it: test surface input region
This commit is contained in:
parent
221a398abe
commit
9703ba8794
6 changed files with 68 additions and 2 deletions
|
|
@ -1019,6 +1019,7 @@ impl WlSurface {
|
|||
{
|
||||
if let Some(region) = pending.input_region.take() {
|
||||
self.input_region.set(region);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
if let Some(region) = pending.opaque_region.take() {
|
||||
self.opaque_region.set(region);
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ impl TestClient {
|
|||
self.run.state.eng.yield_now().await;
|
||||
self.run.sync().await;
|
||||
self.tran.sync().await;
|
||||
self.run.state.eng.yield_now().await;
|
||||
}
|
||||
|
||||
pub async fn take_screenshot(&self, include_cursor: bool) -> Result<Vec<u8>, TestError> {
|
||||
|
|
|
|||
|
|
@ -246,6 +246,13 @@ impl TestConfig {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn set_floating(&self, seat: SeatId, floating: bool) -> TestResult {
|
||||
self.send(ClientMessage::SetFloating {
|
||||
seat: Seat(seat.raw() as _),
|
||||
floating,
|
||||
})
|
||||
}
|
||||
|
||||
fn clear(&self) {
|
||||
unsafe {
|
||||
if let Some(srv) = self.srv.take() {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,12 @@ use {
|
|||
crate::{
|
||||
ifs::wl_surface::WlSurface,
|
||||
it::{
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
test_utils::test_expected_event::TEEH, testrun::ParseFull,
|
||||
test_error::{TestError, TestResult},
|
||||
test_ifs::test_region::TestRegion,
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
test_utils::test_expected_event::TEEH,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{wl_surface::*, WlBufferId, WlSurfaceId},
|
||||
|
|
@ -47,6 +51,14 @@ impl TestSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_input_region(&self, region: &TestRegion) -> TestResult {
|
||||
self.tran.send(SetInputRegion {
|
||||
self_id: self.id,
|
||||
region: region.id,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn commit(&self) -> Result<(), TestError> {
|
||||
self.tran.send(Commit { self_id: self.id })?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ mod t0023_xdg_activation;
|
|||
mod t0024_foreign_toplevel_list;
|
||||
mod t0025_dnd_focus_change;
|
||||
mod t0026_output_transform;
|
||||
mod t0027_input_region;
|
||||
|
||||
pub trait TestCase: Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
|
|
@ -102,5 +103,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
|||
t0024_foreign_toplevel_list,
|
||||
t0025_dnd_focus_change,
|
||||
t0026_output_transform,
|
||||
t0027_input_region,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
43
src/it/tests/t0027_input_region.rs
Normal file
43
src/it/tests/t0027_input_region.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{test_error::TestResult, test_utils::test_rect_ext::TestRectExt, testrun::TestRun},
|
||||
tree::Node,
|
||||
},
|
||||
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.set_color(255, 0, 0, 255);
|
||||
win1.map2().await?;
|
||||
let win2 = client.create_window().await?;
|
||||
win2.set_color(0, 255, 0, 255);
|
||||
win2.map2().await?;
|
||||
|
||||
client.sync().await;
|
||||
let (x, y) = win2.tl.server.node_absolute_position().center();
|
||||
ds.move_to(x, y);
|
||||
client.sync().await;
|
||||
run.cfg.set_floating(ds.seat.id(), true)?;
|
||||
client.sync().await;
|
||||
let (x, y) = win2.tl.server.node_absolute_position().center();
|
||||
ds.move_to(x, y);
|
||||
win2.map2().await?;
|
||||
|
||||
let seat = client.get_default_seat().await?;
|
||||
let enter = seat.pointer.enter.expect()?;
|
||||
|
||||
let region = client.comp.create_region().await?;
|
||||
win2.surface.set_input_region(®ion)?;
|
||||
win2.surface.commit()?;
|
||||
client.sync().await;
|
||||
|
||||
tassert_eq!(enter.next()?.surface, win1.surface.id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue