From 9efe9415c229e06ec27f7d4d953002631b4db4b7 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Wed, 3 Apr 2024 13:58:18 +0200 Subject: [PATCH] it: test float size memoization --- src/it/tests.rs | 2 + src/it/tests/t0033_float_size_memoization.rs | 47 ++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/it/tests/t0033_float_size_memoization.rs diff --git a/src/it/tests.rs b/src/it/tests.rs index 01fcc6b5..5fbab25a 100644 --- a/src/it/tests.rs +++ b/src/it/tests.rs @@ -64,6 +64,7 @@ mod t0030_cursor_shape; mod t0031_syncobj; mod t0032_content_type; mod t0032_data_control; +mod t0033_float_size_memoization; pub trait TestCase: Sync { fn name(&self) -> &'static str; @@ -115,5 +116,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> { t0030_cursor_shape, t0031_syncobj, t0032_data_control, + t0033_float_size_memoization, } } diff --git a/src/it/tests/t0033_float_size_memoization.rs b/src/it/tests/t0033_float_size_memoization.rs new file mode 100644 index 00000000..0c8c0b89 --- /dev/null +++ b/src/it/tests/t0033_float_size_memoization.rs @@ -0,0 +1,47 @@ +use { + crate::{ + it::{test_error::TestResult, testrun::TestRun}, + rect::Rect, + }, + std::rc::Rc, +}; + +testcase!(); + +async fn test(run: Rc) -> TestResult { + let ds = run.create_default_setup().await?; + + let client1 = run.create_client().await?; + let win1 = client1.create_window().await?; + win1.map2().await?; + + run.cfg.set_floating(ds.seat.id(), true)?; + + client1.sync().await; + let (w1, h1) = (win1.tl.core.width.get(), win1.tl.core.height.get()); + + let float = win1.tl.float_parent()?; + let pos = float.position.get(); + float + .position + .set(Rect::new_sized(pos.x1(), pos.x2(), pos.width() / 2, pos.height() / 2).unwrap()); + float.schedule_layout(); + + client1.sync().await; + let (w2, h2) = (win1.tl.core.width.get(), win1.tl.core.height.get()); + tassert!((w1, h1) != (w2, h2)); + + run.cfg.set_floating(ds.seat.id(), false)?; + + client1.sync().await; + let (w3, h3) = (win1.tl.core.width.get(), win1.tl.core.height.get()); + tassert!((w3, h3) != (w2, h2)); + + run.cfg.set_floating(ds.seat.id(), true)?; + + client1.sync().await; + let (w4, h4) = (win1.tl.core.width.get(), win1.tl.core.height.get()); + tassert!((w4, h4) == (w2, h2)); + + Ok(()) +}