GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
src/config_style_tests.rs (3.6K)
1 //! Tests of how the style layer reads the root plate's config keys. They lived in
2 //! `config.rs`'s suite until that module moved to `cce_core::config`; they test
3 //! `color` and `layout`, which stay here.
4
5 /// `style.surface.plate.root.*` is the only root-plate spelling: the
6 /// legacy `root plate.*` block is ignored, whether it stands beside the
7 /// canonical block or alone (its read-alias was removed 2026-09-06).
8 #[test]
9 fn test_plate_root_canonical_spelling() {
10 // Global color state: serialize against the other reload_colors tests,
11 // and fire both once-per-process live-config loads before our reload
12 // so neither can rewrite the state mid-assert.
13 let _guard = crate::color::test_color_state_lock();
14 let _ = crate::color::root_plate_corner_radius();
15 crate::layout::lazy_init_style_registry();
16
17 let content = r##"
18 style {
19 surface {
20 plate {
21 root corner_radius=(i64)17 {
22 menubar blur=(bool)true color=(rgba)"#1a1d26d0"
23 }
24 }
25 backplate corner_radius=(i64)9
26 }
27 }
28 "##;
29 crate::color::reload_colors(content);
30 assert_eq!(crate::color::root_plate_corner_radius(), 17.0, "canonical read; legacy ignored");
31 assert!(crate::color::root_plate_menubar_blur());
32
33 // A legacy-only spelling no longer feeds the getter: the value from
34 // the canonical load above stands.
35 let legacy = r##"
36 style {
37 surface {
38 backplate corner_radius=(i64)9
39 }
40 }
41 "##;
42 crate::color::reload_colors(legacy);
43 assert_eq!(crate::color::root_plate_corner_radius(), 17.0, "legacy spelling is not read");
44 }
45
46 #[test]
47 fn test_root_plate_menubar_statusbar_styling() {
48 // Global color state: serialize against the other reload_colors tests,
49 // and fire both once-per-process live-config loads before our reload
50 // so neither can rewrite the state mid-assert.
51 let _guard = crate::color::test_color_state_lock();
52 let _ = crate::color::root_plate_statusbar_blur();
53 crate::layout::lazy_init_style_registry();
54
55 let content = r##"
56 style {
57 surface {
58 plate {
59 root blur=(f64)0.1 color=(rgba)"#5e657acf" corner_radius=(i64)12 {
60 menubar blur=(bool)true color=(rgba)"#1a1d26d0" text_color=(rgba)"#e2e4f0ff"
61 }
62 }
63 statusbar blur=(bool)false color=(rgba)"#12141cd0" text_color=(rgba)"#b5b9c8ff"
64 }
65 control {
66 dropdown color=(rgba)"#08080cff"
67 }
68 data {
69 textbox placeholder_text_color=(rgba)"#60606aff"
70 }
71 }
72 "##;
73
74 // Parse into json and set colors
75 crate::color::reload_colors(content);
76
77 // Verify values are parsed correctly through the root_plate_* getters.
78 assert!(crate::color::root_plate_menubar_blur());
79
80 let dd_color = crate::color::dropdown_background_color();
81 assert!((dd_color[0] - crate::color::srgb_to_linear(8.0 / 255.0)).abs() < 0.0001);
82
83 let placeholder_color = crate::color::textbox_placeholder_text_color();
84 assert_eq!(placeholder_color, [0x60, 0x60, 0x6a]);
85 assert!(!crate::color::root_plate_statusbar_blur());
86
87 // Colors are in sRGB converted to linear, let's verify text colors
88 let menubar_txt = crate::color::root_plate_menubar_text_color();
89 assert!(menubar_txt[0] > 0.0);
90 let statusbar_txt = crate::color::root_plate_statusbar_text_color();
91 assert!(statusbar_txt[0] > 0.0);
92 }