Test different Theme variants in styling example
This commit is contained in:
parent
ced4276a5e
commit
2b7d8eaaca
27 changed files with 69 additions and 35 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -23,5 +23,5 @@ jobs:
|
|||
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
|
||||
- name: Run tests
|
||||
run: |
|
||||
cargo test --verbose --workspace
|
||||
cargo test --verbose --workspace --all-features
|
||||
cargo test --verbose --workspace -- --ignored
|
||||
cargo test --verbose --workspace --all-features -- --ignored
|
||||
|
|
|
|||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -5519,6 +5519,8 @@ name = "styling"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"iced",
|
||||
"iced_test",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -151,39 +151,6 @@ impl<T> InputMethod<T> {
|
|||
/// However, one couldn't possibly have a key for every single
|
||||
/// unicode character that the user might want to type. The solution operating systems employ is
|
||||
/// to allow the user to type these using _a sequence of keypresses_ instead.
|
||||
///
|
||||
/// A prominent example of this is accents—many keyboard layouts allow you to first click the
|
||||
/// "accent key", and then the character you want to apply the accent to. In this case, some
|
||||
/// platforms will generate the following event sequence:
|
||||
///
|
||||
/// ```ignore
|
||||
/// // Press "`" key
|
||||
/// Ime::Preedit("`", Some((0, 0)))
|
||||
/// // Press "E" key
|
||||
/// Ime::Preedit("", None) // Synthetic event generated to clear preedit.
|
||||
/// Ime::Commit("é")
|
||||
/// ```
|
||||
///
|
||||
/// Additionally, certain input devices are configured to display a candidate box that allow the
|
||||
/// user to select the desired character interactively. (To properly position this box, you must use
|
||||
/// [`Shell::request_input_method`](crate::Shell::request_input_method).)
|
||||
///
|
||||
/// An example of a keyboard layout which uses candidate boxes is pinyin. On a latin keyboard the
|
||||
/// following event sequence could be obtained:
|
||||
///
|
||||
/// ```ignore
|
||||
/// // Press "A" key
|
||||
/// Ime::Preedit("a", Some((1, 1)))
|
||||
/// // Press "B" key
|
||||
/// Ime::Preedit("a b", Some((3, 3)))
|
||||
/// // Press left arrow key
|
||||
/// Ime::Preedit("a b", Some((1, 1)))
|
||||
/// // Press space key
|
||||
/// Ime::Preedit("啊b", Some((3, 3)))
|
||||
/// // Press space key
|
||||
/// Ime::Preedit("", None) // Synthetic event generated to clear preedit.
|
||||
/// Ime::Commit("啊不")
|
||||
/// ```
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Event {
|
||||
/// Notifies when the IME was opened.
|
||||
|
|
|
|||
|
|
@ -7,3 +7,7 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
iced.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
iced_test.workspace = true
|
||||
rayon = "1"
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
9e67e429f88fd5a64744d9cd4d42e123950bea4a45fea78581bc3d64b12e11f0
|
||||
|
|
@ -0,0 +1 @@
|
|||
811a22238f3a40e3e3998f514c0a95f24f2b45449250682d86c8ec392fec5e28
|
||||
|
|
@ -0,0 +1 @@
|
|||
6bf957efe807f87f38cfc672f9a05325aadee6256aacca87bbc3281b98160c8a
|
||||
|
|
@ -0,0 +1 @@
|
|||
d3f4110fae78a3be3b7a4813e9a432b48b81fff1e982c0244e4ea394074bef55
|
||||
1
examples/styling/snapshots/dark-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/dark-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
578e7420de69d82906d284c59d81fcea0edf81098481fc4dd7b4c1fb577b7f1c
|
||||
1
examples/styling/snapshots/dracula-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/dracula-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
422e841113efaa86e9e37593d0d14f8dd36ad483a81c30a08588f48805e4f9f3
|
||||
1
examples/styling/snapshots/ferra-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/ferra-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
3d616a31842a29b4a3d31fbeef25f95c7b50f33360f1c05e069e0b29b3f7553e
|
||||
1
examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/gruvbox_dark-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
9a21865bfc075669d368ccac69b975c3e1f6c22ba297dddfa003d4ee1a06641c
|
||||
|
|
@ -0,0 +1 @@
|
|||
d5164fb10a92177afd0aab353557d1e3fdaa743962c6a901f05cbfcd0d91e9fb
|
||||
|
|
@ -0,0 +1 @@
|
|||
3d5ba3b50f192f8700edbfbf54007e92dfd66997bce7342671afc2b60d556aca
|
||||
|
|
@ -0,0 +1 @@
|
|||
90cb13c900d58a56ce170afeefbceb77410d024e7eae6030e181df1c929c3944
|
||||
|
|
@ -0,0 +1 @@
|
|||
71b625bc39aaead7a1298e4b2dad51b266526c53deab139858774986395878db
|
||||
1
examples/styling/snapshots/light-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/light-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
f08f80a79959ef1c2fd8f8696a26555f2b2eab6618dd3653a042acab563bcced
|
||||
1
examples/styling/snapshots/moonfly-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/moonfly-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
3302b7934051ff8aa01d70c45e28c444bdc93e8a4da219931aa22465b51c6748
|
||||
1
examples/styling/snapshots/nightfly-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/nightfly-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
661ec43b66213f369ce5a3680e9e8ead56c98d94718da25b12fbb313386944e0
|
||||
1
examples/styling/snapshots/nord-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/nord-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
b5dd22b064220d5f2f90c6f0f381eff41d25f534587d1649ed59e25f878eda97
|
||||
1
examples/styling/snapshots/oxocarbon-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/oxocarbon-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
dd6e7e7ba125a2549143501c3de44427633f0bfa6c0d8b6f66aa95d503874065
|
||||
|
|
@ -0,0 +1 @@
|
|||
44b5afe743b753a54f3e68da2fd2701837e7e8cff276ff1e8c349030c83ac72e
|
||||
|
|
@ -0,0 +1 @@
|
|||
1b46820f12611b2759eb843688cd13b6024f2096b7986f205398bb029e0c60bd
|
||||
1
examples/styling/snapshots/tokyo_night-tiny-skia.sha256
Normal file
1
examples/styling/snapshots/tokyo_night-tiny-skia.sha256
Normal file
|
|
@ -0,0 +1 @@
|
|||
27a9a8bb08cea7b0a9b9763e332a6833d4fead1a885cdd59a1f5161e3726d6b1
|
||||
|
|
@ -0,0 +1 @@
|
|||
ab0dee2cc24f30eb51b376a0385302b45bfeddb373348525dab7f551c27ffec2
|
||||
|
|
@ -0,0 +1 @@
|
|||
aef404c7e38aec5387c39cf3a2911688324c1b9b520e5f541b9fd3fd6eefd3a8
|
||||
|
|
@ -167,3 +167,42 @@ impl Styling {
|
|||
self.theme.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
use iced_test::{Error, simulator};
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn it_showcases_every_theme() -> Result<(), Error> {
|
||||
Theme::ALL
|
||||
.par_iter()
|
||||
.map(|theme| {
|
||||
let mut styling = Styling::default();
|
||||
styling.update(Message::ThemeChanged(theme.clone()));
|
||||
|
||||
let theme = styling.theme();
|
||||
|
||||
let mut ui = simulator(styling.view());
|
||||
|
||||
let snapshot = ui.snapshot(&theme)?;
|
||||
|
||||
assert!(
|
||||
snapshot.matches_hash(format!(
|
||||
"snapshots/{theme}",
|
||||
theme = theme
|
||||
.to_string()
|
||||
.to_ascii_lowercase()
|
||||
.replace(" ", "_")
|
||||
))?,
|
||||
"snapshots for {theme} should match!"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue