1
0
Fork 0
forked from wry/wry
wry/src/it/tests/t0014_container_scroll_focus.rs

74 lines
2.1 KiB
Rust

use {
crate::{
it::{
test_error::{TestErrorExt, TestResult},
testrun::TestRun,
},
tree::ToplevelNodeBase,
},
jay_config::Axis,
std::rc::Rc,
};
testcase!();
/// Test that scrolling a mono container header activates the new window
async fn test(run: Rc<TestRun>) -> TestResult {
let ds = run.create_default_setup().await?;
ds.mouse.rel(1.0, 1.0);
let client = run.create_client().await?;
let dss = client.get_default_seat().await?;
let w_tiled = client.create_window().await?;
w_tiled.map2().await?;
let w_mono1 = client.create_window().await?;
w_mono1.map2().await?;
run.cfg.create_split(ds.seat.id(), Axis::Horizontal)?;
run.cfg.set_mono(ds.seat.id(), true)?;
let w_mono2 = client.create_window().await?;
w_mono2.map2().await?;
// current state:
// | w_tiled | [ w_mono1 | w_mono2 ] | with w_mono2 visible and active
client.sync().await;
tassert_eq!(w_tiled.tl.core.width.get(), w_mono2.tl.core.width.get());
let enters = dss.kb.enter.expect()?;
ds.mouse.abs(&ds.connector, 0.0, 0.0);
ds.mouse.abs(&ds.connector, 10.0, 500.0);
client.sync().await;
let enter = enters.next().with_context(|| "no enter event")?;
tassert_eq!(enter.surface, w_tiled.surface.id);
let mono_container = w_mono2.tl.container_parent()?;
let container_pos = mono_container.tl_data().pos.get();
let (tab_x, tab_y) = {
let tab_bar = mono_container.tab_bar.borrow();
let Some(tab_bar) = tab_bar.as_ref() else {
bail!("no tab bar");
};
let w_mono1_title = &tab_bar.entries[0];
(
container_pos.x1() + w_mono1_title.x.get() + w_mono1_title.width.get() / 2,
container_pos.y1() + tab_bar.height / 2,
)
};
ds.mouse.abs(&ds.connector, tab_x as _, tab_y as _);
client.sync().await;
tassert!(enters.next().is_err());
ds.mouse.scroll(-1);
client.sync().await;
let enter = enters.next().with_context(|| "no enter event 2")?;
tassert_eq!(enter.surface, w_mono1.surface.id);
Ok(())
}