Skip to content

Commit 7647309

Browse files
committed
fixing tests
1 parent 859a286 commit 7647309

File tree

6 files changed

+61
-43
lines changed

6 files changed

+61
-43
lines changed
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

crates/viewer/re_selection_panel/src/selection_panel.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,10 @@ mod tests {
10981098
TimeType,
10991099
example_components::{MyPoint, MyPoints},
11001100
};
1101-
use re_test_context::{TestContext, external::egui_kittest::SnapshotOptions};
1101+
use re_test_context::{
1102+
TestContext,
1103+
external::egui_kittest::{SnapshotOptions, kittest::Queryable as _},
1104+
};
11021105
use re_test_viewport::{TestContextExt as _, TestView};
11031106
use re_types::archetypes;
11041107
use re_viewer_context::{RecommendedView, ViewClass as _, blueprint_timeline};
@@ -1182,10 +1185,7 @@ mod tests {
11821185
test_context.handle_system_commands();
11831186
});
11841187

1185-
let raw_input = harness.input_mut();
1186-
raw_input
1187-
.events
1188-
.push(egui::Event::PointerMoved(egui::Pos2 { x: 120.0, y: 80.0 }));
1188+
harness.get_by_label("test_app").hover();
11891189

11901190
harness.run();
11911191

crates/viewer/re_test_context/src/lib.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,31 @@ impl TestContext {
184184

185185
let (command_sender, command_receiver) = command_channel();
186186

187-
let recording_config = RecordingConfig::default();
188-
189187
let blueprint_query = LatestAtQuery::latest(blueprint_timeline());
190188

189+
let recording_config = {
190+
let ctx = TestBlueprintCtx {
191+
command_sender: &command_sender,
192+
current_blueprint: store_hub
193+
.active_blueprint()
194+
.expect("We should have an active blueprint now"),
195+
default_blueprint: store_hub.default_blueprint_for_app(
196+
store_hub
197+
.active_app()
198+
.expect("We should have an active app now"),
199+
),
200+
blueprint_query: &blueprint_query,
201+
};
202+
203+
RecordingConfig::from_blueprint(&ctx)
204+
};
205+
191206
let component_ui_registry = ComponentUiRegistry::new();
192207

193208
let reflection =
194209
re_types::reflection::generate_reflection().expect("Failed to generate reflection");
195210

196-
let this = Self {
211+
Self {
197212
app_options: Default::default(),
198213

199214
view_class_registry: Default::default(),
@@ -215,13 +230,7 @@ impl TestContext {
215230
called_setup_kittest_for_rendering: AtomicBool::new(false),
216231

217232
store_hub: Mutex::new(store_hub),
218-
};
219-
220-
this.with_blueprint_ctx(|ctx| {
221-
ctx.set_timeline("log_tick".into());
222-
});
223-
224-
this
233+
}
225234
}
226235

227236
/// Create a new test context that knows about a specific view class.
@@ -448,6 +457,7 @@ impl TestContext {
448457
.callback_resources
449458
.get_mut::<re_renderer::RenderContext>()
450459
.expect("No re_renderer::RenderContext in egui_render_state");
460+
451461
render_ctx.begin_frame();
452462

453463
let mut selection_state = self.selection_state.lock();
@@ -485,6 +495,14 @@ impl TestContext {
485495
drag_and_drop_manager: &drag_and_drop_manager,
486496
};
487497

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+
);
505+
488506
func(&ctx);
489507

490508
// If re_renderer was used, `setup_kittest_for_rendering` should have been called.

crates/viewer/re_viewer/src/app_blueprint.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::sync::Arc;
22

3-
use re_chunk::{Chunk, RowId};
3+
use re_chunk::{Chunk, RowId, TimePoint};
44
use re_chunk_store::LatestAtQuery;
55
use re_entity_db::EntityDb;
66
use re_log_types::EntityPath;
@@ -203,19 +203,9 @@ pub fn setup_welcome_screen_blueprint(welcome_screen_blueprint: &mut EntityDb) {
203203
(SELECTION_PANEL_PATH, PanelState::Hidden),
204204
(TIME_PANEL_PATH, PanelState::Hidden),
205205
] {
206-
let entity_path = EntityPath::from(panel_name);
207-
208206
let timepoint = re_viewer_context::blueprint_timepoint_for_writes(welcome_screen_blueprint);
209207

210-
let chunk = Chunk::builder(entity_path)
211-
.with_archetype(
212-
RowId::new(),
213-
timepoint,
214-
&PanelBlueprint::update_fields().with_state(value),
215-
)
216-
.build()
217-
// All builtin types, no reason for this to ever fail.
218-
.expect("Failed to build chunk.");
208+
let chunk = get_panel_state_chunk(panel_name, timepoint, value);
219209

220210
welcome_screen_blueprint
221211
.add_chunk(&Arc::new(chunk))
@@ -233,21 +223,9 @@ impl AppBlueprint<'_> {
233223
command_sender: &CommandSender,
234224
) {
235225
if let Some(blueprint_db) = self.blueprint_db {
236-
let entity_path = EntityPath::from(panel_name);
237-
238226
let timepoint = blueprint_timepoint_for_writes(blueprint_db);
239227

240-
let component_update: &dyn AsComponents = if panel_name == TIME_PANEL_PATH {
241-
&TimePanelBlueprint::update_fields().with_state(value)
242-
} else {
243-
&PanelBlueprint::update_fields().with_state(value)
244-
};
245-
246-
let chunk = Chunk::builder(entity_path)
247-
.with_archetype(RowId::new(), timepoint, component_update)
248-
.build()
249-
// All builtin types, no reason for this to ever fail.
250-
.expect("Failed to build chunk.");
228+
let chunk = get_panel_state_chunk(panel_name, timepoint, value);
251229

252230
command_sender.send_system(SystemCommand::AppendToStore(
253231
blueprint_db.store_id().clone(),
@@ -257,6 +235,22 @@ impl AppBlueprint<'_> {
257235
}
258236
}
259237

238+
fn get_panel_state_chunk(panel_name: &str, timepoint: TimePoint, value: PanelState) -> Chunk {
239+
let entity_path = EntityPath::from(panel_name);
240+
241+
let component_update: &dyn AsComponents = if panel_name == TIME_PANEL_PATH {
242+
&TimePanelBlueprint::update_fields().with_state(value)
243+
} else {
244+
&PanelBlueprint::update_fields().with_state(value)
245+
};
246+
247+
Chunk::builder(entity_path)
248+
.with_archetype(RowId::new(), timepoint, component_update)
249+
.build()
250+
// All builtin types, no reason for this to ever fail.
251+
.expect("Failed to build chunk.")
252+
}
253+
260254
fn load_panel_state(
261255
path: &EntityPath,
262256
blueprint_db: &re_entity_db::EntityDb,

rerun_py/rerun_sdk/rerun/blueprint/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,14 @@ def __init__(
468468
The time cursor for a timestamp timeline.
469469
470470
"""
471+
super().__init__(blueprint_path="time_panel", expanded=expanded, state=state)
472+
self.timeline = timeline
473+
471474
if sum(x is not None for x in (sequence_cursor, duration_cursor, timestamp_cursor)) > 1:
472475
raise ValueError(
473476
"At most one of `sequence`, `duration`, and `timestamp` must be set",
474477
)
475478

476-
super().__init__(blueprint_path="time_panel", expanded=expanded, state=state)
477-
self.timeline = timeline
478-
479479
if sequence_cursor is not None:
480480
self.time = sequence_cursor
481481
elif duration_cursor is not None:

0 commit comments

Comments
 (0)