tests: Make tests components have ownership chains as well

This means we can eliminate the use of scattered singletons that isn't
added by the tests or the test framework itself.

tests: Don't get backend from old singleton getter

Either use the ownership chain, or the explicit test context instance
pointer.

tests/wayland: Pass context to test client constructor

So that we can get the Wayland compositor directly from the context.

tests: Don't get display from singleton

tests/client: Make test client carry a context pointer

tests/runner: Have test cases carry a context pointer

tests/wayland/test-driver: Get backend from context

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
This commit is contained in:
Jonas Ådahl 2022-05-27 22:55:43 +02:00 committed by Robert Mader
parent 3a1ded73ad
commit e9cd2b60a6
23 changed files with 168 additions and 115 deletions

View File

@ -23,12 +23,14 @@
#include "backends/meta-stage-view-private.h"
#define META_TYPE_RENDERER_VIEW (meta_renderer_view_get_type ())
META_EXPORT_TEST
G_DECLARE_FINAL_TYPE (MetaRendererView, meta_renderer_view,
META, RENDERER_VIEW,
MetaStageView)
MetaMonitorTransform meta_renderer_view_get_transform (MetaRendererView *view);
META_EXPORT_TEST
MetaCrtc *meta_renderer_view_get_crtc (MetaRendererView *view);
#endif /* META_RENDERER_VIEW_H */

View File

