app/tests: Make gimp_ui_synthesize_key_event() a global test util

This commit is contained in:
Martin Nordholts
2010-10-26 13:53:24 +02:00
parent edff4949bc
commit 62ece2ff18
3 changed files with 32 additions and 25 deletions

View File

@ -134,3 +134,26 @@ gimp_test_utils_create_image (Gimp *gimp,
return image; return image;
} }
/**
* gimp_test_utils_synthesize_key_event:
* @widget: Widget to target.
* @keyval: Keyval, e.g. GDK_Return
*
* Simulates a keypress and release with gdk_test_simulate_key().
**/
void
gimp_test_utils_synthesize_key_event (GtkWidget *widget,
guint keyval)
{
gdk_test_simulate_key (gtk_widget_get_window (widget),
-1, -1, /*x, y*/
keyval,
0 /*modifiers*/,
GDK_KEY_PRESS);
gdk_test_simulate_key (gtk_widget_get_window (widget),
-1, -1, /*x, y*/
keyval,
0 /*modifiers*/,
GDK_KEY_RELEASE);
}

View File

@ -19,12 +19,14 @@
#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, GimpImage * gimp_test_utils_create_image (Gimp *gimp,
gint width, gint width,
gint height); gint height);
void gimp_test_utils_synthesize_key_event (GtkWidget *widget,
guint keyval);
#endif /* __GIMP_RECTANGLE_SELECT_TOOL_H__ */ #endif /* __GIMP_RECTANGLE_SELECT_TOOL_H__ */

View File

@ -89,8 +89,6 @@ typedef struct
static GimpUIManager * gimp_ui_get_ui_manager (Gimp *gimp); static GimpUIManager * gimp_ui_get_ui_manager (Gimp *gimp);
static void gimp_ui_synthesize_delete_event (GtkWidget *widget); static void gimp_ui_synthesize_delete_event (GtkWidget *widget);
static void gimp_ui_synthesize_key_event (GtkWidget *widget,
guint keyval);
static gboolean gimp_ui_synthesize_click (GtkWidget *widget, static gboolean gimp_ui_synthesize_click (GtkWidget *widget,
gint x, gint x,
gint y, gint y,
@ -327,7 +325,7 @@ keyboard_zoom_focus (GimpTestFixture *fixture,
factor_before_zoom = gimp_zoom_model_get_factor (shell->zoom); factor_before_zoom = gimp_zoom_model_get_factor (shell->zoom);
/* Do the zoom */ /* Do the zoom */
gimp_ui_synthesize_key_event (GTK_WIDGET (window), GDK_plus); gimp_test_utils_synthesize_key_event (GTK_WIDGET (window), GDK_plus);
gimp_test_run_mainloop_until_idle (); gimp_test_run_mainloop_until_idle ();
/* Make sure the zoom focus point remained fixed */ /* Make sure the zoom focus point remained fixed */
@ -747,22 +745,6 @@ gimp_ui_synthesize_delete_event (GtkWidget *widget)
gdk_event_free (event); gdk_event_free (event);
} }
static void
gimp_ui_synthesize_key_event (GtkWidget *widget,
guint keyval)
{
gdk_test_simulate_key (gtk_widget_get_window (widget),
-1, -1, /*x, y*/
keyval,
0 /*modifiers*/,
GDK_KEY_PRESS);
gdk_test_simulate_key (gtk_widget_get_window (widget),
-1, -1, /*x, y*/
keyval,
0 /*modifiers*/,
GDK_KEY_RELEASE);
}
static gboolean static gboolean
gimp_ui_synthesize_click (GtkWidget *widget, gimp_ui_synthesize_click (GtkWidget *widget,
gint x, gint x,