[gnome-settings-daemon/benzea/night-light-smearing: 7/7] color: Add test for always on and shortened smearing time



commit 2227cb6d040cddfc5c5b11622e7edb464dfa41c2
Author: Benjamin Berg <bberg redhat com>
Date:   Fri Feb 15 10:51:03 2019 +0100

    color: Add test for always on and shortened smearing time

 plugins/color/gcm-self-test.c | 55 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
---
diff --git a/plugins/color/gcm-self-test.c b/plugins/color/gcm-self-test.c
index 60ddcffc..912fc4bd 100644
--- a/plugins/color/gcm-self-test.c
+++ b/plugins/color/gcm-self-test.c
@@ -216,6 +216,61 @@ gcm_test_night_light (void)
         datetime_override = g_date_time_new_utc (2017, 2, 10, 20, 0, 0);
         gsd_night_light_set_date_time_now (nlight, datetime_override);
         g_assert_false (gsd_night_light_get_disabled_until_tmw (nlight));
+
+
+        /* Check that we are always in night mode if from/to are equal. */
+        gsd_night_light_set_smooth_enabled (nlight, FALSE);
+        g_settings_set_double (settings, "night-light-schedule-from", 6.0);
+        g_settings_set_double (settings, "night-light-schedule-to", 6.0);
+        g_settings_set_boolean (settings, "night-light-enabled", TRUE);
+
+        datetime_override = g_date_time_new_utc (2017, 2, 10, 5, 50, 0);
+        gsd_night_light_set_date_time_now (nlight, datetime_override);
+        g_assert (gsd_night_light_get_active (nlight));
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, 4000);
+
+        datetime_override = g_date_time_new_utc (2017, 2, 10, 6, 0, 0);
+        gsd_night_light_set_date_time_now (nlight, datetime_override);
+        g_assert (gsd_night_light_get_active (nlight));
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, 4000);
+
+        datetime_override = g_date_time_new_utc (2017, 2, 10, 6, 10, 0);
+        gsd_night_light_set_date_time_now (nlight, datetime_override);
+        g_assert (gsd_night_light_get_active (nlight));
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, 4000);
+
+
+        /* Check that the smearing time is lowered correctly when the times are close. */
+        g_settings_set_double (settings, "night-light-schedule-from", 6.0);
+        g_settings_set_double (settings, "night-light-schedule-to", 6.1);
+
+        /* Not enabled 10 minutes before sunset */
+        datetime_override = g_date_time_new_utc (2017, 2, 10, 5, 50, 0);
+        gsd_night_light_set_date_time_now (nlight, datetime_override);
+        g_assert_false (gsd_night_light_get_active (nlight));
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+
+        /* Not enabled >10 minutes after sunrise */
+        datetime_override = g_date_time_new_utc (2017, 2, 10, 6, 20, 0);
+        gsd_night_light_set_date_time_now (nlight, datetime_override);
+        g_assert_false (gsd_night_light_get_active (nlight));
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+
+        /* ~50% smeared 3 min before sunrise (sunrise at 6 past) */
+        datetime_override = g_date_time_new_utc (2017, 2, 10, 6, 3, 0);
+        gsd_night_light_set_date_time_now (nlight, datetime_override);
+        g_assert_true (gsd_night_light_get_active (nlight));
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), <=, (GSD_COLOR_TEMPERATURE_DEFAULT + 
4000) / 2 + 20);
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), >=, (GSD_COLOR_TEMPERATURE_DEFAULT + 
4000) / 2 - 20);
+
+        /* ~50% smeared 3 min before sunset (sunset at 6 past) */
+        g_settings_set_double (settings, "night-light-schedule-from", 6.1);
+        g_settings_set_double (settings, "night-light-schedule-to", 6.0);
+        datetime_override = g_date_time_new_utc (2017, 2, 10, 6, 3, 0);
+        gsd_night_light_set_date_time_now (nlight, datetime_override);
+        g_assert_true (gsd_night_light_get_active (nlight));
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), <=, (GSD_COLOR_TEMPERATURE_DEFAULT + 
4000) / 2 + 20);
+        g_assert_cmpint (gsd_night_light_get_temperature (nlight), >=, (GSD_COLOR_TEMPERATURE_DEFAULT + 
4000) / 2 - 20);
 }
 
 static const gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]