it: test content type protocol
This commit is contained in:
parent
3b0757ee53
commit
fd056c5361
8 changed files with 149 additions and 2 deletions
|
|
@ -246,7 +246,7 @@ pub struct WlSurface {
|
|||
tearing: Cell<bool>,
|
||||
version: u32,
|
||||
pub has_content_type_manager: Cell<bool>,
|
||||
content_type: Cell<Option<ContentType>>,
|
||||
pub content_type: Cell<Option<ContentType>>,
|
||||
pub drm_feedback: CopyHashMap<ZwpLinuxDmabufFeedbackV1Id, Rc<ZwpLinuxDmabufFeedbackV1>>,
|
||||
sync_obj_surface: CloneCell<Option<Rc<WpLinuxDrmSyncobjSurfaceV1>>>,
|
||||
destroyed: Cell<bool>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
mod test_buffer;
|
||||
pub mod test_callback;
|
||||
pub mod test_compositor;
|
||||
pub mod test_content_type;
|
||||
pub mod test_content_type_manager;
|
||||
pub mod test_cursor_shape_device;
|
||||
pub mod test_cursor_shape_manager;
|
||||
pub mod test_data_device;
|
||||
|
|
|
|||
42
src/it/test_ifs/test_content_type.rs
Normal file
42
src/it/test_ifs/test_content_type.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{test_error::TestError, test_object::TestObject, test_transport::TestTransport},
|
||||
wire::{wp_content_type_v1::*, WpContentTypeV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestContentType {
|
||||
pub id: WpContentTypeV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestContentType {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_content_type(&self, content_type: u32) -> Result<(), TestError> {
|
||||
self.tran.send(SetContentType {
|
||||
self_id: self.id,
|
||||
content_type,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestContentType {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestContentType, WpContentTypeV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestContentType {}
|
||||
65
src/it/test_ifs/test_content_type_manager.rs
Normal file
65
src/it/test_ifs/test_content_type_manager.rs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::{TestError, TestResult},
|
||||
test_ifs::{test_content_type::TestContentType, test_surface::TestSurface},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
wire::{wp_content_type_manager_v1::*, WpContentTypeManagerV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestContentTypeManager {
|
||||
pub id: WpContentTypeManagerV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestContentTypeManager {
|
||||
pub fn new(tran: &Rc<TestTransport>) -> Self {
|
||||
Self {
|
||||
id: tran.id(),
|
||||
tran: tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_surface_content_type(
|
||||
&self,
|
||||
surface: &TestSurface,
|
||||
) -> TestResult<Rc<TestContentType>> {
|
||||
let obj = Rc::new(TestContentType {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.tran.add_obj(obj.clone())?;
|
||||
self.tran.send(GetSurfaceContentType {
|
||||
self_id: self.id,
|
||||
id: obj.id,
|
||||
surface: surface.id,
|
||||
})?;
|
||||
Ok(obj)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestContentTypeManager {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestContentTypeManager, WpContentTypeManagerV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestContentTypeManager {}
|
||||
|
|
@ -5,7 +5,8 @@ use {
|
|||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::{
|
||||
test_compositor::TestCompositor, test_cursor_shape_manager::TestCursorShapeManager,
|
||||
test_compositor::TestCompositor, test_content_type_manager::TestContentTypeManager,
|
||||
test_cursor_shape_manager::TestCursorShapeManager,
|
||||
test_data_device_manager::TestDataDeviceManager,
|
||||
test_ext_foreign_toplevel_list::TestExtForeignToplevelList,
|
||||
test_jay_compositor::TestJayCompositor, test_shm::TestShm,
|
||||
|
|
@ -43,6 +44,7 @@ pub struct TestRegistrySingletons {
|
|||
pub wl_data_device_manager: u32,
|
||||
pub wp_cursor_shape_manager_v1: u32,
|
||||
pub wp_linux_drm_syncobj_manager_v1: u32,
|
||||
pub wp_content_type_manager_v1: u32,
|
||||
}
|
||||
|
||||
pub struct TestRegistry {
|
||||
|
|
@ -62,6 +64,7 @@ pub struct TestRegistry {
|
|||
pub data_device_manager: CloneCell<Option<Rc<TestDataDeviceManager>>>,
|
||||
pub cursor_shape_manager: CloneCell<Option<Rc<TestCursorShapeManager>>>,
|
||||
pub syncobj_manager: CloneCell<Option<Rc<TestSyncobjManager>>>,
|
||||
pub content_type_manager: CloneCell<Option<Rc<TestContentTypeManager>>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +128,7 @@ impl TestRegistry {
|
|||
wl_data_device_manager,
|
||||
wp_cursor_shape_manager_v1,
|
||||
wp_linux_drm_syncobj_manager_v1,
|
||||
wp_content_type_manager_v1,
|
||||
};
|
||||
self.singletons.set(Some(singletons.clone()));
|
||||
Ok(singletons)
|
||||
|
|
@ -190,6 +194,13 @@ impl TestRegistry {
|
|||
1,
|
||||
TestSyncobjManager
|
||||
);
|
||||
create_singleton!(
|
||||
get_content_type_manager,
|
||||
content_type_manager,
|
||||
wp_content_type_manager_v1,
|
||||
1,
|
||||
TestContentTypeManager
|
||||
);
|
||||
|
||||
pub fn bind<O: TestObject>(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ impl TestTransport {
|
|||
data_device_manager: Default::default(),
|
||||
cursor_shape_manager: Default::default(),
|
||||
syncobj_manager: Default::default(),
|
||||
content_type_manager: Default::default(),
|
||||
seats: Default::default(),
|
||||
});
|
||||
self.send(wl_display::GetRegistry {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ mod t0028_top_level_restacking;
|
|||
mod t0029_double_click_float;
|
||||
mod t0030_cursor_shape;
|
||||
mod t0031_syncobj;
|
||||
mod t0032_content_type;
|
||||
|
||||
pub trait TestCase: Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
|
|
|
|||
25
src/it/tests/t0032_content_type.rs
Normal file
25
src/it/tests/t0032_content_type.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::wp_content_type_v1::ContentType,
|
||||
it::{test_error::TestResult, testrun::TestRun},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
||||
async fn test(run: Rc<TestRun>) -> TestResult {
|
||||
let _ds = run.create_default_setup().await?;
|
||||
|
||||
let client = run.create_client().await?;
|
||||
let surface = client.comp.create_surface().await?;
|
||||
let ctm = client.registry.get_content_type_manager().await?;
|
||||
let ct = ctm.get_surface_content_type(&surface)?;
|
||||
ct.set_content_type(2)?;
|
||||
surface.commit()?;
|
||||
client.sync().await;
|
||||
|
||||
tassert_eq!(surface.server.content_type.get(), Some(ContentType::Video));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue