Extract app status planning into app core
This commit is contained in:
@@ -328,6 +328,16 @@ add_test(NAME pp_app_core_app_preferences_tests COMMAND pp_app_core_app_preferen
|
||||
set_tests_properties(pp_app_core_app_preferences_tests PROPERTIES
|
||||
LABELS "app;desktop-fast;fuzz")
|
||||
|
||||
add_executable(pp_app_core_app_status_tests
|
||||
app_core/app_status_tests.cpp)
|
||||
target_link_libraries(pp_app_core_app_status_tests PRIVATE
|
||||
pp_app_core
|
||||
pp_test_harness)
|
||||
|
||||
add_test(NAME pp_app_core_app_status_tests COMMAND pp_app_core_app_status_tests)
|
||||
set_tests_properties(pp_app_core_app_status_tests PROPERTIES
|
||||
LABELS "app;desktop-fast;fuzz")
|
||||
|
||||
add_executable(pp_app_core_document_sharing_tests
|
||||
app_core/document_sharing_tests.cpp)
|
||||
target_link_libraries(pp_app_core_document_sharing_tests PRIVATE
|
||||
@@ -637,6 +647,27 @@ if(TARGET pano_cli)
|
||||
LABELS "app;integration;desktop-fast;fuzz"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-app-preferences\".*\"scaleSelection\":\\{\"hasSelection\":false,\"index\":0\\}.*\"direction\":\"left-to-right\".*\"timelapse\":\\{\"enabled\":false,\"recordingAction\":\"stop-recording\"\\}.*\"vrControllers\":\\{\"enabled\":false\\}")
|
||||
|
||||
add_test(NAME pano_cli_plan_app_status_smoke
|
||||
COMMAND pano_cli plan-app-status
|
||||
--doc-name demo
|
||||
--unsaved
|
||||
--resolution 2048
|
||||
--resolution-index 3
|
||||
--zoom 1.26
|
||||
--history-bytes 1572864
|
||||
--recording-running
|
||||
--encoder-available
|
||||
--encoded-frames 12)
|
||||
set_tests_properties(pano_cli_plan_app_status_smoke PROPERTIES
|
||||
LABELS "app;integration;desktop-fast"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-app-status\".*\"title\":\"Panodoc: demo\\* \\(8K\\)\".*\"dpi\":\"1.3x-dpi\".*\"memory\":\"History memory: 1.50 Mb\".*\"recording\":\\{\"visible\":true,\"text\":\"Recorded 12 frames\"\\}.*\"fromIndexValid\":true.*\"fromIndex\":2048.*\"toIndexValid\":true.*\"toIndex\":3.*\"labelValid\":true.*\"label\":\"8K\"")
|
||||
|
||||
add_test(NAME pano_cli_plan_app_status_unknown_resolution_smoke
|
||||
COMMAND pano_cli plan-app-status --doc-name demo --resolution 1234 --resolution-index 9 --recording-running)
|
||||
set_tests_properties(pano_cli_plan_app_status_unknown_resolution_smoke PROPERTIES
|
||||
LABELS "app;integration;desktop-fast;fuzz"
|
||||
PASS_REGULAR_EXPRESSION "\"command\":\"plan-app-status\".*\"title\":\"Panodoc: demo \\(unknown\\)\".*\"recording\":\\{\"visible\":false,\"text\":\"\"\\}.*\"fromIndexValid\":false.*\"toIndexValid\":false.*\"labelValid\":false.*\"label\":\"\"")
|
||||
|
||||
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
|
||||
|
||||
86
tests/app_core/app_status_tests.cpp
Normal file
86
tests/app_core/app_status_tests.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
#include "app_core/app_status.h"
|
||||
#include "test_harness.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void resolution_maps_supported_indices_and_labels(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto resolution = pp::app::display_resolution_from_index(3);
|
||||
PP_EXPECT(harness, resolution);
|
||||
if (resolution) {
|
||||
PP_EXPECT(harness, resolution.value() == 2048);
|
||||
}
|
||||
|
||||
const auto index = pp::app::document_resolution_to_index(4096);
|
||||
PP_EXPECT(harness, index);
|
||||
if (index) {
|
||||
PP_EXPECT(harness, index.value() == 4U);
|
||||
}
|
||||
|
||||
const auto label = pp::app::document_resolution_label(8192);
|
||||
PP_EXPECT(harness, label);
|
||||
if (label) {
|
||||
PP_EXPECT(harness, label.value() == "32K");
|
||||
}
|
||||
}
|
||||
|
||||
void resolution_mapping_rejects_out_of_range_values(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(harness, !pp::app::display_resolution_from_index(-1));
|
||||
PP_EXPECT(harness, !pp::app::display_resolution_from_index(6));
|
||||
PP_EXPECT(harness, !pp::app::document_resolution_to_index(1234));
|
||||
PP_EXPECT(harness, !pp::app::document_resolution_label(1234));
|
||||
}
|
||||
|
||||
void document_title_marks_unsaved_documents(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::make_document_title("demo", false, 2048) == "Panodoc: demo (8K)");
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::make_document_title("demo", true, 2048) == "Panodoc: demo* (8K)");
|
||||
}
|
||||
|
||||
void document_title_survives_unknown_resolution(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::make_document_title("demo", true, 1234) == "Panodoc: demo* (unknown)");
|
||||
}
|
||||
|
||||
void status_labels_match_legacy_text(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(harness, pp::app::make_dpi_label(1.25F) == "1.2x-dpi");
|
||||
PP_EXPECT(harness, pp::app::make_dpi_label(1.26F) == "1.3x-dpi");
|
||||
PP_EXPECT(harness, pp::app::make_history_memory_label(1024U * 1024U * 3U / 2U) == "History memory: 1.50 Mb");
|
||||
}
|
||||
|
||||
void recording_label_only_shows_when_recording_with_encoder(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto inactive = pp::app::make_recording_frame_label(false, true, 12);
|
||||
PP_EXPECT(harness, !inactive.visible);
|
||||
PP_EXPECT(harness, inactive.text.empty());
|
||||
|
||||
const auto missing_encoder = pp::app::make_recording_frame_label(true, false, 12);
|
||||
PP_EXPECT(harness, !missing_encoder.visible);
|
||||
PP_EXPECT(harness, missing_encoder.text.empty());
|
||||
|
||||
const auto active = pp::app::make_recording_frame_label(true, true, 12);
|
||||
PP_EXPECT(harness, active.visible);
|
||||
PP_EXPECT(harness, active.text == "Recorded 12 frames");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
pp::tests::Harness harness;
|
||||
harness.run("resolution maps supported indices and labels", resolution_maps_supported_indices_and_labels);
|
||||
harness.run("resolution mapping rejects out of range values", resolution_mapping_rejects_out_of_range_values);
|
||||
harness.run("document title marks unsaved documents", document_title_marks_unsaved_documents);
|
||||
harness.run("document title survives unknown resolution", document_title_survives_unknown_resolution);
|
||||
harness.run("status labels match legacy text", status_labels_match_legacy_text);
|
||||
harness.run("recording label only shows when recording with encoder", recording_label_only_shows_when_recording_with_encoder);
|
||||
return harness.finish();
|
||||
}
|
||||
Reference in New Issue
Block a user