[gnome-color-manager] Switch to using GTest rather than our own homebrew EggTest
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Switch to using GTest rather than our own homebrew EggTest
- Date: Mon, 10 May 2010 07:52:17 +0000 (UTC)
commit 6a12618322bf46e0749d5eae58dd127d1dbe9691
Author: Richard Hughes <richard hughsie com>
Date: Sun May 9 22:59:00 2010 +0100
Switch to using GTest rather than our own homebrew EggTest
src/Makefile.am | 22 +-
src/egg-test.c | 357 --------------
src/egg-test.h | 48 --
src/gcm-brightness.c | 63 ---
src/gcm-calibrate-dialog.c | 27 -
src/gcm-calibrate-manual.c | 40 --
src/gcm-calibrate.c | 42 --
src/gcm-calibrate.h | 1 +
src/gcm-cie-widget.c | 95 ----
src/gcm-clut.c | 117 -----
src/gcm-device.c | 217 ---------
src/gcm-dmi.c | 43 --
src/gcm-edid.c | 161 ------
src/gcm-edid.h | 2 +-
src/gcm-gamma-widget.c | 64 ---
src/gcm-image.c | 129 -----
src/gcm-print.c | 41 --
src/gcm-profile.c | 166 -------
src/gcm-self-test.c | 1148 ++++++++++++++++++++++++++++++++++++++++++--
src/gcm-tables.c | 63 ---
src/gcm-trc-widget.c | 78 ---
src/gcm-utils.c | 139 +-----
src/gcm-xyz.c | 80 ---
23 files changed, 1114 insertions(+), 2029 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index bd66e22..d0ad5af 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -312,26 +312,6 @@ check_PROGRAMS = \
gcm_self_test_SOURCES = \
gcm-self-test.c \
- gcm-edid.c \
- gcm-tables.c \
- gcm-utils.c \
- gcm-device.c \
- gcm-profile.c \
- gcm-profile-lcms1.c \
- gcm-brightness.c \
- gcm-clut.c \
- gcm-dmi.c \
- gcm-xyz.c \
- gcm-image.c \
- gcm-cie-widget.c \
- gcm-trc-widget.c \
- gcm-gamma-widget.c \
- gcm-calibrate.c \
- gcm-calibrate-manual.c \
- gcm-print.c \
- gcm-calibrate-dialog.c \
- egg-test.h \
- egg-test.c \
$(NULL)
gcm_self_test_LDADD = \
@@ -350,7 +330,7 @@ gcm_self_test_LDADD = \
$(TIFF_LIBS) \
-lm
-gcm_self_test_CFLAGS = -DEGG_TEST $(AM_CFLAGS)
+gcm_self_test_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS_C)
TESTS = gcm-self-test
diff --git a/src/gcm-brightness.c b/src/gcm-brightness.c
index 4ab107b..a0bd09c 100644
--- a/src/gcm-brightness.c
+++ b/src/gcm-brightness.c
@@ -235,66 +235,3 @@ 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-calibrate-dialog.c b/src/gcm-calibrate-dialog.c
index bb2e9a1..9a778de 100644
--- a/src/gcm-calibrate-dialog.c
+++ b/src/gcm-calibrate-dialog.c
@@ -856,30 +856,3 @@ gcm_calibrate_dialog_new (void)
return GCM_CALIBRATE_DIALOG (gcm_calibrate_dialog_object);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_calibrate_dialog_test (EggTest *test)
-{
- GcmCalibrateDialog *calibrate_dialog;
-// gboolean ret;
-// GError *error = NULL;
-
- if (!egg_test_start (test, "GcmCalibrateDialog"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a calibrate_dialog object");
- calibrate_dialog = gcm_calibrate_dialog_new ();
- egg_test_assert (test, calibrate_dialog != NULL);
-
- g_object_unref (calibrate_dialog);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-calibrate-manual.c b/src/gcm-calibrate-manual.c
index 7ebbaba..204d3c0 100644
--- a/src/gcm-calibrate-manual.c
+++ b/src/gcm-calibrate-manual.c
@@ -702,43 +702,3 @@ gcm_calibrate_manual_new (void)
return GCM_CALIBRATE_MANUAL (calibrate);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_calibrate_manual_test (EggTest *test)
-{
- GcmCalibrateManual *calibrate;
- gboolean ret;
- GError *error = NULL;
-
- if (!egg_test_start (test, "GcmCalibrateManual"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a calibrate_manual object");
- calibrate = gcm_calibrate_manual_new ();
- egg_test_assert (test, calibrate != NULL);
-
- /* set to avoid a critical warning */
- g_object_set (calibrate,
- "output-name", "lvds1",
- NULL);
-
- /************************************************************/
- egg_test_title (test, "calibrate display manually");
- ret = gcm_calibrate_display (GCM_CALIBRATE(calibrate), NULL, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "error: %s", error->message);
-
- g_object_unref (calibrate);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index c39bf0c..e81891d 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -1582,45 +1582,3 @@ gcm_calibrate_new (void)
return GCM_CALIBRATE (calibrate);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_calibrate_test (EggTest *test)
-{
- GcmCalibrate *calibrate;
- gboolean ret;
- GError *error = NULL;
- gchar *filename;
-
- if (!egg_test_start (test, "GcmCalibrate"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a calibrate object");
- calibrate = gcm_calibrate_new ();
- egg_test_assert (test, calibrate != NULL);
-
- /************************************************************/
- egg_test_title (test, "calibrate display manually");
- filename = egg_test_get_data_file ("test.tif");
- ret = gcm_calibrate_set_from_exif (GCM_CALIBRATE(calibrate), filename, &error);
- if (!ret)
- egg_test_failed (test, "error: %s", error->message);
- else if (g_strcmp0 (gcm_calibrate_get_model_fallback (calibrate), "NIKON D60") != 0)
- egg_test_failed (test, "got model: %s", gcm_calibrate_get_model_fallback (calibrate));
- else if (g_strcmp0 (gcm_calibrate_get_manufacturer_fallback (calibrate), "NIKON CORPORATION") != 0)
- egg_test_failed (test, "got manufacturer: %s", gcm_calibrate_get_manufacturer_fallback (calibrate));
- else
- egg_test_success (test, NULL);
-
- g_object_unref (calibrate);
- g_free (filename);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index c1b147a..80c4f77 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -23,6 +23,7 @@
#define __GCM_CALIBRATE_H
#include <glib-object.h>
+#include <gtk/gtk.h>
#include "gcm-device.h"
diff --git a/src/gcm-cie-widget.c b/src/gcm-cie-widget.c
index d2f0fd9..22f044b 100644
--- a/src/gcm-cie-widget.c
+++ b/src/gcm-cie-widget.c
@@ -1186,98 +1186,3 @@ gcm_cie_widget_new (void)
return g_object_new (GCM_TYPE_CIE_WIDGET, NULL);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-#include "gcm-profile.h"
-#include "gcm-xyz.h"
-
-void
-gcm_cie_widget_test (EggTest *test)
-{
- GtkWidget *widget;
- GtkWidget *image;
- GtkWidget *dialog;
- GtkWidget *vbox;
- gboolean ret;
- GError *error = NULL;
- GcmProfile *profile;
- GcmXyz *white;
- GcmXyz *red;
- GcmXyz *green;
- GcmXyz *blue;
- gint response;
- gchar *filename_profile;
- gchar *filename_image;
- GFile *file = NULL;
-
- if (!egg_test_start (test, "GcmCieWidget"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a CIE widget object");
- widget = gcm_cie_widget_new ();
- egg_test_assert (test, widget != NULL);
-
- /************************************************************/
- egg_test_title (test, "get filename of image file");
- filename_image = egg_test_get_data_file ("cie-widget.png");
- egg_test_assert (test, (filename_image != NULL));
-
- /************************************************************/
- egg_test_title (test, "get filename of data file");
- filename_profile = egg_test_get_data_file ("bluish.icc");
- egg_test_assert (test, (filename_profile != NULL));
-
- profile = gcm_profile_default_new ();
- file = g_file_new_for_path (filename_profile);
- gcm_profile_parse (profile, file, NULL);
- g_object_get (profile,
- "white", &white,
- "red", &red,
- "green", &green,
- "blue", &blue,
- NULL);
- g_object_unref (file);
-
- g_object_set (widget,
- "red", red,
- "green", green,
- "blue", blue,
- "white", white,
- NULL);
-
- /* show in a dialog as an example */
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does CIE widget match\nthe picture below?");
- image = gtk_image_new_from_file (filename_image);
- vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_pack_end (GTK_BOX(vbox), widget, TRUE, TRUE, 12);
- gtk_box_pack_end (GTK_BOX(vbox), image, TRUE, TRUE, 12);
- gtk_widget_set_size_request (widget, 300, 300);
- gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
- gtk_widget_show (widget);
- gtk_widget_show (image);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- /************************************************************/
- egg_test_title (test, "plotted as expected?");
- egg_test_assert (test, (response == GTK_RESPONSE_YES));
-
- gtk_widget_destroy (dialog);
-
- g_object_unref (profile);
- g_object_unref (white);
- g_object_unref (red);
- g_object_unref (green);
- g_object_unref (blue);
- g_free (filename_profile);
- g_free (filename_image);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-clut.c b/src/gcm-clut.c
index b708cfa..8fbc732 100644
--- a/src/gcm-clut.c
+++ b/src/gcm-clut.c
@@ -369,120 +369,3 @@ gcm_clut_new (void)
return GCM_CLUT (clut);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_clut_test (EggTest *test)
-{
- GcmClut *clut;
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- const GcmClutData *data;
-
- if (!egg_test_start (test, "GcmClut"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a clut object");
- clut = gcm_clut_new ();
- egg_test_assert (test, clut != NULL);
-
- /* set some initial properties */
- g_object_set (clut,
- "size", 3,
- "contrast", 100.0f,
- "brightness", 0.0f,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "get array");
- array = gcm_clut_get_array (clut);
- if (array->len == 3)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid size: %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "check values for reset array");
- data = g_ptr_array_index (array, 0);
- if (data->red != 0 && data->green != 0 && data->blue != 0)
- egg_test_failed (test, "invalid data [0]: %i, %i, %i", data->red, data->green, data->blue);
- data = g_ptr_array_index (array, 1);
- if (data->red != 32767 && data->green != 32767 && data->blue != 32767)
- egg_test_failed (test, "invalid data [1]: %i, %i, %i", data->red, data->green, data->blue);
- data = g_ptr_array_index (array, 2);
- if (data->red != 65535 && data->green != 65535 && data->blue != 65535)
- egg_test_failed (test, "invalid data [2]: %i, %i, %i", data->red, data->green, data->blue);
- egg_test_success (test, NULL);
-
- g_ptr_array_unref (array);
-
- /* set some initial properties */
- g_object_set (clut,
- "contrast", 99.0f,
- "brightness", 0.0f,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "get array");
- array = gcm_clut_get_array (clut);
- if (array->len == 3)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid size: %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "check values for contrast adjusted array");
- data = g_ptr_array_index (array, 0);
- if (data->red != 0 && data->green != 0 && data->blue != 0)
- egg_test_failed (test, "invalid data [0]: %i, %i, %i", data->red, data->green, data->blue);
- data = g_ptr_array_index (array, 1);
- if (data->red != 32439 && data->green != 32439 && data->blue != 32439)
- egg_test_failed (test, "invalid data [1]: %i, %i, %i", data->red, data->green, data->blue);
- data = g_ptr_array_index (array, 2);
- if (data->red != 64879 && data->green != 64879 && data->blue != 64879)
- egg_test_failed (test, "invalid data [2]: %i, %i, %i", data->red, data->green, data->blue);
- egg_test_success (test, NULL);
-
- g_ptr_array_unref (array);
-
- /* set some initial properties */
- g_object_set (clut,
- "contrast", 100.0f,
- "brightness", 1.0f,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "get array");
- array = gcm_clut_get_array (clut);
- if (array->len == 3)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid size: %i", array->len);
-
- /************************************************************/
- egg_test_title (test, "check values for brightness adjusted array");
- data = g_ptr_array_index (array, 0);
- if (data->red != 655 && data->green != 655 && data->blue != 655)
- egg_test_failed (test, "invalid data [0]: %i, %i, %i", data->red, data->green, data->blue);
- data = g_ptr_array_index (array, 1);
- if (data->red != 33094 && data->green != 33094 && data->blue != 33094)
- egg_test_failed (test, "invalid data [1]: %i, %i, %i", data->red, data->green, data->blue);
- data = g_ptr_array_index (array, 2);
- if (data->red != 65535 && data->green != 65535 && data->blue != 65535)
- egg_test_failed (test, "invalid data [2]: %i, %i, %i", data->red, data->green, data->blue);
- egg_test_success (test, NULL);
-
- g_ptr_array_unref (array);
-
- g_object_unref (clut);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-device.c b/src/gcm-device.c
index 2c8d044..5f411ac 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -1105,220 +1105,3 @@ gcm_device_finalize (GObject *object)
G_OBJECT_CLASS (gcm_device_parent_class)->finalize (object);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-#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)
-{
- GcmDevice *device;
- gboolean ret;
- GError *error = NULL;
- const gchar *filename;
- const gchar *profile;
- gchar *data;
- const gchar *kind;
- GcmDeviceKind kind_enum;
-
- if (!egg_test_start (test, "GcmDevice"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a device object");
- 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");
- kind_enum = gcm_device_kind_from_string ("scanner");
- egg_test_assert (test, (kind_enum == GCM_DEVICE_KIND_SCANNER));
-
- /************************************************************/
- egg_test_title (test, "convert to unrecognized enum");
- kind_enum = gcm_device_kind_from_string ("xxx");
- egg_test_assert (test, (kind_enum == GCM_DEVICE_KIND_UNKNOWN));
-
- /************************************************************/
- egg_test_title (test, "convert from recognized enum");
- kind = gcm_device_kind_to_string (GCM_DEVICE_KIND_SCANNER);
- if (g_strcmp0 (kind, "scanner") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", kind);
-
- /************************************************************/
- egg_test_title (test, "convert from unrecognized enum");
- kind = gcm_device_kind_to_string (GCM_DEVICE_KIND_UNKNOWN);
- if (g_strcmp0 (kind, "unknown") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", kind);
-
- /* set some properties */
- g_object_set (device,
- "kind", GCM_DEVICE_KIND_SCANNER,
- "id", "sysfs_dummy_device",
- "connected", FALSE,
- "virtual", FALSE,
- "serial", "0123456789",
- "colorspace", GCM_COLORSPACE_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");
- kind = gcm_device_get_id (device);
- if (g_strcmp0 (kind, "sysfs_dummy_device") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid id: %s", kind);
-
- /* ensure the file is nuked */
- filename = gcm_utils_get_default_config_location ();
- g_unlink (filename);
-
- /************************************************************/
- egg_test_title (test, "load from missing file");
- ret = gcm_device_load (device, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load: %s", error->message);
-
- /* get some properties */
- profile = gcm_device_get_profile_filename (device);
-
- /************************************************************/
- egg_test_title (test, "get profile filename");
- if (g_strcmp0 (profile, NULL) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid profile: %s", profile);
-
- /* empty file that exists */
- g_file_set_contents (filename, "", -1, NULL);
-
- /************************************************************/
- egg_test_title (test, "load from empty file");
- ret = gcm_device_load (device, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load: %s", error->message);
-
- /* set default file */
- g_file_set_contents (filename, "[sysfs_dummy_device]\ntitle=Canon - CanoScan\ntype=scanner\nprofile=/srv/sysfs_canon_canoscan.icc\n", -1, NULL);
-
- /************************************************************/
- egg_test_title (test, "load from configured file");
- ret = gcm_device_load (device, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load: %s", error->message);
-
- /* get some properties */
- profile = gcm_device_get_profile_filename (device);
-
- /************************************************************/
- 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);
- else
- egg_test_failed (test, "invalid profile: %s", profile);
-
- /* set some properties */
- gcm_device_set_profile_filename (device, "/srv/sysfs_canon_canoscan.icc");
-
- /* ensure the file is nuked, again */
- g_unlink (filename);
-
- /************************************************************/
- egg_test_title (test, "save to empty file");
- ret = gcm_device_save (device, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load: %s", error->message);
-
- /************************************************************/
- egg_test_title (test, "get contents of saved file");
- ret = g_file_get_contents (filename, &data, NULL, NULL);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "check data");
- if (g_str_has_suffix (data, "profile=/srv/sysfs_canon_canoscan.icc\nserial=0123456789\ntype=scanner\ncolorspace=rgb\n"))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid data: %s", data);
- g_free (data);
-
- /* ensure the file is nuked, in case we are running in distcheck */
- g_unlink (filename);
-
- g_object_unref (device);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-dmi.c b/src/gcm-dmi.c
index da10ed6..61a4185 100644
--- a/src/gcm-dmi.c
+++ b/src/gcm-dmi.c
@@ -274,46 +274,3 @@ gcm_dmi_new (void)
return GCM_DMI (gcm_dmi_object);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_dmi_test (EggTest *test)
-{
- GcmDmi *dmi;
- const gchar *name;
- const gchar *version;
- const gchar *vendor;
-
- if (!egg_test_start (test, "GcmDmi"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a dmi object");
- dmi = gcm_dmi_new ();
- egg_test_assert (test, dmi != NULL);
-
- /************************************************************/
- egg_test_title (test, "got name: %s", name);
- name = gcm_dmi_get_name (dmi);
- egg_test_assert (test, name != NULL);
-
- /************************************************************/
- egg_test_title (test, "got version: %s", version);
- version = gcm_dmi_get_version (dmi);
- egg_test_assert (test, version != NULL);
-
- /************************************************************/
- egg_test_title (test, "got vendor: %s", vendor);
- vendor = gcm_dmi_get_vendor (dmi);
- egg_test_assert (test, vendor != NULL);
-
- g_object_unref (dmi);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-edid.c b/src/gcm-edid.c
index bee35fc..fa89e5c 100644
--- a/src/gcm-edid.c
+++ b/src/gcm-edid.c
@@ -592,164 +592,3 @@ gcm_edid_new (void)
return GCM_EDID (edid);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-typedef struct {
- const gchar *monitor_name;
- const gchar *vendor_name;
- const gchar *serial_number;
- const gchar *eisa_id;
- const gchar *pnp_id;
- guint width;
- guint height;
- gfloat gamma;
-} GcmEdidTestData;
-
-void
-gcm_edid_test_parse_edid_file (EggTest *test, GcmEdid *edid, const gchar *datafile, GcmEdidTestData *test_data)
-{
- gchar *filename;
- const gchar *monitor_name;
- const gchar *vendor_name;
- const gchar *serial_number;
- const gchar *eisa_id;
- const gchar *pnp_id;
- gchar *data;
- guint width;
- guint height;
- gfloat gamma;
- gboolean ret;
- GError *error = NULL;
-
- /************************************************************/
- egg_test_title (test, "get filename of data file");
- filename = egg_test_get_data_file (datafile);
- ret = g_file_get_contents (filename, &data, NULL, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to load: %s", error->message);
-
- /************************************************************/
- egg_test_title (test, "parse an example edid block");
- ret = gcm_edid_parse (edid, data, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to parse: %s", error->message);
-
- /************************************************************/
- egg_test_title (test, "check monitor name for %s", datafile);
- monitor_name = gcm_edid_get_monitor_name (edid);
- if (g_strcmp0 (monitor_name, test_data->monitor_name) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", monitor_name, test_data->monitor_name);
-
- /************************************************************/
- egg_test_title (test, "check vendor name for %s", datafile);
- vendor_name = gcm_edid_get_vendor_name (edid);
- if (g_strcmp0 (vendor_name, test_data->vendor_name) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", vendor_name, test_data->vendor_name);
-
- /************************************************************/
- egg_test_title (test, "check serial number for %s", datafile);
- serial_number = gcm_edid_get_serial_number (edid);
- if (g_strcmp0 (serial_number, test_data->serial_number) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", serial_number, test_data->serial_number);
-
- /************************************************************/
- egg_test_title (test, "check ascii string for %s", datafile);
- eisa_id = gcm_edid_get_eisa_id (edid);
- if (g_strcmp0 (eisa_id, test_data->eisa_id) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", eisa_id, test_data->eisa_id);
-
- /************************************************************/
- egg_test_title (test, "check pnp id for %s", datafile);
- pnp_id = gcm_edid_get_pnp_id (edid);
- if (g_strcmp0 (pnp_id, test_data->pnp_id) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", pnp_id, test_data->pnp_id);
-
- /************************************************************/
- egg_test_title (test, "check height for %s", datafile);
- height = gcm_edid_get_height (edid);
- if (height == test_data->height)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %i, expecting: %i", height, test_data->height);
-
- /************************************************************/
- egg_test_title (test, "check width for %s", datafile);
- width = gcm_edid_get_width (edid);
- if (width == test_data->width)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %i, expecting: %i", width, test_data->width);
-
- /************************************************************/
- egg_test_title (test, "check gamma for %s", datafile);
- gamma = gcm_edid_get_gamma (edid);
- if (gamma > (test_data->gamma - 0.01) && gamma < (test_data->gamma + 0.01))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %f, expecting: %f", gamma, test_data->gamma);
-
- g_free (filename);
-}
-
-void
-gcm_edid_test (EggTest *test)
-{
- GcmEdid *edid;
- gboolean ret;
- GError *error = NULL;
- GcmEdidTestData test_data;
-
- if (!egg_test_start (test, "GcmEdid"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a edid object");
- edid = gcm_edid_new ();
- egg_test_assert (test, edid != NULL);
-
- /* LG 21" LCD panel */
- test_data.monitor_name = "L225W";
- test_data.vendor_name = "Goldstar Company Ltd";
- test_data.serial_number = "34398";
- test_data.eisa_id = NULL;
- test_data.pnp_id = "GSM";
- test_data.height = 30;
- test_data.width = 47;
- test_data.gamma = 2.2f;
- gcm_edid_test_parse_edid_file (test, edid, "LG-L225W-External.bin", &test_data);
-
- /* Lenovo T61 Intel Panel */
- test_data.monitor_name = NULL;
- test_data.vendor_name = "IBM France";
- test_data.serial_number = NULL;
- test_data.eisa_id = "LTN154P2-L05";
- test_data.pnp_id = "IBM";
- test_data.height = 21;
- test_data.width = 33;
- test_data.gamma = 2.2f;
- gcm_edid_test_parse_edid_file (test, edid, "Lenovo-T61-Internal.bin", &test_data);
-
- g_object_unref (edid);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-edid.h b/src/gcm-edid.h
index 5cc4d6d..76ae336 100644
--- a/src/gcm-edid.h
+++ b/src/gcm-edid.h
@@ -63,7 +63,7 @@ gboolean gcm_edid_parse (GcmEdid *edid,
const gchar *gcm_edid_get_monitor_name (GcmEdid *edid);
const gchar *gcm_edid_get_vendor_name (GcmEdid *edid);
const gchar *gcm_edid_get_serial_number (GcmEdid *edid);
-const gchar *gcm_edid_get_eisa_id (GcmEdid *edid);
+const gchar *gcm_edid_get_eisa_id (GcmEdid *edid);
const gchar *gcm_edid_get_pnp_id (GcmEdid *edid);
guint gcm_edid_get_width (GcmEdid *edid);
guint gcm_edid_get_height (GcmEdid *edid);
diff --git a/src/gcm-gamma-widget.c b/src/gcm-gamma-widget.c
index b578c56..91b1bda 100644
--- a/src/gcm-gamma-widget.c
+++ b/src/gcm-gamma-widget.c
@@ -338,67 +338,3 @@ gcm_gamma_widget_new (void)
return g_object_new (GCM_TYPE_GAMMA_WIDGET, NULL);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_gamma_widget_test (EggTest *test)
-{
- GtkWidget *widget;
- GtkWidget *image;
- GtkWidget *dialog;
- GtkWidget *vbox;
- gboolean ret;
- GError *error = NULL;
- gint response;
- gchar *filename_image;
-
- if (!egg_test_start (test, "GcmGammaWidget"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a gamma widget object");
- widget = gcm_gamma_widget_new ();
- egg_test_assert (test, widget != NULL);
-
- g_object_set (widget,
- "color-light", 0.5f,
- "color-dark", 0.0f,
- "color-red", 0.25f,
- "color-green", 0.25f,
- "color-blue", 0.25f,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "get filename of image file");
- filename_image = egg_test_get_data_file ("gamma-widget.png");
- egg_test_assert (test, (filename_image != NULL));
-
- /* show in a dialog as an example */
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does GAMMA widget match\nthe picture below?");
- image = gtk_image_new_from_file (filename_image);
- vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_pack_end (GTK_BOX(vbox), widget, TRUE, TRUE, 12);
- gtk_box_pack_end (GTK_BOX(vbox), image, TRUE, TRUE, 12);
- gtk_widget_set_size_request (widget, 300, 300);
- gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
- gtk_widget_show (widget);
- gtk_widget_show (image);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- /************************************************************/
- egg_test_title (test, "plotted as expected?");
- egg_test_assert (test, (response == GTK_RESPONSE_YES));
-
- gtk_widget_destroy (dialog);
-
- g_free (filename_image);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-image.c b/src/gcm-image.c
index ab73d36..2204338 100644
--- a/src/gcm-image.c
+++ b/src/gcm-image.c
@@ -441,132 +441,3 @@ gcm_image_new (void)
return GCM_IMAGE (image);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-static gchar *
-gcm_image_test_get_ibmt61_profile ()
-{
- gchar *filename;
- gchar *profile_base64 = NULL;
- gchar *contents = NULL;
- gboolean ret;
- gsize length;
- GError *error = NULL;
-
- /* get test file */
- filename = egg_test_get_data_file ("ibm-t61.icc");
-
- /* get contents */
- ret = g_file_get_contents (filename, &contents, &length, &error);
- if (!ret) {
- egg_warning ("failed to get contents: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* encode */
- profile_base64 = g_base64_encode (contents, length);
-out:
- g_free (contents);
- g_free (filename);
- return profile_base64;
-}
-
-void
-gcm_image_test (EggTest *test)
-{
- GcmImage *image;
- GtkWidget *image_test;
- GtkWidget *dialog;
- GtkWidget *vbox;
- gboolean ret;
- GError *error = NULL;
- gint response;
- gchar *filename_widget;
- gchar *filename_test;
- gchar *profile_base64;
-
- if (!egg_test_start (test, "GcmImage"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a clever image object");
- image = gcm_image_new ();
- egg_test_assert (test, image != NULL);
-
- /************************************************************/
- filename_widget = egg_test_get_data_file ("image-widget.png");
- gtk_image_set_from_file (GTK_IMAGE(image), filename_widget);
-
- /************************************************************/
- egg_test_title (test, "get filename of image file");
- filename_test = egg_test_get_data_file ("image-widget-good.png");
- egg_test_assert (test, (filename_test != NULL));
-
- /* show in a dialog as an example */
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does color-corrected image match\nthe picture below?");
- image_test = gtk_image_new_from_file (filename_test);
- vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_pack_end (GTK_BOX(vbox), GTK_WIDGET(image), TRUE, TRUE, 12);
- gtk_box_pack_end (GTK_BOX(vbox), image_test, TRUE, TRUE, 12);
- gtk_widget_set_size_request (GTK_WIDGET(image), 300, 300);
- gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
- gtk_widget_show (GTK_WIDGET(image));
- gtk_widget_show (image_test);
-
- g_object_set (image,
- "use-embedded-icc-profile", TRUE,
- "output-icc-profile", NULL,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "converted as expected?");
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- egg_test_assert (test, (response == GTK_RESPONSE_YES));
- g_free (filename_test);
-
- /************************************************************/
- filename_test = egg_test_get_data_file ("image-widget-nonembed.png");
- gtk_image_set_from_file (GTK_IMAGE(image_test), filename_test);
- g_object_set (image,
- "use-embedded-icc-profile", FALSE,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "converted as expected?");
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- egg_test_assert (test, (response == GTK_RESPONSE_YES));
- g_free (filename_test);
-
- /************************************************************/
- egg_test_title (test, "get dummy display profile");
- profile_base64 = gcm_image_test_get_ibmt61_profile ();
- egg_test_assert (test, (profile_base64 != NULL));
-
- /************************************************************/
- filename_test = egg_test_get_data_file ("image-widget-output.png");
- gtk_image_set_from_file (GTK_IMAGE(image_test), filename_test);
- g_object_set (image,
- "use-embedded-icc-profile", TRUE,
- "output-icc-profile", profile_base64,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "converted as expected?");
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- egg_test_assert (test, (response == GTK_RESPONSE_YES));
- g_free (filename_test);
-
- gtk_widget_destroy (dialog);
-
- g_free (profile_base64);
- g_free (filename_widget);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-print.c b/src/gcm-print.c
index a245226..2132927 100644
--- a/src/gcm-print.c
+++ b/src/gcm-print.c
@@ -336,44 +336,3 @@ gcm_print_new (void)
return GCM_PRINT (print);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-static GPtrArray *
-gcm_print_test_render_cb (GcmPrint *print, GtkPageSetup *page_setup, gpointer user_data, GError **error)
-{
- GPtrArray *filenames;
- filenames = g_ptr_array_new_with_free_func (g_free);
- g_ptr_array_add (filenames, egg_test_get_data_file ("image-widget-nonembed.png"));
- g_ptr_array_add (filenames, egg_test_get_data_file ("image-widget-good.png"));
- return filenames;
-}
-
-void
-gcm_print_test (EggTest *test)
-{
- gboolean ret;
- GError *error = NULL;
- GcmPrint *print;
-
- if (!egg_test_start (test, "GcmPrint"))
- return;
-
- print = gcm_print_new ();
-
- /************************************************************/
- egg_test_title (test, "try to print");
- ret = gcm_print_with_render_callback (print, NULL, gcm_print_test_render_cb, test, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to print: %s", error->message);
-
- g_object_unref (print);
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index 02a5668..3cd3c33 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -869,169 +869,3 @@ gcm_profile_default_new (void)
return profile;
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include <math.h>
-#include "egg-test.h"
-
-typedef struct {
- const gchar *copyright;
- const gchar *manufacturer;
- const gchar *model;
- const gchar *datetime;
- const gchar *description;
- GcmProfileKind kind;
- GcmColorspace colorspace;
- gfloat luminance;
-} GcmProfileTestData;
-
-void
-gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTestData *test_data)
-{
- gchar *filename = NULL;
- const gchar *copyright;
- const gchar *manufacturer;
- const gchar *model;
- const gchar *datetime;
- const gchar *description;
- const gchar *eisa_id;
- const gchar *pnp_id;
- guint width;
- guint kind;
- guint colorspace;
- gfloat gamma;
- gboolean ret;
- GError *error = NULL;
- GcmProfile *profile_lcms1;
- GcmXyz *xyz;
- gfloat luminance;
- GFile *file;
-
- /************************************************************/
- egg_test_title (test, "get a profile_lcms1 object");
- profile_lcms1 = GCM_PROFILE(gcm_profile_lcms1_new ());
- egg_test_assert (test, profile_lcms1 != NULL);
-
- /************************************************************/
- egg_test_title (test, "get filename of data file");
- filename = egg_test_get_data_file (datafile);
- egg_test_assert (test, (filename != NULL));
-
- /************************************************************/
- egg_test_title (test, "load ICC file");
- file = g_file_new_for_path (filename);
- ret = gcm_profile_parse (profile_lcms1, file, &error);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to parse: %s", error->message);
- g_object_unref (file);
-
- /************************************************************/
- egg_test_title (test, "check copyright for %s", datafile);
- copyright = gcm_profile_get_copyright (profile_lcms1);
- if (g_strcmp0 (copyright, test_data->copyright) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", copyright, test_data->copyright);
-
- /************************************************************/
- egg_test_title (test, "check manufacturer for %s", datafile);
- manufacturer = gcm_profile_get_manufacturer (profile_lcms1);
- if (g_strcmp0 (manufacturer, test_data->manufacturer) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", manufacturer, test_data->manufacturer);
-
- /************************************************************/
- egg_test_title (test, "check model for %s", datafile);
- model = gcm_profile_get_model (profile_lcms1);
- if (g_strcmp0 (model, test_data->model) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", model, test_data->model);
-
- /************************************************************/
- egg_test_title (test, "check datetime for %s", datafile);
- datetime = gcm_profile_get_datetime (profile_lcms1);
- if (g_strcmp0 (datetime, test_data->datetime) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", datetime, test_data->datetime);
-
- /************************************************************/
- egg_test_title (test, "check description for %s", datafile);
- description = gcm_profile_get_description (profile_lcms1);
- if (g_strcmp0 (description, test_data->description) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s, expecting: %s", description, test_data->description);
-
- /************************************************************/
- egg_test_title (test, "check kind for %s", datafile);
- kind = gcm_profile_get_kind (profile_lcms1);
- if (kind == test_data->kind)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %i, expecting: %i", kind, test_data->kind);
-
- /************************************************************/
- egg_test_title (test, "check colorspace for %s", datafile);
- colorspace = gcm_profile_get_colorspace (profile_lcms1);
- if (colorspace == test_data->colorspace)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %i, expecting: %i", colorspace, test_data->colorspace);
-
- /************************************************************/
- egg_test_title (test, "check luminance red %s", datafile);
- g_object_get (profile_lcms1,
- "red", &xyz,
- NULL);
- luminance = gcm_xyz_get_x (xyz);
- if (fabs (luminance - test_data->luminance) < 0.001)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %f, expecting: %f", luminance, test_data->luminance);
-
- g_object_unref (xyz);
- g_object_unref (profile_lcms1);
- g_free (filename);
-}
-
-void
-gcm_profile_test (EggTest *test)
-{
- GcmProfileTestData test_data;
-
- if (!egg_test_start (test, "GcmProfile"))
- return;
-
- /* bluish test */
- test_data.copyright = "Copyright (c) 1998 Hewlett-Packard Company";
- test_data.manufacturer = "IEC http://www.iec.ch";
- test_data.model = "IEC 61966-2.1 Default RGB colour space - sRGB";
- test_data.description = "Blueish Test";
- test_data.kind = GCM_PROFILE_KIND_DISPLAY_DEVICE;
- test_data.colorspace = GCM_COLORSPACE_RGB;
- test_data.luminance = 0.648454;
- test_data.datetime = "February 9 1998, 06:49:00 AM";
- gcm_profile_test_parse_file (test, "bluish.icc", &test_data);
-
- /* Adobe test */
- test_data.copyright = "Copyright (c) 1998 Hewlett-Packard Company Modified using Adobe Gamma";
- test_data.manufacturer = "IEC http://www.iec.ch";
- test_data.model = "IEC 61966-2.1 Default RGB colour space - sRGB";
- test_data.description = "ADOBEGAMMA-Test";
- test_data.kind = GCM_PROFILE_KIND_DISPLAY_DEVICE;
- test_data.colorspace = GCM_COLORSPACE_RGB;
- test_data.luminance = 0.648446;
- test_data.datetime = "August 16 2005, 09:49:54 PM";
- gcm_profile_test_parse_file (test, "AdobeGammaTest.icm", &test_data);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 0fe3bcd..4dc9516 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -20,55 +20,1117 @@
*/
#include <glib-object.h>
-#include "egg-test.h"
-#include <egg-debug.h>
-
-/* prototypes */
-void gcm_print_test (EggTest *test);
-void gcm_edid_test (EggTest *test);
-void gcm_image_test (EggTest *test);
-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);
-void gcm_clut_test (EggTest *test);
-void gcm_dmi_test (EggTest *test);
-void gcm_xyz_test (EggTest *test);
-void gcm_cie_widget_test (EggTest *test);
-void gcm_trc_widget_test (EggTest *test);
-void gcm_calibrate_test (EggTest *test);
-void gcm_calibrate_manual_test (EggTest *test);
+#include <math.h>
+#include <glib/gstdio.h>
+
+#include "gcm-brightness.h"
+#include "gcm-calibrate.h"
+#include "gcm-calibrate-dialog.h"
+#include "gcm-calibrate-manual.h"
+#include "gcm-cie-widget.h"
+#include "gcm-clut.h"
+#include "gcm-device.h"
+#include "gcm-device-udev.h"
+#include "gcm-dmi.h"
+#include "gcm-edid.h"
+#include "gcm-gamma-widget.h"
+#include "gcm-image.h"
+#include "gcm-print.h"
+#include "gcm-profile.h"
+#include "gcm-profile-lcms1.h"
+#include "gcm-tables.h"
+#include "gcm-trc-widget.h"
+#include "gcm-utils.h"
+#include "gcm-xyz.h"
+#include "gcm-profile.h"
+#include "gcm-xyz.h"
+
+/**
+ * gcm_test_get_data_file:
+ **/
+static gchar *
+gcm_test_get_data_file (const gchar *filename)
+{
+ gboolean ret;
+ gchar *full;
+
+ /* check to see if we are being run in the build root */
+ full = g_build_filename ("..", "data", "tests", filename, NULL);
+ ret = g_file_test (full, G_FILE_TEST_EXISTS);
+ if (ret)
+ return full;
+ g_free (full);
+
+ /* check to see if we are being run in the build root */
+ full = g_build_filename ("..", "..", "data", "tests", filename, NULL);
+ ret = g_file_test (full, G_FILE_TEST_EXISTS);
+ if (ret)
+ return full;
+ g_free (full);
+
+ /* check to see if we are being run in make check */
+ full = g_build_filename ("..", "..", "data", "tests", filename, NULL);
+ ret = g_file_test (full, G_FILE_TEST_EXISTS);
+ if (ret)
+ return full;
+ g_free (full);
+ full = g_build_filename ("..", "..", "..", "data", "tests", filename, NULL);
+ ret = g_file_test (full, G_FILE_TEST_EXISTS);
+ if (ret)
+ return full;
+ g_free (full);
+ return NULL;
+}
+
+static void
+gcm_test_brightness_func (void)
+{
+ GcmBrightness *brightness;
+ gboolean ret;
+ GError *error = NULL;
+ guint orig_percentage;
+ guint percentage;
+
+ brightness = gcm_brightness_new ();
+ g_assert (brightness != NULL);
+
+ g_debug ("get original brightness");
+ ret = gcm_brightness_get_percentage (brightness, &orig_percentage, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_debug ("set the new brightness");
+ ret = gcm_brightness_set_percentage (brightness, 10, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_debug ("get the new brightness");
+ ret = gcm_brightness_get_percentage (brightness, &percentage, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_assert_cmpint (percentage, >, 5);
+ g_assert_cmpint (percentage, <, 15);
+
+ g_debug ("set back original brightness");
+ ret = gcm_brightness_set_percentage (brightness, orig_percentage, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_object_unref (brightness);
+}
+
+static void
+gcm_test_calibrate_func (void)
+{
+ GcmCalibrate *calibrate;
+ gboolean ret;
+ GError *error = NULL;
+ gchar *filename;
+
+ calibrate = gcm_calibrate_new ();
+ g_assert (calibrate != NULL);
+
+ g_debug ("calibrate display manually");
+ filename = gcm_test_get_data_file ("test.tif");
+ ret = gcm_calibrate_set_from_exif (GCM_CALIBRATE(calibrate), filename, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_assert_cmpstr (gcm_calibrate_get_model_fallback (calibrate), ==, "NIKON D60");
+ g_assert_cmpstr (gcm_calibrate_get_manufacturer_fallback (calibrate), ==, "NIKON CORPORATION");
+
+ g_object_unref (calibrate);
+ g_free (filename);
+}
+
+static void
+gcm_test_calibrate_dialog_func (void)
+{
+ GcmCalibrateDialog *calibrate_dialog;
+ calibrate_dialog = gcm_calibrate_dialog_new ();
+ g_assert (calibrate_dialog != NULL);
+ g_object_unref (calibrate_dialog);
+}
+
+static void
+gcm_test_calibrate_manual_func (void)
+{
+ GcmCalibrateManual *calibrate;
+ gboolean ret;
+ GError *error = NULL;
+
+ calibrate = gcm_calibrate_manual_new ();
+ g_assert (calibrate != NULL);
+
+ /* set to avoid a critical warning */
+ g_object_set (calibrate,
+ "output-name", "lvds1",
+ NULL);
+
+ g_debug ("calibrate display manually");
+ ret = gcm_calibrate_display (GCM_CALIBRATE(calibrate), NULL, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_object_unref (calibrate);
+}
+
+static void
+gcm_test_cie_widget_func (void)
+{
+ GtkWidget *widget;
+ GtkWidget *image;
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ GcmProfile *profile;
+ GcmXyz *white;
+ GcmXyz *red;
+ GcmXyz *green;
+ GcmXyz *blue;
+ gint response;
+ gchar *filename_profile;
+ gchar *filename_image;
+ GFile *file = NULL;
+
+ widget = gcm_cie_widget_new ();
+ g_assert (widget != NULL);
+
+ g_debug ("get filename of image file");
+ filename_image = gcm_test_get_data_file ("cie-widget.png");
+ g_assert ((filename_image != NULL));
+
+ g_debug ("get filename of data file");
+ filename_profile = gcm_test_get_data_file ("bluish.icc");
+ g_assert ((filename_profile != NULL));
+
+ profile = gcm_profile_default_new ();
+ file = g_file_new_for_path (filename_profile);
+ gcm_profile_parse (profile, file, NULL);
+ g_object_get (profile,
+ "white", &white,
+ "red", &red,
+ "green", &green,
+ "blue", &blue,
+ NULL);
+ g_object_unref (file);
+
+ g_object_set (widget,
+ "red", red,
+ "green", green,
+ "blue", blue,
+ "white", white,
+ NULL);
+
+ /* show in a dialog as an example */
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does CIE widget match\nthe picture below?");
+ image = gtk_image_new_from_file (filename_image);
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_end (GTK_BOX(vbox), widget, TRUE, TRUE, 12);
+ gtk_box_pack_end (GTK_BOX(vbox), image, TRUE, TRUE, 12);
+ gtk_widget_set_size_request (widget, 300, 300);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
+ gtk_widget_show (widget);
+ gtk_widget_show (image);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ g_debug ("plotted as expected?");
+ g_assert ((response == GTK_RESPONSE_YES));
+
+ gtk_widget_destroy (dialog);
+
+ g_object_unref (profile);
+ g_object_unref (white);
+ g_object_unref (red);
+ g_object_unref (green);
+ g_object_unref (blue);
+ g_free (filename_profile);
+ g_free (filename_image);
+}
+
+static void
+gcm_test_clut_func (void)
+{
+ GcmClut *clut;
+ GPtrArray *array;
+ const GcmClutData *data;
+
+ clut = gcm_clut_new ();
+ g_assert (clut != NULL);
+
+ /* set some initial properties */
+ g_object_set (clut,
+ "size", 3,
+ "contrast", 100.0f,
+ "brightness", 0.0f,
+ NULL);
+
+ g_debug ("get array");
+ array = gcm_clut_get_array (clut);
+ g_assert_cmpint (array->len, ==, 3);
+
+ g_debug ("check values for reset array");
+
+ data = g_ptr_array_index (array, 0);
+ g_assert_cmpint (data->red, ==, 0);
+ g_assert_cmpint (data->green, ==, 0);
+ g_assert_cmpint (data->blue, ==, 0);
+
+ data = g_ptr_array_index (array, 1);
+ g_assert_cmpint (data->red, ==, 32767);
+ g_assert_cmpint (data->green, ==, 32767);
+ g_assert_cmpint (data->blue, ==, 32767);
+
+ data = g_ptr_array_index (array, 2);
+ g_assert_cmpint (data->red, ==, 65535);
+ g_assert_cmpint (data->green, ==, 65535);
+ g_assert_cmpint (data->blue, ==, 65535);
+
+ g_ptr_array_unref (array);
+
+ /* set some initial properties */
+ g_object_set (clut,
+ "contrast", 99.0f,
+ "brightness", 0.0f,
+ NULL);
+
+ g_debug ("get array");
+ array = gcm_clut_get_array (clut);
+ g_assert_cmpint (array->len, ==, 3);
+
+ g_debug ("check values for contrast adjusted array");
+ data = g_ptr_array_index (array, 0);
+ g_assert_cmpint (data->red, ==, 0);
+ g_assert_cmpint (data->green, ==, 0);
+ g_assert_cmpint (data->blue, ==, 0);
+ data = g_ptr_array_index (array, 1);
+ g_assert_cmpint (data->red, ==, 32439);
+ g_assert_cmpint (data->green, ==, 32439);
+ g_assert_cmpint (data->blue, ==, 32439);
+ data = g_ptr_array_index (array, 2);
+ g_assert_cmpint (data->red, ==, 64879);
+ g_assert_cmpint (data->green, ==, 64879);
+ g_assert_cmpint (data->blue, ==, 64879);
+
+ g_ptr_array_unref (array);
+
+ /* set some initial properties */
+ g_object_set (clut,
+ "contrast", 100.0f,
+ "brightness", 1.0f,
+ NULL);
+
+ g_debug ("get array");
+ array = gcm_clut_get_array (clut);
+ g_assert_cmpint (array->len, ==, 3);
+
+ g_debug ("check values for brightness adjusted array");
+ data = g_ptr_array_index (array, 0);
+ g_assert_cmpint (data->red, ==, 655);
+ g_assert_cmpint (data->green, ==, 655);
+ g_assert_cmpint (data->blue, ==, 655);
+ data = g_ptr_array_index (array, 1);
+ g_assert_cmpint (data->red, ==, 33094);
+ g_assert_cmpint (data->green, ==, 33094);
+ g_assert_cmpint (data->blue, ==, 33094);
+ data = g_ptr_array_index (array, 2);
+ g_assert_cmpint (data->red, ==, 65535);
+ g_assert_cmpint (data->green, ==, 65535);
+ g_assert_cmpint (data->blue, ==, 65535);
+
+ g_ptr_array_unref (array);
+
+ g_object_unref (clut);
+}
+
+static guint _changes = 0;
+static GMainLoop *_loop = NULL;
+
+static void
+gcm_device_test_changed_cb (GcmDevice *device)
+{
+ g_debug ("emit changed: %s", gcm_device_get_id (device));
+ _changes++;
+
+ g_main_loop_quit (_loop);
+}
+
+static void
+gcm_test_device_func (void)
+{
+ GcmDevice *device;
+ gboolean ret;
+ GError *error = NULL;
+ const gchar *filename;
+ const gchar *profile;
+ gchar *data;
+ gchar **split;
+ const gchar *kind;
+ GcmDeviceKind kind_enum;
+
+ device = gcm_device_udev_new ();
+ g_assert (device != NULL);
+
+ /* connect to the changed signal */
+ g_signal_connect (device, "changed", G_CALLBACK (gcm_device_test_changed_cb), NULL);
+
+ g_debug ("correct number of changed signals");
+ g_assert_cmpint (_changes, ==, 0);
+
+ g_debug ("convert to recognized enum");
+ kind_enum = gcm_device_kind_from_string ("scanner");
+ g_assert ((kind_enum == GCM_DEVICE_KIND_SCANNER));
+
+ g_debug ("convert to unrecognized enum");
+ kind_enum = gcm_device_kind_from_string ("xxx");
+ g_assert ((kind_enum == GCM_DEVICE_KIND_UNKNOWN));
+
+ g_debug ("convert from recognized enum");
+ kind = gcm_device_kind_to_string (GCM_DEVICE_KIND_SCANNER);
+ g_assert_cmpstr (kind, ==, "scanner");
+
+ g_debug ("convert from unrecognized enum");
+ kind = gcm_device_kind_to_string (GCM_DEVICE_KIND_UNKNOWN);
+ g_assert_cmpstr (kind, ==, "unknown");
+
+ /* set some properties */
+ g_object_set (device,
+ "kind", GCM_DEVICE_KIND_SCANNER,
+ "id", "sysfs_dummy_device",
+ "connected", FALSE,
+ "virtual", FALSE,
+ "serial", "0123456789",
+ "colorspace", GCM_COLORSPACE_RGB,
+ NULL);
+
+ _loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (_loop);
+ /* TODO: time out of loop */
+
+ g_debug ("correct number of changed signals");
+ g_assert_cmpint (_changes, ==, 1);
+
+ gcm_device_set_connected (device, TRUE);
+ g_main_loop_run (_loop);
+ /* TODO: time out of loop */
+
+ g_debug ("correct number of changed signals");
+ g_assert_cmpint (_changes, ==, 2);
+
+ g_debug ("get id");
+ kind = gcm_device_get_id (device);
+ g_assert_cmpstr (kind, ==, "sysfs_dummy_device");
+
+ /* ensure the file is nuked */
+ filename = gcm_utils_get_default_config_location ();
+ g_unlink (filename);
+
+ g_debug ("load from missing file");
+ ret = gcm_device_load (device, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ /* get some properties */
+ profile = gcm_device_get_profile_filename (device);
+
+ g_debug ("get profile filename");
+ g_assert_cmpstr (profile, ==, NULL);
+
+ /* empty file that exists */
+ g_file_set_contents (filename, "", -1, NULL);
+
+ g_debug ("load from empty file");
+ ret = gcm_device_load (device, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ /* set default file */
+ g_file_set_contents (filename,
+ "[sysfs_dummy_device]\n"
+ "title=Canon - CanoScan\n"
+ "type=scanner\n"
+ "profile=/srv/sysfs_canon_canoscan.icc\n", -1, NULL);
+
+ g_debug ("load from configured file");
+ ret = gcm_device_load (device, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ /* get some properties */
+ profile = gcm_device_get_profile_filename (device);
+
+ g_main_loop_run (_loop);
+ /* TODO: time out of loop */
+
+ g_debug ("correct number of changed signals");
+ g_assert_cmpint (_changes, ==, 3);
+
+ g_debug ("get profile filename");
+ g_assert_cmpstr (profile, ==, "/srv/sysfs_canon_canoscan.icc");
+
+ /* set some properties */
+ gcm_device_set_profile_filename (device, "/srv/sysfs_canon_canoscan.icc");
+
+ /* ensure the file is nuked, again */
+ g_unlink (filename);
+
+ g_debug ("save to empty file");
+ ret = gcm_device_save (device, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_debug ("get contents of saved file");
+ ret = g_file_get_contents (filename, &data, NULL, NULL);
+ g_assert (ret);
+
+ g_debug ("check data");
+ split = g_strsplit (data, "\n", -1);
+ g_assert_cmpstr (split[1], ==, "[sysfs_dummy_device]");
+ g_assert_cmpstr (split[4], ==, "profile=/srv/sysfs_canon_canoscan.icc");
+ g_assert_cmpstr (split[5], ==, "serial=0123456789");
+ g_assert_cmpstr (split[6], ==, "type=scanner");
+ g_assert_cmpstr (split[7], ==, "colorspace=rgb");
+ g_free (data);
+ g_strfreev (split);
+
+ /* ensure the file is nuked, in case we are running in distcheck */
+ g_unlink (filename);
+ g_main_loop_unref (_loop);
+
+ g_object_unref (device);
+}
+
+static void
+gcm_test_dmi_func (void)
+{
+ GcmDmi *dmi;
+
+ dmi = gcm_dmi_new ();
+ g_assert (dmi != NULL);
+ g_assert (gcm_dmi_get_name (dmi) != NULL);
+ g_assert (gcm_dmi_get_version (dmi) != NULL);
+ g_assert (gcm_dmi_get_vendor (dmi) != NULL);
+ g_object_unref (dmi);
+}
+
+typedef struct {
+ const gchar *monitor_name;
+ const gchar *vendor_name;
+ const gchar *serial_number;
+ const gchar *eisa_id;
+ const gchar *pnp_id;
+ guint width;
+ guint height;
+ gfloat gamma;
+} GcmEdidTestData;
+
+static void
+gcm_test_edid_test_parse_edid_file (GcmEdid *edid, const gchar *datafile, GcmEdidTestData *test_data)
+{
+ gchar *filename;
+ gchar *data;
+ gfloat mygamma;
+ gboolean ret;
+ GError *error = NULL;
+
+ g_debug ("get filename of data file");
+ filename = gcm_test_get_data_file (datafile);
+ ret = g_file_get_contents (filename, &data, NULL, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_debug ("parse an example edid block");
+ ret = gcm_edid_parse (edid, (const guint8 *) data, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_debug ("check monitor name for %s", datafile);
+ g_assert_cmpstr (gcm_edid_get_monitor_name (edid), ==, test_data->monitor_name);
+
+ g_debug ("check vendor name for %s", datafile);
+ g_assert_cmpstr (gcm_edid_get_vendor_name (edid), ==, test_data->vendor_name);
+
+ g_debug ("check serial number for %s", datafile);
+ g_assert_cmpstr (gcm_edid_get_serial_number (edid), ==, test_data->serial_number);
+
+ g_debug ("check ascii string for %s", datafile);
+ g_assert_cmpstr (gcm_edid_get_eisa_id (edid), ==, test_data->eisa_id);
+
+ g_debug ("check pnp id for %s", datafile);
+ g_assert_cmpstr (gcm_edid_get_pnp_id (edid), ==, test_data->pnp_id);
+
+ g_debug ("check height for %s", datafile);
+ g_assert_cmpint (gcm_edid_get_height (edid), ==, test_data->height);
+
+ g_debug ("check width for %s", datafile);
+ g_assert_cmpint (gcm_edid_get_width (edid), ==, test_data->width);
+
+ g_debug ("check gamma for %s", datafile);
+ mygamma = gcm_edid_get_gamma (edid);
+ g_assert_cmpfloat (mygamma, >=, test_data->gamma - 0.01);
+ g_assert_cmpfloat (mygamma, <, test_data->gamma + 0.01);
+
+ g_free (filename);
+}
+
+static void
+gcm_test_edid_func (void)
+{
+ GcmEdid *edid;
+ GcmEdidTestData test_data;
+
+ edid = gcm_edid_new ();
+ g_assert (edid != NULL);
+
+ /* LG 21" LCD panel */
+ test_data.monitor_name = "L225W";
+ test_data.vendor_name = "Goldstar Company Ltd";
+ test_data.serial_number = "34398";
+ test_data.eisa_id = NULL;
+ test_data.pnp_id = "GSM";
+ test_data.height = 30;
+ test_data.width = 47;
+ test_data.gamma = 2.2f;
+ gcm_test_edid_test_parse_edid_file (edid, "LG-L225W-External.bin", &test_data);
+
+ /* Lenovo T61 Intel Panel */
+ test_data.monitor_name = NULL;
+ test_data.vendor_name = "IBM France";
+ test_data.serial_number = NULL;
+ test_data.eisa_id = "LTN154P2-L05";
+ test_data.pnp_id = "IBM";
+ test_data.height = 21;
+ test_data.width = 33;
+ test_data.gamma = 2.2f;
+ gcm_test_edid_test_parse_edid_file (edid, "Lenovo-T61-Internal.bin", &test_data);
+
+ g_object_unref (edid);
+}
+
+static void
+gcm_test_gamma_widget_func (void)
+{
+ GtkWidget *widget;
+ GtkWidget *image;
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ gint response;
+ gchar *filename_image;
+
+ widget = gcm_gamma_widget_new ();
+ g_assert (widget != NULL);
+
+ g_object_set (widget,
+ "color-light", 0.5f,
+ "color-dark", 0.0f,
+ "color-red", 0.25f,
+ "color-green", 0.25f,
+ "color-blue", 0.25f,
+ NULL);
+
+ g_debug ("get filename of image file");
+ filename_image = gcm_test_get_data_file ("gamma-widget.png");
+ g_assert ((filename_image != NULL));
+
+ /* show in a dialog as an example */
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does GAMMA widget match\nthe picture below?");
+ image = gtk_image_new_from_file (filename_image);
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_end (GTK_BOX(vbox), widget, TRUE, TRUE, 12);
+ gtk_box_pack_end (GTK_BOX(vbox), image, TRUE, TRUE, 12);
+ gtk_widget_set_size_request (widget, 300, 300);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
+ gtk_widget_show (widget);
+ gtk_widget_show (image);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ g_debug ("plotted as expected?");
+ g_assert ((response == GTK_RESPONSE_YES));
+
+ gtk_widget_destroy (dialog);
+
+ g_free (filename_image);
+}
+
+static gchar *
+gcm_image_test_get_ibmt61_profile ()
+{
+ gchar *filename;
+ gchar *profile_base64 = NULL;
+ gchar *contents = NULL;
+ gboolean ret;
+ gsize length;
+ GError *error = NULL;
+
+ /* get test file */
+ filename = gcm_test_get_data_file ("ibm-t61.icc");
+
+ /* get contents */
+ ret = g_file_get_contents (filename, &contents, &length, &error);
+ if (!ret) {
+ g_warning ("failed to get contents: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* encode */
+ profile_base64 = g_base64_encode ((const guchar *)contents, length);
+out:
+ g_free (contents);
+ g_free (filename);
+ return profile_base64;
+}
+
+static void
+gcm_test_image_func (void)
+{
+ GcmImage *image;
+ GtkWidget *image_test;
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ gint response;
+ gchar *filename_widget;
+ gchar *filename_test;
+ gchar *profile_base64;
+
+ image = gcm_image_new ();
+ g_assert (image != NULL);
+
+ filename_widget = gcm_test_get_data_file ("image-widget.png");
+ gtk_image_set_from_file (GTK_IMAGE(image), filename_widget);
+
+ g_debug ("get filename of image file");
+ filename_test = gcm_test_get_data_file ("image-widget-good.png");
+ g_assert ((filename_test != NULL));
+
+ /* show in a dialog as an example */
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does color-corrected image match\nthe picture below?");
+ image_test = gtk_image_new_from_file (filename_test);
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_end (GTK_BOX(vbox), GTK_WIDGET(image), TRUE, TRUE, 12);
+ gtk_box_pack_end (GTK_BOX(vbox), image_test, TRUE, TRUE, 12);
+ gtk_widget_set_size_request (GTK_WIDGET(image), 300, 300);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
+ gtk_widget_show (GTK_WIDGET(image));
+ gtk_widget_show (image_test);
+
+ g_object_set (image,
+ "use-embedded-icc-profile", TRUE,
+ "output-icc-profile", NULL,
+ NULL);
+
+ g_debug ("converted as expected?");
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ g_assert ((response == GTK_RESPONSE_YES));
+ g_free (filename_test);
+
+ filename_test = gcm_test_get_data_file ("image-widget-nonembed.png");
+ gtk_image_set_from_file (GTK_IMAGE(image_test), filename_test);
+ g_object_set (image,
+ "use-embedded-icc-profile", FALSE,
+ NULL);
+
+ g_debug ("converted as expected?");
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ g_assert ((response == GTK_RESPONSE_YES));
+ g_free (filename_test);
+
+ g_debug ("get dummy display profile");
+ profile_base64 = gcm_image_test_get_ibmt61_profile ();
+ g_assert ((profile_base64 != NULL));
+
+ filename_test = gcm_test_get_data_file ("image-widget-output.png");
+ gtk_image_set_from_file (GTK_IMAGE(image_test), filename_test);
+ g_object_set (image,
+ "use-embedded-icc-profile", TRUE,
+ "output-icc-profile", profile_base64,
+ NULL);
+
+ g_debug ("converted as expected?");
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ g_assert ((response == GTK_RESPONSE_YES));
+ g_free (filename_test);
+
+ gtk_widget_destroy (dialog);
+
+ g_free (profile_base64);
+ g_free (filename_widget);
+}
+
+static GPtrArray *
+gcm_print_test_render_cb (GcmPrint *print, GtkPageSetup *page_setup, gpointer user_data, GError **error)
+{
+ GPtrArray *filenames;
+ filenames = g_ptr_array_new_with_free_func (g_free);
+ g_ptr_array_add (filenames, gcm_test_get_data_file ("image-widget-nonembed.png"));
+ g_ptr_array_add (filenames, gcm_test_get_data_file ("image-widget-good.png"));
+ return filenames;
+}
+
+static void
+gcm_test_print_func (void)
+{
+ gboolean ret;
+ GError *error = NULL;
+ GcmPrint *print;
+
+ print = gcm_print_new ();
+
+ g_debug ("try to print");
+ ret = gcm_print_with_render_callback (print, NULL, gcm_print_test_render_cb, NULL, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_object_unref (print);
+}
+
+typedef struct {
+ const gchar *copyright;
+ const gchar *manufacturer;
+ const gchar *model;
+ const gchar *datetime;
+ const gchar *description;
+ GcmProfileKind kind;
+ GcmColorspace colorspace;
+ gfloat luminance;
+} GcmProfileTestData;
+
+static void
+gcm_test_profile_test_parse_file (const gchar *datafile, GcmProfileTestData *test_data)
+{
+ gchar *filename = NULL;
+ const gchar *copyright;
+ const gchar *manufacturer;
+ const gchar *model;
+ const gchar *datetime;
+ const gchar *description;
+ guint kind;
+ guint colorspace;
+ gboolean ret;
+ GError *error = NULL;
+ GcmProfile *profile_lcms1;
+ GcmXyz *xyz;
+ gfloat luminance;
+ GFile *file;
+
+ profile_lcms1 = GCM_PROFILE(gcm_profile_lcms1_new ());
+ g_assert (profile_lcms1 != NULL);
+
+ g_debug ("get filename of data file");
+ filename = gcm_test_get_data_file (datafile);
+ g_assert ((filename != NULL));
+
+ g_debug ("load ICC file");
+ file = g_file_new_for_path (filename);
+ ret = gcm_profile_parse (profile_lcms1, file, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_object_unref (file);
+
+ g_debug ("check copyright for %s", datafile);
+ copyright = gcm_profile_get_copyright (profile_lcms1);
+ g_assert_cmpstr (copyright, ==, test_data->copyright);
+
+ g_debug ("check manufacturer for %s", datafile);
+ manufacturer = gcm_profile_get_manufacturer (profile_lcms1);
+ g_assert_cmpstr (manufacturer, ==, test_data->manufacturer);
+
+ g_debug ("check model for %s", datafile);
+ model = gcm_profile_get_model (profile_lcms1);
+ g_assert_cmpstr (model, ==, test_data->model);
+
+ g_debug ("check datetime for %s", datafile);
+ datetime = gcm_profile_get_datetime (profile_lcms1);
+ g_assert_cmpstr (datetime, ==, test_data->datetime);
+
+ g_debug ("check description for %s", datafile);
+ description = gcm_profile_get_description (profile_lcms1);
+ g_assert_cmpstr (description, ==, test_data->description);
+
+ g_debug ("check kind for %s", datafile);
+ kind = gcm_profile_get_kind (profile_lcms1);
+ g_assert_cmpint (kind, ==, test_data->kind);
+
+ g_debug ("check colorspace for %s", datafile);
+ colorspace = gcm_profile_get_colorspace (profile_lcms1);
+ g_assert_cmpint (colorspace, ==, test_data->colorspace);
+
+ g_debug ("check luminance red %s", datafile);
+ g_object_get (profile_lcms1,
+ "red", &xyz,
+ NULL);
+ luminance = gcm_xyz_get_x (xyz);
+ g_assert_cmpfloat (fabs (luminance - test_data->luminance), <, 0.001);
+
+ g_object_unref (xyz);
+ g_object_unref (profile_lcms1);
+ g_free (filename);
+}
+
+static void
+gcm_test_profile_func (void)
+{
+ GcmProfileTestData test_data;
+
+ /* bluish test */
+ test_data.copyright = "Copyright (c) 1998 Hewlett-Packard Company";
+ test_data.manufacturer = "IEC http://www.iec.ch";
+ test_data.model = "IEC 61966-2.1 Default RGB colour space - sRGB";
+ test_data.description = "Blueish Test";
+ test_data.kind = GCM_PROFILE_KIND_DISPLAY_DEVICE;
+ test_data.colorspace = GCM_COLORSPACE_RGB;
+ test_data.luminance = 0.648454;
+ test_data.datetime = "February 9 1998, 06:49:00 AM";
+ gcm_test_profile_test_parse_file ("bluish.icc", &test_data);
+
+ /* Adobe test */
+ test_data.copyright = "Copyright (c) 1998 Hewlett-Packard Company Modified using Adobe Gamma";
+ test_data.manufacturer = "IEC http://www.iec.ch";
+ test_data.model = "IEC 61966-2.1 Default RGB colour space - sRGB";
+ test_data.description = "ADOBEGAMMA-Test";
+ test_data.kind = GCM_PROFILE_KIND_DISPLAY_DEVICE;
+ test_data.colorspace = GCM_COLORSPACE_RGB;
+ test_data.luminance = 0.648446;
+ test_data.datetime = "August 16 2005, 09:49:54 PM";
+ gcm_test_profile_test_parse_file ("AdobeGammaTest.icm", &test_data);
+}
+
+static void
+gcm_test_tables_func (void)
+{
+ GcmTables *tables;
+ GError *error = NULL;
+ gchar *vendor;
+
+ tables = gcm_tables_new ();
+ g_assert (tables != NULL);
+
+ g_debug ("check pnp id 'IBM'");
+ vendor = gcm_tables_get_pnp_id (tables, "IBM", &error);
+ g_assert_no_error (error);
+ g_assert (vendor != NULL);
+ g_assert_cmpstr (vendor, ==, "IBM France");
+ g_free (vendor);
+
+ g_debug ("check pnp id 'MIL'");
+ vendor = gcm_tables_get_pnp_id (tables, "MIL", &error);
+ g_assert_no_error (error);
+ g_assert (vendor != NULL);
+ g_assert_cmpstr (vendor, ==, "Marconi Instruments Ltd");
+ g_free (vendor);
+
+ g_debug ("check pnp id 'XXX'");
+ vendor = gcm_tables_get_pnp_id (tables, "XXX", &error);
+ g_assert_error (error, 1, 0);
+ g_assert_cmpstr (vendor, ==, NULL);
+ g_free (vendor);
+
+ g_object_unref (tables);
+}
+
+static void
+gcm_test_trc_widget_func (void)
+{
+ GtkWidget *widget;
+ GtkWidget *image;
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ GcmClut *clut;
+ GcmProfile *profile;
+ gint response;
+ gchar *filename_profile;
+ gchar *filename_image;
+ GFile *file;
+
+ widget = gcm_trc_widget_new ();
+ g_assert (widget != NULL);
+
+ g_debug ("get filename of image file");
+ filename_image = gcm_test_get_data_file ("trc-widget.png");
+ g_assert ((filename_image != NULL));
+
+ g_debug ("get filename of data file");
+ filename_profile = gcm_test_get_data_file ("AdobeGammaTest.icm");
+ g_assert ((filename_profile != NULL));
+
+ profile = gcm_profile_default_new ();
+ file = g_file_new_for_path (filename_profile);
+ gcm_profile_parse (profile, file, NULL);
+ clut = gcm_profile_generate_vcgt (profile, 256);
+ g_object_set (widget,
+ "clut", clut,
+ NULL);
+ g_object_unref (file);
+
+ /* show in a dialog as an example */
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does TRC widget match\nthe picture below?");
+ image = gtk_image_new_from_file (filename_image);
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_end (GTK_BOX(vbox), widget, TRUE, TRUE, 12);
+ gtk_box_pack_end (GTK_BOX(vbox), image, TRUE, TRUE, 12);
+ gtk_widget_set_size_request (widget, 300, 300);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
+ gtk_widget_show (widget);
+ gtk_widget_show (image);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ g_debug ("plotted as expected?");
+ g_assert ((response == GTK_RESPONSE_YES));
+
+ gtk_widget_destroy (dialog);
+
+ g_object_unref (clut);
+ g_object_unref (profile);
+ g_free (filename_profile);
+ g_free (filename_image);
+}
+
+static void
+gcm_test_utils_func (void)
+{
+ gboolean ret;
+ gchar *text;
+ gchar *filename;
+ GFile *file;
+ GFile *dest;
+
+ g_debug ("Linkify text");
+ text = gcm_utils_linkify ("http://www.dave.org is text http://www.hughsie.com that needs to be linked to http://www.bbc.co.uk really");
+ g_assert_cmpstr (text, ==, "<a href=\"http://www.dave.org\">http://www.dave.org</a> is text "
+ "<a href=\"http://www.hughsie.com\">http://www.hughsie.com</a> that needs to be linked to "
+ "<a href=\"http://www.bbc.co.uk\">http://www.bbc.co.uk</a> really");
+ g_free (text);
+
+ g_debug ("get filename of data file");
+ file = g_file_new_for_path ("dave.icc");
+ dest = gcm_utils_get_profile_destination (file);
+ filename = g_file_get_path (dest);
+ g_assert (g_str_has_suffix (filename, "/.color/icc/dave.icc"));
+ g_free (filename);
+ g_object_unref (file);
+ g_object_unref (dest);
+
+ g_debug ("check is icc profile");
+ filename = gcm_test_get_data_file ("bluish.icc");
+ file = g_file_new_for_path (filename);
+ ret = gcm_utils_is_icc_profile (file);
+ g_assert (ret);
+ g_object_unref (file);
+ g_free (filename);
+
+ g_debug ("detect LVDS panels");
+ ret = gcm_utils_output_is_lcd_internal ("LVDS1");
+ g_assert (ret);
+
+ g_debug ("detect external panels");
+ ret = gcm_utils_output_is_lcd_internal ("DVI1");
+ g_assert (!ret);
+
+ g_debug ("detect LCD panels");
+ ret = gcm_utils_output_is_lcd ("LVDS1");
+ g_assert (ret);
+
+ g_debug ("detect LCD panels (2)");
+ ret = gcm_utils_output_is_lcd ("DVI1");
+ g_assert (ret);
+
+ g_debug ("Make sensible id");
+ filename = g_strdup ("Hello\n\rWorld!");
+ gcm_utils_alphanum_lcase (filename);
+ g_assert_cmpstr (filename, ==, "hello__world_");
+ g_free (filename);
+
+ g_debug ("Make sensible filename");
+ filename = g_strdup ("Hel lo\n\rWo-(r)ld!");
+ gcm_utils_ensure_sensible_filename (filename);
+ g_assert_cmpstr (filename, ==, "Hel lo__Wo-(r)ld_");
+ g_free (filename);
+
+ g_debug ("check strip printable");
+ text = g_strdup ("1\r34 67_90");
+ gcm_utils_ensure_printable (text);
+ g_assert_cmpstr (text, ==, "134 67 90");
+ g_free (text);
+
+ g_debug ("get default config location (when in make check)");
+ g_setenv ("GCM_TEST", "1", TRUE);
+ filename = gcm_utils_get_default_config_location ();
+ g_assert_cmpstr (filename, ==, "/tmp/device-profiles.conf");
+ g_free (filename);
+
+ g_debug ("convert valid device kind to profile kind");
+ g_assert (gcm_utils_device_kind_to_profile_kind (GCM_DEVICE_KIND_SCANNER) == GCM_PROFILE_KIND_INPUT_DEVICE);
+
+ g_debug ("convert invalid device kind to profile kind");
+ g_assert (gcm_utils_device_kind_to_profile_kind (GCM_DEVICE_KIND_UNKNOWN) == GCM_PROFILE_KIND_UNKNOWN);
+}
+
+static void
+gcm_test_xyz_func (void)
+{
+ GcmXyz *xyz;
+ gdouble value;
+
+ xyz = gcm_xyz_new ();
+ g_assert (xyz != NULL);
+
+ g_debug ("get x value (when nothing set)");
+ value = gcm_xyz_get_x (xyz);
+ g_assert_cmpfloat (fabs (value - 0.0f), <, 0.001f);
+
+ /* set dummy values */
+ g_object_set (xyz,
+ "cie-x", 0.125,
+ "cie-y", 0.25,
+ "cie-z", 0.5,
+ NULL);
+
+ g_debug ("get x value");
+ value = gcm_xyz_get_x (xyz);
+ g_assert_cmpfloat (fabs (value - 0.142857143f), <, 0.001f);
+
+ g_debug ("get y value");
+ value = gcm_xyz_get_y (xyz);
+ g_assert_cmpfloat (fabs (value - 0.285714286f), <, 0.001f);
+
+ g_debug ("get z value");
+ value = gcm_xyz_get_z (xyz);
+ g_assert_cmpfloat (fabs (value - 0.571428571f), <, 0.001f);
+
+ g_object_unref (xyz);
+}
int
main (int argc, char **argv)
{
- EggTest *test;
-
if (! g_thread_supported ())
g_thread_init (NULL);
gtk_init (&argc, &argv);
- test = egg_test_init ();
- egg_debug_init (&argc, &argv);
-
- /* components */
- gcm_calibrate_test (test);
- gcm_edid_test (test);
- gcm_tables_test (test);
- gcm_utils_test (test);
- gcm_device_test (test);
- gcm_profile_test (test);
- gcm_brightness_test (test);
- gcm_clut_test (test);
- gcm_dmi_test (test);
- gcm_xyz_test (test);
- gcm_trc_widget_test (test);
- gcm_cie_widget_test (test);
- gcm_gamma_widget_test (test);
- gcm_image_test (test);
- gcm_print_test (test);
-// gcm_calibrate_manual_test (test);
-
- return (egg_test_finish (test));
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/color/dmi", gcm_test_dmi_func);
+ g_test_add_func ("/color/calibrate", gcm_test_calibrate_func);
+ g_test_add_func ("/color/edid", gcm_test_edid_func);
+ g_test_add_func ("/color/tables", gcm_test_tables_func);
+ g_test_add_func ("/color/utils", gcm_test_utils_func);
+ g_test_add_func ("/color/device", gcm_test_device_func);
+ g_test_add_func ("/color/profile", gcm_test_profile_func);
+ g_test_add_func ("/color/clut", gcm_test_clut_func);
+ g_test_add_func ("/color/xyz", gcm_test_xyz_func);
+ g_test_add_func ("/color/calibrate_dialog", gcm_test_calibrate_dialog_func);
+ if (g_test_thorough ()) {
+ g_test_add_func ("/color/brightness", gcm_test_brightness_func);
+ g_test_add_func ("/color/trc", gcm_test_trc_widget_func);
+ g_test_add_func ("/color/cie", gcm_test_cie_widget_func);
+ g_test_add_func ("/color/gamma_widget", gcm_test_gamma_widget_func);
+ g_test_add_func ("/color/image", gcm_test_image_func);
+ }
+ if (g_test_slow ()) {
+ g_test_add_func ("/color/print", gcm_test_print_func);
+ g_test_add_func ("/color/calibrate_manual", gcm_test_calibrate_manual_func);
+ }
+
+ return g_test_run ();
}
diff --git a/src/gcm-tables.c b/src/gcm-tables.c
index 9e672cb..82b5f56 100644
--- a/src/gcm-tables.c
+++ b/src/gcm-tables.c
@@ -265,66 +265,3 @@ gcm_tables_new (void)
return GCM_TABLES (gcm_tables_object);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_tables_test (EggTest *test)
-{
- GcmTables *tables;
- gboolean ret;
- GError *error = NULL;
- gchar *vendor;
-
- if (!egg_test_start (test, "GcmTables"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a tables object");
- tables = gcm_tables_new ();
- egg_test_assert (test, tables != NULL);
-
- /************************************************************/
- egg_test_title (test, "check pnp id 'IBM'");
- vendor = gcm_tables_get_pnp_id (tables, "IBM", &error);
- if (vendor == NULL)
- egg_test_failed (test, "failed to get value: %s", error->message);
- if (g_strcmp0 (vendor, "IBM France") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", vendor);
- g_free (vendor);
-
- /************************************************************/
- egg_test_title (test, "check pnp id 'MIL'");
- vendor = gcm_tables_get_pnp_id (tables, "MIL", &error);
- if (vendor == NULL)
- egg_test_failed (test, "failed to get value: %s", error->message);
- if (g_strcmp0 (vendor, "Marconi Instruments Ltd") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", vendor);
- g_free (vendor);
-
- /************************************************************/
- egg_test_title (test, "check pnp id 'XXX'");
- vendor = gcm_tables_get_pnp_id (tables, "XXX", &error);
- if (vendor == NULL) {
- if (error == NULL)
- egg_test_failed (test, "failed to get value and no error set");
- g_clear_error (&error);
- egg_test_success (test, NULL);
- } else {
- egg_test_failed (test, "vendor should not exist");
- }
- g_free (vendor);
-
- g_object_unref (tables);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-trc-widget.c b/src/gcm-trc-widget.c
index 7685cfb..9d19faf 100644
--- a/src/gcm-trc-widget.c
+++ b/src/gcm-trc-widget.c
@@ -392,81 +392,3 @@ gcm_trc_widget_new (void)
return g_object_new (GCM_TYPE_TRC_WIDGET, NULL);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_trc_widget_test (EggTest *test)
-{
- GtkWidget *widget;
- GtkWidget *image;
- GtkWidget *dialog;
- GtkWidget *vbox;
- gboolean ret;
- GError *error = NULL;
- GcmClut *clut;
- GcmProfile *profile;
- gint response;
- gchar *filename_profile;
- gchar *filename_image;
- GcmClutData *data;
- GFile *file;
-
- if (!egg_test_start (test, "GcmTrcWidget"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a TRC widget object");
- widget = gcm_trc_widget_new ();
- egg_test_assert (test, widget != NULL);
-
- /************************************************************/
- egg_test_title (test, "get filename of image file");
- filename_image = egg_test_get_data_file ("trc-widget.png");
- egg_test_assert (test, (filename_image != NULL));
-
- /************************************************************/
- egg_test_title (test, "get filename of data file");
- filename_profile = egg_test_get_data_file ("AdobeGammaTest.icm");
- egg_test_assert (test, (filename_profile != NULL));
-
- profile = gcm_profile_default_new ();
- file = g_file_new_for_path (filename_profile);
- gcm_profile_parse (profile, file, NULL);
- clut = gcm_profile_generate_vcgt (profile, 256);
- g_object_set (widget,
- "clut", clut,
- NULL);
- g_object_unref (file);
-
- /* show in a dialog as an example */
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Does TRC widget match\nthe picture below?");
- image = gtk_image_new_from_file (filename_image);
- vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_pack_end (GTK_BOX(vbox), widget, TRUE, TRUE, 12);
- gtk_box_pack_end (GTK_BOX(vbox), image, TRUE, TRUE, 12);
- gtk_widget_set_size_request (widget, 300, 300);
- gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
- gtk_widget_show (widget);
- gtk_widget_show (image);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- /************************************************************/
- egg_test_title (test, "plotted as expected?");
- egg_test_assert (test, (response == GTK_RESPONSE_YES));
-
- gtk_widget_destroy (dialog);
-
- g_object_unref (clut);
- g_object_unref (profile);
- g_free (filename_profile);
- g_free (filename_image);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index d7ac2f6..2da35ed 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -515,13 +515,14 @@ gcm_utils_get_default_config_location (void)
{
gchar *filename;
-#ifdef EGG_TEST
- filename = g_strdup ("/tmp/device-profiles.conf");
-#else
+ if (g_getenv ("GCM_TEST") != NULL) {
+ filename = g_strdup ("/tmp/device-profiles.conf");
+ goto out;
+ }
+
/* create default path */
filename = g_build_filename (g_get_user_config_dir (), "gnome-color-manager", "device-profiles.conf", NULL);
-#endif
-
+out:
return filename;
}
@@ -589,131 +590,3 @@ gcm_intent_to_localized_text (GcmIntent intent)
return "unknown";
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_utils_test (EggTest *test)
-{
- gboolean ret;
- GError *error = NULL;
- GPtrArray *array;
- gchar *text;
- gchar *filename;
- GcmProfileKind profile_kind;
- GcmDeviceKind device_kind;
- GFile *file;
- GFile *dest;
-
- if (!egg_test_start (test, "GcmUtils"))
- return;
-
- /************************************************************/
- egg_test_title (test, "Linkify text");
- text = gcm_utils_linkify ("http://www.dave.org is text http://www.hughsie.com that needs to be linked to http://www.bbc.co.uk really");
- if (g_strcmp0 (text, "<a href=\"http://www.dave.org\">http://www.dave.org</a> is text "
- "<a href=\"http://www.hughsie.com\">http://www.hughsie.com</a> that needs to be linked to "
- "<a href=\"http://www.bbc.co.uk\">http://www.bbc.co.uk</a> really") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to linkify text: %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "get filename of data file");
- file = g_file_new_for_path ("dave.icc");
- dest = gcm_utils_get_profile_destination (file);
- filename = g_file_get_path (dest);
- if (g_str_has_suffix (filename, "/.color/icc/dave.icc"))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get filename: %s", filename);
- g_free (filename);
- g_object_unref (file);
- g_object_unref (dest);
-
- /************************************************************/
- egg_test_title (test, "check is icc profile");
- filename = egg_test_get_data_file ("bluish.icc");
- file = g_file_new_for_path (filename);
- ret = gcm_utils_is_icc_profile (file);
- egg_test_assert (test, ret);
- g_object_unref (file);
- g_free (filename);
-
- /************************************************************/
- egg_test_title (test, "detect LVDS panels");
- ret = gcm_utils_output_is_lcd_internal ("LVDS1");
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "detect external panels");
- ret = gcm_utils_output_is_lcd_internal ("DVI1");
- egg_test_assert (test, !ret);
-
- /************************************************************/
- egg_test_title (test, "detect LCD panels");
- ret = gcm_utils_output_is_lcd ("LVDS1");
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "detect LCD panels (2)");
- ret = gcm_utils_output_is_lcd ("DVI1");
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "Make sensible id");
- filename = g_strdup ("Hello\n\rWorld!");
- gcm_utils_alphanum_lcase (filename);
- if (g_strcmp0 (filename, "hello__world_") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get filename: %s", filename);
- g_free (filename);
-
- /************************************************************/
- egg_test_title (test, "Make sensible filename");
- filename = g_strdup ("Hel lo\n\rWo-(r)ld!");
- gcm_utils_ensure_sensible_filename (filename);
- if (g_strcmp0 (filename, "Hel lo__Wo-(r)ld_") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get filename: %s", filename);
- g_free (filename);
-
- /************************************************************/
- egg_test_title (test, "check strip printable");
- text = g_strdup ("1\r34 67_90");
- gcm_utils_ensure_printable (text);
- if (g_strcmp0 (text, "134 67 90") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "invalid value: %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "get default config location (when in make check)");
- filename = gcm_utils_get_default_config_location ();
- if (g_strcmp0 (filename, "/tmp/device-profiles.conf") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get correct config location: %s", filename);
- g_free (filename);
-
- /************************************************************/
- egg_test_title (test, "convert valid device kind to profile kind");
- profile_kind = gcm_utils_device_kind_to_profile_kind (GCM_DEVICE_KIND_SCANNER);
- egg_test_assert (test, (profile_kind == GCM_PROFILE_KIND_INPUT_DEVICE));
-
- /************************************************************/
- egg_test_title (test, "convert invalid device kind to profile kind");
- profile_kind = gcm_utils_device_kind_to_profile_kind (GCM_DEVICE_KIND_UNKNOWN);
- egg_test_assert (test, (profile_kind == GCM_PROFILE_KIND_UNKNOWN));
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gcm-xyz.c b/src/gcm-xyz.c
index a40e513..e6f6a35 100644
--- a/src/gcm-xyz.c
+++ b/src/gcm-xyz.c
@@ -35,8 +35,6 @@
#include "egg-debug.h"
-static void gcm_xyz_finalize (GObject *object);
-
#define GCM_XYZ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_XYZ, GcmXyzPrivate))
/**
@@ -180,7 +178,6 @@ gcm_xyz_class_init (GcmXyzClass *klass)
{
GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gcm_xyz_finalize;
object_class->get_property = gcm_xyz_get_property;
object_class->set_property = gcm_xyz_set_property;
@@ -221,18 +218,6 @@ gcm_xyz_init (GcmXyz *xyz)
}
/**
- * gcm_xyz_finalize:
- **/
-static void
-gcm_xyz_finalize (GObject *object)
-{
-// GcmXyz *xyz = GCM_XYZ (object);
-// GcmXyzPrivate *priv = xyz->priv;
-
- G_OBJECT_CLASS (gcm_xyz_parent_class)->finalize (object);
-}
-
-/**
* gcm_xyz_new:
*
* Return value: a new GcmXyz object.
@@ -245,68 +230,3 @@ gcm_xyz_new (void)
return GCM_XYZ (xyz);
}
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gcm_xyz_test (EggTest *test)
-{
- GcmXyz *xyz;
- gdouble value;
-
- if (!egg_test_start (test, "GcmXyz"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get a xyz object");
- xyz = gcm_xyz_new ();
- egg_test_assert (test, xyz != NULL);
-
- /************************************************************/
- egg_test_title (test, "get x value (when nothing set)");
- value = gcm_xyz_get_x (xyz);
- if (fabs (value - 0.0f) < 0.001f)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get value, got: %f", value);
-
- /* set dummy values */
- g_object_set (xyz,
- "cie-x", 0.125,
- "cie-y", 0.25,
- "cie-z", 0.5,
- NULL);
-
- /************************************************************/
- egg_test_title (test, "get x value");
- value = gcm_xyz_get_x (xyz);
- if (fabs (value - 0.142857143f) < 0.001f)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get value, got: %f", value);
-
- /************************************************************/
- egg_test_title (test, "get y value");
- value = gcm_xyz_get_y (xyz);
- if (fabs (value - 0.285714286f) < 0.001f)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get value, got: %f", value);
-
- /************************************************************/
- egg_test_title (test, "get z value");
- value = gcm_xyz_get_z (xyz);
- if (fabs (value - 0.571428571f) < 0.001f)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed to get value, got: %f", value);
-
- g_object_unref (xyz);
-
- egg_test_end (test);
-}
-#endif
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]