[mutter] tests: Add tests for fractional scaling



commit 5ab116a87f7b7d39f1ef12a9761f7eb2dfc2a7a8
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu May 25 17:22:14 2017 +0800

    tests: Add tests for fractional scaling
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765011

 src/tests/monitor-configs/fractional-scale.xml |   23 +++++
 src/tests/monitor-store-unit-tests.c           |   58 +++++++++++++
 src/tests/monitor-unit-tests.c                 |  108 +++++++++++++++++++++++-
 3 files changed, 187 insertions(+), 2 deletions(-)
---
diff --git a/src/tests/monitor-configs/fractional-scale.xml b/src/tests/monitor-configs/fractional-scale.xml
new file mode 100644
index 0000000..eeb49b6
--- /dev/null
+++ b/src/tests/monitor-configs/fractional-scale.xml
@@ -0,0 +1,23 @@
+<monitors version="2">
+  <configuration>
+    <logicalmonitor>
+      <x>0</x>
+      <y>0</y>
+      <primary>yes</primary>
+      <scale>1.5</scale>
+      <monitor>
+       <monitorspec>
+         <connector>DP-1</connector>
+         <vendor>MetaProduct's Inc.</vendor>
+         <product>MetaMonitor</product>
+         <serial>0x123456</serial>
+       </monitorspec>
+       <mode>
+         <width>1200</width>
+         <height>900</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 b9a8798..ea6fa50 100644
--- a/src/tests/monitor-store-unit-tests.c
+++ b/src/tests/monitor-store-unit-tests.c
@@ -522,6 +522,62 @@ meta_test_monitor_store_scale (void)
 }
 
 static void
+meta_test_monitor_store_fractional_scale (void)
+{
+  MonitorStoreTestExpect expect = {
+    .configurations = {
+      {
+        .logical_monitors = {
+          {
+            .layout = {
+              .x = 0,
+              .y = 0,
+              .width = 800,
+              .height = 600
+            },
+            .scale = 1.5,
+            .is_primary = TRUE,
+            .is_presentation = FALSE,
+            .monitors = {
+              {
+                .connector = "DP-1",
+                .vendor = "MetaProduct's Inc.",
+                .product = "MetaMonitor",
+                .serial = "0x123456",
+                .mode = {
+                  .width = 1200,
+                  .height = 900,
+                  .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;
+    }
+
+  if (!meta_is_stage_views_enabled ())
+    {
+      g_test_skip ("Not using stage views");
+      return;
+    }
+
+  set_custom_monitor_config ("fractional-scale.xml");
+
+  check_monitor_configurations (&expect);
+}
+
+static void
 meta_test_monitor_store_mirrored (void)
 {
   MonitorStoreTestExpect expect = {
@@ -748,6 +804,8 @@ init_monitor_store_tests (void)
                    meta_test_monitor_store_underscanning);
   g_test_add_func ("/backends/monitor-store/scale",
                    meta_test_monitor_store_scale);
+  g_test_add_func ("/backends/monitor-store/fractional-scale",
+                   meta_test_monitor_store_fractional_scale);
   g_test_add_func ("/backends/monitor-store/mirrored",
                    meta_test_monitor_store_mirrored);
   g_test_add_func ("/backends/monitor-store/first-rotated",
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index aadd162..f3563cd 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -102,7 +102,7 @@ typedef struct _MonitorTestCaseOutput
   int width_mm;
   int height_mm;
   MetaTileInfo tile_info;
-  int scale;
+  float scale;
   gboolean is_laptop_panel;
   gboolean is_underscanning;
 } MonitorTestCaseOutput;
@@ -152,7 +152,7 @@ typedef struct _MonitorTestCaseMonitor
 typedef struct _MonitorTestCaseLogicalMonitor
 {
   MetaRectangle layout;
-  int scale;
+  float scale;
   int monitors[MAX_N_MONITORS];
   int n_monitors;
   MetaMonitorTransform transform;
@@ -3010,6 +3010,108 @@ meta_test_monitor_custom_scale_config (void)
 }
 
 static void
+meta_test_monitor_custom_fractional_scale_config (void)
+{
+  MonitorTestCase test_case = {
+    .setup = {
+      .modes = {
+        {
+          .width = 1200,
+          .height = 900,
+          .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 = 1200,
+              .height = 900,
+              .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 = 800, .height = 600 },
+          .scale = 1.5
+        }
+      },
+      .n_logical_monitors = 1,
+      .primary_logical_monitor = 0,
+      .n_outputs = 1,
+      .crtcs = {
+        {
+          .current_mode = 0,
+        }
+      },
+      .n_crtcs = 1,
+      .n_tiled_monitors = 0,
+      .screen_width = 800,
+      .screen_height = 600
+    }
+  };
+  MetaMonitorTestSetup *test_setup;
+
+  if (!is_using_monitor_config_manager ())
+    {
+      g_test_skip ("Not using MetaMonitorConfigManager");
+      return;
+    }
+
+  if (!meta_is_stage_views_enabled ())
+    {
+      g_test_skip ("Not using stage views");
+      return;
+    }
+
+  test_setup = create_monitor_test_setup (&test_case,
+                                          MONITOR_TEST_FLAG_NONE);
+  set_custom_monitor_config ("fractional-scale.xml");
+  emulate_hotplug (test_setup);
+
+  check_monitor_configuration (&test_case);
+}
+
+static void
 meta_test_monitor_custom_tiled_config (void)
 {
   MonitorTestCase test_case = {
@@ -4288,6 +4390,8 @@ init_monitor_tests (void)
                    meta_test_monitor_custom_underscanning_config);
   g_test_add_func ("/backends/monitor/custom/scale-config",
                    meta_test_monitor_custom_scale_config);
+  g_test_add_func ("/backends/monitor/custom/fractional-scale-config",
+                   meta_test_monitor_custom_fractional_scale_config);
   g_test_add_func ("/backends/monitor/custom/tiled-config",
                    meta_test_monitor_custom_tiled_config);
   g_test_add_func ("/backends/monitor/custom/tiled-custom-resolution-config",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]