[libpeas] Added tests for custom icons



commit b2304ef9a624d42e6c2505e24671b80fe5d823d3
Author: Garrett Regier <alias301 gmail com>
Date:   Sun Jan 16 13:43:59 2011 -0800

    Added tests for custom icons

 configure.ac                                       |    1 +
 tests/libpeas-gtk/plugin-manager-store.c           |   37 ++++++++++++++++---
 tests/libpeas-gtk/plugins/Makefile.am              |    7 ++--
 .../libpeas-gtk/plugins/invalid-custom-icon.plugin |    8 ++++
 tests/libpeas-gtk/plugins/invalid-icon.plugin      |    8 ----
 .../libpeas-gtk/plugins/invalid-stock-icon.plugin  |    8 ++++
 .../plugins/valid-custom-icon/Makefile.am          |    3 ++
 .../plugins/valid-custom-icon/exists.png           |  Bin 0 -> 2916 bytes
 .../valid-custom-icon/valid-custom-icon.plugin     |    8 ++++
 .../{valid-icon.plugin => valid-stock-icon.plugin} |    6 ++--
 10 files changed, 66 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d3183f8..c5e9ca0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -322,6 +322,7 @@ tests/libpeas-gtk/Makefile
 tests/libpeas-gtk/plugins/Makefile
 tests/libpeas-gtk/plugins/builtin-configurable/Makefile
 tests/libpeas-gtk/plugins/configurable/Makefile
+tests/libpeas-gtk/plugins/valid-custom-icon/Makefile
 tests/libpeas-gtk/testing/Makefile
 tests/plugins/Makefile
 tests/plugins/builtin/Makefile
diff --git a/tests/libpeas-gtk/plugin-manager-store.c b/tests/libpeas-gtk/plugin-manager-store.c
index 1b653e6..03c69e5 100644
--- a/tests/libpeas-gtk/plugin-manager-store.c
+++ b/tests/libpeas-gtk/plugin-manager-store.c
@@ -265,35 +265,58 @@ test_gtk_plugin_manager_store_verify_info (TestFixture *fixture)
 static void
 verify_icon (TestFixture *fixture,
              const gchar *plugin_name,
+             gboolean     has_pixbuf,
              const gchar *icon_name)
 {
   PeasPluginInfo *info;
   GtkTreeIter iter;
+  GdkPixbuf *model_icon_pixbuf;
   gchar *model_icon_name;
 
   info = peas_engine_get_plugin_info (fixture->engine, plugin_name);
   testing_get_iter_for_plugin_info (fixture->view, info, &iter);
 
   gtk_tree_model_get (fixture->model, &iter,
+    PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_PIXBUF_COLUMN, &model_icon_pixbuf,
     PEAS_GTK_PLUGIN_MANAGER_STORE_ICON_NAME_COLUMN, &model_icon_name,
     -1);
 
+  if (has_pixbuf)
+    g_assert (GDK_IS_PIXBUF (model_icon_pixbuf));
+  else
+    g_assert (!GDK_IS_PIXBUF (model_icon_pixbuf));
+
   g_assert_cmpstr (model_icon_name, ==, icon_name);
 
+  if (model_icon_pixbuf != NULL)
+    g_object_unref (model_icon_pixbuf);
+
   if (model_icon_name != NULL)
     g_free (model_icon_name);
 }
 
 static void
-test_gtk_plugin_manager_store_valid_icon (TestFixture *fixture)
+test_gtk_plugin_manager_store_valid_custom_icon (TestFixture *fixture)
+{
+  verify_icon (fixture, "valid-custom-icon", TRUE, NULL);
+}
+
+static void
+test_gtk_plugin_manager_store_valid_stock_icon (TestFixture *fixture)
+{
+  verify_icon (fixture, "valid-stock-icon", FALSE, "gtk-about");
+}
+
+static void
+test_gtk_plugin_manager_store_invalid_custom_icon (TestFixture *fixture)
 {
-  verify_icon (fixture, "valid-icon", "gtk-about");
+  verify_icon (fixture, "invalid-custom-icon", FALSE, "libpeas-plugin");
 }
 
 static void
-test_gtk_plugin_manager_store_invalid_icon (TestFixture *fixture)
+test_gtk_plugin_manager_store_invalid_stock_icon (TestFixture *fixture)
 {
-  verify_icon (fixture, "invalid-icon", "libpeas-plugin");
+  verify_icon (fixture, "invalid-stock-icon", FALSE, "libpeas-plugin");
 }
 
 int
