-
Notifications
You must be signed in to change notification settings - Fork 572
Integration tests for origin heuristics #11620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
906631a
dc6a4e2
2bc740d
1d42baa
bef288b
95038f8
fe0190e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,246 @@ | ||
| use egui_kittest::kittest::Queryable as _; | ||
| use re_integration_test::HarnessExt as _; | ||
| use re_sdk::TimePoint; | ||
| use re_sdk::log::RowId; | ||
| use re_viewer::external::re_viewer_context::ViewClass as _; | ||
| use re_viewer::external::{re_types, re_view_spatial}; | ||
| use re_viewer::viewer_test_utils::{self, HarnessOptions}; | ||
| use re_viewport_blueprint::ViewBlueprint; | ||
|
|
||
| fn make_test_image() -> re_types::archetypes::Image { | ||
| let image = ndarray::Array3::from_shape_fn((256, 256, 3), |(y, x, c)| match c { | ||
| 0 => x as u8, | ||
| 1 => y as u8, | ||
| 2 => 128, | ||
| _ => unreachable!(), | ||
| }); | ||
|
Comment on lines
+10
to
+16
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| re_types::archetypes::Image::from_color_model_and_tensor( | ||
| re_types::datatypes::ColorModel::RGB, | ||
| image, | ||
| ) | ||
| .expect("Failed to create image") | ||
| } | ||
|
|
||
| fn make_test_harness<'a>() -> egui_kittest::Harness<'a, re_viewer::App> { | ||
| let mut harness = viewer_test_utils::viewer_harness(&HarnessOptions::default()); | ||
| harness.init_recording(); | ||
| harness.set_selection_panel_opened(true); | ||
|
|
||
| // Log some data | ||
| harness.log_entity("/", |builder| { | ||
| builder.with_archetype( | ||
| RowId::new(), | ||
| TimePoint::default(), | ||
| &re_types::archetypes::Boxes3D::from_centers_and_half_sizes( | ||
| [(0.0, 0.0, 0.0)], | ||
| [(0.3, 0.3, 0.3)], | ||
| ) | ||
| .with_colors([0xFF9001FF]), | ||
| ) | ||
| }); | ||
|
|
||
| harness.log_entity("/world", |builder| { | ||
| builder.with_archetype( | ||
| RowId::new(), | ||
| TimePoint::default(), | ||
| &re_types::archetypes::ViewCoordinates::RIGHT_HAND_Y_DOWN(), | ||
| ) | ||
| }); | ||
|
|
||
| harness.log_entity("/world/camera", |builder| { | ||
| builder.with_archetype( | ||
| RowId::new(), | ||
| TimePoint::default(), | ||
| &re_types::archetypes::Transform3D::from_rotation( | ||
| re_types::components::RotationAxisAngle::new( | ||
| [-1.0, 0.9, 0.0], | ||
| std::f32::consts::PI / 2.0, | ||
| ), | ||
| ), | ||
| ) | ||
| }); | ||
|
|
||
| harness.log_entity("/world/camera/image", |builder| { | ||
| builder.with_archetype( | ||
| RowId::new(), | ||
| TimePoint::default(), | ||
| &re_types::archetypes::Pinhole::from_focal_length_and_resolution( | ||
| [128.0, 128.0], | ||
| [256.0, 256.0], | ||
| ) | ||
| .with_principal_point([128.0, 128.0]) | ||
| .with_image_plane_distance(0.2), | ||
| ) | ||
| }); | ||
|
|
||
| harness.log_entity("/world/camera/image", |builder| { | ||
| builder.with_archetype(RowId::new(), TimePoint::default(), &make_test_image()) | ||
| }); | ||
|
|
||
| harness.log_entity("/world/camera/image/keypoint", |builder| { | ||
| builder.with_archetype( | ||
| RowId::new(), | ||
| TimePoint::default(), | ||
| &re_types::archetypes::Points2D::new([(10.0, 10.0), (128.0, -0.0), (50.0, -50.0)]) | ||
| .with_radii([-10.0, -10.0, -10.0]) | ||
| .with_colors([0xFF9001FF, 0x9001FFFF, 0x90FF01FF]), | ||
| ) | ||
| }); | ||
|
|
||
| // Set up a multi-view blueprint | ||
| harness.clear_current_blueprint(); | ||
|
|
||
| let mut view3d = | ||
| ViewBlueprint::new_with_root_wildcard(re_view_spatial::SpatialView3D::identifier()); | ||
| view3d.display_name = Some("3D view".into()); | ||
|
|
||
| harness.setup_viewport_blueprint(move |_viewer_context, blueprint| { | ||
| blueprint.add_view_at_root(view3d); | ||
| }); | ||
|
|
||
| harness | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_keypoint_3d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.right_click_at(harness.get_by_label("keypoint").rect().left_center()); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("3D"); | ||
| harness.snapshot_app("origin_keypoint_3d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_keypoint_2d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.right_click_at(harness.get_by_label("keypoint").rect().left_center()); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("2D"); | ||
| harness.remove_cursor(); | ||
| harness.snapshot_app("origin_keypoint_2d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_image_3d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| // Close the selection panel before clicking on the image entity | ||
| // because rendering its download button requires the UI to be on | ||
| // the main thread. We are in a tokio test and it will crash. | ||
| harness.set_selection_panel_opened(false); | ||
|
Comment on lines
+139
to
+142
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this about? Is this related to What happens if you remove this line? Does something crash? |
||
|
|
||
| harness.blueprint_tree().right_click_label("image"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("3D"); | ||
| harness.set_selection_panel_opened(true); | ||
| harness.snapshot_app("origin_image_3d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_image_2d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| // Close the selection panel before clicking on the image entity | ||
| // because rendering its download button requires the UI to be on | ||
| // the main thread. We are in a tokio test and it will crash. | ||
| harness.set_selection_panel_opened(false); | ||
|
|
||
| harness.blueprint_tree().right_click_label("image"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("2D"); | ||
| harness.set_selection_panel_opened(true); | ||
| harness.snapshot_app("origin_image_2d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_camera_3d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.blueprint_tree().right_click_label("camera"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("3D"); | ||
| harness.snapshot_app("origin_camera_3d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_camera_2d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.blueprint_tree().right_click_label("camera"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("2D"); | ||
| harness.snapshot_app("origin_camera_2d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_world_3d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.blueprint_tree().right_click_label("world"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("3D"); | ||
| harness.snapshot_app("origin_world_3d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_world_2d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.blueprint_tree().right_click_label("world"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("2D"); | ||
| harness.snapshot_app("origin_world_2d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_root_3d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.blueprint_tree().right_click_label("/ (root)"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("3D"); | ||
| harness.snapshot_app("origin_root_3d"); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| pub async fn test_origin_root_2d() { | ||
| let mut harness = make_test_harness(); | ||
|
|
||
| harness.blueprint_tree().right_click_label("3D view"); | ||
| harness.click_label("Expand all"); | ||
|
|
||
| harness.blueprint_tree().right_click_label("/ (root)"); | ||
| harness.hover_label_contains("Add to new view"); | ||
| harness.click_label("2D"); | ||
| harness.snapshot_app("origin_root_2d"); | ||
| } | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have a module-level comment explaining roughly what this test is all about