[gnome-settings-daemon] keyboard: Add test cases for make_xkb_source_id()



commit 316baa6440dcff8e3c9863c1d4705bdaf638790c
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Sep 3 18:10:34 2012 +0200

    keyboard: Add test cases for make_xkb_source_id()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680313

 plugins/keyboard/Makefile.am               |    9 +++++++++
 plugins/keyboard/test-make-xkb-source-id.c |   23 +++++++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/plugins/keyboard/Makefile.am b/plugins/keyboard/Makefile.am
index 640a3ef..0ec5a3e 100644
--- a/plugins/keyboard/Makefile.am
+++ b/plugins/keyboard/Makefile.am
@@ -64,6 +64,15 @@ plugin_in_files = 		\
 
 plugin_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
 
+noinst_PROGRAMS = test-make-xkb-source-id
+test_make_xkb_source_id_SOURCES = test-make-xkb-source-id.c
+test_make_xkb_source_id_CFLAGS = $(libkeyboard_la_CFLAGS)
+test_make_xkb_source_id_CPPFLAGS = $(libkeyboard_la_CPPFLAGS)
+test_make_xkb_source_id_LDADD = $(libkeyboard_la_LIBADD) $(top_builddir)/gnome-settings-daemon/libgsd.la
+
+check-local: test-make-xkb-source-id
+	$(builddir)/test-make-xkb-source-id > /dev/null
+
 EXTRA_DIST = 			\
 	$(icons_DATA)		\
 	$(plugin_in_files)	\
diff --git a/plugins/keyboard/test-make-xkb-source-id.c b/plugins/keyboard/test-make-xkb-source-id.c
new file mode 100644
index 0000000..4ba6347
--- /dev/null
+++ b/plugins/keyboard/test-make-xkb-source-id.c
@@ -0,0 +1,23 @@
+#include "gsd-keyboard-manager.c"
+
+int
+main (void)
+{
+        gint i;
+        const gchar *test_strings[][2] = {
+                /* input                output */
+                { "xkb:aa:bb:cc",       "aa+bb" },
+                { "xkb:aa:bb:",         "aa+bb" },
+                { "xkb:aa::cc",         "aa" },
+                { "xkb:aa::",           "aa" },
+                { "xkb::bb:cc",         "+bb" },
+                { "xkb::bb:",           "+bb" },
+                { "xkb:::cc",           "" },
+                { "xkb:::",             "" },
+        };
+
+        for (i = 0; i < G_N_ELEMENTS (test_strings); ++i)
+                g_assert_cmpstr (make_xkb_source_id (test_strings[i][0]), ==, test_strings[i][1]);
+
+        return 0;
+}



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