mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
tests/clutter: Use the headless backend
One test depends on a pointer event having been emitted so that the stage has a focused pointer; make sure that has happened. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2699>
This commit is contained in:
parent
b15be5e287
commit
58e89b3a5d
@ -4,11 +4,14 @@
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "backends/meta-monitor-manager-private.h"
|
||||
#include "backends/meta-virtual-monitor.h"
|
||||
#include "compositor/meta-plugin-manager.h"
|
||||
#include "core/meta-context-private.h"
|
||||
|
||||
typedef struct {
|
||||
gpointer dummy_field;
|
||||
typedef struct
|
||||
{
|
||||
MetaContext *context;
|
||||
} ClutterTestEnvironment;
|
||||
|
||||
static ClutterTestEnvironment *test_environ = NULL;
|
||||
@ -46,12 +49,13 @@ clutter_test_init (int *argc,
|
||||
{
|
||||
MetaContext *context;
|
||||
|
||||
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
|
||||
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS,
|
||||
META_CONTEXT_TEST_FLAG_NO_X11);
|
||||
g_assert (meta_context_configure (context, argc, argv, NULL));
|
||||
g_assert (meta_context_setup (context, NULL));
|
||||
|
||||
test_environ = g_new0 (ClutterTestEnvironment, 1);
|
||||
test_environ->context = context;
|
||||
|
||||
g_assert (meta_context_start (context, NULL));
|
||||
|
||||
@ -251,12 +255,30 @@ clutter_test_add_data_full (const char *test_path,
|
||||
int
|
||||
clutter_test_run (void)
|
||||
{
|
||||
MetaBackend *backend = meta_context_get_backend (test_environ->context);
|
||||
MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend);
|
||||
MetaVirtualMonitor *virtual_monitor;
|
||||
g_autoptr (MetaVirtualMonitorInfo) monitor_info = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
int res;
|
||||
|
||||
g_assert (test_environ != NULL);
|
||||
monitor_info = meta_virtual_monitor_info_new (1024, 768, 60.0,
|
||||
"MetaTestVendor",
|
||||
"ClutterTestMonitor",
|
||||
"0x123");
|
||||
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);
|
||||
|
||||
res = g_test_run ();
|
||||
|
||||
g_object_unref (virtual_monitor);
|
||||
|
||||
g_clear_object (&test_environ->context);
|
||||
g_free (test_environ);
|
||||
|
||||
return res;
|
||||
|
@ -66,6 +66,8 @@ actor_event_hold (void)
|
||||
ClutterActor *stage;
|
||||
ClutterBackend *backend;
|
||||
ClutterSeat *seat;
|
||||
g_autoptr (ClutterVirtualInputDevice) virtual_pointer = NULL;
|
||||
int64_t now_us;
|
||||
ClutterInputDevice *device;
|
||||
ClutterEvent *event;
|
||||
ClutterEvent *captured_event;
|
||||
@ -81,8 +83,15 @@ actor_event_hold (void)
|
||||
/* Get the input device*/
|
||||
backend = clutter_get_default_backend ();
|
||||
seat = clutter_backend_get_default_seat (backend);
|
||||
device = clutter_seat_get_pointer (seat);
|
||||
|
||||
virtual_pointer =
|
||||
clutter_seat_create_virtual_device (seat, CLUTTER_POINTER_DEVICE);
|
||||
now_us = g_get_monotonic_time ();
|
||||
clutter_virtual_input_device_notify_absolute_motion (virtual_pointer,
|
||||
now_us,
|
||||
1.0, 1.0);
|
||||
|
||||
device = clutter_seat_get_pointer (seat);
|
||||
while (clutter_stage_get_device_actor (CLUTTER_STAGE (stage), device, NULL) == NULL)
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user