[libpeas] Simplify finding the plugin manager buttons



commit fcbd3fdb05ccacd8cd2817010f7787b19d6c29e7
Author: Garrett Regier <garrettregier gmail com>
Date:   Mon Sep 8 23:10:45 2014 -0700

    Simplify finding the plugin manager buttons

 po/POTFILES.in                     |    1 +
 tests/libpeas-gtk/plugin-manager.c |   74 ++++--------------------------------
 2 files changed, 9 insertions(+), 66 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7d1b725..ffd1b95 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,3 +11,4 @@ libpeas-gtk/peas-gtk-disable-plugins-dialog.c
 libpeas-gtk/peas-gtk-plugin-manager.c
 libpeas-gtk/peas-gtk-plugin-manager-view.c
 peas-demo/peas-demo.c
+tests/libpeas-gtk/plugin-manager.c
diff --git a/tests/libpeas-gtk/plugin-manager.c b/tests/libpeas-gtk/plugin-manager.c
index d3188ac..524b369 100644
--- a/tests/libpeas-gtk/plugin-manager.c
+++ b/tests/libpeas-gtk/plugin-manager.c
@@ -26,6 +26,7 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <libpeas/peas.h>
+#include <libpeas/peas-i18n.h>
 #include <libpeas-gtk/peas-gtk.h>
 
 #include "testing/testing.h"
@@ -53,24 +54,9 @@ notify_model_cb (GtkTreeView *view,
 }
 
 static void
-plugin_manager_forall_cb (GtkWidget  *widget,
-                          GtkWidget **toolbar)
-{
-  if (GTK_IS_TOOLBAR (widget))
-    *toolbar = widget;
-}
-
-static void
 test_setup (TestFixture   *fixture,
             gconstpointer  data)
 {
-  GList *children;
-  GtkContainer *toolbar = NULL;
-  GtkContainer *tool_item;
-  GtkContainer *toolbar_box;
-  GtkContainer *item_box1;
-  GtkContainer *item_box2;
-
   fixture->engine = testing_engine_new ();
   fixture->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   fixture->window_group = gtk_window_group_new ();
@@ -96,59 +82,15 @@ test_setup (TestFixture   *fixture,
   /* Set the model */
   g_object_notify (G_OBJECT (fixture->view), "model");
 
-  /* Must use forall as the buttons are "internal" children */
-  gtk_container_forall (GTK_CONTAINER (fixture->manager),
-                        (GtkCallback) plugin_manager_forall_cb,
-                        &toolbar);
-
-  g_assert (toolbar != NULL);
-
-  /* The structure for the toolbar is:
-     toolbar
-       toolitem
-         box
-           box
-             button
-           box
-             button
-  */
-
-  children = gtk_container_get_children (toolbar);
-  g_assert (g_list_length (children) == 1);
-
-  tool_item = children->data;
-  g_assert (GTK_IS_TOOL_ITEM (tool_item));
-  g_list_free (children);
-
-  children = gtk_container_get_children (tool_item);
-  g_assert (g_list_length (children) == 1);
-
-  toolbar_box = children->data;
-  g_assert (GTK_IS_BOX (toolbar_box));
-  g_list_free (children);
-
-  children = gtk_container_get_children (toolbar_box);
-  g_assert (g_list_length (children) == 2);
-
-  item_box1 = children->data;
-  item_box2 = children->next->data;
-  g_assert (GTK_IS_BOX (item_box1));
-  g_assert (GTK_IS_BOX (item_box2));
-  g_list_free (children);
-
-  children = gtk_container_get_children (item_box1);
-  g_assert (g_list_length (children) == 1);
+  fixture->about_button = gtk_test_find_widget (fixture->window,
+                                                _("About"),
+                                                GTK_TYPE_BUTTON);
+  g_assert (GTK_IS_BUTTON (fixture->about_button));
 
-  fixture->configure_button = GTK_WIDGET (children->data);
+  fixture->configure_button = gtk_test_find_widget (fixture->window,
+                                                    _("Preferences"),
+                                                    GTK_TYPE_BUTTON);
   g_assert (GTK_IS_BUTTON (fixture->configure_button));
-  g_list_free (children);
-
-  children = gtk_container_get_children (item_box2);
-  g_assert (g_list_length (children) == 1);
-
-  fixture->about_button = GTK_WIDGET (children->data);
-  g_assert (GTK_IS_BUTTON (fixture->about_button));
-  g_list_free (children);
 }
 
 static void


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