diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2017-08-18 14:37:53 +0800 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2017-08-30 13:44:05 +0800 |
commit | e2d904c32b565626afe5602a4a03c1dc8cf999e0 (patch) | |
tree | b6296f9f23a9334ba3d1ba122c98c14d40765168 /src/tests/monitor-unit-tests.c | |
parent | fa9c09feee24412d87c9b04ee74cc0761ebc81d7 (diff) | |
download | mutter-e2d904c32b565626afe5602a4a03c1dc8cf999e0.tar.gz |
tests/monitor-unit-tests: Run a client while testing
Run a client while testing and check that it's alive when checking each
monitor configuration.
https://bugzilla.gnome.org/show_bug.cgi?id=730551
Diffstat (limited to 'src/tests/monitor-unit-tests.c')
-rw-r--r-- | src/tests/monitor-unit-tests.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index d1cb24d36..d17b0cdfe 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -28,6 +28,7 @@ #include "backends/meta-monitor-config-store.h" #include "tests/meta-monitor-manager-test.h" #include "tests/monitor-test-utils.h" +#include "tests/test-utils.h" #define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1) @@ -313,6 +314,53 @@ static MonitorTestCase initial_test_case = { } }; +static TestClient *monitor_test_client = NULL; + +#define TEST_CLIENT_NAME "client1" +#define TEST_CLIENT_WINDOW "window1" + +static void +create_monitor_test_client (void) +{ + GError *error = NULL; + + monitor_test_client = test_client_new (TEST_CLIENT_NAME, + META_WINDOW_CLIENT_TYPE_WAYLAND, + &error); + if (!monitor_test_client) + g_error ("Failed to launch test client: %s", error->message); + + if (!test_client_do (monitor_test_client, &error, + "create", TEST_CLIENT_WINDOW, + NULL)) + g_error ("Failed to create window: %s", error->message); + + if (!test_client_do (monitor_test_client, &error, + "show", TEST_CLIENT_WINDOW, + NULL)) + g_error ("Failed to show the window: %s", error->message); +} + +static void +check_monitor_test_client_state (void) +{ + GError *error = NULL; + + if (!test_client_wait (monitor_test_client, &error)) + g_error ("Failed to sync test client: %s", error->message); +} + +static void +destroy_monitor_test_client (void) +{ + GError *error = NULL; + + if (!test_client_quit (monitor_test_client, &error)) + g_error ("Failed to quit test client: %s", error->message); + + test_client_destroy (monitor_test_client); +} + static MetaOutput * output_from_winsys_id (MetaMonitorManager *monitor_manager, long winsys_id) @@ -782,6 +830,8 @@ check_monitor_configuration (MonitorTestCase *test_case) } } } + + check_monitor_test_client_state (); } static void @@ -4876,3 +4926,15 @@ init_monitor_tests (void) add_monitor_test ("/backends/monitor/migrated/rotated", meta_test_monitor_migrated_rotated); } + +void +pre_run_monitor_tests (void) +{ + create_monitor_test_client (); +} + +void +finish_monitor_tests (void) +{ + destroy_monitor_test_client (); +} |