forge
Explore
Log in

Don't you dare go Hollow

layout/tests: Support forced test window size

Browse files at this commit

a2767041d990fa3d5512627fe757a091e02fa17cIvan MolodetskikhParent: 5bda304
src/layout/tests.rsmodified+23 -1
@@ -24,6 +24,8 @@ struct TestWindowInner {
24 bbox: Cell<Rectangle<i32, Logical>>,24 bbox: Cell<Rectangle<i32, Logical>>,
25 initial_bbox: Rectangle<i32, Logical>,25 initial_bbox: Rectangle<i32, Logical>,
26 requested_size: Cell<Option<Size<i32, Logical>>>,26 requested_size: Cell<Option<Size<i32, Logical>>>,
27+ // Emulates the window ignoring the compositor-provided size.
28+ forced_size: Cell<Option<Size<i32, Logical>>>,
27 min_size: Size<i32, Logical>,29 min_size: Size<i32, Logical>,
28 max_size: Size<i32, Logical>,30 max_size: Size<i32, Logical>,
29 pending_fullscreen: Cell<bool>,31 pending_fullscreen: Cell<bool>,
@@ -71,6 +73,7 @@ impl TestWindow {
71 bbox: Cell::new(params.bbox),73 bbox: Cell::new(params.bbox),
72 initial_bbox: params.bbox,74 initial_bbox: params.bbox,
73 requested_size: Cell::new(None),75 requested_size: Cell::new(None),
76+ forced_size: Cell::new(None),
74 min_size: params.min_max_size.0,77 min_size: params.min_max_size.0,
75 max_size: params.min_max_size.1,78 max_size: params.min_max_size.1,
76 pending_fullscreen: Cell::new(false),79 pending_fullscreen: Cell::new(false),
@@ -86,7 +89,8 @@ impl TestWindow {
86 fn communicate(&self) -> bool {89 fn communicate(&self) -> bool {
87 let mut changed = false;90 let mut changed = false;
88 91
89- if let Some(size) = self.0.requested_size.get() {92+ let size = self.0.forced_size.get().or(self.0.requested_size.get());
93+ if let Some(size) = size {
90 assert!(size.w >= 0);94 assert!(size.w >= 0);
91 assert!(size.h >= 0);95 assert!(size.h >= 0);
92 96
@@ -284,6 +288,10 @@ impl LayoutElement for TestWindow {
284 }288 }
285 }289 }
286 290
291+fn arbitrary_size() -> impl Strategy<Value = Size<i32, Logical>> {
292+ any::<(u16, u16)>().prop_map(|(w, h)| Size::from((w.max(1).into(), h.max(1).into())))
293+}
294+
287 fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> {295 fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> {
288 any::<(i16, i16, u16, u16)>().prop_map(|(x, y, w, h)| {296 any::<(i16, i16, u16, u16)>().prop_map(|(x, y, w, h)| {
289 let loc: Point<i32, _> = Point::from((x.into(), y.into()));297 let loc: Point<i32, _> = Point::from((x.into(), y.into()));
@@ -592,6 +600,12 @@ enum Op {
592 #[proptest(strategy = "prop::option::of(1..=5usize)")]600 #[proptest(strategy = "prop::option::of(1..=5usize)")]
593 new_parent_id: Option<usize>,601 new_parent_id: Option<usize>,
594 },602 },
603+ SetForcedSize {
604+ #[proptest(strategy = "1..=5usize")]
605+ id: usize,
606+ #[proptest(strategy = "proptest::option::of(arbitrary_size())")]
607+ size: Option<Size<i32, Logical>>,
608+ },
595 Communicate(#[proptest(strategy = "1..=5usize")] usize),609 Communicate(#[proptest(strategy = "1..=5usize")] usize),
596 Refresh {610 Refresh {
597 is_active: bool,611 is_active: bool,
@@ -1315,6 +1329,14 @@ impl Op {
1315 }1329 }
1316 }1330 }
1317 }1331 }
1332+ Op::SetForcedSize { id, size } => {
1333+ for (_mon, win) in layout.windows() {
1334+ if win.0.id == id {
1335+ win.0.forced_size.set(size);
1336+ return;
1337+ }
1338+ }
1339+ }
1318 Op::Communicate(id) => {1340 Op::Communicate(id) => {
1319 let mut update = false;1341 let mut update = false;
1320 1342