Route dialog work directory picker through platform services

This commit is contained in:
2026-06-04 18:14:02 +02:00
parent 52cf7628da
commit b1acd5118b
11 changed files with 164 additions and 78 deletions

View File

@@ -212,6 +212,19 @@ public:
callback(directory_path);
}
[[nodiscard]] bool supports_working_directory_picker() override
{
++working_directory_picker_support_checks;
return working_directory_picker_supported;
}
[[nodiscard]] std::string format_working_directory_path(std::string_view path) override
{
++working_directory_path_format_requests;
last_working_directory_path.assign(path);
return formatted_working_directory_path;
}
[[nodiscard]] bool uses_prepared_file_writes() override
{
++prepared_file_write_policy_checks;
@@ -306,6 +319,8 @@ public:
int pick_file_requests = 0;
int pick_save_file_requests = 0;
int pick_directory_requests = 0;
int working_directory_picker_support_checks = 0;
int working_directory_path_format_requests = 0;
int prepared_file_write_policy_checks = 0;
int document_export_collection_policy_checks = 0;
int network_tls_policy_checks = 0;
@@ -318,6 +333,7 @@ public:
bool keyboard_visible = false;
bool prepared_file_saved = true;
bool prepared_file_writes = true;
bool working_directory_picker_supported = false;
bool work_directory_document_export_collections = false;
bool network_tls_verification_disabled = false;
bool ppbr_export_data_directory_override = false;
@@ -341,6 +357,8 @@ public:
std::string picker_path = "D:/Paint/import.png";
std::string save_path = "D:/Paint/export.ppi";
std::string directory_path = "D:/Paint";
std::string last_working_directory_path;
std::string formatted_working_directory_path = "D:/Paint/Absolute";
pp::platform::PlatformStoragePaths storage_paths{
"D:/Paint",
"D:/Paint/work",
@@ -592,6 +610,22 @@ void platform_services_dispatch_picker_callbacks(pp::tests::Harness& harness)
PP_EXPECT(harness, fake.save_file_types.size() == 1);
}
void platform_services_dispatch_working_directory_picker_policy(pp::tests::Harness& harness)
{
FakePlatformServices fake("unused");
pp::platform::PlatformServices& services = fake;
PP_EXPECT(harness, !services.supports_working_directory_picker());
fake.working_directory_picker_supported = true;
PP_EXPECT(harness, services.supports_working_directory_picker());
const auto formatted = services.format_working_directory_path("D:/Paint");
PP_EXPECT(harness, formatted == "D:/Paint/Absolute");
PP_EXPECT(harness, fake.last_working_directory_path == "D:/Paint");
PP_EXPECT(harness, fake.working_directory_picker_support_checks == 2);
PP_EXPECT(harness, fake.working_directory_path_format_requests == 1);
}
void platform_services_dispatch_prepared_file_save(pp::tests::Harness& harness)
{
FakePlatformServices fake("unused");
@@ -714,6 +748,9 @@ int main()
harness.run("platform services dispatch frame hooks", platform_services_dispatch_frame_hooks);
harness.run("platform services dispatch file actions", platform_services_dispatch_file_actions);
harness.run("platform services dispatch picker callbacks", platform_services_dispatch_picker_callbacks);
harness.run(
"platform services dispatch working directory picker policy",
platform_services_dispatch_working_directory_picker_policy);
harness.run("platform services dispatch prepared file save", platform_services_dispatch_prepared_file_save);
harness.run("platform services dispatch writable file target", platform_services_dispatch_writable_file_target);
harness.run(