autocommit 2022-05-01 17:23:55 CEST
This commit is contained in:
parent
4373ed05bf
commit
e1d5bf0e5d
39 changed files with 1772 additions and 57 deletions
45
src/it/test_ifs/test_callback.rs
Normal file
45
src/it/test_ifs/test_callback.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{wl_callback::*, WlCallbackId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestCallback {
|
||||
pub id: WlCallbackId,
|
||||
pub transport: Rc<TestTransport>,
|
||||
pub handler: Cell<Option<Box<dyn FnOnce()>>>,
|
||||
pub done: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestCallback {
|
||||
fn handle_done(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
let _ev = Done::parse_full(parser)?;
|
||||
self.dispatch();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn dispatch(&self) {
|
||||
self.done.set(true);
|
||||
if let Some(handler) = self.handler.take() {
|
||||
handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestCallback, WlCallback;
|
||||
|
||||
DONE => handle_done,
|
||||
}
|
||||
|
||||
impl TestObject for TestCallback {
|
||||
fn on_remove(&self, _transport: &TestTransport) {
|
||||
self.dispatch();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue