config: generate graphics-initialized event in the frontend
This commit is contained in:
parent
c30f4d7266
commit
5e21e00059
17 changed files with 56 additions and 29 deletions
|
|
@ -8,12 +8,12 @@ use {
|
|||
},
|
||||
compositor::TestFuture,
|
||||
fixed::Fixed,
|
||||
it::test_error::TestResult,
|
||||
render::{RenderContext, RenderError},
|
||||
state::State,
|
||||
time::Time,
|
||||
utils::{
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, oserror::OsError,
|
||||
syncqueue::SyncQueue,
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, oserror::OsError, syncqueue::SyncQueue,
|
||||
},
|
||||
video::drm::{ConnectorType, Drm},
|
||||
},
|
||||
|
|
@ -41,6 +41,7 @@ pub struct TestBackend {
|
|||
pub default_connector: Rc<TestConnector>,
|
||||
pub default_mouse: Rc<TestBackendMouse>,
|
||||
pub default_kb: Rc<TestBackendKb>,
|
||||
pub render_context_installed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl TestBackend {
|
||||
|
|
@ -92,10 +93,21 @@ impl TestBackend {
|
|||
default_connector,
|
||||
default_mouse,
|
||||
default_kb,
|
||||
render_context_installed: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn install_default(&self) {
|
||||
pub fn install_render_context(&self) -> TestResult {
|
||||
if self.render_context_installed.get() {
|
||||
return Ok(());
|
||||
}
|
||||
self.create_render_context()?;
|
||||
self.render_context_installed.set(true);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn install_default(&self) -> TestResult {
|
||||
self.install_render_context()?;
|
||||
self.state
|
||||
.backend_events
|
||||
.push(BackendEvent::NewConnector(self.default_connector.clone()));
|
||||
|
|
@ -121,6 +133,7 @@ impl TestBackend {
|
|||
self.state
|
||||
.backend_events
|
||||
.push(BackendEvent::NewInputDevice(self.default_mouse.clone()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn create_render_context(&self) -> Result<(), TestBackendError> {
|
||||
|
|
@ -175,11 +188,7 @@ impl TestBackend {
|
|||
impl Backend for TestBackend {
|
||||
fn run(self: Rc<Self>) -> SpawnedFuture<Result<(), Box<dyn std::error::Error>>> {
|
||||
let future = (self.test_future)(&self.state);
|
||||
let slf = self.clone();
|
||||
self.state.eng.spawn(async move {
|
||||
if let Err(e) = slf.create_render_context() {
|
||||
log::error!("Could not create render context: {}", ErrorFmt(e));
|
||||
}
|
||||
let future: Pin<_> = future.into();
|
||||
future.await;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ where
|
|||
srv: Cell::new(None),
|
||||
responses: Default::default(),
|
||||
invoked_shortcuts: Default::default(),
|
||||
graphics_initialized: Cell::new(false),
|
||||
});
|
||||
let old = CONFIG;
|
||||
CONFIG = tc.deref();
|
||||
|
|
@ -99,7 +100,7 @@ unsafe extern "C" fn handle_msg(data: *const u8, msg: *const u8, size: usize) {
|
|||
ServerMessage::NewConnector { .. } => {}
|
||||
ServerMessage::DelConnector { .. } => {}
|
||||
ServerMessage::TimerExpired { .. } => {}
|
||||
ServerMessage::GraphicsInitialized => {}
|
||||
ServerMessage::GraphicsInitialized => tc.graphics_initialized.set(true),
|
||||
ServerMessage::Clear => tc.clear(),
|
||||
}
|
||||
}
|
||||
|
|
@ -115,6 +116,7 @@ pub struct TestConfig {
|
|||
srv: Cell<Option<ServerData>>,
|
||||
responses: Stack<Response>,
|
||||
pub invoked_shortcuts: CopyHashMap<(SeatId, ModifiedKeySym), ()>,
|
||||
pub graphics_initialized: Cell<bool>,
|
||||
}
|
||||
|
||||
macro_rules! get_response {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ impl<T> TestExpectedEvent<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn last(&self) -> TestResult<T> {
|
||||
match self.data.events.borrow_mut().pop_back() {
|
||||
Some(t) => Ok(t),
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ impl TestRun {
|
|||
}
|
||||
|
||||
pub async fn create_default_setup(&self) -> Result<DefaultSetup, TestError> {
|
||||
self.backend.install_default();
|
||||
self.backend.install_default()?;
|
||||
let seat = self.get_seat("default")?;
|
||||
self.state.eng.yield_now().await;
|
||||
let output = match self.state.outputs.lock().values().next() {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ mod t0009_tab_focus;
|
|||
mod t0010_fullscreen_focus;
|
||||
mod t0011_set_keymap;
|
||||
mod t0012_subsurface_focus;
|
||||
mod t0013_graphics_initialized;
|
||||
|
||||
pub trait TestCase: Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
|
|
@ -68,5 +69,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
|||
t0010_fullscreen_focus,
|
||||
t0011_set_keymap,
|
||||
t0012_subsurface_focus,
|
||||
t0013_graphics_initialized,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ testcase!();
|
|||
|
||||
/// Create and map a single surface
|
||||
async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
||||
run.backend.install_default();
|
||||
run.backend.install_default()?;
|
||||
|
||||
let client = run.create_client().await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ testcase!();
|
|||
|
||||
/// Create and map two surfaces
|
||||
async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
||||
run.backend.install_default();
|
||||
run.backend.install_default()?;
|
||||
|
||||
let client = run.create_client().await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ testcase!();
|
|||
|
||||
/// Test subsurface positioning
|
||||
async fn test(run: Rc<TestRun>) -> Result<(), TestError> {
|
||||
run.backend.install_default();
|
||||
run.backend.install_default()?;
|
||||
|
||||
let seat = run.get_seat("default")?;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
|||
|
||||
run.cfg.set_fullscreen(ds.seat.id(), true)?;
|
||||
client.sync().await;
|
||||
window.map().await;
|
||||
window.map().await?;
|
||||
|
||||
ds.mouse.rel(-1000.0, -1000.0);
|
||||
|
||||
|
|
|
|||
18
src/it/tests/t0013_graphics_initialized.rs
Normal file
18
src/it/tests/t0013_graphics_initialized.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use {
|
||||
crate::it::{test_error::TestResult, testrun::TestRun},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
||||
async fn test(run: Rc<TestRun>) -> TestResult {
|
||||
run.sync().await;
|
||||
|
||||
tassert!(!run.cfg.graphics_initialized.get());
|
||||
|
||||
run.backend.install_render_context()?;
|
||||
|
||||
tassert!(run.cfg.graphics_initialized.get());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue