it: test cursor-shape protocol
This commit is contained in:
parent
9c8131e145
commit
6448a14fb1
10 changed files with 154 additions and 2 deletions
38
src/it/test_ifs/test_cursor_shape_device.rs
Normal file
38
src/it/test_ifs/test_cursor_shape_device.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{test_error::TestResult, test_object::TestObject, test_transport::TestTransport},
|
||||
wire::{wp_cursor_shape_device_v1::*, WpCursorShapeDeviceV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestCursorShapeDevice {
|
||||
pub id: WpCursorShapeDeviceV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestCursorShapeDevice {
|
||||
#[allow(dead_code)]
|
||||
pub fn destroy(&self) -> TestResult {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_shape(&self, serial: u32, shape: u32) -> TestResult {
|
||||
self.tran.send(SetShape {
|
||||
self_id: self.id,
|
||||
serial,
|
||||
shape,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestCursorShapeDevice, WpCursorShapeDeviceV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestCursorShapeDevice {}
|
||||
51
src/it/test_ifs/test_cursor_shape_manager.rs
Normal file
51
src/it/test_ifs/test_cursor_shape_manager.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult,
|
||||
test_ifs::{
|
||||
test_cursor_shape_device::TestCursorShapeDevice, test_pointer::TestPointer,
|
||||
},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
wire::{wp_cursor_shape_manager_v1::*, WpCursorShapeManagerV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestCursorShapeManager {
|
||||
pub id: WpCursorShapeManagerV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestCursorShapeManager {
|
||||
#[allow(dead_code)]
|
||||
pub fn destroy(&self) -> TestResult {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_pointer(&self, pointer: &TestPointer) -> TestResult<Rc<TestCursorShapeDevice>> {
|
||||
let obj = Rc::new(TestCursorShapeDevice {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.tran.send(GetPointer {
|
||||
self_id: self.id,
|
||||
cursor_shape_device: obj.id,
|
||||
pointer: pointer.id,
|
||||
})?;
|
||||
self.tran.add_obj(obj.clone())?;
|
||||
Ok(obj)
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestCursorShapeManager, WpCursorShapeManagerV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestCursorShapeManager {}
|
||||
|
|
@ -5,7 +5,8 @@ use {
|
|||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::{
|
||||
test_compositor::TestCompositor, test_data_device_manager::TestDataDeviceManager,
|
||||
test_compositor::TestCompositor, test_cursor_shape_manager::TestCursorShapeManager,
|
||||
test_data_device_manager::TestDataDeviceManager,
|
||||
test_ext_foreign_toplevel_list::TestExtForeignToplevelList,
|
||||
test_jay_compositor::TestJayCompositor, test_shm::TestShm,
|
||||
test_single_pixel_buffer_manager::TestSinglePixelBufferManager,
|
||||
|
|
@ -42,6 +43,7 @@ pub struct TestRegistrySingletons {
|
|||
pub xdg_activation_v1: u32,
|
||||
pub ext_foreign_toplevel_list_v1: u32,
|
||||
pub wl_data_device_manager: u32,
|
||||
pub wp_cursor_shape_manager_v1: u32,
|
||||
}
|
||||
|
||||
pub struct TestRegistry {
|
||||
|
|
@ -59,6 +61,7 @@ pub struct TestRegistry {
|
|||
pub activation: CloneCell<Option<Rc<TestXdgActivation>>>,
|
||||
pub foreign_toplevel_list: CloneCell<Option<Rc<TestExtForeignToplevelList>>>,
|
||||
pub data_device_manager: CloneCell<Option<Rc<TestDataDeviceManager>>>,
|
||||
pub cursor_shape_manager: CloneCell<Option<Rc<TestCursorShapeManager>>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +114,7 @@ impl TestRegistry {
|
|||
xdg_activation_v1,
|
||||
ext_foreign_toplevel_list_v1,
|
||||
wl_data_device_manager,
|
||||
wp_cursor_shape_manager_v1,
|
||||
};
|
||||
self.singletons.set(Some(singletons.clone()));
|
||||
Ok(singletons)
|
||||
|
|
@ -256,6 +260,20 @@ impl TestRegistry {
|
|||
Ok(jc)
|
||||
}
|
||||
|
||||
pub async fn get_cursor_shape_manager(&self) -> Result<Rc<TestCursorShapeManager>, TestError> {
|
||||
singleton!(self.cursor_shape_manager);
|
||||
let singletons = self.get_singletons().await?;
|
||||
singleton!(self.cursor_shape_manager);
|
||||
let jc = Rc::new(TestCursorShapeManager {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.bind(&jc, singletons.wp_cursor_shape_manager_v1, 1)?;
|
||||
self.cursor_shape_manager.set(Some(jc.clone()));
|
||||
Ok(jc)
|
||||
}
|
||||
|
||||
pub fn bind<O: TestObject>(
|
||||
&self,
|
||||
obj: &Rc<O>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue