Files
gpui-native-kit/crates/core/tests/sizing.rs
T
reya 21faea00c5 Shrink xsmall controls
- Reduce xsmall control height from 24px to 20px.
- Scale xsmall text, icons, avatars, and switches down with it.
2026-11-16 19:07:10 +07:00

49 lines
1.5 KiB
Rust

#![cfg(feature = "button")]
use gpui::{
Context, IntoElement, ParentElement as _, Render, Styled as _, TestAppContext,
VisualTestContext, Window, div, px, size,
};
use gpui_native_core::button::Button;
use gpui_native_core::common::Sizable as _;
use gpui_native_theme::Theme;
struct Harness;
impl Render for Harness {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.size_full()
.flex()
.flex_col()
.gap_2()
.child(
Button::new("height-probe")
.label("Probe")
.debug_selector(|| "height-probe".to_string()),
)
.child(
Button::new("xsmall-height-probe")
.label("Probe")
.xsmall()
.debug_selector(|| "xsmall-height-probe".to_string()),
)
}
}
#[gpui::test]
fn buttons_render_at_their_token_heights(cx: &mut TestAppContext) {
cx.update(Theme::init);
let window = cx.open_window(size(px(400.), px(400.)), |_, _| Harness);
let mut cx = VisualTestContext::from_window(window.into(), cx);
cx.run_until_parked();
let medium = cx.debug_bounds("height-probe").expect("button laid out");
let xsmall = cx
.debug_bounds("xsmall-height-probe")
.expect("xsmall button laid out");
assert_eq!(medium.size.height, px(32.0));
assert_eq!(xsmall.size.height, px(20.0));
}