1
0
Fork 0
forked from wry/wry

autocommit 2022-05-02 00:00:45 CEST

This commit is contained in:
Julian Orth 2022-05-02 00:00:45 +02:00
parent 04580c4aeb
commit 552c8a9950
8 changed files with 155 additions and 43 deletions

View file

@ -2,6 +2,7 @@ use {
crate::{
cli::screenshot::buf_to_qoi,
client::Client,
format::ARGB8888,
it::{
test_error::TestError,
test_ifs::{
@ -9,10 +10,13 @@ use {
test_registry::TestRegistry, test_shm::TestShm, test_xdg_base::TestXdgWmBase,
},
test_transport::TestTransport,
test_utils::test_window::TestWindow,
testrun::TestRun,
},
theme::Color,
utils::clonecell::CloneCell,
},
std::rc::Rc,
std::{cell::Cell, rc::Rc},
};
pub struct TestClient {
@ -27,19 +31,39 @@ pub struct TestClient {
}
impl TestClient {
#[allow(dead_code)]
pub fn error(&self, msg: &str) {
self.tran.error(msg)
}
pub async fn sync(self: &Rc<Self>) {
pub async fn sync(&self) {
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)
}
pub async fn create_window(&self) -> Result<Rc<TestWindow>, TestError> {
let surface = self.comp.create_surface().await?;
let shm = self.shm.create_pool(0)?;
let buffer = shm.create_buffer(0, 0, 0, 0, ARGB8888)?;
let xdg = self.xdg.create_xdg_surface(surface.id).await?;
let tl = xdg.create_toplevel().await?;
surface.commit();
self.sync().await;
Ok(Rc::new(TestWindow {
surface,
xdg,
tl,
shm,
buffer: CloneCell::new(buffer),
color: Cell::new(Color::from_rgba_straight(0, 0, 0, 0)),
}))
}
}
impl Drop for TestClient {