]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
add default-keyboard-layout test and code to support it
authorMichael Terry <michael.terry@canonical.com>
Tue, 7 Feb 2012 14:47:15 +0000 (09:47 -0500)
committerMichael Terry <michael.terry@canonical.com>
Tue, 7 Feb 2012 14:47:15 +0000 (09:47 -0500)
tests/scripts/default-keyboard-layout.conf [new file with mode: 0644]
tests/scripts/keyboard-layout.conf
tests/scripts/no-keyboard-layout.conf
tests/src/test-gobject-greeter.c
tests/src/x-server.c
tests/test-default-keyboard-layout [new file with mode: 0755]

diff --git a/tests/scripts/default-keyboard-layout.conf b/tests/scripts/default-keyboard-layout.conf
new file mode 100644 (file)
index 0000000..2ee8e0d
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# Check returns correct layout for a user
+#
+
+[LightDM]
+minimum-display-number=50
+
+[test-xserver-config]
+keyboard-layout=ara
+keyboard-variant=azerty
+
+[test-greeter-config]
+log-keyboard-layout=%DEFAULT%
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER :50 START
+#?XSERVER :50 INDICATE-READY
+
+# LightDM connects to X server
+#?XSERVER :50 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER :50 START
+#?XSERVER :50 ACCEPT-CONNECT
+#?GREETER :50 CONNECT-XSERVER
+#?GREETER :50 CONNECT-TO-DAEMON
+#?GREETER :50 CONNECTED-TO-DAEMON
+
+# Correct layout is found
+#?XSERVER :50 ACCEPT-CONNECT
+#?GREETER :50 GET-LAYOUT USERNAME=%DEFAULT% LAYOUT='ara        azerty'
+
+# Cleanup
+#?*STOP-DAEMON
+# Don't know what order they will terminate
+#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
+#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
+#?RUNNER DAEMON-EXIT STATUS=0
index 92c61198deea8ab919f53ee985c10940b259c9ea..cc5e1af2dd5b5ac32d74b3909de1c6f73abc0c4e 100644 (file)
@@ -25,7 +25,7 @@ log-keyboard-layout=bob
 #?GREETER :50 CONNECTED-TO-DAEMON
 
 # Correct layout is found
-#?GREETER :50 GET-LAYOUT USERNAME=bob LAYOUT=us
+#?GREETER :50 GET-LAYOUT USERNAME=bob LAYOUT='us'
 
 # Cleanup
 #?*STOP-DAEMON
index 6a7034734947e25d44935cae97026334a9c077c7..a77818ef3aa3676f0e1abde6739b1a5fe6e4bc8e 100644 (file)
@@ -25,7 +25,7 @@ log-keyboard-layout=alice
 #?GREETER :50 CONNECTED-TO-DAEMON
 
 # Correct layout is found
-#?GREETER :50 GET-LAYOUT USERNAME=alice LAYOUT=
+#?GREETER :50 GET-LAYOUT USERNAME=alice LAYOUT=''
 
 # Cleanup
 #?*STOP-DAEMON
index d7558e93e10fec9cb0bd5cc472a47533dd6159b3..55568013aea7ac99a0c6df78dac3382e5aa17123 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 4 -*- */
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -130,10 +132,15 @@ main (int argc, char **argv)
         LightDMUser *user;
         const gchar *layout;
 
-        user = lightdm_user_list_get_user_by_name (lightdm_user_list_get_instance (), layout_username);
-        layout = lightdm_user_get_layout (user);
+        if (g_strcmp0 (layout_username, "%DEFAULT%") == 0) /* Grab system default layout */
+            layout = lightdm_layout_get_name (lightdm_get_layout ());
+        else
+        {
+            user = lightdm_user_list_get_user_by_name (lightdm_user_list_get_instance (), layout_username);
+            layout = lightdm_user_get_layout (user);
+        }
 
-        status_notify ("GREETER %s GET-LAYOUT USERNAME=%s LAYOUT=%s", getenv ("DISPLAY"), layout_username, layout ? layout : "");
+        status_notify ("GREETER %s GET-LAYOUT USERNAME=%s LAYOUT='%s'", getenv ("DISPLAY"), layout_username, layout ? layout : "");
     }
 
     language_username = g_key_file_get_string (config, "test-greeter-config", "log-language", NULL);
index 76126928dd234772c6235ca7ff71e55ad9449741..335f7c8c9fac364913fed0e9450a3746c3c23911 100644 (file)
@@ -521,14 +521,13 @@ process_get_property (XClient *client, const guint8 *buffer, gssize buffer_lengt
 
     gsize offset = 0;
     guint8 delete;
-    guint32 window;
     guint32 property;
     guint32 type;
 
     read_padding (1, &offset); /* reqType */
     delete = read_card8 (buffer, buffer_length, &offset);
     read_padding (2, &offset); /* length */
-    window = read_card32 (buffer, buffer_length, client->priv->byte_order, &offset);
+    read_padding (4, &offset); /* window */
     property = read_card32 (buffer, buffer_length, client->priv->byte_order, &offset);
     type = read_card32 (buffer, buffer_length, client->priv->byte_order, &offset);
     read_padding (4, &offset); /* longOffset */
@@ -542,26 +541,34 @@ process_get_property (XClient *client, const guint8 *buffer, gssize buffer_lengt
 
     if (g_strcmp0 (name, "_XKB_RULES_NAMES") == 0)
     {
+        GKeyFile *config;
+
+        config = g_key_file_new ();
+        if (g_getenv ("LIGHTDM_TEST_CONFIG"))
+            g_key_file_load_from_file (config, g_getenv ("LIGHTDM_TEST_CONFIG"), G_KEY_FILE_NONE, NULL);
+
         reply = g_string_new ("");
 
         g_string_append (reply, "evdev"); /* rules file */
         g_string_append_c (reply, 0); /* embedded null byte */
 
-        g_string_append (reply, "evdev"); /* model name */
+        g_string_append (reply, "pc105"); /* model name */
         g_string_append_c (reply, 0); /* embedded null byte */
 
-        if (g_getenv ("LIGHTDM_TEST_KEYBOARD_LAYOUT"))
-            g_string_append (reply, g_getenv ("LIGHTDM_TEST_KEYBOARD_LAYOUT"));
+        if (g_key_file_has_key (config, "test-xserver-config", "keyboard-layout", NULL))
+            g_string_append (reply, g_key_file_get_string (config, "test-xserver-config", "keyboard-layout", NULL));
         else
             g_string_append (reply, "us");
         g_string_append_c (reply, 0); /* embedded null byte */
 
-        if (g_getenv ("LIGHTDM_TEST_KEYBOARD_VARIANT"))
-            g_string_append (reply, g_getenv ("LIGHTDM_TEST_KEYBOARD_VARIANT"));
+        if (g_key_file_has_key (config, "test-xserver-config", "keyboard-variant", NULL))
+            g_string_append (reply, g_key_file_get_string (config, "test-xserver-config", "keyboard-variant", NULL));
         g_string_append_c (reply, 0); /* embedded null byte */
 
         /* no xkb options */
         g_string_append_c (reply, 0); /* embedded null byte */
+
+        g_key_file_free (config);
     }
 
     if (name && delete)
diff --git a/tests/test-default-keyboard-layout b/tests/test-default-keyboard-layout
new file mode 100755 (executable)
index 0000000..705b48a
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner default-keyboard-layout test-gobject-greeter