summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2018-05-11 16:39:28 +1200
committerRobert Ancell <robert.ancell@canonical.com>2018-05-11 16:39:28 +1200
commit9813401387b31f5a3c4c7dfffd225fe76c5a78aa (patch)
tree37b0de88dddae95345ca9db84f7e14f4a7416dd0
parent149d9d7dff76f1db1daac33031f5d2d0c5407443 (diff)
downloadlightdm-git-9813401387b31f5a3c4c7dfffd225fe76c5a78aa.tar.gz
Fix test failing due to random ordering of results
-rw-r--r--tests/scripts/sessions.conf4
-rw-r--r--tests/src/test-gobject-greeter.c7
-rwxr-xr-xtests/src/test-python-greeter8
-rw-r--r--tests/src/test-qt-greeter.cpp10
4 files changed, 23 insertions, 6 deletions
diff --git a/tests/scripts/sessions.conf b/tests/scripts/sessions.conf
index fa25652d..95a1b7db 100644
--- a/tests/scripts/sessions.conf
+++ b/tests/scripts/sessions.conf
@@ -28,11 +28,11 @@ user-session=default
#?*GREETER-X-0 LOG-SESSIONS
#?GREETER-X-0 LOG-SESSION KEY=alternative
#?GREETER-X-0 LOG-SESSION KEY=default
+#?GREETER-X-0 LOG-SESSION KEY=greeter
#?GREETER-X-0 LOG-SESSION KEY=mir
-#?GREETER-X-0 LOG-SESSION KEY=named-legacy
#?GREETER-X-0 LOG-SESSION KEY=named
+#?GREETER-X-0 LOG-SESSION KEY=named-legacy
#?GREETER-X-0 LOG-SESSION KEY=wayland
-#?GREETER-X-0 LOG-SESSION KEY=greeter
# Cleanup
#?*STOP-DAEMON
diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c
index 43b8b96f..54fff9a9 100644
--- a/tests/src/test-gobject-greeter.c
+++ b/tests/src/test-gobject-greeter.c
@@ -166,6 +166,12 @@ read_shared_data_finished (GObject *object, GAsyncResult *result, gpointer data)
status_notify ("%s READ-SHARED-DATA ERROR=%s", greeter_id, error->message);
}
+static int
+compare_session (gconstpointer a, gconstpointer b)
+{
+ return strcmp (lightdm_session_get_key (LIGHTDM_SESSION (a)), lightdm_session_get_key (LIGHTDM_SESSION (b)));
+}
+
static void
request_cb (const gchar *name, GHashTable *params)
{
@@ -312,6 +318,7 @@ request_cb (const gchar *name, GHashTable *params)
else if (strcmp (name, "LOG-SESSIONS") == 0)
{
GList *sessions = lightdm_get_sessions ();
+ sessions = g_list_sort (sessions, compare_session);
for (GList *link = sessions; link; link = link->next)
{
LightDMSession *session = link->data;
diff --git a/tests/src/test-python-greeter b/tests/src/test-python-greeter
index 2d7382d9..04af1b0e 100755
--- a/tests/src/test-python-greeter
+++ b/tests/src/test-python-greeter
@@ -107,6 +107,14 @@ def request_cb (channel, condition):
r = '%s LOG-SESSIONS' % greeter_id
if request == r:
sessions = LightDM.get_sessions ();
+ def compare_session (a, b):
+ if a.get_key () > b.get_key ():
+ return 1
+ elif a.get_key () < b.get_key ():
+ return -1
+ else:
+ return 0
+ sessions.sort (compare_session)
for session in sessions:
status_notify ('%s LOG-SESSION KEY=%s' % (greeter_id, session.get_key ()))
diff --git a/tests/src/test-qt-greeter.cpp b/tests/src/test-qt-greeter.cpp
index 87edc729..e95afa4f 100644
--- a/tests/src/test-qt-greeter.cpp
+++ b/tests/src/test-qt-greeter.cpp
@@ -11,6 +11,7 @@
#include <QtCore/QSettings>
#include <QtCore/QDebug>
#include <QtCore/QCoreApplication>
+#include <QStringList>
#include "test-qt-greeter.h"
#include "status.h"
@@ -190,11 +191,12 @@ request_cb (const gchar *name, GHashTable *params)
else if (strcmp (name, "LOG-SESSIONS") == 0)
{
+ QStringList names;
for (int i = 0; i < sessions_model->rowCount (QModelIndex ()); i++)
- {
- QString key = sessions_model->data (sessions_model->index (i, 0), QLightDM::SessionsModel::KeyRole).toString ();
- status_notify ("%s LOG-SESSION KEY=%s", greeter_id, qPrintable (key));
- }
+ names.append (sessions_model->data (sessions_model->index (i, 0), QLightDM::SessionsModel::KeyRole).toString ());
+ names.sort ();
+ for (int i = 0; i < names.size (); i++)
+ status_notify ("%s LOG-SESSION KEY=%s", greeter_id, qPrintable (names.at (i)));
}
else if (strcmp (name, "GET-CAN-SUSPEND") == 0)