diff --git a/src/it/test_config.rs b/src/it/test_config.rs index 1768786a..a5e7adf9 100644 --- a/src/it/test_config.rs +++ b/src/it/test_config.rs @@ -3,6 +3,7 @@ use { backend::InputDeviceId, ifs::wl_seat::SeatId, it::test_error::{TestError, TestResult}, + tree::OutputNode, utils::{copyhashmap::CopyHashMap, stack::Stack}, }, bincode::Options, @@ -15,6 +16,7 @@ use { }, input::{InputDevice, Seat}, keyboard::{Keymap, ModifiedKeySym}, + video::Connector, Axis, Direction, }, std::{cell::Cell, ops::Deref, ptr, rc::Rc}, @@ -251,6 +253,13 @@ impl TestConfig { } } } + + pub fn set_scale(&self, output: &OutputNode, scale: f64) -> TestResult { + self.send(ClientMessage::ConnectorSetScale { + connector: Connector(output.global.connector.connector.id().raw() as _), + scale, + }) + } } impl Drop for TestConfig { diff --git a/src/it/test_ifs/test_compositor.rs b/src/it/test_ifs/test_compositor.rs index 7bfc989a..5c6162c6 100644 --- a/src/it/test_ifs/test_compositor.rs +++ b/src/it/test_ifs/test_compositor.rs @@ -34,6 +34,7 @@ impl TestCompositor { tran: self.tran.clone(), server, destroyed: Cell::new(false), + preferred_buffer_scale: Rc::new(Default::default()), }); self.tran.add_obj(surface.clone())?; Ok(surface) diff --git a/src/it/test_ifs/test_surface.rs b/src/it/test_ifs/test_surface.rs index fa05c11e..72c27524 100644 --- a/src/it/test_ifs/test_surface.rs +++ b/src/it/test_ifs/test_surface.rs @@ -3,7 +3,7 @@ use { ifs::wl_surface::WlSurface, it::{ test_error::TestError, test_object::TestObject, test_transport::TestTransport, - testrun::ParseFull, + test_utils::test_expected_event::TEEH, testrun::ParseFull, }, utils::buffd::MsgParser, wire::{wl_surface::*, WlBufferId, WlSurfaceId}, @@ -16,6 +16,7 @@ pub struct TestSurface { pub tran: Rc, pub server: Rc, pub destroyed: Cell, + pub preferred_buffer_scale: TEEH, } impl TestSurface { @@ -59,6 +60,12 @@ impl TestSurface { let _ev = Leave::parse_full(parser)?; Ok(()) } + + fn handle_preferred_buffer_scale(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> { + let ev = PreferredBufferScale::parse_full(parser)?; + self.preferred_buffer_scale.push(ev.factor); + Ok(()) + } } impl Drop for TestSurface { @@ -72,6 +79,7 @@ test_object! { ENTER => handle_enter, LEAVE => handle_leave, + PREFERRED_BUFFER_SCALE => handle_preferred_buffer_scale, } impl TestObject for TestSurface {} diff --git a/src/it/tests.rs b/src/it/tests.rs index a6931da7..c1e85851 100644 --- a/src/it/tests.rs +++ b/src/it/tests.rs @@ -46,6 +46,7 @@ mod t0017_remove_unused_ws; mod t0018_click_to_active_ws; mod t0019_natural_scrolling; mod t0020_surface_offset; +mod t0021_preferred_buffer_scale; pub trait TestCase: Sync { fn name(&self) -> &'static str; @@ -85,5 +86,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> { t0018_click_to_active_ws, t0019_natural_scrolling, t0020_surface_offset, + t0021_preferred_buffer_scale, } } diff --git a/src/it/tests/t0021_preferred_buffer_scale.rs b/src/it/tests/t0021_preferred_buffer_scale.rs new file mode 100644 index 00000000..91304116 --- /dev/null +++ b/src/it/tests/t0021_preferred_buffer_scale.rs @@ -0,0 +1,29 @@ +use { + crate::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.map2().await?; + + let scale = win1.surface.preferred_buffer_scale.expect()?; + + run.cfg.set_scale(&ds.output, 2.0)?; + + client.sync().await; + tassert_eq!(scale.next()?, 2); + + run.cfg.set_scale(&ds.output, 3.0)?; + + client.sync().await; + tassert_eq!(scale.next()?, 3); + + Ok(()) +}