Add export menu service boundary
This commit is contained in:
@@ -3,6 +3,36 @@
|
||||
|
||||
namespace {
|
||||
|
||||
class FakeDocumentExportMenuServices final : public pp::app::DocumentExportMenuServices {
|
||||
public:
|
||||
void show_jpeg_dialog() override { jpeg_dialogs += 1; }
|
||||
void show_png_dialog() override { png_dialogs += 1; }
|
||||
void show_layers_dialog() override { layer_dialogs += 1; }
|
||||
void show_cube_faces_dialog() override { cube_dialogs += 1; }
|
||||
void show_depth_dialog() override { depth_dialogs += 1; }
|
||||
void show_animation_frames_dialog() override { animation_frame_dialogs += 1; }
|
||||
void show_animation_mp4_dialog() override { animation_mp4_dialogs += 1; }
|
||||
void show_timelapse_dialog() override { timelapse_dialogs += 1; }
|
||||
void show_license_disabled() override { license_messages += 1; }
|
||||
|
||||
[[nodiscard]] int total_calls() const noexcept
|
||||
{
|
||||
return jpeg_dialogs + png_dialogs + layer_dialogs + cube_dialogs + depth_dialogs
|
||||
+ animation_frame_dialogs + animation_mp4_dialogs + timelapse_dialogs
|
||||
+ license_messages;
|
||||
}
|
||||
|
||||
int jpeg_dialogs = 0;
|
||||
int png_dialogs = 0;
|
||||
int layer_dialogs = 0;
|
||||
int cube_dialogs = 0;
|
||||
int depth_dialogs = 0;
|
||||
int animation_frame_dialogs = 0;
|
||||
int animation_mp4_dialogs = 0;
|
||||
int timelapse_dialogs = 0;
|
||||
int license_messages = 0;
|
||||
};
|
||||
|
||||
void equirectangular_export_builds_file_target(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::make_document_export_file_target("D:/Paint", "demo", ".png");
|
||||
@@ -123,6 +153,106 @@ void export_menu_reports_missing_canvas_for_unlicensed_image_exports(pp::tests::
|
||||
PP_EXPECT(harness, !plan.opens_dialog);
|
||||
}
|
||||
|
||||
void export_menu_executor_dispatches_all_dialog_actions(pp::tests::Harness& harness)
|
||||
{
|
||||
FakeDocumentExportMenuServices services;
|
||||
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::jpeg,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::png,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::layers,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::cube_faces,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::depth,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::animation_frames,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::animation_mp4,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_document_export_menu_plan(
|
||||
pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::timelapse,
|
||||
true,
|
||||
true),
|
||||
services).ok());
|
||||
|
||||
PP_EXPECT(harness, services.jpeg_dialogs == 1);
|
||||
PP_EXPECT(harness, services.png_dialogs == 1);
|
||||
PP_EXPECT(harness, services.layer_dialogs == 1);
|
||||
PP_EXPECT(harness, services.cube_dialogs == 1);
|
||||
PP_EXPECT(harness, services.depth_dialogs == 1);
|
||||
PP_EXPECT(harness, services.animation_frame_dialogs == 1);
|
||||
PP_EXPECT(harness, services.animation_mp4_dialogs == 1);
|
||||
PP_EXPECT(harness, services.timelapse_dialogs == 1);
|
||||
}
|
||||
|
||||
void export_menu_executor_preserves_blocked_and_unavailable_actions(pp::tests::Harness& harness)
|
||||
{
|
||||
FakeDocumentExportMenuServices services;
|
||||
|
||||
const auto blocked = pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::animation_mp4,
|
||||
true,
|
||||
false);
|
||||
PP_EXPECT(harness, blocked.action == pp::app::DocumentExportMenuAction::show_license_disabled);
|
||||
PP_EXPECT(harness, pp::app::execute_document_export_menu_plan(blocked, services).ok());
|
||||
PP_EXPECT(harness, services.license_messages == 1);
|
||||
|
||||
const auto unavailable = pp::app::plan_document_export_menu_action(
|
||||
pp::app::DocumentExportMenuKind::png,
|
||||
false,
|
||||
true);
|
||||
PP_EXPECT(harness, unavailable.action == pp::app::DocumentExportMenuAction::unavailable_no_canvas);
|
||||
PP_EXPECT(harness, pp::app::execute_document_export_menu_plan(unavailable, services).ok());
|
||||
PP_EXPECT(harness, services.total_calls() == 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -139,5 +269,7 @@ int main()
|
||||
harness.run("export menu routes image dialogs without license", export_menu_routes_image_dialogs_without_license);
|
||||
harness.run("export menu blocks video when license is missing", export_menu_blocks_video_when_license_is_missing);
|
||||
harness.run("export menu reports missing canvas for unlicensed image exports", export_menu_reports_missing_canvas_for_unlicensed_image_exports);
|
||||
harness.run("export menu executor dispatches all dialog actions", export_menu_executor_dispatches_all_dialog_actions);
|
||||
harness.run("export menu executor preserves blocked and unavailable actions", export_menu_executor_preserves_blocked_and_unavailable_actions);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user