aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2014-01-29 16:40:39 +0000
committerTarmac <Unknown>2014-01-29 16:40:39 +0000
commit0828bc2dc4851698d8f42f84ec277ab568687318 (patch)
tree8086a99223c44b15302d5433cc30df594859c697
parentd1d2cc4c5084fe4745db725d1c5515885a603739 (diff)
parent393bc45087de952438a54f851ca449b8fe2cd10f (diff)
downloadayatana-indicator-keyboard-0828bc2dc4851698d8f42f84ec277ab568687318.tar.gz
ayatana-indicator-keyboard-0828bc2dc4851698d8f42f84ec277ab568687318.tar.bz2
ayatana-indicator-keyboard-0828bc2dc4851698d8f42f84ec277ab568687318.zip
Fix tests by restoring DISPLAY's value.
Approved by Lars Uebernickel, PS Jenkins bot.
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/fixture.vala125
-rw-r--r--tests/main.vala1073
3 files changed, 628 insertions, 573 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index da083318..f3be1539 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,7 +8,8 @@ AM_LDFLAGS = -lm
AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \
--vapidir $(top_srcdir)/deps
-indicator_keyboard_tests_SOURCES = main.vala \
+indicator_keyboard_tests_SOURCES = main.vala \
+ fixture.vala \
config.vala
indicator_keyboard_tests_VALAFLAGS = $(AM_VALAFLAGS) \
--pkg gio-2.0
diff --git a/tests/fixture.vala b/tests/fixture.vala
new file mode 100644
index 00000000..7adc434f
--- /dev/null
+++ b/tests/fixture.vala
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by Michal Hruby <michal.hruby@canonical.com>
+ *
+ * This file is taken from libunity.
+ */
+
+/* A bit of magic to get proper-ish fixture support */
+public interface Fixture : Object
+{
+ class DelegateWrapper
+ {
+ TestDataFunc func;
+ public DelegateWrapper (owned TestDataFunc f) { func = (owned) f; }
+ }
+
+ public virtual void setup () {}
+ public virtual void teardown () {}
+
+ [CCode (has_target = false)]
+ public delegate void Callback<T> (T ptr);
+
+ private static List<DelegateWrapper> _tests;
+
+ public static unowned TestDataFunc create<F> (Callback<void*> cb)
+ requires (typeof (F).is_a (typeof (Fixture)))
+ {
+ TestDataFunc functor = () =>
+ {
+ var type = typeof (F);
+ var instance = Object.new (type) as Fixture;
+ instance.setup ();
+ cb (instance);
+ instance.teardown ();
+ };
+ unowned TestDataFunc copy = functor;
+ _tests.append (new DelegateWrapper ((owned) functor));
+ return copy;
+ }
+ public static unowned TestDataFunc create_static<F> (Callback<F> cb)
+ {
+ return create<F> ((Callback<void*>) cb);
+ }
+}
+
+public static bool run_with_timeout (MainLoop ml, uint timeout_ms = 5000)
+{
+ bool timeout_reached = false;
+ var t_id = Timeout.add (timeout_ms, () =>
+ {
+ timeout_reached = true;
+ debug ("Timeout reached");
+ ml.quit ();
+ return false;
+ });
+
+ ml.run ();
+
+ if (!timeout_reached) Source.remove (t_id);
+
+ return !timeout_reached;
+}
+
+/* calling this will ensure that the object was destroyed, but note that
+ * it needs to be called with the (owned) modifier */
+public static void ensure_destruction (owned Object obj)
+{
+ var ml = new MainLoop ();
+ bool destroyed = false;
+ obj.weak_ref (() => { destroyed = true; ml.quit (); });
+
+ obj = null;
+ if (!destroyed)
+ {
+ // wait a bit if there were async operations
+ assert (run_with_timeout (ml));
+ }
+}
+
+public class ErrorHandler
+{
+ public ErrorHandler ()
+ {
+ GLib.Test.log_set_fatal_handler (handle_fatal_func);
+ }
+
+ private bool handle_fatal_func (string? log_domain, LogLevelFlags flags,
+ string message)
+ {
+ return false;
+ }
+
+ private uint[] handler_ids;
+ private GenericArray<string?> handler_domains;
+
+ public void ignore_message (string? domain, LogLevelFlags flags)
+ {
+ handler_ids += Log.set_handler (domain, flags | LogLevelFlags.FLAG_FATAL,
+ () => {});
+ if (handler_domains == null)
+ {
+ handler_domains = new GenericArray<string?> ();
+ }
+ handler_domains.add (domain);
+ }
+
+ ~ErrorHandler ()
+ {
+ for(uint i = 0; i < handler_ids.length; i++)
+ Log.remove_handler (handler_domains[i], handler_ids[i]);
+ }
+}
diff --git a/tests/main.vala b/tests/main.vala
index 1a7833a2..d84de7ee 100644
--- a/tests/main.vala
+++ b/tests/main.vala
@@ -20,6 +20,8 @@ const int TIMEOUT_S = 1;
const int TIMEOUT_MS = 1000;
const int LONG_TIMEOUT_S = 10;
+static string display;
+
[DBus (name = "com.canonical.indicator.keyboard.test")]
public class Service : Object {
@@ -42,676 +44,603 @@ public class Service : Object {
}
}
-struct Fixture {
- TestDBus? bus;
- uint service_name;
- DBusConnection? connection;
- Service? service;
- uint object_name;
-}
+public class Tests : Object, Fixture {
+
+ private TestDBus? _bus;
+ private uint _service_name;
+ private DBusConnection? _connection;
+ private Service? _service;
+ private uint _object_name;
+
+ public void start_service () {
+ if (_connection != null) {
+ try {
+ _service = new Service ();
+ _object_name = ((!) _connection).register_object ("/com/canonical/indicator/keyboard/test", _service);
+ } catch (IOError error) {
+ _connection = null;
+ _service = null;
+ _object_name = 0;
+
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ }
+ }
+ }
-static void start_service (Fixture *fixture) {
- if (fixture.connection != null) {
- try {
- fixture.service = new Service ();
- fixture.object_name = ((!) fixture.connection).register_object ("/com/canonical/indicator/keyboard/test", fixture.service);
- } catch (IOError error) {
- fixture.connection = null;
- fixture.service = null;
- fixture.object_name = 0;
+ public void setup () {
+ Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true);
+ Environment.set_variable ("DISPLAY", display, true);
+ Environment.set_variable ("LC_ALL", "C", true);
+
+ _bus = new TestDBus (TestDBusFlags.NONE);
+ ((!) _bus).add_service_dir (SERVICE_DIR);
+ ((!) _bus).up ();
+
+ var loop = new MainLoop (null, false);
+
+ _service_name = Bus.own_name (BusType.SESSION,
+ "com.canonical.indicator.keyboard.test",
+ BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE,
+ (connection, name) => {
+ if (loop.is_running ()) {
+ _connection = connection;
+ start_service ();
+ loop.quit ();
+ }
+ },
+ null,
+ (connection, name) => {
+ if (loop.is_running ()) {
+ _connection = null;
+ _service = null;
+ _object_name = 0;
+ loop.quit ();
+ }
+ });
+
+ loop.run ();
+
+ if (_connection == null) {
+ Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test.");
+ Test.fail ();
+ }
- Test.message ("error: %s", error.message);
+ if (_object_name == 0) {
+ Test.message ("error: Test fixture not initialized.");
Test.fail ();
+ return;
}
}
-}
-static void begin_test (void *data) {
- var fixture = (Fixture *) data;
+ public void teardown () {
+ if (_object_name != 0) {
+ ((!) _connection).unregister_object (_object_name);
+ _object_name = 0;
+ }
- fixture.bus = new TestDBus (TestDBusFlags.NONE);
- ((!) fixture.bus).add_service_dir (SERVICE_DIR);
- ((!) fixture.bus).up ();
+ if (_service_name != 0) {
+ Bus.unown_name (_service_name);
+ _service_name = 0;
+ }
- var loop = new MainLoop (null, false);
+ _service = null;
+ _connection = null;
- fixture.service_name = Bus.own_name (BusType.SESSION,
- "com.canonical.indicator.keyboard.test",
- BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE,
- (connection, name) => {
- if (loop.is_running ()) {
- fixture.connection = connection;
+ if (_bus != null) {
+ ((!) _bus).down ();
+ _bus = null;
+ }
+ }
- start_service (fixture);
+ public void test_activate_input_source () {
+ 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;
+ }
- loop.quit ();
- }
- },
- null,
- (connection, name) => {
- if (loop.is_running ()) {
- fixture.connection = null;
- fixture.service = null;
- fixture.object_name = 0;
+ var action_group = DBusActionGroup.get ((!) _connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard");
+ action_group.list_actions ();
+ action_group.activate_action ("current", new Variant.uint32 (2));
- loop.quit ();
- }
- });
+ var loop = new MainLoop (null, false);
+ Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
+ loop.run ();
- loop.run ();
+ var state = action_group.get_action_state ("current");
+ var current = state.get_uint32 ();
+ stderr.printf ("current = %u\n", current);
+ assert (current == 2);
- if (fixture.connection == null) {
- Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test.");
- Test.fail ();
+ try {
+ string output;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
+ stderr.printf ("output = \"%s\"\n", output);
+ assert (strcmp (output, "uint32 2\n") == 0);
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
}
-}
-static void end_test (void *data) {
- var fixture = (Fixture *) data;
+ public void test_activate_character_map () {
+ var action_group = DBusActionGroup.get ((!) _connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard");
+ var loop = new MainLoop (null, false);
+ var signal_name = ((!) _service).notify["command"].connect ((pspec) => {
+ loop.quit ();
+ });
- if (fixture.object_name != 0) {
- ((!) fixture.connection).unregister_object (fixture.object_name);
- fixture.object_name = 0;
- }
+ action_group.activate_action ("map", null);
- if (fixture.service_name != 0) {
- Bus.unown_name (fixture.service_name);
- fixture.service_name = 0;
+ var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ ((!) _service).disconnect (signal_name);
+
+ stderr.printf ("_service.command = \"%s\"\n", (!) ((!) _service).command);
+ assert (strcmp ((!) ((!) _service).command, "'gucharmap '") == 0);
}
- fixture.service = null;
- fixture.connection = null;
+ public void test_activate_keyboard_layout_chart () {
+ 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;
+ }
- if (fixture.bus != null) {
- ((!) fixture.bus).down ();
- fixture.bus = null;
- }
-}
+ var action_group = DBusActionGroup.get ((!) _connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard");
+ var loop = new MainLoop (null, false);
+ var signal_name = ((!) _service).notify["command"].connect ((pspec) => {
+ loop.quit ();
+ });
-static void test_activate_input_source (void *data) {
- var fixture = (Fixture *) data;
+ action_group.activate_action ("chart", null);
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ ((!) _service).disconnect (signal_name);
- 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;
+ stderr.printf ("_service.command = \"%s\"\n", (!) ((!) _service).command);
+ assert (strcmp ((!) ((!) _service).command, "'gkbd-keyboard-display -l ca\teng'") == 0);
}
- var action_group = DBusActionGroup.get ((!) fixture.connection,
- "com.canonical.indicator.keyboard",
- "/com/canonical/indicator/keyboard");
- action_group.list_actions ();
- action_group.activate_action ("current", new Variant.uint32 (2));
-
- var loop = new MainLoop (null, false);
- Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
-
- var state = action_group.get_action_state ("current");
- var current = state.get_uint32 ();
- stderr.printf ("current = %u\n", current);
- assert (current == 2);
-
- try {
- string output;
- Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
- stderr.printf ("output = \"%s\"\n", output);
- assert (strcmp (output, "uint32 2\n") == 0);
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
-}
+ public void test_activate_text_entry_settings () {
+ var action_group = DBusActionGroup.get ((!) _connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard");
+ var loop = new MainLoop (null, false);
+ var signal_name = ((!) _service).notify["command"].connect ((pspec) => {
+ loop.quit ();
+ });
-static void test_activate_character_map (void *data) {
- var fixture = (Fixture *) data;
+ action_group.activate_action ("settings", null);
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ ((!) _service).disconnect (signal_name);
- var action_group = DBusActionGroup.get ((!) fixture.connection,
- "com.canonical.indicator.keyboard",
- "/com/canonical/indicator/keyboard");
- var loop = new MainLoop (null, false);
- var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
- loop.quit ();
- });
+ stderr.printf ("_service.command = \"%s\"\n", (!) ((!) _service).command);
+ assert (strcmp ((!) ((!) _service).command, "'gnome-control-center region layouts'") == 0);
+ }
- action_group.activate_action ("map", null);
+ public void test_migration () {
+ try {
+ var migrated = false;
+ var sources = "[('xkb', 'us')]";
+ var layouts = "['us', 'ca\teng', 'epo']";
+ Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
+ Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
+ Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
- var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- ((!) fixture.service).disconnect (signal_name);
+ try {
+ var cancellable = new Cancellable ();
- stderr.printf ("fixture.service.command = \"%s\"\n", (!) ((!) fixture.service).command);
- assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0);
-}
+ var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { cancellable.cancel (); return true; });
-static void test_activate_keyboard_layout_chart (void *data) {
- var fixture = (Fixture *) data;
+ var dbus_proxy = new DBusProxy.sync ((!) _connection,
+ DBusProxyFlags.NONE,
+ null,
+ "org.freedesktop.DBus",
+ "/",
+ "org.freedesktop.DBus",
+ cancellable);
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ Source.remove (source);
- 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;
- }
+ if (cancellable.is_cancelled ()) {
+ Test.message ("error: Unable to connect to org.freedesktop.DBus.");
+ Test.fail ();
+ return;
+ }
- var action_group = DBusActionGroup.get ((!) fixture.connection,
- "com.canonical.indicator.keyboard",
- "/com/canonical/indicator/keyboard");
- var loop = new MainLoop (null, false);
- var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
- loop.quit ();
- });
+ dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
+ } catch (Error error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
- action_group.activate_action ("chart", null);
+ var loop = new MainLoop (null, false);
+ Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
+ loop.run ();
- var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- ((!) fixture.service).disconnect (signal_name);
+ try {
+ string sources;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
+ stderr.printf ("sources = \"%s\"\n", sources);
+ assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0);
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
+ }
- stderr.printf ("fixture.service.command = \"%s\"\n", (!) ((!) fixture.service).command);
- assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0);
-}
+ public void test_no_migration () {
+ try {
+ var migrated = true;
+ var sources = "[('xkb', 'us')]";
+ var layouts = "['us', 'ca\teng', 'epo']";
+ Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
+ Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
+ Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
-static void test_activate_text_entry_settings (void *data) {
- var fixture = (Fixture *) data;
+ try {
+ var cancellable = new Cancellable ();
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { cancellable.cancel (); return true; });
- var action_group = DBusActionGroup.get ((!) fixture.connection,
- "com.canonical.indicator.keyboard",
- "/com/canonical/indicator/keyboard");
- var loop = new MainLoop (null, false);
- var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
- loop.quit ();
- });
+ var dbus_proxy = new DBusProxy.sync ((!) _connection,
+ DBusProxyFlags.NONE,
+ null,
+ "org.freedesktop.DBus",
+ "/",
+ "org.freedesktop.DBus",
+ cancellable);
- action_group.activate_action ("settings", null);
+ Source.remove (source);
- var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- ((!) fixture.service).disconnect (signal_name);
+ if (cancellable.is_cancelled ()) {
+ Test.message ("error: Unable to connect to org.freedesktop.DBus.");
+ Test.fail ();
+ return;
+ }
- stderr.printf ("fixture.service.command = \"%s\"\n", (!) ((!) fixture.service).command);
- assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0);
-}
+ dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
+ } catch (Error error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
-static void test_migration (void *data) {
- var fixture = (Fixture *) data;
+ var loop = new MainLoop (null, false);
+ Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
+ loop.run ();
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
+ try {
+ string sources;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
+ stderr.printf ("sources = \"%s\"\n", sources);
+ assert (strcmp (sources, "[('xkb', 'us')]\n") == 0);
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
}
- try {
- var migrated = false;
- var sources = "[('xkb', 'us')]";
- var layouts = "['us', 'ca\teng', 'epo']";
- Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
- Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
- Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
+ public void test_update_visible () {
+ bool visible;
- try {
- var cancellable = new Cancellable ();
+ try {
+ visible = true;
+ Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
- var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { cancellable.cancel (); return false; });
+ var action_group = DBusActionGroup.get ((!) _connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard");
+ var loop = new MainLoop (null, false);
+ var signal_name = action_group.action_added["indicator"].connect ((action) => {
+ loop.quit ();
+ });
- var dbus_proxy = new DBusProxy.sync ((!) fixture.connection,
- DBusProxyFlags.NONE,
- null,
- "org.freedesktop.DBus",
- "/",
- "org.freedesktop.DBus",
- cancellable);
+ action_group.list_actions ();
+ var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
Source.remove (source);
+ action_group.disconnect (signal_name);
- if (cancellable.is_cancelled ()) {
- Test.message ("error: Unable to connect to org.freedesktop.DBus.");
+ var state = action_group.get_action_state ("indicator");
+ assert (state.lookup ("visible", "b", out visible));
+ stderr.printf ("visible = %s\n", visible ? "true" : "false");
+ assert (visible);
+
+ loop = new MainLoop (null, false);
+ signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
+ loop.quit ();
+ });
+
+ try {
+ visible = false;
+ Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
Test.fail ();
return;
}
- dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
- } catch (Error error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
+ source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ action_group.disconnect (signal_name);
- var loop = new MainLoop (null, false);
- Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
-
- try {
- string sources;
- Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
- stderr.printf ("sources = \"%s\"\n", sources);
- assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0);
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
-}
+ state = action_group.get_action_state ("indicator");
+ assert (state.lookup ("visible", "b", out visible));
+ stderr.printf ("visible = %s\n", visible ? "true" : "false");
+ assert (!visible);
-static void test_no_migration (void *data) {
- var fixture = (Fixture *) data;
+ loop = new MainLoop (null, false);
+ signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
+ loop.quit ();
+ });
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ try {
+ visible = true;
+ Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
- try {
- var migrated = true;
- var sources = "[('xkb', 'us')]";
- var layouts = "['us', 'ca\teng', 'epo']";
- Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
- Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
- Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
+ source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ action_group.disconnect (signal_name);
- try {
- var cancellable = new Cancellable ();
+ state = action_group.get_action_state ("indicator");
+ assert (state.lookup ("visible", "b", out visible));
+ stderr.printf ("visible = %s\n", visible ? "true" : "false");
+ assert (visible);
+ }
- var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { cancellable.cancel (); return false; });
+ public void test_update_input_source () {
+ 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 dbus_proxy = new DBusProxy.sync ((!) fixture.connection,
- DBusProxyFlags.NONE,
- null,
- "org.freedesktop.DBus",
- "/",
- "org.freedesktop.DBus",
- cancellable);
+ var action_group = DBusActionGroup.get ((!) _connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard");
+ var loop = new MainLoop (null, false);
+ var signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
+ loop.quit ();
+ });
- Source.remove (source);
+ action_group.list_actions ();
- if (cancellable.is_cancelled ()) {
- Test.message ("error: Unable to connect to org.freedesktop.DBus.");
+ 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;
}
- dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
- } catch (Error error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
+ var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ action_group.disconnect (signal_name);
- var loop = new MainLoop (null, false);
- Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
-
- try {
- string sources;
- Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
- stderr.printf ("sources = \"%s\"\n", sources);
- assert (strcmp (sources, "[('xkb', 'us')]\n") == 0);
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
-}
+ var state = action_group.get_action_state ("current");
+ var current = state.get_uint32 ();
+ stderr.printf ("current = %u\n", current);
+ assert (current == 1);
-static void test_update_visible (void *data) {
- var fixture = (Fixture *) data;
+ try {
+ string output;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
+ stderr.printf ("output = \"%s\"\n", output);
+ assert (strcmp (output, "uint32 1\n") == 0);
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ loop = new MainLoop (null, false);
+ signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
+ loop.quit ();
+ });
- bool visible;
+ 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;
+ }
- try {
- visible = true;
- Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
+ source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ action_group.disconnect (signal_name);
- var action_group = DBusActionGroup.get ((!) fixture.connection,
- "com.canonical.indicator.keyboard",
- "/com/canonical/indicator/keyboard");
- var loop = new MainLoop (null, false);
- var signal_name = action_group.action_added["indicator"].connect ((action) => {
- loop.quit ();
- });
-
- action_group.list_actions ();
-
- var source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- action_group.disconnect (signal_name);
-
- var state = action_group.get_action_state ("indicator");
- assert (state.lookup ("visible", "b", out visible));
- stderr.printf ("visible = %s\n", visible ? "true" : "false");
- assert (visible);
-
- loop = new MainLoop (null, false);
- signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
- loop.quit ();
- });
-
- try {
- visible = false;
- Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
+ state = action_group.get_action_state ("current");
+ current = state.get_uint32 ();
+ stderr.printf ("current = %u\n", current);
+ assert (current == 0);
- source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- action_group.disconnect (signal_name);
-
- state = action_group.get_action_state ("indicator");
- assert (state.lookup ("visible", "b", out visible));
- stderr.printf ("visible = %s\n", visible ? "true" : "false");
- assert (!visible);
-
- loop = new MainLoop (null, false);
- signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
- loop.quit ();
- });
-
- try {
- visible = true;
- Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
+ try {
+ string output;
+ Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
+ stderr.printf ("output = \"%s\"\n", output);
+ assert (strcmp (output, "uint32 0\n") == 0);
+ } catch (SpawnError error) {
+ Test.message ("error: %s", error.message);
+ Test.fail ();
+ return;
+ }
}
- source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- action_group.disconnect (signal_name);
+ public void test_update_input_sources () {
+ try {
+ var current = 0;
+ var sources = "[('xkb', 'us')]";
+ 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;
+ }
- state = action_group.get_action_state ("indicator");
- assert (state.lookup ("visible", "b", out visible));
- stderr.printf ("visible = %s\n", visible ? "true" : "false");
- assert (visible);
-}
+ var menu_model = DBusMenuModel.get ((!) _connection,
+ "com.canonical.indicator.keyboard",
+ "/com/canonical/indicator/keyboard/desktop");
+ var loop = new MainLoop (null, false);
+ var signal_name = menu_model.items_changed.connect ((position, removed, added) => {
+ loop.quit ();
+ });
-static void test_update_input_source (void *data) {
- var fixture = (Fixture *) data;
+ menu_model.get_n_items ();
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ menu_model.disconnect (signal_name);
- 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 menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU);
+ loop = new MainLoop (null, false);
+ signal_name = menu.items_changed.connect ((position, removed, added) => {
+ loop.quit ();
+ });
- var action_group = DBusActionGroup.get ((!) fixture.connection,
- "com.canonical.indicator.keyboard",
- "/com/canonical/indicator/keyboard");
- var loop = new MainLoop (null, false);
- 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;
- }
+ menu.get_n_items ();
- 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 ();
- stderr.printf ("current = %u\n", current);
- assert (current == 1);
-
- try {
- string output;
- Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
- stderr.printf ("output = \"%s\"\n", output);
- assert (strcmp (output, "uint32 1\n") == 0);
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
+ source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ menu.disconnect (signal_name);
- 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;
- }
+ var section = menu.get_item_link (0, Menu.LINK_SECTION);
+ loop = new MainLoop (null, false);
+ signal_name = section.items_changed.connect ((position, removed, added) => {
+ loop.quit ();
+ });
- source = Timeout.add_seconds (LONG_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 ();
- stderr.printf ("current = %u\n", current);
- assert (current == 0);
-
- try {
- string output;
- Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
- stderr.printf ("output = \"%s\"\n", output);
- assert (strcmp (output, "uint32 0\n") == 0);
- } catch (SpawnError error) {
- Test.message ("error: %s", error.message);
- Test.fail ();
- return;
- }
-}
+ section.get_n_items ();
-static void test_update_input_sources (void *data) {
- var fixture = (Fixture *) data;
+ source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ section.disconnect (signal_name);
- if (fixture.object_name == 0) {
- Test.message ("error: Test fixture not initialized.");
- Test.fail ();
- return;
- }
+ string label;
- try {
- var current = 0;
- var sources = "[('xkb', 'us')]";
- 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;
- }
+ stderr.printf ("section.get_n_items () = %d\n", section.get_n_items ());
+ assert (section.get_n_items () == 1);
+ section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
+ stderr.printf ("label = \"%s\"\n", label);
+ assert (strcmp (label, "English (US)") == 0);
- var menu_model = DBusMenuModel.get ((!) fixture.connection,
- "com.canonical.indicator.keyboard",
- "/com/canonical/indicator/keyboard/desktop");
- var loop = new MainLoop (null, false);
- var signal_name = menu_model.items_changed.connect ((position, removed, added) => {
- loop.quit ();
- });
-
- menu_model.get_n_items ();
-
- var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- menu_model.disconnect (signal_name);
-
- var menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU);
- loop = new MainLoop (null, false);
- signal_name = menu.items_changed.connect ((position, removed, added) => {
- loop.quit ();
- });
-
- menu.get_n_items ();
-
- source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- menu.disconnect (signal_name);
-
- var section = menu.get_item_link (0, Menu.LINK_SECTION);
- loop = new MainLoop (null, false);
- signal_name = section.items_changed.connect ((position, removed, added) => {
- loop.quit ();
- });
-
- section.get_n_items ();
-
- source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- section.disconnect (signal_name);
-
- string label;
-
- stderr.printf ("section.get_n_items () = %d\n", section.get_n_items ());
- assert (section.get_n_items () == 1);
- section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
- stderr.printf ("label = \"%s\"\n", label);
- assert (strcmp (label, "English (US)") == 0);
-
- loop = new MainLoop (null, false);
- signal_name = section.items_changed.connect ((position, removed, added) => {
- if (section.get_n_items () == 4) {
- loop.quit ();
+ loop = new MainLoop (null, false);
+ signal_name = section.items_changed.connect ((position, removed, added) => {
+ if (section.get_n_items () == 4) {
+ loop.quit ();
+ }
+ });
+
+ try {
+ var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
+ 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;
}
- });
-
- try {
- var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
- 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;
- }
- source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return false; });
- loop.run ();
- Source.remove (source);
- section.disconnect (signal_name);
-
- stderr.printf ("section.get_n_items () = %d\n", section.get_n_items ());
- assert (section.get_n_items () == 4);
- section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
- stderr.printf ("label = \"%s\"\n", label);
- assert (strcmp (label, "English (US)") == 0);
- section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label);
- stderr.printf ("label = \"%s\"\n", label);
- assert (strcmp (label, "English (Canada)") == 0);
- section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label);
- stderr.printf ("label = \"%s\"\n", label);
- assert (strcmp (label, "Esperanto") == 0);
- section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label);
- stderr.printf ("label = \"%s\"\n", label);
- assert (label.ascii_casecmp ("Pinyin") == 0);
+ source = Timeout.add_seconds (LONG_TIMEOUT_S, () => { loop.quit (); return true; });
+ loop.run ();
+ Source.remove (source);
+ section.disconnect (signal_name);
+
+ stderr.printf ("section.get_n_items () = %d\n", section.get_n_items ());
+ assert (section.get_n_items () == 4);
+ section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
+ stderr.printf ("label = \"%s\"\n", label);
+ assert (strcmp (label, "English (US)") == 0);
+ section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label);
+ stderr.printf ("label = \"%s\"\n", label);
+ assert (strcmp (label, "English (Canada)") == 0);
+ section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label);
+ stderr.printf ("label = \"%s\"\n", label);
+ assert (strcmp (label, "Esperanto") == 0);
+ section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label);
+ stderr.printf ("label = \"%s\"\n", label);
+ assert (label.ascii_casecmp ("Pinyin") == 0);
+ }
}
public int main (string[] args) {
- Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true);
- Environment.set_variable ("LC_ALL", "C", true);
-
- Test.init (ref args, null);
-
- var suite = new TestSuite ("indicator-keyboard");
-
- suite.add (new TestCase ("activate-input-source", begin_test, test_activate_input_source, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("activate-character-map", begin_test, test_activate_character_map, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("activate-keyboard-layout-chart", begin_test, test_activate_keyboard_layout_chart, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("activate-text-entry-settings", begin_test, test_activate_text_entry_settings, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("migration", begin_test, test_migration, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("no-migration", begin_test, test_no_migration, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("update-visible", begin_test, test_update_visible, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("update-input-source", begin_test, test_update_input_source, end_test, sizeof (Fixture)));
- suite.add (new TestCase ("update-input-sources", begin_test, test_update_input_sources, end_test, sizeof (Fixture)));
-
- TestSuite.get_root ().add_suite (suite);
+ display = Environment.get_variable ("DISPLAY");
+
+ Test.init (ref args);
+
+ Test.add_data_func ("/indicator-keyboard-service/activate-input-source", Fixture.create<Tests> (Tests.test_activate_input_source));
+ Test.add_data_func ("/indicator-keyboard-service/activate-character-map", Fixture.create<Tests> (Tests.test_activate_character_map));
+ Test.add_data_func ("/indicator-keyboard-service/activate-keyboard-layout-chart", Fixture.create<Tests> (Tests.test_activate_keyboard_layout_chart));
+ Test.add_data_func ("/indicator-keyboard-service/activate-text-entry-settings", Fixture.create<Tests> (Tests.test_activate_text_entry_settings));
+ Test.add_data_func ("/indicator-keyboard-service/migration", Fixture.create<Tests> (Tests.test_migration));
+ Test.add_data_func ("/indicator-keyboard-service/no-migration", Fixture.create<Tests> (Tests.test_no_migration));
+ Test.add_data_func ("/indicator-keyboard-service/update-visible", Fixture.create<Tests> (Tests.test_update_visible));
+ Test.add_data_func ("/indicator-keyboard-service/update-input-source", Fixture.create<Tests> (Tests.test_update_input_source));
+ Test.add_data_func ("/indicator-keyboard-service/update-input-sources", Fixture.create<Tests> (Tests.test_update_input_sources));
return Test.run ();
}