[mutter] tests: Split out monitor configuration tests to its own test case



commit d8a66a38927834404b7242a8be142467777d3df8
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Sep 30 14:47:51 2021 +0200

    tests: Split out monitor configuration tests to its own test case
    
    This makes it easier to run without having to run all the other tests,
    and it will allow us to be more particular with its setup.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>

 src/tests/meson.build          | 22 ++++++++++++++++++++--
 src/tests/monitor-test-utils.h |  4 ++--
 src/tests/monitor-unit-tests.c | 35 +++++++++++++++++++++++++++++------
 src/tests/monitor-unit-tests.h | 34 ----------------------------------
 src/tests/unit-tests.c         |  7 -------
 5 files changed, 51 insertions(+), 51 deletions(-)
---
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 6f13914533..5fdc844b5c 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -143,9 +143,20 @@ unit_tests = executable('mutter-test-unit-tests',
     'monitor-test-utils.h',
     'monitor-transform-tests.c',
     'monitor-transform-tests.h',
-    'monitor-unit-tests.c',
     'orientation-manager-unit-tests.c',
-    'monitor-unit-tests.h',
+  ],
+  include_directories: tests_includes,
+  c_args: tests_c_args,
+  dependencies: libmutter_test_dep,
+  install: have_installed_tests,
+  install_dir: mutter_installed_tests_libexecdir,
+)
+
+monitor_unit_tests = executable('mutter-monitor-unit-tests',
+  sources: [
+    'monitor-test-utils.c',
+    'monitor-test-utils.h',
+    'monitor-unit-tests.c',
   ],
   include_directories: tests_includes,
   c_args: tests_c_args,
@@ -374,6 +385,13 @@ test('normal', unit_tests,
   timeout: 60,
 )
 
+test('monitors', monitor_unit_tests,
+  suite: ['core', 'mutter/unit'],
+  env: test_env,
+  is_parallel: false,
+  timeout: 60,
+)
+
 test('headless-start', headless_start_test,
   suite: ['core', 'mutter/unit'],
   env: test_env,
diff --git a/src/tests/monitor-test-utils.h b/src/tests/monitor-test-utils.h
index 6027a56748..3f2f757d01 100644
--- a/src/tests/monitor-test-utils.h
+++ b/src/tests/monitor-test-utils.h
@@ -191,11 +191,11 @@ typedef struct _MonitorTestCaseExpect
   int screen_height;
 } MonitorTestCaseExpect;
 
-struct _MonitorTestCase
+typedef struct _MonitorTestCase
 {
   MonitorTestCaseSetup setup;
   MonitorTestCaseExpect expect;
-};
+} MonitorTestCase;
 
 MetaGpu * test_get_gpu (void);
 
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 7af85c4046..ca337ce7e8 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -19,8 +19,6 @@
 
 #include "config.h"
 
-#include "tests/monitor-unit-tests.h"
-
 #include "backends/meta-backend-private.h"
 #include "backends/meta-crtc.h"
 #include "backends/meta-logical-monitor.h"
@@ -31,13 +29,15 @@
 #include "backends/meta-output.h"
 #include "core/window-private.h"
 #include "meta-backend-test.h"
+#include "meta-test/meta-context-test.h"
 #include "tests/meta-monitor-manager-test.h"
 #include "tests/meta-sensors-proxy-mock.h"
 #include "tests/monitor-test-utils.h"
 #include "tests/meta-test-utils.h"
-#include "tests/unit-tests.h"
 #include "x11/meta-x11-display-private.h"
 
+static MetaContext *test_context;
+
 static MonitorTestCase initial_test_case = {
   .setup = {
     .modes = {
@@ -8776,7 +8776,7 @@ create_initial_test_setup (void)
                                     MONITOR_TEST_FLAG_NO_STORED);
 }
 
-void
+static void
 init_monitor_tests (void)
 {
   meta_monitor_manager_test_init_test_setup (create_initial_test_setup);
@@ -8911,14 +8911,37 @@ init_monitor_tests (void)
                     meta_test_monitor_supported_fractional_scales);
 }
 
-void
+static void
 pre_run_monitor_tests (MetaContext *context)
 {
   create_monitor_test_clients (context);
 }
 
-void
+static void
 finish_monitor_tests (void)
 {
   destroy_monitor_test_clients ();
 }
+
+int
+main (int   argc,
+      char *argv[])
+{
+  g_autoptr (MetaContext) context = NULL;
+
+  context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
+                                      META_CONTEXT_TEST_FLAG_TEST_CLIENT);
+  g_assert (meta_context_configure (context, &argc, &argv, NULL));
+
+  test_context = context;
+
+  init_monitor_tests ();
+
+  g_signal_connect (context, "before-tests",
+                    G_CALLBACK (pre_run_monitor_tests), NULL);
+  g_signal_connect (context, "after-tests",
+                    G_CALLBACK (finish_monitor_tests), NULL);
+
+  return meta_context_test_run_tests (META_CONTEXT_TEST (context),
+                                      META_TEST_RUN_FLAG_NONE);
+}
diff --git a/src/tests/unit-tests.c b/src/tests/unit-tests.c
index 66448a2131..0fefb8d556 100644
--- a/src/tests/unit-tests.c
+++ b/src/tests/unit-tests.c
@@ -32,7 +32,6 @@
 #include "meta/meta-context.h"
 #include "tests/boxes-tests.h"
 #include "tests/monitor-config-migration-unit-tests.h"
-#include "tests/monitor-unit-tests.h"
 #include "tests/monitor-store-unit-tests.h"
 #include "tests/monitor-transform-tests.h"
 #include "tests/meta-test-utils.h"
@@ -229,7 +228,6 @@ init_tests (void)
 
   init_monitor_store_tests ();
   init_monitor_config_migration_tests ();
-  init_monitor_tests ();
   init_boxes_tests ();
   init_monitor_transform_tests ();
   init_orientation_manager_tests ();
@@ -250,11 +248,6 @@ main (int argc, char *argv[])
 
   init_tests ();
 
-  g_signal_connect (context, "before-tests",
-                    G_CALLBACK (pre_run_monitor_tests), NULL);
-  g_signal_connect (context, "after-tests",
-                    G_CALLBACK (finish_monitor_tests), NULL);
-
   return meta_context_test_run_tests (META_CONTEXT_TEST (context),
                                       META_TEST_RUN_FLAG_NONE);
 }


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