[gimp] app/tests: Make gimp_ui_get_ui_manager() a global test util
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app/tests: Make gimp_ui_get_ui_manager() a global test util
- Date: Tue, 26 Oct 2010 12:16:00 +0000 (UTC)
commit e7b7bb713631fff68f14405ae020bee19e83a55f
Author: Martin Nordholts <martinn src gnome org>
Date: Tue Oct 26 14:15:03 2010 +0200
app/tests: Make gimp_ui_get_ui_manager() a global test util
Make gimp_ui_get_ui_manager() a global test util and make
gimp_test_utils_create_image() return void, clients can reach the new
image and display from the Gimp instance.
app/tests/gimp-app-test-utils.c | 48 +++++++++++++++++++++++++++++++++++---
app/tests/gimp-app-test-utils.h | 17 +++++++------
app/tests/test-ui.c | 39 +++++--------------------------
3 files changed, 60 insertions(+), 44 deletions(-)
---
diff --git a/app/tests/gimp-app-test-utils.c b/app/tests/gimp-app-test-utils.c
index c063109..d12d1d5 100644
--- a/app/tests/gimp-app-test-utils.c
+++ b/app/tests/gimp-app-test-utils.c
@@ -18,8 +18,15 @@
#include "config.h"
#include <gegl.h>
+#include <gtk/gtk.h>
-#include "core/core-types.h"
+#include "display/display-types.h"
+
+#include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
+#include "display/gimpimagewindow.h"
+
+#include "widgets/gimpuimanager.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
@@ -100,7 +107,7 @@ gimp_test_utils_setup_menus_dir (void)
*
* Returns: The new #GimpImage.
**/
-GimpImage *
+void
gimp_test_utils_create_image (Gimp *gimp,
gint width,
gint height)
@@ -131,8 +138,6 @@ gimp_test_utils_create_image (Gimp *gimp,
image,
GIMP_UNIT_PIXEL,
1.0 /*scale*/);
-
- return image;
}
/**
@@ -157,3 +162,38 @@ gimp_test_utils_synthesize_key_event (GtkWidget *widget,
0 /*modifiers*/,
GDK_KEY_RELEASE);
}
+
+/**
+ * gimp_test_utils_get_ui_manager:
+ * @gimp: The #Gimp instance.
+ *
+ * Returns the "best" #GimpUIManager to use when performing
+ * actions. It gives the ui manager of the empty display if it exists,
+ * otherwise it gives it the ui manager of the first display.
+ *
+ * Returns: The #GimpUIManager.
+ **/
+GimpUIManager *
+gimp_test_utils_get_ui_manager (Gimp *gimp)
+{
+ GimpDisplay *display = NULL;
+ GimpDisplayShell *shell = NULL;
+ GtkWidget *toplevel = NULL;
+ GimpImageWindow *image_window = NULL;
+ GimpUIManager *ui_manager = NULL;
+
+ display = GIMP_DISPLAY (gimp_get_empty_display (gimp));
+
+ /* If there were not empty display, assume that there is at least
+ * one image display and use that
+ */
+ if (! display)
+ display = GIMP_DISPLAY (gimp_get_display_iter (gimp)->data);
+
+ shell = gimp_display_get_shell (display);
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
+ image_window = GIMP_IMAGE_WINDOW (toplevel);
+ ui_manager = gimp_image_window_get_ui_manager (image_window);
+
+ return ui_manager;
+}
diff --git a/app/tests/gimp-app-test-utils.h b/app/tests/gimp-app-test-utils.h
index 086037c..4802e0d 100644
--- a/app/tests/gimp-app-test-utils.h
+++ b/app/tests/gimp-app-test-utils.h
@@ -19,14 +19,15 @@
#define __GIMP_RECTANGLE_SELECT_TOOL_H__
-void gimp_test_utils_set_gimp2_directory (const gchar *root_env_var,
- const gchar *subdir);
-void gimp_test_utils_setup_menus_dir (void);
-GimpImage * gimp_test_utils_create_image (Gimp *gimp,
- gint width,
- gint height);
-void gimp_test_utils_synthesize_key_event (GtkWidget *widget,
- guint keyval);
+void gimp_test_utils_set_gimp2_directory (const gchar *root_env_var,
+ const gchar *subdir);
+void gimp_test_utils_setup_menus_dir (void);
+void gimp_test_utils_create_image (Gimp *gimp,
+ gint width,
+ gint height);
+void gimp_test_utils_synthesize_key_event (GtkWidget *widget,
+ guint keyval);
+GimpUIManager * gimp_test_utils_get_ui_manager (Gimp *gimp);
#endif /* __GIMP_RECTANGLE_SELECT_TOOL_H__ */
diff --git a/app/tests/test-ui.c b/app/tests/test-ui.c
index 0cf3180..fe6c559 100644
--- a/app/tests/test-ui.c
+++ b/app/tests/test-ui.c
@@ -87,7 +87,7 @@ typedef struct
} GimpTestFixture;
-static GimpUIManager * gimp_ui_get_ui_manager (Gimp *gimp);
+static GimpUIManager * gimp_test_utils_get_ui_manager (Gimp *gimp);
static void gimp_ui_synthesize_delete_event (GtkWidget *widget);
static gboolean gimp_ui_synthesize_click (GtkWidget *widget,
gint x,
@@ -476,7 +476,7 @@ restore_recently_closed_multi_column_dock (GimpTestFixture *fixture,
/* Restore the (only avaiable) closed dock and make sure the session
* infos in the global dock factory are increased again
*/
- gimp_ui_manager_activate_action (gimp_ui_get_ui_manager (gimp),
+ gimp_ui_manager_activate_action (gimp_test_utils_get_ui_manager (gimp),
"windows",
/* FIXME: This is severly hardcoded */
"windows-recent-0003");
@@ -528,14 +528,14 @@ tab_toggle_dont_change_dock_window_position (GimpTestFixture *fixture,
&h_before_hide);
/* Hide all dock windows */
- gimp_ui_manager_activate_action (gimp_ui_get_ui_manager (gimp),
+ gimp_ui_manager_activate_action (gimp_test_utils_get_ui_manager (gimp),
"windows",
"windows-hide-docks");
gimp_test_run_mainloop_until_idle ();
g_assert (! gtk_widget_get_visible (dock_window));
/* Show them again */
- gimp_ui_manager_activate_action (gimp_ui_get_ui_manager (gimp),
+ gimp_ui_manager_activate_action (gimp_test_utils_get_ui_manager (gimp),
"windows",
"windows-hide-docks");
gimp_test_run_mainloop_until_idle ();
@@ -565,7 +565,7 @@ switch_to_single_window_mode (GimpTestFixture *fixture,
/* Switch to single-window mode. We consider this test as passed if
* we don't get any GLib warnings/errors
*/
- gimp_ui_manager_activate_action (gimp_ui_get_ui_manager (gimp),
+ gimp_ui_manager_activate_action (gimp_test_utils_get_ui_manager (gimp),
"windows",
"windows-use-single-window-mode");
gimp_test_run_mainloop_until_idle ();
@@ -597,7 +597,7 @@ gimp_ui_toggle_docks_in_single_window_mode (Gimp *gimp)
&x_before_hide, &y_before_hide);
/* Hide all dock windows */
- gimp_ui_manager_activate_action (gimp_ui_get_ui_manager (gimp),
+ gimp_ui_manager_activate_action (gimp_test_utils_get_ui_manager (gimp),
"windows",
"windows-hide-docks");
gimp_test_run_mainloop_until_idle ();
@@ -641,7 +641,7 @@ switch_back_to_multi_window_mode (GimpTestFixture *fixture,
/* Switch back to multi-window mode. We consider this test as passed
* if we don't get any GLib warnings/errors
*/
- gimp_ui_manager_activate_action (gimp_ui_get_ui_manager (gimp),
+ gimp_ui_manager_activate_action (gimp_test_utils_get_ui_manager (gimp),
"windows",
"windows-use-single-window-mode");
gimp_test_run_mainloop_until_idle ();
@@ -698,31 +698,6 @@ paintbrush_is_standard_tool (GimpTestFixture *fixture,
"gimp-tool-paintbrush");
}
-static GimpUIManager *
-gimp_ui_get_ui_manager (Gimp *gimp)
-{
- GimpDisplay *display = NULL;
- GimpDisplayShell *shell = NULL;
- GtkWidget *toplevel = NULL;
- GimpImageWindow *image_window = NULL;
- GimpUIManager *ui_manager = NULL;
-
- display = GIMP_DISPLAY (gimp_get_empty_display (gimp));
-
- /* If there were not empty display, assume that there is at least
- * one image display and use that
- */
- if (! display)
- display = GIMP_DISPLAY (gimp_get_display_iter (gimp)->data);
-
- shell = gimp_display_get_shell (display);
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
- image_window = GIMP_IMAGE_WINDOW (toplevel);
- ui_manager = gimp_image_window_get_ui_manager (image_window);
-
- return ui_manager;
-}
-
/**
* gimp_ui_synthesize_delete_event:
* @widget:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]