it: test focus moving
This commit is contained in:
parent
03b267e51f
commit
23f1aa5a31
7 changed files with 77 additions and 3 deletions
|
|
@ -106,7 +106,7 @@ impl ForkerProxy {
|
||||||
Forked::Child { .. } => {
|
Forked::Child { .. } => {
|
||||||
drop(parent);
|
drop(parent);
|
||||||
Forker::handle(pid, child)
|
Forker::handle(pid, child)
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::InputDeviceId, ifs::wl_seat::SeatId, it::test_error::TestError,
|
backend::InputDeviceId,
|
||||||
|
ifs::wl_seat::SeatId,
|
||||||
|
it::test_error::{TestError, TestResult},
|
||||||
utils::stack::Stack,
|
utils::stack::Stack,
|
||||||
},
|
},
|
||||||
isnt::std_1::primitive::IsntConstPtrExt,
|
isnt::std_1::primitive::IsntConstPtrExt,
|
||||||
|
|
@ -11,6 +13,7 @@ use {
|
||||||
ConfigEntry, VERSION,
|
ConfigEntry, VERSION,
|
||||||
},
|
},
|
||||||
input::{InputDevice, Seat},
|
input::{InputDevice, Seat},
|
||||||
|
Direction,
|
||||||
},
|
},
|
||||||
std::{cell::Cell, ops::Deref, ptr, rc::Rc},
|
std::{cell::Cell, ops::Deref, ptr, rc::Rc},
|
||||||
};
|
};
|
||||||
|
|
@ -171,6 +174,13 @@ impl TestConfig {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn focus(&self, seat: SeatId, direction: Direction) -> TestResult {
|
||||||
|
self.send(ClientMessage::Focus {
|
||||||
|
seat: Seat(seat.raw() as _),
|
||||||
|
direction,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if let Some(srv) = self.srv.take() {
|
if let Some(srv) = self.srv.take() {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ pub struct TestKeyboard {
|
||||||
pub server: CloneCell<Option<Rc<WlKeyboard>>>,
|
pub server: CloneCell<Option<Rc<WlKeyboard>>>,
|
||||||
pub destroyed: Once,
|
pub destroyed: Once,
|
||||||
pub enter: TEEH<TestEnterEvent>,
|
pub enter: TEEH<TestEnterEvent>,
|
||||||
|
pub leave: TEEH<Leave>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestKeyboard {
|
impl TestKeyboard {
|
||||||
|
|
@ -49,7 +50,8 @@ impl TestKeyboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_leave(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
fn handle_leave(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||||
let _ev = Leave::parse_full(parser)?;
|
let ev = Leave::parse_full(parser)?;
|
||||||
|
self.leave.push(ev);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ impl TestSeat {
|
||||||
server: Default::default(),
|
server: Default::default(),
|
||||||
destroyed: Default::default(),
|
destroyed: Default::default(),
|
||||||
enter: Default::default(),
|
enter: Default::default(),
|
||||||
|
leave: Default::default(),
|
||||||
});
|
});
|
||||||
self.tran.add_obj(kb.clone())?;
|
self.tran.add_obj(kb.clone())?;
|
||||||
self.tran.sync().await;
|
self.tran.sync().await;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{it::test_error::TestResult, utils::clonecell::CloneCell},
|
crate::{it::test_error::TestResult, utils::clonecell::CloneCell},
|
||||||
|
isnt::std_1::collections::IsntVecDequeExt,
|
||||||
std::{cell::RefCell, collections::VecDeque, rc::Rc},
|
std::{cell::RefCell, collections::VecDeque, rc::Rc},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -22,6 +23,13 @@ impl<T> TestExpectedEvent<T> {
|
||||||
_ => bail!("No event occurred"),
|
_ => bail!("No event occurred"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn none(&self) -> TestResult {
|
||||||
|
if self.data.events.borrow_mut().is_not_empty() {
|
||||||
|
bail!("There are unexpected events");
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TestExpectedEventHolder<T> {
|
pub struct TestExpectedEventHolder<T> {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ mod t0005_create_seat;
|
||||||
mod t0006_region;
|
mod t0006_region;
|
||||||
mod t0007_subsurface;
|
mod t0007_subsurface;
|
||||||
mod t0008_map_focus;
|
mod t0008_map_focus;
|
||||||
|
mod t0009_tab_focus;
|
||||||
|
|
||||||
pub trait TestCase: Sync {
|
pub trait TestCase: Sync {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|
@ -60,5 +61,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
||||||
t0006_region,
|
t0006_region,
|
||||||
t0007_subsurface,
|
t0007_subsurface,
|
||||||
t0008_map_focus,
|
t0008_map_focus,
|
||||||
|
t0009_tab_focus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
51
src/it/tests/t0009_tab_focus.rs
Normal file
51
src/it/tests/t0009_tab_focus.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
use {
|
||||||
|
crate::it::{
|
||||||
|
test_error::{TestError, TestErrorExt},
|
||||||
|
testrun::TestRun,
|
||||||
|
},
|
||||||
|
jay_config::Direction,
|
||||||
|
std::rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
|
testcase!();
|
||||||
|
|
||||||
|
async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
||||||
|
let ds = run.create_default_setup().await?;
|
||||||
|
ds.mouse.rel(1.0, 1.0);
|
||||||
|
|
||||||
|
let client = run.create_client().await?;
|
||||||
|
let default_seat = client.get_default_seat().await?;
|
||||||
|
|
||||||
|
let eleave = default_seat.kb.leave.expect()?;
|
||||||
|
let eenter = default_seat.kb.enter.expect()?;
|
||||||
|
|
||||||
|
let window = client.create_window().await?;
|
||||||
|
window.map().await?;
|
||||||
|
|
||||||
|
tassert!(eenter.next().is_ok());
|
||||||
|
tassert!(eleave.next().is_err());
|
||||||
|
|
||||||
|
let window2 = client.create_window().await?;
|
||||||
|
window2.map().await?;
|
||||||
|
|
||||||
|
let leave = eleave.next().with_context(|| "Did not leave")?;
|
||||||
|
let enter = eenter.next().with_context(|| "Did not enter")?;
|
||||||
|
|
||||||
|
tassert_eq!(leave.surface, window.surface.id);
|
||||||
|
tassert_eq!(enter.surface, window2.surface.id);
|
||||||
|
|
||||||
|
eenter.none().with_context(|| "Unexpected enter")?;
|
||||||
|
eleave.none().with_context(|| "Unexpected leave")?;
|
||||||
|
|
||||||
|
run.cfg.focus(ds.seat.id(), Direction::Left)?;
|
||||||
|
|
||||||
|
client.sync().await;
|
||||||
|
|
||||||
|
let leave = eleave.next().with_context(|| "Did not leave")?;
|
||||||
|
let enter = eenter.next().with_context(|| "Did not enter")?;
|
||||||
|
|
||||||
|
tassert_eq!(leave.surface, window2.surface.id);
|
||||||
|
tassert_eq!(enter.surface, window.surface.id);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue