1
0
Fork 0
forked from wry/wry

wayland: implement wl-fixes

This commit is contained in:
Julian Orth 2024-04-24 17:25:27 +02:00
parent f36993eb6e
commit b13dd08991
14 changed files with 183 additions and 3 deletions

View file

@ -25,7 +25,7 @@ use {
pub struct TestClient {
pub run: Rc<TestRun>,
pub _server: Rc<Client>,
pub server: Rc<Client>,
pub tran: Rc<TestTransport>,
pub registry: Rc<TestRegistry>,
pub jc: Rc<TestJayCompositor>,

View file

@ -49,6 +49,7 @@ pub mod test_viewport;
pub mod test_viewporter;
pub mod test_virtual_keyboard;
pub mod test_virtual_keyboard_manager;
pub mod test_wl_fixes;
pub mod test_xdg_activation;
pub mod test_xdg_activation_token;
pub mod test_xdg_base;

View file

@ -19,7 +19,8 @@ use {
test_toplevel_drag_manager::TestToplevelDragManager,
test_viewporter::TestViewporter,
test_virtual_keyboard_manager::TestVirtualKeyboardManager,
test_xdg_activation::TestXdgActivation, test_xdg_base::TestXdgWmBase,
test_wl_fixes::TestWlFixes, test_xdg_activation::TestXdgActivation,
test_xdg_base::TestXdgWmBase,
},
test_object::TestObject,
test_transport::TestTransport,
@ -58,6 +59,7 @@ pub struct TestRegistrySingletons {
pub zwp_virtual_keyboard_manager_v1: u32,
pub zwp_input_method_manager_v2: u32,
pub zwp_text_input_manager_v3: u32,
pub wl_fixes: u32,
}
pub struct TestRegistry {
@ -85,6 +87,7 @@ pub struct TestRegistry {
pub virtual_keyboard_manager: CloneCell<Option<Rc<TestVirtualKeyboardManager>>>,
pub input_method_manager: CloneCell<Option<Rc<TestInputMethodManager>>>,
pub text_input_manager: CloneCell<Option<Rc<TestTextInputManager>>>,
pub wl_fixes: CloneCell<Option<Rc<TestWlFixes>>>,
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
}
@ -156,6 +159,7 @@ impl TestRegistry {
zwp_virtual_keyboard_manager_v1,
zwp_input_method_manager_v2,
zwp_text_input_manager_v3,
wl_fixes,
};
self.singletons.set(Some(singletons.clone()));
Ok(singletons)
@ -271,6 +275,7 @@ impl TestRegistry {
1,
TestTextInputManager
);
create_singleton!(get_wl_fixes, wl_fixes, wl_fixes, 1, TestWlFixes);
pub fn bind<O: TestObject>(
&self,

View file

@ -0,0 +1,38 @@
use {
crate::{
it::{
test_error::TestResult, test_ifs::test_registry::TestRegistry, test_object::TestObject,
test_transport::TestTransport,
},
wire::{wl_fixes::*, WlFixesId},
},
std::rc::Rc,
};
pub struct TestWlFixes {
pub id: WlFixesId,
pub tran: Rc<TestTransport>,
}
impl TestWlFixes {
pub fn new(tran: &Rc<TestTransport>) -> Self {
Self {
id: tran.id(),
tran: tran.clone(),
}
}
pub fn destroy_registry(&self, registry: &TestRegistry) -> TestResult {
self.tran.send(DestroyRegistry {
self_id: self.id,
registry: registry.id,
})?;
Ok(())
}
}
test_object! {
TestWlFixes, WlFixes;
}
impl TestObject for TestWlFixes {}

View file

@ -73,6 +73,7 @@ impl TestTransport {
virtual_keyboard_manager: Default::default(),
input_method_manager: Default::default(),
text_input_manager: Default::default(),
wl_fixes: Default::default(),
seats: Default::default(),
});
self.send(wl_display::GetRegistry {

View file

@ -79,7 +79,7 @@ impl TestRun {
let client = self.state.clients.get(client_id)?;
Ok(Rc::new(TestClient {
run: self.clone(),
_server: client,
server: client,
tran,
jc,
comp: registry.get_compositor().await?,

View file

@ -74,6 +74,7 @@ mod t0039_alpha_modifier;
mod t0040_virtual_keyboard;
mod t0041_input_method;
mod t0042_toplevel_select;
mod t0043_destroy_registry;
pub trait TestCase: Sync {
fn name(&self) -> &'static str;
@ -135,5 +136,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
t0040_virtual_keyboard,
t0041_input_method,
t0042_toplevel_select,
t0043_destroy_registry,
}
}

View file

@ -0,0 +1,31 @@
use {
crate::it::{test_error::TestResult, testrun::TestRun},
std::rc::Rc,
};
testcase!();
async fn test(run: Rc<TestRun>) -> TestResult {
let client = run.create_client().await?;
let wl_fixes = client.registry.get_wl_fixes().await?;
let registry1 = client.tran.get_registry();
client.sync().await;
let before = client.server.objects.registries.len();
wl_fixes.destroy_registry(&registry1)?;
client.sync().await;
let after = client.server.objects.registries.len();
tassert_eq!(before, after + 1);
let registry2 = client.tran.get_registry();
client.sync().await;
tassert_eq!(registry1.id, registry2.id);
tassert!(registry2.globals.is_not_empty());
Ok(())
}