[gnome-packagekit] Port from a homegrown EggTest to GTest
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] Port from a homegrown EggTest to GTest
- Date: Thu, 11 Apr 2013 13:53:06 +0000 (UTC)
commit 0eb8d01f5b2c8ada706702f61f189aaccf1849c5
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 11 14:33:31 2013 +0100
Port from a homegrown EggTest to GTest
src/.gitignore | 4 +-
src/Makefile.am | 4 +-
src/egg-console-kit.c | 1 -
src/egg-markdown.c | 387 -----------------------
src/egg-string.c | 219 -------------
src/egg-test.c | 359 ---------------------
src/egg-test.h | 48 ---
src/gpk-animated-icon.c | 3 +-
src/gpk-application.c | 1 -
src/gpk-common.c | 159 ----------
src/gpk-common.h | 1 -
src/gpk-dbus-service.c | 1 -
src/gpk-dbus-task.c | 136 +--------
src/gpk-dbus-task.h | 9 +
src/gpk-dbus.c | 29 --
src/gpk-desktop.c | 1 -
src/gpk-enum.c | 199 ------------
src/gpk-enum.h | 1 -
src/gpk-error.c | 27 --
src/gpk-gnome.c | 1 -
src/gpk-language.c | 60 ----
src/gpk-modal-dialog.c | 136 --------
src/gpk-self-test.c | 792 +++++++++++++++++++++++++++++++++++++++++++++--
src/gpk-task.c | 93 ------
src/gpk-task.h | 1 -
25 files changed, 784 insertions(+), 1888 deletions(-)
---
diff --git a/src/.gitignore b/src/.gitignore
index 09232bf..b627c4b 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -29,5 +29,7 @@ gpk-service-pack
gpk-log
gpk-dbus-service
gpk-distro-upgrade
+gpk-self-test.log
+gpk-self-test.trs
+test-suite.log
.svn
-
diff --git a/src/Makefile.am b/src/Makefile.am
index ae06294..17214ea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -270,8 +270,6 @@ noinst_PROGRAMS = \
gpk_self_test_SOURCES = \
gpk-self-test.c \
- egg-test.h \
- egg-test.c \
egg-string.c \
egg-string.h \
egg-markdown.c \
@@ -319,7 +317,7 @@ gpk_self_test_LDADD = \
$(SELFTEST_LIBS) \
$(NULL)
-gpk_self_test_CFLAGS = -DEGG_TEST $(AM_CFLAGS)
+gpk_self_test_CFLAGS = $(AM_CFLAGS)
TESTS = gpk-self-test
endif
diff --git a/src/egg-console-kit.c b/src/egg-console-kit.c
index a278ba7..f7894f2 100644
--- a/src/egg-console-kit.c
+++ b/src/egg-console-kit.c
@@ -349,4 +349,3 @@ egg_console_kit_new (void)
console = g_object_new (EGG_TYPE_CONSOLE_KIT, NULL);
return EGG_CONSOLE_KIT (console);
}
-
diff --git a/src/egg-markdown.c b/src/egg-markdown.c
index 52a7961..c0475ff 100644
--- a/src/egg-markdown.c
+++ b/src/egg-markdown.c
@@ -949,390 +949,3 @@ egg_markdown_new (void)
self = g_object_new (EGG_TYPE_MARKDOWN, NULL);
return EGG_MARKDOWN (self);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-egg_markdown_test (EggTest *test)
-{
- EggMarkdown *self;
- gchar *text;
- gboolean ret;
- const gchar *markdown;
- const gchar *markdown_expected;
-
- if (!egg_test_start (test, "EggMarkdown"))
- return;
-
- /************************************************************
- **************** line_is_rule **************
- ************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("* * *");
- egg_test_title_assert (test, "is rule (1)", ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("***");
- egg_test_title_assert (test, "is rule (2)", ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("*****");
- egg_test_title_assert (test, "is rule (3)", ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("- - -");
- egg_test_title_assert (test, "is rule (4)", ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("---------------------------------------");
- egg_test_title_assert (test, "is rule (5)", ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("");
- egg_test_title_assert (test, "is rule (blank)", !ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("richard hughes");
- egg_test_title_assert (test, "is rule (text)", !ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_rule ("- richard-hughes");
- egg_test_title_assert (test, "is rule (bullet)", !ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_blank ("");
- egg_test_title_assert (test, "is blank (blank)", ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_blank (" \t ");
- egg_test_title_assert (test, "is blank (mix)", ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_blank ("richard hughes");
- egg_test_title_assert (test, "is blank (name)", !ret);
-
- /************************************************************/
- ret = egg_markdown_to_text_line_is_blank ("ccccccccc");
- egg_test_title_assert (test, "is blank (full)", !ret);
-
- /************************************************************
- **************** replace **************
- ************************************************************/
- text = egg_markdown_replace ("summary -- really -- sure!", " -- ", " – ");
- egg_test_title (test, "replace (multiple)");
- if (g_strcmp0 (text, "summary – really – sure!") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************
- **************** formatter **************
- ************************************************************/
- text = egg_markdown_to_text_line_formatter ("**is important** text", "**", "<b>", "</b>");
- egg_test_title (test, "formatter (left)");
- if (g_strcmp0 (text, "<b>is important</b> text") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_to_text_line_formatter ("this is **important**", "**", "<b>", "</b>");
- egg_test_title (test, "formatter (right)");
- if (g_strcmp0 (text, "this is <b>important</b>") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_to_text_line_formatter ("**important**", "**", "<b>", "</b>");
- egg_test_title (test, "formatter (only)");
- if (g_strcmp0 (text, "<b>important</b>") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_to_text_line_formatter ("***important***", "**", "<b>", "</b>");
- egg_test_title (test, "formatter (only)");
- if (g_strcmp0 (text, "<b>*important</b>*") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_to_text_line_formatter ("I guess * this is * not bold", "*", "<i>", "</i>");
- egg_test_title (test, "formatter (with spaces)");
- if (g_strcmp0 (text, "I guess * this is * not bold") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_to_text_line_formatter ("this **is important** text in **several** places", "**",
"<b>", "</b>");
- egg_test_title (test, "formatter (middle, multiple)");
- if (g_strcmp0 (text, "this <b>is important</b> text in <b>several</b> places") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_word_auto_format_code ("this is http://www.hughsie.com/with_spaces_in_url inline
link");
- egg_test_title (test, "auto formatter (url)");
- if (g_strcmp0 (text, "this is `http://www.hughsie.com/with_spaces_in_url` inline link") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_to_text_line_formatter ("this was \"triffic\" it was", "\"", "“", "”");
- egg_test_title (test, "formatter (quotes)");
- if (g_strcmp0 (text, "this was “triffic” it was") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- text = egg_markdown_to_text_line_formatter ("This isn't a present", "'", "‘", "’");
- egg_test_title (test, "formatter (one quote)");
- if (g_strcmp0 (text, "This isn't a present") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************
- **************** markdown **************
- ************************************************************/
- egg_test_title (test, "get EggMarkdown object");
- self = egg_markdown_new ();
- egg_test_assert (test, self != NULL);
-
- /************************************************************/
- ret = egg_markdown_set_output (self, EGG_MARKDOWN_OUTPUT_PANGO);
- egg_test_title_assert (test, "set pango output", ret);
-
- /************************************************************/
- markdown = "OEMs\n"
- "====\n"
- " - Bullett\n";
- markdown_expected =
- "<big>OEMs</big>\n"
- "• Bullett";
- egg_test_title (test, "markdown (type2 header)");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- markdown = "this is http://www.hughsie.com/with_spaces_in_url inline link\n";
- markdown_expected = "this is <tt>http://www.hughsie.com/with_spaces_in_url</tt> inline link";
- egg_test_title (test, "markdown (autocode)");
- egg_markdown_set_autocode (self, TRUE);
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- markdown = "*** This software is currently in alpha state ***\n";
- markdown_expected = "<b><i> This software is currently in alpha state </b></i>";
- egg_test_title (test, "markdown some invalid header");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- markdown = " - This is a *very*\n"
- " short paragraph\n"
- " that is not usual.\n"
- " - Another";
- markdown_expected =
- "• This is a <i>very</i> short paragraph that is not usual.\n"
- "• Another";
- egg_test_title (test, "markdown (complex1)");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- markdown = "* This is a *very*\n"
- " short paragraph\n"
- " that is not usual.\n"
- "* This is the second\n"
- " bullett point.\n"
- "* And the third.\n"
- " \n"
- "* * *\n"
- " \n"
- "Paragraph one\n"
- "isn't __very__ long at all.\n"
- "\n"
- "Paragraph two\n"
- "isn't much better.";
- markdown_expected =
- "• This is a <i>very</i> short paragraph that is not usual.\n"
- "• This is the second bullett point.\n"
- "• And the third.\n"
- "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
- "Paragraph one isn't <b>very</b> long at all.\n"
- "Paragraph two isn't much better.";
- egg_test_title (test, "markdown (complex1)");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- markdown = "This is a spec file description or\n"
- "an **update** description in bohdi.\n"
- "\n"
- "* * *\n"
- "# Big title #\n"
- "\n"
- "The *following* things 'were' fixed:\n"
- "- Fix `dave`\n"
- "* Fubar update because of \"security\"\n";
- markdown_expected =
- "This is a spec file description or an <b>update</b> description in bohdi.\n"
- "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
- "<big>Big title</big>\n"
- "The <i>following</i> things 'were' fixed:\n"
- "• Fix <tt>dave</tt>\n"
- "• Fubar update because of \"security\"";
- egg_test_title (test, "markdown (complex2)");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- markdown = "* list seporated with spaces -\n"
- " first item\n"
- "\n"
- "* second item\n"
- "\n"
- "* third item\n";
- markdown_expected =
- "• list seporated with spaces - first item\n"
- "• second item\n"
- "• third item";
- egg_test_title (test, "markdown (list with spaces)");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- ret = egg_markdown_set_max_lines (self, 1);
- egg_test_title_assert (test, "set max_lines", ret);
-
- /************************************************************/
- markdown = "* list seporated with spaces -\n"
- " first item\n"
- "* second item\n";
- markdown_expected =
- "• list seporated with spaces - first item";
- egg_test_title (test, "markdown (one line limit)");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- ret = egg_markdown_set_max_lines (self, 1);
- egg_test_title_assert (test, "set max_lines", ret);
-
- /************************************************************/
- markdown = "* list & spaces";
- markdown_expected =
- "• list & spaces";
- egg_test_title (test, "markdown (escaping)");
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "markdown (free text)");
- text = egg_markdown_parse (self, "This isn't a present");
- if (g_strcmp0 (text, "This isn't a present") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s'", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "markdown (autotext underscore)");
- text = egg_markdown_parse (self, "This isn't CONFIG_UEVENT_HELPER_PATH present");
- if (g_strcmp0 (text, "This isn't <tt>CONFIG_UEVENT_HELPER_PATH</tt> present") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s'", text);
- g_free (text);
-
- /************************************************************/
- markdown = "*Thu Mar 12 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.79-1\n"
- "- Update to upstream \n"
- " * Netlink socket handoff patch from Adam Jackson.\n"
- " * AVC caching of compute_create results by Eric Paris.\n"
- "\n"
- "*Tue Mar 10 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.78-5\n"
- "- Add patch from ajax to accellerate X SELinux \n"
- "- Update eparis patch\n";
- markdown_expected =
- "<i>Thu Mar 12 12:00:00 2009</i> Dan Walsh <tt><dwalsh redhat com></tt> - 2.0.79-1\n"
- "• Update to upstream\n"
- "• Netlink socket handoff patch from Adam Jackson.\n"
- "• AVC caching of compute_create results by Eric Paris.\n"
- "<i>Tue Mar 10 12:00:00 2009</i> Dan Walsh <tt><dwalsh redhat com></tt> - 2.0.78-5\n"
- "• Add patch from ajax to accellerate X SELinux\n"
- "• Update eparis patch";
- egg_test_title (test, "markdown (end of bullett)");
- egg_markdown_set_escape (self, TRUE);
- ret = egg_markdown_set_max_lines (self, 1024);
- text = egg_markdown_parse (self, markdown);
- if (g_strcmp0 (text, markdown_expected) == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got '%s', expected '%s'", text, markdown_expected);
- g_free (text);
-
- g_object_unref (self);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/egg-string.c b/src/egg-string.c
index 5af98cf..2f7db0b 100644
--- a/src/egg-string.c
+++ b/src/egg-string.c
@@ -229,222 +229,3 @@ egg_strreplace (const gchar *text, const gchar *find, const gchar *replace)
g_strfreev (array);
return retval;
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-egg_string_test (EggTest *test)
-{
- gboolean ret;
- gchar *text_safe;
- guint length;
- gint value;
- guint uvalue;
- gchar **id1;
- gchar **id2;
-
- if (!egg_test_start (test, "EggString"))
- return;
-
- /************************************************************
- **************** String array equal ******************
- ************************************************************/
- egg_test_title (test, "egg_strvequal same argument");
- id1 = g_strsplit ("the quick brown fox", " ", 0);
- if (egg_strvequal (id1, id1))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect ret when both same");
- g_strfreev (id1);
-
- /************************************************************/
- egg_test_title (test, "egg_strvequal same");
- id1 = g_strsplit ("the quick brown fox", " ", 0);
- id2 = g_strsplit ("the quick brown fox", " ", 0);
- if (egg_strvequal (id1, id2))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect ret when both same");
- g_strfreev (id1);
- g_strfreev (id2);
-
- /************************************************************/
- egg_test_title (test, "egg_strvequal different lengths");
- id1 = g_strsplit ("the quick brown", " ", 0);
- id2 = g_strsplit ("the quick brown fox", " ", 0);
- if (!egg_strvequal (id1, id2))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "incorrect ret when both same");
- g_strfreev (id1);
- g_strfreev (id2);
-
- /************************************************************/
- egg_test_title (test, "egg_strvequal different");
- id1 = g_strsplit ("the quick brown fox", " ", 0);
- id2 = g_strsplit ("richard hughes maintainer dude", " ", 0);
- if (!egg_strvequal (id1, id2))
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "same when different");
- g_strfreev (id1);
- g_strfreev (id2);
-
- /************************************************************
- **************** Zero ******************
- ************************************************************/
- egg_test_title (test, "test strzero (null)");
- ret = egg_strzero (NULL);
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed null");
-
- /************************************************************/
- egg_test_title (test, "test strzero (null first char)");
- ret = egg_strzero ("");
- if (ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed null");
-
- /************************************************************/
- egg_test_title (test, "test strzero (long string)");
- ret = egg_strzero ("Richard");
- if (!ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "zero length word!");
-
- /************************************************************/
- egg_test_title (test, "id strcmp pass");
- ret = (g_strcmp0 ("moo;0.0.1;i386;fedora", "moo;0.0.1;i386;fedora") == 0);
- egg_test_assert (test, ret);
-
- /************************************************************/
- egg_test_title (test, "id strcmp fail");
- ret = (g_strcmp0 ("moo;0.0.1;i386;fedora", "moo;0.0.2;i386;fedora") == 0);
- egg_test_assert (test, !ret);
-
- /************************************************************
- **************** strlen ******************
- ************************************************************/
- egg_test_title (test, "strlen bigger");
- length = egg_strlen ("123456789", 20);
- if (length == 9)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed the strlen %i", length);
-
- /************************************************************/
- egg_test_title (test, "strlen smaller");
- length = egg_strlen ("123456789", 5);
- if (length == 5)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed the strlen %i", length);
-
- /************************************************************/
- egg_test_title (test, "strlen correct");
- length = egg_strlen ("123456789", 9);
- if (length == 9)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed the strlen %i", length);
-
- /************************************************************
- **************** Replace ******************
- ************************************************************/
- egg_test_title (test, "replace start");
- text_safe = egg_strreplace ("richard\nhughes", "r", "e");
- if (g_strcmp0 (text_safe, "eichaed\nhughes") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed the replace '%s'", text_safe);
- g_free (text_safe);
-
- /************************************************************/
- egg_test_title (test, "replace none");
- text_safe = egg_strreplace ("richard\nhughes", "dave", "e");
- if (g_strcmp0 (text_safe, "richard\nhughes") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed the replace '%s'", text_safe);
- g_free (text_safe);
-
- /************************************************************/
- egg_test_title (test, "replace end");
- text_safe = egg_strreplace ("richard\nhughes", "s", "e");
- if (g_strcmp0 (text_safe, "richard\nhughee") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed the replace '%s'", text_safe);
- g_free (text_safe);
-
- /************************************************************/
- egg_test_title (test, "replace unicode");
- text_safe = egg_strreplace ("richard\n- hughes", "\n- ", "\n• ");
- if (g_strcmp0 (text_safe, "richard\n• hughes") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed the replace '%s'", text_safe);
- g_free (text_safe);
-
- /************************************************************
- ************** Convert numbers ****************
- ************************************************************/
- egg_test_title (test, "convert valid number");
- ret = egg_strtoint ("234", &value);
- if (ret && value == 234)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "value is %i", value);
-
- /************************************************************/
- egg_test_title (test, "convert negative valid number");
- ret = egg_strtoint ("-234", &value);
- if (ret && value == -234)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "value is %i", value);
-
- /************************************************************/
- egg_test_title (test, "don't convert invalid number");
- ret = egg_strtoint ("dave", &value);
- if (!ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "value is %i", value);
-
- /************************************************************/
- egg_test_title (test, "convert NULL to a number");
- ret = egg_strtouint (NULL, &uvalue);
- if (!ret)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "value is %i", uvalue);
-
- /************************************************************/
- egg_test_title (test, "convert valid uint number");
- ret = egg_strtouint ("234", &uvalue);
- if (ret && uvalue == 234)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "value is %i", uvalue);
-
- /************************************************************/
- egg_test_title (test, "convert invalid uint number");
- ret = egg_strtouint ("-234", &uvalue);
- if (ret == FALSE)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "value is %i", uvalue);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-animated-icon.c b/src/gpk-animated-icon.c
index f07a712..496785b 100644
--- a/src/gpk-animated-icon.c
+++ b/src/gpk-animated-icon.c
@@ -117,7 +117,7 @@ gpk_animated_icon_set_filename_tile (GpkAnimatedIcon *icon, GtkIconSize size, co
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), name, w, 0, NULL);
/* can't load from gnome-icon-theme */
if (pixbuf == NULL) {
- g_warning ("can't load %s", name);
+ g_debug ("can't load animation %s", name);
return FALSE;
}
@@ -303,4 +303,3 @@ gpk_animated_icon_new (void)
{
return g_object_new (GPK_TYPE_ANIMATED_ICON, NULL);
}
-
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 975b7a0..77cdcf7 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -3617,4 +3617,3 @@ main (int argc, char *argv[])
return status;
}
-
diff --git a/src/gpk-common.c b/src/gpk-common.c
index fbc01e0..9eb0046 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -775,162 +775,3 @@ gpk_package_entry_completion_new (void)
return completion;
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gpk_common_test (gpointer data)
-{
- gchar *text;
- EggTest *test = (EggTest *) data;
-
- if (!egg_test_start (test, "GpkCommon"))
- return;
-
- /************************************************************
- **************** time text **************
- ************************************************************/
- egg_test_title (test, "time zero");
- text = gpk_time_to_localised_string (0);
- if (text != NULL && strcmp (text, "Now") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "time 1s");
- text = gpk_time_to_localised_string (1);
- if (text != NULL && strcmp (text, "1 second") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "time 1m");
- text = gpk_time_to_localised_string (1*60);
- if (text != NULL && strcmp (text, "1 minute") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "time 1h");
- text = gpk_time_to_localised_string (1*60*60);
- if (text != NULL && strcmp (text, "1 hour") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "time 30s");
- text = gpk_time_to_localised_string (30);
- if (text != NULL && strcmp (text, "30 seconds") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "time 30m");
- text = gpk_time_to_localised_string (30*60);
- if (text != NULL && strcmp (text, "30 minutes") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "time 30m1s");
- text = gpk_time_to_localised_string (30*60+1);
- if (text != NULL && strcmp (text, "30 minutes 1 second") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "time 30m10s");
- text = gpk_time_to_localised_string (30*60+10);
- if (text != NULL && strcmp (text, "30 minutes 10 seconds") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "imprecise time 1s");
- text = gpk_time_to_imprecise_string (1);
- if (text != NULL && strcmp (text, "1 second") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "imprecise time 30m");
- text = gpk_time_to_imprecise_string (30*60);
- if (text != NULL && strcmp (text, "30 minutes") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "imprecise time 30m10s");
- text = gpk_time_to_imprecise_string (30*60+10);
- if (text != NULL && strcmp (text, "30 minutes") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************
- **************** package name text **************
- ************************************************************/
- egg_test_title (test, "package id pretty valid package id, no summary");
- text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;i386;data", NULL);
- if (text != NULL && strcmp (text, "simon-0.0.1 (32-bit)") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "package id pretty valid package id, no summary 2");
- text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;;data", NULL);
- if (text != NULL && strcmp (text, "simon-0.0.1") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "package id pretty valid package id, no summary 3");
- text = gpk_package_id_format_twoline (NULL, "simon;;;data", NULL);
- if (text != NULL && strcmp (text, "simon") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- /************************************************************/
- egg_test_title (test, "package id pretty valid package id, no summary 4");
- text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;;data", "dude");
- if (text != NULL && strcmp (text, "dude\n<span color=\"gray\">simon-0.0.1</span>") == 0)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "failed, got %s", text);
- g_free (text);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-common.h b/src/gpk-common.h
index f762d92..864bc43 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -74,7 +74,6 @@ G_BEGIN_DECLS
/* any status that is slower than this will not be shown in the UI */
#define GPK_UI_STATUS_SHOW_DELAY 750 /* ms */
-void gpk_common_test (gpointer data);
void gtk_text_buffer_insert_markup (GtkTextBuffer *buffer,
GtkTextIter *iter,
const gchar *markup);
diff --git a/src/gpk-dbus-service.c b/src/gpk-dbus-service.c
index 1e50468..e1de468 100644
--- a/src/gpk-dbus-service.c
+++ b/src/gpk-dbus-service.c
@@ -203,4 +203,3 @@ out:
g_object_unref (dbus);
return retval;
}
-
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 0bdb871..eba06c3 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -1984,7 +1984,7 @@ out:
/**
* gpk_dbus_task_font_tag_to_lang:
**/
-static gchar *
+gchar *
gpk_dbus_task_font_tag_to_lang (const gchar *tag)
{
gchar *lang = NULL;
@@ -2030,7 +2030,7 @@ out:
/**
* gpk_dbus_task_font_tag_to_localised_name:
**/
-static gchar *
+gchar *
gpk_dbus_task_font_tag_to_localised_name (GpkDbusTask *dtask, const gchar *tag)
{
gchar *lang;
@@ -3207,7 +3207,7 @@ out:
/**
* gpk_dbus_task_get_package_for_exec:
**/
-static gchar *
+gchar *
gpk_dbus_task_get_package_for_exec (GpkDbusTask *dtask, const gchar *exec)
{
const gchar *package_id;
@@ -3261,7 +3261,7 @@ out:
/**
* gpk_dbus_task_path_is_trusted:
**/
-static gboolean
+gboolean
gpk_dbus_task_path_is_trusted (const gchar *exec)
{
gboolean res = FALSE;
@@ -3486,131 +3486,3 @@ gpk_dbus_task_new (void)
dtask = g_object_new (GPK_TYPE_DBUS_TASK, NULL);
return GPK_DBUS_TASK (dtask);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gpk_dbus_task_test (gpointer data)
-{
- EggTest *test = (EggTest *) data;
- GpkDbusTask *dtask;
- gchar *lang;
- gchar *language;
- gchar *package;
- gboolean ret;
-#if 0
- const gchar *fonts[] = { ":lang=mn", NULL };
- GError *error;
-#endif
-
- if (egg_test_start (test, "GpkChooser") == FALSE)
- return;
-
- /************************************************************/
- egg_test_title (test, "get GpkDbusTask object");
- dtask = gpk_dbus_task_new ();
- if (dtask != NULL)
- egg_test_success (test, NULL);
- else
- g_warning (NULL);
-
- /************************************************************/
- egg_test_title (test, "convert tag to lang");
- lang = gpk_dbus_task_font_tag_to_lang (":lang=mn");
- if (g_strcmp0 (lang, "mn") == 0)
- egg_test_success (test, NULL);
- else
- g_warning ("lang '%s'", lang);
- g_free (lang);
-
- /************************************************************/
- egg_test_title (test, "convert tag to language");
- language = gpk_dbus_task_font_tag_to_localised_name (dtask, ":lang=mn");
- if (g_strcmp0 (language, "Mongolian") == 0)
- egg_test_success (test, NULL);
- else
- g_warning ("language '%s'", language);
- g_free (language);
-
- /************************************************************/
- egg_test_title (test, "test trusted path");
- ret = gpk_dbus_task_path_is_trusted ("/usr/libexec/gst-install-plugins-helper");
- if (ret)
- egg_test_success (test, NULL);
- else
- g_warning ("failed to identify trusted");
-
- /************************************************************/
- egg_test_title (test, "test trusted path");
- ret = gpk_dbus_task_path_is_trusted ("/usr/bin/totem");
- if (!ret)
- egg_test_success (test, NULL);
- else
- g_warning ("identify untrusted as trusted!");
-
- /************************************************************/
- egg_test_title (test, "get package for exec");
- package = gpk_dbus_task_get_package_for_exec (dtask, "/usr/bin/totem");
- if (g_strcmp0 (package, "totem") == 0)
- egg_test_success (test, NULL);
- else
- g_warning ("package '%s'", package);
- g_free (package);
-
- /************************************************************/
- egg_test_title (test, "set exec");
- ret = gpk_dbus_task_set_exec (dtask, "/usr/bin/totem");
- if (ret)
- egg_test_success (test, NULL);
- else
- g_warning ("failed to set exec");
-
-#if 0
- /************************************************************/
- egg_test_title (test, "install fonts (no UI)");
- error = NULL;
- gpk_dbus_task_set_interaction (dtask, GPK_CLIENT_INTERACT_NEVER);
- ret = gpk_dbus_task_install_fontconfig_resources (dtask, (gchar**)fonts, &error);
- if (ret)
- egg_test_success (test, NULL);
- else {
- /* success until we can do the server parts */
- egg_test_success (test, "failed to install font : %s", error->message);
- g_error_free (error);
- }
-
- /************************************************************/
- egg_test_title (test, "install fonts (if found)");
- error = NULL;
- gpk_dbus_task_set_interaction (dtask, pk_bitfield_from_enums (GPK_CLIENT_INTERACT_CONFIRM_SEARCH,
GPK_CLIENT_INTERACT_FINISHED, -1));
- ret = gpk_dbus_task_install_fontconfig_resources (dtask, (gchar**)fonts, &error);
- if (ret)
- egg_test_success (test, NULL);
- else {
- /* success until we can do the server parts */
- egg_test_success (test, "failed to install font : %s", error->message);
- g_error_free (error);
- }
-
- /************************************************************/
- egg_test_title (test, "install fonts (always)");
- error = NULL;
- gpk_dbus_task_set_interaction (dtask, GPK_CLIENT_INTERACT_ALWAYS);
- ret = gpk_dbus_task_install_fontconfig_resources (dtask, (gchar**)fonts, &error);
- if (ret)
- egg_test_success (test, NULL);
- else {
- /* success until we can do the server parts */
- egg_test_success (test, "failed to install font : %s", error->message);
- g_error_free (error);
- }
-#endif
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-dbus-task.h b/src/gpk-dbus-task.h
index bab4c7a..a310d19 100644
--- a/src/gpk-dbus-task.h
+++ b/src/gpk-dbus-task.h
@@ -152,6 +152,15 @@ gboolean gpk_dbus_task_set_xid (GpkDbusTask *dtask,
gboolean gpk_dbus_task_set_exec (GpkDbusTask *dtask,
const gchar *exec);
+/* for self checks */
+gchar *gpk_dbus_task_font_tag_to_localised_name (GpkDbusTask *dtask,
+ const gchar *tag);
+gboolean gpk_dbus_task_path_is_trusted (const gchar *exec);
+gchar *gpk_dbus_task_get_package_for_exec (GpkDbusTask *dtask,
+ const gchar *exec);
+gchar *gpk_dbus_task_font_tag_to_lang (const gchar *tag);
+
+
G_END_DECLS
#endif /* __GPK_DBUS_TASK_H */
diff --git a/src/gpk-dbus.c b/src/gpk-dbus.c
index 6aab531..1c2808f 100644
--- a/src/gpk-dbus.c
+++ b/src/gpk-dbus.c
@@ -599,32 +599,3 @@ gpk_dbus_new (void)
dbus = g_object_new (GPK_TYPE_DBUS, NULL);
return GPK_DBUS (dbus);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gpk_dbus_test (EggTest *test)
-{
- GpkDbus *dbus = NULL;
-
- if (!egg_test_start (test, "GpkDbus"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get GpkDbus object");
- dbus = gpk_dbus_new ();
- if (dbus != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, NULL);
-
- g_object_unref (dbus);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-desktop.c b/src/gpk-desktop.c
index 0dbc4b1..1e043e3 100644
--- a/src/gpk-desktop.c
+++ b/src/gpk-desktop.c
@@ -235,4 +235,3 @@ out:
g_free (filename);
return data;
}
-
diff --git a/src/gpk-enum.c b/src/gpk-enum.c
index e11ec7d..ae83a34 100644
--- a/src/gpk-enum.c
+++ b/src/gpk-enum.c
@@ -1810,202 +1810,3 @@ gpk_info_status_enum_to_icon_name (GpkInfoStatusEnum info)
/* regular PkInfoEnum */
return gpk_info_enum_to_icon_name (info);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gpk_enum_test (gpointer data)
-{
- guint i;
- const gchar *string;
- EggTest *test = (EggTest *) data;
-
- if (!egg_test_start (test, "GpkEnum"))
- return;
-
- /************************************************************
- **************** localized enums **************
- ************************************************************/
- egg_test_title (test, "check we convert all the localized past role enums");
- for (i=0; i<PK_ROLE_ENUM_LAST; i++) {
- string = gpk_role_enum_to_localised_past (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %i", i);
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized present role enums");
- for (i=0; i<PK_ROLE_ENUM_LAST; i++) {
- string = gpk_role_enum_to_localised_present (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %i", i);
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the role icon name enums");
- for (i=PK_ROLE_ENUM_UNKNOWN+1; i<PK_ROLE_ENUM_LAST; i++) {
- string = gpk_role_enum_to_icon_name (i);
- if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
- egg_test_failed (test, "failed to get %s", pk_role_enum_to_string (i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the status animation enums");
- for (i=PK_STATUS_ENUM_UNKNOWN+1; i<PK_STATUS_ENUM_UNKNOWN; i++) {
- string = gpk_status_enum_to_animation (i);
- if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
- egg_test_failed (test, "failed to get %s", pk_status_enum_to_string (i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the info icon names enums");
- for (i=PK_INFO_ENUM_UNKNOWN+1; i<PK_INFO_ENUM_LAST; i++) {
- string = gpk_info_enum_to_icon_name (i);
- if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
- egg_test_failed (test, "failed to get %s", pk_info_enum_to_string (i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized status enums");
- for (i=0; i<PK_STATUS_ENUM_LAST; i++) {
- string = gpk_status_enum_to_localised_text (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %i", i);
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the status icon names enums");
- for (i=PK_STATUS_ENUM_UNKNOWN+1; i<PK_STATUS_ENUM_LAST; i++) {
- string = gpk_status_enum_to_icon_name (i);
- if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
- egg_test_failed (test, "failed to get %s", pk_status_enum_to_string (i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the restart icon names enums");
- for (i=PK_RESTART_ENUM_UNKNOWN+1; i<PK_RESTART_ENUM_NONE; i++) {
- string = gpk_restart_enum_to_icon_name (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %s", pk_restart_enum_to_string (i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized error enums");
- for (i=0; i<PK_ERROR_ENUM_LAST; i++) {
- string = gpk_error_enum_to_localised_text (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %s", pk_error_enum_to_string(i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized error messages");
- for (i=0; i<PK_ERROR_ENUM_LAST; i++) {
- string = gpk_error_enum_to_localised_message (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %s", pk_error_enum_to_string(i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized restart enums");
- for (i=PK_RESTART_ENUM_UNKNOWN+1; i<PK_RESTART_ENUM_LAST; i++) {
- string = gpk_restart_enum_to_localised_text (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %i", i);
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the message icon name enums");
- for (i=PK_MESSAGE_ENUM_UNKNOWN+1; i<PK_MESSAGE_ENUM_LAST; i++) {
- string = gpk_message_enum_to_icon_name (i);
- if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
- egg_test_failed (test, "failed to get %s", pk_message_enum_to_string (i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized message enums");
- for (i=PK_MESSAGE_ENUM_UNKNOWN+1; i<PK_MESSAGE_ENUM_LAST; i++) {
- string = gpk_message_enum_to_localised_text (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %i", i);
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized restart future enums");
- for (i=PK_RESTART_ENUM_UNKNOWN+1; i<PK_RESTART_ENUM_LAST; i++) {
- string = gpk_restart_enum_to_localised_text_future (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %i", i);
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the localized group enums");
- for (i=0; i<PK_GROUP_ENUM_LAST; i++) {
- string = gpk_group_enum_to_localised_text (i);
- if (string == NULL) {
- egg_test_failed (test, "failed to get %i", i);
- break;
- }
- }
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "check we convert all the group icon name enums");
- for (i=PK_GROUP_ENUM_UNKNOWN+1; i<PK_GROUP_ENUM_LAST; i++) {
- string = gpk_group_enum_to_icon_name (i);
- if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
- egg_test_failed (test, "failed to get %s", pk_group_enum_to_string (i));
- break;
- }
- }
- egg_test_success (test, NULL);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-enum.h b/src/gpk-enum.h
index 19d0025..ab1e874 100644
--- a/src/gpk-enum.h
+++ b/src/gpk-enum.h
@@ -65,7 +65,6 @@ typedef enum {
#define PK_ERROR_ENUM_LOCK_REQUIRED (PK_ERROR_ENUM_UNFINISHED_TRANSACTION+1)
#endif
-void gpk_enum_test (gpointer data);
const gchar *gpk_role_enum_to_localised_past (PkRoleEnum role)
G_GNUC_CONST;
const gchar *gpk_role_enum_to_localised_present (PkRoleEnum role)
diff --git a/src/gpk-error.c b/src/gpk-error.c
index 9f232bc..fe565e7 100644
--- a/src/gpk-error.c
+++ b/src/gpk-error.c
@@ -169,30 +169,3 @@ gpk_error_dialog (const gchar *title, const gchar *message, const gchar *details
{
return gpk_error_dialog_modal (NULL, title, message, details);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gpk_error_test (EggTest *test)
-{
- gboolean ret;
-
- if (!egg_test_start (test, "GpkError"))
- return;
-
- /************************************************************/
- egg_test_title (test, "do dialog");
- ret = gpk_error_dialog ("No space is left on the disk",
- "There is insufficient space on the device.\n"
- "Free some space on the system disk to perform this operation.",
- "[Errno 28] No space left on device");
- egg_test_assert (test, ret);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-gnome.c b/src/gpk-gnome.c
index 09511f6..4c0e875 100644
--- a/src/gpk-gnome.c
+++ b/src/gpk-gnome.c
@@ -80,4 +80,3 @@ gpk_gnome_help (const gchar *link_id)
g_free (uri);
return ret;
}
-
diff --git a/src/gpk-language.c b/src/gpk-language.c
index 30805c7..55d41cb 100644
--- a/src/gpk-language.c
+++ b/src/gpk-language.c
@@ -194,63 +194,3 @@ gpk_language_new (void)
language = g_object_new (GPK_TYPE_LANGUAGE, NULL);
return GPK_LANGUAGE (language);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gpk_language_test (EggTest *test)
-{
- gboolean ret;
- gchar *lang;
- GError *error = NULL;
- GpkLanguage *language = NULL;
-
- if (!egg_test_start (test, "GpkLanguage"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get GpkLanguage object");
- language = gpk_language_new ();
- if (language != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "populate");
- ret = gpk_language_populate (language, &error);
- if (ret) {
- egg_test_success (test, NULL);
- } else {
- egg_test_failed (test, "failed to load XML: %s", error->message);
- g_error_free (error);
- }
-
- /************************************************************/
- egg_test_title (test, "get data (present)");
- lang = gpk_language_iso639_to_language (language, "en");
- if (lang != NULL && strcmp (lang, "English") == 0)
- egg_test_success (test, "got %s", lang);
- else
- egg_test_failed (test, NULL);
- g_free (lang);
-
- /************************************************************/
- egg_test_title (test, "get data (missing)");
- lang = gpk_language_iso639_to_language (language, "notgoingtoexist");
- if (lang == NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got %s", lang);
- g_free (lang);
-
- g_object_unref (language);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-modal-dialog.c b/src/gpk-modal-dialog.c
index 8b6f3a6..fb186e0 100644
--- a/src/gpk-modal-dialog.c
+++ b/src/gpk-modal-dialog.c
@@ -908,139 +908,3 @@ gpk_modal_dialog_new (void)
dialog = g_object_new (GPK_TYPE_CLIENT_DIALOG, NULL);
return GPK_MODAL_DIALOG (dialog);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-void
-gpk_modal_dialog_test (EggTest *test)
-{
- GtkResponseType button;
- GpkModalDialog *dialog = NULL;
- GPtrArray *array;
- PkPackage *item;
- gboolean ret;
-
- if (!egg_test_start (test, "GpkModalDialog"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get GpkModalDialog object");
- dialog = gpk_modal_dialog_new ();
- if (dialog != NULL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, NULL);
-
- /* set some packages */
- array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
- item = pk_package_new ();
- ret = pk_package_set_id (item, "totem;001;i386;fedora", NULL);
- g_assert (ret);
- g_object_set (item,
- "info", PK_INFO_ENUM_INSTALLED,
- "summary", "Totem is a music player for GNOME",
- NULL);
- g_ptr_array_add (array, item);
- item = pk_package_new ();
- ret = pk_package_set_id (item, "totem;001;i386;fedora", NULL);
- g_assert (ret);
- g_object_set (item,
- "info", PK_INFO_ENUM_AVAILABLE,
- "summary", "Amarok is a music player for KDE",
- NULL);
- g_ptr_array_add (array, item);
- gpk_modal_dialog_set_package_list (dialog, array);
- g_ptr_array_unref (array);
-
- /************************************************************/
- egg_test_title (test, "help button");
- gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
- gpk_modal_dialog_set_window_title (dialog, "PackageKit self test");
- gpk_modal_dialog_set_title (dialog, "Button press test");
- gpk_modal_dialog_set_message (dialog, "Please press close");
- gpk_modal_dialog_set_image (dialog, "dialog-warning");
- gpk_modal_dialog_present (dialog);
- button = gpk_modal_dialog_run (dialog);
- if (button == GTK_RESPONSE_CLOSE)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got id %i", button);
-
- /************************************************************/
- egg_test_title (test, "confirm button");
- gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, 0);
- gpk_modal_dialog_set_title (dialog, "Button press test with a really really long title");
- gpk_modal_dialog_set_message (dialog, "Please press Uninstall\n\nThis is a really really,
really,\nreally long title <i>with formatting</i>");
- gpk_modal_dialog_set_image (dialog, "dialog-information");
- gpk_modal_dialog_set_action (dialog, "Uninstall");
- gpk_modal_dialog_present (dialog);
- button = gpk_modal_dialog_run (dialog);
- if (button == GTK_RESPONSE_OK)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got id %i", button);
-
- /************************************************************/
- egg_test_title (test, "no message");
- gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, 0);
- gpk_modal_dialog_set_title (dialog, "Refresh cache");
- gpk_modal_dialog_set_image_status (dialog, PK_STATUS_ENUM_REFRESH_CACHE);
- gpk_modal_dialog_set_percentage (dialog, -1);
- gpk_modal_dialog_present (dialog);
- gpk_modal_dialog_run (dialog);
- egg_test_success (test, NULL);
-
- /************************************************************/
- egg_test_title (test, "progress");
- gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, GPK_MODAL_DIALOG_PACKAGE_PADDING);
- gpk_modal_dialog_set_title (dialog, "Button press test");
- gpk_modal_dialog_set_message (dialog, "Please press cancel");
- gpk_modal_dialog_set_image_status (dialog, PK_STATUS_ENUM_RUNNING);
- gpk_modal_dialog_set_percentage (dialog, 50);
- gpk_modal_dialog_present (dialog);
- button = gpk_modal_dialog_run (dialog);
- if (button == GTK_RESPONSE_CANCEL)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got id %i", button);
-
- /************************************************************/
- egg_test_title (test, "progress");
- gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, pk_bitfield_from_enums
(GPK_MODAL_DIALOG_WIDGET_MESSAGE, -1));
- gpk_modal_dialog_set_title (dialog, "Button press test");
- gpk_modal_dialog_set_message (dialog, "Please press close");
- gpk_modal_dialog_set_image_status (dialog, PK_STATUS_ENUM_INSTALL);
- gpk_modal_dialog_set_percentage (dialog, -1);
- gpk_modal_dialog_present (dialog);
- button = gpk_modal_dialog_run (dialog);
- if (button == GTK_RESPONSE_CLOSE)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got id %i", button);
-
- /************************************************************/
- egg_test_title (test, "confirm install button");
- gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
- gpk_modal_dialog_set_title (dialog, "Button press test");
- gpk_modal_dialog_set_message (dialog, "Please press Install if you can see the package list");
- gpk_modal_dialog_set_image (dialog, "dialog-information");
- gpk_modal_dialog_set_action (dialog, "Install");
- gpk_modal_dialog_present (dialog);
- button = gpk_modal_dialog_run (dialog);
- if (button == GTK_RESPONSE_OK)
- egg_test_success (test, NULL);
- else
- egg_test_failed (test, "got id %i", button);
-
- gpk_modal_dialog_close (dialog);
-
- g_object_unref (dialog);
-
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-self-test.c b/src/gpk-self-test.c
index 37b15c4..89ff6f1 100644
--- a/src/gpk-self-test.c
+++ b/src/gpk-self-test.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2007-2008 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2007-2013 Richard Hughes <richard hughsie com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -21,41 +21,781 @@
#include <glib.h>
#include <glib-object.h>
-#include "egg-test.h"
+
+#include "egg-markdown.h"
+
#include "gpk-common.h"
+#include "gpk-dbus.h"
+#include "gpk-dbus-task.h"
#include "gpk-enum.h"
+#include "gpk-error.h"
+#include "gpk-language.h"
+#include "gpk-modal-dialog.h"
#include "gpk-task.h"
-void egg_markdown_test (EggTest *test);
-void egg_string_test (EggTest *test);
-void gpk_dbus_test (EggTest *test);
-void gpk_language_test (EggTest *test);
-void gpk_modal_dialog_test (EggTest *test);
-void gpk_client_test (EggTest *test);
-void gpk_error_test (EggTest *test);
-int
-main (int argc, char **argv)
+/** ver:1.0 ***********************************************************/
+static GMainLoop *_test_loop = NULL;
+static guint _test_loop_timeout_id = 0;
+
+static gboolean
+_g_test_hang_wait_cb (gpointer user_data)
{
- EggTest *test;
+ g_main_loop_quit (_test_loop);
+ _test_loop_timeout_id = 0;
+ return FALSE;
+}
+
+/**
+ * _g_test_loop_wait:
+ **/
+static void
+_g_test_loop_wait (guint timeout_ms)
+{
+ g_assert (_test_loop_timeout_id == 0);
+ _test_loop = g_main_loop_new (NULL, FALSE);
+ _test_loop_timeout_id = g_timeout_add (timeout_ms, _g_test_hang_wait_cb, &timeout_ms);
+ g_main_loop_run (_test_loop);
+}
+
+/**
+ * _g_test_loop_quit:
+ **/
+static void
+_g_test_loop_quit (void)
+{
+ if (_test_loop_timeout_id > 0) {
+ g_source_remove (_test_loop_timeout_id);
+ _test_loop_timeout_id = 0;
+ }
+ if (_test_loop != NULL) {
+ g_main_loop_quit (_test_loop);
+ g_main_loop_unref (_test_loop);
+ _test_loop = NULL;
+ }
+}
+
+/**********************************************************************/
+
+static void
+gpk_test_enum_func (void)
+{
+ guint i;
+ const gchar *string;
+
+ /* check we convert all the localized past role enums */
+ for (i = 0; i < PK_ROLE_ENUM_LAST; i++) {
+ string = gpk_role_enum_to_localised_past (i);
+ if (string == NULL) {
+ g_warning ("failed to get %i", i);
+ break;
+ }
+ }
+
+ /* check we convert all the localized present role enums */
+ for (i = 0; i < PK_ROLE_ENUM_LAST; i++) {
+ string = gpk_role_enum_to_localised_present (i);
+ if (string == NULL) {
+ g_warning ("failed to get %i", i);
+ break;
+ }
+ }
+ /* check we convert all the role icon name enums */
+ for (i = PK_ROLE_ENUM_UNKNOWN+1; i < PK_ROLE_ENUM_LAST; i++) {
+ string = gpk_role_enum_to_icon_name (i);
+ if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
+ g_warning ("failed to get %s", pk_role_enum_to_string (i));
+ break;
+ }
+ }
+
+ /* check we convert all the status animation enums */
+ for (i = PK_STATUS_ENUM_UNKNOWN+1; i < PK_STATUS_ENUM_UNKNOWN; i++) {
+ string = gpk_status_enum_to_animation (i);
+ if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
+ g_warning ("failed to get %s", pk_status_enum_to_string (i));
+ break;
+ }
+ }
+
+ /* check we convert all the info icon names enums */
+ for (i = PK_INFO_ENUM_UNKNOWN+1; i < PK_INFO_ENUM_LAST; i++) {
+ string = gpk_info_enum_to_icon_name (i);
+ if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
+ g_warning ("failed to get %s", pk_info_enum_to_string (i));
+ break;
+ }
+ }
+
+ /* check we convert all the localized status enums */
+ for (i = 0; i < PK_STATUS_ENUM_LAST; i++) {
+ string = gpk_status_enum_to_localised_text (i);
+ if (string == NULL) {
+ g_warning ("failed to get %i", i);
+ break;
+ }
+ }
+
+ /* check we convert all the status icon names enums */
+ for (i = PK_STATUS_ENUM_UNKNOWN+1; i < PK_STATUS_ENUM_LAST; i++) {
+ string = gpk_status_enum_to_icon_name (i);
+ if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
+ g_warning ("failed to get %s", pk_status_enum_to_string (i));
+ break;
+ }
+ }
+
+ /* check we convert all the restart icon names enums */
+ for (i = PK_RESTART_ENUM_UNKNOWN+1; i < PK_RESTART_ENUM_NONE; i++) {
+ string = gpk_restart_enum_to_icon_name (i);
+ if (string == NULL) {
+ g_warning ("failed to get %s", pk_restart_enum_to_string (i));
+ break;
+ }
+ }
+
+ /* check we convert all the localized error enums */
+ for (i = 0; i < PK_ERROR_ENUM_LAST; i++) {
+ string = gpk_error_enum_to_localised_text (i);
+ if (string == NULL) {
+ g_warning ("failed to get %s", pk_error_enum_to_string(i));
+ break;
+ }
+ }
+
+ /* check we convert all the localized error messages */
+ for (i = 0; i < PK_ERROR_ENUM_LAST; i++) {
+ string = gpk_error_enum_to_localised_message (i);
+ if (string == NULL) {
+ g_warning ("failed to get %s", pk_error_enum_to_string(i));
+ break;
+ }
+ }
+
+ /* check we convert all the localized restart enums */
+ for (i = PK_RESTART_ENUM_UNKNOWN+1; i < PK_RESTART_ENUM_LAST; i++) {
+ string = gpk_restart_enum_to_localised_text (i);
+ if (string == NULL) {
+ g_warning ("failed to get %i", i);
+ break;
+ }
+ }
+
+ /* check we convert all the message icon name enums */
+ for (i = PK_MESSAGE_ENUM_UNKNOWN+1; i < PK_MESSAGE_ENUM_LAST; i++) {
+ string = gpk_message_enum_to_icon_name (i);
+ if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
+ g_warning ("failed to get %s", pk_message_enum_to_string (i));
+ break;
+ }
+ }
+
+ /* check we convert all the localized message enums */
+ for (i = PK_MESSAGE_ENUM_UNKNOWN+1; i < PK_MESSAGE_ENUM_LAST; i++) {
+ string = gpk_message_enum_to_localised_text (i);
+ if (string == NULL) {
+ g_warning ("failed to get %i", i);
+ break;
+ }
+ }
+
+ /* check we convert all the localized restart future enums */
+ for (i = PK_RESTART_ENUM_UNKNOWN+1; i < PK_RESTART_ENUM_LAST; i++) {
+ string = gpk_restart_enum_to_localised_text_future (i);
+ if (string == NULL) {
+ g_warning ("failed to get %i", i);
+ break;
+ }
+ }
+
+ /* check we convert all the localized group enums */
+ for (i = 0; i < PK_GROUP_ENUM_LAST; i++) {
+ string = gpk_group_enum_to_localised_text (i);
+ if (string == NULL) {
+ g_warning ("failed to get %i", i);
+ break;
+ }
+ }
+
+ /* check we convert all the group icon name enums */
+ for (i = PK_GROUP_ENUM_UNKNOWN+1; i < PK_GROUP_ENUM_LAST; i++) {
+ string = gpk_group_enum_to_icon_name (i);
+ if (string == NULL || g_strcmp0 (string, "help-browser") == 0) {
+ g_warning ("failed to get %s", pk_group_enum_to_string (i));
+ break;
+ }
+ }
+
+}
+
+static void
+gpk_test_modal_dialog_func (void)
+{
+ GtkResponseType button;
+ GpkModalDialog *dialog = NULL;
+ GPtrArray *array;
+ PkPackage *item;
+ gboolean ret;
+
+ /* get GpkModalDialog object */
+ dialog = gpk_modal_dialog_new ();
+ g_assert (dialog);
+
+ /* set some packages */
+ array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
+ item = pk_package_new ();
+ ret = pk_package_set_id (item, "totem;001;i386;fedora", NULL);
+ g_assert (ret);
+ g_object_set (item,
+ "info", PK_INFO_ENUM_INSTALLED,
+ "summary", "Totem is a music player for GNOME",
+ NULL);
+ g_ptr_array_add (array, item);
+ item = pk_package_new ();
+ ret = pk_package_set_id (item, "totem;001;i386;fedora", NULL);
+ g_assert (ret);
+ g_object_set (item,
+ "info", PK_INFO_ENUM_AVAILABLE,
+ "summary", "Amarok is a music player for KDE",
+ NULL);
+ g_ptr_array_add (array, item);
+ gpk_modal_dialog_set_package_list (dialog, array);
+ g_ptr_array_unref (array);
+
+ /* help button */
+ gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+ gpk_modal_dialog_set_title (dialog, "Button press test");
+ gpk_modal_dialog_set_message (dialog, "Please press close");
+ gpk_modal_dialog_set_image (dialog, "dialog-warning");
+ gpk_modal_dialog_present (dialog);
+ button = gpk_modal_dialog_run (dialog);
+ g_assert_cmpint (button, ==, GTK_RESPONSE_CLOSE);
+
+ /* confirm button */
+ gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, 0);
+ gpk_modal_dialog_set_title (dialog, "Button press test with a really really long title");
+ gpk_modal_dialog_set_message (dialog, "Please press Uninstall\n\nThis is a really really,
really,\nreally long title <i>with formatting</i>");
+ gpk_modal_dialog_set_image (dialog, "dialog-information");
+ gpk_modal_dialog_set_action (dialog, "Uninstall");
+ gpk_modal_dialog_present (dialog);
+ button = gpk_modal_dialog_run (dialog);
+ g_assert_cmpint (button, ==, GTK_RESPONSE_OK);
+
+ /* no message */
+ gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, 0);
+ gpk_modal_dialog_set_title (dialog, "Refresh cache");
+ gpk_modal_dialog_set_image_status (dialog, PK_STATUS_ENUM_REFRESH_CACHE);
+ gpk_modal_dialog_set_percentage (dialog, -1);
+ gpk_modal_dialog_present (dialog);
+ gpk_modal_dialog_run (dialog);
+
+ /* progress */
+ gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, GPK_MODAL_DIALOG_PACKAGE_PADDING);
+ gpk_modal_dialog_set_title (dialog, "Button press test");
+ gpk_modal_dialog_set_message (dialog, "Please press cancel");
+ gpk_modal_dialog_set_image_status (dialog, PK_STATUS_ENUM_RUNNING);
+ gpk_modal_dialog_set_percentage (dialog, 50);
+ gpk_modal_dialog_present (dialog);
+ button = gpk_modal_dialog_run (dialog);
+ g_assert_cmpint (button, ==, GTK_RESPONSE_CANCEL);
+
+ /* progress */
+ gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, pk_bitfield_from_enums
(GPK_MODAL_DIALOG_WIDGET_MESSAGE, -1));
+ gpk_modal_dialog_set_title (dialog, "Button press test");
+ gpk_modal_dialog_set_message (dialog, "Please press close");
+ gpk_modal_dialog_set_image_status (dialog, PK_STATUS_ENUM_INSTALL);
+ gpk_modal_dialog_set_percentage (dialog, -1);
+ gpk_modal_dialog_present (dialog);
+ button = gpk_modal_dialog_run (dialog);
+ g_assert_cmpint (button, ==, GTK_RESPONSE_CLOSE);
+
+ /* confirm install button */
+ gpk_modal_dialog_setup (dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
+ gpk_modal_dialog_set_title (dialog, "Button press test");
+ gpk_modal_dialog_set_message (dialog, "Please press Install if you can see the package list");
+ gpk_modal_dialog_set_image (dialog, "dialog-information");
+ gpk_modal_dialog_set_action (dialog, "Install");
+ gpk_modal_dialog_present (dialog);
+ button = gpk_modal_dialog_run (dialog);
+ g_assert_cmpint (button, ==, GTK_RESPONSE_OK);
+
+ gpk_modal_dialog_close (dialog);
+
+ g_object_unref (dialog);
+}
+
+static void
+gpk_test_language_func (void)
+{
+ gboolean ret;
+ gchar *lang;
+ GError *error = NULL;
+ GpkLanguage *language = NULL;
+
+ /* get GpkLanguage object */
+ language = gpk_language_new ();
+ g_assert (language != NULL);
+
+ /* populate */
+ ret = gpk_language_populate (language, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ /* get data (present) */
+ lang = gpk_language_iso639_to_language (language, "en");
+ g_assert_cmpstr (lang, ==, "English");
+ g_free (lang);
+
+ /* get data (missing) */
+ lang = gpk_language_iso639_to_language (language, "notgoingtoexist");
+ g_assert_cmpstr (lang, ==, NULL);
+
+ g_object_unref (language);
+}
+
+static void
+gpk_test_dbus_task_func (void)
+{
+ GpkDbusTask *dtask;
+ gchar *lang;
+ gchar *language;
+ gchar *package;
+ gboolean ret;
+// const gchar *fonts[] = { ":lang=mn", NULL };
+// GError *error;
+
+ /* get GpkDbusTask object */
+ dtask = gpk_dbus_task_new ();
+ g_assert (dtask);
+
+ /* convert tag to lang */
+ lang = gpk_dbus_task_font_tag_to_lang (":lang=mn");
+ g_assert_cmpstr (lang, ==, "mn");
+ g_free (lang);
+
+ /* convert tag to language */
+ language = gpk_dbus_task_font_tag_to_localised_name (dtask, ":lang=mn");
+ g_assert_cmpstr (language, ==, "Mongolian");
+ g_free (language);
+
+ /* test trusted path */
+// ret = gpk_dbus_task_path_is_trusted ("/usr/libexec/gst-install-plugins-helper");
+// g_assert (ret);
+
+ /* test trusted path */
+ ret = gpk_dbus_task_path_is_trusted ("/usr/bin/totem");
+ g_assert (!ret);
+
+ /* get package for exec */
+ package = gpk_dbus_task_get_package_for_exec (dtask, "/usr/bin/totem");
+ g_assert_cmpstr (package, ==, "totem");
+ g_free (package);
+
+ /* set exec */
+ ret = gpk_dbus_task_set_exec (dtask, "/usr/bin/totem");
+ g_assert (ret);
+#if 0
+ /* install fonts (no UI) */
+ error = NULL;
+ gpk_dbus_task_set_interaction (dtask, GPK_CLIENT_INTERACT_NEVER);
+ ret = gpk_dbus_task_install_fontconfig_resources (dtask, (gchar**)fonts, NULL, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ /* install fonts (if found) */
+ error = NULL;
+ gpk_dbus_task_set_interaction (dtask, pk_bitfield_from_enums (GPK_CLIENT_INTERACT_CONFIRM_SEARCH,
GPK_CLIENT_INTERACT_FINISHED, -1));
+ ret = gpk_dbus_task_install_fontconfig_resources (dtask, (gchar**)fonts, NULL, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ /* install fonts (always) */
+ error = NULL;
+ gpk_dbus_task_set_interaction (dtask, GPK_CLIENT_INTERACT_ALWAYS);
+ ret = gpk_dbus_task_install_fontconfig_resources (dtask, (gchar**)fonts, NULL, &error);
+ g_assert_no_error (error);
+ g_assert (ret);
+#endif
+}
+
+static void
+gpk_test_error_func (void)
+{
+ gboolean ret;
+ /* do dialog */
+ ret = gpk_error_dialog ("No space is left on the disk",
+ "There is insufficient space on the device.\n"
+ "Free some space on the system disk to perform this operation.",
+ "[Errno 28] No space left on device");
+ g_assert (ret);
+}
+
+static void
+gpk_test_dbus_func (void)
+{
+ GpkDbus *dbus = NULL;
+
+ /* get GpkDbus object */
+ dbus = gpk_dbus_new ();
+ g_assert (dbus);
+ g_object_unref (dbus);
+}
+
+static void
+gpk_test_common_func (void)
+{
+ gchar *text;
+
+ /* time zero */
+ text = gpk_time_to_localised_string (0);
+ g_assert_cmpstr (text, ==, "Now");
+ g_free (text);
+
+ /* time 1s */
+ text = gpk_time_to_localised_string (1);
+ g_assert_cmpstr (text, ==, "1 second");
+ g_free (text);
+
+ /* time 1m */
+ text = gpk_time_to_localised_string (1*60);
+ g_assert_cmpstr (text, ==, "1 minute");
+ g_free (text);
+
+ /* time 1h */
+ text = gpk_time_to_localised_string (1*60*60);
+ g_assert_cmpstr (text, ==, "1 hour");
+ g_free (text);
+
+ /* time 30s */
+ text = gpk_time_to_localised_string (30);
+ g_assert_cmpstr (text, ==, "30 seconds");
+ g_free (text);
+
+ /* time 30m */
+ text = gpk_time_to_localised_string (30*60);
+ g_assert_cmpstr (text, ==, "30 minutes");
+ g_free (text);
+
+ /* time 30m1s */
+ text = gpk_time_to_localised_string (30*60+1);
+ g_assert_cmpstr (text, ==, "30 minutes 1 second");
+ g_free (text);
+
+ /* time 30m10s */
+ text = gpk_time_to_localised_string (30*60+10);
+ g_assert_cmpstr (text, ==, "30 minutes 10 seconds");
+ g_free (text);
+
+ /* imprecise time 1s */
+ text = gpk_time_to_imprecise_string (1);
+ g_assert_cmpstr (text, ==, "1 second");
+ g_free (text);
+
+ /* imprecise time 30m */
+ text = gpk_time_to_imprecise_string (30*60);
+ g_assert_cmpstr (text, ==, "30 minutes");
+ g_free (text);
+
+ /* imprecise time 30m10s */
+ text = gpk_time_to_imprecise_string (30*60+10);
+ g_assert_cmpstr (text, ==, "30 minutes");
+ g_free (text);
+
+ /* package id pretty valid package id, no summary */
+ text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;i386;data", NULL);
+ g_assert_cmpstr (text, ==, "simon-0.0.1 (32-bit)");
+ g_free (text);
+
+ /* package id pretty valid package id, no summary 2 */
+ text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;;data", NULL);
+ g_assert_cmpstr (text, ==, "simon-0.0.1");
+ g_free (text);
+
+ /* package id pretty valid package id, no summary 3 */
+ text = gpk_package_id_format_twoline (NULL, "simon;;;data", NULL);
+ g_assert_cmpstr (text, ==, "simon");
+ g_free (text);
+
+ /* package id pretty valid package id, no summary 4 */
+ text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;;data", "dude");
+ g_assert_cmpstr (text, ==, "dude\n<span color=\"gray\">simon-0.0.1</span>");
+ g_free (text);
+}
+
+static void
+gpk_test_markdown_func (void)
+{
+ EggMarkdown *md;
+ gchar *text;
+ gboolean ret;
+ const gchar *markdown;
+ const gchar *markdown_expected;
+
+ /* get EggMarkdown object */
+ md = egg_markdown_new ();
+ g_assert (md);
+
+ ret = egg_markdown_set_output (md, EGG_MARKDOWN_OUTPUT_PANGO);
+ g_assert (ret);
+
+ markdown = "OEMs\n"
+ "====\n"
+ " - Bullett\n";
+ markdown_expected =
+ "<big>OEMs</big>\n"
+ "• Bullett";
+ /* markdown (type2 header) */
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ markdown = "this is http://www.hughsie.com/with_spaces_in_url inline link\n";
+ markdown_expected = "this is <tt>http://www.hughsie.com/with_spaces_in_url</tt> inline link";
+ /* markdown (autocode) */
+ egg_markdown_set_autocode (md, TRUE);
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ markdown = "*** This software is currently in alpha state ***\n";
+ markdown_expected = "<b><i> This software is currently in alpha state </b></i>";
+ /* markdown some invalid header */
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ markdown = " - This is a *very*\n"
+ " short paragraph\n"
+ " that is not usual.\n"
+ " - Another";
+ markdown_expected =
+ "• This is a <i>very</i> short paragraph that is not usual.\n"
+ "• Another";
+ /* markdown (complex1) */
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ markdown = "* This is a *very*\n"
+ " short paragraph\n"
+ " that is not usual.\n"
+ "* This is the second\n"
+ " bullett point.\n"
+ "* And the third.\n"
+ " \n"
+ "* * *\n"
+ " \n"
+ "Paragraph one\n"
+ "isn't __very__ long at all.\n"
+ "\n"
+ "Paragraph two\n"
+ "isn't much better.";
+ markdown_expected =
+ "• This is a <i>very</i> short paragraph that is not usual.\n"
+ "• This is the second bullett point.\n"
+ "• And the third.\n"
+ "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
+ "Paragraph one isn't <b>very</b> long at all.\n"
+ "Paragraph two isn't much better.";
+ /* markdown (complex1) */
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ markdown = "This is a spec file description or\n"
+ "an **update** description in bohdi.\n"
+ "\n"
+ "* * *\n"
+ "# Big title #\n"
+ "\n"
+ "The *following* things 'were' fixed:\n"
+ "- Fix `dave`\n"
+ "* Fubar update because of \"security\"\n";
+ markdown_expected =
+ "This is a spec file description or an <b>update</b> description in bohdi.\n"
+ "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n"
+ "<big>Big title</big>\n"
+ "The <i>following</i> things 'were' fixed:\n"
+ "• Fix <tt>dave</tt>\n"
+ "• Fubar update because of \"security\"";
+ /* markdown (complex2) */
+ text = egg_markdown_parse (md, markdown);
+ if (g_strcmp0 (text, markdown_expected) == 0)
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ markdown = "* list seporated with spaces -\n"
+ " first item\n"
+ "\n"
+ "* second item\n"
+ "\n"
+ "* third item\n";
+ markdown_expected =
+ "• list seporated with spaces - first item\n"
+ "• second item\n"
+ "• third item";
+ /* markdown (list with spaces) */
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ ret = egg_markdown_set_max_lines (md, 1);
+ g_assert (ret);
+
+ markdown = "* list seporated with spaces -\n"
+ " first item\n"
+ "* second item\n";
+ markdown_expected =
+ "• list seporated with spaces - first item";
+ /* markdown (one line limit) */
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ ret = egg_markdown_set_max_lines (md, 1);
+ g_assert (ret);
+
+ markdown = "* list & spaces";
+ markdown_expected =
+ "• list & spaces";
+ /* markdown (escaping) */
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ /* markdown (free text) */
+ text = egg_markdown_parse (md, "This isn't a present");
+ g_assert_cmpstr (text, ==, "This isn't a present");
+ g_free (text);
+
+ /* markdown (autotext underscore) */
+ text = egg_markdown_parse (md, "This isn't CONFIG_UEVENT_HELPER_PATH present");
+ g_assert_cmpstr (text, ==, "This isn't <tt>CONFIG_UEVENT_HELPER_PATH</tt> present");
+ g_free (text);
+
+ markdown = "*Thu Mar 12 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.79-1\n"
+ "- Update to upstream \n"
+ " * Netlink socket handoff patch from Adam Jackson.\n"
+ " * AVC caching of compute_create results by Eric Paris.\n"
+ "\n"
+ "*Tue Mar 10 12:00:00 2009* Dan Walsh <dwalsh redhat com> - 2.0.78-5\n"
+ "- Add patch from ajax to accellerate X SELinux \n"
+ "- Update eparis patch\n";
+ markdown_expected =
+ "<i>Thu Mar 12 12:00:00 2009</i> Dan Walsh <tt><dwalsh redhat com></tt> - 2.0.79-1\n"
+ "• Update to upstream\n"
+ "• Netlink socket handoff patch from Adam Jackson.\n"
+ "• AVC caching of compute_create results by Eric Paris.\n"
+ "<i>Tue Mar 10 12:00:00 2009</i> Dan Walsh <tt><dwalsh redhat com></tt> - 2.0.78-5\n"
+ "• Add patch from ajax to accellerate X SELinux\n"
+ "• Update eparis patch";
+ /* markdown (end of bullett) */
+ egg_markdown_set_escape (md, TRUE);
+ ret = egg_markdown_set_max_lines (md, 1024);
+ text = egg_markdown_parse (md, markdown);
+ g_assert_cmpstr (text, ==, markdown_expected);
+ g_free (text);
+
+ g_object_unref (md);
+}
+
+static void
+gpk_task_test_install_packages_cb (GObject *object, GAsyncResult *res, gpointer user_data)
+{
+ GpkTask *task = GPK_TASK (object);
+ GError *error = NULL;
+ PkResults *results;
+ GPtrArray *packages;
+ PkError *error_code = NULL;
+
+ /* get the results */
+ results = pk_task_generic_finish (PK_TASK(task), res, &error);
+ if (results == NULL) {
+ g_warning ("failed to resolve: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* check error code */
+ error_code = pk_results_get_error_code (results);
+ if (error_code != NULL)
+ g_warning ("failed to resolve success: %s", pk_error_get_details (error_code));
+
+ packages = pk_results_get_package_array (results);
+ if (packages == NULL)
+ g_warning ("no packages!");
+
+ if (packages->len != 4)
+ g_warning ("invalid number of packages: %i", packages->len);
+
+ g_ptr_array_unref (packages);
+out:
+ if (error_code != NULL)
+ g_object_unref (error_code);
+ if (results != NULL)
+ g_object_unref (results);
+ _g_test_loop_quit ();
+}
+
+static void
+gpk_task_test_progress_cb (PkProgress *progress, PkProgressType type, gpointer user_data)
+{
+ PkStatusEnum status;
+ if (type == PK_PROGRESS_TYPE_STATUS) {
+ g_object_get (progress,
+ "status", &status,
+ NULL);
+ g_debug ("now %s", pk_status_enum_to_string (status));
+ }
+}
+
+static void
+gpk_test_task_func (void)
+{
+ GpkTask *task;
+ gchar **package_ids;
+
+ /* get task */
+ task = gpk_task_new ();
+ g_assert (task);
+
+ /* For testing, you will need to manually do:
+ pkcon repo-set-data dummy use-gpg 1
+ pkcon repo-set-data dummy use-eula 1
+ pkcon repo-set-data dummy use-media 1
+ */
+
+ /* install package */
+ package_ids = pk_package_ids_from_id ("vips-doc;7.12.4-2.fc8;noarch;linva");
+ pk_task_install_packages_async (PK_TASK(task), package_ids, NULL,
+ (PkProgressCallback) gpk_task_test_progress_cb, NULL,
+ (GAsyncReadyCallback) gpk_task_test_install_packages_cb, NULL);
+ g_strfreev (package_ids);
+ _g_test_loop_wait (150000);
+
+ g_object_unref (task);
+}
+
+int
+main (int argc, char **argv)
+{
g_type_init ();
gtk_init (&argc, &argv);
- test = egg_test_init ();
+ g_test_init (&argc, &argv, NULL);
- /* tests go here */
- egg_markdown_test (test);
- egg_string_test (test);
- gpk_enum_test (test);
- gpk_common_test (test);
-// gpk_dbus_test (test);
- gpk_language_test (test);
- gpk_error_test (test);
-// gpk_client_test (test);
- gpk_modal_dialog_test (test);
- gpk_task_test (test);
+ g_test_add_func ("/gnome-packagekit/enum", gpk_test_enum_func);
+ g_test_add_func ("/gnome-packagekit/common", gpk_test_common_func);
+ g_test_add_func ("/gnome-packagekit/language", gpk_test_language_func);
+ g_test_add_func ("/gnome-packagekit/markdown", gpk_test_markdown_func);
+ g_test_add_func ("/gnome-packagekit/dbus", gpk_test_dbus_func);
+ g_test_add_func ("/gnome-packagekit/dbus-task", gpk_test_dbus_task_func);
+ if (g_test_thorough ()) {
+ g_test_add_func ("/gnome-packagekit/modal-dialog", gpk_test_modal_dialog_func);
+ g_test_add_func ("/gnome-packagekit/error", gpk_test_error_func);
+ g_test_add_func ("/gnome-packagekit/task", gpk_test_task_func);
+ }
- return egg_test_finish (test);
+ return g_test_run ();
}
-
diff --git a/src/gpk-task.c b/src/gpk-task.c
index a7e6b8f..ced44a5 100644
--- a/src/gpk-task.c
+++ b/src/gpk-task.c
@@ -760,96 +760,3 @@ gpk_task_new (void)
task = g_object_new (GPK_TYPE_TASK, NULL);
return GPK_TASK (task);
}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef EGG_TEST
-#include "egg-test.h"
-
-static void
-gpk_task_test_install_packages_cb (GObject *object, GAsyncResult *res, EggTest *test)
-{
- GpkTask *task = GPK_TASK (object);
- GError *error = NULL;
- PkResults *results;
- GPtrArray *packages;
- PkError *error_code = NULL;
-
- /* get the results */
- results = pk_task_generic_finish (PK_TASK(task), res, &error);
- if (results == NULL) {
- egg_test_failed (test, "failed to resolve: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* check error code */
- error_code = pk_results_get_error_code (results);
- if (error_code != NULL)
- egg_test_failed (test, "failed to resolve success: %s", pk_error_get_details (error_code));
-
- packages = pk_results_get_package_array (results);
- if (packages == NULL)
- egg_test_failed (test, "no packages!");
-
- if (packages->len != 4)
- egg_test_failed (test, "invalid number of packages: %i", packages->len);
-
- g_ptr_array_unref (packages);
-out:
- if (error_code != NULL)
- g_object_unref (error_code);
- if (results != NULL)
- g_object_unref (results);
- egg_test_loop_quit (test);
-}
-
-static void
-gpk_task_test_progress_cb (PkProgress *progress, PkProgressType type, EggTest *test)
-{
- PkStatusEnum status;
- if (type == PK_PROGRESS_TYPE_STATUS) {
- g_object_get (progress,
- "status", &status,
- NULL);
- g_debug ("now %s", pk_status_enum_to_string (status));
- }
-}
-
-void
-gpk_task_test (gpointer user_data)
-{
- EggTest *test = (EggTest *) user_data;
- GpkTask *task;
- gchar **package_ids;
-
- if (!egg_test_start (test, "GpkTask"))
- return;
-
- /************************************************************/
- egg_test_title (test, "get task");
- task = gpk_task_new ();
- egg_test_assert (test, task != NULL);
-
- /* For testing, you will need to manually do:
- pkcon repo-set-data dummy use-gpg 1
- pkcon repo-set-data dummy use-eula 1
- pkcon repo-set-data dummy use-media 1
- */
-
- /************************************************************/
- egg_test_title (test, "install package");
- package_ids = pk_package_ids_from_id ("vips-doc;7.12.4-2.fc8;noarch;linva");
- pk_task_install_packages_async (PK_TASK(task), package_ids, NULL,
- (PkProgressCallback) gpk_task_test_progress_cb, test,
- (GAsyncReadyCallback) gpk_task_test_install_packages_cb, test);
- g_strfreev (package_ids);
- egg_test_loop_wait (test, 150000);
- egg_test_success (test, "installed in %i", egg_test_elapsed (test));
-
- g_object_unref (task);
- egg_test_end (test);
-}
-#endif
-
diff --git a/src/gpk-task.h b/src/gpk-task.h
index 318fd66..53da8e8 100644
--- a/src/gpk-task.h
+++ b/src/gpk-task.h
@@ -53,7 +53,6 @@ struct _GpkTaskClass
GQuark gpk_task_error_quark (void);
GType gpk_task_get_type (void);
GpkTask *gpk_task_new (void);
-void gpk_task_test (gpointer user_data);
gboolean gpk_task_set_parent_window (GpkTask *task,
GtkWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]