1
0
Fork 0
forked from wry/wry

it: test suspended state

This commit is contained in:
Julian Orth 2024-04-02 14:30:24 +02:00
parent 3f4386609e
commit 91022cd1c8
12 changed files with 119 additions and 33 deletions

View file

@ -193,7 +193,7 @@ impl TestRegistry {
tran: self.tran.clone(),
destroyed: Cell::new(false),
});
self.bind(&jc, singletons.xdg_wm_base, 3)?;
self.bind(&jc, singletons.xdg_wm_base, 6)?;
self.xdg.set(Some(jc.clone()));
Ok(jc)
}

View file

@ -2,8 +2,11 @@ use {
crate::{
ifs::wl_surface::xdg_surface::XdgSurface,
it::{
test_error::TestError, test_ifs::test_xdg_toplevel::TestXdgToplevel,
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
test_error::TestError,
test_ifs::test_xdg_toplevel::{TestXdgToplevel, TestXdgToplevelCore},
test_object::TestObject,
test_transport::TestTransport,
testrun::ParseFull,
},
utils::buffd::MsgParser,
wire::{xdg_surface::*, XdgSurfaceId},
@ -33,20 +36,20 @@ impl TestXdgSurface {
self_id: self.id,
id,
})?;
self.tran.sync().await;
let client = self.tran.get_client()?;
let server = client.lookup(id)?;
let tl = Rc::new(TestXdgToplevel {
let core = Rc::new(TestXdgToplevelCore {
id,
tran: self.tran.clone(),
destroyed: Cell::new(false),
server,
width: Cell::new(0),
height: Cell::new(0),
states: Default::default(),
close_requested: Cell::new(false),
});
self.tran.add_obj(tl.clone())?;
self.tran.add_obj(core.clone())?;
self.tran.sync().await;
let client = self.tran.get_client()?;
let server = client.lookup(id)?;
let tl = Rc::new(TestXdgToplevel { core, server });
Ok(tl)
}

View file

@ -18,11 +18,10 @@ use {
},
};
pub struct TestXdgToplevel {
pub struct TestXdgToplevelCore {
pub id: XdgToplevelId,
pub tran: Rc<TestTransport>,
pub destroyed: Cell<bool>,
pub server: Rc<XdgToplevel>,
pub width: Cell<i32>,
pub height: Cell<i32>,
@ -31,14 +30,12 @@ pub struct TestXdgToplevel {
pub close_requested: Cell<bool>,
}
impl TestXdgToplevel {
pub fn destroy(&self) -> Result<(), TestError> {
if !self.destroyed.replace(true) {
self.tran.send(Destroy { self_id: self.id })?;
}
Ok(())
}
pub struct TestXdgToplevel {
pub core: Rc<TestXdgToplevelCore>,
pub server: Rc<XdgToplevel>,
}
impl TestXdgToplevel {
pub fn container_parent(&self) -> TestResult<Rc<ContainerNode>> {
let parent = match self.server.tl_data().parent.get() {
Some(p) => p,
@ -49,6 +46,15 @@ impl TestXdgToplevel {
_ => bail!("toplevel parent is not a container"),
}
}
}
impl TestXdgToplevelCore {
pub fn destroy(&self) -> Result<(), TestError> {
if !self.destroyed.replace(true) {
self.tran.send(Destroy { self_id: self.id })?;
}
Ok(())
}
fn handle_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
let ev = Configure::parse_full(parser)?;
@ -68,20 +74,26 @@ impl TestXdgToplevel {
let _ev = ConfigureBounds::parse_full(parser)?;
Ok(())
}
fn handle_wm_capabilities(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
let _ev = WmCapabilities::parse_full(parser)?;
Ok(())
}
}
impl Drop for TestXdgToplevel {
impl Drop for TestXdgToplevelCore {
fn drop(&mut self) {
let _ = self.destroy();
}
}
test_object! {
TestXdgToplevel, XdgToplevel;
TestXdgToplevelCore, XdgToplevel;
CONFIGURE => handle_configure,
CLOSE => handle_close,
CONFIGURE_BOUNDS => handle_configure_bounds,
WM_CAPABILITIES => handle_wm_capabilities,
}
impl TestObject for TestXdgToplevel {}
impl TestObject for TestXdgToplevelCore {}