it: test dnd focus change on drop
This commit is contained in:
parent
a39031d4f9
commit
c6b34550d8
16 changed files with 421 additions and 9 deletions
115
src/it/test_ifs/test_data_device.rs
Normal file
115
src/it/test_ifs/test_data_device.rs
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult,
|
||||
test_ifs::{
|
||||
test_data_offer::TestDataOffer, test_data_source::TestDataSource,
|
||||
test_surface::TestSurface,
|
||||
},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{wl_data_device::*, WlDataDeviceId, WlSurfaceId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestDataDevice {
|
||||
pub id: WlDataDeviceId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestDataDevice {
|
||||
pub fn destroy(&self) -> TestResult {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Release { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn start_drag(
|
||||
&self,
|
||||
source: &TestDataSource,
|
||||
origin: &TestSurface,
|
||||
icon: Option<&TestSurface>,
|
||||
serial: u32,
|
||||
) -> TestResult {
|
||||
self.tran.send(StartDrag {
|
||||
self_id: self.id,
|
||||
source: source.id,
|
||||
origin: origin.id,
|
||||
icon: icon.map(|i| i.id).unwrap_or(WlSurfaceId::NONE),
|
||||
serial,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn set_selection(&self, source: &TestDataSource, serial: u32) -> TestResult {
|
||||
self.tran.send(SetSelection {
|
||||
self_id: self.id,
|
||||
source: source.id,
|
||||
serial,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_data_offer(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let ev = DataOffer::parse_full(parser)?;
|
||||
let offer = Rc::new(TestDataOffer {
|
||||
id: ev.id,
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.tran.add_obj(offer.clone())?;
|
||||
offer.destroy()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_enter(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Enter::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_leave(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Leave::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_motion(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Motion::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_drop(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Drop::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_selection(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Selection::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Drop for TestDataDevice {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestDataDevice, WlDataDevice;
|
||||
|
||||
DATA_OFFER => handle_data_offer,
|
||||
ENTER => handle_enter,
|
||||
LEAVE => handle_leave,
|
||||
MOTION => handle_motion,
|
||||
DROP => handle_drop,
|
||||
SELECTION => handle_selection,
|
||||
}
|
||||
|
||||
impl TestObject for TestDataDevice {}
|
||||
57
src/it/test_ifs/test_data_device_manager.rs
Normal file
57
src/it/test_ifs/test_data_device_manager.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult,
|
||||
test_ifs::{
|
||||
test_data_device::TestDataDevice, test_data_source::TestDataSource,
|
||||
test_seat::TestSeat,
|
||||
},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
wire::{wl_data_device_manager::*, WlDataDeviceManagerId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestDataDeviceManager {
|
||||
pub id: WlDataDeviceManagerId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
}
|
||||
|
||||
impl TestDataDeviceManager {
|
||||
pub fn create_data_source(&self) -> TestResult<Rc<TestDataSource>> {
|
||||
let data_source = Rc::new(TestDataSource {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.tran.add_obj(data_source.clone())?;
|
||||
self.tran.send(CreateDataSource {
|
||||
self_id: self.id,
|
||||
id: data_source.id,
|
||||
})?;
|
||||
Ok(data_source)
|
||||
}
|
||||
|
||||
pub fn get_data_device(&self, seat: &TestSeat) -> TestResult<Rc<TestDataDevice>> {
|
||||
let data_device = Rc::new(TestDataDevice {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.tran.add_obj(data_device.clone())?;
|
||||
self.tran.send(GetDataDevice {
|
||||
self_id: self.id,
|
||||
id: data_device.id,
|
||||
seat: seat.id,
|
||||
})?;
|
||||
Ok(data_device)
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestDataDeviceManager, WlDataDeviceManager;
|
||||
}
|
||||
|
||||
impl TestObject for TestDataDeviceManager {}
|
||||
57
src/it/test_ifs/test_data_offer.rs
Normal file
57
src/it/test_ifs/test_data_offer.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{wl_data_offer::*, WlDataOfferId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestDataOffer {
|
||||
pub id: WlDataOfferId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestDataOffer {
|
||||
pub fn destroy(&self) -> TestResult {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_offer(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Offer::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_source_actions(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = SourceActions::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_action(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Action::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestDataOffer {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestDataOffer, WlDataOffer;
|
||||
|
||||
OFFER => handle_offer,
|
||||
SOURCE_ACTIONS => handle_source_actions,
|
||||
ACTION => handle_action,
|
||||
}
|
||||
|
||||
impl TestObject for TestDataOffer {}
|
||||
93
src/it/test_ifs/test_data_source.rs
Normal file
93
src/it/test_ifs/test_data_source.rs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
wire::{wl_data_source::*, WlDataSourceId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestDataSource {
|
||||
pub id: WlDataSourceId,
|
||||
pub tran: Rc<TestTransport>,
|
||||
pub destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestDataSource {
|
||||
pub fn destroy(&self) -> TestResult {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.tran.send(Destroy { self_id: self.id })?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn offer(&self, mime_type: &str) -> TestResult {
|
||||
self.tran.send(Offer {
|
||||
self_id: self.id,
|
||||
mime_type,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn set_actions(&self, actions: u32) -> TestResult {
|
||||
self.tran.send(SetActions {
|
||||
self_id: self.id,
|
||||
dnd_actions: actions,
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_target(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Target::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_send(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Send::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_cancelled(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Cancelled::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_dnd_drop_performed(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = DndDropPerformed::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_dnd_finished(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = DndFinished::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_action(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Action::parse_full(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestDataSource {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestDataSource, WlDataSource;
|
||||
|
||||
TARGET => handle_target,
|
||||
SEND => handle_send,
|
||||
CANCELLED => handle_cancelled,
|
||||
DND_DROP_PERFORMED => handle_dnd_drop_performed,
|
||||
DND_FINISHED => handle_dnd_finished,
|
||||
ACTION => handle_action,
|
||||
}
|
||||
|
||||
impl TestObject for TestDataSource {}
|
||||
|
|
@ -20,6 +20,7 @@ pub struct TestPointer {
|
|||
pub leave: TEEH<Leave>,
|
||||
pub enter: TEEH<Enter>,
|
||||
pub motion: TEEH<Motion>,
|
||||
pub button: TEEH<Button>,
|
||||
pub axis_relative_direction: TEEH<AxisRelativeDirection>,
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +68,8 @@ impl TestPointer {
|
|||
}
|
||||
|
||||
fn handle_button(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Button::parse_full(parser)?;
|
||||
let ev = Button::parse_full(parser)?;
|
||||
self.button.push(ev);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use {
|
|||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::{
|
||||
test_compositor::TestCompositor,
|
||||
test_compositor::TestCompositor, test_data_device_manager::TestDataDeviceManager,
|
||||
test_ext_foreign_toplevel_list::TestExtForeignToplevelList,
|
||||
test_jay_compositor::TestJayCompositor, test_shm::TestShm,
|
||||
test_single_pixel_buffer_manager::TestSinglePixelBufferManager,
|
||||
|
|
@ -41,6 +41,7 @@ pub struct TestRegistrySingletons {
|
|||
pub wp_viewporter: u32,
|
||||
pub xdg_activation_v1: u32,
|
||||
pub ext_foreign_toplevel_list_v1: u32,
|
||||
pub wl_data_device_manager: u32,
|
||||
}
|
||||
|
||||
pub struct TestRegistry {
|
||||
|
|
@ -57,6 +58,7 @@ pub struct TestRegistry {
|
|||
pub xdg: CloneCell<Option<Rc<TestXdgWmBase>>>,
|
||||
pub activation: CloneCell<Option<Rc<TestXdgActivation>>>,
|
||||
pub foreign_toplevel_list: CloneCell<Option<Rc<TestExtForeignToplevelList>>>,
|
||||
pub data_device_manager: CloneCell<Option<Rc<TestDataDeviceManager>>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||
}
|
||||
|
||||
|
|
@ -108,6 +110,7 @@ impl TestRegistry {
|
|||
wp_viewporter,
|
||||
xdg_activation_v1,
|
||||
ext_foreign_toplevel_list_v1,
|
||||
wl_data_device_manager,
|
||||
};
|
||||
self.singletons.set(Some(singletons.clone()));
|
||||
Ok(singletons)
|
||||
|
|
@ -240,6 +243,19 @@ impl TestRegistry {
|
|||
Ok(jc)
|
||||
}
|
||||
|
||||
pub async fn get_data_device_manager(&self) -> Result<Rc<TestDataDeviceManager>, TestError> {
|
||||
singleton!(self.data_device_manager);
|
||||
let singletons = self.get_singletons().await?;
|
||||
singleton!(self.data_device_manager);
|
||||
let jc = Rc::new(TestDataDeviceManager {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
});
|
||||
self.bind(&jc, singletons.wl_data_device_manager, 3)?;
|
||||
self.data_device_manager.set(Some(jc.clone()));
|
||||
Ok(jc)
|
||||
}
|
||||
|
||||
pub fn bind<O: TestObject>(
|
||||
&self,
|
||||
obj: &Rc<O>,
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ impl TestSeat {
|
|||
leave: Rc::new(Default::default()),
|
||||
enter: Rc::new(Default::default()),
|
||||
motion: Rc::new(Default::default()),
|
||||
button: Rc::new(Default::default()),
|
||||
axis_relative_direction: Rc::new(Default::default()),
|
||||
});
|
||||
self.tran.add_obj(pointer.clone())?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue