Extract grid UI operation planning
This commit is contained in:
@@ -278,6 +278,16 @@ add_test(NAME pp_app_core_brush_ui_tests COMMAND pp_app_core_brush_ui_tests)
|
||||
set_tests_properties(pp_app_core_brush_ui_tests PROPERTIES
|
||||
LABELS "app;paint;desktop-fast;fuzz")
|
||||
|
||||
add_executable(pp_app_core_grid_ui_tests
|
||||
app_core/grid_ui_tests.cpp)
|
||||
target_link_libraries(pp_app_core_grid_ui_tests PRIVATE
|
||||
pp_app_core
|
||||
pp_test_harness)
|
||||
|
||||
add_test(NAME pp_app_core_grid_ui_tests COMMAND pp_app_core_grid_ui_tests)
|
||||
set_tests_properties(pp_app_core_grid_ui_tests PROPERTIES
|
||||
LABELS "app;ui;renderer;desktop-fast;fuzz")
|
||||
|
||||
add_executable(pp_app_core_document_route_tests
|
||||
app_core/document_route_tests.cpp)
|
||||
target_link_libraries(pp_app_core_document_route_tests PRIVATE
|
||||
@@ -816,6 +826,42 @@ if(TARGET pano_cli)
|
||||
LABELS "app;paint;integration;desktop-fast;fuzz"
|
||||
WILL_FAIL TRUE)
|
||||
|
||||
add_test(NAME pano_cli_plan_grid_operation_pick_smoke
|
||||
COMMAND pano_cli plan-grid-operation --kind pick)
|
||||
set_tests_properties(pano_cli_plan_grid_operation_pick_smoke PROPERTIES
|
||||
LABELS "app;ui;renderer;integration;desktop-fast"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-grid-operation\".*\"operation\":\"request-heightmap-pick\".*\"opensPicker\":true.*\"mutatesGridState\":false")
|
||||
|
||||
add_test(NAME pano_cli_plan_grid_operation_load_smoke
|
||||
COMMAND pano_cli plan-grid-operation --kind load --path D:/Paint/height.png)
|
||||
set_tests_properties(pano_cli_plan_grid_operation_load_smoke PROPERTIES
|
||||
LABELS "app;ui;renderer;integration;desktop-fast"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-grid-operation\".*\"operation\":\"load-heightmap\".*\"path\":\"D:/Paint/height.png\".*\"loadsHeightmap\":true.*\"updatesPreview\":true.*\"updatesGroundOpacity\":true")
|
||||
|
||||
add_test(NAME pano_cli_plan_grid_operation_render_supported_smoke
|
||||
COMMAND pano_cli plan-grid-operation --kind render --float32 --texture-resolution 1024 --samples 32)
|
||||
set_tests_properties(pano_cli_plan_grid_operation_render_supported_smoke PROPERTIES
|
||||
LABELS "app;ui;renderer;integration;desktop-fast"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-grid-operation\".*\"operation\":\"render-lightmap\".*\"textureResolution\":1024.*\"sampleCount\":32.*\"rendersLightmap\":true.*\"updatesShadingMode\":true.*\"showsProgress\":true")
|
||||
|
||||
add_test(NAME pano_cli_plan_grid_operation_render_unsupported_smoke
|
||||
COMMAND pano_cli plan-grid-operation --kind render)
|
||||
set_tests_properties(pano_cli_plan_grid_operation_render_unsupported_smoke PROPERTIES
|
||||
LABELS "app;ui;renderer;integration;desktop-fast;fuzz"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-grid-operation\".*\"operation\":\"render-lightmap\".*\"rendersLightmap\":false.*\"showsUnsupportedMessage\":true")
|
||||
|
||||
add_test(NAME pano_cli_plan_grid_operation_rejects_empty_reload
|
||||
COMMAND pano_cli plan-grid-operation --kind reload)
|
||||
set_tests_properties(pano_cli_plan_grid_operation_rejects_empty_reload PROPERTIES
|
||||
LABELS "app;ui;renderer;integration;desktop-fast;fuzz"
|
||||
WILL_FAIL TRUE)
|
||||
|
||||
add_test(NAME pano_cli_plan_grid_operation_rejects_bad_samples
|
||||
COMMAND pano_cli plan-grid-operation --kind render --float32 --samples 0)
|
||||
set_tests_properties(pano_cli_plan_grid_operation_rejects_bad_samples PROPERTIES
|
||||
LABELS "app;ui;renderer;integration;desktop-fast;fuzz"
|
||||
WILL_FAIL TRUE)
|
||||
|
||||
add_test(NAME pano_cli_plan_share_file_unsaved_smoke
|
||||
COMMAND pano_cli plan-share-file)
|
||||
set_tests_properties(pano_cli_plan_share_file_unsaved_smoke PROPERTIES
|
||||
|
||||
99
tests/app_core/grid_ui_tests.cpp
Normal file
99
tests/app_core/grid_ui_tests.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
#include "app_core/grid_ui.h"
|
||||
#include "test_harness.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void heightmap_load_reload_and_clear_plan_state(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto pick = pp::app::plan_grid_heightmap_pick();
|
||||
PP_EXPECT(harness, pick.operation == pp::app::GridUiOperation::request_heightmap_pick);
|
||||
PP_EXPECT(harness, pick.opens_picker);
|
||||
PP_EXPECT(harness, !pick.mutates_grid_state);
|
||||
|
||||
const auto load = pp::app::plan_grid_heightmap_load("D:/Paint/height.png");
|
||||
PP_EXPECT(harness, load);
|
||||
if (load) {
|
||||
PP_EXPECT(harness, load.value().operation == pp::app::GridUiOperation::load_heightmap);
|
||||
PP_EXPECT(harness, load.value().path == "D:/Paint/height.png");
|
||||
PP_EXPECT(harness, load.value().loads_heightmap);
|
||||
PP_EXPECT(harness, load.value().updates_preview);
|
||||
PP_EXPECT(harness, load.value().updates_ground_opacity);
|
||||
}
|
||||
|
||||
const auto reload = pp::app::plan_grid_heightmap_reload("D:/Paint/height.png");
|
||||
PP_EXPECT(harness, reload);
|
||||
if (reload) {
|
||||
PP_EXPECT(harness, reload.value().operation == pp::app::GridUiOperation::reload_heightmap);
|
||||
PP_EXPECT(harness, reload.value().loads_heightmap);
|
||||
PP_EXPECT(harness, !reload.value().updates_ground_opacity);
|
||||
}
|
||||
|
||||
const auto clear_existing = pp::app::plan_grid_heightmap_clear(true);
|
||||
PP_EXPECT(harness, clear_existing.clears_heightmap);
|
||||
PP_EXPECT(harness, clear_existing.updates_preview);
|
||||
PP_EXPECT(harness, clear_existing.mutates_grid_state);
|
||||
|
||||
const auto clear_empty = pp::app::plan_grid_heightmap_clear(false);
|
||||
PP_EXPECT(harness, clear_empty.clears_heightmap);
|
||||
PP_EXPECT(harness, !clear_empty.updates_preview);
|
||||
PP_EXPECT(harness, !clear_empty.mutates_grid_state);
|
||||
|
||||
PP_EXPECT(harness, !pp::app::plan_grid_heightmap_load(""));
|
||||
PP_EXPECT(harness, !pp::app::plan_grid_heightmap_reload(""));
|
||||
}
|
||||
|
||||
void lightmap_render_validates_capabilities_and_limits(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto supported = pp::app::plan_grid_lightmap_render(true, true, false, 1024, 32);
|
||||
PP_EXPECT(harness, supported);
|
||||
if (supported) {
|
||||
PP_EXPECT(harness, supported.value().operation == pp::app::GridUiOperation::render_lightmap);
|
||||
PP_EXPECT(harness, supported.value().renders_lightmap);
|
||||
PP_EXPECT(harness, supported.value().shows_progress);
|
||||
PP_EXPECT(harness, supported.value().updates_shading_mode);
|
||||
PP_EXPECT(harness, supported.value().texture_resolution == 1024);
|
||||
PP_EXPECT(harness, supported.value().sample_count == 32);
|
||||
}
|
||||
|
||||
const auto missing_heightmap = pp::app::plan_grid_lightmap_render(false, true, false, 1024, 32);
|
||||
PP_EXPECT(harness, missing_heightmap);
|
||||
if (missing_heightmap) {
|
||||
PP_EXPECT(harness, !missing_heightmap.value().renders_lightmap);
|
||||
PP_EXPECT(harness, !missing_heightmap.value().shows_unsupported_message);
|
||||
}
|
||||
|
||||
const auto unsupported = pp::app::plan_grid_lightmap_render(true, false, false, 1024, 32);
|
||||
PP_EXPECT(harness, unsupported);
|
||||
if (unsupported) {
|
||||
PP_EXPECT(harness, unsupported.value().shows_unsupported_message);
|
||||
PP_EXPECT(harness, !unsupported.value().renders_lightmap);
|
||||
}
|
||||
|
||||
PP_EXPECT(harness, !pp::app::plan_grid_lightmap_render(true, true, false, 0, 32));
|
||||
PP_EXPECT(harness, !pp::app::plan_grid_lightmap_render(true, true, false, 1024, 0));
|
||||
PP_EXPECT(harness, !pp::app::plan_grid_lightmap_render(true, true, false, 20000, 32));
|
||||
PP_EXPECT(harness, !pp::app::plan_grid_lightmap_render(true, true, false, 1024, 4097));
|
||||
}
|
||||
|
||||
void commit_plan_requires_canvas(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto live = pp::app::plan_grid_heightmap_commit(true);
|
||||
PP_EXPECT(harness, live.operation == pp::app::GridUiOperation::commit_heightmap);
|
||||
PP_EXPECT(harness, live.commits_heightmap);
|
||||
PP_EXPECT(harness, live.updates_ground_opacity);
|
||||
|
||||
const auto headless = pp::app::plan_grid_heightmap_commit(false);
|
||||
PP_EXPECT(harness, !headless.commits_heightmap);
|
||||
PP_EXPECT(harness, !headless.mutates_grid_state);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
pp::tests::Harness harness;
|
||||
harness.run("heightmap load reload and clear plan state", heightmap_load_reload_and_clear_plan_state);
|
||||
harness.run("lightmap render validates capabilities and limits", lightmap_render_validates_capabilities_and_limits);
|
||||
harness.run("commit plan requires canvas", commit_plan_requires_canvas);
|
||||
return harness.finish();
|
||||
}
|
||||
Reference in New Issue
Block a user