@ -71,7 +71,8 @@ clutter_test_init (int *argc,
ClutterActor *
clutter_test_get_stage (void)
{
MetaBackend *backend = meta_get_backend ();
MetaContext *context = test_environ->context;
MetaBackend *backend = meta_context_get_backend (context);
return meta_backend_get_stage (backend);
}

View File

@ -26,10 +26,12 @@
#include "meta-test/meta-context-test.h"
#include "tests/meta-monitor-manager-test.h"
static MetaContext *test_context;
static void
meta_test_headless_start (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
GList *gpus;
@ -59,7 +61,7 @@ meta_test_headless_monitor_getters (void)
MetaDisplay *display;
int index;
display = meta_get_display ();
display = meta_context_get_display (test_context);
index = meta_display_get_monitor_index_for_rect (display,
&(MetaRectangle) { 0 });
@ -69,7 +71,7 @@ meta_test_headless_monitor_getters (void)
static void
meta_test_headless_monitor_connect (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -99,7 +101,7 @@ meta_test_headless_monitor_connect (void)
NULL);
test_setup->modes = g_list_append (NULL, crtc_mode);
gpu = META_GPU (meta_backend_get_gpus (meta_get_backend ())->data);
gpu = META_GPU (meta_backend_get_gpus (backend)->data);
crtc = g_object_new (META_TYPE_CRTC_TEST,
"id", (uint64_t) 1,
"backend", backend,
@ -177,6 +179,8 @@ main (int argc, char *argv[])
init_tests ();
test_context = context;
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
META_TEST_RUN_FLAG_NONE);
}

View File

@ -129,7 +129,7 @@ meta_context_test_setup (MetaContext *context,
error))
return FALSE;
backend = meta_get_backend ();
backend = meta_context_get_backend (context);
settings = meta_backend_get_settings (backend);
meta_settings_override_experimental_features (settings);
meta_settings_enable_experimental_feature (

View File

@ -357,9 +357,9 @@ meta_monitor_manager_test_calculate_supported_scales (MetaMonitorManager
}
static gboolean
is_monitor_framebuffer_scaled (void)
is_monitor_framebuffer_scaled (MetaMonitorManager *manager)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
MetaSettings *settings = meta_backend_get_settings (backend);
return meta_settings_is_experimental_feature_enabled (
@ -373,7 +373,7 @@ meta_monitor_manager_test_get_capabilities (MetaMonitorManager *manager)
MetaMonitorManagerCapability capabilities =
META_MONITOR_MANAGER_CAPABILITY_NONE;
if (is_monitor_framebuffer_scaled ())
if (is_monitor_framebuffer_scaled (manager))
capabilities |= META_MONITOR_MANAGER_CAPABILITY_LAYOUT_MODE;
return capabilities;
@ -390,7 +390,7 @@ meta_monitor_manager_test_get_max_screen_size (MetaMonitorManager *manager,
static MetaLogicalMonitorLayoutMode
meta_monitor_manager_test_get_default_layout_mode (MetaMonitorManager *manager)
{
if (is_monitor_framebuffer_scaled ())
if (is_monitor_framebuffer_scaled (manager))
return META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL;
else
return META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;

View File

@ -75,6 +75,8 @@
#include <glib.h>
#include "backends/meta-backend-private.h"
#include "backends/meta-crtc.h"
#include "backends/meta-gpu.h"
#include "backends/meta-stage-private.h"
#include "clutter/clutter/clutter-stage-view-private.h"
@ -207,9 +209,12 @@ compare_images (cairo_surface_t *ref_image,
}
static void
assert_software_rendered (void)
assert_software_rendered (ClutterStageView *stage_view)
{
MetaBackend *backend = meta_get_backend ();
MetaRendererView *view = META_RENDERER_VIEW (stage_view);
MetaCrtc *crtc = meta_renderer_view_get_crtc (view);
MetaGpu *gpu = meta_crtc_get_gpu (crtc);
MetaBackend *backend = meta_gpu_get_backend (gpu);
g_assert_false (meta_backend_is_rendering_hardware_accelerated (backend));
}
@ -302,19 +307,21 @@ on_after_paint (MetaStage *stage,
}
static cairo_surface_t *
capture_view (ClutterStageView *view)
capture_view (ClutterStageView *stage_view)
{
MetaBackend *backend = meta_get_backend ();
MetaRendererView *view = META_RENDERER_VIEW (stage_view);
MetaCrtc *crtc = meta_renderer_view_get_crtc (view);
MetaBackend *backend = meta_crtc_get_backend (crtc);
MetaStage *stage = META_STAGE (meta_backend_get_stage (backend));
CaptureViewData data = { 0 };
data.loop = g_main_loop_new (NULL, FALSE);
data.watch = meta_stage_watch_view (stage, view,
data.watch = meta_stage_watch_view (stage, stage_view,
META_STAGE_WATCH_AFTER_PAINT,
on_after_paint,
&data);
clutter_stage_view_add_redraw_clip (view, NULL);
clutter_stage_view_schedule_update (view);
clutter_stage_view_add_redraw_clip (stage_view, NULL);
clutter_stage_view_schedule_update (stage_view);
g_main_loop_run (data.loop);
g_main_loop_unref (data.loop);
@ -459,7 +466,7 @@ meta_ref_test_verify_view (ClutterStageView *view,
cairo_status_t ref_status;
if (flags & META_REFTEST_FLAG_UPDATE_REF)
assert_software_rendered ();
assert_software_rendered (view);
view_image = capture_view (view);

View File

@ -39,6 +39,8 @@
struct _MetaTestClient
{
MetaContext *context;
char *id;
MetaWindowClientType type;
GSubprocess *subprocess;
@ -388,7 +390,7 @@ meta_test_client_find_window (MetaTestClient *client,
const char *window_id,
GError **error)
{
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (client->context);
g_autofree char *expected_title = NULL;
MetaWindow *window;
@ -614,6 +616,7 @@ meta_test_client_new (MetaContext *context,
process_handler);
client = g_new0 (MetaTestClient, 1);
client->context = context;
client->type = type;
client->id = g_strdup (id);
client->cancellable = g_cancellable_new ();
@ -669,7 +672,7 @@ meta_test_client_quit (MetaTestClient *client,
void
meta_test_client_destroy (MetaTestClient *client)
{
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (client->context);
MetaX11Display *x11_display;
GError *error = NULL;

View File

@ -42,6 +42,8 @@ struct _MetaWaylandTestDriver
{
GObject parent;
MetaWaylandCompositor *compositor;
struct wl_global *test_driver;
GList *resources;
@ -135,7 +137,10 @@ sync_effects_completed (struct wl_client *client,
uint32_t id,
struct wl_resource *surface_resource)
{
MetaBackend *backend = meta_get_backend ();
MetaWaylandTestDriver *test_driver = wl_resource_get_user_data (resource);
MetaContext *context =
meta_wayland_compositor_get_context (test_driver->compositor);
MetaBackend *backend = meta_context_get_backend (context);
ClutterActor *stage = meta_backend_get_stage (backend);
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
PendingEffectsData *data;
@ -186,7 +191,10 @@ verify_view (struct wl_client *client,
uint32_t id,
uint32_t sequence)
{
MetaBackend *backend = meta_get_backend ();
MetaWaylandTestDriver *test_driver = wl_resource_get_user_data (resource);
MetaContext *context =
meta_wayland_compositor_get_context (test_driver->compositor);
MetaBackend *backend = meta_context_get_backend (context);
ClutterActor *stage = meta_backend_get_stage (backend);
GList *stage_views;
struct wl_resource *callback;
@ -298,6 +306,7 @@ meta_wayland_test_driver_new (MetaWaylandCompositor *compositor)
MetaWaylandTestDriver *test_driver;
test_driver = g_object_new (META_TYPE_WAYLAND_TEST_DRIVER, NULL);
test_driver->compositor = compositor;
test_driver->test_driver = wl_global_create (compositor->wayland_display,
&test_driver_interface,
1,

View File

@ -42,7 +42,8 @@ get_test_client_path (const char *test_client_name)
}
MetaWaylandTestClient *
meta_wayland_test_client_new (const char *test_client_name)
meta_wayland_test_client_new (MetaContext *context,
const char *test_client_name)
{
MetaWaylandCompositor *compositor;
const char *wayland_display_name;
@ -52,7 +53,7 @@ meta_wayland_test_client_new (const char *test_client_name)
GError *error = NULL;
MetaWaylandTestClient *wayland_test_client;
compositor = meta_wayland_compositor_get_default ();
compositor = meta_context_get_wayland_compositor (context);
wayland_display_name = meta_wayland_get_wayland_display_name (compositor);
test_client_path = get_test_client_path (test_client_name);

View File

@ -18,9 +18,12 @@
#ifndef META_WAYLAND_TEST_UTILS_H
#define META_WAYLAND_TEST_UTILS_H
#include "meta/meta-context.h"
typedef struct _MetaWaylandTestClient MetaWaylandTestClient;
MetaWaylandTestClient * meta_wayland_test_client_new (const char *test_client_name);
MetaWaylandTestClient * meta_wayland_test_client_new (MetaContext *context,
const char *test_client_name);
void meta_wayland_test_client_finish (MetaWaylandTestClient *wayland_test_client);

View File

@ -30,12 +30,13 @@
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-monitor-config-migration.h"
#include "tests/meta-monitor-test-utils.h"
#include "tests/unit-tests.h"
static void
test_migration (const char *old_config,
const char *new_config)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;

View File

@ -210,7 +210,7 @@ check_monitor_store_configuration (MetaMonitorConfigStore *config_store,
static void
check_monitor_store_configurations (MonitorStoreTestExpect *expect)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -938,7 +938,7 @@ meta_test_monitor_store_policy_not_allowed (void)
static void
meta_test_monitor_store_policy (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;

View File

@ -261,7 +261,7 @@ meta_test_monitor_initial_linear_config (void)
static void
emulate_hotplug (MetaMonitorTestSetup *test_setup)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -275,7 +275,7 @@ static void
meta_test_monitor_config_store_set_current_on_empty (void)
{
g_autoptr (MetaMonitorsConfig) linear_config = NULL;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -306,7 +306,7 @@ meta_test_monitor_config_store_set_current_with_parent_on_empty (void)
g_autoptr (MetaMonitorsConfig) child_config3 = NULL;
g_autoptr (MetaMonitorsConfig) linear_config = NULL;
g_autoptr (MetaMonitorsConfig) fallback_config = NULL;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -403,7 +403,7 @@ meta_test_monitor_config_store_set_current (void)
{
g_autoptr (MetaMonitorsConfig) linear_config = NULL;
g_autoptr (MetaMonitorsConfig) fallback_config = NULL;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -443,7 +443,7 @@ meta_test_monitor_config_store_set_current_with_parent (void)
g_autoptr (MetaMonitorsConfig) other_child = NULL;
g_autoptr (MetaMonitorsConfig) linear_config = NULL;
g_autoptr (MetaMonitorsConfig) fallback_config = NULL;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -524,7 +524,7 @@ meta_test_monitor_config_store_set_current_max_size (void)
/* Keep this in sync with CONFIG_HISTORY_MAX_SIZE */
const unsigned int config_history_max_size = 3;
g_autolist (MetaMonitorsConfig) added = NULL;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -592,7 +592,7 @@ meta_test_monitor_config_store_set_current_max_size (void)
static void
meta_test_monitor_config_store_set_current_null (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -2418,7 +2418,7 @@ meta_test_monitor_lid_switch_config (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -2603,7 +2603,7 @@ meta_test_monitor_lid_opened_config (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -2718,7 +2718,7 @@ meta_test_monitor_lid_closed_no_external (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
test_setup = meta_create_monitor_test_setup (test_backend,
&test_case.setup,
@ -2858,7 +2858,7 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
/*
* The first part of this test emulate the following:
@ -3069,7 +3069,7 @@ meta_test_monitor_lid_scaled_closed_opened (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -3612,7 +3612,7 @@ meta_test_monitor_switch_external_without_external (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -3762,9 +3762,8 @@ meta_test_monitor_switch_config_remember_scale (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
meta_backend_get_monitor_manager (test_backend);
/*
* Check that default configuration is non-scaled linear.
@ -3943,7 +3942,7 @@ typedef MetaSensorsProxyMock MetaSensorsProxyAutoResetMock;
static void
meta_sensors_proxy_reset (MetaSensorsProxyMock *proxy)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaOrientationManager *orientation_manager =
meta_backend_get_orientation_manager (backend);
@ -3960,7 +3959,7 @@ typedef ClutterInputDevice ClutterAutoRemoveInputDevice;
static void
input_device_test_remove (ClutterAutoRemoveInputDevice *device)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
meta_backend_test_remove_device (META_BACKEND_TEST (backend), device);
g_object_unref (device);
@ -4051,7 +4050,7 @@ meta_test_monitor_orientation_is_managed (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaOrientationManager *orientation_manager =
meta_backend_get_orientation_manager (backend);
MetaMonitorManager *monitor_manager =
@ -4247,7 +4246,7 @@ meta_test_monitor_orientation_initial_rotated (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaOrientationManager *orientation_manager =
meta_backend_get_orientation_manager (backend);
g_autoptr (MetaSensorsProxyAutoResetMock) orientation_mock = NULL;
@ -4360,7 +4359,7 @@ meta_test_monitor_orientation_initial_rotated_no_touch_mode (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaOrientationManager *orientation_manager =
meta_backend_get_orientation_manager (backend);
g_autoptr (MetaSensorsProxyAutoResetMock) orientation_mock = NULL;
@ -4469,7 +4468,7 @@ meta_test_monitor_orientation_initial_stored_rotated (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaOrientationManager *orientation_manager =
@ -4627,7 +4626,7 @@ meta_test_monitor_orientation_initial_stored_rotated_no_touch (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaOrientationManager *orientation_manager =
@ -4749,7 +4748,7 @@ meta_test_monitor_orientation_changes (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -4949,7 +4948,7 @@ meta_test_monitor_orientation_changes_for_transformed_panel (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -5215,7 +5214,7 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaOrientationManager *orientation_manager =
meta_backend_get_orientation_manager (backend);
g_autoptr (ClutterAutoRemoveInputDevice) touch_device = NULL;
@ -7195,7 +7194,7 @@ meta_test_monitor_custom_second_rotated_tiled_config (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -7394,7 +7393,7 @@ meta_test_monitor_custom_second_rotated_nonnative_tiled_config (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -7544,7 +7543,7 @@ meta_test_monitor_custom_second_rotated_nonnative_config (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -7942,7 +7941,7 @@ meta_test_monitor_custom_lid_switch_config (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
test_setup = meta_create_monitor_test_setup (test_backend,
&test_case.setup,
@ -8113,7 +8112,7 @@ meta_test_monitor_migrated_rotated (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -8259,7 +8258,7 @@ meta_test_monitor_migrated_wiggle_discard (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -8539,7 +8538,7 @@ meta_test_monitor_migrated_wiggle (void)
}
};
MetaMonitorTestSetup *test_setup;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
@ -9337,7 +9336,7 @@ static void
test_case_setup (void **fixture,
const void *data)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =

View File

@ -25,9 +25,9 @@
#include "tests/native-virtual-monitor.h"
static void
init_tests (void)
init_tests (MetaContext *context)
{
init_virtual_monitor_tests ();
init_virtual_monitor_tests (context);
init_screen_cast_tests ();
}
@ -41,7 +41,7 @@ main (int argc,
META_CONTEXT_TEST_FLAG_NO_X11);
g_assert (meta_context_configure (context, &argc, &argv, NULL));
init_tests ();
init_tests (context);
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
META_TEST_RUN_FLAG_NONE);

View File

@ -205,7 +205,7 @@ meta_test_kms_render_client_scanout (void)
meta_kms_device_get_path (kms_device));
wayland_test_client =
meta_wayland_test_client_new ("dma-buf-scanout");
meta_wayland_test_client_new (test_context, "dma-buf-scanout");
g_assert_nonnull (wayland_test_client);
test = (KmsRenderingTest) {
@ -311,6 +311,8 @@ main (int argc,
init_tests ();
test_context = context;
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
META_TEST_RUN_FLAG_CAN_SKIP);
}

View File

@ -26,11 +26,13 @@
#include "meta/meta-backend.h"
#include "tests/meta-test-utils.h"
static MetaContext *test_context;
static gboolean
wait_for_paint (gpointer user_data)
{
MetaContext *context = user_data;
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
ClutterActor *stage = meta_backend_get_stage (backend);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -94,6 +96,8 @@ main (int argc,
g_idle_add (wait_for_paint, context);
test_context = context;
g_assert (meta_context_run_main_loop (context, &error));
return EXIT_SUCCESS;

View File

@ -29,10 +29,12 @@
#include "backends/native/meta-renderer-native.h"
#include "tests/meta-ref-test.h"
static MetaContext *test_context;
static void
meta_test_virtual_monitor_create (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager =
meta_monitor_manager_get_config_manager (monitor_manager);
@ -128,8 +130,10 @@ meta_test_virtual_monitor_create (void)
}
void
init_virtual_monitor_tests (void)
init_virtual_monitor_tests (MetaContext *context)
{
test_context = context;
g_test_add_func ("/backends/native/virtual-monitor/create",
meta_test_virtual_monitor_create);
}

View File

@ -21,6 +21,8 @@
#ifndef NATIVE_VIRTUAL_MONITOR_H
#define NATIVE_VIRTUAL_MONITOR_H
void init_virtual_monitor_tests (void);
typedef struct _MetaContext MetaContext;
void init_virtual_monitor_tests (MetaContext *context);
#endif /* NATIVE_VIRTUAL_MONITOR_H */

View File

@ -23,12 +23,14 @@
#include "meta-test/meta-context-test.h"
#include "tests/meta-ref-test.h"
static MetaContext *test_context;
static MetaVirtualMonitor *virtual_monitor;
static void
setup_test_environment (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaSettings *settings = meta_backend_get_settings (backend);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -61,7 +63,7 @@ setup_test_environment (void)
static void
tear_down_test_environment (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -72,7 +74,7 @@ tear_down_test_environment (void)
static ClutterStageView *
get_view (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
MetaRenderer *renderer = meta_backend_get_renderer (backend);
return CLUTTER_STAGE_VIEW (meta_renderer_get_views (renderer)->data);
@ -81,7 +83,7 @@ get_view (void)
static void
meta_test_ref_test_sanity (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = meta_context_get_backend (test_context);
ClutterActor *stage = meta_backend_get_stage (backend);
ClutterActor *actor1;
ClutterActor *actor2;
@ -144,6 +146,8 @@ main (int argc,
g_signal_connect (context, "after-tests",
G_CALLBACK (tear_down_test_environment), NULL);
test_context = context;
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
META_TEST_RUN_FLAG_NONE);
}

View File

@ -79,7 +79,7 @@ static MonitorTestCaseSetup initial_test_case_setup = {
static void
meta_test_stage_views_exist (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage;
GList *stage_views;
@ -154,7 +154,7 @@ is_on_stage_views (ClutterActor *actor,
static void
meta_test_actor_stage_views (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage, *container, *test_actor;
GList *stage_views;
gboolean stage_views_changed_container = FALSE;
@ -235,7 +235,7 @@ on_relayout_actor_frame (ClutterTimeline *timeline,
int msec,
ClutterActor *actor)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage = meta_backend_get_stage (backend);
clutter_stage_clear_stage_views (CLUTTER_STAGE (stage));
@ -244,7 +244,7 @@ on_relayout_actor_frame (ClutterTimeline *timeline,
static void
meta_test_actor_stage_views_relayout (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage, *actor;
ClutterTransition *transition;
GMainLoop *main_loop;
@ -279,7 +279,7 @@ meta_test_actor_stage_views_relayout (void)
static void
meta_test_actor_stage_views_reparent (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage, *container, *test_actor;
GList *stage_views;
gboolean stage_views_changed_container = FALSE;
@ -386,7 +386,7 @@ meta_test_actor_stage_views_reparent (void)
static void
meta_test_actor_stage_views_hide_parent (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage, *outer_container, *inner_container, *test_actor;
GList *stage_views;
gboolean stage_views_changed_outer_container = FALSE;
@ -519,7 +519,7 @@ assert_is_stage_view (ClutterStageView *stage_view,
static void
meta_test_actor_stage_views_hot_plug (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -588,7 +588,7 @@ meta_test_actor_stage_views_hot_plug (void)
static void
meta_test_actor_stage_views_frame_clock (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -732,7 +732,7 @@ static void
meta_test_actor_stage_views_timeline (void)
{
TimelineTest test = { 0 };
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -813,7 +813,7 @@ meta_test_actor_stage_views_timeline (void)
static void
meta_test_actor_stage_views_parent_views_rebuilt (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -899,7 +899,7 @@ meta_test_actor_stage_views_parent_views_rebuilt (void)
static void
meta_test_actor_stage_views_parent_views_changed (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -975,7 +975,7 @@ meta_test_actor_stage_views_parent_views_changed (void)
static void
meta_test_actor_stage_views_and_frame_clocks_freed (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorManagerTest *monitor_manager_test =
@ -1080,7 +1080,7 @@ meta_test_actor_stage_views_and_frame_clocks_freed (void)
static void
ensure_view_count (int n_views)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage = meta_backend_get_stage (backend);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -1207,7 +1207,7 @@ meta_test_actor_stage_views_queue_frame_drawn (void)
static void
meta_test_timeline_actor_destroyed (void)
{
MetaBackend *backend = meta_get_backend ();
MetaBackend *backend = test_backend;
ClutterActor *stage;
GList *stage_views;
ClutterActor *persistent_actor;

View File

@ -84,7 +84,7 @@ test_case_new (MetaContext *context)
else
{
test->x11_display_opened_handler_id =
g_signal_connect (meta_get_display (), "x11-display-opened",
g_signal_connect (display, "x11-display-opened",
G_CALLBACK (on_x11_display_opened),
test);
}
@ -223,7 +223,7 @@ test_case_assert_stacking (TestCase *test,
MetaWorkspace *workspace,
GError **error)
{
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
guint64 *windows;
int n_windows;
GString *stack_string = g_string_new (NULL);
@ -295,7 +295,7 @@ test_case_assert_focused (TestCase *test,
const char *expected_window,
GError **error)
{
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
if (!display->focus_window)
{
@ -355,7 +355,7 @@ static gboolean
test_case_check_xserver_stacking (TestCase *test,
GError **error)
{
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
GString *local_string = g_string_new (NULL);
GString *x11_string = g_string_new (NULL);
int i;
@ -846,7 +846,7 @@ test_case_do (TestCase *test,
else
return FALSE;
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
MetaWorkspaceManager *workspace_manager =
meta_display_get_workspace_manager (display);
MetaRectangle rect = { x, y, width, height };
@ -869,7 +869,7 @@ test_case_do (TestCase *test,
if (argc != 1)
BAD_COMMAND("usage: %s", argv[0]);
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
MetaWorkspaceManager *workspace_manager =
meta_display_get_workspace_manager (display);
GList *workspaces =
@ -1026,7 +1026,7 @@ test_case_do (TestCase *test,
if (argc != 2)
BAD_COMMAND("usage: %s <num>", argv[0]);
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
MetaWorkspaceManager *workspace_manager =
meta_display_get_workspace_manager (display);
uint32_t timestamp = meta_display_get_current_time_roundtrip (display);
@ -1039,7 +1039,7 @@ test_case_do (TestCase *test,
if (argc != 2)
BAD_COMMAND("usage: %s <workspace-index>", argv[0]);
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
MetaWorkspaceManager *workspace_manager =
meta_display_get_workspace_manager (display);
@ -1068,7 +1068,7 @@ test_case_do (TestCase *test,
if (!window)
return FALSE;
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
MetaWorkspaceManager *workspace_manager =
meta_display_get_workspace_manager (display);
@ -1087,7 +1087,7 @@ test_case_do (TestCase *test,
if (argc < 2)
BAD_COMMAND("usage: %s <workspace-index> [<window-id1> ...]", argv[0]);
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
MetaWorkspaceManager *workspace_manager =
meta_display_get_workspace_manager (display);
@ -1120,7 +1120,7 @@ test_case_do (TestCase *test,
if (!window)
return FALSE;
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
MetaWorkspaceManager *workspace_manager =
meta_display_get_workspace_manager (display);
@ -1162,7 +1162,7 @@ test_case_do (TestCase *test,
if (argc != 1)
BAD_COMMAND("usage: %s", argv[0]);
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test->context);
uint32_t timestamp = meta_display_get_current_time_roundtrip (display);
meta_display_focus_default_window (display, timestamp);
@ -1207,7 +1207,7 @@ test_case_destroy (TestCase *test,
g_clear_pointer (&test->waiter, meta_async_waiter_destroy);
display = meta_get_display ();
display = meta_context_get_display (test->context);
g_clear_signal_handler (&test->x11_display_opened_handler_id, display);
if (display->x11_display && test->alarm_filter)
{

View File

@ -175,7 +175,8 @@ on_before_tests (void)
virtual_monitor = meta_create_test_monitor (test_context, 100, 100, 10.0);
wayland_test_client = meta_wayland_test_client_new ("fullscreen");
wayland_test_client = meta_wayland_test_client_new (test_context,
"fullscreen");
while (!(test_window =
meta_find_window_from_title (test_context, "fullscreen")))

View File

@ -39,7 +39,7 @@ static ClutterVirtualInputDevice *virtual_pointer;
static MetaWindow *
find_client_window (const char *title)
{
MetaDisplay *display = meta_get_display ();
MetaDisplay *display = meta_context_get_display (test_context);
g_autoptr (GSList) windows = NULL;
GSList *l;
@ -61,7 +61,7 @@ subsurface_remap_toplevel (void)
MetaWaylandTestClient *wayland_test_client;
wayland_test_client =
meta_wayland_test_client_new ("subsurface-remap-toplevel");
meta_wayland_test_client_new (test_context, "subsurface-remap-toplevel");
meta_wayland_test_client_finish (wayland_test_client);
}
@ -71,7 +71,7 @@ buffer_transform (void)
MetaWaylandTestClient *wayland_test_client;
wayland_test_client =
meta_wayland_test_client_new ("buffer-transform");
meta_wayland_test_client_new (test_context, "buffer-transform");
meta_wayland_test_client_finish (wayland_test_client);
}
@ -81,7 +81,7 @@ single_pixel_buffer (void)
MetaWaylandTestClient *wayland_test_client;
wayland_test_client =
meta_wayland_test_client_new ("single-pixel-buffer");
meta_wayland_test_client_new (test_context, "single-pixel-buffer");
meta_wayland_test_client_finish (wayland_test_client);
}
@ -91,7 +91,7 @@ subsurface_reparenting (void)
MetaWaylandTestClient *wayland_test_client;
wayland_test_client =
meta_wayland_test_client_new ("subsurface-reparenting");
meta_wayland_test_client_new (test_context, "subsurface-reparenting");
meta_wayland_test_client_finish (wayland_test_client);
}
@ -101,7 +101,7 @@ subsurface_invalid_subsurfaces (void)
MetaWaylandTestClient *wayland_test_client;
wayland_test_client =
meta_wayland_test_client_new ("invalid-subsurfaces");
meta_wayland_test_client_new (test_context, "invalid-subsurfaces");
g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
"WL: error in client communication*");
g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
@ -116,7 +116,7 @@ subsurface_invalid_xdg_shell_actions (void)
MetaWaylandTestClient *wayland_test_client;
wayland_test_client =
meta_wayland_test_client_new ("invalid-xdg-shell-actions");
meta_wayland_test_client_new (test_context, "invalid-xdg-shell-actions");
g_test_expect_message ("libmutter", G_LOG_LEVEL_WARNING,
"Invalid geometry * set on xdg_surface*");
meta_wayland_test_client_finish (wayland_test_client);
@ -287,7 +287,7 @@ subsurface_parent_unmapped (void)
CLUTTER_POINTER_DEVICE);
wayland_test_client =
meta_wayland_test_client_new ("subsurface-parent-unmapped");
meta_wayland_test_client_new (test_context, "subsurface-parent-unmapped");
window_added_id =
g_signal_connect (display->stack, "window-added",
@ -364,7 +364,8 @@ toplevel_apply_limits (void)
gulong handler_id;
data.loop = g_main_loop_new (NULL, FALSE);
data.wayland_test_client = meta_wayland_test_client_new ("xdg-apply-limits");
data.wayland_test_client =
meta_wayland_test_client_new (test_context, "xdg-apply-limits");
handler_id = g_signal_connect (test_driver, "sync-point",
G_CALLBACK (on_apply_limits_sync_point),
&data);
@ -381,7 +382,8 @@ toplevel_activation (void)
ApplyLimitData data = {};
data.loop = g_main_loop_new (NULL, FALSE);
data.wayland_test_client = meta_wayland_test_client_new ("xdg-activation");
data.wayland_test_client =
meta_wayland_test_client_new (test_context, "xdg-activation");
meta_wayland_test_client_finish (data.wayland_test_client);
}
@ -505,7 +507,8 @@ toplevel_bounds_struts (void)
},
META_SIDE_TOP);
wayland_test_client = meta_wayland_test_client_new ("xdg-toplevel-bounds");
wayland_test_client =
meta_wayland_test_client_new (test_context, "xdg-toplevel-bounds");
wait_for_sync_point (1);
wait_until_after_paint ();
@ -525,7 +528,8 @@ toplevel_bounds_struts (void)
clear_struts ();
wayland_test_client = meta_wayland_test_client_new ("xdg-toplevel-bounds");
wayland_test_client =
meta_wayland_test_client_new (test_context, "xdg-toplevel-bounds");
wait_for_sync_point (1);
wait_until_after_paint ();
@ -595,7 +599,8 @@ toplevel_bounds_monitors (void)
},
META_SIDE_TOP);
wayland_test_client = meta_wayland_test_client_new ("xdg-toplevel-bounds");
wayland_test_client =
meta_wayland_test_client_new (test_context, "xdg-toplevel-bounds");
wait_for_sync_point (1);
wait_until_after_paint ();
@ -618,7 +623,8 @@ toplevel_bounds_monitors (void)
550.0, 100.0);
wait_for_cursor_position (550.0, 100.0);
wayland_test_client = meta_wayland_test_client_new ("xdg-toplevel-bounds");
wayland_test_client =
meta_wayland_test_client_new (test_context, "xdg-toplevel-bounds");
wait_for_sync_point (1);
wait_until_after_paint ();