Skip to content

Commit 9b453be

Browse files
MichaelGruppWumpf
andauthored
Enable "Close current recording" only when there's a recording (#11353)
Adds also a snapshot test where the menu is opened on an empty start screen without dataset. --------- Co-authored-by: Andreas Reich <[email protected]>
1 parent 750dae5 commit 9b453be

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

crates/viewer/re_viewer/src/ui/rerun_menu.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ impl App {
7575

7676
UICommand::SaveBlueprint.menu_button_ui(ui, &self.command_sender);
7777

78-
UICommand::CloseCurrentRecording.menu_button_ui(ui, &self.command_sender);
78+
let has_recording = _store_context.is_some_and(|ctx| !ctx.recording.is_empty());
79+
ui.add_enabled_ui(has_recording, |ui| {
80+
UICommand::CloseCurrentRecording.menu_button_ui(ui, &self.command_sender);
81+
});
7982

8083
ui.add_space(SPACING);
8184

crates/viewer/re_viewer/src/viewer_test_utils/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ pub fn viewer_harness() -> Harness<'static, App> {
1919
build_info!(),
2020
AppEnvironment::Test,
2121
StartupOptions {
22+
// Don't show the welcome / example screen in tests.
23+
// See also: https://github.com/rerun-io/rerun/issues/10989
24+
hide_welcome_screen: true,
2225
// Don't calculate memory limit in tests.
2326
memory_limit: re_memory::MemoryLimit::UNLIMITED,
2427
..Default::default()

crates/viewer/re_viewer/tests/app_kittest.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ async fn settings_screen() {
4141
harness.snapshot("settings_screen");
4242
}
4343

44+
/// Opens the Rerun menu without an active recording and snapshots the app.
45+
/// Tests that certain recording-related entries are disabled (e.g. save or close recording).
46+
#[tokio::test]
47+
async fn menu_without_recording() {
48+
let mut harness = viewer_test_utils::viewer_harness();
49+
harness.get_by_label("Menu").click();
50+
harness.run_ok();
51+
harness.snapshot_options(
52+
"menu_without_recording",
53+
&SnapshotOptions::new().failed_pixel_count_threshold(2),
54+
);
55+
}
56+
4457
/// Tests the colormap selector UI with snapshot testing.
4558
/// This is defined here instead of in `re_viewer/tests` because it depends on `re_test_context`,
4659
/// which depends on `re_viewer_context`.
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)