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

pub use gtk;
pub use gtk::gdk;

Macros

To check if the widget’s label matches the given string.

To check if the widget’s name matches the given string.

To check if the widget’s text matches the given string.

To check if the widget’s title matches the given string.

Create a new observer for signals.

Structs

Used to wait for a widget’s signal.

Functions

Simulate a click on a widget.

Simulate a double-click on a widget.

Send a key event to the given widget.

Send keys event to the given widget.

Returns the child element which has the given name.

Returns the child widget which has the given name.

Focus on the given widget.

Send a key press event to the given widget.

Send a key release event to the given widget.

Move the mouse relative to the widget position.

Send a mouse press event to the given widget.

Send a mouse release event to the given widget.

Process all pending events and then return.

Wait for events the specified amount the milliseconds.

Wait for a widget to be drawn.

Wait until the given condition returns true.