it: simplify tracking of deleted objects
This commit is contained in:
parent
ae34a65efe
commit
fd027d9a5a
17 changed files with 57 additions and 154 deletions
|
|
@ -1,9 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
|
|
@ -17,7 +15,6 @@ pub struct TestCallback {
|
|||
pub tran: Rc<TestTransport>,
|
||||
pub handler: Cell<Option<Box<dyn FnOnce()>>>,
|
||||
pub done: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestCallback {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use {
|
|||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::{test_region::TestRegion, test_surface::TestSurface},
|
||||
test_object::{Deleted, TestObject},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
wire::{
|
||||
|
|
@ -17,17 +17,15 @@ use {
|
|||
pub struct TestCompositor {
|
||||
pub id: WlCompositorId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestCompositor {
|
||||
pub async fn create_surface(&self) -> Result<Rc<TestSurface>, TestError> {
|
||||
let id = self.tran.id();
|
||||
self.deleted.check()?;
|
||||
self.tran.send(CreateSurface {
|
||||
self_id: self.id,
|
||||
id,
|
||||
});
|
||||
})?;
|
||||
self.tran.sync().await;
|
||||
let client = self.tran.get_client()?;
|
||||
let server = client.lookup(id)?;
|
||||
|
|
@ -36,7 +34,6 @@ impl TestCompositor {
|
|||
tran: self.tran.clone(),
|
||||
server,
|
||||
destroyed: Cell::new(false),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.tran.add_obj(surface.clone())?;
|
||||
Ok(surface)
|
||||
|
|
@ -44,11 +41,10 @@ impl TestCompositor {
|
|||
|
||||
pub async fn create_region(&self) -> Result<Rc<TestRegion>, TestError> {
|
||||
let id = self.tran.id();
|
||||
self.deleted.check()?;
|
||||
self.tran.send(CreateRegion {
|
||||
self_id: self.id,
|
||||
id,
|
||||
});
|
||||
})?;
|
||||
self.tran.sync().await;
|
||||
let client = self.tran.get_client()?;
|
||||
let server = client.lookup(id)?;
|
||||
|
|
@ -57,7 +53,6 @@ impl TestCompositor {
|
|||
tran: self.tran.clone(),
|
||||
server,
|
||||
destroyed: Cell::new(false),
|
||||
deleted: Default::default(),
|
||||
expected: Default::default(),
|
||||
});
|
||||
self.tran.add_obj(region.clone())?;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
object::ObjectId,
|
||||
|
|
@ -16,7 +14,6 @@ use {
|
|||
pub struct TestDisplay {
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub id: WlDisplayId,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestDisplay {
|
||||
|
|
@ -38,7 +35,6 @@ impl TestDisplay {
|
|||
);
|
||||
}
|
||||
Some(obj) => {
|
||||
obj.deleted().set();
|
||||
obj.on_remove(&self.tran);
|
||||
self.tran.obj_ids.borrow_mut().release(ev.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ use {
|
|||
crate::{
|
||||
client::ClientId,
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::test_screenshot::TestJayScreenshot,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
test_error::TestError, test_ifs::test_screenshot::TestJayScreenshot,
|
||||
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{
|
||||
|
|
@ -22,14 +19,12 @@ pub struct TestJayCompositor {
|
|||
pub id: JayCompositorId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub client_id: Cell<Option<ClientId>>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestJayCompositor {
|
||||
pub async fn get_client_id(&self) -> Result<ClientId, TestError> {
|
||||
if self.client_id.get().is_none() {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(GetClientId { self_id: self.id });
|
||||
self.tran.send(GetClientId { self_id: self.id })?;
|
||||
}
|
||||
self.tran.sync().await;
|
||||
match self.client_id.get() {
|
||||
|
|
@ -42,13 +37,11 @@ impl TestJayCompositor {
|
|||
let js = Rc::new(TestJayScreenshot {
|
||||
id: self.tran.id(),
|
||||
result: Cell::new(None),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.deleted.check()?;
|
||||
self.tran.send(TakeScreenshot {
|
||||
self_id: self.id,
|
||||
id: js.id,
|
||||
});
|
||||
})?;
|
||||
self.tran.add_obj(js.clone())?;
|
||||
self.tran.sync().await;
|
||||
match js.result.take() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::wl_region::WlRegion,
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
it::{test_error::TestError, test_object::TestObject, test_transport::TestTransport},
|
||||
rect::{Rect, RegionBuilder},
|
||||
wire::{wl_region::*, WlRegionId},
|
||||
},
|
||||
|
|
@ -19,22 +15,19 @@ pub struct TestRegion {
|
|||
pub id: WlRegionId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
pub server: Rc<WlRegion>,
|
||||
pub expected: RefCell<RegionBuilder>,
|
||||
}
|
||||
|
||||
impl TestRegion {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add(&self, rect: Rect) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.expected.borrow_mut().add(rect);
|
||||
self.tran.send(Add {
|
||||
self_id: self.id,
|
||||
|
|
@ -42,12 +35,11 @@ impl TestRegion {
|
|||
y: rect.y1(),
|
||||
width: rect.width(),
|
||||
height: rect.height(),
|
||||
});
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn subtract(&self, rect: Rect) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.expected.borrow_mut().sub(rect);
|
||||
self.tran.send(Subtract {
|
||||
self_id: self.id,
|
||||
|
|
@ -55,7 +47,7 @@ impl TestRegion {
|
|||
y: rect.y1(),
|
||||
width: rect.width(),
|
||||
height: rect.height(),
|
||||
});
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
test_compositor::TestCompositor, test_jay_compositor::TestJayCompositor,
|
||||
test_shm::TestShm, test_xdg_base::TestXdgWmBase,
|
||||
},
|
||||
test_object::{Deleted, TestObject},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
|
|
@ -41,7 +41,6 @@ pub struct TestRegistry {
|
|||
pub shm: CloneCell<Option<Rc<TestShm>>>,
|
||||
pub xdg: CloneCell<Option<Rc<TestXdgWmBase>>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
macro_rules! singleton {
|
||||
|
|
@ -100,7 +99,6 @@ impl TestRegistry {
|
|||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
client_id: Default::default(),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.bind(&jc, singletons.jay_compositor, 1)?;
|
||||
self.jay_compositor.set(Some(jc.clone()));
|
||||
|
|
@ -114,7 +112,6 @@ impl TestRegistry {
|
|||
let jc = Rc::new(TestCompositor {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.bind(&jc, singletons.wl_compositor, 4)?;
|
||||
self.compositor.set(Some(jc.clone()));
|
||||
|
|
@ -130,7 +127,6 @@ impl TestRegistry {
|
|||
tran: self.tran.clone(),
|
||||
formats: Default::default(),
|
||||
formats_awaited: Cell::new(false),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.bind(&jc, singletons.wl_shm, 1)?;
|
||||
self.shm.set(Some(jc.clone()));
|
||||
|
|
@ -145,7 +141,6 @@ impl TestRegistry {
|
|||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.bind(&jc, singletons.xdg_wm_base, 3)?;
|
||||
self.xdg.set(Some(jc.clone()));
|
||||
|
|
@ -158,14 +153,13 @@ impl TestRegistry {
|
|||
name: u32,
|
||||
version: u32,
|
||||
) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Bind {
|
||||
self_id: self.id,
|
||||
name,
|
||||
interface: obj.interface().name(),
|
||||
version,
|
||||
id: obj.id().into(),
|
||||
});
|
||||
})?;
|
||||
self.tran.add_obj(obj.clone())?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_object::{Deleted, TestObject},
|
||||
testrun::ParseFull,
|
||||
},
|
||||
it::{test_error::TestError, test_object::TestObject, testrun::ParseFull},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{jay_screenshot::*, JayScreenshotId},
|
||||
},
|
||||
|
|
@ -14,7 +10,6 @@ use {
|
|||
pub struct TestJayScreenshot {
|
||||
pub id: JayScreenshotId,
|
||||
pub result: Cell<Option<Result<Dmabuf, String>>>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestJayScreenshot {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::test_shm_pool::TestShmPool,
|
||||
test_mem::TestMem,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
test_error::TestError, test_ifs::test_shm_pool::TestShmPool, test_mem::TestMem,
|
||||
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
|
||||
},
|
||||
utils::{buffd::MsgParser, clonecell::CloneCell, copyhashmap::CopyHashMap},
|
||||
wire::{wl_shm::*, WlShmId},
|
||||
|
|
@ -19,7 +15,6 @@ pub struct TestShm {
|
|||
pub tran: Rc<TestTransport>,
|
||||
pub formats: CopyHashMap<u32, ()>,
|
||||
pub formats_awaited: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestShm {
|
||||
|
|
@ -37,15 +32,13 @@ impl TestShm {
|
|||
tran: self.tran.clone(),
|
||||
mem: CloneCell::new(mem.clone()),
|
||||
destroyed: Cell::new(false),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.deleted.check()?;
|
||||
self.tran.send(CreatePool {
|
||||
self_id: self.id,
|
||||
id: pool.id,
|
||||
fd: mem.fd.clone(),
|
||||
size: size as _,
|
||||
});
|
||||
})?;
|
||||
self.tran.add_obj(pool.clone())?;
|
||||
Ok(pool)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_mem::TestMem,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
test_error::TestError, test_mem::TestMem, test_object::TestObject,
|
||||
test_transport::TestTransport, testrun::ParseFull,
|
||||
},
|
||||
theme::Color,
|
||||
utils::{buffd::MsgParser, windows::WindowsExt},
|
||||
|
|
@ -25,7 +22,6 @@ pub struct TestShmBuffer {
|
|||
pub mem: Rc<TestMem>,
|
||||
pub released: Cell<bool>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestShmBuffer {
|
||||
|
|
@ -43,8 +39,7 @@ impl TestShmBuffer {
|
|||
if self.destroyed.replace(true) {
|
||||
return Ok(());
|
||||
}
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ use {
|
|||
crate::{
|
||||
format::Format,
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::test_shm_buffer::TestShmBuffer,
|
||||
test_mem::TestMem,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
test_error::TestError, test_ifs::test_shm_buffer::TestShmBuffer, test_mem::TestMem,
|
||||
test_object::TestObject, test_transport::TestTransport,
|
||||
},
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{wl_shm_pool::*, WlShmPoolId},
|
||||
|
|
@ -19,7 +16,6 @@ pub struct TestShmPool {
|
|||
pub tran: Rc<TestTransport>,
|
||||
pub mem: CloneCell<Rc<TestMem>>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestShmPool {
|
||||
|
|
@ -45,10 +41,8 @@ impl TestShmPool {
|
|||
mem,
|
||||
released: Cell::new(true),
|
||||
destroyed: Cell::new(false),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.tran.add_obj(buffer.clone())?;
|
||||
self.deleted.check()?;
|
||||
self.tran.send(CreateBuffer {
|
||||
self_id: self.id,
|
||||
id: buffer.id,
|
||||
|
|
@ -57,18 +51,17 @@ impl TestShmPool {
|
|||
height,
|
||||
stride,
|
||||
format: format.wl_id.unwrap_or(format.drm),
|
||||
});
|
||||
})?;
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
pub fn resize(&self, size: usize) -> Result<(), TestError> {
|
||||
let mem = self.mem.get().grow(size)?;
|
||||
self.mem.set(mem);
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Resize {
|
||||
self_id: self.id,
|
||||
size: size as _,
|
||||
});
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -76,8 +69,7 @@ impl TestShmPool {
|
|||
if self.destroyed.replace(true) {
|
||||
return Ok(());
|
||||
}
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ use {
|
|||
crate::{
|
||||
ifs::wl_surface::WlSurface,
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
|
|
@ -18,32 +16,28 @@ pub struct TestSurface {
|
|||
pub tran: Rc<TestTransport>,
|
||||
pub server: Rc<WlSurface>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestSurface {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn attach(&self, buffer_id: WlBufferId) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Attach {
|
||||
self_id: self.id,
|
||||
buffer: buffer_id,
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn commit(&self) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Commit { self_id: self.id });
|
||||
self.tran.send(Commit { self_id: self.id })?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::test_xdg_surface::TestXdgSurface,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
test_error::TestError, test_ifs::test_xdg_surface::TestXdgSurface,
|
||||
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{xdg_wm_base::*, WlSurfaceId, XdgWmBaseId},
|
||||
|
|
@ -17,14 +14,12 @@ pub struct TestXdgWmBase {
|
|||
pub id: XdgWmBaseId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestXdgWmBase {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -34,12 +29,11 @@ impl TestXdgWmBase {
|
|||
surface: WlSurfaceId,
|
||||
) -> Result<Rc<TestXdgSurface>, TestError> {
|
||||
let id = self.tran.id();
|
||||
self.deleted.check()?;
|
||||
self.tran.send(GetXdgSurface {
|
||||
self_id: self.id,
|
||||
id,
|
||||
surface,
|
||||
});
|
||||
})?;
|
||||
self.tran.sync().await;
|
||||
let client = self.tran.get_client()?;
|
||||
let server = client.lookup(id)?;
|
||||
|
|
@ -49,7 +43,6 @@ impl TestXdgWmBase {
|
|||
server,
|
||||
destroyed: Cell::new(false),
|
||||
last_serial: Cell::new(0),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.tran.add_obj(xdg.clone())?;
|
||||
Ok(xdg)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ use {
|
|||
crate::{
|
||||
ifs::wl_surface::xdg_surface::XdgSurface,
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::test_xdg_toplevel::TestXdgToplevel,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
test_error::TestError, test_ifs::test_xdg_toplevel::TestXdgToplevel,
|
||||
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{xdg_surface::*, XdgSurfaceId},
|
||||
|
|
@ -20,25 +17,22 @@ pub struct TestXdgSurface {
|
|||
pub server: Rc<XdgSurface>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub last_serial: Cell<u32>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestXdgSurface {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn create_toplevel(&self) -> Result<Rc<TestXdgToplevel>, TestError> {
|
||||
let id = self.tran.id();
|
||||
self.deleted.check()?;
|
||||
self.tran.send(GetToplevel {
|
||||
self_id: self.id,
|
||||
id,
|
||||
});
|
||||
})?;
|
||||
self.tran.sync().await;
|
||||
let client = self.tran.get_client()?;
|
||||
let server = client.lookup(id)?;
|
||||
|
|
@ -47,7 +41,6 @@ impl TestXdgSurface {
|
|||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
server,
|
||||
deleted: Default::default(),
|
||||
width: Cell::new(0),
|
||||
height: Cell::new(0),
|
||||
states: Default::default(),
|
||||
|
|
@ -58,11 +51,10 @@ impl TestXdgSurface {
|
|||
}
|
||||
|
||||
pub fn ack_configure(&self, serial: u32) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(AckConfigure {
|
||||
self_id: self.id,
|
||||
serial,
|
||||
});
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ use {
|
|||
crate::{
|
||||
ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel,
|
||||
it::{
|
||||
test_error::TestError,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
|
|
@ -22,7 +20,6 @@ pub struct TestXdgToplevel {
|
|||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub server: Rc<XdgToplevel>,
|
||||
pub deleted: Deleted,
|
||||
|
||||
pub width: Cell<i32>,
|
||||
pub height: Cell<i32>,
|
||||
|
|
@ -34,8 +31,7 @@ pub struct TestXdgToplevel {
|
|||
impl TestXdgToplevel {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
object::{Interface, ObjectId},
|
||||
utils::buffd::MsgParser,
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
macro_rules! test_object {
|
||||
|
|
@ -14,10 +14,6 @@ macro_rules! test_object {
|
|||
self.id.into()
|
||||
}
|
||||
|
||||
fn deleted(&self) -> &Deleted {
|
||||
&self.deleted
|
||||
}
|
||||
|
||||
#[allow(unused_variables, unreachable_code)]
|
||||
fn handle_request(
|
||||
self: std::rc::Rc<Self>,
|
||||
|
|
@ -41,25 +37,8 @@ macro_rules! test_object {
|
|||
};
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Deleted(Cell<bool>);
|
||||
|
||||
impl Deleted {
|
||||
pub fn set(&self) {
|
||||
self.0.set(true);
|
||||
}
|
||||
|
||||
pub fn check(&self) -> Result<(), TestError> {
|
||||
match self.0.get() {
|
||||
true => bail!("Object has already been deleted"),
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TestObjectBase: 'static {
|
||||
fn id(&self) -> ObjectId;
|
||||
fn deleted(&self) -> &Deleted;
|
||||
fn handle_request(
|
||||
self: Rc<Self>,
|
||||
request: u32,
|
||||
|
|
|
|||
|
|
@ -55,12 +55,12 @@ impl TestTransport {
|
|||
shm: Default::default(),
|
||||
xdg: Default::default(),
|
||||
seats: Default::default(),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.send(wl_display::GetRegistry {
|
||||
self_id: WL_DISPLAY_ID,
|
||||
registry: reg.id,
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
let _ = self.add_obj(reg.clone());
|
||||
reg
|
||||
}
|
||||
|
|
@ -98,12 +98,12 @@ impl TestTransport {
|
|||
tran: self.clone(),
|
||||
handler: Cell::new(None),
|
||||
done: Cell::new(self.killed.get()),
|
||||
deleted: Default::default(),
|
||||
});
|
||||
self.send(wl_display::Sync {
|
||||
self_id: WL_DISPLAY_ID,
|
||||
callback: cb.id,
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
let _ = self.add_obj(cb.clone());
|
||||
futures_util::future::poll_fn(move |ctx| {
|
||||
if cb.done.get() {
|
||||
|
|
@ -147,9 +147,16 @@ impl TestTransport {
|
|||
));
|
||||
}
|
||||
|
||||
pub fn send<M: EventFormatter>(&self, msg: M) {
|
||||
pub fn send<M: EventFormatter>(&self, msg: M) -> Result<(), TestError> {
|
||||
if self.killed.get() {
|
||||
return;
|
||||
return Ok(());
|
||||
}
|
||||
let obj = match self.objects.get(&msg.id()) {
|
||||
Some(obj) => obj,
|
||||
_ => bail!("Object with id {} has already been deleted", msg.id()),
|
||||
};
|
||||
if obj.interface().name() != msg.interface().name() {
|
||||
bail!("Object with id {} has an incompatible interface", msg.id());
|
||||
}
|
||||
let mut fds = vec![];
|
||||
let mut swapchain = self.swapchain.borrow_mut();
|
||||
|
|
@ -160,6 +167,7 @@ impl TestTransport {
|
|||
swapchain.commit();
|
||||
}
|
||||
self.flush_request.trigger();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ impl TestRun {
|
|||
tran.add_obj(Rc::new(TestDisplay {
|
||||
tran: tran.clone(),
|
||||
id: WL_DISPLAY_ID,
|
||||
deleted: Default::default(),
|
||||
}))?;
|
||||
tran.init();
|
||||
let registry = tran.get_registry();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue