tests/monitor-manager: Add API to emulate a hotplug event

Let a test case pass a test setup, which will be used as the new state
emulated by the test backend.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2016-12-07 17:39:53 +08:00
parent d920eaba4a
commit 2e4c516d43
2 changed files with 30 additions and 0 deletions

View File

@ -39,6 +39,22 @@ meta_monitor_manager_test_init_test_setup (MetaMonitorTestSetup *test_setup)
_initial_test_setup = test_setup;
}
void
meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
MetaMonitorTestSetup *test_setup)
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_test);
MetaMonitorTestSetup *old_test_setup;
old_test_setup = manager_test->test_setup;
manager_test->test_setup = test_setup;
meta_monitor_manager_read_current_config (manager);
meta_monitor_manager_on_hotplug (manager);
g_free (old_test_setup);
}
static void
meta_monitor_manager_test_read_current (MetaMonitorManager *manager)
{
@ -173,6 +189,14 @@ meta_monitor_manager_test_apply_configuration (MetaMonitorManager *manager,
meta_monitor_manager_rebuild_derived (manager);
}
static void
meta_monitor_manager_test_dispose (GObject *object)
{
MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (object);
g_clear_pointer (&manager_test->test_setup, g_free);
}
static void
meta_monitor_manager_test_init (MetaMonitorManagerTest *manager_test)
{
@ -184,8 +208,11 @@ meta_monitor_manager_test_init (MetaMonitorManagerTest *manager_test)
static void
meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_CLASS (klass);
object_class->dispose = meta_monitor_manager_test_dispose;
manager_class->read_current = meta_monitor_manager_test_read_current;
manager_class->apply_configuration = meta_monitor_manager_test_apply_configuration;
}

View File

@ -38,4 +38,7 @@ G_DECLARE_FINAL_TYPE (MetaMonitorManagerTest, meta_monitor_manager_test,
void meta_monitor_manager_test_init_test_setup (MetaMonitorTestSetup *test_setup);
void meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
MetaMonitorTestSetup *test_setup);
#endif /* META_MONITOR_MANAGER_TEST_H */