Route prepared file saves through platform services

This commit is contained in:
2026-06-03 04:29:58 +02:00
parent e10e16f491
commit 2ea850cbcc
10 changed files with 109 additions and 27 deletions

View File

@@ -78,6 +78,17 @@ public:
callback(directory_path);
}
void save_prepared_file(
std::string_view path,
std::string_view suggested_name,
pp::platform::PreparedFileCallback callback) override
{
++save_prepared_file_requests;
prepared_file_path.assign(path);
prepared_file_name.assign(suggested_name);
callback(prepared_file_path, prepared_file_saved);
}
int clipboard_reads = 0;
int clipboard_writes = 0;
int cursor_updates = 0;
@@ -88,10 +99,14 @@ public:
int pick_file_requests = 0;
int pick_save_file_requests = 0;
int pick_directory_requests = 0;
int save_prepared_file_requests = 0;
bool cursor_visible = false;
bool keyboard_visible = false;
bool prepared_file_saved = true;
std::string displayed_path;
std::string shared_path;
std::string prepared_file_path;
std::string prepared_file_name;
std::string picker_path = "D:/Paint/import.png";
std::string save_path = "D:/Paint/export.ppi";
std::string directory_path = "D:/Paint";
@@ -180,6 +195,28 @@ void platform_services_dispatch_picker_callbacks(pp::tests::Harness& harness)
PP_EXPECT(harness, fake.save_file_types.size() == 1);
}
void platform_services_dispatch_prepared_file_save(pp::tests::Harness& harness)
{
FakePlatformServices fake("unused");
pp::platform::PlatformServices& services = fake;
std::string saved_path;
bool saved = false;
services.save_prepared_file(
"D:/Paint/export.mp4",
"export.mp4",
[&](std::string path, bool success) {
saved_path = std::move(path);
saved = success;
});
PP_EXPECT(harness, fake.save_prepared_file_requests == 1);
PP_EXPECT(harness, fake.prepared_file_path == "D:/Paint/export.mp4");
PP_EXPECT(harness, fake.prepared_file_name == "export.mp4");
PP_EXPECT(harness, saved_path == "D:/Paint/export.mp4");
PP_EXPECT(harness, saved);
}
}
int main()
@@ -190,5 +227,6 @@ int main()
harness.run("platform services dispatch visibility updates", platform_services_dispatch_visibility_updates);
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 prepared file save", platform_services_dispatch_prepared_file_save);
return harness.finish();
}