tests: Test that transforms are properly configured

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2017-03-21 14:28:25 +08:00
parent dd14e1cebc
commit 17c54c6e03

View File

@ -155,10 +155,12 @@ typedef struct _MonitorTestCaseLogicalMonitor
int scale; int scale;
int monitors[MAX_N_MONITORS]; int monitors[MAX_N_MONITORS];
int n_monitors; int n_monitors;
MetaMonitorTransform transform;
} MonitorTestCaseLogicalMonitor; } MonitorTestCaseLogicalMonitor;
typedef struct _MonitorTestCaseCrtcExpect typedef struct _MonitorTestCaseCrtcExpect
{ {
MetaMonitorTransform transform;
int current_mode; int current_mode;
int x; int x;
int y; int y;
@ -438,6 +440,9 @@ check_logical_monitor (MonitorTestCase *test_case,
g_assert_cmpint (logical_monitor->scale, g_assert_cmpint (logical_monitor->scale,
==, ==,
test_logical_monitor->scale); test_logical_monitor->scale);
g_assert_cmpuint (logical_monitor->transform,
==,
test_logical_monitor->transform);
if (logical_monitor == monitor_manager->primary_logical_monitor) if (logical_monitor == monitor_manager->primary_logical_monitor)
g_assert (meta_logical_monitor_is_primary (logical_monitor)); g_assert (meta_logical_monitor_is_primary (logical_monitor));
@ -708,6 +713,10 @@ check_monitor_configuration (MonitorTestCase *test_case)
g_assert (crtc->current_mode == expected_current_mode); g_assert (crtc->current_mode == expected_current_mode);
g_assert_cmpuint (crtc->transform,
==,
test_case->expect.crtcs[i].transform);
get_compensated_crtc_position (crtc, &crtc_x, &crtc_y); get_compensated_crtc_position (crtc, &crtc_x, &crtc_y);
g_assert_cmpint (crtc_x, ==, test_case->expect.crtcs[i].x); g_assert_cmpint (crtc_x, ==, test_case->expect.crtcs[i].x);
@ -3210,6 +3219,282 @@ meta_test_monitor_custom_mirrored_config (void)
check_monitor_configuration (&test_case); check_monitor_configuration (&test_case);
} }
static void
meta_test_monitor_custom_first_rotated_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,
},
{
.crtc = 1,
.modes = { 0 },
.n_modes = 1,
.preferred_mode = 0,
.possible_crtcs = { 1 },
.n_possible_crtcs = 1,
.width_mm = 222,
.height_mm = 125,
}
},
.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 = 222,
.height_mm = 125,
}
},
.n_monitors = 2,
.logical_monitors = {
{
.monitors = { 0 },
.n_monitors = 1,
.layout = { .x = 0, .y = 0, .width = 768, .height = 1024 },
.scale = 1,
.transform = META_MONITOR_TRANSFORM_270
},
{
.monitors = { 1 },
.n_monitors = 1,
.layout = { .x = 768, .y = 0, .width = 1024, .height = 768 },
.scale = 1
}
},
.n_logical_monitors = 2,
.primary_logical_monitor = 0,
.n_outputs = 2,
.crtcs = {
{
.current_mode = 0,
.transform = META_MONITOR_TRANSFORM_270
},
{
.current_mode = 0,
}
},
.n_crtcs = 2,
.screen_width = 768 + 1024,
.screen_height = 1024
}
};
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 ("first-rotated.xml");
emulate_hotplug (test_setup);
check_monitor_configuration (&test_case);
}
static void
meta_test_monitor_custom_second_rotated_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,
},
{
.crtc = 1,
.modes = { 0 },
.n_modes = 1,
.preferred_mode = 0,
.possible_crtcs = { 1 },
.n_possible_crtcs = 1,
.width_mm = 222,
.height_mm = 125,
}
},
.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 = 222,
.height_mm = 125,
}
},
.n_monitors = 2,
.logical_monitors = {
{
.monitors = { 0 },
.n_monitors = 1,
.layout = { .x = 0, .y = 256, .width = 1024, .height = 768 },
.scale = 1
},
{
.monitors = { 1 },
.n_monitors = 1,
.layout = { .x = 1024, .y = 0, .width = 768, .height = 1024 },
.scale = 1,
.transform = META_MONITOR_TRANSFORM_90
}
},
.n_logical_monitors = 2,
.primary_logical_monitor = 0,
.n_outputs = 2,
.crtcs = {
{
.current_mode = 0,
},
{
.current_mode = 0,
.transform = META_MONITOR_TRANSFORM_90
}
},
.n_crtcs = 2,
.screen_width = 768 + 1024,
.screen_height = 1024
}
};
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 ("second-rotated.xml");
emulate_hotplug (test_setup);
check_monitor_configuration (&test_case);
}
void void
init_monitor_tests (void) init_monitor_tests (void)
{ {
@ -3260,4 +3545,8 @@ init_monitor_tests (void)
meta_test_monitor_custom_tiled_custom_resolution_config); meta_test_monitor_custom_tiled_custom_resolution_config);
g_test_add_func ("/backends/monitor/custom/mirrored-config", g_test_add_func ("/backends/monitor/custom/mirrored-config",
meta_test_monitor_custom_mirrored_config); meta_test_monitor_custom_mirrored_config);
g_test_add_func ("/backends/monitor/custom/first-rotated-config",
meta_test_monitor_custom_first_rotated_config);
g_test_add_func ("/backends/monitor/custom/second-rotated-config",
meta_test_monitor_custom_second_rotated_config);
} }