Testing

Members

Static functions

createSimpleWindow
Widget createSimpleWindow(string windowTitle, string dialogText)

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.

findLabel
Widget findLabel(Widget widget, string labelPattern)

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, 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.

findSibling
Widget findSibling(Widget baseWidget, GType widgetType)

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.

findWidget
Widget findWidget(Widget widget, string labelPattern, GType widgetType)

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.

listAllTypes
GType[] listAllTypes()

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

registerAllTypes
void registerAllTypes()

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.

sliderGetValue
double sliderGetValue(Widget widget)

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().

sliderSetPerc
void sliderSetPerc(Widget widget, double percentage)

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.

spinButtonClick
bool spinButtonClick(SpinButton spinner, uint button, bool upwards)

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.

testInit
void testInit(string[] argv)

This function is used to initialize a GTK+ test program. It will in turn call testInit() and 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 the test program environments as deterministic as possible. Like init() any known arguments will be processed and stripped from and argv.

textGet
string textGet(Widget widget)

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

textSet
void textSet(Widget widget, string string_)

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

widgetClick
bool widgetClick(Widget widget, uint button, GdkModifierType modifiers)

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 gtk.Button (which returns FALSE from Widget.getHasWindow), 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.

widgetSendKey
bool widgetSendKey(Widget widget, uint 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 gtk.Button (which returns FALSE from Widget.getHasWindow), 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.

widgetWaitForDraw
void widgetWaitForDraw(Widget 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.