monitor-unit-tests: Add laptop lid switch test case
Test that the laptop panel is disabled if the lid is closed. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
d6efdfab4b
commit
cde1a730e8
@ -27,6 +27,8 @@ struct _MetaMonitorManagerTest
|
|||||||
{
|
{
|
||||||
MetaMonitorManager parent;
|
MetaMonitorManager parent;
|
||||||
|
|
||||||
|
gboolean is_lid_closed;
|
||||||
|
|
||||||
int tiled_monitor_count;
|
int tiled_monitor_count;
|
||||||
|
|
||||||
MetaMonitorTestSetup *test_setup;
|
MetaMonitorTestSetup *test_setup;
|
||||||
@ -59,6 +61,13 @@ meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
|
|||||||
g_free (old_test_setup);
|
g_free (old_test_setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_monitor_manager_test_set_is_lid_closed (MetaMonitorManagerTest *manager_test,
|
||||||
|
gboolean is_lid_closed)
|
||||||
|
{
|
||||||
|
manager_test->is_lid_closed = is_lid_closed;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
meta_monitor_manager_test_get_tiled_monitor_count (MetaMonitorManagerTest *manager_test)
|
meta_monitor_manager_test_get_tiled_monitor_count (MetaMonitorManagerTest *manager_test)
|
||||||
{
|
{
|
||||||
@ -88,7 +97,9 @@ meta_monitor_manager_test_read_current (MetaMonitorManager *manager)
|
|||||||
static gboolean
|
static gboolean
|
||||||
meta_monitor_manager_test_is_lid_closed (MetaMonitorManager *manager)
|
meta_monitor_manager_test_is_lid_closed (MetaMonitorManager *manager)
|
||||||
{
|
{
|
||||||
return FALSE;
|
MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (manager);
|
||||||
|
|
||||||
|
return manager_test->is_lid_closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -41,6 +41,9 @@ void meta_monitor_manager_test_init_test_setup (MetaMonitorTestSetup *test_setup
|
|||||||
void meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
|
void meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
|
||||||
MetaMonitorTestSetup *test_setup);
|
MetaMonitorTestSetup *test_setup);
|
||||||
|
|
||||||
|
void meta_monitor_manager_test_set_is_lid_closed (MetaMonitorManagerTest *manager_test,
|
||||||
|
gboolean is_lid_closed);
|
||||||
|
|
||||||
int meta_monitor_manager_test_get_tiled_monitor_count (MetaMonitorManagerTest *manager_test);
|
int meta_monitor_manager_test_get_tiled_monitor_count (MetaMonitorManagerTest *manager_test);
|
||||||
|
|
||||||
#endif /* META_MONITOR_MANAGER_TEST_H */
|
#endif /* META_MONITOR_MANAGER_TEST_H */
|
||||||
|
@ -96,6 +96,7 @@ typedef struct _MonitorTestCaseOutput
|
|||||||
int height_mm;
|
int height_mm;
|
||||||
MetaTileInfo tile_info;
|
MetaTileInfo tile_info;
|
||||||
int scale;
|
int scale;
|
||||||
|
gboolean is_laptop_panel;
|
||||||
} MonitorTestCaseOutput;
|
} MonitorTestCaseOutput;
|
||||||
|
|
||||||
typedef struct _MonitorTestCaseCrtc
|
typedef struct _MonitorTestCaseCrtc
|
||||||
@ -458,6 +459,8 @@ create_monitor_test_setup (MonitorTestCase *test_case)
|
|||||||
{
|
{
|
||||||
MetaMonitorTestSetup *test_setup;
|
MetaMonitorTestSetup *test_setup;
|
||||||
int i;
|
int i;
|
||||||
|
int n_laptop_panels = 0;
|
||||||
|
int n_normal_panels = 0;
|
||||||
|
|
||||||
test_setup = g_new0 (MetaMonitorTestSetup, 1);
|
test_setup = g_new0 (MetaMonitorTestSetup, 1);
|
||||||
|
|
||||||
@ -508,6 +511,7 @@ create_monitor_test_setup (MonitorTestCase *test_case)
|
|||||||
MetaCrtc **possible_crtcs;
|
MetaCrtc **possible_crtcs;
|
||||||
int n_possible_crtcs;
|
int n_possible_crtcs;
|
||||||
int scale;
|
int scale;
|
||||||
|
gboolean is_laptop_panel;
|
||||||
|
|
||||||
crtc_index = test_case->setup.outputs[i].crtc;
|
crtc_index = test_case->setup.outputs[i].crtc;
|
||||||
if (crtc_index == -1)
|
if (crtc_index == -1)
|
||||||
@ -545,10 +549,15 @@ create_monitor_test_setup (MonitorTestCase *test_case)
|
|||||||
if (scale < 1)
|
if (scale < 1)
|
||||||
scale = 1;
|
scale = 1;
|
||||||
|
|
||||||
|
is_laptop_panel = test_case->setup.outputs[i].is_laptop_panel;
|
||||||
|
|
||||||
test_setup->outputs[i] = (MetaOutput) {
|
test_setup->outputs[i] = (MetaOutput) {
|
||||||
.crtc = crtc,
|
.crtc = crtc,
|
||||||
.winsys_id = i,
|
.winsys_id = i,
|
||||||
.name = g_strdup_printf ("LVDS%d", i + 1),
|
.name = (is_laptop_panel ? g_strdup_printf ("eDP-%d",
|
||||||
|
++n_laptop_panels)
|
||||||
|
: g_strdup_printf ("DP-%d",
|
||||||
|
++n_normal_panels)),
|
||||||
.vendor = g_strdup ("MetaProducts Inc."),
|
.vendor = g_strdup ("MetaProducts Inc."),
|
||||||
.product = g_strdup ("unknown"),
|
.product = g_strdup ("unknown"),
|
||||||
.serial = g_strdup ("0xC0FFEE"),
|
.serial = g_strdup ("0xC0FFEE"),
|
||||||
@ -566,7 +575,8 @@ create_monitor_test_setup (MonitorTestCase *test_case)
|
|||||||
.n_possible_clones = 0,
|
.n_possible_clones = 0,
|
||||||
.possible_clones = NULL,
|
.possible_clones = NULL,
|
||||||
.backlight = -1,
|
.backlight = -1,
|
||||||
.connector_type = META_CONNECTOR_TYPE_LVDS,
|
.connector_type = (is_laptop_panel ? META_CONNECTOR_TYPE_eDP
|
||||||
|
: META_CONNECTOR_TYPE_DisplayPort),
|
||||||
.tile_info = test_case->setup.outputs[i].tile_info,
|
.tile_info = test_case->setup.outputs[i].tile_info,
|
||||||
.scale = scale
|
.scale = scale
|
||||||
};
|
};
|
||||||
@ -1344,6 +1354,146 @@ meta_test_monitor_limited_crtcs (void)
|
|||||||
check_monitor_configuration (&test_case);
|
check_monitor_configuration (&test_case);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_test_monitor_lid_switch_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 = 0,
|
||||||
|
.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 = 2,
|
||||||
|
.n_outputs = 2,
|
||||||
|
.n_crtcs = 2,
|
||||||
|
.n_tiled_monitors = 0,
|
||||||
|
.screen_width = 1024 * 2,
|
||||||
|
.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);
|
||||||
|
|
||||||
|
test_setup = create_monitor_test_setup (&test_case);
|
||||||
|
emulate_hotplug (test_setup);
|
||||||
|
check_monitor_configuration (&test_case);
|
||||||
|
|
||||||
|
meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
|
||||||
|
meta_monitor_manager_lid_is_closed_changed (monitor_manager);
|
||||||
|
|
||||||
|
test_case.expect.n_logical_monitors = 1;
|
||||||
|
test_case.expect.screen_width = 1024;
|
||||||
|
test_case.expect.monitors[0].current_mode = -1;
|
||||||
|
|
||||||
|
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
|
void
|
||||||
init_monitor_tests (void)
|
init_monitor_tests (void)
|
||||||
{
|
{
|
||||||
@ -1368,4 +1518,6 @@ init_monitor_tests (void)
|
|||||||
meta_test_monitor_suggested_config);
|
meta_test_monitor_suggested_config);
|
||||||
g_test_add_func ("/backends/monitor/limited-crtcs",
|
g_test_add_func ("/backends/monitor/limited-crtcs",
|
||||||
meta_test_monitor_limited_crtcs);
|
meta_test_monitor_limited_crtcs);
|
||||||
|
g_test_add_func ("/backends/monitor/lid-switch-config",
|
||||||
|
meta_test_monitor_lid_switch_config);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user