use compose_rust::prelude::*;
use compose_rust::protocol::{Mutation, decode_batch};
use compose_rust::{Host, LaunchBuilder, LoopMode};
fn app() -> Element {
rsx! { Text { text: "a window" } }
}
#[test]
fn fr19_3_the_window_crosses_as_the_application_asked_for_it() {
fn window_in_the_first_batch(host: &mut Host) -> Window {
let batch = host.rebuild().expect("the first tree encodes");
decode_batch(batch)
.expect("the batch did not decode")
.into_iter()
.find_map(|mutation| match mutation {
Mutation::SetWindow(window) => Some(window),
_ => None,
})
.expect(
"no window record in the first batch, so the Renderer has nothing to \
build the window from",
)
}
let mut host = Host::new(app);
assert_eq!(
window_in_the_first_batch(&mut host),
Window::new(),
"an application that asked for nothing did not get the default"
);
let asked = Window::new()
.with_chrome(Chrome::System)
.with_size(900, 640)
.with_min_size(400, 300)
.resizable(false);
LaunchBuilder::new()
.with_mode(LoopMode::Platform)
.with_window(asked)
.try_launch(app);
let mut host = Host::new(app);
assert_eq!(
window_in_the_first_batch(&mut host),
asked,
"the window crossed the boundary as something other than what was asked for"
);
}