Own Web platform services directly
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "platform_api/platform_policy.h"
|
||||
#include "platform_api/platform_services.h"
|
||||
#include "platform_apple/apple_platform_services.h"
|
||||
#include "platform_web/web_platform_services.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -1000,6 +1001,37 @@ void web_platform_services_resolve_injected_services(pp::tests::Harness& harness
|
||||
PP_EXPECT(harness, pp::platform::injected_web_platform_services() == nullptr);
|
||||
}
|
||||
|
||||
void web_platform_services_dispatch_full_platform_surface(pp::tests::Harness& harness)
|
||||
{
|
||||
auto services = pp::platform::web::create_platform_services();
|
||||
std::string saved_path;
|
||||
bool saved = true;
|
||||
|
||||
PP_EXPECT(harness, services->uses_prepared_file_writes());
|
||||
PP_EXPECT(harness, !services->supports_working_directory_picker());
|
||||
PP_EXPECT(harness, services->default_canvas_resolution() == 512);
|
||||
PP_EXPECT(harness, services->document_browse_roots("D:/Paint/work", "D:/Paint").size() == 1);
|
||||
PP_EXPECT(harness, services->document_browse_roots("D:/Paint/work", "D:/Paint")[0] == "D:/Paint/work");
|
||||
PP_EXPECT(harness, services->format_working_directory_path("D:/Paint/.") == "D:/Paint/.");
|
||||
PP_EXPECT(harness, services->draws_canvas_tip_for_pointer(true, false, false));
|
||||
|
||||
const auto target = services->prepare_writable_file("png", "export", "/PanoPainter", "/tmp");
|
||||
PP_EXPECT(harness, target.path == "/PanoPainter/export.png");
|
||||
PP_EXPECT(harness, target.suggested_name == "export.png");
|
||||
PP_EXPECT(harness, !target.write_on_background_thread);
|
||||
|
||||
services->save_prepared_file(
|
||||
"/PanoPainter/export.png",
|
||||
"export.png",
|
||||
[&](std::string path, bool success) {
|
||||
saved_path = std::move(path);
|
||||
saved = success;
|
||||
});
|
||||
|
||||
PP_EXPECT(harness, saved_path == "/PanoPainter/export.png");
|
||||
PP_EXPECT(harness, !saved);
|
||||
}
|
||||
|
||||
void platform_services_dispatch_writable_file_target(pp::tests::Harness& harness)
|
||||
{
|
||||
FakePlatformServices fake("unused");
|
||||
@@ -1385,6 +1417,9 @@ int main()
|
||||
apple_document_platform_services_preserve_working_directory_picker_policy);
|
||||
harness.run("web platform services preserve default web policy", web_platform_services_preserve_default_web_policy);
|
||||
harness.run("web platform services resolve injected services", web_platform_services_resolve_injected_services);
|
||||
harness.run(
|
||||
"web platform services dispatch full platform surface",
|
||||
web_platform_services_dispatch_full_platform_surface);
|
||||
harness.run("platform services dispatch writable file target", platform_services_dispatch_writable_file_target);
|
||||
harness.run(
|
||||
"platform services dispatch document export collection policy",
|
||||
|
||||
Reference in New Issue
Block a user