summaryrefslogtreecommitdiff
path: root/plugins/color/gcm-self-test.c
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2018-06-05 00:27:08 +0200
committerCarlos Garnacho <mrgarnacho@gmail.com>2018-06-20 13:58:19 +0000
commit9ddf480a07bbbe3eec7bb8a76e3160dad772f28c (patch)
tree8c8430ea4836f9d32a426bb0678b333e171216d5 /plugins/color/gcm-self-test.c
parente3cba8d02cff2c3cb48a531f9467edd2d6b50653 (diff)
downloadgnome-settings-daemon-9ddf480a07bbbe3eec7bb8a76e3160dad772f28c.tar.gz
color: Add test for disabled until tomorrow sunrise logic
Disabled until tomorrow needs to detect whether sunrise has passed since it was turned on. Test this logic to be correct in various cases.
Diffstat (limited to 'plugins/color/gcm-self-test.c')
-rw-r--r--plugins/color/gcm-self-test.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/color/gcm-self-test.c b/plugins/color/gcm-self-test.c
index f2971e87..f26e8b04 100644
--- a/plugins/color/gcm-self-test.c
+++ b/plugins/color/gcm-self-test.c
@@ -189,6 +189,33 @@ gcm_test_night_light (void)
/* Ensure that the color temperature is still the default one.*/
g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+
+
+ /* Check that disabled until tomorrow resets again correctly. */
+ g_settings_set_double (settings, "night-light-schedule-from", 17.0);
+ g_settings_set_double (settings, "night-light-schedule-to", 7.f);
+ g_settings_set_boolean (settings, "night-light-enabled", TRUE);
+ gsd_night_light_set_disabled_until_tmw (nlight, TRUE);
+
+ /* Move time past midnight */
+ g_clear_pointer (&datetime_override, g_date_time_unref);
+ datetime_override = g_date_time_new_utc (2017, 2, 9, 1, 0, 0);
+ gsd_night_light_set_date_time_now (nlight, datetime_override);
+ g_assert_true (gsd_night_light_get_disabled_until_tmw (nlight));
+
+ /* Move past sunrise */
+ g_clear_pointer (&datetime_override, g_date_time_unref);
+ datetime_override = g_date_time_new_utc (2017, 2, 9, 8, 0, 0);
+ gsd_night_light_set_date_time_now (nlight, datetime_override);
+ g_assert_false (gsd_night_light_get_disabled_until_tmw (nlight));
+
+ gsd_night_light_set_disabled_until_tmw (nlight, TRUE);
+
+ /* Move into night more than 24h in the future */
+ g_clear_pointer (&datetime_override, g_date_time_unref);
+ 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));
}
static void