Commit 936d27a4 authored by Tim Janik's avatar Tim Janik

Added Gtk+ testing utilities.

* gtk/gtktestutils.h, gtk/gtktestutils.c: added unit test utility functions.
for the most part, the functions herein involve navigating and interacting
with dialog elements programatically, to automate user interaction tests of
dialogs and widgets.

* gtk/gtk.h: include gtk/gtktestutils.h as public API.

* gtk/gtk.symbols: added gtk_test_* symbols.

* gtk/Makefile.am: include gtktestutils.h and gtktestutils.c into the build.
generate gtktypefuncs.c which contains a list of all _get_type functions in
Gtk+ and Gdk.

svn path=/trunk/; revision=19010
parent 9e0b0194
......@@ -279,6 +279,7 @@ gtk_public_h_sources = \
gtkstyle.h \
gtktable.h \
gtktearoffmenuitem.h \
gtktestutils.h \
gtktext.h \
gtktextbuffer.h \
gtktextbufferrichtext.h \
......@@ -559,6 +560,7 @@ gtk_base_c_sources = \
gtkstyle.c \
gtktable.c \
gtktearoffmenuitem.c \
gtktestutils.c \
gtktext.c \
gtktextbtree.c \
gtktextbuffer.c \
......@@ -714,6 +716,7 @@ gtk_built_private_headers = \
gtk_built_sources = \
gtkaliasdef.c \
gtktypebuiltins.c \
gtktypefuncs.c \
gtkmarshalers.c \
gtkmarshal.c \
${gtk_built_private_headers} \
......@@ -751,7 +754,7 @@ EXTRA_DIST += $(STOCK_ICONS)
# rules to generate built sources
#
# setup autogeneration dependencies
gen_sources = xgen-gdef xgen-gtbh xgen-gtic xgen-gmh xgen-gmc xgen-gmlh xgen-gmlc
gen_sources = xgen-gdef xgen-gtbh xgen-gtic xgen-gmh xgen-gmc xgen-gmlh xgen-gmlc xgen-gtfsrc.c xgen-gtf
CLEANFILES = $(gen_sources)
BUILT_SOURCES = $(gtk_built_sources)
......@@ -817,6 +820,14 @@ gtktypebuiltins.c: @REBUILD@ $(gtk_public_h_sources) Makefile
&& cp xgen-gtbc gtktypebuiltins.c \
&& rm -f xgen-gtbc
gtktypefuncs.c: @REBUILD@ $(top_srcdir)/gtk/*.h $(top_srcdir)/gdk/*.h Makefile
echo '#include <gtk/gtk.h>' > xgen-gtfsrc.c && \
${CPP} $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \
egrep -o '\<g[td]k_[a-zA-Z0-9_]+_get_type\>' | sort | uniq | \
sed '{ s/^/vgt=/; s/$$/();/; }' > xgen-gtf \
&& cp xgen-gtf $@ && rm -f xgen-gtf
gtktestutils.c: gtktypefuncs.c
# target platform:
lib_LTLIBRARIES = $(gtktargetlib)
......
......@@ -183,6 +183,7 @@
#include <gtk/gtktoolitem.h>
#include <gtk/gtktooltip.h>
#include <gtk/gtktooltips.h>
#include <gtk/gtktestutils.h>
#include <gtk/gtktree.h>
#include <gtk/gtktreednd.h>
#include <gtk/gtktreeitem.h>
......
......@@ -3253,6 +3253,29 @@ gtk_recent_info_match
#endif
#endif
#if IN_HEADER(__GTK_TEST_UTILS_H__)
#if IN_FILE(__GTK_TEST_UTILS_C__)
gtk_test_create_simple_window
gtk_test_create_widget
gtk_test_display_button_window
gtk_test_find_label
gtk_test_find_sibling
gtk_test_find_widget
gtk_test_init
gtk_test_register_all_types
gtk_test_simulate_button
gtk_test_simulate_key
gtk_test_slider_get_value
gtk_test_slider_set_perc
gtk_test_spin_button_click
gtk_test_text_get
gtk_test_text_set
gtk_test_widget_click
gtk_test_widget_send_key
gtk_test_xserver_render_sync
#endif
#endif
#if IN_HEADER(__GTK_TEXT_BUFFER_RICH_TEXT_H__)
#if IN_FILE(__GTK_TEXT_BUFFER_RICH_TEXT_C__)
gtk_text_buffer_deserialize
......
This diff is collapsed.
/* Gtk+ testing utilities
* Copyright (C) 2007 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_TEST_UTILS_H__
#define __GTK_TEST_UTILS_H__
#include <gtk/gtkwidget.h>
#include <gtk/gtkspinbutton.h>
G_BEGIN_DECLS;
/* --- Gtk+ Test Utility API --- */
void gtk_test_init (int *argcp,
char ***argvp,
...);
void gtk_test_register_all_types (void);
GtkWidget* gtk_test_find_widget (GtkWidget *widget,
const gchar *label_pattern,
GType widget_type);
GtkWidget* gtk_test_create_widget (GType widget_type,
const gchar *first_property_name,
...);
GtkWidget* gtk_test_create_simple_window (const gchar *window_title,
const gchar *dialog_text);
GtkWidget* gtk_test_display_button_window (const gchar *window_title,
const gchar *dialog_text,
...); /* NULL terminated list of (label, &int) pairs */
void gtk_test_xserver_render_sync (GdkWindow *window);
void gtk_test_slider_set_perc (GtkWidget *widget, /* GtkRange-alike */
double percentage);
double gtk_test_slider_get_value (GtkWidget *widget);
gboolean gtk_test_spin_button_click (GtkSpinButton *widget,
guint button,
gboolean upwards);
gboolean gtk_test_widget_click (GtkWidget *widget,
guint button,
GdkModifierType modifiers);
gboolean gtk_test_widget_send_key (GtkWidget *widget,
guint keyval,
GdkModifierType modifiers);
/* operate on GtkEntry, GtkText, GtkTextView or GtkLabel */
void gtk_test_text_set (GtkWidget *widget,
const gchar *string);
gchar* gtk_test_text_get (GtkWidget *widget);
/* --- Gtk+ Test low-level API --- */
GtkWidget* gtk_test_find_sibling (GtkWidget *base_widget,
GType widget_type);
GtkWidget* gtk_test_find_label (GtkWidget *widget,
const gchar *label_pattern);
gboolean gtk_test_simulate_key (GdkWindow *window,
gint x,
gint y,
guint keyval,
GdkModifierType modifiers,
gboolean press_or_release);
gboolean gtk_test_simulate_button (GdkWindow *window,
gint x,
gint y,
guint button, /*1..3*/
GdkModifierType modifiers,
gboolean press_or_release);
G_END_DECLS;
#endif /* __GTK_TEST_UTILS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment