tests: Add monitor store and config test for output underscanning

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl
2017-01-17 11:34:23 +08:00
parent e357b4a46a
commit e9a8208607
4 changed files with 262 additions and 1 deletions

View File

@ -104,6 +104,7 @@ typedef struct _MonitorTestCaseOutput
MetaTileInfo tile_info;
int scale;
gboolean is_laptop_panel;
gboolean is_underscanning;
} MonitorTestCaseOutput;
typedef struct _MonitorTestCaseCrtc
@ -145,6 +146,7 @@ typedef struct _MonitorTestCaseMonitor
int current_mode;
int width_mm;
int height_mm;
gboolean is_underscanning;
} MonitorTestCaseMonitor;
typedef struct _MonitorTestCaseLogicalMonitor
@ -391,6 +393,9 @@ check_monitor_configuration (MonitorTestCase *test_case)
g_assert (output == output_from_winsys_id (monitor_manager,
winsys_id));
g_assert_cmpint (test_case->expect.monitors[i].is_underscanning,
==,
output->is_underscanning);
}
meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm);
@ -661,7 +666,8 @@ create_monitor_test_setup (MonitorTestCase *test_case,
.connector_type = (is_laptop_panel ? META_CONNECTOR_TYPE_eDP
: META_CONNECTOR_TYPE_DisplayPort),
.tile_info = test_case->setup.outputs[i].tile_info,
.scale = scale
.scale = scale,
.is_underscanning = test_case->setup.outputs[i].is_underscanning
};
}
@ -1856,6 +1862,88 @@ meta_test_monitor_no_outputs (void)
check_monitor_configuration (&test_case);
}
static void
meta_test_monitor_underscanning_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_underscanning = TRUE,
}
},
.n_outputs = 1,
.crtcs = {
{
.current_mode = 0
}
},
.n_crtcs = 1
},
.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,
.is_underscanning = TRUE,
}
},
.n_monitors = 1,
.logical_monitors = {
{
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
.scale = 1
}
},
.n_logical_monitors = 1,
.primary_logical_monitor = 0,
.n_outputs = 1,
.n_crtcs = 1,
.screen_width = 1024,
.screen_height = 768
}
};
MetaMonitorTestSetup *test_setup;
test_setup = create_monitor_test_setup (&test_case,
MONITOR_TEST_FLAG_NO_STORED);
emulate_hotplug (test_setup);
check_monitor_configuration (&test_case);
}
static void
meta_test_monitor_custom_vertical_config (void)
{
@ -2118,6 +2206,96 @@ meta_test_monitor_custom_primary_config (void)
check_monitor_configuration (&test_case);
}
static void
meta_test_monitor_custom_underscanning_config (void)
{
MonitorTestCase test_case = {
.setup = {
.modes = {
{
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.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
},
},
.n_outputs = 1,
.crtcs = {
{
.current_mode = 0
},
},
.n_crtcs = 1
},
.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,
.is_underscanning = TRUE,
}
},
.n_monitors = 1,
.logical_monitors = {
{
.layout = { .x = 0, .y = 0, .width = 1024, .height = 768 },
.scale = 1
}
},
.n_logical_monitors = 1,
.primary_logical_monitor = 0,
.n_outputs = 1,
.n_crtcs = 1,
.n_tiled_monitors = 0,
.screen_width = 1024,
.screen_height = 768
}
};
MetaMonitorTestSetup *test_setup;
if (!is_using_monitor_config_manager ())
{
g_test_skip ("Not using MetaMonitorConfigManager");
return;
}
test_setup = create_monitor_test_setup (&test_case,
MONITOR_TEST_FLAG_NONE);
set_custom_monitor_config ("underscanning.xml");
emulate_hotplug (test_setup);
check_monitor_configuration (&test_case);
}
void
init_monitor_tests (void)
{
@ -2151,9 +2329,13 @@ init_monitor_tests (void)
meta_test_monitor_lid_closed_no_external);
g_test_add_func ("/backends/monitor/no-outputs",
meta_test_monitor_no_outputs);
g_test_add_func ("/backends/monitor/underscanning-config",
meta_test_monitor_underscanning_config);
g_test_add_func ("/backends/monitor/custom/vertical-config",
meta_test_monitor_custom_vertical_config);
g_test_add_func ("/backends/monitor/custom/primary-config",
meta_test_monitor_custom_primary_config);
g_test_add_func ("/backends/monitor/custom/underscanning-config",
meta_test_monitor_custom_underscanning_config);
}