1
0
Fork 0

tests/stacking: Change primary monitor handling

The first monitor in stacking tests is the primary monitor but that
doesn't have to stay this way forever. Instead of special casing the
name "primary" to refer to whatever monitor happens to be the primary
monitor, we add an `assert_primary_monitor` command to verify that the
monitor that should be the primary monitor actually is.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2748>
This commit is contained in:
Sebastian Wick 2023-02-07 17:41:04 +01:00
parent 4727609d2b
commit 63522de4d0
6 changed files with 32 additions and 5 deletions

View file

@ -112,6 +112,7 @@ gboolean meta_monitor_is_active (MetaMonitor *monitor);
META_EXPORT_TEST
MetaOutput * meta_monitor_get_main_output (MetaMonitor *monitor);
META_EXPORT_TEST
gboolean meta_monitor_is_primary (MetaMonitor *monitor);
gboolean meta_monitor_supports_underscanning (MetaMonitor *monitor);

View file

@ -1,4 +1,4 @@
resize_monitor primary 800 600
resize_monitor default 800 600
num_workspaces 2

View file

@ -4,7 +4,7 @@
# 3. Resize such that the following resize will extend beyond the screen
# 4. Check that the window was moved to the position that would allow it to fit on the screen
resize_monitor primary 800 600
resize_monitor default 800 600
new_client w wayland
create w/1 csd

View file

@ -7,7 +7,7 @@ freeze w/1
resize w/1 100 200
show w/1 async
resize_monitor primary 1024 768
resize_monitor default 1024 768
wait

View file

@ -1,5 +1,6 @@
resize_monitor primary 800 600
resize_monitor default 800 600
add_monitor secondary 800 600
assert_primary_monitor default
num_workspaces 2

View file

@ -104,7 +104,7 @@ test_case_new (MetaContext *context)
g_free,
g_object_unref);
monitor = meta_create_test_monitor (context, 800, 600, 60.0);
g_hash_table_insert (test->virtual_monitors, g_strdup ("primary"), monitor);
g_hash_table_insert (test->virtual_monitors, g_strdup ("default"), monitor);
return test;
}
@ -1069,6 +1069,31 @@ test_case_do (TestCase *test,
g_hash_table_insert (test->virtual_monitors, g_strdup (argv[1]), monitor);
}
else if (strcmp (argv[0], "assert_primary_monitor") == 0)
{
MetaVirtualMonitor *virtual_monitor;
MetaOutput *output;
MetaMonitor *monitor;
if (argc != 2)
BAD_COMMAND ("usage: %s <monitor-id>", argv[0]);
virtual_monitor = g_hash_table_lookup (test->virtual_monitors, argv[1]);
if (!virtual_monitor)
BAD_COMMAND ("Unknown monitor %s", argv[1]);
output = meta_virtual_monitor_get_output (virtual_monitor);
monitor = meta_output_get_monitor (output);
if (!meta_monitor_is_primary (monitor))
{
g_set_error (error,
META_TEST_CLIENT_ERROR,
META_TEST_CLIENT_ERROR_ASSERTION_FAILED,
"Monitor %s is not the primary monitor", argv[1]);
return FALSE;
}
}
else if (strcmp (argv[0], "num_workspaces") == 0)
{
if (argc != 2)