it: test natural scrolling
This commit is contained in:
parent
f562f887f0
commit
adf6d2ae2b
12 changed files with 149 additions and 2 deletions
20
src/it/test_utils/test_container_node_ext.rs
Normal file
20
src/it/test_utils/test_container_node_ext.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use {
|
||||
crate::{
|
||||
it::test_error::TestResult,
|
||||
tree::{ContainerNode, ToplevelNode},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub trait TestContainerExt {
|
||||
fn first_toplevel(&self) -> TestResult<Rc<dyn ToplevelNode>>;
|
||||
}
|
||||
|
||||
impl TestContainerExt for ContainerNode {
|
||||
fn first_toplevel(&self) -> TestResult<Rc<dyn ToplevelNode>> {
|
||||
match self.children.first() {
|
||||
None => bail!("container does not have children"),
|
||||
Some(c) => Ok(c.node.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/it/test_utils/test_ouput_node_ext.rs
Normal file
20
src/it/test_utils/test_ouput_node_ext.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use {
|
||||
crate::{
|
||||
it::test_error::TestResult,
|
||||
tree::{OutputNode, WorkspaceNode},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub trait TestOutputNodeExt {
|
||||
fn workspace(&self) -> TestResult<Rc<WorkspaceNode>>;
|
||||
}
|
||||
|
||||
impl TestOutputNodeExt for OutputNode {
|
||||
fn workspace(&self) -> TestResult<Rc<WorkspaceNode>> {
|
||||
match self.workspace.get() {
|
||||
None => bail!("Output node does not have a container"),
|
||||
Some(w) => Ok(w),
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/it/test_utils/test_toplevel_node_ext.rs
Normal file
12
src/it/test_utils/test_toplevel_node_ext.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
use crate::tree::ToplevelNode;
|
||||
|
||||
pub trait TestToplevelNodeExt {
|
||||
fn center(&self) -> (i32, i32);
|
||||
}
|
||||
|
||||
impl TestToplevelNodeExt for dyn ToplevelNode {
|
||||
fn center(&self) -> (i32, i32) {
|
||||
let rect = self.node_absolute_position();
|
||||
((rect.x1() + rect.x2()) / 2, (rect.y1() + rect.y2()) / 2)
|
||||
}
|
||||
}
|
||||
20
src/it/test_utils/test_workspace_node_ext.rs
Normal file
20
src/it/test_utils/test_workspace_node_ext.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use {
|
||||
crate::{
|
||||
it::test_error::TestResult,
|
||||
tree::{ContainerNode, WorkspaceNode},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub trait TestWorkspaceNodeExt {
|
||||
fn container(&self) -> TestResult<Rc<ContainerNode>>;
|
||||
}
|
||||
|
||||
impl TestWorkspaceNodeExt for WorkspaceNode {
|
||||
fn container(&self) -> TestResult<Rc<ContainerNode>> {
|
||||
match self.container.get() {
|
||||
None => bail!("workspace does not have a container"),
|
||||
Some(c) => Ok(c),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue