Panics · P20 Debug: stale selections, frames and focus paths mark none; the timeline's wheel keeps a drawable range
This commit is contained in:
1 parent
99980e413c
commit
295731d336
6 files changed
+184
-28
No files matched your search
@@ -138,3 +138,112 @@ fn tab_reaches_each_span_and_enter_picks_it(cx: &mut TestAppContext) {
|
||||
"the second Tab stands on the second span"
|
||||
);
|
||||
}
|
||||
|
||||
/// A stack whose current frame left with a shorter stack.
|
||||
struct Unwound;
|
||||
|
||||
impl Render for Unwound {
|
||||
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||
let frame = super::StackFrame {
|
||||
function: "main".into(),
|
||||
path: "src/main.rs".into(),
|
||||
line: 3,
|
||||
library: false,
|
||||
};
|
||||
div()
|
||||
.w(px(400.0))
|
||||
.child(super::CallStack::new("stack", [frame]).current(4))
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_current_frame_past_the_stack_marks_none(cx: &mut TestAppContext) {
|
||||
cx.update(Theme::init);
|
||||
let (_, cx) = cx.add_window_view(|_, _| Unwound);
|
||||
settle(cx);
|
||||
}
|
||||
|
||||
/// A flame graph focused on a call its new profile lacks; a dump ending at the last address.
|
||||
struct Edges(bool);
|
||||
|
||||
impl Render for Edges {
|
||||
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||
let root = super::ProfileFrame {
|
||||
name: "root".into(),
|
||||
own: 1,
|
||||
calls: vec![],
|
||||
};
|
||||
div().w(px(400.0)).h(px(100.0)).child(match self.0 {
|
||||
true => super::Flamegraph::new("flame", root)
|
||||
.focus(vec![0])
|
||||
.into_any_element(),
|
||||
false => super::HexViewer::new("hex", vec![0x42])
|
||||
.base(u64::MAX)
|
||||
.into_any_element(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_lost_focus_and_the_last_address_draw(cx: &mut TestAppContext) {
|
||||
cx.update(Theme::init);
|
||||
for flame in [true, false] {
|
||||
let (_, cx) = cx.add_window_view(move |_, _| Edges(flame));
|
||||
settle(cx);
|
||||
}
|
||||
}
|
||||
|
||||
/// A timeline whose owner keeps each range it reports.
|
||||
struct Zooming((f64, f64));
|
||||
|
||||
impl Render for Zooming {
|
||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let owner = cx.entity();
|
||||
div().w(px(400.0)).child(
|
||||
TimelineProfiler::new("timeline", ["Main"], vec![], self.0).on_range(
|
||||
move |range, _, cx| {
|
||||
owner.update(cx, |owner, cx| {
|
||||
owner.0 = range;
|
||||
cx.notify();
|
||||
})
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_zoom_past_the_finest_range_stays_put(cx: &mut TestAppContext) {
|
||||
cx.update(Theme::init);
|
||||
let start = (1.0, 1.0 + f64::EPSILON);
|
||||
let (owner, cx) = cx.add_window_view(move |_, _| Zooming(start));
|
||||
settle(cx);
|
||||
for _ in 0..2 {
|
||||
cx.simulate_event(gpui::ScrollWheelEvent {
|
||||
position: point(px(250.0), px(30.0)),
|
||||
delta: gpui::ScrollDelta::Pixels(point(px(0.0), px(400.0))),
|
||||
modifiers: Modifiers::none(),
|
||||
touch_phase: gpui::TouchPhase::Moved,
|
||||
});
|
||||
settle(cx);
|
||||
}
|
||||
let range = owner.read_with(cx, |owner, _| owner.0);
|
||||
assert!(range.1 > range.0, "{range:?}");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_wheel_too_large_for_a_zoom_stays_put(cx: &mut TestAppContext) {
|
||||
cx.update(Theme::init);
|
||||
let (owner, cx) = cx.add_window_view(|_, _| Zooming((0.0, 25.0)));
|
||||
settle(cx);
|
||||
for pixels in [300_000.0, -300_000.0] {
|
||||
cx.simulate_event(gpui::ScrollWheelEvent {
|
||||
position: point(px(250.0), px(30.0)),
|
||||
delta: gpui::ScrollDelta::Pixels(point(px(0.0), px(pixels))),
|
||||
modifiers: Modifiers::none(),
|
||||
touch_phase: gpui::TouchPhase::Moved,
|
||||
});
|
||||
settle(cx);
|
||||
}
|
||||
assert_eq!(owner.read_with(cx, |owner, _| owner.0), (0.0, 25.0));
|
||||
}
|
||||
Reference in new issue
Block a user