Re-vendor the native UI kit at 278430d
- Upstream merged core, data, editor, and utils into a single `components` crate: `ui::button`, `ui::tabs`, `ui::code`, `ui::tree`, `ui::sidebar` are flat, and `h_flex`/`v_flex`/`StyledExt` live in `ui::common` and `ui::layout`. - Adopts the new wrapper-less component module tree, the merged theme/icon updates, and the relocated editor grammars. - Titlebar repo tabs use the new `TabsVariant::Titlebar` capsule sizing. - Doc examples now import from `ui::`, so all 44 doctests compile; the clipboard sample no longer names the kit crate. - docs/ui-gaps.md records that `ui` has no dock/view-registry API instead of the deleted `DockState`.
This commit is contained in:
@@ -274,156 +274,3 @@ fn active_theme() -> String {
|
||||
fn base_dirs() -> Vec<PathBuf> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn scratch(name: &str) -> PathBuf {
|
||||
let root =
|
||||
std::env::temp_dir().join(format!("gpui-native-icons-{name}-{}", std::process::id()));
|
||||
// NotFound is the expected first run; anything else is a setup failure.
|
||||
if let Err(error) = std::fs::remove_dir_all(&root)
|
||||
&& error.kind() != std::io::ErrorKind::NotFound
|
||||
{
|
||||
panic!("failed to clear scratch dir {root:?}: {error}");
|
||||
}
|
||||
std::fs::create_dir_all(&root).expect("scratch dir");
|
||||
root
|
||||
}
|
||||
|
||||
fn write(path: &Path, contents: &str) {
|
||||
std::fs::create_dir_all(path.parent().expect("parent")).expect("dirs");
|
||||
std::fs::write(path, contents).expect("write");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_theme_beats_hicolor() {
|
||||
let base = scratch("precedence");
|
||||
write(
|
||||
&base.join("mytheme/scalable/actions/object-select-symbolic.svg"),
|
||||
"<svg/>",
|
||||
);
|
||||
write(
|
||||
&base.join("hicolor/scalable/actions/object-select-symbolic.svg"),
|
||||
"<svg/>",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
lookup(
|
||||
&["object-select-symbolic"],
|
||||
"mytheme",
|
||||
16,
|
||||
std::slice::from_ref(&base)
|
||||
),
|
||||
Some(base.join("mytheme/scalable/actions/object-select-symbolic.svg"))
|
||||
);
|
||||
std::fs::remove_dir_all(&base).expect("cleanup");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_missing_glyph_falls_through_to_hicolor() {
|
||||
let base = scratch("hicolor");
|
||||
write(&base.join("hicolor/24/actions/search.svg"), "<svg/>");
|
||||
|
||||
assert_eq!(
|
||||
lookup(&["search"], "breeze", 24, std::slice::from_ref(&base)),
|
||||
Some(base.join("hicolor/24/actions/search.svg"))
|
||||
);
|
||||
std::fs::remove_dir_all(&base).expect("cleanup");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_inherits_chain_is_walked() {
|
||||
let base = scratch("inherits");
|
||||
write(&base.join("parent/scalable/actions/add.svg"), "<svg/>");
|
||||
write(
|
||||
&base.join("child/index.theme"),
|
||||
"[Icon Theme]\nInherits=parent\n",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
lookup(&["add"], "child", 16, std::slice::from_ref(&base)),
|
||||
Some(base.join("parent/scalable/actions/add.svg"))
|
||||
);
|
||||
std::fs::remove_dir_all(&base).expect("cleanup");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scalable_wins_and_the_closest_size_wins_without_it() {
|
||||
let base = scratch("sizes");
|
||||
write(&base.join("theme/16x16/actions/check.svg"), "<svg/>");
|
||||
write(&base.join("theme/48x48/actions/check.svg"), "<svg/>");
|
||||
write(&base.join("theme/scalable/actions/check.svg"), "<svg/>");
|
||||
|
||||
assert_eq!(
|
||||
lookup(&["check"], "theme", 16, std::slice::from_ref(&base)),
|
||||
Some(base.join("theme/scalable/actions/check.svg"))
|
||||
);
|
||||
|
||||
let base = scratch("sizes-plain");
|
||||
write(&base.join("theme/16x16/actions/check.svg"), "<svg/>");
|
||||
write(&base.join("theme/48x48/actions/check.svg"), "<svg/>");
|
||||
|
||||
assert_eq!(
|
||||
lookup(&["check"], "theme", 16, std::slice::from_ref(&base)),
|
||||
Some(base.join("theme/16x16/actions/check.svg"))
|
||||
);
|
||||
std::fs::remove_dir_all(&base).expect("cleanup");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn both_theme_layouts_are_searched() {
|
||||
let adwaita = scratch("layout-adwaita");
|
||||
write(&adwaita.join("theme/scalable/actions/check.svg"), "<svg/>");
|
||||
assert_eq!(
|
||||
lookup(&["check"], "theme", 16, std::slice::from_ref(&adwaita)),
|
||||
Some(adwaita.join("theme/scalable/actions/check.svg"))
|
||||
);
|
||||
|
||||
let breeze = scratch("layout-breeze");
|
||||
write(&breeze.join("theme/actions/16/check.svg"), "<svg/>");
|
||||
assert_eq!(
|
||||
lookup(&["check"], "theme", 16, std::slice::from_ref(&breeze)),
|
||||
Some(breeze.join("theme/actions/16/check.svg"))
|
||||
);
|
||||
std::fs::remove_dir_all(&adwaita).expect("cleanup");
|
||||
std::fs::remove_dir_all(&breeze).expect("cleanup");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn png_only_themes_are_skipped() {
|
||||
let base = scratch("png");
|
||||
write(&base.join("theme/16x16/actions/check.png"), "png");
|
||||
|
||||
assert_eq!(
|
||||
lookup(&["check"], "theme", 16, std::slice::from_ref(&base)),
|
||||
None
|
||||
);
|
||||
std::fs::remove_dir_all(&base).expect("cleanup");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_themes_second_candidate_beats_hicolors_first() {
|
||||
let base = scratch("candidates");
|
||||
write(
|
||||
&base.join("mytheme/scalable/actions/emblem-ok-symbolic.svg"),
|
||||
"<svg/>",
|
||||
);
|
||||
write(
|
||||
&base.join("hicolor/scalable/actions/object-select-symbolic.svg"),
|
||||
"<svg/>",
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
lookup(
|
||||
&["object-select-symbolic", "emblem-ok-symbolic"],
|
||||
"mytheme",
|
||||
16,
|
||||
std::slice::from_ref(&base)
|
||||
),
|
||||
Some(base.join("mytheme/scalable/actions/emblem-ok-symbolic.svg"))
|
||||
);
|
||||
std::fs::remove_dir_all(&base).expect("cleanup");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user