@@ -319,8 +342,10 @@ main (int    argc,
   TEST ("verify-builtin", verify_builtin);
   TEST ("verify-info", verify_info);
 
-  TEST ("valid-icon", valid_icon);
-  TEST ("invalid-icon", invalid_icon);
+  TEST ("valid-custom-icon", valid_custom_icon);
+  TEST ("valid-stock-icon", valid_stock_icon);
+  TEST ("invalid-custom-icon", invalid_custom_icon);
+  TEST ("invalid-stock-icon", invalid_stock_icon);
 
 #undef TEST
 
diff --git a/tests/libpeas-gtk/plugins/Makefile.am b/tests/libpeas-gtk/plugins/Makefile.am
index ee31fd7..9137b9f 100644
--- a/tests/libpeas-gtk/plugins/Makefile.am
+++ b/tests/libpeas-gtk/plugins/Makefile.am
@@ -1,7 +1,8 @@
-SUBDIRS = builtin-configurable configurable
+SUBDIRS = builtin-configurable configurable valid-custom-icon
 
 noinst_DATA = \
-	invalid-icon.plugin	\
-	valid-icon.plugin
+	invalid-custom-icon.plugin	\
+	invalid-stock-icon.plugin	\
+	valid-stock-icon.plugin
 
 EXTRA_DIST = $(noinst_DATA)
diff --git a/tests/libpeas-gtk/plugins/invalid-custom-icon.plugin b/tests/libpeas-gtk/plugins/invalid-custom-icon.plugin
new file mode 100644
index 0000000..519dcb1
--- /dev/null
+++ b/tests/libpeas-gtk/plugins/invalid-custom-icon.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=invalid-custom-icon
+IAge=2
+Name=Invalid Custom Icon
+Description=A plugin that has an invalid custom icon.
+Icon=does-not-exist.png
+Authors=Garrett Regier
+Copyright=Copyright © 2010 Garrett Regier
diff --git a/tests/libpeas-gtk/plugins/invalid-stock-icon.plugin b/tests/libpeas-gtk/plugins/invalid-stock-icon.plugin
new file mode 100644
index 0000000..328116e
--- /dev/null
+++ b/tests/libpeas-gtk/plugins/invalid-stock-icon.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=invalid-stock-icon
+IAge=2
+Name=Invalid Stock Icon
+Description=A plugin that has an invalid stock icon.
+Icon=does-not-exist
+Authors=Garrett Regier
+Copyright=Copyright © 2010 Garrett Regier
diff --git a/tests/libpeas-gtk/plugins/valid-custom-icon/Makefile.am b/tests/libpeas-gtk/plugins/valid-custom-icon/Makefile.am
new file mode 100644
index 0000000..dd94ec5
--- /dev/null
+++ b/tests/libpeas-gtk/plugins/valid-custom-icon/Makefile.am
@@ -0,0 +1,3 @@
+noinst_DATA = valid-custom-icon.plugin
+
+EXTRA_DIST = $(noinst_DATA)
diff --git a/tests/libpeas-gtk/plugins/valid-custom-icon/exists.png b/tests/libpeas-gtk/plugins/valid-custom-icon/exists.png
new file mode 100644
index 0000000..0476658
Binary files /dev/null and b/tests/libpeas-gtk/plugins/valid-custom-icon/exists.png differ
diff --git a/tests/libpeas-gtk/plugins/valid-custom-icon/valid-custom-icon.plugin b/tests/libpeas-gtk/plugins/valid-custom-icon/valid-custom-icon.plugin
new file mode 100644
index 0000000..30cda1f
--- /dev/null
+++ b/tests/libpeas-gtk/plugins/valid-custom-icon/valid-custom-icon.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=valid-custom-icon
+IAge=2
+Name=Valid Custom Icon
+Description=A plugin that has a valid custom icon.
+Icon=exists.png
+Authors=Garrett Regier
+Copyright=Copyright © 2010 Garrett Regier
diff --git a/tests/libpeas-gtk/plugins/valid-icon.plugin b/tests/libpeas-gtk/plugins/valid-stock-icon.plugin
similarity index 50%
rename from tests/libpeas-gtk/plugins/valid-icon.plugin
rename to tests/libpeas-gtk/plugins/valid-stock-icon.plugin
index 78bf559..292aa9a 100644
--- a/tests/libpeas-gtk/plugins/valid-icon.plugin
+++ b/tests/libpeas-gtk/plugins/valid-stock-icon.plugin
@@ -1,8 +1,8 @@
 [Plugin]
-Module=valid-icon
+Module=valid-stock-icon
 IAge=2
-Name=Valid Icon
-Description=A plugin that has a valid icon.
+Name=Valid Stock Icon
+Description=A plugin that has a valid stock icon.
 Icon=gtk-about
 Authors=Garrett Regier
 Copyright=Copyright © 2010 Garrett Regier



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