[mutter] monitor-store-unit-tests: Verify <maxbpc> XML is stored correctly



commit 0cfd0c3a8cb26270b51bb631348c910a97751b77
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Wed Jun 29 17:47:26 2022 +0800

    monitor-store-unit-tests: Verify <maxbpc> XML is stored correctly
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>

 src/tests/monitor-configs/max-bpc.xml | 23 +++++++++++++++
 src/tests/monitor-store-unit-tests.c  | 54 +++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
---
diff --git a/src/tests/monitor-configs/max-bpc.xml b/src/tests/monitor-configs/max-bpc.xml
new file mode 100644
index 0000000000..c98e6605cc
--- /dev/null
+++ b/src/tests/monitor-configs/max-bpc.xml
@@ -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&apos;s Inc.</vendor>
+         <product>MetaMonitor</product>
+         <serial>0x123456</serial>
+       </monitorspec>
+       <mode>
+         <width>1024</width>
+         <height>768</height>
+         <rate>60.000495910644531</rate>
+       </mode>
+        <maxbpc>12</maxbpc>
+      </monitor>
+    </logicalmonitor>
+  </configuration>
+</monitors>
diff --git a/src/tests/monitor-store-unit-tests.c b/src/tests/monitor-store-unit-tests.c
index 38f4bc52fc..f8fd2b2628 100644
--- a/src/tests/monitor-store-unit-tests.c
+++ b/src/tests/monitor-store-unit-tests.c
@@ -48,6 +48,7 @@ typedef struct _MonitorStoreTestCaseMonitor
   const char *serial;
   MonitorStoreTestCaseMonitorMode mode;
   gboolean is_underscanning;
+  unsigned int max_bpc;
 } MonitorStoreTestCaseMonitor;
 
 typedef struct _MonitorStoreTestCaseLogicalMonitor
@@ -196,6 +197,12 @@ check_monitor_store_configuration (MetaMonitorConfigStore        *config_store,
           g_assert_cmpint (monitor_config->enable_underscanning,
                            ==,
                            test_monitor->is_underscanning);
+          g_assert_cmpint (monitor_config->has_max_bpc,
+                           ==,
+                           !!test_monitor->max_bpc);
+          g_assert_cmpint (monitor_config->max_bpc,
+                           ==,
+                           test_monitor->max_bpc);
         }
     }
 }
@@ -446,6 +453,51 @@ meta_test_monitor_store_underscanning (void)
   check_monitor_store_configurations (&expect);
 }
 
+static void
+meta_test_monitor_store_max_bpc (void)
+{
+  MonitorStoreTestExpect expect = {
+    .configurations = {
+      {
+        .logical_monitors = {
+          {
+            .layout = {
+              .x = 0,
+              .y = 0,
+              .width = 1024,
+              .height = 768
+            },
+            .scale = 1,
+            .is_primary = TRUE,
+            .is_presentation = FALSE,
+            .monitors = {
+              {
+                .connector = "DP-1",
+                .vendor = "MetaProduct's Inc.",
+                .product = "MetaMonitor",
+                .serial = "0x123456",
+                .max_bpc = 12,
+                .mode = {
+                  .width = 1024,
+                  .height = 768,
+                  .refresh_rate = 60.000495910644531
+                }
+              }
+            },
+            .n_monitors = 1,
+          },
+        },
+        .n_logical_monitors = 1
+      }
+    },
+    .n_configurations = 1
+  };
+
+  meta_set_custom_monitor_config (test_context, "max-bpc.xml");
+
+  check_monitor_store_configurations (&expect);
+}
+
 static void
 meta_test_monitor_store_scale (void)
 {
@@ -1013,6 +1065,8 @@ 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/max-bpc",
+                   meta_test_monitor_store_max_bpc);
   g_test_add_func ("/backends/monitor-store/scale",
                    meta_test_monitor_store_scale);
   g_test_add_func ("/backends/monitor-store/fractional-scale",


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