Panics · P05 Buttons: a segmented choice missing from its segments marks none; slide logs and shows no marker

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 16:32:12 -04:00
1 parent 9bb342cb16
commit 73a8bf2e34
4 files changed
+40 -13

No files matched your search

+29 -1
View File
@@ -3,7 +3,7 @@ use gpui::{
Render, Styled, TestAppContext, VisualTestContext, Window, div, point, px,
};
use super::{Button, ToggleButton, ToggleItem};
use super::{Button, SegmentedControl, ToggleButton, ToggleItem};
use crate::{
primitives::{FocusNext, FocusScope},
theme::Theme,
@@ -98,3 +98,31 @@ fn a_disabled_toggle_ignores_clicks(cx: &mut TestAppContext) {
cx.simulate_click(point(px(4.0), px(4.0)), Modifiers::none());
assert_eq!(view.read_with(cx, |toggles, _| toggles.presses), 1);
}
/// Segments whose chosen value left with a change of list.
struct Stale;
impl Render for Stale {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div().w(px(300.0)).child(
SegmentedControl::new("views", "gone")
.segment("list", "List", None)
.segment("grid", "Grid", None),
)
}
}
#[gpui::test]
fn a_choice_missing_from_its_segments_marks_none(cx: &mut TestAppContext) {
cx.update(Theme::init);
let (_, cx) = cx.add_window_view(|_, _| Stale);
for _ in 0..3 {
cx.run_until_parked();
cx.update(|window, _| window.refresh());
}
assert!(cx.debug_bounds("segment list").is_some());
assert!(
cx.debug_bounds("segment-thumb").is_none(),
"no thumb marks a choice"
);
}