tests: Add more monitor config policy parsing tests

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
This commit is contained in:
Jonas Ådahl 2021-09-24 19:07:32 +02:00 committed by Marge Bot
parent c611b64c53
commit 85a3ca3d17
5 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<monitors version="2">
<policy>
<stores>
<store>user</store>
<store>user</store>
</stores>
</policy>
</monitors>

View File

@ -0,0 +1,7 @@
<monitors version="2">
<policy>
<stores>
<store></store>
</stores>
</policy>
</monitors>

View File

@ -0,0 +1,8 @@
<monitors version="2">
<policy>
<stores>
<store>user</store>
<store>not-a-store</store>
</stores>
</policy>
</monitors>

View File

@ -0,0 +1,12 @@
<monitors version="2">
<policy>
<stores>
<store>user</store>
<store>system</store>
</stores>
<stores>
<store>system</store>
<store>user</store>
</stores>
</policy>
</monitors>

View File

@ -919,6 +919,42 @@ meta_test_monitor_store_policy (void)
META_CONFIG_STORE_SYSTEM); META_CONFIG_STORE_SYSTEM);
} }
static void
meta_test_monitor_store_policy_empty (void)
{
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
"*Invalid store*");
set_custom_monitor_system_config ("policy-empty.xml");
g_test_assert_expected_messages ();
}
static void
meta_test_monitor_store_policy_duplicate (void)
{
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
"*Multiple identical stores*");
set_custom_monitor_system_config ("policy-duplicate.xml");
g_test_assert_expected_messages ();
}
static void
meta_test_monitor_store_policy_invalid (void)
{
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
"*Invalid store*");
set_custom_monitor_system_config ("policy-invalid.xml");
g_test_assert_expected_messages ();
}
static void
meta_test_monitor_store_policy_multiple (void)
{
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
"*Multiple stores elements under policy*");
set_custom_monitor_system_config ("policy-multiple.xml");
g_test_assert_expected_messages ();
}
void void
init_monitor_store_tests (void) init_monitor_store_tests (void)
{ {
@ -950,4 +986,12 @@ init_monitor_store_tests (void)
meta_test_monitor_store_policy_not_allowed); meta_test_monitor_store_policy_not_allowed);
g_test_add_func ("/backends/monitor-store/policy", g_test_add_func ("/backends/monitor-store/policy",
meta_test_monitor_store_policy); meta_test_monitor_store_policy);
g_test_add_func ("/backends/monitor-store/policy-empty",
meta_test_monitor_store_policy_empty);
g_test_add_func ("/backends/monitor-store/policy-duplicate",
meta_test_monitor_store_policy_duplicate);
g_test_add_func ("/backends/monitor-store/policy-invalid",
meta_test_monitor_store_policy_invalid);
g_test_add_func ("/backends/monitor-store/policy-multiple",
meta_test_monitor_store_policy_multiple);
} }