aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--po/indicator-keyboard.pot2
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/main.vala118
3 files changed, 113 insertions, 10 deletions
diff --git a/po/indicator-keyboard.pot b/po/indicator-keyboard.pot
index 2bd8feb7..3870550e 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-07-03 15:08-0400\n"
+"POT-Creation-Date: 2013-07-03 15:47-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/Makefile.am b/tests/Makefile.am
index ccb6f472..59cd0e3e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,8 +4,7 @@ check_PROGRAMS = indicator-keyboard-test
AM_CFLAGS = -w
AM_LDFLAGS = -lm
-AM_VALAFLAGS = --enable-experimental-non-null \
- --metadatadir $(top_srcdir)/deps \
+AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \
--vapidir $(top_srcdir)/deps
indicator_keyboard_test_SOURCES = main.vala \
diff --git a/tests/main.vala b/tests/main.vala
index 64ed7a74..96214071 100644
--- a/tests/main.vala
+++ b/tests/main.vala
@@ -129,16 +129,30 @@ static void test_activate_input_source (void *data) {
return;
}
+ var loop = new MainLoop (null, false);
+
var action_group = DBusActionGroup.get ((!) fixture.connection,
"com.canonical.indicator.keyboard",
"/com/canonical/indicator/keyboard");
+ var signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
+ loop.quit ();
+ });
+ action_group.list_actions ();
action_group.activate_action ("current", new Variant.uint32 (2));
- Posix.sleep (TIMEOUT_S);
+
+ var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
+ loop.run ();
+ Source.remove (source);
+ action_group.disconnect (signal_name);
+
+ var state = action_group.get_action_state ("current");
+ var current = state.get_uint32 ();
+ assert (current == 2);
try {
- string current;
- Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out current);
- assert (strcmp (current, "uint32 2\n") == 0);
+ string output;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
+ assert (strcmp (output, "uint32 2\n") == 0);
} catch (SpawnError error) {
Test.message ("error: %s", error.message);
Test.fail ();
@@ -401,7 +415,7 @@ static void test_update_visible (void *data) {
action_group.disconnect (signal_name);
var state = action_group.get_action_state ("indicator");
- assert (((!) state).lookup ("visible", "b", out visible));
+ assert (state.lookup ("visible", "b", out visible));
assert (visible);
loop = new MainLoop (null, false);
@@ -424,7 +438,7 @@ static void test_update_visible (void *data) {
action_group.disconnect (signal_name);
state = action_group.get_action_state ("indicator");
- assert (((!) state).lookup ("visible", "b", out visible));
+ assert (state.lookup ("visible", "b", out visible));
assert (!visible);
loop = new MainLoop (null, false);
@@ -447,11 +461,101 @@ static void test_update_visible (void *data) {
action_group.disconnect (signal_name);
state = action_group.get_action_state ("indicator");
- assert (((!) state).lookup ("visible", "b", out visible));
+ assert (state.lookup ("visible", "b", out visible));
assert (visible);
}
static void test_update_input_source (void *data) {
+ var fixture = (Fixture *) data;
+
+ if (fixture.object_name == 0) {
+ Test.message ("error: Test fixture not initialized.");
+ Test.fail ();
+ return;
+ }
+
+ try {
+ var current = 0;
+ 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 loop = new MainLoop (null, false);
+
+ var action_group = DBusActionGroup.get ((!) fixture.connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard");
+ var signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
+ loop.quit ();
+ });
+ action_group.list_actions ();
+
+ try {
+ var current = 1;
+ Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
+
+ var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
+ loop.run ();
+ Source.remove (source);
+ action_group.disconnect (signal_name);
+
+ var state = action_group.get_action_state ("current");
+ var current = state.get_uint32 ();
+ assert (current == 1);
+
+ try {
+ string output;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
+ assert (strcmp (output, "uint32 1\n") == 0);
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
+
+ loop = new MainLoop (null, false);
+
+ signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
+ loop.quit ();
+ });
+
+ try {
+ current = 0;
+ Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
+
+ source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
+ loop.run ();
+ Source.remove (source);
+ action_group.disconnect (signal_name);
+
+ state = action_group.get_action_state ("current");
+ current = state.get_uint32 ();
+ assert (current == 0);
+
+ try {
+ string output;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
+ assert (strcmp (output, "uint32 0\n") == 0);
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
}
static void test_update_input_sources (void *data) {