summaryrefslogtreecommitdiff
path: root/plugins/color/gcm-self-test.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2017-02-10 16:28:33 +0000
committerRichard Hughes <richard@hughsie.com>2017-02-10 16:28:33 +0000
commit5237382507944b5e5731b38781f09062ef8a7e5a (patch)
treee0fb66b49194fc08e20441a6391d58ec30dd08a8 /plugins/color/gcm-self-test.c
parent1e1fccb80e576b313f6730b26f385e0d6426ed4d (diff)
downloadgnome-settings-daemon-5237382507944b5e5731b38781f09062ef8a7e5a.tar.gz
color: Rename 'Natural Light Filter' to 'Night Light'
Diffstat (limited to 'plugins/color/gcm-self-test.c')
-rw-r--r--plugins/color/gcm-self-test.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/plugins/color/gcm-self-test.c b/plugins/color/gcm-self-test.c
index 695754eb..37ec1338 100644
--- a/plugins/color/gcm-self-test.c
+++ b/plugins/color/gcm-self-test.c
@@ -27,11 +27,11 @@
#include "gcm-edid.h"
#include "gsd-color-state.h"
-#include "gsd-natural-light.h"
-#include "gsd-natural-light-common.h"
+#include "gsd-night-light.h"
+#include "gsd-night-light-common.h"
static void
-on_notify (GsdNaturalLight *nlight,
+on_notify (GsdNightLight *nlight,
GParamSpec *pspec,
gpointer user_data)
{
@@ -40,7 +40,7 @@ on_notify (GsdNaturalLight *nlight,
}
static void
-gcm_test_natural_light (void)
+gcm_test_night_light (void)
{
gboolean ret;
guint active_cnt = 0;
@@ -50,11 +50,11 @@ gcm_test_natural_light (void)
guint temperature_cnt = 0;
g_autoptr(GDateTime) datetime_override = NULL;
g_autoptr(GError) error = NULL;
- g_autoptr(GsdNaturalLight) nlight = NULL;
+ g_autoptr(GsdNightLight) nlight = NULL;
g_autoptr(GSettings) settings = NULL;
- nlight = gsd_natural_light_new ();
- g_assert (GSD_IS_NATURAL_LIGHT (nlight));
+ nlight = gsd_night_light_new ();
+ g_assert (GSD_IS_NIGHT_LIGHT (nlight));
g_signal_connect (nlight, "notify::active",
G_CALLBACK (on_notify), &active_cnt);
g_signal_connect (nlight, "notify::sunset",
@@ -68,27 +68,27 @@ gcm_test_natural_light (void)
/* hardcode a specific date and time */
datetime_override = g_date_time_new_utc (2017, 2, 8, 20, 0, 0);
- gsd_natural_light_set_date_time_now (nlight, datetime_override);
+ gsd_night_light_set_date_time_now (nlight, datetime_override);
/* do not start geoclue */
- gsd_natural_light_set_geoclue_enabled (nlight, FALSE);
+ gsd_night_light_set_geoclue_enabled (nlight, FALSE);
/* switch off */
settings = g_settings_new ("org.gnome.settings-daemon.plugins.color");
- g_settings_set_boolean (settings, "natural-light-enabled", FALSE);
+ g_settings_set_boolean (settings, "night-light-enabled", FALSE);
/* check default values */
- g_assert (!gsd_natural_light_get_active (nlight));
- g_assert_cmpint ((gint) gsd_natural_light_get_sunrise (nlight), ==, -1);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunset (nlight), ==, -1);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ g_assert (!gsd_night_light_get_active (nlight));
+ g_assert_cmpint ((gint) gsd_night_light_get_sunrise (nlight), ==, -1);
+ g_assert_cmpint ((gint) gsd_night_light_get_sunset (nlight), ==, -1);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
/* start module, disabled */
- ret = gsd_natural_light_start (nlight, &error);
+ ret = gsd_night_light_start (nlight, &error);
g_assert_no_error (error);
g_assert (ret);
- g_assert (!gsd_natural_light_get_active (nlight));
+ g_assert (!gsd_night_light_get_active (nlight));
g_assert_cmpint (active_cnt, ==, 0);
g_assert_cmpint (sunset_cnt, ==, 0);
g_assert_cmpint (sunrise_cnt, ==, 0);
@@ -96,57 +96,57 @@ gcm_test_natural_light (void)
g_assert_cmpint (disabled_until_tmw_cnt, ==, 0);
/* enable automatic mode */
- g_settings_set_value (settings, "natural-light-last-coordinates",
+ g_settings_set_value (settings, "night-light-last-coordinates",
g_variant_new ("(dd)", 51.5, -0.1278));
- g_settings_set_boolean (settings, "natural-light-schedule-automatic", TRUE);
- g_settings_set_boolean (settings, "natural-light-enabled", TRUE);
- g_assert (gsd_natural_light_get_active (nlight));
+ g_settings_set_boolean (settings, "night-light-schedule-automatic", TRUE);
+ g_settings_set_boolean (settings, "night-light-enabled", TRUE);
+ g_assert (gsd_night_light_get_active (nlight));
g_assert_cmpint (active_cnt, ==, 1);
g_assert_cmpint (sunset_cnt, ==, 1);
g_assert_cmpint (sunrise_cnt, ==, 1);
g_assert_cmpint (temperature_cnt, ==, 1);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 0);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunrise (nlight), ==, 7);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunset (nlight), ==, 17);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, 4000);
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ g_assert_cmpint ((gint) gsd_night_light_get_sunrise (nlight), ==, 7);
+ g_assert_cmpint ((gint) gsd_night_light_get_sunset (nlight), ==, 17);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, 4000);
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
/* disable for one day */
- gsd_natural_light_set_disabled_until_tmw (nlight, TRUE);
- gsd_natural_light_set_disabled_until_tmw (nlight, TRUE);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
- g_assert (gsd_natural_light_get_active (nlight));
- g_assert (gsd_natural_light_get_disabled_until_tmw (nlight));
+ gsd_night_light_set_disabled_until_tmw (nlight, TRUE);
+ gsd_night_light_set_disabled_until_tmw (nlight, TRUE);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+ g_assert (gsd_night_light_get_active (nlight));
+ g_assert (gsd_night_light_get_disabled_until_tmw (nlight));
g_assert_cmpint (temperature_cnt, ==, 2);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 1);
/* change our mind */
- gsd_natural_light_set_disabled_until_tmw (nlight, FALSE);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, 4000);
- g_assert (gsd_natural_light_get_active (nlight));
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ gsd_night_light_set_disabled_until_tmw (nlight, FALSE);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, 4000);
+ g_assert (gsd_night_light_get_active (nlight));
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
g_assert_cmpint (active_cnt, ==, 1);
g_assert_cmpint (temperature_cnt, ==, 3);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 2);
/* enabled manual mode (night shift) */
- g_settings_set_double (settings, "natural-light-schedule-from", 4.0);
- g_settings_set_double (settings, "natural-light-schedule-to", 16.f);
- g_settings_set_boolean (settings, "natural-light-schedule-automatic", FALSE);
+ g_settings_set_double (settings, "night-light-schedule-from", 4.0);
+ g_settings_set_double (settings, "night-light-schedule-to", 16.f);
+ g_settings_set_boolean (settings, "night-light-schedule-automatic", FALSE);
g_assert_cmpint (active_cnt, ==, 2);
g_assert_cmpint (sunset_cnt, ==, 1);
g_assert_cmpint (sunrise_cnt, ==, 1);
g_assert_cmpint (temperature_cnt, ==, 4);
g_assert_cmpint (disabled_until_tmw_cnt, ==, 2);
- g_assert (!gsd_natural_light_get_active (nlight));
- g_assert_cmpint ((gint) gsd_natural_light_get_sunrise (nlight), ==, 7);
- g_assert_cmpint ((gint) gsd_natural_light_get_sunset (nlight), ==, 17);
- g_assert_cmpint (gsd_natural_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
- g_assert (!gsd_natural_light_get_disabled_until_tmw (nlight));
+ g_assert (!gsd_night_light_get_active (nlight));
+ g_assert_cmpint ((gint) gsd_night_light_get_sunrise (nlight), ==, 7);
+ g_assert_cmpint ((gint) gsd_night_light_get_sunset (nlight), ==, 17);
+ g_assert_cmpint (gsd_night_light_get_temperature (nlight), ==, GSD_COLOR_TEMPERATURE_DEFAULT);
+ g_assert (!gsd_night_light_get_disabled_until_tmw (nlight));
/* finally disable, with no changes */
- g_settings_set_boolean (settings, "natural-light-enabled", FALSE);
- g_assert (!gsd_natural_light_get_active (nlight));
+ g_settings_set_boolean (settings, "night-light-enabled", FALSE);
+ g_assert (!gsd_night_light_get_active (nlight));
g_assert_cmpint (active_cnt, ==, 2);
g_assert_cmpint (sunset_cnt, ==, 1);
g_assert_cmpint (sunrise_cnt, ==, 1);
@@ -221,7 +221,7 @@ gcm_test_sunset_sunrise (void)
g_autoptr(GDateTime) dt = g_date_time_new_utc (2007, 2, 1, 0, 0, 0);
/* get for London, today */
- gsd_natural_light_get_sunrise_sunset (dt, 51.5, -0.1278, &sunrise, &sunset);
+ gsd_night_light_get_sunrise_sunset (dt, 51.5, -0.1278, &sunrise, &sunset);
g_assert_cmpfloat (sunrise, <, sunrise_actual + 0.1);
g_assert_cmpfloat (sunrise, >, sunrise_actual - 0.1);
g_assert_cmpfloat (sunset, <, sunset_actual + 0.1);
@@ -236,22 +236,22 @@ gcm_test_frac_day (void)
gdouble fd_actual = 12.99;
/* test for 12:59:59 */
- fd = gsd_natural_light_frac_day_from_dt (dt);
+ fd = gsd_night_light_frac_day_from_dt (dt);
g_assert_cmpfloat (fd, >, fd_actual - 0.01);
g_assert_cmpfloat (fd, <, fd_actual + 0.01);
/* test same day */
- g_assert (gsd_natural_light_frac_day_is_between (12, 6, 20));
- g_assert (!gsd_natural_light_frac_day_is_between (5, 6, 20));
- g_assert (gsd_natural_light_frac_day_is_between (12, 0, 24));
- g_assert (gsd_natural_light_frac_day_is_between (12, -1, 25));
+ g_assert (gsd_night_light_frac_day_is_between (12, 6, 20));
+ g_assert (!gsd_night_light_frac_day_is_between (5, 6, 20));
+ g_assert (gsd_night_light_frac_day_is_between (12, 0, 24));
+ g_assert (gsd_night_light_frac_day_is_between (12, -1, 25));
/* test rollover to next day */
- g_assert (gsd_natural_light_frac_day_is_between (23, 20, 6));
- g_assert (!gsd_natural_light_frac_day_is_between (12, 20, 6));
+ g_assert (gsd_night_light_frac_day_is_between (23, 20, 6));
+ g_assert (!gsd_night_light_frac_day_is_between (12, 20, 6));
/* test rollover to the previous day */
- g_assert (gsd_natural_light_frac_day_is_between (5, 16, 8));
+ g_assert (gsd_night_light_frac_day_is_between (5, 16, 8));
}
int
@@ -265,7 +265,7 @@ main (int argc, char **argv)
g_test_add_func ("/color/edid", gcm_test_edid_func);
g_test_add_func ("/color/sunset-sunrise", gcm_test_sunset_sunrise);
g_test_add_func ("/color/fractional-day", gcm_test_frac_day);
- g_test_add_func ("/color/natural-light", gcm_test_natural_light);
+ g_test_add_func ("/color/night-light", gcm_test_night_light);
return g_test_run ();
}