From 397f5e126e05c1ebe7cbaa03c4235ae64eb45a41 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 7 Apr 2022 14:30:46 +0000 Subject: [PATCH] state: Add sizing unit test --- src/outputs.rs | 4 ++-- src/state.rs | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/outputs.rs b/src/outputs.rs index 22de38c5..a6a8944d 100644 --- a/src/outputs.rs +++ b/src/outputs.rs @@ -313,8 +313,8 @@ pub type PixelSize = Size; /// wl_output mode #[derive(Clone, Copy, Debug)] pub struct Mode { - width: i32, - height: i32, + pub width: i32, + pub height: i32, } #[derive(Clone, Copy, Debug)] diff --git a/src/state.rs b/src/state.rs index f3fbe91a..d5d4437a 100644 --- a/src/state.rs +++ b/src/state.rs @@ -566,4 +566,29 @@ pub mod test { ); } + + #[test] + fn size_l5() { + use crate::outputs::{Mode, Geometry, c, Size}; + assert_eq!( + Application::get_preferred_height(&OutputState { + current_mode: Some(Mode { + width: 720, + height: 1440, + }), + geometry: Some(Geometry{ + transform: c::Transform::Normal, + phys_size: Size { + width: Some(Millimeter(65)), + height: Some(Millimeter(130)), + }, + }), + scale: 2, + }), + Some(PixelSize { + scale_factor: 2, + pixels: 420, + }), + ); + } }