monitor-unit-tests: Test starting with lid closed

Add a test case that checks that configuration works when the lid is
initialy closed then later opened. This test case is disabled when the
legacy configuration is used as it does not handle that situation.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2017-01-10 13:18:46 +08:00
parent f19cb6a610
commit 81923410f6

View File

@ -1494,6 +1494,145 @@ meta_test_monitor_lid_switch_config (void)
check_monitor_configuration (&test_case);
}
static void
meta_test_monitor_lid_opened_config (void)
{
MonitorTestCase test_case = {
.setup = {
.modes = {
{
.width = 1024,
.height = 768,
.refresh_rate = 60.0
}
},
.n_modes = 1,
.outputs = {
{
.crtc = 0,
.modes = { 0 },
.n_modes = 1,
.preferred_mode = 0,
.possible_crtcs = { 0 },
.n_possible_crtcs = 1,
.width_mm = 222,
.height_mm = 125,
.is_laptop_panel = TRUE
},
{
.crtc = 1,
.modes = { 0 },
.n_modes = 1,
.preferred_mode = 0,
.possible_crtcs = { 1 },
.n_possible_crtcs = 1,
.width_mm = 220,
.height_mm = 124
}
},
.n_outputs = 2,
.crtcs = {
{
.current_mode = 0
},
{
.current_mode = 0
}
},
.n_crtcs = 2
},
.expect = {
.monitors = {
{
.outputs = { 0 },
.n_outputs = 1,
.modes = {
{
.width = 1024,
.height = 768,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 0
}
}
}
},
.n_modes = 1,
.current_mode = -1,
.width_mm = 222,
.height_mm = 125
},
{
.outputs = { 1 },
.n_outputs = 1,
.modes = {
{
.width = 1024,
.height = 768,
.crtc_modes = {
{
.output = 1,
.crtc_mode = 0
}
}
}
},
.n_modes = 1,
.current_mode = 0,
.width_mm = 220,
.height_mm = 124
}
},
.n_monitors = 2,
.logical_monitors = {
{
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
.scale = 1
},
{
.layout = { .x = 1024, .y = 0, .width = 1024, .height = 768 },
.scale = 1
}
},
.n_logical_monitors = 1, /* Second one checked after lid opened. */
.n_outputs = 2,
.n_crtcs = 2,
.n_tiled_monitors = 0,
.screen_width = 1024,
.screen_height = 768
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
META_MONITOR_MANAGER_TEST (monitor_manager);
if (!monitor_manager->config_manager)
{
g_test_skip ("Only the new monitor config manager handles this case.");
return;
}
test_setup = create_monitor_test_setup (&test_case);
meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
emulate_hotplug (test_setup);
check_monitor_configuration (&test_case);
meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
meta_monitor_manager_lid_is_closed_changed (monitor_manager);
test_case.expect.n_logical_monitors = 2;
test_case.expect.screen_width = 1024 * 2;
test_case.expect.monitors[0].current_mode = 0;
check_monitor_configuration (&test_case);
}
void
init_monitor_tests (void)
{
@ -1520,4 +1659,6 @@ init_monitor_tests (void)
meta_test_monitor_limited_crtcs);
g_test_add_func ("/backends/monitor/lid-switch-config",
meta_test_monitor_lid_switch_config);
g_test_add_func ("/backends/monitor/lid-opened-config",
meta_test_monitor_lid_opened_config);
}