diff --git a/crates/ui/src/assets.rs b/crates/ui/src/assets.rs index 1dc44d1..2fc913c 100644 --- a/crates/ui/src/assets.rs +++ b/crates/ui/src/assets.rs @@ -102,3 +102,28 @@ impl AssetSource for Assets { Ok(paths) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn component_caption_icons_load_through_assets_facade() { + for path in [ + "icons/window-minimize.svg", + "icons/window-maximize.svg", + "icons/window-restore.svg", + "icons/window-close.svg", + ] { + let bytes = AssetSource::load(&Assets, path) + .unwrap_or_else(|error| panic!("failed to load {path}: {error}")) + .unwrap_or_else(|| panic!("asset was not found: {path}")); + + assert!(!bytes.is_empty(), "asset was empty: {path}"); + assert!( + String::from_utf8_lossy(&bytes).contains(" &'static str { + fn icon(self, maximized: bool) -> IconName { match self { - Self::Minimize => "\u{e921}", - Self::MaximizeRestore if maximized => "\u{e923}", - Self::MaximizeRestore => "\u{e922}", - Self::Close => "\u{e8bb}", + Self::Minimize => IconName::WindowMinimize, + Self::MaximizeRestore if maximized => IconName::WindowRestore, + Self::MaximizeRestore => IconName::WindowMaximize, + Self::Close => IconName::WindowClose, } } } @@ -192,11 +187,9 @@ fn caption_button(button: CaptionButton, maximized: bool, cx: &App) -> impl Into // header's drag listeners nor any enclosing `Drag` control area is in // the hit set — the platform sees a caption button, never a drag area. .occlude() - .font_family(CAPTION_FONT) - .text_size(px(10.)) .hover(move |style| style.bg(hover_bg).text_color(active_fg)) .active(move |style| style.bg(pressed_bg).text_color(active_fg)) - .child(button.glyph(maximized)) + .child(Icon::new(button.icon(maximized)).small()) } #[cfg(test)]