From 94208691b230ba69c9f37ba9e92055fea1150231 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 2 Apr 2024 18:57:04 +0200 Subject: [PATCH] it: test float restacking --- src/it/test_ifs/test_xdg_toplevel.rs | 22 +++++++-- src/it/tests.rs | 2 + src/it/tests/t0028_top_level_restacking.rs | 43 ++++++++++++++++++ .../screenshot_1.qoi | Bin 0 -> 11228 bytes .../screenshot_2.qoi | Bin 0 -> 11228 bytes src/tree/float.rs | 2 +- 6 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 src/it/tests/t0028_top_level_restacking.rs create mode 100644 src/it/tests/t0028_top_level_restacking/screenshot_1.qoi create mode 100644 src/it/tests/t0028_top_level_restacking/screenshot_2.qoi diff --git a/src/it/test_ifs/test_xdg_toplevel.rs b/src/it/test_ifs/test_xdg_toplevel.rs index ca9ee1e8..5757ad73 100644 --- a/src/it/test_ifs/test_xdg_toplevel.rs +++ b/src/it/test_ifs/test_xdg_toplevel.rs @@ -7,7 +7,7 @@ use { test_transport::TestTransport, testrun::ParseFull, }, - tree::{ContainerNode, ToplevelNodeBase}, + tree::{ContainerNode, ContainingNode, FloatNode, ToplevelNodeBase}, utils::buffd::MsgParser, wire::{xdg_toplevel::*, XdgToplevelId}, }, @@ -36,16 +36,28 @@ pub struct TestXdgToplevel { } impl TestXdgToplevel { - pub fn container_parent(&self) -> TestResult> { - let parent = match self.server.tl_data().parent.get() { - Some(p) => p, + pub fn parent(&self) -> TestResult> { + match self.server.tl_data().parent.get() { + Some(p) => Ok(p), _ => bail!("toplevel has no parent"), - }; + } + } + + pub fn container_parent(&self) -> TestResult> { + let parent = self.parent()?; match parent.node_into_container() { Some(p) => Ok(p), _ => bail!("toplevel parent is not a container"), } } + + pub fn float_parent(&self) -> TestResult> { + let parent = self.parent()?; + match parent.node_into_float() { + Some(p) => Ok(p), + _ => bail!("toplevel parent is not a float"), + } + } } impl TestXdgToplevelCore { diff --git a/src/it/tests.rs b/src/it/tests.rs index 34c2a60b..018ae928 100644 --- a/src/it/tests.rs +++ b/src/it/tests.rs @@ -58,6 +58,7 @@ mod t0024_foreign_toplevel_list; mod t0025_dnd_focus_change; mod t0026_output_transform; mod t0027_input_region; +mod t0028_top_level_restacking; pub trait TestCase: Sync { fn name(&self) -> &'static str; @@ -104,5 +105,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> { t0025_dnd_focus_change, t0026_output_transform, t0027_input_region, + t0028_top_level_restacking, } } diff --git a/src/it/tests/t0028_top_level_restacking.rs b/src/it/tests/t0028_top_level_restacking.rs new file mode 100644 index 00000000..b02fefb2 --- /dev/null +++ b/src/it/tests/t0028_top_level_restacking.rs @@ -0,0 +1,43 @@ +use { + crate::{ + ifs::wl_seat::BTN_LEFT, + it::{test_error::TestResult, testrun::TestRun}, + }, + std::rc::Rc, +}; + +testcase!(); + +async fn test(run: Rc) -> TestResult { + let ds = run.create_default_setup().await?; + + let client = run.create_client().await?; + + let win1 = client.create_window().await?; + win1.set_color(255, 0, 0, 255); + win1.map2().await?; + run.cfg.set_floating(ds.seat.id(), true)?; + + let win2 = client.create_window().await?; + win2.set_color(0, 255, 0, 255); + win2.map2().await?; + run.cfg.set_floating(ds.seat.id(), true)?; + + { + let parent = win1.tl.float_parent()?; + let rect = parent.position.get(); + parent.position.set(rect.at_point(100, 100)); + parent.schedule_layout(); + } + + client.sync().await; + client.compare_screenshot("1", false).await?; + + ds.move_to(110, 110); + ds.mouse.click(BTN_LEFT); + + client.sync().await; + client.compare_screenshot("2", false).await?; + + Ok(()) +} diff --git a/src/it/tests/t0028_top_level_restacking/screenshot_1.qoi b/src/it/tests/t0028_top_level_restacking/screenshot_1.qoi new file mode 100644 index 0000000000000000000000000000000000000000..f7bf53bfb47e66ca0eb0cb80d5c67eab09895f17 GIT binary patch literal 11228 zcmXTS&rD-rU{+vYV2WU7_@@zCe*PZ=1H)e=@KpS~DH8YZh~xh=Ha12MfN%d81SF9K zM%kkwFd71*A%GSFFaFuPdqKn=nLy}E(h!<>{-J+LN=gt-x13S-9JXqb$K3AieUW#`cZF`6Jo6U1n4xFbDUjbdr- zj24fh#p7u4I9fc87LVXQ)@aY`@87?pxnVRnjOK>XqF}Tr01w2D_8Ug~4Up-f(TZ{8 zR*Zk2V04wq6#D!362@4>s2HfhF&ZudnGQfP@b@qA^XI7QA-qv?Gz3ONU^E0qLtr!n MhF=JLV}Jlg0J2guZvX%Q literal 0 HcmV?d00001 diff --git a/src/it/tests/t0028_top_level_restacking/screenshot_2.qoi b/src/it/tests/t0028_top_level_restacking/screenshot_2.qoi new file mode 100644 index 0000000000000000000000000000000000000000..b454acd32bb155d7ad0c8228081cd1b491d69a6a GIT binary patch literal 11228 zcmXTS&rD-rU{+vYV2WU7_@@zCe*PZ=1H)e=@KpS~DH8YZh~xh=Ha12MfN%d81SF9K zM%kkwFd71*A%GSFFaFuPdqKn=nLy}E(h!<>{vmOQj$6`);AV`9U6Q6K42-aZ>A(N5 zY7Zr-u_+xDlRg9wgTGI}>GB;lgbw{vQd0VR2b$E8jXY#LDhx`rbPE%3qX#J_P_oBA zhW`xM!f0+7ak&8; z?SCI352leR^!M*2&@cp8H_C*V0ayr>w!i~cqv}B6F&b9%N(Z3O{`;5s`EykD5Z)*` Y8UmvsFd71*Aut*O!!HEBF+cz#0NCX-ZvX%Q literal 0 HcmV?d00001 diff --git a/src/tree/float.rs b/src/tree/float.rs index 6cc692ca..4b8f1a5c 100644 --- a/src/tree/float.rs +++ b/src/tree/float.rs @@ -136,7 +136,7 @@ impl FloatNode { self.schedule_render_titles(); } - fn schedule_layout(self: &Rc) { + pub fn schedule_layout(self: &Rc) { if !self.layout_scheduled.replace(true) { self.state.pending_float_layout.push(self.clone()); }