Expand description
Crate to test UI interactions with gtk-rs crates.
Small example:
extern crate gtk;
#[macro_use]
extern crate gtk_test;
use gtk::{prelude::ButtonExt, prelude::ContainerExt, prelude::GtkWindowExt, prelude::LabelExt, prelude::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!");
Re-exports§
Macros§
- assert_
label - To check if the widget’s label matches the given string.
- assert_
name - To check if the widget’s name 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
true
.