aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-07-02 09:10:50 -0400
committerWilliam Hua <william.hua@canonical.com>2013-07-02 09:10:50 -0400
commit607a5dee7f61a0ad46efd5071ddc195db56ec367 (patch)
tree8dd09c55a110a5f208364df7c4bcf777e851655b
parentdb0ebaa3de76091a9b3ad2dbb6823172ae06f7fe (diff)
downloadayatana-indicator-keyboard-607a5dee7f61a0ad46efd5071ddc195db56ec367.tar.gz
ayatana-indicator-keyboard-607a5dee7f61a0ad46efd5071ddc195db56ec367.tar.bz2
ayatana-indicator-keyboard-607a5dee7f61a0ad46efd5071ddc195db56ec367.zip
Repair test fixtures.
-rw-r--r--Makefile.am2
-rw-r--r--debian/changelog1
-rw-r--r--po/indicator-keyboard.pot2
l---------tests/execute/gnome-control-center1
l---------tests/execute/gucharmap1
-rw-r--r--tests/main.vala198
-rw-r--r--tests/profiles/indicator-keyboard-test2
7 files changed, 187 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am
index b19f3988..c0d4a471 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,3 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = po lib data
+SUBDIRS = po lib data tests
diff --git a/debian/changelog b/debian/changelog
index 89c2c0e5..d0d98251 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
indicator-keyboard (0.0.0-0ubuntu18) UNRELEASED; urgency=low
* Add indicator schema.
+ * Repair test fixtures.
-- William Hua <william.hua@canonical.com> Mon, 01 Jul 2013 10:21:40 -0400
diff --git a/po/indicator-keyboard.pot b/po/indicator-keyboard.pot
index 841cb42f..b8e5d4b4 100644
--- a/po/indicator-keyboard.pot
+++ b/po/indicator-keyboard.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-06-27 11:04-0400\n"
+"POT-Creation-Date: 2013-07-02 08:19-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
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