mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
tests: Add virtual monitor tests
The testing currently done is: * Creating a virtual monitor succeeds and gets the right configuration * Painting a few times results in the expected output * Changing the content of the stage also changes the painted content accordingly * Destroying the virtual monitor works as expected Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
This commit is contained in:
parent
d7ce6a47f8
commit
51ff51c854
@ -397,6 +397,7 @@ MetaVirtualMonitor * meta_monitor_manager_create_virtual_monitor (MetaMonitorMan
|
||||
const MetaVirtualMonitorInfo *info,
|
||||
GError **error);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaMonitorConfigManager *
|
||||
meta_monitor_manager_get_config_manager (MetaMonitorManager *manager);
|
||||
|
||||
|
@ -65,6 +65,7 @@ typedef enum _MetaMonitorScalesConstraint
|
||||
} MetaMonitorScalesConstraint;
|
||||
|
||||
#define META_TYPE_MONITOR (meta_monitor_get_type ())
|
||||
META_EXPORT_TEST
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaMonitor, meta_monitor, META, MONITOR, GObject)
|
||||
|
||||
struct _MetaMonitorClass
|
||||
|
@ -62,6 +62,7 @@ MetaCrtc * meta_virtual_monitor_get_crtc (MetaVirtualMonitor *virtual_monitor);
|
||||
|
||||
MetaCrtcMode * meta_virtual_monitor_get_crtc_mode (MetaVirtualMonitor *virtual_monitor);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaOutput * meta_virtual_monitor_get_output (MetaVirtualMonitor *virtual_monitor);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaVirtualMonitorInfo,
|
||||
|
@ -166,8 +166,11 @@ if have_native_tests
|
||||
native_headless_tests = executable('mutter-native-headless-tests',
|
||||
sources: [
|
||||
'native-headless.c',
|
||||
'native-virtual-monitor.c',
|
||||
'native-virtual-monitor.h',
|
||||
'test-utils.c',
|
||||
'test-utils.h',
|
||||
ref_test_sources,
|
||||
],
|
||||
include_directories: tests_includepath,
|
||||
c_args: tests_c_args,
|
||||
|
@ -26,11 +26,13 @@
|
||||
#include "core/main-private.h"
|
||||
#include "meta/main.h"
|
||||
#include "meta/meta-backend.h"
|
||||
#include "tests/native-virtual-monitor.h"
|
||||
#include "tests/test-utils.h"
|
||||
|
||||
static void
|
||||
init_tests (void)
|
||||
{
|
||||
init_virtual_monitor_tests ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
135
src/tests/native-virtual-monitor.c
Normal file
135
src/tests/native-virtual-monitor.c
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "tests/native-virtual-monitor.h"
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/meta-logical-monitor.h"
|
||||
#include "backends/meta-monitor-config-manager.h"
|
||||
#include "backends/meta-virtual-monitor.h"
|
||||
#include "backends/native/meta-renderer-native.h"
|
||||
#include "tests/meta-ref-test.h"
|
||||
|
||||
static void
|
||||
meta_test_virtual_monitor_create (void)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend);
|
||||
MetaMonitorConfigManager *config_manager =
|
||||
meta_monitor_manager_get_config_manager (monitor_manager);
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
MetaVirtualMonitor *virtual_monitor;
|
||||
g_autoptr (MetaVirtualMonitorInfo) monitor_info = NULL;
|
||||
GError *error = NULL;
|
||||
GList *monitors;
|
||||
MetaMonitor *monitor;
|
||||
MetaMonitorsConfig *monitors_config;
|
||||
GList *logical_monitors;
|
||||
GList *logical_monitor_monitors;
|
||||
GList *views;
|
||||
int i;
|
||||
ClutterActor *actor;
|
||||
|
||||
g_assert_null (meta_monitor_config_manager_get_current (config_manager));
|
||||
g_assert_null (meta_monitor_manager_get_logical_monitors (monitor_manager));
|
||||
g_assert_null (meta_monitor_manager_get_monitors (monitor_manager));
|
||||
g_assert_null (meta_renderer_get_views (renderer));
|
||||
|
||||
monitor_info = meta_virtual_monitor_info_new (80, 60, 60.0,
|
||||
"MetaTestVendor",
|
||||
"MetaVirtualMonitor",
|
||||
"0x1234");
|
||||
virtual_monitor = meta_monitor_manager_create_virtual_monitor (monitor_manager,
|
||||
monitor_info,
|
||||
&error);
|
||||
if (!virtual_monitor)
|
||||
g_error ("Failed to create virtual monitor: %s", error->message);
|
||||
|
||||
meta_monitor_manager_reload (monitor_manager);
|
||||
|
||||
monitors = meta_monitor_manager_get_monitors (monitor_manager);
|
||||
g_assert_cmpint (g_list_length (monitors), ==, 1);
|
||||
monitor = META_MONITOR (monitors->data);
|
||||
g_assert_cmpstr (meta_monitor_get_vendor (monitor), ==, "MetaTestVendor");
|
||||
g_assert_cmpstr (meta_monitor_get_product (monitor), ==, "MetaVirtualMonitor");
|
||||
g_assert_cmpstr (meta_monitor_get_serial (monitor), ==, "0x1234");
|
||||
g_assert (meta_monitor_get_main_output (monitor) ==
|
||||
meta_virtual_monitor_get_output (virtual_monitor));
|
||||
|
||||
monitors_config = meta_monitor_manager_ensure_configured (monitor_manager);
|
||||
g_assert_nonnull (monitors_config);
|
||||
g_assert_cmpint (g_list_length (monitors_config->logical_monitor_configs),
|
||||
==,
|
||||
1);
|
||||
|
||||
g_assert_cmpint (g_list_length (monitors_config->disabled_monitor_specs),
|
||||
==,
|
||||
0);
|
||||
|
||||
logical_monitors =
|
||||
meta_monitor_manager_get_logical_monitors (monitor_manager);
|
||||
g_assert_cmpint (g_list_length (logical_monitors), ==, 1);
|
||||
logical_monitor_monitors =
|
||||
meta_logical_monitor_get_monitors (logical_monitors->data);
|
||||
g_assert_cmpint (g_list_length (logical_monitor_monitors), ==, 1);
|
||||
g_assert (logical_monitor_monitors->data == monitor);
|
||||
|
||||
views = meta_renderer_get_views (renderer);
|
||||
g_assert_cmpint (g_list_length (views), ==, 1);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
meta_ref_test_verify_view (CLUTTER_STAGE_VIEW (views->data),
|
||||
g_test_get_path (), 0,
|
||||
meta_ref_test_determine_ref_test_flag ());
|
||||
}
|
||||
|
||||
actor = clutter_actor_new ();
|
||||
clutter_actor_set_position (actor, 10, 10);
|
||||
clutter_actor_set_size (actor, 40, 40);
|
||||
clutter_actor_set_background_color (actor, CLUTTER_COLOR_LightSkyBlue);
|
||||
clutter_actor_add_child (meta_backend_get_stage (backend), actor);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
meta_ref_test_verify_view (CLUTTER_STAGE_VIEW (views->data),
|
||||
g_test_get_path (), 1,
|
||||
meta_ref_test_determine_ref_test_flag ());
|
||||
}
|
||||
|
||||
g_object_unref (virtual_monitor);
|
||||
meta_monitor_manager_reload (monitor_manager);
|
||||
|
||||
g_assert_null (meta_monitor_manager_ensure_configured (monitor_manager));
|
||||
g_assert_null (meta_monitor_manager_get_logical_monitors (monitor_manager));
|
||||
g_assert_null (meta_monitor_manager_get_monitors (monitor_manager));
|
||||
g_assert_null (meta_renderer_get_views (renderer));
|
||||
|
||||
clutter_actor_destroy (actor);
|
||||
}
|
||||
|
||||
void
|
||||
init_virtual_monitor_tests (void)
|
||||
{
|
||||
g_test_add_func ("/backends/native/virtual-monitor/create",
|
||||
meta_test_virtual_monitor_create);
|
||||
}
|
26
src/tests/native-virtual-monitor.h
Normal file
26
src/tests/native-virtual-monitor.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NATIVE_VIRTUAL_MONITOR_H
|
||||
#define NATIVE_VIRTUAL_MONITOR_H
|
||||
|
||||
void init_virtual_monitor_tests (void);
|
||||
|
||||
#endif /* NATIVE_VIRTUAL_MONITOR_H */
|
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in New Issue
Block a user