Try to find text targets in tester::recorder
This commit is contained in:
parent
81d1eda7fe
commit
1923d1db1e
5 changed files with 245 additions and 59 deletions
|
|
@ -8,6 +8,7 @@ mod find;
|
|||
pub use find::{Find, FindAll};
|
||||
pub use target::Target;
|
||||
|
||||
use crate::core::Point;
|
||||
use crate::core::widget::Id;
|
||||
|
||||
pub trait Selector {
|
||||
|
|
@ -116,6 +117,21 @@ impl Selector for Id {
|
|||
}
|
||||
}
|
||||
|
||||
impl Selector for Point {
|
||||
type Output = target::Match;
|
||||
|
||||
fn select(&mut self, target: Target<'_>) -> Option<Self::Output> {
|
||||
target
|
||||
.visible_bounds()
|
||||
.is_some_and(|visible_bounds| visible_bounds.contains(*self))
|
||||
.then(|| target::Match::from_target(target))
|
||||
}
|
||||
|
||||
fn description(&self) -> String {
|
||||
format!("bounds contains {:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, T> Selector for F
|
||||
where
|
||||
F: FnMut(Target<'_>) -> Option<T>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue