1
0
Fork 0
forked from wry/wry

it: test idle timeout

This commit is contained in:
Julian Orth 2024-04-03 16:06:35 +02:00
parent b966a73682
commit d4f49bf947
4 changed files with 43 additions and 3 deletions

View file

@ -11,7 +11,7 @@ use {
drm_feedback::DrmFeedback, drm_feedback::DrmFeedback,
fixed::Fixed, fixed::Fixed,
gfx_api::GfxError, gfx_api::GfxError,
it::test_error::TestResult, it::{test_error::TestResult, test_utils::test_expected_event::TEEH},
state::State, state::State,
time::now_usec, time::now_usec,
utils::{ utils::{
@ -46,6 +46,7 @@ pub struct TestBackend {
pub default_mouse: Rc<TestBackendMouse>, pub default_mouse: Rc<TestBackendMouse>,
pub default_kb: Rc<TestBackendKb>, pub default_kb: Rc<TestBackendKb>,
pub render_context_installed: Cell<bool>, pub render_context_installed: Cell<bool>,
pub idle: TEEH<bool>,
} }
impl TestBackend { impl TestBackend {
@ -114,6 +115,7 @@ impl TestBackend {
default_mouse, default_mouse,
default_kb, default_kb,
render_context_installed: Cell::new(false), render_context_installed: Cell::new(false),
idle: Rc::new(Default::default()),
} }
} }
@ -210,7 +212,9 @@ impl Backend for TestBackend {
let _ = vtnr; let _ = vtnr;
} }
fn set_idle(&self, _idle: bool) {} fn set_idle(&self, idle: bool) {
self.idle.push(idle);
}
fn supports_presentation_feedback(&self) -> bool { fn supports_presentation_feedback(&self) -> bool {
true true

View file

@ -19,7 +19,7 @@ use {
video::{Connector, Transform}, video::{Connector, Transform},
Axis, Direction, 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 { 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 { pub fn set_floating(&self, seat: SeatId, floating: bool) -> TestResult {
self.send(ClientMessage::SetFloating { self.send(ClientMessage::SetFloating {
seat: Seat(seat.raw() as _), seat: Seat(seat.raw() as _),

View file

@ -67,6 +67,7 @@ mod t0032_data_control;
mod t0033_float_size_memoization; mod t0033_float_size_memoization;
mod t0034_workspace_restoration; mod t0034_workspace_restoration;
mod t0035_scanout_feedback; mod t0035_scanout_feedback;
mod t0036_idle;
pub trait TestCase: Sync { pub trait TestCase: Sync {
fn name(&self) -> &'static str; fn name(&self) -> &'static str;
@ -121,5 +122,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
t0033_float_size_memoization, t0033_float_size_memoization,
t0034_workspace_restoration, t0034_workspace_restoration,
t0035_scanout_feedback, t0035_scanout_feedback,
t0036_idle,
} }
} }

View 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(())
}