monitor-unit-tests: Add tests to verify the computed scaling values
Scaling values computation code served us well in the past years but it's quite delicate and it has some issues in edge cases, so add a test that verifies that the computed scaling values for all the most common resolutions (and some that may be common in future) are what we expect to be. This may also serve us in future when we'd define a better algorithm to compute the preferred scale, but this not the day. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
This commit is contained in:
@ -5727,6 +5727,316 @@ meta_test_monitor_migrated_wiggle (void)
|
||||
g_error ("Failed to remove test data output file: %s", error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_test_monitor_supported_fractional_scales (void)
|
||||
{
|
||||
MonitorTestCase test_case = {
|
||||
.setup = {
|
||||
.n_modes = 21,
|
||||
.modes = {
|
||||
{
|
||||
.width = 800,
|
||||
.height = 600,
|
||||
.refresh_rate = 60.0
|
||||
},
|
||||
{
|
||||
.width = 1024,
|
||||
.height = 768,
|
||||
.refresh_rate = 60.0
|
||||
},
|
||||
{
|
||||
.width = 1280,
|
||||
.height = 720,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1280,
|
||||
.height = 800,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1280,
|
||||
.height = 1024,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1366,
|
||||
.height = 768,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1440,
|
||||
.height = 900,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1400,
|
||||
.height = 1050,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1600,
|
||||
.height = 900,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1920,
|
||||
.height = 1080,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 1920,
|
||||
.height = 1200,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 2650,
|
||||
.height = 1440,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 2880,
|
||||
.height = 1800,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 3200,
|
||||
.height = 1800,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 3200,
|
||||
.height = 2048,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 3840,
|
||||
.height = 2160,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 3840,
|
||||
.height = 2400,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 4096,
|
||||
.height = 2160,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 4096,
|
||||
.height = 3072,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 5120,
|
||||
.height = 2880,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
{
|
||||
.width = 7680,
|
||||
.height = 4320,
|
||||
.refresh_rate = 60.0,
|
||||
},
|
||||
},
|
||||
.outputs = {
|
||||
{
|
||||
.crtc = -1,
|
||||
.modes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20 },
|
||||
.n_modes = 21,
|
||||
.preferred_mode = 5,
|
||||
.possible_crtcs = { 0 },
|
||||
.n_possible_crtcs = 1,
|
||||
.width_mm = 222,
|
||||
.height_mm = 125
|
||||
}
|
||||
},
|
||||
.n_outputs = 1,
|
||||
.crtcs = {
|
||||
{
|
||||
.current_mode = 0
|
||||
}
|
||||
},
|
||||
.n_crtcs = 1
|
||||
},
|
||||
|
||||
.expect = {
|
||||
.n_monitors = 1,
|
||||
.monitors = {
|
||||
{
|
||||
.n_modes = 21,
|
||||
.modes = {
|
||||
{
|
||||
.width = 800,
|
||||
.height = 600,
|
||||
.n_scales = 1,
|
||||
.scales = { 1.000000 },
|
||||
},
|
||||
{
|
||||
.width = 1024,
|
||||
.height = 768,
|
||||
.n_scales = 2,
|
||||
.scales = { 1.000000, 1.24878049 },
|
||||
},
|
||||
{
|
||||
.width = 1280,
|
||||
.height = 720,
|
||||
.n_scales = 3,
|
||||
.scales = { 1.000000, 1.250000, 1.509434 },
|
||||
},
|
||||
{
|
||||
.width = 1280,
|
||||
.height = 800,
|
||||
.n_scales = 3,
|
||||
.scales = { 1.000000, 1.250000, 1.495327 },
|
||||
},
|
||||
{
|
||||
.width = 1280,
|
||||
.height = 1024,
|
||||
.n_scales = 4,
|
||||
.scales = { 1.000000, 1.248780, 1.497076, 1.753425 },
|
||||
},
|
||||
{
|
||||
.width = 1366,
|
||||
.height = 768,
|
||||
.n_scales = 1,
|
||||
.scales = { 1.000000 },
|
||||
},
|
||||
{
|
||||
.width = 1440,
|
||||
.height = 900,
|
||||
.n_scales = 4,
|
||||
.scales = { 1.000000, 1.250000, 1.500000, 1.747573 },
|
||||
},
|
||||
{
|
||||
.width = 1400,
|
||||
.height = 1050,
|
||||
.n_scales = 4,
|
||||
.scales = { 1.000000, 1.250000, 1.502146, 1.750000 },
|
||||
},
|
||||
{
|
||||
.width = 1600,
|
||||
.height = 900,
|
||||
.n_scales = 4,
|
||||
.scales = { 1.000000, 1.250000, 1.492537, 1.754386 },
|
||||
},
|
||||
{
|
||||
.width = 1920,
|
||||
.height = 1080,
|
||||
.n_scales = 6,
|
||||
.scales = { 1.000000, 1.250000, 1.500000, 1.739130, 2.000000,
|
||||
2.307692 },
|
||||
},
|
||||
{
|
||||
.width = 1920,
|
||||
.height = 1200,
|
||||
.n_scales = 6,
|
||||
.scales = { 1.000000, 1.250000, 1.500000, 1.751825, 2.000000,
|
||||
2.242991 },
|
||||
},
|
||||
{
|
||||
.width = 2650,
|
||||
.height = 1440,
|
||||
.n_scales = 6,
|
||||
.scales = { 1.000000, 1.250000, 1.428571, 1.666667, 2.000000,
|
||||
2.500000
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 2880,
|
||||
.height = 1800,
|
||||
.n_scales = 11,
|
||||
.scales = { 1.000000, 1.250000, 1.500000, 1.747573, 2.000000,
|
||||
2.250000, 2.500000, 2.748092, 3.000000, 3.243243,
|
||||
3.495146
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 3200,
|
||||
.height = 1800,
|
||||
.n_scales = 12,
|
||||
.scales = { 1.000000, 1.250000, 1.503759, 1.754386, 2.000000,
|
||||
2.247191, 2.500000, 2.739726, 2.985075, 3.225806,
|
||||
3.508772, 3.773585
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 3200,
|
||||
.height = 2048,
|
||||
.n_scales = 13,
|
||||
.scales = { 1.000000, 1.254902, 1.505882, 1.753425, 2.000000,
|
||||
2.245614, 2.509804, 2.723404, 2.976744, 3.282051,
|
||||
3.459460, 3.764706, 4.000000,
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 3840,
|
||||
.height = 2160,
|
||||
.n_scales = 13,
|
||||
.scales = { 1.000000, 1.250000, 1.500000, 1.751825, 2.000000,
|
||||
2.201835, 2.500000, 2.758621, 3.000000, 3.243243,
|
||||
3.478261, 3.750000, 4.000000
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 3840,
|
||||
.height = 2400,
|
||||
.n_scales = 13,
|
||||
.scales = { 1.000000, 1.250000, 1.500000, 1.751825, 2.000000,
|
||||
2.253521, 2.500000, 2.742857, 3.000000, 3.243243,
|
||||
3.503650, 3.750000, 4.000000
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 4096,
|
||||
.height = 2160,
|
||||
.n_scales = 10,
|
||||
.scales = { 1.000000, 1.333333, 1.454545, 1.777778, 2.000000,
|
||||
2.666667, 2.666667, 3.200000, 3.200000, 4.000000
|
||||
}
|
||||
},
|
||||
{
|
||||
.width = 4096,
|
||||
.height = 3072,
|
||||
.n_scales = 13,
|
||||
.scales = { 1.000000, 1.250305, 1.499268, 1.750427, 2.000000,
|
||||
2.245614, 2.497561, 2.752688, 3.002933, 3.250794,
|
||||
3.494880, 3.750916, 4.000000
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 5120,
|
||||
.height = 2880,
|
||||
.n_scales = 13,
|
||||
.scales = { 1.000000, 1.250000, 1.495327, 1.748634, 2.000000,
|
||||
2.253521, 2.500000, 2.758621, 2.990654, 3.265306,
|
||||
3.516484, 3.764706, 4.000000
|
||||
},
|
||||
},
|
||||
{
|
||||
.width = 7680,
|
||||
.height = 4320,
|
||||
.n_scales = 13,
|
||||
.scales = { 1.000000, 1.250000, 1.500000, 1.751825, 2.000000,
|
||||
2.211982, 2.500000, 2.742857, 3.000000, 3.243243,
|
||||
3.503650, 3.750000, 4.000000
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
MetaMonitorTestSetup *test_setup;
|
||||
test_setup = create_monitor_test_setup (&test_case.setup,
|
||||
MONITOR_TEST_FLAG_NO_STORED);
|
||||
emulate_hotplug (test_setup);
|
||||
check_monitor_scales (&test_case.expect, META_MONITOR_SCALES_CONSTRAINT_NONE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_case_setup (void **fixture,
|
||||
const void *data)
|
||||
@ -5853,6 +6163,9 @@ init_monitor_tests (void)
|
||||
|
||||
add_monitor_test ("/backends/monitor/wm/tiling",
|
||||
meta_test_monitor_wm_tiling);
|
||||
|
||||
add_monitor_test ("/backends/monitor/suppported_scales/fractional",
|
||||
meta_test_monitor_supported_fractional_scales);
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user