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

@ -182,6 +182,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
output->is_primary = output_info->is_primary;
output->is_presentation = output_info->is_presentation;
output->is_underscanning = output_info->is_underscanning;
}
/* Disable CRTCs not mentioned in the list */

View File

@ -0,0 +1,23 @@
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>0</y>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>1024</width>
<height>768</height>
<rate>60.000495910644531</rate>
</mode>
<underscanning>yes</underscanning>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View File

@ -176,6 +176,9 @@ check_monitor_configuration (MetaMonitorConfigStore *config_store,
g_assert_cmpfloat (monitor_config->mode_spec->refresh_rate,
==,
test_monitor->mode.refresh_rate);
g_assert_cmpint (monitor_config->is_underscanning,
==,
test_monitor->is_underscanning);
}
}
}
@ -394,6 +397,56 @@ meta_test_monitor_store_primary (void)
check_monitor_configurations (&expect);
}
static void
meta_test_monitor_store_underscanning (void)
{
MonitorStoreTestExpect expect = {
.configurations = {
{
.logical_monitors = {
{
.layout = {
.x = 0,
.y = 0,
.width = 1024,
.height = 768
},
.is_primary = TRUE,
.is_presentation = FALSE,
.monitors = {
{
.connector = "DP-1",
.vendor = "MetaProduct's Inc.",
.product = "MetaMonitor",
.serial = "0x123456",
.is_underscanning = TRUE,
.mode = {
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
}
},
.n_monitors = 1,
},
},
.n_logical_monitors = 1
}
},
.n_configurations = 1
};
if (!is_using_monitor_config_manager ())
{
g_test_skip ("Not using MetaMonitorConfigManager");
return;
}
set_custom_monitor_config ("underscanning.xml");
check_monitor_configurations (&expect);
}
void
init_monitor_store_tests (void)
{
@ -403,4 +456,6 @@ init_monitor_store_tests (void)
meta_test_monitor_store_vertical);
g_test_add_func ("/backends/monitor-store/primary",
meta_test_monitor_store_primary);
g_test_add_func ("/backends/monitor-store/underscanning",
meta_test_monitor_store_underscanning);
}

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);
}