it: test xdg-activation
This commit is contained in:
parent
91022cd1c8
commit
6fe6b1b491
16 changed files with 239 additions and 23 deletions
|
|
@ -33,14 +33,15 @@ impl TestJayCompositor {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn take_screenshot(&self) -> Result<Dmabuf, TestError> {
|
||||
pub async fn take_screenshot(&self, include_cursor: bool) -> Result<Dmabuf, TestError> {
|
||||
let js = Rc::new(TestJayScreenshot {
|
||||
id: self.tran.id(),
|
||||
result: Cell::new(None),
|
||||
});
|
||||
self.tran.send(TakeScreenshot {
|
||||
self.tran.send(TakeScreenshot2 {
|
||||
self_id: self.id,
|
||||
id: js.id,
|
||||
include_cursor: include_cursor as _,
|
||||
})?;
|
||||
self.tran.add_obj(js.clone())?;
|
||||
self.tran.sync().await;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
test_compositor::TestCompositor, test_jay_compositor::TestJayCompositor,
|
||||
test_shm::TestShm, test_single_pixel_buffer_manager::TestSinglePixelBufferManager,
|
||||
test_subcompositor::TestSubcompositor, test_viewporter::TestViewporter,
|
||||
test_xdg_base::TestXdgWmBase,
|
||||
test_xdg_activation::TestXdgActivation, test_xdg_base::TestXdgWmBase,
|
||||
},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
|
|
@ -34,6 +34,7 @@ pub struct TestRegistrySingletons {
|
|||
pub xdg_wm_base: u32,
|
||||
pub wp_single_pixel_buffer_manager_v1: u32,
|
||||
pub wp_viewporter: u32,
|
||||
pub xdg_activation_v1: u32,
|
||||
}
|
||||
|
||||
pub struct TestRegistry {
|
||||
|
|
@ -48,6 +49,7 @@ pub struct TestRegistry {
|
|||
pub spbm: CloneCell<Option<Rc<TestSinglePixelBufferManager>>>,
|
||||
pub viewporter: CloneCell<Option<Rc<TestViewporter>>>,
|
||||
pub xdg: CloneCell<Option<Rc<TestXdgWmBase>>>,
|
||||
pub activation: CloneCell<Option<Rc<TestXdgActivation>>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +99,7 @@ impl TestRegistry {
|
|||
xdg_wm_base,
|
||||
wp_single_pixel_buffer_manager_v1,
|
||||
wp_viewporter,
|
||||
xdg_activation_v1,
|
||||
};
|
||||
self.singletons.set(Some(singletons.clone()));
|
||||
Ok(singletons)
|
||||
|
|
@ -184,6 +187,20 @@ impl TestRegistry {
|
|||
Ok(jc)
|
||||
}
|
||||
|
||||
pub async fn get_activation(&self) -> Result<Rc<TestXdgActivation>, TestError> {
|
||||
singleton!(self.activation);
|
||||
let singletons = self.get_singletons().await?;
|
||||
singleton!(self.activation);
|
||||
let jc = Rc::new(TestXdgActivation {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.bind(&jc, singletons.xdg_activation_v1, 1)?;
|
||||
self.activation.set(Some(jc.clone()));
|
||||
Ok(jc)
|
||||
}
|
||||
|
||||
pub async fn get_xdg(&self) -> Result<Rc<TestXdgWmBase>, TestError> {
|
||||
singleton!(self.xdg);
|
||||
let singletons = self.get_singletons().await?;
|
||||
|
|
|
|||
66
src/it/test_ifs/test_xdg_activation.rs
Normal file
66
src/it/test_ifs/test_xdg_activation.rs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::{TestError, TestResult},
|
||||
test_ifs::{
|
||||
test_surface::TestSurface, test_xdg_activation_token::TestXdgActivationToken,
|
||||
},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
wire::{xdg_activation_v1::*, XdgActivationV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestXdgActivation {
|
||||
pub id: XdgActivationV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestXdgActivation {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_token(&self) -> Result<String, TestError> {
|
||||
let token = Rc::new(TestXdgActivationToken {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
token: Cell::new(None),
|
||||
});
|
||||
self.tran.add_obj(token.clone())?;
|
||||
self.tran.send(GetActivationToken {
|
||||
self_id: self.id,
|
||||
id: token.id,
|
||||
})?;
|
||||
let res = token.commit().await?;
|
||||
token.destroy()?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn activate(&self, tl: &TestSurface, token: &str) -> TestResult {
|
||||
self.tran.send(Activate {
|
||||
self_id: self.id,
|
||||
token,
|
||||
surface: tl.id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestXdgActivation, XdgActivationV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestXdgActivation {}
|
||||
|
||||
impl Drop for TestXdgActivation {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
56
src/it/test_ifs/test_xdg_activation_token.rs
Normal file
56
src/it/test_ifs/test_xdg_activation_token.rs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{xdg_activation_token_v1::*, XdgActivationTokenV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestXdgActivationToken {
|
||||
pub id: XdgActivationTokenV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub token: Cell<Option<String>>,
|
||||
}
|
||||
|
||||
impl TestXdgActivationToken {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn commit(&self) -> Result<String, TestError> {
|
||||
self.tran.send(Commit { self_id: self.id })?;
|
||||
self.tran.sync().await;
|
||||
match self.token.take() {
|
||||
Some(t) => Ok(t),
|
||||
_ => bail!("Server did not send a token"),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_done(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
let ev = Done::parse_full(parser)?;
|
||||
self.token.set(Some(ev.token.to_string()));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestXdgActivationToken, XdgActivationTokenV1;
|
||||
|
||||
DONE => handle_done,
|
||||
}
|
||||
|
||||
impl TestObject for TestXdgActivationToken {}
|
||||
|
||||
impl Drop for TestXdgActivationToken {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue