Commit 73f2d726 authored by Simon McVittie's avatar Simon McVittie

launch-preferences: Wait for settings changes to reach the disk

Otherwise, they might not be visible to Canterbury soon enough for the
test to work. I've seen this test fail intermittently on minimal
images, where Canterbury tries to launch mildenhall-settings,
but in theory it could also happen on the larger images where
canterbury-full is meant to be used.

Apertis: https://phabricator.apertis.org/T3932Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
Reviewed-by: Frédéric Dalleau's avatarFrédéric Dalleau <frederic.dalleau@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D6993
parent 31f231b9
......@@ -8,7 +8,7 @@ Tests: core-as-root
Depends: canterbury-core-tests, gnome-desktop-testing, ribchester-core (>= 0.1706.3~)
Tests: full
Depends: apertis-tests, canterbury-tests, gnome-desktop-testing
Depends: apertis-tests, canterbury-tests, gnome-desktop-testing, libglib2.0-bin
Tests: full-as-root
Depends: canterbury-tests, gnome-desktop-testing, ribchester-full (>= 0.1706.3~)
......
......@@ -78,12 +78,41 @@ setup (Fixture *f,
* preferences application, rather than mildenhall-settings.
*
* It will do this by launching
* org.apertis.CanterburyTests.LaunchPreferences. */
* org.apertis.CanterburyTests.LaunchPreferences.
*
* We do the actual settings change in a subprocess and wait for the
* change to become visible to the parent. This ensures that the D-Bus
* signal notifying processes other than the setter about the dconf
* change has gone out, which in turn ensures that when our test
* subprocess makes D-Bus calls to Canterbury, those D-Bus calls will
* arrive after the dconf change notification. Hopefully that is enough
* to ensure that Canterbury launches our helper and not
* mildenhall-settings. */
const gchar * const argv[] =
{
"gsettings", "set", "org.apertis.Canterbury.Config",
"preferences-entry-point", SETTINGS_ENTRY_POINT, NULL
};
g_autoptr (GError) error = NULL;
f->settings = g_settings_new ("org.apertis.Canterbury.Config");
f->old_preferences_entry_point = g_settings_get_string (f->settings,
"preferences-entry-point");
g_settings_set_string (f->settings, "preferences-entry-point",
SETTINGS_ENTRY_POINT);
g_spawn_sync (NULL, (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
NULL, NULL, NULL, NULL, &error);
g_assert_no_error (error);
while (TRUE)
{
g_autofree gchar *new_value =
g_settings_get_string (f->settings, "preferences-entry-point");
if (g_strcmp0 (new_value, SETTINGS_ENTRY_POINT) == 0)
break;
g_main_context_iteration (NULL, TRUE);
}
}
}
......@@ -395,9 +424,28 @@ teardown (Fixture *f,
{
if (!g_test_subprocess () && getuid () != 0)
{
/* Reset the Canterbury settings. */
g_settings_set_string (f->settings, "preferences-entry-point",
f->old_preferences_entry_point);
/* See comments in setup() */
const gchar * const argv[] =
{
"gsettings", "set", "org.apertis.Canterbury.Config",
"preferences-entry-point", f->old_preferences_entry_point, NULL
};
g_autoptr (GError) error = NULL;
g_spawn_sync (NULL, (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
NULL, NULL, NULL, NULL, &error);
g_assert_no_error (error);
while (TRUE)
{
g_autofree gchar *new_value =
g_settings_get_string (f->settings, "preferences-entry-point");
if (g_strcmp0 (new_value, f->old_preferences_entry_point) == 0)
break;
g_main_context_iteration (NULL, TRUE);
}
}
/* cancel watchdog */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment