Crate gtk_test [−] [src]
Crate to test UI interactions with gtk-rs crates.
Small example:
extern crate gtk; #[macro_use] extern crate gtk_test; use gtk::{ButtonExt, ContainerExt, GtkWindowExt, LabelExt, WidgetExt}; gtk::init().expect("GTK init failed"); let win = gtk::Window::new(gtk::WindowType::Toplevel); let but = gtk::Button::new(); but.set_label(""); // Otherwise, assert_label! call will fail. but.connect_clicked(|b| { b.set_label("clicked!"); }); win.add(&but); win.show_all(); win.activate_focus(); // Very important, otherwise tests will fail on OSX! assert_label!(but, ""); gtk_test::click(&but); gtk_test::wait(1000); // To be sure that GTK has updated the label's text. assert_label!(but, "clicked!");
Macros
assert_label |
To check if the widget's label matches the given string. |
assert_text |
To check if the widget's text matches the given string. |
assert_title |
To check if the widget's title matches the given string. |
observer_new |
Create a new observer for signals. |
Structs
Observer |
Used to wait for a widget's signal. |
Functions
click |
Simulate a click on a widget. |
double_click |
Simulate a double-click on a widget. |
enter_key |
Send a key event to the given widget. |
enter_keys |
Send keys event to the given widget. |
find_child_by_name |
Returns the child element which has the given name. |
find_widget_by_name |
Returns the child widget which has the given name. |
focus |
Focus on the given widget. |
key_press |
Send a key press event to the given widget. |
key_release |
Send a key release event to the given widget. |
mouse_move |
Move the mouse relative to the widget position. |
mouse_press |
Send a mouse press event to the given widget. |
mouse_release |
Send a mouse release event to the given widget. |
run_loop |
Process all pending events and then return. |
wait |
Wait for events the specified amount the milliseconds. |
wait_for_draw |
Wait for a widget to be drawn. |
wait_until_done |
Wait until the given condition returns |