{
+ env::var_os("XDG_DATA_HOME")
+ .and_then(is_absolute_path)
+ .or_else(|| home_dir().map(|h| h.join(".local/share")))
+}
+
+/// Returns the path to the directory within the data dir
+pub fn data_path(path: P) -> Option
+ where P: AsRef
+{
+ data_dir().map(|dir| {
+ dir.join(path.as_ref())
+ })
+}
diff --git a/tests/eek-simple-test.c b/tests/eek-simple-test.c
deleted file mode 100644
index 33f2a151..00000000
--- a/tests/eek-simple-test.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Daiki Ueno
- * Copyright (C) 2010-2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-#include "eek/eek.h"
-
-#include
-
-static void
-test_create (void)
-{
- EekBounds bounds = {0};
- struct squeek_view *view = squeek_view_new(bounds);
- struct squeek_button *button0, *button1;
-
- struct squeek_row *row = squeek_view_create_row (view, 0);
- g_assert (row);
- button0 = squeek_row_create_button (row, 1, 0);
- g_assert (button0);
- button1 = squeek_row_create_button (row, 2, 0);
- g_assert (button1);
-}
-
-int
-main (int argc, char **argv)
-{
- g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/eek-simple-test/create", test_create);
- return g_test_run ();
-}
diff --git a/tests/eek-xml-test.c b/tests/eek-xml-test.c
deleted file mode 100644
index f21872c4..00000000
--- a/tests/eek-xml-test.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Daiki Ueno
- * Copyright (C) 2010-2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-/* For gdk_x11_display_get_xdisplay(). See main(). */
-#include
-
-#include "config.h"
-
-#include "eek/eek.h"
-#include "eek/eek-xml-layout.h"
-
-static void
-test_output_parse (void)
-{
- EekLayout *layout;
- LevelKeyboard *keyboard;
- GError *error;
-
- error = NULL;
- layout = eek_xml_layout_new ("us", &error);
- g_assert_no_error (error);
-
- /* We don't need the context service to parse an XML file, so we can pass
- NULL when creating a keyboard. */
- keyboard = eek_xml_layout_real_create_keyboard(layout, NULL);
- g_object_unref (layout);
- level_keyboard_free(keyboard);
-}
-
-int
-main (int argc, char **argv)
-{
- g_test_init (&argc, &argv, NULL);
-
- g_test_add_func ("/eek-xml-test/output-parse", test_output_parse);
-
- return g_test_run ();
-}
diff --git a/tests/layout.yaml b/tests/layout.yaml
new file mode 100644
index 00000000..a33121b6
--- /dev/null
+++ b/tests/layout.yaml
@@ -0,0 +1,17 @@
+---
+bounds:
+ x: 0
+ y: 0
+ width: 0
+ height: 0
+views:
+ base:
+ - "test"
+outlines:
+ default:
+ corner_radius: 1
+ bounds: { x: 0, y: 0, width: 0, height: 0 }
+
+buttons:
+ test:
+ label: "test"
diff --git a/tests/layout2.yaml b/tests/layout2.yaml
new file mode 100644
index 00000000..1a824a21
--- /dev/null
+++ b/tests/layout2.yaml
@@ -0,0 +1,12 @@
+---
+# missing views
+bounds:
+ x: 0
+ y: 0
+ width: 0
+ height: 0
+outlines:
+ default:
+ corner_radius: 1
+ bounds: { x: 0, y: 0, width: 0, height: 0 }
+
diff --git a/tests/layout3.yaml b/tests/layout3.yaml
new file mode 100644
index 00000000..5dd944ce
--- /dev/null
+++ b/tests/layout3.yaml
@@ -0,0 +1,16 @@
+---
+# extra field
+bounds:
+ x: 0
+ y: 0
+ width: 0
+ height: 0
+views:
+ base:
+ - "test"
+outlines:
+ default:
+ corner_radius: 1
+ bounds: { x: 0, y: 0, width: 0, height: 0 }
+
+bad_field: false
diff --git a/tests/meson.build b/tests/meson.build
index 50b39f7f..8b33f55e 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -20,8 +20,6 @@ test_link_args = [
]
tests = [
- 'eek-simple-test',
- 'eek-xml-test',
'test-keymap-generation'
]
diff --git a/tests/test-keymap-generation.c b/tests/test-keymap-generation.c
index e6a5af56..4aadf8e5 100644
--- a/tests/test-keymap-generation.c
+++ b/tests/test-keymap-generation.c
@@ -25,22 +25,16 @@
#include "config.h"
-#include "eek/eek.h"
#include "eek/eek-xml-layout.h"
+#include "eek/eek-keyboard.h"
+
+#include "src/layout.h"
static void
test_check_xkb (void)
{
- EekLayout *layout;
- LevelKeyboard *keyboard;
- GError *error;
-
- error = NULL;
- layout = eek_xml_layout_new ("us", &error);
- g_assert_no_error (error);
-
- keyboard = eek_xml_layout_real_create_keyboard(layout, NULL);
- gchar *keymap_str = eek_keyboard_get_keymap(keyboard);
+ LevelKeyboard *keyboard = eek_xml_layout_real_create_keyboard("us", NULL);
+ const gchar *keymap_str = squeek_layout_get_keymap(keyboard->layout);
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!context) {
@@ -50,14 +44,11 @@ test_check_xkb (void)
struct xkb_keymap *keymap = xkb_keymap_new_from_string(context, keymap_str,
XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
- free(keymap_str);
-
xkb_context_unref(context);
if (!keymap) {
g_error("Bad keymap");
}
- g_object_unref (layout);
level_keyboard_free(keyboard);
}