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
|
|
@ -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