it: test toplevel drag
This commit is contained in:
parent
d4f49bf947
commit
660fa92659
11 changed files with 182 additions and 4 deletions
52
src/it/test_ifs/test_toplevel_drag.rs
Normal file
52
src/it/test_ifs/test_toplevel_drag.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError, test_ifs::test_xdg_toplevel::TestXdgToplevel,
|
||||
test_object::TestObject, test_transport::TestTransport,
|
||||
},
|
||||
wire::{xdg_toplevel_drag_v1::*, XdgToplevelDragV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestToplevelDrag {
|
||||
pub id: XdgToplevelDragV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestToplevelDrag {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn attach(
|
||||
&self,
|
||||
toplevel: &TestXdgToplevel,
|
||||
x_offset: i32,
|
||||
y_offset: i32,
|
||||
) -> Result<(), TestError> {
|
||||
self.tran.send(Attach {
|
||||
self_id: self.id,
|
||||
toplevel: toplevel.core.id,
|
||||
x_offset,
|
||||
y_offset,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestToplevelDrag {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestToplevelDrag, XdgToplevelDragV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestToplevelDrag {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue