]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
augment keyboard-layout test to test our ability to grab layout from the Accounts...
authorMichael Terry <michael.terry@canonical.com>
Tue, 7 Feb 2012 18:55:25 +0000 (13:55 -0500)
committerMichael Terry <michael.terry@canonical.com>
Tue, 7 Feb 2012 18:55:25 +0000 (13:55 -0500)
tests/scripts/keyboard-layout.conf
tests/src/test-gobject-greeter.c
tests/src/test-runner.c

index cc5e1af2dd5b5ac32d74b3909de1c6f73abc0c4e..a7b92f541590ca8338373ee448fdcc69f141d7c0 100644 (file)
@@ -6,7 +6,7 @@
 minimum-display-number=50
 
 [test-greeter-config]
-log-keyboard-layout=bob
+log-keyboard-layout=bob,carol
 
 #?RUNNER DAEMON-START
 
@@ -26,6 +26,7 @@ log-keyboard-layout=bob
 
 # Correct layout is found
 #?GREETER :50 GET-LAYOUT USERNAME=bob LAYOUT='us'
+#?GREETER :50 GET-LAYOUT USERNAME=carol LAYOUT='fr     oss'
 
 # Cleanup
 #?*STOP-DAEMON
index 0b8526b9eb8154a29986a0f1304a79b54cb62321..c61dda9b93f4ba92f1cda3f0b04e7e48b5dd4226 100644 (file)
@@ -129,18 +129,28 @@ main (int argc, char **argv)
     layout_username = g_key_file_get_string (config, "test-greeter-config", "log-keyboard-layout", NULL);
     if (layout_username)
     {
-        LightDMUser *user;
-        const gchar *layout;
+        gchar **users;
+        int i;
 
-        if (g_strcmp0 (layout_username, "%DEFAULT%") == 0) /* Grab system default layout */
-            layout = lightdm_layout_get_name (lightdm_get_layout ());
-        else
+        users = g_strsplit (layout_username, ",", 0);
+
+        for (i = 0; users[i]; i++)
         {
-            user = lightdm_user_list_get_user_by_name (lightdm_user_list_get_instance (), layout_username);
-            layout = lightdm_user_get_layout (user);
+            LightDMUser *user;
+            const gchar *layout;
+
+            if (g_strcmp0 (users[i], "%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 (), users[i]);
+                layout = lightdm_user_get_layout (user);
+            }
+
+            status_notify ("GREETER %s GET-LAYOUT USERNAME=%s LAYOUT='%s'", getenv ("DISPLAY"), users[i], layout ? layout : "");
         }
 
-        status_notify ("GREETER %s GET-LAYOUT USERNAME=%s LAYOUT='%s'", getenv ("DISPLAY"), layout_username, layout ? layout : "");
+        g_strfreev (users);
     }
 
     layout_prefix = g_key_file_get_string (config, "test-greeter-config", "log-keyboard-layouts", NULL);
index 2beec52ef134763542b1596b336472a4ad736b25..4a72a96129cad00af32a2d8892f507ae59764c96 100644 (file)
@@ -49,6 +49,7 @@ typedef struct
     guint id;
     gchar *language;
     gchar *xsession;
+    gchar *layout;
 } AccountsUser;
 static GList *accounts_users = NULL;
 static void handle_user_call (GDBusConnection       *connection,
@@ -771,6 +772,7 @@ load_passwd_file ()
                     *c = '\0';
             }
             user->xsession = g_key_file_get_string (dmrc_file, "Desktop", "Session", NULL);
+            user->layout = g_key_file_get_string (dmrc_file, "X-Accounts", "Layout", NULL);
             user->path = g_strdup_printf ("/org/freedesktop/Accounts/User%d", uid);
             user->id = g_dbus_connection_register_object (accounts_connection,
                                                           user->path,
@@ -895,6 +897,8 @@ handle_user_get_property (GDBusConnection       *connection,
         return g_variant_new_string (user->language ? user->language : "");
     else if (strcmp (property_name, "XSession") == 0)
         return g_variant_new_string (user->xsession ? user->xsession : "");
+    else if (strcmp (property_name, "XKeyboardLayout") == 0)
+        return g_variant_new_string (user->layout ? user->layout : "");
 
     return NULL;
 }
@@ -932,6 +936,7 @@ accounts_name_acquired_cb (GDBusConnection *connection,
         "    <property name='BackgroundFile' type='s' access='read'/>"
         "    <property name='Language' type='s' access='read'/>"
         "    <property name='XSession' type='s' access='read'/>"
+        "    <property name='XKeyboardLayout' type='s' access='read'/>"
         "  </interface>"
         "</node>";
     GError *error = NULL;
@@ -1180,18 +1185,19 @@ main (int argc, char **argv)
         gboolean have_home_dir;
         gchar *real_name;
         gchar *xsession;
-        gchar *layout;
+        gchar *dmrc_layout;
+        gchar *dbus_layout;
         gchar *language;
         gint uid;
     } users[] =
     {
-        {"root",    "",         TRUE,  "root",       NULL,          NULL, NULL,             0},
-        {"lightdm", "",         TRUE,  "",           NULL,          NULL, NULL,           100},
-        {"alice",   "password", TRUE,  "Alice User", NULL,          NULL, NULL,          1000},
-        {"bob",     "",         TRUE,  "Bob User",   NULL,          "us", "en_AU.utf8",  1001},
-        {"carol",   "",         TRUE,  "Carol User", "alternative", "fr", "fr_FR.UTF-8", 1002},
-        {"dave",    "",         FALSE, "Dave User",  NULL,          NULL, NULL,          1003},
-        {NULL,      NULL,       FALSE, NULL,         NULL,          NULL, NULL,             0}
+        {"root",    "",         TRUE,  "root",       NULL,          NULL, NULL,      NULL,             0},
+        {"lightdm", "",         TRUE,  "",           NULL,          NULL, NULL,      NULL,           100},
+        {"alice",   "password", TRUE,  "Alice User", NULL,          NULL, NULL,      NULL,          1000},
+        {"bob",     "",         TRUE,  "Bob User",   NULL,          "us", NULL,      "en_AU.utf8",  1001},
+        {"carol",   "",         TRUE,  "Carol User", "alternative", "ru", "fr\toss", "fr_FR.UTF-8", 1002},
+        {"dave",    "",         FALSE, "Dave User",  NULL,          NULL, NULL,      NULL,          1003},
+        {NULL,      NULL,       FALSE, NULL,         NULL,          NULL, NULL,      NULL,             0}
     };
     passwd_data = g_string_new ("");
     int i;
@@ -1215,9 +1221,14 @@ main (int argc, char **argv)
             g_key_file_set_string (dmrc_file, "Desktop", "Session", users[i].xsession);
             save_dmrc = TRUE;
         }
-        if (users[i].layout)
+        if (users[i].dmrc_layout)
         {
-            g_key_file_set_string (dmrc_file, "Desktop", "Layout", users[i].layout);
+            g_key_file_set_string (dmrc_file, "Desktop", "Layout", users[i].dmrc_layout);
+            save_dmrc = TRUE;
+        }
+        if (users[i].dbus_layout)
+        {
+            g_key_file_set_string (dmrc_file, "X-Accounts", "Layout", users[i].dbus_layout);
             save_dmrc = TRUE;
         }
         if (users[i].language)