it: test subsurface positioning
This commit is contained in:
parent
fd027d9a5a
commit
cbf539cbcc
17 changed files with 291 additions and 9 deletions
60
src/it/test_ifs/test_subcompositor.rs
Normal file
60
src/it/test_ifs/test_subcompositor.rs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError, test_ifs::test_subsurface::TestSubsurface,
|
||||
test_object::TestObject, test_transport::TestTransport,
|
||||
},
|
||||
wire::{wl_subcompositor::*, WlSubcompositorId, WlSurfaceId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestSubcompositor {
|
||||
pub id: WlSubcompositorId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestSubcompositor {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_subsurface(
|
||||
&self,
|
||||
surface: WlSurfaceId,
|
||||
parent: WlSurfaceId,
|
||||
) -> Result<Rc<TestSubsurface>, TestError> {
|
||||
let id = self.tran.id();
|
||||
self.tran.send(GetSubsurface {
|
||||
self_id: self.id,
|
||||
id,
|
||||
surface,
|
||||
parent,
|
||||
})?;
|
||||
self.tran.sync().await;
|
||||
let ss = Rc::new(TestSubsurface {
|
||||
id,
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
server: self.tran.get_object(id)?,
|
||||
});
|
||||
self.tran.add_obj(ss.clone())?;
|
||||
Ok(ss)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestSubcompositor {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestSubcompositor, WlSubcompositor;
|
||||
}
|
||||
|
||||
impl TestObject for TestSubcompositor {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue