-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e639d0b
commit a35bbf2
Showing
7 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use web_sys::HtmlElement; | ||
|
||
use crate::{ | ||
build_queries, | ||
error::QueryError, | ||
types::{ByRoleOptions, Matcher}, | ||
}; | ||
|
||
pub fn _query_all_by_role<M: Into<Matcher>>( | ||
_container: &HtmlElement, | ||
_alt: M, | ||
options: ByRoleOptions, | ||
) -> Result<Vec<HtmlElement>, QueryError> { | ||
if options.selected.is_some() { | ||
// TODO | ||
} | ||
|
||
Ok(vec![]) | ||
} | ||
|
||
fn get_multiple_error(_container: &HtmlElement, alt: Matcher) -> Result<String, QueryError> { | ||
Ok(format!("Found multiple elements with the alt text: {alt}")) | ||
} | ||
|
||
fn get_missing_error( | ||
_container: &HtmlElement, | ||
alt: Matcher, | ||
_options: ByRoleOptions, | ||
) -> Result<String, QueryError> { | ||
Ok(format!( | ||
"Unable to find an element with the alt text: {alt}" | ||
)) | ||
} | ||
|
||
build_queries!( | ||
_query_all_by_role, | ||
get_multiple_error, | ||
get_missing_error, | ||
role, | ||
crate::types::ByRoleOptions | ||
); | ||
|
||
pub use internal::{ | ||
find_all_by_role, find_by_role, get_all_by_role, get_by_role, query_all_by_role, query_by_role, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
mod config; | ||
mod matches; | ||
mod queries; | ||
mod suggestions; | ||
mod wait_for; | ||
|
||
pub use config::*; | ||
pub use matches::*; | ||
pub use queries::*; | ||
pub use suggestions::*; | ||
pub use wait_for::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
use regex::Regex; | ||
// use web_sys::Element; | ||
|
||
use crate::types::Matcher; | ||
|
||
#[derive(Clone, Default)] | ||
pub struct ByRoleOptionsValue { | ||
pub now: Option<isize>, | ||
pub min: Option<isize>, | ||
pub max: Option<isize>, | ||
pub text: Option<Matcher>, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub enum ByRoleOptionsCurrent { | ||
Bool(bool), | ||
String(String), | ||
} | ||
|
||
#[derive(Clone)] | ||
pub enum ByRoleOptionsName { | ||
Regex(Regex), | ||
String(String), | ||
// Fn(Box<dyn Fn(String, Element) -> bool>), | ||
} | ||
|
||
#[derive(Clone)] | ||
pub enum ByRoleOptionsDescription { | ||
Regex(Regex), | ||
String(String), | ||
// Fn(Box<dyn Fn(String, Element) -> bool>), | ||
} | ||
|
||
#[derive(Clone, Default)] | ||
pub struct ByRoleOptions { | ||
pub suggest: Option<bool>, | ||
pub hidden: Option<bool>, | ||
pub selected: Option<bool>, | ||
pub busy: Option<bool>, | ||
pub checked: Option<bool>, | ||
pub pressed: Option<bool>, | ||
pub current: Option<ByRoleOptionsCurrent>, | ||
pub expanded: Option<bool>, | ||
pub level: Option<isize>, | ||
pub value: Option<ByRoleOptionsValue>, | ||
pub query_fallbacks: Option<bool>, | ||
pub name: Option<ByRoleOptionsName>, | ||
pub description: Option<ByRoleOptionsDescription>, | ||
} | ||
|
||
impl ByRoleOptions { | ||
pub fn suggest(mut self, value: bool) -> Self { | ||
self.suggest = Some(value); | ||
self | ||
} | ||
|
||
pub fn hidden(mut self, value: bool) -> Self { | ||
self.hidden = Some(value); | ||
self | ||
} | ||
|
||
pub fn selected(mut self, value: bool) -> Self { | ||
self.selected = Some(value); | ||
self | ||
} | ||
|
||
pub fn busy(mut self, value: bool) -> Self { | ||
self.busy = Some(value); | ||
self | ||
} | ||
|
||
pub fn checked(mut self, value: bool) -> Self { | ||
self.checked = Some(value); | ||
self | ||
} | ||
|
||
pub fn pressed(mut self, value: bool) -> Self { | ||
self.pressed = Some(value); | ||
self | ||
} | ||
|
||
pub fn current(mut self, value: ByRoleOptionsCurrent) -> Self { | ||
self.current = Some(value); | ||
self | ||
} | ||
|
||
pub fn expanded(mut self, value: bool) -> Self { | ||
self.expanded = Some(value); | ||
self | ||
} | ||
|
||
pub fn level(mut self, value: isize) -> Self { | ||
self.level = Some(value); | ||
self | ||
} | ||
|
||
pub fn value(mut self, value: ByRoleOptionsValue) -> Self { | ||
self.value = Some(value); | ||
self | ||
} | ||
|
||
pub fn query_fallbacks(mut self, value: bool) -> Self { | ||
self.query_fallbacks = Some(value); | ||
self | ||
} | ||
|
||
pub fn name(mut self, value: ByRoleOptionsName) -> Self { | ||
self.name = Some(value); | ||
self | ||
} | ||
|
||
pub fn description(mut self, value: ByRoleOptionsDescription) -> Self { | ||
self.description = Some(value); | ||
self | ||
} | ||
} |