use pagetop::prelude::*; // The background is made of `rect`s; only the logo paths use the line color. fn line_color(bg: (u8, u8, u8)) -> &'static str { let svg = PageTopSvg::TileRGB(bg.0, bg.1, bg.2).markup().into_string(); let dark = svg.contains("************************************************************************ #[pagetop::test] async fn tile_rgb_uses_a_white_line_on_dark_backgrounds() { assert_eq!(line_color((0, 82, 204)), "white"); assert_eq!(line_color((0, 0, 0)), "white"); assert_eq!(line_color((220, 20, 60)), "white"); } #[pagetop::test] async fn tile_rgb_uses_a_dark_line_on_light_backgrounds() { assert_eq!(line_color((255, 184, 75)), "dark"); assert_eq!(line_color((0, 255, 0)), "dark"); assert_eq!(line_color((255, 255, 255)), "dark"); } #[pagetop::test] async fn tile_rgb_switches_line_color_around_the_contrast_threshold() { // Relative luminance ~0.181 and ~0.188 respectively; with the default dark and light lines the // contrast with both is equal at ~0.186. assert_eq!(line_color((118, 118, 118)), "white"); assert_eq!(line_color((120, 120, 120)), "dark"); } #[pagetop::test] async fn tile_keeps_a_white_line_on_its_default_dark_background() { let svg = PageTopSvg::Tile.markup().into_string(); assert!(svg.contains("