tests/color: Auto cleanup devices after tests
This helps making the test cases smaller, skipping irrelevant repetitive cleanup after each test. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
This commit is contained in:
parent
a232eb263f
commit
99d0c37d32
@ -180,6 +180,55 @@ add_colord_system_profile (const char *cd_profile_id,
|
|||||||
g_error ("Failed to add system profile: %s", error->message);
|
g_error ("Failed to add system profile: %s", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
prepare_color_test (void)
|
||||||
|
{
|
||||||
|
MetaBackend *backend = meta_context_get_backend (test_context);
|
||||||
|
MetaMonitorManager *monitor_manager =
|
||||||
|
meta_backend_get_monitor_manager (backend);
|
||||||
|
MetaColorManager *color_manager =
|
||||||
|
meta_backend_get_color_manager (backend);
|
||||||
|
GDBusProxy *proxy;
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
|
proxy = get_colord_mock_proxy ();
|
||||||
|
|
||||||
|
if (!g_dbus_proxy_call_sync (proxy,
|
||||||
|
"Reset",
|
||||||
|
NULL,
|
||||||
|
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL,
|
||||||
|
&error))
|
||||||
|
g_error ("Failed to reset mocked colord state: %s", error->message);
|
||||||
|
|
||||||
|
g_assert_null (meta_monitor_manager_get_monitors (monitor_manager));
|
||||||
|
g_assert_cmpint (meta_color_manager_get_num_color_devices (color_manager),
|
||||||
|
==,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
finish_color_test (void)
|
||||||
|
{
|
||||||
|
MetaBackend *backend = meta_context_get_backend (test_context);
|
||||||
|
MonitorTestCaseSetup test_case_setup = base_monitor_setup;
|
||||||
|
MetaMonitorManager *monitor_manager =
|
||||||
|
meta_backend_get_monitor_manager (backend);
|
||||||
|
MetaMonitorManagerTest *monitor_manager_test =
|
||||||
|
META_MONITOR_MANAGER_TEST (monitor_manager);
|
||||||
|
MetaColorManager *color_manager =
|
||||||
|
meta_backend_get_color_manager (backend);
|
||||||
|
MetaMonitorTestSetup *test_setup;
|
||||||
|
|
||||||
|
test_case_setup.n_outputs = 0;
|
||||||
|
test_setup = meta_create_monitor_test_setup (backend, &test_case_setup,
|
||||||
|
MONITOR_TEST_FLAG_NO_STORED);
|
||||||
|
meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
|
||||||
|
g_assert_null (meta_monitor_manager_get_monitors (monitor_manager));
|
||||||
|
g_assert_cmpint (meta_color_manager_get_num_color_devices (color_manager),
|
||||||
|
==,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_test_color_management_device_basic (void)
|
meta_test_color_management_device_basic (void)
|
||||||
{
|
{
|
||||||
@ -201,11 +250,6 @@ meta_test_color_management_device_basic (void)
|
|||||||
test_case_setup.outputs[1].edid_info = ANCOR_VX239_EDID;
|
test_case_setup.outputs[1].edid_info = ANCOR_VX239_EDID;
|
||||||
test_case_setup.outputs[1].has_edid_info = TRUE;
|
test_case_setup.outputs[1].has_edid_info = TRUE;
|
||||||
|
|
||||||
test_case_setup.n_outputs = 0;
|
|
||||||
test_setup = meta_create_monitor_test_setup (backend, &test_case_setup,
|
|
||||||
MONITOR_TEST_FLAG_NO_STORED);
|
|
||||||
meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
|
|
||||||
|
|
||||||
test_case_setup.n_outputs = 2;
|
test_case_setup.n_outputs = 2;
|
||||||
test_setup = meta_create_monitor_test_setup (backend, &test_case_setup,
|
test_setup = meta_create_monitor_test_setup (backend, &test_case_setup,
|
||||||
MONITOR_TEST_FLAG_NO_STORED);
|
MONITOR_TEST_FLAG_NO_STORED);
|
||||||
@ -416,24 +460,45 @@ static void
|
|||||||
on_before_tests (MetaContext *context)
|
on_before_tests (MetaContext *context)
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_context_get_backend (test_context);
|
MetaBackend *backend = meta_context_get_backend (test_context);
|
||||||
|
MetaMonitorManager *monitor_manager =
|
||||||
|
meta_backend_get_monitor_manager (backend);
|
||||||
|
MetaMonitorManagerTest *monitor_manager_test =
|
||||||
|
META_MONITOR_MANAGER_TEST (monitor_manager);
|
||||||
MetaColorManager *color_manager =
|
MetaColorManager *color_manager =
|
||||||
meta_backend_get_color_manager (backend);
|
meta_backend_get_color_manager (backend);
|
||||||
|
MonitorTestCaseSetup test_case_setup = base_monitor_setup;
|
||||||
|
MetaMonitorTestSetup *test_setup;
|
||||||
|
|
||||||
|
test_case_setup.n_outputs = 0;
|
||||||
|
test_setup = meta_create_monitor_test_setup (backend, &test_case_setup,
|
||||||
|
MONITOR_TEST_FLAG_NO_STORED);
|
||||||
|
meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
|
||||||
|
|
||||||
while (!meta_color_manager_is_ready (color_manager))
|
while (!meta_color_manager_is_ready (color_manager))
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_color_test (const char *test_path,
|
||||||
|
GTestFunc test_func)
|
||||||
|
{
|
||||||
|
g_test_add_vtable (test_path, 0, NULL,
|
||||||
|
(GTestFixtureFunc) prepare_color_test,
|
||||||
|
(GTestFixtureFunc) test_func,
|
||||||
|
(GTestFixtureFunc) finish_color_test);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_tests (void)
|
init_tests (void)
|
||||||
{
|
{
|
||||||
meta_init_monitor_test_setup (create_stage_view_test_setup);
|
meta_init_monitor_test_setup (create_stage_view_test_setup);
|
||||||
|
|
||||||
g_test_add_func ("/color-management/device/basic",
|
add_color_test ("/color-management/device/basic",
|
||||||
meta_test_color_management_device_basic);
|
meta_test_color_management_device_basic);
|
||||||
g_test_add_func ("/color-management/profile/device",
|
add_color_test ("/color-management/profile/device",
|
||||||
meta_test_color_management_profile_device);
|
meta_test_color_management_profile_device);
|
||||||
g_test_add_func ("/color-management/profile/system",
|
add_color_test ("/color-management/profile/system",
|
||||||
meta_test_color_management_profile_system);
|
meta_test_color_management_profile_system);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user