[gnome-color-manager] trivial: add some self checks for the GcmDevice::changed functionality



commit 7ed381e86124f198c69919e851a67616d95b79af
Author: Richard Hughes <richard hughsie com>
Date:   Wed Mar 24 15:20:49 2010 +0000

    trivial: add some self checks for the GcmDevice::changed functionality

 src/gcm-device.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/src/gcm-device.c b/src/gcm-device.c
index ffb241a..981fd0a 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -1072,6 +1072,17 @@ gcm_device_finalize (GObject *object)
 
 #include "gcm-device-udev.h"
 
+static guint _changes = 0;
+
+static void
+gcm_device_test_changed_cb (GcmDevice *device, EggTest *test)
+{
+	egg_debug ("emit changed: %s", gcm_device_get_id (device));
+	_changes++;
+
+	egg_test_loop_quit (test);
+}
+
 void
 gcm_device_test (EggTest *test)
 {
@@ -1092,6 +1103,16 @@ gcm_device_test (EggTest *test)
 	device = gcm_device_udev_new ();
 	egg_test_assert (test, device != NULL);
 
+	/* connect to the changed signal */
+	g_signal_connect (device, "changed", G_CALLBACK (gcm_device_test_changed_cb), test);
+
+	/************************************************************/
+	egg_test_title (test, "correct number of changed signals");
+	if (_changes == 0)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "changes: %i", _changes);
+
 	/************************************************************/
 	egg_test_title (test, "convert to recognized enum");
 	type_enum = gcm_device_type_enum_from_string ("scanner");
@@ -1122,13 +1143,36 @@ gcm_device_test (EggTest *test)
 	g_object_set (device,
 		      "type", GCM_DEVICE_TYPE_ENUM_SCANNER,
 		      "id", "sysfs_dummy_device",
-		      "connected", TRUE,
+		      "connected", FALSE,
 		      "virtual", FALSE,
 		      "serial", "0123456789",
 		      "colorspace", GCM_COLORSPACE_ENUM_RGB,
 		      NULL);
 
 	/************************************************************/
+	egg_test_loop_wait (test, 100);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "correct number of changed signals");
+	if (_changes == 1)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "changes: %i", _changes);
+
+	/************************************************************/
+	gcm_device_set_connected (device, TRUE);
+	egg_test_loop_wait (test, 100);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "correct number of changed signals");
+	if (_changes == 2)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "changes: %i", _changes);
+
+	/************************************************************/
 	egg_test_title (test, "get id");
 	type = gcm_device_get_id (device);
 	if (g_strcmp0 (type, "sysfs_dummy_device") == 0)
@@ -1189,6 +1233,17 @@ gcm_device_test (EggTest *test)
 		      NULL);
 
 	/************************************************************/
+	egg_test_loop_wait (test, 100);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "correct number of changed signals");
+	if (_changes == 3)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "changes: %i", _changes);
+
+	/************************************************************/
 	egg_test_title (test, "get profile filename");
 	if (g_strcmp0 (profile, "/srv/sysfs_canon_canoscan.icc") == 0)
 		egg_test_success (test, NULL);



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