diff options
author | William Hua <william.hua@canonical.com> | 2013-07-02 09:10:50 -0400 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2013-07-02 09:10:50 -0400 |
commit | 607a5dee7f61a0ad46efd5071ddc195db56ec367 (patch) | |
tree | 8dd09c55a110a5f208364df7c4bcf777e851655b /tests | |
parent | db0ebaa3de76091a9b3ad2dbb6823172ae06f7fe (diff) | |
download | ayatana-indicator-keyboard-607a5dee7f61a0ad46efd5071ddc195db56ec367.tar.gz ayatana-indicator-keyboard-607a5dee7f61a0ad46efd5071ddc195db56ec367.tar.bz2 ayatana-indicator-keyboard-607a5dee7f61a0ad46efd5071ddc195db56ec367.zip |
Repair test fixtures.
Diffstat (limited to 'tests')
l--------- | tests/execute/gnome-control-center | 1 | ||||
l--------- | tests/execute/gucharmap | 1 | ||||
-rw-r--r-- | tests/main.vala | 198 | ||||
-rw-r--r-- | tests/profiles/indicator-keyboard-test | 2 |
4 files changed, 184 insertions, 18 deletions
diff --git a/tests/execute/gnome-control-center b/tests/execute/gnome-control-center new file mode 120000 index 00000000..849e205e --- /dev/null +++ b/tests/execute/gnome-control-center @@ -0,0 +1 @@ +com.canonical.indicator.keyboard.test.Execute
\ No newline at end of file diff --git a/tests/execute/gucharmap b/tests/execute/gucharmap new file mode 120000 index 00000000..849e205e --- /dev/null +++ b/tests/execute/gucharmap @@ -0,0 +1 @@ +com.canonical.indicator.keyboard.test.Execute
\ No newline at end of file diff --git a/tests/main.vala b/tests/main.vala index b606121f..350a3bf5 100644 --- a/tests/main.vala +++ b/tests/main.vala @@ -121,11 +121,6 @@ static void test_activate_character_map (void *data) { return; } - /* XXX: bootstrap the settings with what we want to test with. */ - var settings = new Settings ("org.gnome.desktop.input-sources"); - settings.set_uint ("current", 0); - settings.set_value ("sources", new Variant.parsed ("[('xkb', 'us'), ('ibus', 'pinyin')]")); - var cancellable = new Cancellable (); DBusProxy action_proxy; DBusProxy menu_proxy; @@ -178,16 +173,102 @@ static void test_activate_character_map (void *data) { return; } - /* XXX: This is just to make sure the GSettings are shared between processes. */ - { - var builder = new VariantBuilder (new VariantType ("(au)")); - builder.open (new VariantType ("au")); - builder.add ("u", 0); - builder.add ("u", 1); - builder.close (); - var variant = builder.end (); - stdout.printf ("%s\n", menu_proxy.call_sync ("Start", variant, DBusCallFlags.NONE, SHORT_TIMEOUT).print (true)); - menu_proxy.call_sync ("End", variant, DBusCallFlags.NONE, SHORT_TIMEOUT); + var loop = new MainLoop (null, false); + + var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { + loop.quit (); + }); + + try { + var builder = new VariantBuilder (new VariantType ("(sava{sv})")); + builder.add ("s", "map"); + builder.add_value (new Variant.parsed ("@av []")); + builder.add_value (new Variant.parsed ("@a{sv} {}")); + action_proxy.call_sync ("Activate", builder.end (), DBusCallFlags.NONE, SHORT_TIMEOUT); + } catch (Error error) { + Test.message ("error: %s", error.message); + Test.fail (); + return; + } + + source = Timeout.add_seconds (LONG_TIMEOUT, () => { loop.quit (); return false; }); + loop.run (); + Source.remove (source); + ((!) fixture.service).disconnect (signal_name); + + assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0); +} + +static void test_activate_keyboard_layout_chart (void *data) { + var fixture = (Fixture *) data; + + if (fixture.object_name == 0) { + Test.message ("Invalid test fixture."); + Test.fail (); + return; + } + + try { + var current = 1; + var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; + Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); + Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); + } catch (SpawnError error) { + Test.message ("error: %s", error.message); + Test.fail (); + return; + } + + var cancellable = new Cancellable (); + DBusProxy action_proxy; + DBusProxy menu_proxy; + + var source = Timeout.add_seconds (LONG_TIMEOUT, () => { cancellable.cancel (); return false; }); + + try { + action_proxy = new DBusProxy.for_bus_sync (BusType.SESSION, + DBusProxyFlags.NONE, + null, + "com.canonical.indicator.keyboard", + "/com/canonical/indicator/keyboard", + "org.gtk.Actions", + cancellable); + } catch (Error error) { + Test.message ("error: %s", error.message); + Test.fail (); + return; + } + + Source.remove (source); + + if (cancellable.is_cancelled ()) { + Test.message ("Unable to connect to 'com.canonical.indicator.keyboard'.\n"); + Test.fail (); + return; + } + + source = Timeout.add_seconds (LONG_TIMEOUT, () => { cancellable.cancel (); return false; }); + + try { + menu_proxy = new DBusProxy.for_bus_sync (BusType.SESSION, + DBusProxyFlags.NONE, + null, + "com.canonical.indicator.keyboard", + "/com/canonical/indicator/keyboard/desktop", + "org.gtk.Menus", + cancellable); + } catch (Error error) { + Test.message ("error: %s", error.message); + Test.fail (); + return; + } + + Source.remove (source); + + if (cancellable.is_cancelled ()) { + Test.message ("Unable to connect to 'com.canonical.indicator.keyboard'.\n"); + Test.fail (); + return; } var loop = new MainLoop (null, false); @@ -212,12 +293,95 @@ static void test_activate_character_map (void *data) { loop.run (); Source.remove (source); ((!) fixture.service).disconnect (signal_name); -} -static void test_activate_keyboard_layout_chart (void *data) { + assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0); } static void test_activate_text_entry_settings (void *data) { + var fixture = (Fixture *) data; + + if (fixture.object_name == 0) { + Test.message ("Invalid test fixture."); + Test.fail (); + return; + } + + var cancellable = new Cancellable (); + DBusProxy action_proxy; + DBusProxy menu_proxy; + + var source = Timeout.add_seconds (LONG_TIMEOUT, () => { cancellable.cancel (); return false; }); + + try { + action_proxy = new DBusProxy.for_bus_sync (BusType.SESSION, + DBusProxyFlags.NONE, + null, + "com.canonical.indicator.keyboard", + "/com/canonical/indicator/keyboard", + "org.gtk.Actions", + cancellable); + } catch (Error error) { + Test.message ("error: %s", error.message); + Test.fail (); + return; + } + + Source.remove (source); + + if (cancellable.is_cancelled ()) { + Test.message ("Unable to connect to 'com.canonical.indicator.keyboard'.\n"); + Test.fail (); + return; + } + + source = Timeout.add_seconds (LONG_TIMEOUT, () => { cancellable.cancel (); return false; }); + + try { + menu_proxy = new DBusProxy.for_bus_sync (BusType.SESSION, + DBusProxyFlags.NONE, + null, + "com.canonical.indicator.keyboard", + "/com/canonical/indicator/keyboard/desktop", + "org.gtk.Menus", + cancellable); + } catch (Error error) { + Test.message ("error: %s", error.message); + Test.fail (); + return; + } + + Source.remove (source); + + if (cancellable.is_cancelled ()) { + Test.message ("Unable to connect to 'com.canonical.indicator.keyboard'.\n"); + Test.fail (); + return; + } + + var loop = new MainLoop (null, false); + + var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { + loop.quit (); + }); + + try { + var builder = new VariantBuilder (new VariantType ("(sava{sv})")); + builder.add ("s", "settings"); + builder.add_value (new Variant.parsed ("@av []")); + builder.add_value (new Variant.parsed ("@a{sv} {}")); + action_proxy.call_sync ("Activate", builder.end (), DBusCallFlags.NONE, SHORT_TIMEOUT); + } catch (Error error) { + Test.message ("error: %s", error.message); + Test.fail (); + return; + } + + source = Timeout.add_seconds (LONG_TIMEOUT, () => { loop.quit (); return false; }); + loop.run (); + Source.remove (source); + ((!) fixture.service).disconnect (signal_name); + + assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0); } static void test_update_input_source (void *data) { diff --git a/tests/profiles/indicator-keyboard-test b/tests/profiles/indicator-keyboard-test index 87f5ecb0..5268b3f5 100644 --- a/tests/profiles/indicator-keyboard-test +++ b/tests/profiles/indicator-keyboard-test @@ -1 +1 @@ -service-db:shm/indicator/keyboard/test +service-db:shm/indicator_keyboard_test |