Route file actions through platform services

This commit is contained in:
2026-06-03 04:03:25 +02:00
parent 4ed72ebc80
commit 1e0500a3f7
7 changed files with 84 additions and 45 deletions

View File

@@ -39,12 +39,28 @@ public:
keyboard_visible = visible;
}
void display_file(std::string_view path) override
{
++display_file_requests;
displayed_path.assign(path);
}
void share_file(std::string_view path) override
{
++share_file_requests;
shared_path.assign(path);
}
int clipboard_reads = 0;
int clipboard_writes = 0;
int cursor_updates = 0;
int keyboard_updates = 0;
int display_file_requests = 0;
int share_file_requests = 0;
bool cursor_visible = false;
bool keyboard_visible = false;
std::string displayed_path;
std::string shared_path;
private:
std::string clipboard_value_;
@@ -88,6 +104,20 @@ void platform_services_dispatch_visibility_updates(pp::tests::Harness& harness)
PP_EXPECT(harness, !fake.keyboard_visible);
}
void platform_services_dispatch_file_actions(pp::tests::Harness& harness)
{
FakePlatformServices fake("unused");
pp::platform::PlatformServices& services = fake;
services.display_file("D:/Paint/export.png");
services.share_file("D:/Paint/demo.ppi");
PP_EXPECT(harness, fake.display_file_requests == 1);
PP_EXPECT(harness, fake.share_file_requests == 1);
PP_EXPECT(harness, fake.displayed_path == "D:/Paint/export.png");
PP_EXPECT(harness, fake.shared_path == "D:/Paint/demo.ppi");
}
}
int main()
@@ -96,5 +126,6 @@ int main()
harness.run("platform services dispatch clipboard reads and writes", platform_services_dispatch_clipboard_reads_and_writes);
harness.run("platform services preserve empty clipboard writes", platform_services_preserve_empty_clipboard_writes);
harness.run("platform services dispatch visibility updates", platform_services_dispatch_visibility_updates);
harness.run("platform services dispatch file actions", platform_services_dispatch_file_actions);
return harness.finish();
}