From 974a30aa6377e8a5f25086be89ef32a77ade398e Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Thu, 23 Jan 2025 20:22:29 +0100 Subject: [PATCH] Add insta tests on `BlueprintTreeData` --- Cargo.lock | 57 +++++++ crates/viewer/re_blueprint_tree/Cargo.toml | 16 +- crates/viewer/re_blueprint_tree/src/data.rs | 6 + crates/viewer/re_blueprint_tree/src/lib.rs | 5 + .../view_structure_test__no-query-empty.snap | 32 ++++ ...tructure_test__no-query-multiple_proj.snap | 71 +++++++++ ...ucture_test__no-query-non_root_origin.snap | 83 ++++++++++ ..._test__no-query-proj_with_placeholder.snap | 134 ++++++++++++++++ ..._structure_test__no-query-root_origin.snap | 123 +++++++++++++++ ..._structure_test__no-query-single_proj.snap | 94 +++++++++++ ...ructure_test__no-query-unknown_origin.snap | 34 ++++ ...view_structure_test__query-path-empty.snap | 5 + ...ucture_test__query-path-multiple_proj.snap | 5 + ...ture_test__query-path-non_root_origin.snap | 5 + ...est__query-path-proj_with_placeholder.snap | 55 +++++++ ...tructure_test__query-path-root_origin.snap | 104 ++++++++++++ ...tructure_test__query-path-single_proj.snap | 5 + ...cture_test__query-path-unknown_origin.snap | 36 +++++ .../view_structure_test__query-t-empty.snap | 5 + ...structure_test__query-t-multiple_proj.snap | 64 ++++++++ ...ructure_test__query-t-non_root_origin.snap | 91 +++++++++++ ...e_test__query-t-proj_with_placeholder.snap | 148 ++++++++++++++++++ ...w_structure_test__query-t-root_origin.snap | 135 ++++++++++++++++ ...w_structure_test__query-t-single_proj.snap | 91 +++++++++++ ...tructure_test__query-t-unknown_origin.snap | 36 +++++ ...view_structure_test__query-void-empty.snap | 5 + ...ucture_test__query-void-multiple_proj.snap | 50 ++++++ ...ture_test__query-void-non_root_origin.snap | 61 ++++++++ ...est__query-void-proj_with_placeholder.snap | 61 ++++++++ ...tructure_test__query-void-root_origin.snap | 80 ++++++++++ ...tructure_test__query-void-single_proj.snap | 61 ++++++++ ...cture_test__query-void-unknown_origin.snap | 5 + .../tests/view_structure_test.rs | 107 +++++++++---- .../viewer/re_viewer_context/src/contents.rs | 1 + .../re_viewer_context/src/test_context.rs | 42 ++++- .../viewer/re_viewport_blueprint/src/view.rs | 17 +- 36 files changed, 1890 insertions(+), 40 deletions(-) create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-empty.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-multiple_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-non_root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-proj_with_placeholder.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-single_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-unknown_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-empty.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-multiple_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-non_root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-proj_with_placeholder.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-single_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-unknown_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-empty.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-multiple_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-non_root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-proj_with_placeholder.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-single_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-unknown_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-empty.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-multiple_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-non_root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-proj_with_placeholder.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-root_origin.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-single_proj.snap create mode 100644 crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-unknown_origin.snap diff --git a/Cargo.lock b/Cargo.lock index dd30a966c1f7..d0b1b67580eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3635,6 +3635,9 @@ dependencies = [ "console", "lazy_static", "linked-hash-map", + "pest", + "pest_derive", + "serde", "similar", ] @@ -4940,6 +4943,51 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" +dependencies = [ + "memchr", + "thiserror 2.0.7", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "pest_meta" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "petgraph" version = "0.6.5" @@ -5638,7 +5686,9 @@ dependencies = [ "egui", "egui_kittest", "egui_tiles", + "insta", "itertools 0.13.0", + "re_blueprint_tree", "re_chunk_store", "re_context_menu", "re_data_ui", @@ -5651,6 +5701,7 @@ dependencies = [ "re_view_spatial", "re_viewer_context", "re_viewport_blueprint", + "serde", "smallvec", ] @@ -9212,6 +9263,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "uds_windows" version = "1.1.0" diff --git a/crates/viewer/re_blueprint_tree/Cargo.toml b/crates/viewer/re_blueprint_tree/Cargo.toml index 4d6327fa1bde..f52ae4b1fb89 100644 --- a/crates/viewer/re_blueprint_tree/Cargo.toml +++ b/crates/viewer/re_blueprint_tree/Cargo.toml @@ -18,6 +18,11 @@ workspace = true [package.metadata.docs.rs] all-features = true +[features] +default = [] +testing = ["dep:serde"] + + [dependencies] re_context_menu.workspace = true re_data_ui.workspace = true @@ -33,13 +38,20 @@ re_viewport_blueprint.workspace = true egui.workspace = true egui_tiles.workspace = true itertools.workspace = true +serde = { workspace = true, optional = true } smallvec.workspace = true [dev-dependencies] -re_viewer_context = { workspace = true, features = ["testing"] } -re_viewport_blueprint = { workspace = true, features = ["testing"] } +# Trick to reliably auto-enable the testing feature when running tests +# see: https://github.com/rust-lang/cargo/issues/2911#issuecomment-1483256987 +re_blueprint_tree = { path = ".", default-features = false, features = ["testing"] } + re_chunk_store.workspace = true re_view_spatial.workspace = true +re_viewer_context = { workspace = true, features = ["testing"] } +re_viewport_blueprint = { workspace = true, features = ["testing"] } egui_kittest.workspace = true +insta = { workspace = true, features = ["redactions", "yaml"] } + diff --git a/crates/viewer/re_blueprint_tree/src/data.rs b/crates/viewer/re_blueprint_tree/src/data.rs index 09699d1a92e6..5438ef91f85b 100644 --- a/crates/viewer/re_blueprint_tree/src/data.rs +++ b/crates/viewer/re_blueprint_tree/src/data.rs @@ -25,6 +25,7 @@ use re_viewport_blueprint::{ContainerBlueprint, ViewBlueprint, ViewportBlueprint use crate::data_result_node_or_path::DataResultNodeOrPath; #[derive(Debug, Default)] +#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))] pub struct BlueprintTreeData { pub root_container: Option, } @@ -55,12 +56,14 @@ impl BlueprintTreeData { // --- #[derive(Debug)] +#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))] pub enum ContentsData { Container(ContainerData), View(ViewData), } #[derive(Debug)] +#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))] pub struct ContainerData { pub id: ContainerId, pub name: ContentsName, @@ -129,6 +132,7 @@ impl ContainerData { // --- #[derive(Debug)] +#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))] pub struct ViewData { pub id: ViewId, @@ -250,6 +254,7 @@ impl ViewData { /// The kind of thing we may be displaying in the tree #[derive(Debug)] +#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))] pub enum DataResultKind { EmptyOriginPlaceholder, @@ -259,6 +264,7 @@ pub enum DataResultKind { } #[derive(Debug)] +#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))] pub struct DataResultData { pub kind: DataResultKind, pub entity_path: EntityPath, diff --git a/crates/viewer/re_blueprint_tree/src/lib.rs b/crates/viewer/re_blueprint_tree/src/lib.rs index 7163bddc5aae..39cb4b301d8a 100644 --- a/crates/viewer/re_blueprint_tree/src/lib.rs +++ b/crates/viewer/re_blueprint_tree/src/lib.rs @@ -1,6 +1,11 @@ //! This crate implements the UI for the blueprint tree in the left panel. mod blueprint_tree; + +#[cfg(feature = "testing")] +pub mod data; + +#[cfg(not(feature = "testing"))] pub(crate) mod data; mod data_result_node_or_path; diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-empty.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-empty.snap new file mode 100644 index 000000000000..2feaee91c8e0 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-empty.snap @@ -0,0 +1,32 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: / + visible: true + default_open: false + origin_tree: + kind: EmptyOriginPlaceholder + entity_path: [] + visible: false + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: false + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-multiple_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-multiple_proj.snap new file mode 100644 index 000000000000..1381aa8dd448 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-multiple_proj.snap @@ -0,0 +1,71 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: center/way + visible: true + default_open: false + origin_tree: + kind: DataResult + entity_path: + - center + - way + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: way + highlight_sections: [] + default_open: false + children: [] + projection_trees: + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: false + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-non_root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-non_root_origin.snap new file mode 100644 index 000000000000..1c34f08bb8dd --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-non_root_origin.snap @@ -0,0 +1,83 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: path/to + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: false + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-proj_with_placeholder.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-proj_with_placeholder.snap new file mode 100644 index 000000000000..b88695c0da9c --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-proj_with_placeholder.snap @@ -0,0 +1,134 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: path/to + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: false + children: [] + projection_trees: + - kind: DataResult + entity_path: [] + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - center + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: center + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - center + - way + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: way + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: [] + default_open: false + children: + - kind: OriginProjectionPlaceholder + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: false + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-root_origin.snap new file mode 100644 index 000000000000..f9343e6d008b --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-root_origin.snap @@ -0,0 +1,123 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: / + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: [] + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - center + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: center + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - center + - way + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: way + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: false + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-single_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-single_proj.snap new file mode 100644 index 000000000000..ce683663ce9a --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-single_proj.snap @@ -0,0 +1,94 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: center/way + visible: true + default_open: false + origin_tree: + kind: DataResult + entity_path: + - center + - way + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: way + highlight_sections: [] + default_open: false + children: [] + projection_trees: + - kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: [] + default_open: false + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: false + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: false + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-unknown_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-unknown_origin.snap new file mode 100644 index 000000000000..0c48dcf8b8db --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__no-query-unknown_origin.snap @@ -0,0 +1,34 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: wrong/path + visible: true + default_open: false + origin_tree: + kind: EmptyOriginPlaceholder + entity_path: + - wrong + - path + visible: false + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: [] + default_open: false + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-empty.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-empty.snap new file mode 100644 index 000000000000..6007f31692d5 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-empty.snap @@ -0,0 +1,5 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: ~ diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-multiple_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-multiple_proj.snap new file mode 100644 index 000000000000..6007f31692d5 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-multiple_proj.snap @@ -0,0 +1,5 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: ~ diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-non_root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-non_root_origin.snap new file mode 100644 index 000000000000..6007f31692d5 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-non_root_origin.snap @@ -0,0 +1,5 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: ~ diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-proj_with_placeholder.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-proj_with_placeholder.snap new file mode 100644 index 000000000000..c44ad29efbf7 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-proj_with_placeholder.snap @@ -0,0 +1,55 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: path/to + visible: true + default_open: true + origin_tree: ~ + projection_trees: + - kind: DataResult + entity_path: [] + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: + - start: 0 + end: 4 + default_open: true + children: + - kind: OriginProjectionPlaceholder + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-root_origin.snap new file mode 100644 index 000000000000..ddacdc45341b --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-root_origin.snap @@ -0,0 +1,104 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: / + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: [] + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: + - start: 0 + end: 4 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: [] + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: [] + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: true + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-single_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-single_proj.snap new file mode 100644 index 000000000000..6007f31692d5 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-single_proj.snap @@ -0,0 +1,5 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: ~ diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-unknown_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-unknown_origin.snap new file mode 100644 index 000000000000..a51aa4a4aaa1 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-path-unknown_origin.snap @@ -0,0 +1,36 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: wrong/path + visible: true + default_open: true + origin_tree: + kind: EmptyOriginPlaceholder + entity_path: + - wrong + - path + visible: false + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: + - start: 0 + end: 4 + default_open: false + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-empty.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-empty.snap new file mode 100644 index 000000000000..6007f31692d5 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-empty.snap @@ -0,0 +1,5 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: ~ diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-multiple_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-multiple_proj.snap new file mode 100644 index 000000000000..51ab5d9ab110 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-multiple_proj.snap @@ -0,0 +1,64 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: center/way + visible: true + default_open: true + origin_tree: ~ + projection_trees: + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: + - start: 4 + end: 5 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: true + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-non_root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-non_root_origin.snap new file mode 100644 index 000000000000..a6476d68cb0e --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-non_root_origin.snap @@ -0,0 +1,91 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: path/to + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: + - start: 3 + end: 4 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: + - start: 4 + end: 5 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: true + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-proj_with_placeholder.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-proj_with_placeholder.snap new file mode 100644 index 000000000000..dbf1a33d5f1b --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-proj_with_placeholder.snap @@ -0,0 +1,148 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: path/to + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: + - start: 3 + end: 4 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: + - start: 4 + end: 5 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: true + children: [] + projection_trees: + - kind: DataResult + entity_path: [] + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - center + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: center + highlight_sections: + - start: 3 + end: 4 + default_open: true + children: + - kind: DataResult + entity_path: + - center + - way + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: way + highlight_sections: [] + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: + - start: 2 + end: 3 + default_open: true + children: + - kind: OriginProjectionPlaceholder + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-root_origin.snap new file mode 100644 index 000000000000..93868b845c45 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-root_origin.snap @@ -0,0 +1,135 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: / + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: [] + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - center + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: center + highlight_sections: + - start: 3 + end: 4 + default_open: true + children: + - kind: DataResult + entity_path: + - center + - way + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: way + highlight_sections: [] + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: + - start: 2 + end: 3 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: + - start: 3 + end: 4 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: + - start: 4 + end: 5 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: true + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-single_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-single_proj.snap new file mode 100644 index 000000000000..2e7f7e65577f --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-single_proj.snap @@ -0,0 +1,91 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: center/way + visible: true + default_open: true + origin_tree: ~ + projection_trees: + - kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - left + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: left + highlight_sections: + - start: 3 + end: 4 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - right + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: right + highlight_sections: + - start: 4 + end: 5 + default_open: true + children: [] + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: + - start: 0 + end: 1 + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: [] + default_open: true + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-unknown_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-unknown_origin.snap new file mode 100644 index 000000000000..02f9a114f0d0 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-t-unknown_origin.snap @@ -0,0 +1,36 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: wrong/path + visible: true + default_open: true + origin_tree: + kind: EmptyOriginPlaceholder + entity_path: + - wrong + - path + visible: false + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: + - start: 2 + end: 3 + default_open: false + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-empty.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-empty.snap new file mode 100644 index 000000000000..6007f31692d5 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-empty.snap @@ -0,0 +1,5 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: ~ diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-multiple_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-multiple_proj.snap new file mode 100644 index 000000000000..0ee5c05a2c6f --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-multiple_proj.snap @@ -0,0 +1,50 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: center/way + visible: true + default_open: true + origin_tree: ~ + projection_trees: + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: + - start: 0 + end: 4 + default_open: true + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-non_root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-non_root_origin.snap new file mode 100644 index 000000000000..289f2abdf691 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-non_root_origin.snap @@ -0,0 +1,61 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: path/to + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: + - start: 0 + end: 4 + default_open: true + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-proj_with_placeholder.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-proj_with_placeholder.snap new file mode 100644 index 000000000000..289f2abdf691 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-proj_with_placeholder.snap @@ -0,0 +1,61 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: path/to + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: + - start: 0 + end: 4 + default_open: true + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-root_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-root_origin.snap new file mode 100644 index 000000000000..40b426d93b85 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-root_origin.snap @@ -0,0 +1,80 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: / + visible: true + default_open: true + origin_tree: + kind: DataResult + entity_path: [] + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: / (root) + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: path + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: + - start: 0 + end: 4 + default_open: true + children: [] + projection_trees: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-single_proj.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-single_proj.snap new file mode 100644 index 000000000000..1843f67695e4 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-single_proj.snap @@ -0,0 +1,61 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: + id: + id: "" + name: + Placeholder: Grid + kind: Grid + visible: true + default_open: true + children: + - View: + id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + class_identifier: 3D + name: + Placeholder: center/way + visible: true + default_open: true + origin_tree: ~ + projection_trees: + - kind: DataResult + entity_path: + - path + - to + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: to + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: the + highlight_sections: [] + default_open: true + children: + - kind: DataResult + entity_path: + - path + - to + - the + - void + visible: true + view_id: + id: 0864e1b8-cec4-1b82-5b17-b9d628b8f4fe + label: void + highlight_sections: + - start: 0 + end: 4 + default_open: true + children: [] diff --git a/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-unknown_origin.snap b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-unknown_origin.snap new file mode 100644 index 000000000000..6007f31692d5 --- /dev/null +++ b/crates/viewer/re_blueprint_tree/tests/snapshots/view_structure_test__query-void-unknown_origin.snap @@ -0,0 +1,5 @@ +--- +source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +expression: blueprint_tree_data +--- +root_container: ~ diff --git a/crates/viewer/re_blueprint_tree/tests/view_structure_test.rs b/crates/viewer/re_blueprint_tree/tests/view_structure_test.rs index dd1e3e961da4..247fd0f6ba10 100644 --- a/crates/viewer/re_blueprint_tree/tests/view_structure_test.rs +++ b/crates/viewer/re_blueprint_tree/tests/view_structure_test.rs @@ -4,16 +4,21 @@ use egui::Vec2; use egui_kittest::{SnapshotError, SnapshotOptions}; use itertools::Itertools; + +use re_blueprint_tree::data::BlueprintTreeData; use re_blueprint_tree::BlueprintTree; use re_chunk_store::external::re_chunk::ChunkBuilder; use re_chunk_store::RowId; use re_log_types::{build_frame_nr, EntityPath}; use re_types::archetypes::Points3D; +use re_ui::filter_widget::FilterState; use re_viewer_context::test_context::TestContext; -use re_viewer_context::{RecommendedView, ViewClass}; +use re_viewer_context::{RecommendedView, ViewClass, ViewId}; use re_viewport_blueprint::test_context_ext::TestContextExt; use re_viewport_blueprint::{ViewBlueprint, ViewportBlueprint}; +const VIEW_ID: &str = "this-is-a-view-id"; + #[derive(Debug, Clone, Copy)] enum RecordingKind { /// No entities are logged. @@ -81,12 +86,16 @@ fn base_test_cases() -> impl Iterator { .into_iter() } -fn test_context(kind: RecordingKind) -> TestContext { +fn filter_queries() -> impl Iterator> { + [None, Some("t"), Some("void"), Some("path")].into_iter() +} + +fn test_context(test_case: &TestCase) -> TestContext { let mut test_context = TestContext::default(); test_context.register_view_class::(); - match kind { + match test_case.recording_kind { RecordingKind::Emtpy => {} RecordingKind::Regular => { test_context.log_entity("/path/to/left".into(), add_point_to_chunk_builder); @@ -96,6 +105,22 @@ fn test_context(kind: RecordingKind) -> TestContext { } } + test_context.setup_viewport_blueprint(|_, blueprint| { + let view = ViewBlueprint::new_with_id( + re_view_spatial::SpatialView3D::identifier(), + RecommendedView { + origin: test_case.origin.clone(), + query_filter: test_case + .entity_filter + .try_into() + .expect("invalid entity filter"), + }, + ViewId::hashed_from_str(VIEW_ID), + ); + + blueprint.add_views(std::iter::once(view), None, None); + }); + test_context } @@ -108,12 +133,11 @@ fn add_point_to_chunk_builder(builder: ChunkBuilder) -> ChunkBuilder { } #[test] -fn run_all_test_cases() { - let errors = [None, Some("t"), Some("void"), Some("path")] - .into_iter() +fn test_all_snapshot_test_cases() { + let errors = filter_queries() .flat_map(|filter_query| { base_test_cases() - .map(move |test_case| (filter_query, run_test_case(test_case, filter_query))) + .map(move |test_case| (filter_query, run_test_case(&test_case, filter_query))) }) .filter_map(|(filter_query, result)| result.err().map(|err| (filter_query, err))) .collect_vec(); @@ -125,29 +149,9 @@ fn run_all_test_cases() { assert!(errors.is_empty(), "Some test cases failed"); } -fn run_test_case(test_case: TestCase, filter_query: Option<&str>) -> Result<(), SnapshotError> { - let mut test_context = test_context(test_case.recording_kind); - - let view_id = test_context.setup_viewport_blueprint(|_, blueprint| { - let view = ViewBlueprint::new( - re_view_spatial::SpatialView3D::identifier(), - RecommendedView { - origin: test_case.origin, - query_filter: test_case - .entity_filter - .try_into() - .expect("invalid entity filter"), - }, - ); - - let view_id = view.id; - blueprint.add_views(std::iter::once(view), None, None); - - // TODO(ab): add containers in the hierarchy (requires work on the container API, - // currently very cumbersome to use for testing purposes). - - view_id - }); +fn run_test_case(test_case: &TestCase, filter_query: Option<&str>) -> Result<(), SnapshotError> { + let mut test_context = test_context(test_case); + let view_id = ViewId::hashed_from_str(VIEW_ID); let mut blueprint_tree = BlueprintTree::default(); @@ -198,3 +202,46 @@ fn run_test_case(test_case: TestCase, filter_query: Option<&str>) -> Result<(), )); harness.try_snapshot_options(test_case.name, &options) } + +// --- + +#[test] +fn test_all_insta_test_cases() { + for test_case in base_test_cases() { + for filter_query in filter_queries() { + let test_context = test_context(&test_case); + + let blueprint_tree_data = + test_context.run_once_in_egui_central_panel(|viewer_ctx, _| { + let blueprint = ViewportBlueprint::try_from_db( + viewer_ctx.store_context.blueprint, + viewer_ctx.blueprint_query, + ); + + let mut filter_state = FilterState::default(); + + if let Some(filter_query) = filter_query { + filter_state.activate(filter_query); + } + + BlueprintTreeData::from_blueprint_and_filter( + viewer_ctx, + &blueprint, + &filter_state.filter(), + ) + }); + + let snapshot_name = format!( + "{}-{}", + filter_query + .map(|query| format!("query-{query}")) + .unwrap_or("no-query".to_owned()), + test_case.name + ); + + insta::assert_yaml_snapshot!(snapshot_name, blueprint_tree_data, { + ".root_container.id.id" => "" + }); + } + } +} diff --git a/crates/viewer/re_viewer_context/src/contents.rs b/crates/viewer/re_viewer_context/src/contents.rs index 558fbe8ad941..2290c5c44bd4 100644 --- a/crates/viewer/re_viewer_context/src/contents.rs +++ b/crates/viewer/re_viewer_context/src/contents.rs @@ -101,6 +101,7 @@ impl From for Contents { /// The name of a [`Contents`]. #[derive(Clone, Debug)] +#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))] pub enum ContentsName { /// This [`Contents`] has been given a name by the user. Named(String), diff --git a/crates/viewer/re_viewer_context/src/test_context.rs b/crates/viewer/re_viewer_context/src/test_context.rs index 21e1ac379b1d..d00d5ef41eff 100644 --- a/crates/viewer/re_viewer_context/src/test_context.rs +++ b/crates/viewer/re_viewer_context/src/test_context.rs @@ -305,8 +305,9 @@ impl TestContext { /// Notes: /// - Uses [`egui::__run_test_ctx`]. /// - There is a possibility that the closure will be called more than once, see - /// [`egui::Context::run`]. - //TODO(ab): replace this with a kittest-based helper. + /// [`egui::Context::run`]. Use [`Self::run_once_in_egui_central_panel`] if you want to ensure + /// that the closure is called exactly once. + //TODO(ab): should this be removed entirely in favor of `run_once_in_egui_central_panel`? pub fn run_in_egui_central_panel( &self, mut func: impl FnMut(&ViewerContext<'_>, &mut egui::Ui), @@ -322,6 +323,36 @@ impl TestContext { }); } + /// Run the given function once with a [`ViewerContext`] produced by the [`Self`], in the + /// context of an [`egui::CentralPanel`]. + /// + /// IMPORTANT: call [`Self::handle_system_commands`] after calling this function if your test + /// relies on system commands. + /// + /// Notes: + /// - Uses [`egui::__run_test_ctx`]. + pub fn run_once_in_egui_central_panel( + &self, + func: impl FnOnce(&ViewerContext<'_>, &mut egui::Ui) -> R, + ) -> R { + let mut func = Some(func); + let mut result = None; + + egui::__run_test_ctx(|ctx| { + egui::CentralPanel::default().show(ctx, |ui| { + let egui_ctx = ui.ctx().clone(); + + self.run(&egui_ctx, |ctx| { + if let Some(func) = func.take() { + result = Some(func(ctx, ui)); + } + }); + }); + }); + + result.expect("Function should have been called at least once") + } + /// Best-effort attempt to meaningfully handle some of the system commands. pub fn handle_system_commands(&mut self) { while let Some(command) = self.command_receiver.recv_system() { @@ -379,10 +410,9 @@ impl TestContext { SystemCommand::FileSaver(_) => handled = false, } - eprintln!( - "{} system command: {command_name:?}", - if handled { "Handled" } else { "Ignored" } - ); + if !handled { + eprintln!("Ignored system command: {command_name:?}",); + } } } } diff --git a/crates/viewer/re_viewport_blueprint/src/view.rs b/crates/viewer/re_viewport_blueprint/src/view.rs index 5b65507fd3be..84e14ca6c4a4 100644 --- a/crates/viewer/re_viewport_blueprint/src/view.rs +++ b/crates/viewer/re_viewport_blueprint/src/view.rs @@ -66,11 +66,24 @@ impl ViewBlueprint { /// Creates a new [`ViewBlueprint`] with a single [`ViewContents`]. /// - /// This [`ViewBlueprint`] is ephemeral. If you want to make it permanent you + /// This [`ViewBlueprint`] is ephemeral. If you want to make it permanent, you /// must call [`Self::save_to_blueprint_store`]. pub fn new(view_class: ViewClassIdentifier, recommended: RecommendedView) -> Self { - let id = ViewId::random(); + Self::new_with_id(view_class, recommended, ViewId::random()) + } + /// Creates a new [`ViewBlueprint`] with a single [`ViewContents`], using the provided id. + /// + /// Useful for testing contexts where random ids are not desired. Avoid using in production + /// code. + /// + /// This [`ViewBlueprint`] is ephemeral. If you want to make it permanent, you + /// must call [`Self::save_to_blueprint_store`]. + pub fn new_with_id( + view_class: ViewClassIdentifier, + recommended: RecommendedView, + id: ViewId, + ) -> Self { let path_subs = EntityPathSubs::new_with_origin(&recommended.origin); let query_filter = recommended.query_filter.resolve_forgiving(&path_subs);