Skip to content

Commit bd286d2

Browse files
committed
fix snapshot tests
1 parent b249c43 commit bd286d2

File tree

15 files changed

+90
-39
lines changed

15 files changed

+90
-39
lines changed

crates/viewer/re_test_context/src/lib.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ impl TestContext {
200200
blueprint_query: &blueprint_query,
201201
};
202202

203+
// ctx.set_timeline("log_tick".into());
204+
203205
RecordingConfig::from_blueprint(&ctx)
204206
};
205207

@@ -346,12 +348,19 @@ impl TestContext {
346348
panic!("No active blueprint")
347349
};
348350

349-
f(TestBlueprintCtx {
351+
let r = f(TestBlueprintCtx {
350352
command_sender: &self.command_sender,
351353
current_blueprint: store_context.blueprint,
352354
default_blueprint: store_context.default_blueprint,
353355
blueprint_query: &self.blueprint_query,
354-
})
356+
});
357+
358+
drop(store_hub);
359+
360+
// Handle system commands directly after updating blueprints to write it to the store.
361+
self.handle_system_commands();
362+
363+
r
355364
}
356365

357366
pub fn setup_kittest_for_rendering(&self) -> egui_kittest::HarnessBuilder<()> {
@@ -495,13 +504,10 @@ impl TestContext {
495504
drag_and_drop_manager: &drag_and_drop_manager,
496505
};
497506

498-
self.recording_config.time_ctrl.write().update(
499-
store_context.recording.times_per_timeline(),
500-
0.0,
501-
false,
502-
true,
503-
&ctx,
504-
);
507+
self.recording_config
508+
.time_ctrl
509+
.write()
510+
.update_from_blueprint(&ctx, Some(store_context.recording.times_per_timeline()));
505511

506512
func(&ctx);
507513

Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

crates/viewer/re_view_spatial/tests/video.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![expect(clippy::unwrap_used)] // It's a test!
22

33
use re_chunk_store::RowId;
4-
use re_log_types::{NonMinI64, TimePoint};
4+
use re_log_types::{NonMinI64, TimeInt, TimePoint};
55
use re_test_context::{TestContext, external::egui_kittest::SnapshotOptions};
66
use re_test_viewport::TestContextExt as _;
77
use re_types::{
@@ -287,7 +287,9 @@ fn test_video(video_type: VideoType, codec: VideoCodec) {
287287
// not tearing down the video player!
288288
let desired_seek_ns = seek_location.get_time_ns(&frame_timestamps_nanos);
289289
test_context.with_blueprint_ctx(|ctx| {
290-
ctx.set_time(NonMinI64::new(desired_seek_ns).unwrap());
290+
ctx.set_time(TimeInt::from_nanos(
291+
NonMinI64::new(desired_seek_ns).unwrap(),
292+
));
291293
});
292294

293295
// Video decoding happens in a different thread, so it's important that we give it time

crates/viewer/re_view_time_series/tests/basic.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use re_log_types::{EntityPath, TimePoint, Timeline};
33
use re_test_context::{TestContext, external::egui_kittest::SnapshotOptions};
44
use re_test_viewport::TestContextExt as _;
55
use re_view_time_series::TimeSeriesView;
6-
use re_viewer_context::{BlueprintContext as _, ViewClass as _, ViewId};
6+
use re_viewer_context::{BlueprintContext as _, TimeBlueprintExt as _, ViewClass as _, ViewId};
77
use re_viewport_blueprint::{ViewBlueprint, ViewContents};
88

99
fn color_gradient0(step: i64) -> re_types::components::Color {
@@ -24,6 +24,8 @@ pub fn test_clear_series_points_and_line() {
2424
fn test_clear_series_points_and_line_impl(two_series_per_entity: bool) {
2525
let mut test_context = TestContext::new_with_view_class::<TimeSeriesView>();
2626

27+
let timeline = Timeline::log_tick();
28+
2729
// TODO(#10512): Potentially fix up this after we have "markers".
2830
// There are some intricacies involved with this test. `SeriesLines` and
2931
// `SeriesPoints` can both be logged without any associated data (all
@@ -50,7 +52,7 @@ fn test_clear_series_points_and_line_impl(two_series_per_entity: bool) {
5052
});
5153

5254
for i in 0..32 {
53-
let timepoint = TimePoint::from([(test_context.active_timeline(), i)]);
55+
let timepoint = TimePoint::from([(timeline, i)]);
5456

5557
match i {
5658
15 => {
@@ -85,6 +87,10 @@ fn test_clear_series_points_and_line_impl(two_series_per_entity: bool) {
8587
}
8688
}
8789

90+
test_context.with_blueprint_ctx(|ctx| {
91+
ctx.set_timeline(*timeline.name());
92+
});
93+
8894
let allowed_broken_pixels = if two_series_per_entity { 5 } else { 2 };
8995
let view_id = setup_blueprint(&mut test_context);
9096
test_context.run_view_ui_and_save_snapshot(
@@ -136,6 +142,8 @@ fn test_line_properties() {
136142
fn test_line_properties_impl(multiple_properties: bool, multiple_scalars: bool) {
137143
let mut test_context = TestContext::new_with_view_class::<TimeSeriesView>();
138144

145+
let timeline = Timeline::log_tick();
146+
139147
let properties_static = if multiple_properties {
140148
re_types::archetypes::SeriesLines::new()
141149
.with_widths([4.0, 8.0])
@@ -155,7 +163,7 @@ fn test_line_properties_impl(multiple_properties: bool, multiple_scalars: bool)
155163
});
156164

157165
for step in 0..32 {
158-
let timepoint = TimePoint::from([(test_context.active_timeline(), step)]);
166+
let timepoint = TimePoint::from([(timeline, step)]);
159167

160168
let properties = if multiple_properties {
161169
re_types::archetypes::SeriesLines::new()
@@ -181,6 +189,10 @@ fn test_line_properties_impl(multiple_properties: bool, multiple_scalars: bool)
181189
});
182190
}
183191

192+
test_context.with_blueprint_ctx(|ctx| {
193+
ctx.set_timeline(*timeline.name());
194+
});
195+
184196
let view_id = setup_blueprint(&mut test_context);
185197
let mut name = "line_properties".to_owned();
186198
if multiple_properties {
@@ -208,6 +220,8 @@ fn test_per_series_visibility() {
208220
] {
209221
let mut test_context = TestContext::new_with_view_class::<TimeSeriesView>();
210222

223+
let timeline = Timeline::log_tick();
224+
211225
test_context.log_entity("plots", |builder| {
212226
builder.with_archetype(
213227
RowId::new(),
@@ -217,13 +231,17 @@ fn test_per_series_visibility() {
217231
});
218232

219233
for step in 0..32 {
220-
let timepoint = TimePoint::from([(test_context.active_timeline(), step)]);
234+
let timepoint = TimePoint::from([(timeline, step)]);
221235
let (scalars, _) = scalars_for_properties_test(step, true);
222236
test_context.log_entity("plots", |builder| {
223237
builder.with_archetype(RowId::new(), timepoint.clone(), &scalars)
224238
});
225239
}
226240

241+
test_context.with_blueprint_ctx(|ctx| {
242+
ctx.set_timeline(*timeline.name());
243+
});
244+
227245
let view_id = setup_blueprint(&mut test_context);
228246
test_context.run_view_ui_and_save_snapshot(view_id, name, egui::vec2(300.0, 300.0), None);
229247
}
@@ -253,6 +271,8 @@ fn test_point_properties() {
253271
fn test_point_properties_impl(multiple_properties: bool, multiple_scalars: bool) {
254272
let mut test_context = TestContext::new_with_view_class::<TimeSeriesView>();
255273

274+
let timeline = Timeline::log_tick();
275+
256276
let static_props = if multiple_properties {
257277
re_types::archetypes::SeriesPoints::new()
258278
.with_marker_sizes([4.0, 8.0])
@@ -278,7 +298,7 @@ fn test_point_properties_impl(multiple_properties: bool, multiple_scalars: bool)
278298
});
279299

280300
for step in 0..32 {
281-
let timepoint = TimePoint::from([(test_context.active_timeline(), step)]);
301+
let timepoint = TimePoint::from([(timeline, step)]);
282302

283303
let properties = if multiple_properties {
284304
re_types::archetypes::SeriesPoints::new()
@@ -308,6 +328,10 @@ fn test_point_properties_impl(multiple_properties: bool, multiple_scalars: bool)
308328
});
309329
}
310330

331+
test_context.with_blueprint_ctx(|ctx| {
332+
ctx.set_timeline(*timeline.name());
333+
});
334+
311335
let view_id = setup_blueprint(&mut test_context);
312336
let mut name = "point_properties".to_owned();
313337
if multiple_properties {
@@ -399,6 +423,10 @@ fn test_bootstrapped_secondaries_impl(partial_range: bool) {
399423
blueprint.add_view_at_root(view)
400424
});
401425

426+
test_context.with_blueprint_ctx(|ctx| {
427+
ctx.set_timeline(*Timeline::log_tick().name());
428+
});
429+
402430
let name = if partial_range {
403431
"bootstrapped_secondaries_partial"
404432
} else {

0 commit comments

Comments
 (0)