From d09d5d45ae4697eef277dfe30756b91c7d802a94 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 3 Dec 2024 22:03:06 +0100 Subject: Draft `iced_test` crate and test `todos` example --- test/src/selector.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/src/selector.rs (limited to 'test/src/selector.rs') diff --git a/test/src/selector.rs b/test/src/selector.rs new file mode 100644 index 00000000..54faa1a9 --- /dev/null +++ b/test/src/selector.rs @@ -0,0 +1,24 @@ +use crate::core::text; +use crate::core::widget; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Selector { + Id(widget::Id), + Text(text::Fragment<'static>), +} + +impl From for Selector { + fn from(id: widget::Id) -> Self { + Self::Id(id) + } +} + +impl From<&'static str> for Selector { + fn from(id: &'static str) -> Self { + Self::Id(widget::Id::new(id)) + } +} + +pub fn text(fragment: impl text::IntoFragment<'static>) -> Selector { + Selector::Text(fragment.into_fragment()) +} -- cgit From 5220a064c5054e872fd2f8922aa83838bf066949 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 17 Dec 2024 04:13:19 +0100 Subject: Write documentation for `iced_test` --- test/src/selector.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/src/selector.rs') diff --git a/test/src/selector.rs b/test/src/selector.rs index 54faa1a9..7b8dcb7e 100644 --- a/test/src/selector.rs +++ b/test/src/selector.rs @@ -1,9 +1,13 @@ +//! Select widgets of a user interface. use crate::core::text; use crate::core::widget; +/// A selector describes a strategy to find a certain widget in a user interface. #[derive(Debug, Clone, PartialEq, Eq)] pub enum Selector { + /// Find the widget with the given [`widget::Id`]. Id(widget::Id), + /// Find the widget containing the given [`text::Fragment`]. Text(text::Fragment<'static>), } @@ -19,6 +23,7 @@ impl From<&'static str> for Selector { } } +/// Creates [`Selector`] that finds the widget containing the given text fragment. pub fn text(fragment: impl text::IntoFragment<'static>) -> Selector { Selector::Text(fragment.into_fragment()) } -- cgit