gtk-rs / gtk3-rs

Rust bindings for GTK 3
https://gtk-rs.org
MIT License
508 stars 90 forks source link

[HELP] How can I show the ui inside the test module? #754

Closed ski0090 closed 1 year ago

ski0090 commented 2 years ago
#[cfg(test)]
mod test {
    fn build_ui(app: &gtk::Application) {
        let window = gtk::ApplicationWindow::new(app);
        window.set_title("Widget test");
        window.set_border_width(10);
        window.set_position(gtk::WindowPosition::Center);
        window.set_default_size(350, 70);
        window.add(&gtk::Button::with_label("hello"));
        window.show_all();
    }

    #[test]
    fn main() {
        let application = gtk::Application::new(Some("com.playerbar.test"), Default::default());
        application.connect_activate(build_ui);
        application.run();
    }
}
ski0090 commented 2 years ago

If you want to partially test your ui inside a bin crate, how do you test it?

|-- some_view.rs <-test only this view
`-- main.rs