it: add test for preferred buffer scale
This commit is contained in:
parent
9cddeb964d
commit
80dead55c3
5 changed files with 50 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<TestTransport>,
|
||||
pub server: Rc<WlSurface>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub preferred_buffer_scale: TEEH<i32>,
|
||||
}
|
||||
|
||||
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 {}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
29
src/it/tests/t0021_preferred_buffer_scale.rs
Normal file
29
src/it/tests/t0021_preferred_buffer_scale.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use {
|
||||
crate::it::{test_error::TestResult, testrun::TestRun},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
||||
async fn test(run: Rc<TestRun>) -> 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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue