chore: audit components
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::time::Instant;
|
||||
|
||||
use gpui::{
|
||||
AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render, SharedString,
|
||||
@@ -70,19 +69,31 @@ fn real_keystrokes_are_not_pathologically_slow() {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
|
||||
let started = Instant::now();
|
||||
// The focused caret must ride executor timers, never frame requests.
|
||||
let frames = visual.update(|window, cx| window.simulate_next_frame(cx));
|
||||
assert_eq!(
|
||||
frames, 0,
|
||||
"an idle focused combobox must not request animation frames"
|
||||
);
|
||||
|
||||
for letter in "abcdefghijklmnopqrstuvwxyz".chars() {
|
||||
visual.simulate_keystrokes(&letter.to_string());
|
||||
visual.update(|window, cx| {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
}
|
||||
let elapsed = started.elapsed();
|
||||
|
||||
let total_renders = *renders.borrow();
|
||||
println!(
|
||||
"26 real keystrokes: {elapsed:?}, host renders: {total_renders} ({} per keystroke)",
|
||||
"26 real keystrokes: {total_renders} host renders ({:.2} per keystroke)",
|
||||
total_renders as f32 / 26.
|
||||
);
|
||||
assert!(elapsed.as_millis() < 2000, "typing took {elapsed:?}");
|
||||
assert!(
|
||||
total_renders >= 26,
|
||||
"every keystroke must redraw the page; got {total_renders} renders"
|
||||
);
|
||||
assert!(
|
||||
total_renders <= 26 * 3,
|
||||
"typing caused {total_renders} host renders; healthy filtering stays under 3 per keystroke"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::time::Instant;
|
||||
|
||||
use gpui::{
|
||||
AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render, SharedString,
|
||||
@@ -78,19 +77,31 @@ fn typing_with_the_palette_open_is_not_pathologically_slow() {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
|
||||
let started = Instant::now();
|
||||
// The open palette must sit idle on executor timers, never frame requests.
|
||||
let frames = visual.update(|window, cx| window.simulate_next_frame(cx));
|
||||
assert_eq!(
|
||||
frames, 0,
|
||||
"an idle open palette must not request animation frames"
|
||||
);
|
||||
|
||||
for letter in "abcdefghijklmnopqrstuvwxyz".chars() {
|
||||
visual.simulate_keystrokes(&letter.to_string());
|
||||
visual.update(|window, cx| {
|
||||
window.draw(cx).clear(cx);
|
||||
});
|
||||
}
|
||||
let elapsed = started.elapsed();
|
||||
|
||||
let total_renders = *renders.borrow();
|
||||
println!(
|
||||
"26 real keystrokes with the palette open: {elapsed:?}, host renders: {total_renders} ({} per keystroke)",
|
||||
"26 real keystrokes with the palette open: {total_renders} host renders ({:.2} per keystroke)",
|
||||
total_renders as f32 / 26.
|
||||
);
|
||||
assert!(elapsed.as_millis() < 2000, "typing took {elapsed:?}");
|
||||
assert!(
|
||||
total_renders >= 26,
|
||||
"every keystroke must redraw the page; got {total_renders} renders"
|
||||
);
|
||||
assert!(
|
||||
total_renders <= 26 * 3,
|
||||
"typing caused {total_renders} host renders; healthy filtering stays under 3 per keystroke"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{cell::RefCell, rc::Rc};
|
||||
use gpui::{
|
||||
Context, InteractiveElement as _, IntoElement, Modifiers, MouseButton, ParentElement as _,
|
||||
Render, StatefulInteractiveElement as _, Styled as _, TestAppContext, VisualTestContext,
|
||||
Window, WindowHandle, div, point, px, rgba,
|
||||
Window, WindowHandle, div, point, px,
|
||||
};
|
||||
use gpui_native_core::popover::Popover;
|
||||
use gpui_native_theme::Theme;
|
||||
@@ -26,7 +26,6 @@ impl Render for Harness {
|
||||
div()
|
||||
.id("popover-target")
|
||||
.size(px(40.))
|
||||
.bg(rgba(0x000000ff))
|
||||
.on_click(move |_, _, cx| {
|
||||
*target_clicks.borrow_mut() += 1;
|
||||
cx.stop_propagation();
|
||||
@@ -48,7 +47,6 @@ impl Render for Harness {
|
||||
.debug_selector(|| "popover-trigger".to_string())
|
||||
.w(px(100.))
|
||||
.h(px(32.))
|
||||
.bg(rgba(0x000000ff))
|
||||
.into_any_element()
|
||||
})
|
||||
.content(|_, _| {
|
||||
|
||||
@@ -3,7 +3,7 @@ use gpui::{
|
||||
VisualTestContext, Window, div, px,
|
||||
};
|
||||
use gpui_native_core::separator::{Separator, SeparatorOrientation};
|
||||
use gpui_native_theme::Theme;
|
||||
use gpui_native_theme::{BORDER_WIDTH, Theme};
|
||||
|
||||
struct Harness {
|
||||
orientation: SeparatorOrientation,
|
||||
@@ -47,7 +47,7 @@ fn the_horizontal_rule_spans_its_container_at_hairline_height() {
|
||||
.debug_bounds("test-separator")
|
||||
.expect("horizontal separator rendered");
|
||||
assert_eq!(bounds.size.width, px(200.));
|
||||
assert_eq!(bounds.size.height, px(1.));
|
||||
assert_eq!(bounds.size.height, BORDER_WIDTH);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -56,6 +56,6 @@ fn the_vertical_rule_spans_its_container_at_hairline_width() {
|
||||
let bounds = visual
|
||||
.debug_bounds("test-separator")
|
||||
.expect("vertical separator rendered");
|
||||
assert_eq!(bounds.size.width, px(1.));
|
||||
assert_eq!(bounds.size.width, BORDER_WIDTH);
|
||||
assert_eq!(bounds.size.height, px(50.));
|
||||
}
|
||||
|
||||
@@ -155,8 +155,4 @@ fn dismissal_does_not_run_the_action() {
|
||||
*dismissed.borrow(),
|
||||
"on_dismiss still reports the dismissal"
|
||||
);
|
||||
assert!(
|
||||
*dismissed.borrow(),
|
||||
"on_dismiss still reports the dismissal"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -129,10 +129,6 @@ fn hovering_the_target_deploys_the_tooltip_after_the_delay() {
|
||||
calls.borrow().is_empty(),
|
||||
"builder runs only after the delay"
|
||||
);
|
||||
assert!(
|
||||
calls.borrow().is_empty(),
|
||||
"builder runs only after the delay"
|
||||
);
|
||||
|
||||
cx.executor().advance_clock(SHOW_DELAY);
|
||||
visual.run_until_parked();
|
||||
|
||||
Reference in New Issue
Block a user