[gnome-color-manager] Add self check code to GcmBrightness
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add self check code to GcmBrightness
- Date: Fri, 27 Nov 2009 22:22:04 +0000 (UTC)
commit 0d43dcca56b38ebfb1591ffed6dde7ba934f5dda
Author: Richard Hughes <richard hughsie com>
Date: Fri Nov 27 22:21:44 2009 +0000
Add self check code to GcmBrightness
src/Makefile.am | 1 +
src/gcm-brightness.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/gcm-self-test.c | 2 +
3 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index be67de5..68c368a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -166,6 +166,7 @@ gcm_self_test_SOURCES = \
gcm-utils.c \
gcm-device.c \
gcm-profile.c \
+ gcm-brightness.c \
egg-test.h \
egg-test.c \
$(NULL)
diff --git a/src/gcm-brightness.c b/src/gcm-brightness.c
index 0298b34..e23a50c 100644
--- a/src/gcm-brightness.c
+++ b/src/gcm-brightness.c
@@ -241,3 +241,66 @@ gcm_brightness_new (void)
return GCM_BRIGHTNESS (brightness);
}
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+gcm_brightness_test (EggTest *test)
+{
+ GcmBrightness *brightness;
+ gboolean ret;
+ GError *error = NULL;
+ guint orig_percentage;
+ guint percentage;
+
+ if (!egg_test_start (test, "GcmBrightness"))
+ return;
+
+ /************************************************************/
+ egg_test_title (test, "get a brightness object");
+ brightness = gcm_brightness_new ();
+ egg_test_assert (test, brightness != NULL);
+
+ /************************************************************/
+ egg_test_title (test, "get original brightness");
+ ret = gcm_brightness_get_percentage (brightness, &orig_percentage, &error);
+ if (ret)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "failed to get brightness: %s", error->message);
+
+ /************************************************************/
+ egg_test_title (test, "set the new brightness");
+ ret = gcm_brightness_set_percentage (brightness, 10, &error);
+ if (ret)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "failed to set brightness: %s", error->message);
+
+ /************************************************************/
+ egg_test_title (test, "get the new brightness");
+ ret = gcm_brightness_get_percentage (brightness, &percentage, &error);
+ if (!ret)
+ egg_test_failed (test, "failed to get brightness: %s", error->message);
+ else if (percentage < 5 || percentage > 15)
+ egg_test_failed (test, "percentage was not set: %i", percentage);
+ else
+ egg_test_success (test, NULL);
+
+ /************************************************************/
+ egg_test_title (test, "set back original brightness");
+ ret = gcm_brightness_set_percentage (brightness, orig_percentage, &error);
+ if (ret)
+ egg_test_success (test, NULL);
+ else
+ egg_test_failed (test, "failed to set brightness: %s", error->message);
+
+ g_object_unref (brightness);
+
+ egg_test_end (test);
+}
+#endif
+
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index b1a927c..acb3be2 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -29,6 +29,7 @@ void gcm_tables_test (EggTest *test);
void gcm_utils_test (EggTest *test);
void gcm_device_test (EggTest *test);
void gcm_profile_test (EggTest *test);
+void gcm_brightness_test (EggTest *test);
int
main (int argc, char **argv)
@@ -47,6 +48,7 @@ main (int argc, char **argv)
gcm_utils_test (test);
gcm_device_test (test);
gcm_profile_test (test);
+ gcm_brightness_test (test);
return (egg_test_finish (test));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]