tests/monitor-manager: Move out CRTC and output to separate files
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3812>
This commit is contained in:
parent
b94a5de39d
commit
c8d3465e83
@ -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;
|
||||
|
@ -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',
|
||||
|
126
src/tests/meta-crtc-test.c
Normal file
126
src/tests/meta-crtc-test.c
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
41
src/tests/meta-crtc-test.h
Normal file
41
src/tests/meta-crtc-test.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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);
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
||||
|
33
src/tests/meta-output-test.c
Normal file
33
src/tests/meta-output-test.c
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
33
src/tests/meta-output-test.h
Normal file
33
src/tests/meta-output-test.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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)
|
Loading…
x
Reference in New Issue
Block a user