Skip to content

Commit dbb85cc

Browse files
committed
fix some tests
1 parent 1ebe966 commit dbb85cc

File tree

6 files changed

+46
-32
lines changed

6 files changed

+46
-32
lines changed

crates/viewer/re_blueprint_tree/tests/blueprint_tree_tests.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ use egui_kittest::{OsThreshold, SnapshotOptions};
66
use re_blueprint_tree::BlueprintTree;
77
use re_chunk_store::RowId;
88
use re_chunk_store::external::re_chunk::ChunkBuilder;
9-
use re_log_types::{Timeline, build_frame_nr};
9+
use re_log_types::{TimelineName, build_frame_nr};
1010
use re_test_context::TestContext;
1111
use re_test_viewport::TestContextExt as _;
1212
use re_types::archetypes::Points3D;
13-
use re_viewer_context::{CollapseScope, RecommendedView, ViewClass as _, ViewId};
13+
use re_viewer_context::{
14+
CollapseScope, RecommendedView, TimeBlueprintExt as _, ViewClass as _, ViewId,
15+
};
1416
use re_viewport_blueprint::{ViewBlueprint, ViewportBlueprint};
1517

1618
#[test]
@@ -28,7 +30,7 @@ fn basic_blueprint_panel_should_match_snapshot() {
2830
});
2931

3032
let blueprint_tree = BlueprintTree::default();
31-
run_blueprint_panel_and_save_snapshot(test_context, blueprint_tree, "basic_blueprint_panel");
33+
run_blueprint_panel_and_save_snapshot(&test_context, blueprint_tree, "basic_blueprint_panel");
3234
}
3335

