Extract platform policy catalog
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "platform_api/asset_file_load_policy.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
#include "platform_api/platform_policy.h"
|
||||
#include "platform_api/platform_services.h"
|
||||
|
||||
#include <filesystem>
|
||||
@@ -853,6 +854,104 @@ void platform_services_dispatch_canvas_input_policy(pp::tests::Harness& harness)
|
||||
PP_EXPECT(harness, fake.canvas_pressure_adjustments == 1);
|
||||
}
|
||||
|
||||
void platform_policy_preserves_recording_and_export_storage_rules(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(harness, pp::platform::platform_deletes_recorded_files_on_clear(pp::platform::PlatformFamily::ios));
|
||||
PP_EXPECT(harness, pp::platform::platform_deletes_recorded_files_on_clear(pp::platform::PlatformFamily::macos));
|
||||
PP_EXPECT(harness, !pp::platform::platform_deletes_recorded_files_on_clear(pp::platform::PlatformFamily::windows));
|
||||
PP_EXPECT(harness, pp::platform::platform_publishes_exported_images(pp::platform::PlatformFamily::ios));
|
||||
PP_EXPECT(harness, !pp::platform::platform_publishes_exported_images(pp::platform::PlatformFamily::macos));
|
||||
PP_EXPECT(harness, pp::platform::platform_flushes_persistent_storage(pp::platform::PlatformFamily::webgl));
|
||||
PP_EXPECT(harness, !pp::platform::platform_flushes_persistent_storage(pp::platform::PlatformFamily::windows));
|
||||
}
|
||||
|
||||
void platform_policy_preserves_document_browse_roots(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto ios_roots = pp::platform::platform_document_browse_roots(
|
||||
pp::platform::PlatformFamily::ios,
|
||||
"D:/Paint/work",
|
||||
"D:/Paint");
|
||||
const auto desktop_roots = pp::platform::platform_document_browse_roots(
|
||||
pp::platform::PlatformFamily::windows,
|
||||
"D:/Paint/work",
|
||||
"D:/Paint");
|
||||
|
||||
PP_EXPECT(harness, ios_roots.size() == 2);
|
||||
PP_EXPECT(harness, ios_roots[0] == "D:/Paint/work");
|
||||
PP_EXPECT(harness, ios_roots[1] == "D:/Paint/Inbox");
|
||||
PP_EXPECT(harness, desktop_roots.size() == 1);
|
||||
PP_EXPECT(harness, desktop_roots[0] == "D:/Paint/work");
|
||||
}
|
||||
|
||||
void platform_policy_preserves_picker_and_prepared_file_rules(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(harness, pp::platform::platform_supports_working_directory_picker(pp::platform::PlatformFamily::windows));
|
||||
PP_EXPECT(harness, pp::platform::platform_supports_working_directory_picker(pp::platform::PlatformFamily::macos));
|
||||
PP_EXPECT(harness, !pp::platform::platform_supports_working_directory_picker(pp::platform::PlatformFamily::ios));
|
||||
PP_EXPECT(harness, pp::platform::platform_uses_prepared_file_writes(pp::platform::PlatformFamily::ios));
|
||||
PP_EXPECT(harness, pp::platform::platform_uses_prepared_file_writes(pp::platform::PlatformFamily::webgl));
|
||||
PP_EXPECT(harness, !pp::platform::platform_uses_prepared_file_writes(pp::platform::PlatformFamily::windows));
|
||||
PP_EXPECT(harness, pp::platform::platform_uses_work_directory_document_export_collections(pp::platform::PlatformFamily::ios));
|
||||
PP_EXPECT(harness, !pp::platform::platform_uses_work_directory_document_export_collections(pp::platform::PlatformFamily::webgl));
|
||||
|
||||
const auto ios_target = pp::platform::plan_platform_writable_file(
|
||||
pp::platform::PlatformFamily::ios,
|
||||
"mp4",
|
||||
"timelapse",
|
||||
"/PanoPainter",
|
||||
"/tmp");
|
||||
PP_EXPECT(harness, ios_target.path == "/tmp/timelapse.mp4");
|
||||
PP_EXPECT(harness, ios_target.suggested_name == "timelapse.mp4");
|
||||
PP_EXPECT(harness, ios_target.write_on_background_thread);
|
||||
|
||||
const auto web_target = pp::platform::plan_platform_writable_file(
|
||||
pp::platform::PlatformFamily::webgl,
|
||||
"png",
|
||||
"export",
|
||||
"/PanoPainter",
|
||||
"/tmp");
|
||||
PP_EXPECT(harness, web_target.path == "/PanoPainter/export.png");
|
||||
PP_EXPECT(harness, web_target.suggested_name == "export.png");
|
||||
PP_EXPECT(harness, !web_target.write_on_background_thread);
|
||||
|
||||
const auto desktop_target = pp::platform::plan_platform_writable_file(
|
||||
pp::platform::PlatformFamily::windows,
|
||||
"png",
|
||||
"export",
|
||||
"/PanoPainter",
|
||||
"/tmp");
|
||||
PP_EXPECT(harness, desktop_target.path.empty());
|
||||
PP_EXPECT(harness, desktop_target.suggested_name.empty());
|
||||
}
|
||||
|
||||
void platform_policy_preserves_ui_asset_and_input_rules(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(harness, pp::platform::platform_enables_live_asset_reloading(pp::platform::PlatformFamily::windows));
|
||||
PP_EXPECT(harness, pp::platform::platform_enables_live_asset_reloading(pp::platform::PlatformFamily::macos));
|
||||
PP_EXPECT(harness, !pp::platform::platform_enables_live_asset_reloading(pp::platform::PlatformFamily::ios));
|
||||
PP_EXPECT(harness, pp::platform::platform_uses_ppbr_export_data_directory_override(pp::platform::PlatformFamily::macos));
|
||||
PP_EXPECT(harness, !pp::platform::platform_uses_ppbr_export_data_directory_override(pp::platform::PlatformFamily::windows));
|
||||
PP_EXPECT(harness, pp::platform::platform_supports_sonarpen(pp::platform::PlatformFamily::ios));
|
||||
PP_EXPECT(harness, !pp::platform::platform_supports_sonarpen(pp::platform::PlatformFamily::android));
|
||||
PP_EXPECT(harness, pp::platform::platform_default_canvas_resolution(pp::platform::PlatformFamily::webgl) == 512);
|
||||
PP_EXPECT(harness, pp::platform::platform_default_canvas_resolution(pp::platform::PlatformFamily::windows) == 1536);
|
||||
PP_EXPECT(harness, pp::platform::platform_draws_canvas_tip_for_pointer(
|
||||
pp::platform::PlatformFamily::ios,
|
||||
true,
|
||||
false,
|
||||
false));
|
||||
PP_EXPECT(harness, !pp::platform::platform_draws_canvas_tip_for_pointer(
|
||||
pp::platform::PlatformFamily::ios,
|
||||
true,
|
||||
false,
|
||||
true));
|
||||
PP_EXPECT(harness, pp::platform::platform_draws_canvas_tip_for_pointer(
|
||||
pp::platform::PlatformFamily::windows,
|
||||
false,
|
||||
true,
|
||||
true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -894,5 +993,15 @@ int main()
|
||||
harness.run("platform services dispatch sonarpen policy and start", platform_services_dispatch_sonarpen_policy_and_start);
|
||||
harness.run("platform services dispatch default canvas resolution", platform_services_dispatch_default_canvas_resolution);
|
||||
harness.run("platform services dispatch canvas input policy", platform_services_dispatch_canvas_input_policy);
|
||||
harness.run(
|
||||
"platform policy preserves recording and export storage rules",
|
||||
platform_policy_preserves_recording_and_export_storage_rules);
|
||||
harness.run("platform policy preserves document browse roots", platform_policy_preserves_document_browse_roots);
|
||||
harness.run(
|
||||
"platform policy preserves picker and prepared file rules",
|
||||
platform_policy_preserves_picker_and_prepared_file_rules);
|
||||
harness.run(
|
||||
"platform policy preserves UI asset and input rules",
|
||||
platform_policy_preserves_ui_asset_and_input_rules);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user