it: test idle timeout
This commit is contained in:
parent
b966a73682
commit
d4f49bf947
4 changed files with 43 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ use {
|
|||
drm_feedback::DrmFeedback,
|
||||
fixed::Fixed,
|
||||
gfx_api::GfxError,
|
||||
it::test_error::TestResult,
|
||||
it::{test_error::TestResult, test_utils::test_expected_event::TEEH},
|
||||
state::State,
|
||||
time::now_usec,
|
||||
utils::{
|
||||
|
|
@ -46,6 +46,7 @@ pub struct TestBackend {
|
|||
pub default_mouse: Rc<TestBackendMouse>,
|
||||
pub default_kb: Rc<TestBackendKb>,
|
||||
pub render_context_installed: Cell<bool>,
|
||||
pub idle: TEEH<bool>,
|
||||
}
|
||||
|
||||
impl TestBackend {
|
||||
|
|
@ -114,6 +115,7 @@ impl TestBackend {
|
|||
default_mouse,
|
||||
default_kb,
|
||||
render_context_installed: Cell::new(false),
|
||||
idle: Rc::new(Default::default()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +212,9 @@ impl Backend for TestBackend {
|
|||
let _ = vtnr;
|
||||
}
|
||||
|
||||
fn set_idle(&self, _idle: bool) {}
|
||||
fn set_idle(&self, idle: bool) {
|
||||
self.idle.push(idle);
|
||||
}
|
||||
|
||||
fn supports_presentation_feedback(&self) -> bool {
|
||||
true
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use {
|
|||
video::{Connector, Transform},
|
||||
Axis, Direction,
|
||||
},
|
||||
std::{cell::Cell, ops::Deref, ptr, rc::Rc},
|
||||
std::{cell::Cell, ops::Deref, ptr, rc::Rc, time::Duration},
|
||||
};
|
||||
|
||||
pub static TEST_CONFIG_ENTRY: ConfigEntry = ConfigEntry {
|
||||
|
|
@ -246,6 +246,10 @@ impl TestConfig {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn set_idle(&self, timeout: Duration) -> TestResult {
|
||||
self.send(ClientMessage::SetIdle { timeout })
|
||||
}
|
||||
|
||||
pub fn set_floating(&self, seat: SeatId, floating: bool) -> TestResult {
|
||||
self.send(ClientMessage::SetFloating {
|
||||
seat: Seat(seat.raw() as _),
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ mod t0032_data_control;
|
|||
mod t0033_float_size_memoization;
|
||||
mod t0034_workspace_restoration;
|
||||
mod t0035_scanout_feedback;
|
||||
mod t0036_idle;
|
||||
|
||||
pub trait TestCase: Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
|
|
@ -121,5 +122,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
|||
t0033_float_size_memoization,
|
||||
t0034_workspace_restoration,
|
||||
t0035_scanout_feedback,
|
||||
t0036_idle,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
30
src/it/tests/t0036_idle.rs
Normal file
30
src/it/tests/t0036_idle.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use {
|
||||
crate::it::{
|
||||
test_error::{TestErrorExt, TestResult},
|
||||
testrun::TestRun,
|
||||
},
|
||||
std::{rc::Rc, time::Duration},
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
||||
async fn test(run: Rc<TestRun>) -> TestResult {
|
||||
let ds = run.create_default_setup().await?;
|
||||
|
||||
run.cfg.set_idle(Duration::from_micros(100))?;
|
||||
|
||||
let idle = run.backend.idle.expect()?;
|
||||
tassert!(idle.next().is_err());
|
||||
|
||||
run.state.wheel.timeout(3).await?;
|
||||
|
||||
tassert_eq!(idle.next().with_context(|| "idle")?, true);
|
||||
tassert!(idle.next().is_err());
|
||||
|
||||
ds.mouse.rel(1.0, 1.0);
|
||||
run.state.eng.yield_now().await;
|
||||
|
||||
tassert_eq!(idle.next().with_context(|| "wake")?, false);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue