1
0
Fork 0
forked from wry/wry

it: test subsurface positioning

This commit is contained in:
Julian Orth 2022-05-03 18:32:43 +02:00
parent fd027d9a5a
commit cbf539cbcc
17 changed files with 291 additions and 9 deletions

View 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 {}