diff --git a/src/tests/color-management-tests.c b/src/tests/color-management-tests.c
index ee3089d1e..8e8e10a8f 100644
--- a/src/tests/color-management-tests.c
+++ b/src/tests/color-management-tests.c
@@ -24,6 +24,7 @@
#include "backends/meta-color-manager-private.h"
#include "backends/meta-color-profile.h"
#include "meta-test/meta-context-test.h"
+#include "tests/meta-crtc-test.h"
#include "tests/meta-monitor-test-utils.h"
static MetaContext *test_context;
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 09f6e8a05..757bb2cf2 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -2,12 +2,16 @@ mutter_test_sources = [
'meta-backend-test.c',
'meta-backend-test.h',
'meta-context-test.c',
+ 'meta-crtc-test.c',
+ 'meta-crtc-test.h',
'meta-gpu-test.c',
'meta-gpu-test.h',
'meta-monitor-manager-test.c',
'meta-monitor-manager-test.h',
'meta-monitor-test-utils.c',
'meta-monitor-test-utils.h',
+ 'meta-output-test.c',
+ 'meta-output-test.h',
'meta-ref-test.c',
'meta-ref-test.h',
'meta-sensors-proxy-mock.c',
diff --git a/src/tests/meta-crtc-test.c b/src/tests/meta-crtc-test.c
new file mode 100644
index 000000000..4ef21dffe
--- /dev/null
+++ b/src/tests/meta-crtc-test.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2016-2024 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#include "config.h"
+
+#include "tests/meta-crtc-test.h"
+
+#define GAMMA_SIZE 256
+
+G_DEFINE_TYPE (MetaCrtcTest, meta_crtc_test, META_TYPE_CRTC)
+
+static size_t
+meta_crtc_test_get_gamma_lut_size (MetaCrtc *crtc)
+{
+ MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc);
+
+ return crtc_test->gamma.size;
+}
+
+static MetaGammaLut *
+meta_crtc_test_get_gamma_lut (MetaCrtc *crtc)
+{
+ MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc);
+ MetaGammaLut *lut;
+
+ g_assert_cmpint (crtc_test->gamma.size, >, 0);
+
+ lut = g_new0 (MetaGammaLut, 1);
+ lut->size = crtc_test->gamma.size;
+ lut->red = g_memdup2 (crtc_test->gamma.red,
+ lut->size * sizeof (uint16_t));
+ lut->green = g_memdup2 (crtc_test->gamma.green,
+ lut->size * sizeof (uint16_t));
+ lut->blue = g_memdup2 (crtc_test->gamma.blue,
+ lut->size * sizeof (uint16_t));
+ return lut;
+}
+
+static void
+meta_crtc_test_set_gamma_lut (MetaCrtc *crtc,
+ const MetaGammaLut *lut)
+{
+ MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc);
+
+ g_assert_cmpint (crtc_test->gamma.size, ==, lut->size);
+
+ g_free (crtc_test->gamma.red);
+ g_free (crtc_test->gamma.green);
+ g_free (crtc_test->gamma.blue);
+
+ crtc_test->gamma.red = g_memdup2 (lut->red,
+ sizeof (uint16_t) * lut->size);
+ crtc_test->gamma.green = g_memdup2 (lut->green,
+ sizeof (uint16_t) * lut->size);
+ crtc_test->gamma.blue = g_memdup2 (lut->blue,
+ sizeof (uint16_t) * lut->size);
+}
+
+static void
+meta_crtc_test_finalize (GObject *object)
+{
+ MetaCrtcTest *crtc_test = META_CRTC_TEST (object);
+
+ g_free (crtc_test->gamma.red);
+ g_free (crtc_test->gamma.green);
+ g_free (crtc_test->gamma.blue);
+
+ G_OBJECT_CLASS (meta_crtc_test_parent_class)->finalize (object);
+}
+
+static void
+meta_crtc_test_class_init (MetaCrtcTestClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ MetaCrtcClass *crtc_class = META_CRTC_CLASS (klass);
+
+ object_class->finalize = meta_crtc_test_finalize;
+
+ crtc_class->get_gamma_lut_size = meta_crtc_test_get_gamma_lut_size;
+ crtc_class->get_gamma_lut = meta_crtc_test_get_gamma_lut;
+ crtc_class->set_gamma_lut = meta_crtc_test_set_gamma_lut;
+}
+
+static void
+meta_crtc_test_init (MetaCrtcTest *crtc_test)
+{
+ int i;
+
+ crtc_test->gamma.size = GAMMA_SIZE;
+ crtc_test->gamma.red = g_new0 (uint16_t, GAMMA_SIZE);
+ crtc_test->gamma.green = g_new0 (uint16_t, GAMMA_SIZE);
+ crtc_test->gamma.blue = g_new0 (uint16_t, GAMMA_SIZE);
+
+ for (i = 0; i < GAMMA_SIZE; i++)
+ {
+ uint16_t gamma;
+
+ gamma = ((float) i / GAMMA_SIZE) * UINT16_MAX;
+ crtc_test->gamma.red[i] = gamma;
+ crtc_test->gamma.green[i] = gamma;
+ crtc_test->gamma.blue[i] = gamma;
+ }
+}
+
+void
+meta_crtc_test_disable_gamma_lut (MetaCrtcTest *crtc_test)
+{
+ crtc_test->gamma.size = 0;
+ g_clear_pointer (&crtc_test->gamma.red, g_free);
+ g_clear_pointer (&crtc_test->gamma.green, g_free);
+ g_clear_pointer (&crtc_test->gamma.blue, g_free);
+}
diff --git a/src/tests/meta-crtc-test.h b/src/tests/meta-crtc-test.h
new file mode 100644
index 000000000..583882f83
--- /dev/null
+++ b/src/tests/meta-crtc-test.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016-2024 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#pragma once
+
+#include "backends/meta-crtc.h"
+
+struct _MetaCrtcTest
+{
+ MetaCrtc parent;
+
+ struct {
+ size_t size;
+ uint16_t *red;
+ uint16_t *green;
+ uint16_t *blue;
+ } gamma;
+};
+
+#define META_TYPE_CRTC_TEST (meta_crtc_test_get_type ())
+META_EXPORT
+G_DECLARE_FINAL_TYPE (MetaCrtcTest, meta_crtc_test,
+ META, CRTC_TEST,
+ MetaCrtc)
+
+META_EXPORT
+void meta_crtc_test_disable_gamma_lut (MetaCrtcTest *crtc_test);
diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c
index f9275160c..a1dad80bc 100644
--- a/src/tests/meta-monitor-manager-test.c
+++ b/src/tests/meta-monitor-manager-test.c
@@ -27,10 +27,9 @@
#include "backends/meta-monitor-config-manager.h"
#include "backends/meta-output.h"
#include "tests/meta-backend-test.h"
+#include "tests/meta-crtc-test.h"
#include "tests/meta-monitor-test-utils.h"
-
-G_DEFINE_TYPE (MetaCrtcTest, meta_crtc_test, META_TYPE_CRTC)
-G_DEFINE_TYPE (MetaOutputTest, meta_output_test, META_TYPE_OUTPUT)
+#include "tests/meta-output-test.h"
struct _MetaMonitorManagerTest
{
@@ -456,118 +455,3 @@ meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass)
manager_class->get_max_screen_size = meta_monitor_manager_test_get_max_screen_size;
manager_class->get_default_layout_mode = meta_monitor_manager_test_get_default_layout_mode;
}
-
-static void
-meta_output_test_init (MetaOutputTest *output_test)
-{
- output_test->scale = 1;
-}
-
-static void
-meta_output_test_class_init (MetaOutputTestClass *klass)
-{
-}
-
-#define GAMMA_SIZE 256
-
-static size_t
-meta_crtc_test_get_gamma_lut_size (MetaCrtc *crtc)
-{
- MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc);
-
- return crtc_test->gamma.size;
-}
-
-static MetaGammaLut *
-meta_crtc_test_get_gamma_lut (MetaCrtc *crtc)
-{
- MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc);
- MetaGammaLut *lut;
-
- g_assert_cmpint (crtc_test->gamma.size, >, 0);
-
- lut = g_new0 (MetaGammaLut, 1);
- lut->size = crtc_test->gamma.size;
- lut->red = g_memdup2 (crtc_test->gamma.red,
- lut->size * sizeof (uint16_t));
- lut->green = g_memdup2 (crtc_test->gamma.green,
- lut->size * sizeof (uint16_t));
- lut->blue = g_memdup2 (crtc_test->gamma.blue,
- lut->size * sizeof (uint16_t));
- return lut;
-}
-
-static void
-meta_crtc_test_set_gamma_lut (MetaCrtc *crtc,
- const MetaGammaLut *lut)
-{
- MetaCrtcTest *crtc_test = META_CRTC_TEST (crtc);
-
- g_assert_cmpint (crtc_test->gamma.size, ==, lut->size);
-
- g_free (crtc_test->gamma.red);
- g_free (crtc_test->gamma.green);
- g_free (crtc_test->gamma.blue);
-
- crtc_test->gamma.red = g_memdup2 (lut->red,
- sizeof (uint16_t) * lut->size);
- crtc_test->gamma.green = g_memdup2 (lut->green,
- sizeof (uint16_t) * lut->size);
- crtc_test->gamma.blue = g_memdup2 (lut->blue,
- sizeof (uint16_t) * lut->size);
-}
-
-static void
-meta_crtc_test_finalize (GObject *object)
-{
- MetaCrtcTest *crtc_test = META_CRTC_TEST (object);
-
- g_free (crtc_test->gamma.red);
- g_free (crtc_test->gamma.green);
- g_free (crtc_test->gamma.blue);
-
- G_OBJECT_CLASS (meta_crtc_test_parent_class)->finalize (object);
-}
-
-static void
-meta_crtc_test_class_init (MetaCrtcTestClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- MetaCrtcClass *crtc_class = META_CRTC_CLASS (klass);
-
- object_class->finalize = meta_crtc_test_finalize;
-
- crtc_class->get_gamma_lut_size = meta_crtc_test_get_gamma_lut_size;
- crtc_class->get_gamma_lut = meta_crtc_test_get_gamma_lut;
- crtc_class->set_gamma_lut = meta_crtc_test_set_gamma_lut;
-}
-
-static void
-meta_crtc_test_init (MetaCrtcTest *crtc_test)
-{
- int i;
-
- crtc_test->gamma.size = GAMMA_SIZE;
- crtc_test->gamma.red = g_new0 (uint16_t, GAMMA_SIZE);
- crtc_test->gamma.green = g_new0 (uint16_t, GAMMA_SIZE);
- crtc_test->gamma.blue = g_new0 (uint16_t, GAMMA_SIZE);
-
- for (i = 0; i < GAMMA_SIZE; i++)
- {
- uint16_t gamma;
-
- gamma = ((float) i / GAMMA_SIZE) * UINT16_MAX;
- crtc_test->gamma.red[i] = gamma;
- crtc_test->gamma.green[i] = gamma;
- crtc_test->gamma.blue[i] = gamma;
- }
-}
-
-void
-meta_crtc_test_disable_gamma_lut (MetaCrtcTest *crtc_test)
-{
- crtc_test->gamma.size = 0;
- g_clear_pointer (&crtc_test->gamma.red, g_free);
- g_clear_pointer (&crtc_test->gamma.green, g_free);
- g_clear_pointer (&crtc_test->gamma.blue, g_free);
-}
diff --git a/src/tests/meta-monitor-manager-test.h b/src/tests/meta-monitor-manager-test.h
index 0b8c5fb6c..494b74915 100644
--- a/src/tests/meta-monitor-manager-test.h
+++ b/src/tests/meta-monitor-manager-test.h
@@ -19,9 +19,7 @@
#pragma once
-#include "backends/meta-crtc.h"
#include "backends/meta-monitor-manager-private.h"
-#include "backends/meta-output.h"
#include "core/util-private.h"
typedef struct _MetaMonitorTestSetup
@@ -31,39 +29,8 @@ typedef struct _MetaMonitorTestSetup
GList *crtcs;
} MetaMonitorTestSetup;
-struct _MetaCrtcTest
-{
- MetaCrtc parent;
-
- struct {
- size_t size;
- uint16_t *red;
- uint16_t *green;
- uint16_t *blue;
- } gamma;
-};
-
-struct _MetaOutputTest
-{
- MetaOutput parent;
-
- float scale;
-};
-
typedef MetaMonitorTestSetup * (* MetaCreateTestSetupFunc) (MetaBackend *backend);
-#define META_TYPE_CRTC_TEST (meta_crtc_test_get_type ())
-META_EXPORT
-G_DECLARE_FINAL_TYPE (MetaCrtcTest, meta_crtc_test,
- META, CRTC_TEST,
- MetaCrtc)
-
-#define META_TYPE_OUTPUT_TEST (meta_output_test_get_type ())
-META_EXPORT
-G_DECLARE_FINAL_TYPE (MetaOutputTest, meta_output_test,
- META, OUTPUT_TEST,
- MetaOutput)
-
#define META_TYPE_MONITOR_MANAGER_TEST (meta_monitor_manager_test_get_type ())
META_EXPORT
G_DECLARE_FINAL_TYPE (MetaMonitorManagerTest, meta_monitor_manager_test,
@@ -86,9 +53,6 @@ void meta_monitor_manager_test_set_handles_transforms (MetaMonitorManagerTest *m
META_EXPORT
int meta_monitor_manager_test_get_tiled_monitor_count (MetaMonitorManagerTest *manager_test);
-META_EXPORT
-void meta_crtc_test_disable_gamma_lut (MetaCrtcTest *crtc_test);
-
META_EXPORT
void meta_monitor_manager_test_set_layout_mode (MetaMonitorManagerTest *manager_test,
MetaLogicalMonitorLayoutMode layout_mode);
diff --git a/src/tests/meta-monitor-test-utils.c b/src/tests/meta-monitor-test-utils.c
index 2e44aedbb..8d81d6501 100644
--- a/src/tests/meta-monitor-test-utils.c
+++ b/src/tests/meta-monitor-test-utils.c
@@ -28,7 +28,8 @@
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor-config-manager.h"
#include "backends/meta-monitor-config-store.h"
-#include "backends/meta-output.h"
+#include "tests/meta-crtc-test.h"
+#include "tests/meta-output-test.h"
#include "tests/meta-test-utils.h"
#include "meta-backend-test.h"
diff --git a/src/tests/meta-output-test.c b/src/tests/meta-output-test.c
new file mode 100644
index 000000000..a6893b218
--- /dev/null
+++ b/src/tests/meta-output-test.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016-2024 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#include "config.h"
+
+#include "tests/meta-output-test.h"
+
+G_DEFINE_TYPE (MetaOutputTest, meta_output_test, META_TYPE_OUTPUT)
+
+static void
+meta_output_test_class_init (MetaOutputTestClass *klass)
+{
+}
+
+static void
+meta_output_test_init (MetaOutputTest *output_test)
+{
+ output_test->scale = 1;
+}
diff --git a/src/tests/meta-output-test.h b/src/tests/meta-output-test.h
new file mode 100644
index 000000000..9301bdc86
--- /dev/null
+++ b/src/tests/meta-output-test.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016-2024 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#pragma once
+
+#include "backends/meta-output.h"
+
+struct _MetaOutputTest
+{
+ MetaOutput parent;
+
+ float scale;
+};
+
+#define META_TYPE_OUTPUT_TEST (meta_output_test_get_type ())
+META_EXPORT
+G_DECLARE_FINAL_TYPE (MetaOutputTest, meta_output_test,
+ META, OUTPUT_TEST,
+ MetaOutput)