summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Terry <michael.terry@canonical.com>2012-02-07 09:47:15 -0500
committerMichael Terry <michael.terry@canonical.com>2012-02-07 09:47:15 -0500
commit23f43e2e5cc419c4cd8a5a33020871b65737b7ba (patch)
tree44280967657cb0d050ad6bfdd84f808a64d22c95 /tests
parent67a13760769cad9bfe46e71596bc41172bf53975 (diff)
downloadlightdm-23f43e2e5cc419c4cd8a5a33020871b65737b7ba.tar.gz
add default-keyboard-layout test and code to support it
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/default-keyboard-layout.conf40
-rw-r--r--tests/scripts/keyboard-layout.conf2
-rw-r--r--tests/scripts/no-keyboard-layout.conf2
-rw-r--r--tests/src/test-gobject-greeter.c13
-rw-r--r--tests/src/x-server.c21
-rwxr-xr-xtests/test-default-keyboard-layout2
6 files changed, 68 insertions, 12 deletions
diff --git a/tests/scripts/default-keyboard-layout.conf b/tests/scripts/default-keyboard-layout.conf
new file mode 100644
index 00000000..2ee8e0d2
--- /dev/null
+++ b/tests/scripts/default-keyboard-layout.conf
@@ -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
diff --git a/tests/scripts/keyboard-layout.conf b/tests/scripts/keyboard-layout.conf
index 92c61198..cc5e1af2 100644
--- a/tests/scripts/keyboard-layout.conf
+++ b/tests/scripts/keyboard-layout.conf
@@ -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
diff --git a/tests/scripts/no-keyboard-layout.conf b/tests/scripts/no-keyboard-layout.conf
index 6a703473..a77818ef 100644
--- a/tests/scripts/no-keyboard-layout.conf
+++ b/tests/scripts/no-keyboard-layout.conf
@@ -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
diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c
index d7558e93..55568013 100644
--- a/tests/src/test-gobject-greeter.c
+++ b/tests/src/test-gobject-greeter.c
@@ -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);
diff --git a/tests/src/x-server.c b/tests/src/x-server.c
index 76126928..335f7c8c 100644
--- a/tests/src/x-server.c
+++ b/tests/src/x-server.c
@@ -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
index 00000000..705b48a9
--- /dev/null
+++ b/tests/test-default-keyboard-layout
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner default-keyboard-layout test-gobject-greeter