3436
// ---
@@ -61,7 +63,9 @@ fn collapse_expand_all_blueprint_panel_should_match_snapshot() {
6163
let mut blueprint_tree = BlueprintTree::default();
6264

6365
// set the current timeline to the timeline where data was logged to
64-
test_context.set_active_timeline(Timeline::new_sequence("frame_nr"));
66+
test_context.with_blueprint_ctx(|ctx| {
67+
ctx.set_timeline(TimelineName::new("frame_nr"));
68+
});
6569

6670
let mut harness = test_context
6771
.setup_kittest_for_rendering()
@@ -103,7 +107,7 @@ fn blueprint_panel_filter_active_inside_origin_should_match_snapshot() {
103107
let (test_context, blueprint_tree) = setup_filter_test(Some("left"));
104108

105109
run_blueprint_panel_and_save_snapshot(
106-
test_context,
110+
&test_context,
107111
blueprint_tree,
108112
"blueprint_panel_filter_active_inside_origin",
109113
);
@@ -114,7 +118,7 @@ fn blueprint_panel_filter_active_outside_origin_should_match_snapshot() {
114118
let (test_context, blueprint_tree) = setup_filter_test(Some("out"));
115119

116120
run_blueprint_panel_and_save_snapshot(
117-
test_context,
121+
&test_context,
118122
blueprint_tree,
119123
"blueprint_panel_filter_active_outside_origin",
120124
);
@@ -125,7 +129,7 @@ fn blueprint_panel_filter_active_above_origin_should_match_snapshot() {
125129
let (test_context, blueprint_tree) = setup_filter_test(Some("path"));
126130

127131
run_blueprint_panel_and_save_snapshot(
128-
test_context,
132+
&test_context,
129133
blueprint_tree,
130134
"blueprint_panel_filter_active_above_origin",
131135
);
@@ -182,12 +186,14 @@ fn add_point_to_chunk_builder(builder: ChunkBuilder) -> ChunkBuilder {
182186
}
183187

184188
fn run_blueprint_panel_and_save_snapshot(
185-
mut test_context: TestContext,
189+
test_context: &TestContext,
186190
mut blueprint_tree: BlueprintTree,
187191
snapshot_name: &str,
188192
) {
189193
// set the current timeline to the timeline where data was logged to
190-
test_context.set_active_timeline(Timeline::new_sequence("frame_nr"));
194+
test_context.with_blueprint_ctx(|ctx| {
195+
ctx.set_timeline(TimelineName::new("frame_nr"));
196+
});
191197

192198
let mut harness = test_context
193199
.setup_kittest_for_rendering()

crates/viewer/re_blueprint_tree/tests/range_selection_test.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ use egui_kittest::{OsThreshold, SnapshotOptions, kittest::Queryable as _};
55
use re_blueprint_tree::BlueprintTree;
66
use re_chunk_store::RowId;
77
use re_chunk_store::external::re_chunk::ChunkBuilder;
8-
use re_log_types::{Timeline, build_frame_nr};
8+
use re_log_types::{TimelineName, build_frame_nr};
99
use re_test_context::TestContext;
1010
use re_test_viewport::TestContextExt as _;
1111
use re_types::archetypes::Points3D;
12-
use re_viewer_context::{Contents, ViewClass as _, VisitorControlFlow};
12+
use re_viewer_context::{Contents, TimeBlueprintExt as _, ViewClass as _, VisitorControlFlow};
1313
use re_viewport_blueprint::{ViewBlueprint, ViewportBlueprint};
1414

1515
#[test]
@@ -29,7 +29,9 @@ fn test_range_selection_in_blueprint_tree() {
2929
let mut blueprint_tree = BlueprintTree::default();
3030

3131
// set the current timeline to the timeline where data was logged to
32-
test_context.set_active_timeline(Timeline::new_sequence("frame_nr"));
32+
test_context.with_blueprint_ctx(|ctx| {
33+
ctx.set_timeline(TimelineName::new("frame_nr"));
34+
});
3335

3436
let mut harness = test_context
3537
.setup_kittest_for_rendering()

crates/viewer/re_blueprint_tree/tests/view_structure_test.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use re_blueprint_tree::BlueprintTree;
1111
use re_blueprint_tree::data::BlueprintTreeData;
1212
use re_chunk_store::RowId;
1313
use re_chunk_store::external::re_chunk::ChunkBuilder;
14-
use re_log_types::{EntityPath, Timeline, build_frame_nr};
14+
use re_log_types::{EntityPath, TimelineName, build_frame_nr};
1515
use re_test_context::TestContext;
1616
use re_test_viewport::TestContextExt as _;
1717
use re_types::archetypes::Points3D;
1818
use re_ui::filter_widget::FilterState;
19-
use re_viewer_context::{RecommendedView, ViewClass as _, ViewId};
19+
use re_viewer_context::{RecommendedView, TimeBlueprintExt as _, ViewClass as _, ViewId};
2020
use re_viewport_blueprint::{ViewBlueprint, ViewportBlueprint};
2121

2222
const VIEW_ID: &str = "this-is-a-view-id";
@@ -163,7 +163,7 @@ fn test_all_snapshot_test_cases() {
163163
}
164164

165165
fn run_test_case(test_case: &TestCase, filter_query: Option<&str>) -> Result<(), SnapshotError> {
166-
let mut test_context = test_context(test_case);
166+
let test_context = test_context(test_case);
167167
let view_id = ViewId::hashed_from_str(VIEW_ID);
168168

169169
let mut blueprint_tree = BlueprintTree::default();
@@ -183,7 +183,9 @@ fn run_test_case(test_case: &TestCase, filter_query: Option<&str>) -> Result<(),
183183
}
184184

185185
// set the current timeline to the timeline where data was logged to
186-
test_context.set_active_timeline(Timeline::new_sequence("frame_nr"));
186+
test_context.with_blueprint_ctx(|ctx| {
187+
ctx.set_timeline(TimelineName::new("frame_nr"));
188+
});
187189

188190
let mut harness = test_context
189191
.setup_kittest_for_rendering()

crates/viewer/re_time_panel/tests/time_panel_filter_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn add_point_to_chunk_builder(builder: ChunkBuilder) -> ChunkBuilder {
116116
}
117117

118118
fn run_time_panel_and_save_snapshot(
119-
mut test_context: TestContext,
119+
test_context: TestContext,
120120
mut time_panel: TimePanel,
121121
snapshot_name: &str,
122122
) {

crates/viewer/re_time_panel/tests/time_panel_tests.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ use egui::Vec2;
55
use re_chunk_store::{LatestAtQuery, RowId};
66
use re_entity_db::InstancePath;
77
use re_log_types::{
8-
AbsoluteTimeRange, EntityPath, TimeInt, TimePoint, TimeType, Timeline, build_frame_nr,
8+
AbsoluteTimeRange, EntityPath, TimeInt, TimePoint, TimeType, Timeline, TimelineName,
9+
build_frame_nr,
910
example_components::{MyPoint, MyPoints},
1011
};
1112
use re_test_context::{TestContext, external::egui_kittest::SnapshotOptions};
1213
use re_time_panel::TimePanel;
1314
use re_types::archetypes::Points2D;
14-
use re_viewer_context::{CollapseScope, TimeView, blueprint_timeline};
15+
use re_viewer_context::{CollapseScope, TimeBlueprintExt as _, TimeView, blueprint_timeline};
1516
use re_viewport_blueprint::ViewportBlueprint;
1617

1718
fn add_sparse_data(test_context: &mut TestContext) {
@@ -39,7 +40,7 @@ pub fn time_panel_two_sections() {
3940
add_sparse_data(&mut test_context);
4041

4142
run_time_panel_and_save_snapshot(
42-
&mut test_context,
43+
&test_context,
4344
TimePanel::default(),
4445
300.0,
4546
false,
@@ -63,7 +64,7 @@ pub fn time_panel_two_sections_with_valid_range() {
6364
}
6465

6566
run_time_panel_and_save_snapshot(
66-
&mut test_context,
67+
&test_context,
6768
TimePanel::default(),
6869
300.0,
6970
false,
@@ -79,7 +80,7 @@ pub fn time_panel_two_sections_with_valid_range() {
7980
});
8081
}
8182
run_time_panel_and_save_snapshot(
82-
&mut test_context,
83+
&test_context,
8384
TimePanel::default(),
8485
300.0,
8586
false,
@@ -109,7 +110,7 @@ pub fn time_panel_two_sections_with_two_valid_ranges() {
109110
}
110111

111112
run_time_panel_and_save_snapshot(
112-
&mut test_context,
113+
&test_context,
113114
TimePanel::default(),
114115
300.0,
115116
false,
@@ -125,7 +126,7 @@ pub fn time_panel_two_sections_with_two_valid_ranges() {
125126
});
126127
}
127128
run_time_panel_and_save_snapshot(
128-
&mut test_context,
129+
&test_context,
129130
TimePanel::default(),
130131
300.0,
131132
false,
@@ -165,7 +166,7 @@ pub fn time_panel_dense_data() {
165166
});
166167

167168
run_time_panel_and_save_snapshot(
168-
&mut test_context,
169+
&test_context,
169170
TimePanel::default(),
170171
300.0,
171172
false,
@@ -243,11 +244,12 @@ pub fn test_various_entity_kinds_in_time_panel() {
243244

244245
log_data_for_various_entity_kinds_tests(&mut test_context);
245246

246-
test_context
247-
.recording_config
248-
.time_ctrl
249-
.write()
250-
.set_timeline_and_time(Timeline::new(timeline, TimeType::Sequence), time);
247+
test_context.with_blueprint_ctx(|ctx| {
248+
ctx.set_timeline_and_time(
249+
TimelineName::new(timeline),
250+
TimeInt::saturated_temporal_i64(time),
251+
);
252+
});
251253

252254
test_context
253255
.recording_config
@@ -358,7 +360,7 @@ pub fn log_static_data(test_context: &mut TestContext, entity_path: impl Into<En
358360
}
359361

360362
fn run_time_panel_and_save_snapshot(
361-
test_context: &mut TestContext,
363+
test_context: &TestContext,
362364
mut time_panel: TimePanel,
363365
height: f32,
364366
expand_all: bool,

crates/viewer/re_viewer/src/app.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ impl App {
11531153
self.command_sender
11541154
.send_system(SystemCommand::SetActiveTime {
11551155
store_id,
1156-
timeline: timeline,
1156+
timeline,
11571157
time: Some(timecell.value.into()),
11581158
});
11591159
}
@@ -3357,6 +3357,8 @@ impl BlueprintContext for AppBlueprintCtx<'_> {
33573357
&self.blueprint_query
33583358
}
33593359
}
3360+
3361+
/// Build a [`AppBlueprintCtx`] to interact with the active blueprint.
33603362
fn blueprint_ctx<'a>(
33613363
app_state: &mut AppState,
33623364
command_sender: &'a CommandSender,

0 commit comments

Comments
 (0)