[mutter] monitor-tests: Test config migration with refresh rate wiggle room
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-tests: Test config migration with refresh rate wiggle room
- Date: Wed, 4 Oct 2017 13:49:20 +0000 (UTC)
commit 120db06c602fd5ea18846559431a634d4c5bd1f6
Author: Jonas Ådahl <jadahl gmail com>
Date: Mon Sep 25 17:59:40 2017 -0400
monitor-tests: Test config migration with refresh rate wiggle room
Check that we finish configurations within range, and discard the ones
out of range.
https://bugzilla.gnome.org/show_bug.cgi?id=787668
src/tests/migration/wiggle-new-discarded.xml | 2 +
src/tests/migration/wiggle-new-finished.xml | 27 ++
src/tests/migration/wiggle-new.xml | 27 ++
src/tests/migration/wiggle-old.xml | 21 ++
src/tests/monitor-config-migration-unit-tests.c | 8 +
src/tests/monitor-unit-tests.c | 288 +++++++++++++++++++++++
6 files changed, 373 insertions(+), 0 deletions(-)
---
diff --git a/src/tests/migration/wiggle-new-discarded.xml b/src/tests/migration/wiggle-new-discarded.xml
new file mode 100644
index 0000000..fa4090a
--- /dev/null
+++ b/src/tests/migration/wiggle-new-discarded.xml
@@ -0,0 +1,2 @@
+<monitors version="2">
+</monitors>
diff --git a/src/tests/migration/wiggle-new-finished.xml b/src/tests/migration/wiggle-new-finished.xml
new file mode 100644
index 0000000..4d7e9dc
--- /dev/null
+++ b/src/tests/migration/wiggle-new-finished.xml
@@ -0,0 +1,27 @@
+<monitors version="2">
+ <configuration>
+ <logicalmonitor>
+ <x>0</x>
+ <y>0</y>
+ <scale>1</scale>
+ <primary>yes</primary>
+ <transform>
+ <rotation>left</rotation>
+ <flipped>no</flipped>
+ </transform>
+ <monitor>
+ <monitorspec>
+ <connector>DP-1</connector>
+ <vendor>MetaProduct's Inc.</vendor>
+ <product>MetaMonitor</product>
+ <serial>0x123456</serial>
+ </monitorspec>
+ <mode>
+ <width>800</width>
+ <height>600</height>
+ <rate>60.000801086425781</rate>
+ </mode>
+ </monitor>
+ </logicalmonitor>
+ </configuration>
+</monitors>
diff --git a/src/tests/migration/wiggle-new.xml b/src/tests/migration/wiggle-new.xml
new file mode 100644
index 0000000..9afc904
--- /dev/null
+++ b/src/tests/migration/wiggle-new.xml
@@ -0,0 +1,27 @@
+<monitors version="2">
+ <configuration>
+ <migrated/>
+ <logicalmonitor>
+ <x>0</x>
+ <y>0</y>
+ <primary>yes</primary>
+ <transform>
+ <rotation>left</rotation>
+ <flipped>no</flipped>
+ </transform>
+ <monitor>
+ <monitorspec>
+ <connector>DP-1</connector>
+ <vendor>MetaProduct's Inc.</vendor>
+ <product>MetaMonitor</product>
+ <serial>0x123456</serial>
+ </monitorspec>
+ <mode>
+ <width>800</width>
+ <height>600</height>
+ <rate>60.000801086425781</rate>
+ </mode>
+ </monitor>
+ </logicalmonitor>
+ </configuration>
+</monitors>
diff --git a/src/tests/migration/wiggle-old.xml b/src/tests/migration/wiggle-old.xml
new file mode 100644
index 0000000..be57011
--- /dev/null
+++ b/src/tests/migration/wiggle-old.xml
@@ -0,0 +1,21 @@
+<monitors version="1">
+ <configuration>
+ <clone>no</clone>
+ <output name="DP-1">
+ <vendor>MetaProduct's Inc.</vendor>
+ <product>MetaMonitor</product>
+ <serial>0x123456</serial>
+ <width>600</width>
+ <height>800</height>
+ <rate>60.000801086425781</rate>
+ <x>0</x>
+ <y>0</y>
+ <rotation>left</rotation>
+ <reflect_x>no</reflect_x>
+ <reflect_y>no</reflect_y>
+ <primary>yes</primary>
+ <presentation>no</presentation>
+ <underscanning>no</underscanning>
+ </output>
+ </configuration>
+</monitors>
diff --git a/src/tests/monitor-config-migration-unit-tests.c b/src/tests/monitor-config-migration-unit-tests.c
index fa2beb4..461035d 100644
--- a/src/tests/monitor-config-migration-unit-tests.c
+++ b/src/tests/monitor-config-migration-unit-tests.c
@@ -112,6 +112,12 @@ meta_test_monitor_config_migration_oneoff (void)
test_migration ("oneoff-old.xml", "oneoff-new.xml");
}
+static void
+meta_test_monitor_config_migration_wiggle (void)
+{
+ test_migration ("wiggle-old.xml", "wiggle-new.xml");
+}
+
void
init_monitor_config_migration_tests (void)
{
@@ -125,4 +131,6 @@ init_monitor_config_migration_tests (void)
meta_test_monitor_config_migration_first_rotated);
g_test_add_func ("/backends/monitor-config-migration/oneoff",
meta_test_monitor_config_migration_oneoff);
+ g_test_add_func ("/backends/monitor-config-migration/wiggle",
+ meta_test_monitor_config_migration_wiggle);
}
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index 529a6bd..6685650 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -4965,6 +4965,290 @@ meta_test_monitor_migrated_rotated (void)
}
static void
+meta_test_monitor_migrated_wiggle_discard (void)
+{
+ MonitorTestCase test_case = {
+ .setup = {
+ .modes = {
+ {
+ .width = 800,
+ .height = 600,
+ .refresh_rate = 59.0
+ }
+ },
+ .n_modes = 1,
+ .outputs = {
+ {
+ .crtc = -1,
+ .modes = { 0 },
+ .n_modes = 1,
+ .preferred_mode = 0,
+ .possible_crtcs = { 0 },
+ .n_possible_crtcs = 1,
+ .width_mm = 222,
+ .height_mm = 125
+ }
+ },
+ .n_outputs = 1,
+ .crtcs = {
+ {
+ .current_mode = -1
+ }
+ },
+ .n_crtcs = 1
+ },
+
+ .expect = {
+ .monitors = {
+ {
+ .outputs = { 0 },
+ .n_outputs = 1,
+ .modes = {
+ {
+ .width = 800,
+ .height = 600,
+ .refresh_rate = 59.0,
+ .crtc_modes = {
+ {
+ .output = 0,
+ .crtc_mode = 0
+ }
+ }
+ }
+ },
+ .n_modes = 1,
+ .current_mode = 0,
+ .width_mm = 222,
+ .height_mm = 125
+ }
+ },
+ .n_monitors = 1,
+ .logical_monitors = {
+ {
+ .monitors = { 0 },
+ .n_monitors = 1,
+ .layout = { .x = 0, .y = 0, .width = 800, .height = 600 },
+ .scale = 1,
+ .transform = META_MONITOR_TRANSFORM_NORMAL
+ },
+ },
+ .n_logical_monitors = 1,
+ .primary_logical_monitor = 0,
+ .n_outputs = 1,
+ .crtcs = {
+ {
+ .current_mode = 0,
+ }
+ },
+ .n_crtcs = 1,
+ .screen_width = 800,
+ .screen_height = 600,
+ }
+ };
+ MetaMonitorTestSetup *test_setup;
+ MetaBackend *backend = meta_get_backend ();
+ MetaMonitorManager *monitor_manager =
+ meta_backend_get_monitor_manager (backend);
+ MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
+ MetaMonitorConfigStore *config_store =
+ meta_monitor_config_manager_get_store (config_manager);
+ g_autofree char *migrated_path = NULL;
+ const char *old_config_path;
+ g_autoptr (GFile) old_config_file = NULL;
+ GError *error = NULL;
+ const char *expected_path;
+ g_autofree char *migrated_data = NULL;
+ g_autofree char *expected_data = NULL;
+ g_autoptr (GFile) migrated_file = NULL;
+
+ test_setup = create_monitor_test_setup (&test_case,
+ MONITOR_TEST_FLAG_NONE);
+
+ migrated_path = g_build_filename (g_get_tmp_dir (),
+ "test-finished-migrated-monitors.xml",
+ NULL);
+ if (!meta_monitor_config_store_set_custom (config_store,
+ "/dev/null",
+ migrated_path,
+ &error))
+ g_error ("Failed to set custom config store files: %s", error->message);
+
+ old_config_path = g_test_get_filename (G_TEST_DIST,
+ "tests", "migration",
+ "wiggle-old.xml",
+ NULL);
+ old_config_file = g_file_new_for_path (old_config_path);
+ if (!meta_migrate_old_monitors_config (config_store,
+ old_config_file,
+ &error))
+ g_error ("Failed to migrate config: %s", error->message);
+
+ g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+ "Failed to finish monitors config migration: "
+ "Mode not available on monitor");
+ emulate_hotplug (test_setup);
+ g_test_assert_expected_messages ();
+
+ check_monitor_configuration (&test_case);
+
+ expected_path = g_test_get_filename (G_TEST_DIST,
+ "tests", "migration",
+ "wiggle-new-discarded.xml",
+ NULL);
+ expected_data = read_file (expected_path);
+ migrated_data = read_file (migrated_path);
+
+ g_assert_nonnull (expected_data);
+ g_assert_nonnull (migrated_data);
+
+ g_assert (strcmp (expected_data, migrated_data) == 0);
+
+ migrated_file = g_file_new_for_path (migrated_path);
+ if (!g_file_delete (migrated_file, NULL, &error))
+ g_error ("Failed to remove test data output file: %s", error->message);
+}
+
+static void
+meta_test_monitor_migrated_wiggle (void)
+{
+ MonitorTestCase test_case = {
+ .setup = {
+ .modes = {
+ {
+ .width = 800,
+ .height = 600,
+ .refresh_rate = 60.0
+ }
+ },
+ .n_modes = 1,
+ .outputs = {
+ {
+ .crtc = -1,
+ .modes = { 0 },
+ .n_modes = 1,
+ .preferred_mode = 0,
+ .possible_crtcs = { 0 },
+ .n_possible_crtcs = 1,
+ .width_mm = 222,
+ .height_mm = 125
+ }
+ },
+ .n_outputs = 1,
+ .crtcs = {
+ {
+ .current_mode = -1
+ }
+ },
+ .n_crtcs = 1
+ },
+
+ .expect = {
+ .monitors = {
+ {
+ .outputs = { 0 },
+ .n_outputs = 1,
+ .modes = {
+ {
+ .width = 800,
+ .height = 600,
+ .refresh_rate = 60.0,
+ .crtc_modes = {
+ {
+ .output = 0,
+ .crtc_mode = 0
+ }
+ }
+ }
+ },
+ .n_modes = 1,
+ .current_mode = 0,
+ .width_mm = 222,
+ .height_mm = 125
+ }
+ },
+ .n_monitors = 1,
+ .logical_monitors = {
+ {
+ .monitors = { 0 },
+ .n_monitors = 1,
+ .layout = { .x = 0, .y = 0, .width = 600, .height = 800 },
+ .scale = 1,
+ .transform = META_MONITOR_TRANSFORM_90
+ },
+ },
+ .n_logical_monitors = 1,
+ .primary_logical_monitor = 0,
+ .n_outputs = 1,
+ .crtcs = {
+ {
+ .current_mode = 0,
+ }
+ },
+ .n_crtcs = 1,
+ .screen_width = 600,
+ .screen_height = 800,
+ }
+ };
+ MetaMonitorTestSetup *test_setup;
+ MetaBackend *backend = meta_get_backend ();
+ MetaMonitorManager *monitor_manager =
+ meta_backend_get_monitor_manager (backend);
+ MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
+ MetaMonitorConfigStore *config_store =
+ meta_monitor_config_manager_get_store (config_manager);
+ g_autofree char *migrated_path = NULL;
+ const char *old_config_path;
+ g_autoptr (GFile) old_config_file = NULL;
+ GError *error = NULL;
+ const char *expected_path;
+ g_autofree char *migrated_data = NULL;
+ g_autofree char *expected_data = NULL;
+ g_autoptr (GFile) migrated_file = NULL;
+
+ test_setup = create_monitor_test_setup (&test_case,
+ MONITOR_TEST_FLAG_NONE);
+
+ migrated_path = g_build_filename (g_get_tmp_dir (),
+ "test-finished-migrated-monitors.xml",
+ NULL);
+ if (!meta_monitor_config_store_set_custom (config_store,
+ "/dev/null",
+ migrated_path,
+ &error))
+ g_error ("Failed to set custom config store files: %s", error->message);
+
+ old_config_path = g_test_get_filename (G_TEST_DIST,
+ "tests", "migration",
+ "wiggle-old.xml",
+ NULL);
+ old_config_file = g_file_new_for_path (old_config_path);
+ if (!meta_migrate_old_monitors_config (config_store,
+ old_config_file,
+ &error))
+ g_error ("Failed to migrate config: %s", error->message);
+
+ emulate_hotplug (test_setup);
+
+ check_monitor_configuration (&test_case);
+
+ expected_path = g_test_get_filename (G_TEST_DIST,
+ "tests", "migration",
+ "wiggle-new-finished.xml",
+ NULL);
+ expected_data = read_file (expected_path);
+ migrated_data = read_file (migrated_path);
+
+ g_assert_nonnull (expected_data);
+ g_assert_nonnull (migrated_data);
+
+ g_assert (strcmp (expected_data, migrated_data) == 0);
+
+ migrated_file = g_file_new_for_path (migrated_path);
+ if (!g_file_delete (migrated_file, NULL, &error))
+ g_error ("Failed to remove test data output file: %s", error->message);
+}
+
+static void
test_case_setup (void **fixture,
const void *data)
{
@@ -5062,6 +5346,10 @@ init_monitor_tests (void)
add_monitor_test ("/backends/monitor/migrated/rotated",
meta_test_monitor_migrated_rotated);
+ add_monitor_test ("/backends/monitor/migrated/wiggle",
+ meta_test_monitor_migrated_wiggle);
+ add_monitor_test ("/backends/monitor/migrated/wiggle-discard",
+ meta_test_monitor_migrated_wiggle_discard);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]