[libdazzle] tests: ensure shortcuts are loaded and merged



commit 1f5d880abe6d2f9efdad5a73eadd5ede450d070f
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jun 13 21:45:36 2017 -0700

    tests: ensure shortcuts are loaded and merged

 tests/data/shortcuts/0/shortcuts/default.keytheme  |    6 +++
 .../data/shortcuts/0/shortcuts/secondary.keytheme  |    6 +++
 tests/test-shortcut-overlays.c                     |   42 +++++++++++++++-----
 3 files changed, 44 insertions(+), 10 deletions(-)
---
diff --git a/tests/data/shortcuts/0/shortcuts/default.keytheme 
b/tests/data/shortcuts/0/shortcuts/default.keytheme
new file mode 100644
index 0000000..d442124
--- /dev/null
+++ b/tests/data/shortcuts/0/shortcuts/default.keytheme
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<theme name="default">
+  <property name="title">Default</property>
+  <property name="subtitle">The default theme</property>
+  <shortcut accelerator="<Control>f" command="a.b.c.a"/>
+</theme>
diff --git a/tests/data/shortcuts/0/shortcuts/secondary.keytheme 
b/tests/data/shortcuts/0/shortcuts/secondary.keytheme
new file mode 100644
index 0000000..acd63b4
--- /dev/null
+++ b/tests/data/shortcuts/0/shortcuts/secondary.keytheme
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<theme name="secondary" parent="default">
+  <property name="title">Secondary</property>
+
+  <shortcut accelerator="<Control>f" command="a.b.c.b"/>
+</theme>
diff --git a/tests/test-shortcut-overlays.c b/tests/test-shortcut-overlays.c
index e585a10..73e264c 100644
--- a/tests/test-shortcut-overlays.c
+++ b/tests/test-shortcut-overlays.c
@@ -1,15 +1,7 @@
 #include <dazzle.h>
 
 static void
-on_startup (DzlApplication *app)
-{
-  dzl_application_add_resources (app, TEST_DATA_DIR"/shortcuts/0");
-  dzl_application_add_resources (app, TEST_DATA_DIR"/shortcuts/1");
-  dzl_application_add_resources (app, TEST_DATA_DIR"/shortcuts/2");
-}
-
-static void
-on_activate (DzlApplication *app)
+ensure_menu_merging (DzlApplication *app)
 {
   g_autofree gchar *id1 = NULL;
   g_autofree gchar *id2 = NULL;
@@ -56,6 +48,32 @@ on_activate (DzlApplication *app)
   g_assert_cmpstr (id3, ==, "section-4-item-1");
 }
 
+static void
+ensure_keybinding_merging (DzlApplication *app)
+{
+  DzlShortcutManager *manager;
+  DzlShortcutTheme *theme;
+
+  g_assert (DZL_IS_APPLICATION (app));
+
+  manager = dzl_application_get_shortcut_manager (app);
+  g_assert (DZL_IS_SHORTCUT_MANAGER (manager));
+
+  theme = dzl_shortcut_manager_get_theme_by_name (manager, "default");
+  g_assert (DZL_IS_SHORTCUT_THEME (theme));
+
+  theme = dzl_shortcut_manager_get_theme_by_name (manager, "secondary");
+  g_assert (DZL_IS_SHORTCUT_THEME (theme));
+  g_assert_cmpstr (dzl_shortcut_theme_get_parent_name (theme), ==, "default");
+}
+
+static void
+on_activate (DzlApplication *app)
+{
+  ensure_menu_merging (app);
+  ensure_keybinding_merging (app);
+}
+
 gint
 main (gint   argc,
       gchar *argv[])
@@ -67,8 +85,12 @@ main (gint   argc,
                       "flags", G_APPLICATION_NON_UNIQUE,
                       NULL);
 
+  /* Queue resource adding, which will happen for real during startup */
+  dzl_application_add_resources (app, TEST_DATA_DIR"/shortcuts/0");
+  dzl_application_add_resources (app, TEST_DATA_DIR"/shortcuts/1");
+  dzl_application_add_resources (app, TEST_DATA_DIR"/shortcuts/2");
+
   g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
-  g_signal_connect (app, "startup", G_CALLBACK (on_startup), NULL);
 
   return g_application_run (G_APPLICATION (app), argc, argv);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]