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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
This commit is contained in:
Daniel van Vugt 2022-06-29 17:47:26 +08:00 committed by Marge Bot
parent 26a9dd7f88
commit 0cfd0c3a8c
2 changed files with 77 additions and 0 deletions

View File

@ -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>

View File

@ -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",