Skip to content

Commit

Permalink
Add insta tests on BlueprintTreeData
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Jan 23, 2025
1 parent dbde5d1 commit 974a30a
Show file tree
Hide file tree
Showing 36 changed files with 1,890 additions and 40 deletions.
57 changes: 57 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3635,6 +3635,9 @@ dependencies = [
"console",
"lazy_static",
"linked-hash-map",
"pest",
"pest_derive",
"serde",
"similar",
]

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -5651,6 +5701,7 @@ dependencies = [
"re_view_spatial",
"re_viewer_context",
"re_viewport_blueprint",
"serde",
"smallvec",
]

Expand Down Expand Up @@ -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"
Expand Down
16 changes: 14 additions & 2 deletions crates/viewer/re_blueprint_tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"] }

6 changes: 6 additions & 0 deletions crates/viewer/re_blueprint_tree/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContainerData>,
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -129,6 +132,7 @@ impl ContainerData {
// ---

#[derive(Debug)]
#[cfg_attr(feature = "testing", derive(serde::Serialize, serde::Deserialize))]
pub struct ViewData {
pub id: ViewId,

Expand Down Expand Up @@ -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,

Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions crates/viewer/re_blueprint_tree/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs
expression: blueprint_tree_data
---
root_container:
id:
id: "<container-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: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs
expression: blueprint_tree_data
---
root_container:
id:
id: "<container-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: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
source: crates/viewer/re_blueprint_tree/tests/view_structure_test.rs
expression: blueprint_tree_data
---
root_container:
id:
id: "<container-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: []
Loading

0 comments on commit 974a30a

Please sign in to comment.