Skip to content

Commit a2417ae

Browse files
committed
Addressed review comments
1 parent a4c38ef commit a2417ae

File tree

1 file changed

+28
-49
lines changed

1 file changed

+28
-49
lines changed

crates/viewer/re_time_panel/tests/time_panel_tests.rs

+28-49
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub fn time_panel_two_sections_should_match_snapshot() {
3434
run_time_panel_and_save_snapshot(
3535
test_context,
3636
TimePanel::default(),
37+
300.0,
38+
false,
3739
"time_panel_two_sections",
3840
);
3941
}
@@ -69,42 +71,13 @@ pub fn time_panel_dense_data_should_match_snapshot() {
6971
builder
7072
});
7173

72-
run_time_panel_and_save_snapshot(test_context, TimePanel::default(), "time_panel_dense_data");
73-
}
74-
75-
fn run_time_panel_and_save_snapshot(
76-
mut test_context: TestContext,
77-
mut time_panel: TimePanel,
78-
snapshot_name: &str,
79-
) {
80-
let mut harness = test_context
81-
.setup_kittest_for_rendering()
82-
.with_size(Vec2::new(700.0, 300.0))
83-
.build_ui(|ui| {
84-
test_context.run(&ui.ctx().clone(), |viewer_ctx| {
85-
let blueprint = ViewportBlueprint::try_from_db(
86-
viewer_ctx.store_context.blueprint,
87-
&LatestAtQuery::latest(blueprint_timeline()),
88-
);
89-
90-
let mut time_ctrl = viewer_ctx.rec_cfg.time_ctrl.read().clone();
91-
92-
time_panel.show_expanded_with_header(
93-
viewer_ctx,
94-
&blueprint,
95-
viewer_ctx.recording(),
96-
&mut time_ctrl,
97-
ui,
98-
);
99-
100-
*viewer_ctx.rec_cfg.time_ctrl.write() = time_ctrl;
101-
});
102-
103-
test_context.handle_system_commands();
104-
});
105-
106-
harness.run();
107-
harness.snapshot(snapshot_name);
74+
run_time_panel_and_save_snapshot(
75+
test_context,
76+
TimePanel::default(),
77+
300.0,
78+
false,
79+
"time_panel_dense_data",
80+
);
10881
}
10982

11083
// ---
@@ -159,7 +132,7 @@ pub fn run_time_panel_filter_tests(filter_active: bool, query: &str, snapshot_na
159132
time_panel.activate_filter(query);
160133
}
161134

162-
run_time_panel_and_save_snapshot(test_context, time_panel, snapshot_name);
135+
run_time_panel_and_save_snapshot(test_context, time_panel, 300.0, false, snapshot_name);
163136
}
164137

165138
// --
@@ -175,7 +148,7 @@ pub fn test_various_entity_kinds_in_time_panel() {
175148
for time in [0, 5, i64::MAX] {
176149
let mut test_context = TestContext::default();
177150

178-
log_all_data(&mut test_context);
151+
log_data_for_various_entity_kinds_tests(&mut test_context);
179152

180153
test_context
181154
.recording_config
@@ -194,16 +167,18 @@ pub fn test_various_entity_kinds_in_time_panel() {
194167

195168
let time_panel = TimePanel::default();
196169

197-
run_expanded_time_panel_and_save_snapshot(
170+
run_time_panel_and_save_snapshot(
198171
test_context,
199172
time_panel,
173+
1200.0,
174+
true,
200175
&format!("various_entity_kinds_{timeline}_{time}"),
201176
);
202177
}
203178
}
204179
}
205180

206-
pub fn log_all_data(test_context: &mut TestContext) {
181+
pub fn log_data_for_various_entity_kinds_tests(test_context: &mut TestContext) {
207182
let timeline_a = "timeline_a";
208183
let timeline_b = "timeline_b";
209184

@@ -267,23 +242,27 @@ pub fn log_static_data(test_context: &mut TestContext, entity_path: impl Into<En
267242
});
268243
}
269244

270-
fn run_expanded_time_panel_and_save_snapshot(
245+
fn run_time_panel_and_save_snapshot(
271246
mut test_context: TestContext,
272247
mut time_panel: TimePanel,
248+
height: f32,
249+
expand_all: bool,
273250
snapshot_name: &str,
274251
) {
275252
let mut harness = test_context
276253
.setup_kittest_for_rendering()
277-
.with_size(Vec2::new(700.0, 1200.0))
254+
.with_size(Vec2::new(700.0, height))
278255
.build_ui(|ui| {
279256
test_context.run(&ui.ctx().clone(), |viewer_ctx| {
280-
re_context_menu::collapse_expand::collapse_expand_instance_path(
281-
viewer_ctx,
282-
viewer_ctx.recording(),
283-
&InstancePath::entity_all("/".into()),
284-
CollapseScope::StreamsTree,
285-
true,
286-
);
257+
if expand_all {
258+
re_context_menu::collapse_expand::collapse_expand_instance_path(
259+
viewer_ctx,
260+
viewer_ctx.recording(),
261+
&InstancePath::entity_all("/".into()),
262+
CollapseScope::StreamsTree,
263+
true,
264+
);
265+
}
287266

288267
let blueprint = ViewportBlueprint::try_from_db(
289268
viewer_ctx.store_context.blueprint,

0 commit comments

Comments
 (0)