[mutter] tests: Test configured custom logical monitor scale
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests: Test configured custom logical monitor scale
- Date: Fri, 7 Apr 2017 14:32:43 +0000 (UTC)
commit 63bc86cd43e33bcc2a7ae9352064110f548fbb73
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Jan 19 22:46:33 2017 +0800
tests: Test configured custom logical monitor scale
Check that a configured logical monitor scale overrides any calculated
one.
https://bugzilla.gnome.org/show_bug.cgi?id=777732
src/tests/monitor-configs/scale.xml | 23 ++++++++
src/tests/monitor-store-unit-tests.c | 62 +++++++++++++++++++++
src/tests/monitor-unit-tests.c | 98 ++++++++++++++++++++++++++++++++++
3 files changed, 183 insertions(+), 0 deletions(-)
---
diff --git a/src/tests/monitor-configs/scale.xml b/src/tests/monitor-configs/scale.xml
new file mode 100644
index 0000000..d6c66b7
--- /dev/null
+++ b/src/tests/monitor-configs/scale.xml
@@ -0,0 +1,23 @@
+<monitors version="2">
+ <configuration>
+ <logicalmonitor>
+ <x>0</x>
+ <y>0</y>
+ <primary>yes</primary>
+ <scale>2</scale>
+ <monitor>
+ <monitorspec>
+ <connector>DP-1</connector>
+ <vendor>MetaProduct's Inc.</vendor>
+ <product>MetaMonitor</product>
+ <serial>0x123456</serial>
+ </monitorspec>
+ <mode>
+ <width>1920</width>
+ <height>1080</height>
+ <rate>60.000495910644531</rate>
+ </mode>
+ </monitor>
+ </logicalmonitor>
+ </configuration>
+</monitors>
diff --git a/src/tests/monitor-store-unit-tests.c b/src/tests/monitor-store-unit-tests.c
index 39d370d..f31bf10 100644
--- a/src/tests/monitor-store-unit-tests.c
+++ b/src/tests/monitor-store-unit-tests.c
@@ -51,6 +51,7 @@ typedef struct _MonitorTestCaseMonitor
typedef struct _MonitorTestCaseLogicalMonitor
{
MetaRectangle layout;
+ int scale;
gboolean is_primary;
gboolean is_presentation;
MonitorTestCaseMonitor monitors[MAX_N_MONITORS];
@@ -139,6 +140,9 @@ check_monitor_configuration (MetaMonitorConfigStore *config_store,
g_assert (meta_rectangle_equal (&logical_monitor_config->layout,
&config_expect->logical_monitors[i].layout));
+ g_assert_cmpint (logical_monitor_config->scale,
+ ==,
+ config_expect->logical_monitors[i].scale);
g_assert_cmpint (logical_monitor_config->is_primary,
==,
config_expect->logical_monitors[i].is_primary);
@@ -220,6 +224,7 @@ meta_test_monitor_store_single (void)
.width = 1920,
.height = 1080
},
+ .scale = 1,
.is_primary = TRUE,
.is_presentation = FALSE,
.monitors = {
@@ -269,6 +274,7 @@ meta_test_monitor_store_vertical (void)
.width = 1024,
.height = 768
},
+ .scale = 1,
.is_primary = TRUE,
.is_presentation = FALSE,
.monitors = {
@@ -293,6 +299,7 @@ meta_test_monitor_store_vertical (void)
.width = 800,
.height = 600
},
+ .scale = 1,
.is_primary = FALSE,
.is_presentation = FALSE,
.monitors = {
@@ -342,6 +349,7 @@ meta_test_monitor_store_primary (void)
.width = 1024,
.height = 768
},
+ .scale = 1,
.is_primary = FALSE,
.is_presentation = FALSE,
.monitors = {
@@ -366,6 +374,7 @@ meta_test_monitor_store_primary (void)
.width = 800,
.height = 600
},
+ .scale = 1,
.is_primary = TRUE,
.is_presentation = FALSE,
.monitors = {
@@ -415,6 +424,7 @@ meta_test_monitor_store_underscanning (void)
.width = 1024,
.height = 768
},
+ .scale = 1,
.is_primary = TRUE,
.is_presentation = FALSE,
.monitors = {
@@ -451,6 +461,56 @@ meta_test_monitor_store_underscanning (void)
check_monitor_configurations (&expect);
}
+static void
+meta_test_monitor_store_scale (void)
+{
+ MonitorStoreTestExpect expect = {
+ .configurations = {
+ {
+ .logical_monitors = {
+ {
+ .layout = {
+ .x = 0,
+ .y = 0,
+ .width = 1920,
+ .height = 1080
+ },
+ .scale = 2,
+ .is_primary = TRUE,
+ .is_presentation = FALSE,
+ .monitors = {
+ {
+ .connector = "DP-1",
+ .vendor = "MetaProduct's Inc.",
+ .product = "MetaMonitor",
+ .serial = "0x123456",
+ .mode = {
+ .width = 1920,
+ .height = 1080,
+ .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 ("scale.xml");
+
+ check_monitor_configurations (&expect);
+}
+
void
init_monitor_store_tests (void)
{
@@ -462,4 +522,6 @@ init_monitor_store_tests (void)
meta_test_monitor_store_primary);
g_test_add_func ("/backends/monitor-store/underscanning",
meta_test_monitor_store_underscanning);
+ g_test_add_func ("/backends/monitor-store/scale",
+ meta_test_monitor_store_scale);
}
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index a4c48b9..a8c100a 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -2626,6 +2626,102 @@ meta_test_monitor_custom_underscanning_config (void)
check_monitor_configuration (&test_case);
}
+static void
+meta_test_monitor_custom_scale_config (void)
+{
+ MonitorTestCase test_case = {
+ .setup = {
+ .modes = {
+ {
+ .width = 1920,
+ .height = 1080,
+ .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 = 1920,
+ .height = 1080,
+ .crtc_modes = {
+ {
+ .output = 0,
+ .crtc_mode = 0
+ }
+ }
+ }
+ },
+ .n_modes = 1,
+ .current_mode = 0,
+ .width_mm = 222,
+ .height_mm = 125,
+ }
+ },
+ .n_monitors = 1,
+ .logical_monitors = {
+ {
+ .monitors = { 0 },
+ .n_monitors = 1,
+ .layout = { .x = 0, .y = 0, .width = 1920, .height = 1080 },
+ .scale = 2
+ }
+ },
+ .n_logical_monitors = 1,
+ .primary_logical_monitor = 0,
+ .n_outputs = 1,
+ .crtcs = {
+ {
+ .current_mode = 0,
+ }
+ },
+ .n_crtcs = 1,
+ .n_tiled_monitors = 0,
+ .screen_width = 1920,
+ .screen_height = 1080
+ }
+ };
+ 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 ("scale.xml");
+ emulate_hotplug (test_setup);
+
+ check_monitor_configuration (&test_case);
+}
+
void
init_monitor_tests (void)
{
@@ -2668,4 +2764,6 @@ init_monitor_tests (void)
meta_test_monitor_custom_primary_config);
g_test_add_func ("/backends/monitor/custom/underscanning-config",
meta_test_monitor_custom_underscanning_config);
+ g_test_add_func ("/backends/monitor/custom/scale-config",
+ meta_test_monitor_custom_scale_config);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]