it: test subsurface positioning
This commit is contained in:
parent
fd027d9a5a
commit
cbf539cbcc
17 changed files with 291 additions and 9 deletions
|
|
@ -7,7 +7,8 @@ use {
|
|||
test_error::TestError,
|
||||
test_ifs::{
|
||||
test_compositor::TestCompositor, test_jay_compositor::TestJayCompositor,
|
||||
test_registry::TestRegistry, test_shm::TestShm, test_xdg_base::TestXdgWmBase,
|
||||
test_registry::TestRegistry, test_shm::TestShm,
|
||||
test_subcompositor::TestSubcompositor, test_xdg_base::TestXdgWmBase,
|
||||
},
|
||||
test_transport::TestTransport,
|
||||
test_utils::test_window::TestWindow,
|
||||
|
|
@ -26,6 +27,7 @@ pub struct TestClient {
|
|||
pub registry: Rc<TestRegistry>,
|
||||
pub jc: Rc<TestJayCompositor>,
|
||||
pub comp: Rc<TestCompositor>,
|
||||
pub sub: Rc<TestSubcompositor>,
|
||||
pub shm: Rc<TestShm>,
|
||||
pub xdg: Rc<TestXdgWmBase>,
|
||||
}
|
||||
|
|
@ -40,13 +42,35 @@ impl TestClient {
|
|||
self.tran.sync().await
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn take_screenshot(&self) -> Result<Vec<u8>, TestError> {
|
||||
let dmabuf = self.jc.take_screenshot().await?;
|
||||
let qoi = buf_to_qoi(&dmabuf);
|
||||
Ok(qoi)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn save_screenshot(&self, name: &str) -> Result<(), TestError> {
|
||||
let qoi = self.take_screenshot().await?;
|
||||
let path = format!("{}/screenshot_{}.qoi", self.run.out_dir, name);
|
||||
std::fs::write(path, qoi)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn compare_screenshot(&self, name: &str) -> Result<(), TestError> {
|
||||
let actual = self.take_screenshot().await?;
|
||||
let expected_path = format!("{}/screenshot_{}.qoi", self.run.in_dir, name);
|
||||
let expected = std::fs::read(expected_path)?;
|
||||
if actual != expected {
|
||||
let actual_out_path = format!("{}/screenshot_{}_actual.qoi", self.run.out_dir, name);
|
||||
let expected_out_path =
|
||||
format!("{}/screenshot_{}_expected.qoi", self.run.out_dir, name);
|
||||
let _ = std::fs::write(actual_out_path, actual);
|
||||
let _ = std::fs::write(expected_out_path, expected);
|
||||
bail!("Screenshots differ");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn create_window(&self) -> Result<Rc<TestWindow>, TestError> {
|
||||
let surface = self.comp.create_surface().await?;
|
||||
let shm = self.shm.create_pool(0)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue