manpagez: man pages & more
html files: gtk3
Home | html | info | man

Testing

Testing — Utilities for testing GTK+ applications

Includes

#include <gtk/gtk.h>

Description

Functions

gtk_test_create_simple_window ()

GtkWidget *
gtk_test_create_simple_window (const gchar *window_title,
                               const gchar *dialog_text);

gtk_test_create_simple_window has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

Create a simple window with window title window_title and text contents dialog_text . The window will quit any running gtk_main()-loop when destroyed, and it will automatically be destroyed upon test function teardown.

Parameters

window_title

Title of the window to be displayed.

 

dialog_text

Text inside the window to be displayed.

 

Returns

a widget pointer to the newly created GtkWindow.

[transfer none]

Since: 2.14


gtk_test_create_widget ()

GtkWidget *
gtk_test_create_widget (GType widget_type,
                        const gchar *first_property_name,
                        ...);

gtk_test_create_widget has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

This function wraps g_object_new() for widget types. It’ll automatically show all created non window widgets, also g_object_ref_sink() them (to keep them alive across a running test) and set them up for destruction during the next test teardown phase.

Parameters

widget_type

a valid widget type.

 

first_property_name

Name of first property to set or NULL.

[allow-none]

...

value to set the first property to, followed by more name-value pairs, terminated by NULL

 

Returns

a newly created widget.

[transfer none]

Since: 2.14


gtk_test_display_button_window ()

GtkWidget *
gtk_test_display_button_window (const gchar *window_title,
                                const gchar *dialog_text,
                                ...);

gtk_test_display_button_window has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

Create a window with window title window_title , text contents dialog_text , and a number of buttons, according to the paired argument list given as @... parameters. Each button is created with a label and a ::clicked signal handler that incremrents the integer stored in nump . The window will be automatically shown with gtk_widget_show_now() after creation, so when this function returns it has already been mapped, resized and positioned on screen. The window will quit any running gtk_main()-loop when destroyed, and it will automatically be destroyed upon test function teardown.

Parameters

window_title

Title of the window to be displayed.

 

dialog_text

Text inside the window to be displayed.

 

...

NULL terminated list of (const char *label, int *nump) pairs.

 

Returns

a widget pointer to the newly created GtkWindow.

[transfer full]

Since: 2.14


gtk_test_find_label ()

GtkWidget *
gtk_test_find_label (GtkWidget *widget,
                     const gchar *label_pattern);

This function will search widget and all its descendants for a GtkLabel widget with a text string matching label_pattern . The label_pattern may contain asterisks “*” and question marks “?” as placeholders, g_pattern_match() is used for the matching. Note that locales other than "C“ tend to alter (translate” label strings, so this function is genrally only useful in test programs with predetermined locales, see gtk_test_init() for more details.

Parameters

widget

Valid label or container widget.

 

label_pattern

Shell-glob pattern to match a label string.

 

Returns

a GtkLabel widget if any is found.

[transfer none]

Since: 2.14


gtk_test_find_sibling ()

GtkWidget *
gtk_test_find_sibling (GtkWidget *base_widget,
                       GType widget_type);

This function will search siblings of base_widget and siblings of its ancestors for all widgets matching widget_type . Of the matching widgets, the one that is geometrically closest to base_widget will be returned. The general purpose of this function is to find the most likely “action” widget, relative to another labeling widget. Such as finding a button or text entry widget, given its corresponding label widget.

Parameters

base_widget

Valid widget, part of a widget hierarchy

 

widget_type

Type of a aearched for sibling widget

 

Returns

a widget of type widget_type if any is found.

[transfer none]

Since: 2.14


gtk_test_find_widget ()

GtkWidget *
gtk_test_find_widget (GtkWidget *widget,
                      const gchar *label_pattern,
                      GType widget_type);

This function will search the descendants of widget for a widget of type widget_type that has a label matching label_pattern next to it. This is most useful for automated GUI testing, e.g. to find the “OK” button in a dialog and synthesize clicks on it. However see gtk_test_find_label(), gtk_test_find_sibling() and gtk_test_widget_click() for possible caveats involving the search of such widgets and synthesizing widget events.

Parameters

widget

Container widget, usually a GtkWindow.

 

label_pattern

Shell-glob pattern to match a label string.

 

widget_type

Type of a aearched for label sibling widget.

 

Returns

a valid widget if any is found or NULL.

[nullable][transfer none]

Since: 2.14


gtk_test_init ()

void
gtk_test_init (int *argcp,
               char ***argvp,
               ...);

This function is used to initialize a GTK+ test program.

It will in turn call g_test_init() and gtk_init() to properly initialize the testing framework and graphical toolkit. It’ll also set the program’s locale to “C” and prevent loading of rc files and Gtk+ modules. This is done to make tets program environments as deterministic as possible.

Like gtk_init() and g_test_init(), any known arguments will be processed and stripped from argc and argv .

Parameters

argcp

Address of the argc parameter of the main() function. Changed if any arguments were handled.

 

argvp

Address of the argv parameter of main(). Any parameters understood by g_test_init() or gtk_init() are stripped before return.

[inout][array length=argcp]

...

currently unused

 

Since: 2.14


gtk_test_list_all_types ()

const GType *
gtk_test_list_all_types (guint *n_types);

Return the type ids that have been registered after calling gtk_test_register_all_types().

Parameters

n_types

location to store number of types

 

Returns

0-terminated array of type ids.

[array length=n_types zero-terminated=1][transfer none]

Since: 2.14


gtk_test_register_all_types ()

void
gtk_test_register_all_types (void);

Force registration of all core Gtk+ and Gdk object types. This allowes to refer to any of those object types via g_type_from_name() after calling this function.

Since: 2.14


gtk_test_slider_get_value ()

double
gtk_test_slider_get_value (GtkWidget *widget);

gtk_test_slider_get_value has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

Retrive the literal adjustment value for GtkRange based widgets and spin buttons. Note that the value returned by this function is anything between the lower and upper bounds of the adjustment belonging to widget , and is not a percentage as passed in to gtk_test_slider_set_perc().

Parameters

widget

valid widget pointer.

 

Returns

gtk_adjustment_get_value (adjustment) for an adjustment belonging to widget .

Since: 2.14


gtk_test_slider_set_perc ()

void
gtk_test_slider_set_perc (GtkWidget *widget,
                          double percentage);

gtk_test_slider_set_perc has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

This function will adjust the slider position of all GtkRange based widgets, such as scrollbars or scales, it’ll also adjust spin buttons. The adjustment value of these widgets is set to a value between the lower and upper limits, according to the percentage argument.

Parameters

widget

valid widget pointer.

 

percentage

value between 0 and 100.

 

Since: 2.14


gtk_test_spin_button_click ()

gboolean
gtk_test_spin_button_click (GtkSpinButton *spinner,
                            guint button,
                            gboolean upwards);

gtk_test_spin_button_click has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

This function will generate a button click in the upwards or downwards spin button arrow areas, usually leading to an increase or decrease of spin button’s value.

Parameters

spinner

valid GtkSpinButton widget.

 

button

Number of the pointer button for the event, usually 1, 2 or 3.

 

upwards

TRUE for upwards arrow click, FALSE for downwards arrow click.

 

Returns

whether all actions neccessary for the button click simulation were carried out successfully.

Since: 2.14


gtk_test_text_get ()

gchar *
gtk_test_text_get (GtkWidget *widget);

gtk_test_text_get has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

Retrive the text string of widget if it is a GtkLabel, GtkEditable (entry and text widgets) or GtkTextView.

Parameters

widget

valid widget pointer.

 

Returns

new 0-terminated C string, needs to be released with g_free().

Since: 2.14


gtk_test_text_set ()

void
gtk_test_text_set (GtkWidget *widget,
                   const gchar *string);

gtk_test_text_set has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

Set the text string of widget to string if it is a GtkLabel, GtkEditable (entry and text widgets) or GtkTextView.

Parameters

widget

valid widget pointer.

 

string

a 0-terminated C string

 

Since: 2.14


gtk_test_widget_click ()

gboolean
gtk_test_widget_click (GtkWidget *widget,
                       guint button,
                       GdkModifierType modifiers);

gtk_test_widget_click has been deprecated since version 3.20 and should not be used in newly-written code.

This testing infrastructure is phased out in favor of reftests.

This function will generate a button click (button press and button release event) in the middle of the first GdkWindow found that belongs to widget . For windowless widgets like GtkButton (which returns FALSE from gtk_widget_get_has_window()), this will often be an input-only event window. For other widgets, this is usually widget->window. Certain caveats should be considered when using this function, in particular because the mouse pointer is warped to the button click location, see gdk_test_simulate_button() for details.

Parameters

widget

Widget to generate a button click on.

 

button

Number of the pointer button for the event, usually 1, 2 or 3.

 

modifiers

Keyboard modifiers the event is setup with.

 

Returns

whether all actions neccessary for the button click simulation were carried out successfully.

Since: 2.14


gtk_test_widget_send_key ()

gboolean
gtk_test_widget_send_key (GtkWidget *widget,
                          guint keyval,
                          GdkModifierType modifiers);

This function will generate keyboard press and release events in the middle of the first GdkWindow found that belongs to widget . For windowless widgets like GtkButton (which returns FALSE from gtk_widget_get_has_window()), this will often be an input-only event window. For other widgets, this is usually widget->window. Certain caveats should be considered when using this function, in particular because the mouse pointer is warped to the key press location, see gdk_test_simulate_key() for details.

Parameters

widget

Widget to generate a key press and release on.

 

keyval

A Gdk keyboard value.

 

modifiers

Keyboard modifiers the event is setup with.

 

Returns

whether all actions neccessary for the key event simulation were carried out successfully.

Since: 2.14


gtk_test_widget_wait_for_draw ()

void
gtk_test_widget_wait_for_draw (GtkWidget *widget);

Enters the main loop and waits for widget to be “drawn”. In this context that means it waits for the frame clock of widget to have run a full styling, layout and drawing cycle.

This function is intended to be used for syncing with actions that depend on widget relayouting or on interaction with the display server.

Parameters

widget

the widget to wait for

 

Since: 3.10

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.