1
0
Fork 0
forked from wry/wry

it: test float restacking

This commit is contained in:
Julian Orth 2024-04-02 18:57:04 +02:00
parent 9703ba8794
commit 94208691b2
6 changed files with 63 additions and 6 deletions

View file

@ -7,7 +7,7 @@ use {
test_transport::TestTransport,
testrun::ParseFull,
},
tree::{ContainerNode, ToplevelNodeBase},
tree::{ContainerNode, ContainingNode, FloatNode, ToplevelNodeBase},
utils::buffd::MsgParser,
wire::{xdg_toplevel::*, XdgToplevelId},
},
@ -36,16 +36,28 @@ pub struct TestXdgToplevel {
}
impl TestXdgToplevel {
pub fn container_parent(&self) -> TestResult<Rc<ContainerNode>> {
let parent = match self.server.tl_data().parent.get() {
Some(p) => p,
pub fn parent(&self) -> TestResult<Rc<dyn ContainingNode>> {
match self.server.tl_data().parent.get() {
Some(p) => Ok(p),
_ => bail!("toplevel has no parent"),
};
}
}
pub fn container_parent(&self) -> TestResult<Rc<ContainerNode>> {
let parent = self.parent()?;
match parent.node_into_container() {
Some(p) => Ok(p),
_ => bail!("toplevel parent is not a container"),
}
}
pub fn float_parent(&self) -> TestResult<Rc<FloatNode>> {
let parent = self.parent()?;
match parent.node_into_float() {
Some(p) => Ok(p),
_ => bail!("toplevel parent is not a float"),
}
}
}
impl TestXdgToplevelCore {

View file

@ -58,6 +58,7 @@ mod t0024_foreign_toplevel_list;
mod t0025_dnd_focus_change;
mod t0026_output_transform;
mod t0027_input_region;
mod t0028_top_level_restacking;
pub trait TestCase: Sync {
fn name(&self) -> &'static str;
@ -104,5 +105,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
t0025_dnd_focus_change,
t0026_output_transform,
t0027_input_region,
t0028_top_level_restacking,
}
}

View file

@ -0,0 +1,43 @@
use {
crate::{
ifs::wl_seat::BTN_LEFT,
it::{test_error::TestResult, testrun::TestRun},
},
std::rc::Rc,
};
testcase!();
async fn test(run: Rc<TestRun>) -> TestResult {
let ds = run.create_default_setup().await?;
let client = run.create_client().await?;
let win1 = client.create_window().await?;
win1.set_color(255, 0, 0, 255);
win1.map2().await?;
run.cfg.set_floating(ds.seat.id(), true)?;
let win2 = client.create_window().await?;
win2.set_color(0, 255, 0, 255);
win2.map2().await?;
run.cfg.set_floating(ds.seat.id(), true)?;
{
let parent = win1.tl.float_parent()?;
let rect = parent.position.get();
parent.position.set(rect.at_point(100, 100));
parent.schedule_layout();
}
client.sync().await;
client.compare_screenshot("1", false).await?;
ds.move_to(110, 110);
ds.mouse.click(BTN_LEFT);
client.sync().await;
client.compare_screenshot("2", false).await?;
Ok(())
}

View file

@ -136,7 +136,7 @@ impl FloatNode {
self.schedule_render_titles();
}
fn schedule_layout(self: &Rc<Self>) {
pub fn schedule_layout(self: &Rc<Self>) {
if !self.layout_scheduled.replace(true) {
self.state.pending_float_layout.push(self.clone());
}