Function relm::init_test
[−]
[src]
pub fn init_test<WIDGET, MSG: Clone + DisplayVariant + Send + 'static>()
-> Result<(Component<WIDGET::Model, MSG, WIDGET::Container>, WIDGET), ()> where WIDGET: Widget<MSG> + Clone + 'static, WIDGET::Model: Send
Initialize a widget for a test.
It is to be used this way: ```
extern crate gtk;
#[macro_use]
extern crate relm;
#[macro_use]
extern crate relm_derive;
use gtk::{Window, WindowType};
use relm::{RemoteRelm, Widget};
#[derive(Clone)]
struct Win {
window: Window,
}
impl Widget for Win {
type Container = Window;
type Model = ();
fn container(&self) -> &Self::Container {
&self.window
}
fn model() -> () {
()
}
fn update(&mut self, event: Msg, model: &mut Self::Model) {
}
fn view(relm: RemoteRelm, _model: &Self::Model) -> Self {
let window = Window::new(WindowType::Toplevel);
Win {
window: window,
}
}
}
#[derive(Msg)]
enum Msg {}
fn main() {
let (_component, widgets) = relm::init_test::
}
## Warning You **should** use `_component` instead of `_` to avoid dropping it too early, which will cause events to not be sent.