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.
This commit is contained in:
@ -18,8 +18,15 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <gegl.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/gimp.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
@ -100,7 +107,7 @@ gimp_test_utils_setup_menus_dir (void)
|
|||||||
*
|
*
|
||||||
* Returns: The new #GimpImage.
|
* Returns: The new #GimpImage.
|
||||||
**/
|
**/
|
||||||
GimpImage *
|
void
|
||||||
gimp_test_utils_create_image (Gimp *gimp,
|
gimp_test_utils_create_image (Gimp *gimp,
|
||||||
gint width,
|
gint width,
|
||||||
gint height)
|
gint height)
|
||||||
@ -131,8 +138,6 @@ gimp_test_utils_create_image (Gimp *gimp,
|
|||||||
image,
|
image,
|
||||||
GIMP_UNIT_PIXEL,
|
GIMP_UNIT_PIXEL,
|
||||||
1.0 /*scale*/);
|
1.0 /*scale*/);
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,3 +162,38 @@ gimp_test_utils_synthesize_key_event (GtkWidget *widget,
|
|||||||
0 /*modifiers*/,
|
0 /*modifiers*/,
|
||||||
GDK_KEY_RELEASE);
|
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;
|
||||||
|
}
|
||||||
|
@ -19,14 +19,15 @@
|
|||||||
#define __GIMP_RECTANGLE_SELECT_TOOL_H__
|
#define __GIMP_RECTANGLE_SELECT_TOOL_H__
|
||||||
|
|
||||||
|
|
||||||
void gimp_test_utils_set_gimp2_directory (const gchar *root_env_var,
|
void gimp_test_utils_set_gimp2_directory (const gchar *root_env_var,
|
||||||
const gchar *subdir);
|
const gchar *subdir);
|
||||||
void gimp_test_utils_setup_menus_dir (void);
|
void gimp_test_utils_setup_menus_dir (void);
|
||||||
GimpImage * gimp_test_utils_create_image (Gimp *gimp,
|
void gimp_test_utils_create_image (Gimp *gimp,
|
||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
void gimp_test_utils_synthesize_key_event (GtkWidget *widget,
|
void gimp_test_utils_synthesize_key_event (GtkWidget *widget,
|
||||||
guint keyval);
|
guint keyval);
|
||||||
|
GimpUIManager * gimp_test_utils_get_ui_manager (Gimp *gimp);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_RECTANGLE_SELECT_TOOL_H__ */
|
#endif /* __GIMP_RECTANGLE_SELECT_TOOL_H__ */
|
||||||
|
@ -87,7 +87,7 @@ typedef struct
|
|||||||
} GimpTestFixture;
|
} 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 void gimp_ui_synthesize_delete_event (GtkWidget *widget);
|
||||||
static gboolean gimp_ui_synthesize_click (GtkWidget *widget,
|
static gboolean gimp_ui_synthesize_click (GtkWidget *widget,
|
||||||
gint x,
|
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
|
/* Restore the (only avaiable) closed dock and make sure the session
|
||||||
* infos in the global dock factory are increased again
|
* 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",
|
"windows",
|
||||||
/* FIXME: This is severly hardcoded */
|
/* FIXME: This is severly hardcoded */
|
||||||
"windows-recent-0003");
|
"windows-recent-0003");
|
||||||
@ -528,14 +528,14 @@ tab_toggle_dont_change_dock_window_position (GimpTestFixture *fixture,
|
|||||||
&h_before_hide);
|
&h_before_hide);
|
||||||
|
|
||||||
/* Hide all dock windows */
|
/* 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",
|
||||||
"windows-hide-docks");
|
"windows-hide-docks");
|
||||||
gimp_test_run_mainloop_until_idle ();
|
gimp_test_run_mainloop_until_idle ();
|
||||||
g_assert (! gtk_widget_get_visible (dock_window));
|
g_assert (! gtk_widget_get_visible (dock_window));
|
||||||
|
|
||||||
/* Show them again */
|
/* 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",
|
||||||
"windows-hide-docks");
|
"windows-hide-docks");
|
||||||
gimp_test_run_mainloop_until_idle ();
|
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
|
/* Switch to single-window mode. We consider this test as passed if
|
||||||
* we don't get any GLib warnings/errors
|
* 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",
|
||||||
"windows-use-single-window-mode");
|
"windows-use-single-window-mode");
|
||||||
gimp_test_run_mainloop_until_idle ();
|
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);
|
&x_before_hide, &y_before_hide);
|
||||||
|
|
||||||
/* Hide all dock windows */
|
/* 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",
|
||||||
"windows-hide-docks");
|
"windows-hide-docks");
|
||||||
gimp_test_run_mainloop_until_idle ();
|
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
|
/* Switch back to multi-window mode. We consider this test as passed
|
||||||
* if we don't get any GLib warnings/errors
|
* 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",
|
||||||
"windows-use-single-window-mode");
|
"windows-use-single-window-mode");
|
||||||
gimp_test_run_mainloop_until_idle ();
|
gimp_test_run_mainloop_until_idle ();
|
||||||
@ -698,31 +698,6 @@ paintbrush_is_standard_tool (GimpTestFixture *fixture,
|
|||||||
"gimp-tool-paintbrush");
|
"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:
|
* gimp_ui_synthesize_delete_event:
|
||||||
* @widget:
|
* @widget:
|
||||||
|
Reference in New Issue
Block a user