mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
Make the App own the Platform
Removes optional platform, which only existed for tests.
There is now a global `@import("testing.zig").test_app` available. This is setup
when the test runner starts, and cleaned up at the end of tests. Individual
tests don't have to worry about creating app, which I assume was the reason I
Platform optional, since that woul dhave been something else that needed to be
setup.
This commit is contained in:
@@ -153,7 +153,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
return struct {
|
||||
allocator: Allocator,
|
||||
|
||||
platform: ?*const Platform,
|
||||
platform: *const Platform,
|
||||
|
||||
// the global isolate
|
||||
isolate: v8.Isolate,
|
||||
@@ -182,7 +182,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
|
||||
const Opts = struct {};
|
||||
|
||||
pub fn init(allocator: Allocator, platform: ?*const Platform, _: Opts) !*Self {
|
||||
pub fn init(allocator: Allocator, platform: *const Platform, _: Opts) !*Self {
|
||||
// var params = v8.initCreateParams();
|
||||
var params = try allocator.create(v8.CreateParams);
|
||||
errdefer allocator.destroy(params);
|
||||
@@ -301,13 +301,11 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
}
|
||||
|
||||
pub fn pumpMessageLoop(self: *const Self) bool {
|
||||
// assume it's not-null.
|
||||
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
|
||||
return self.platform.inner.pumpMessageLoop(self.isolate, false);
|
||||
}
|
||||
|
||||
pub fn runIdleTasks(self: *const Self) void {
|
||||
// assume it's not-null.
|
||||
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
|
||||
return self.platform.inner.runIdleTasks(self.isolate, 1);
|
||||
}
|
||||
|
||||
pub fn newExecutionWorld(self: *Self) !ExecutionWorld {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
const js = @import("js.zig");
|
||||
const base = @import("../testing.zig");
|
||||
const generate = @import("generate.zig");
|
||||
|
||||
pub const allocator = std.testing.allocator;
|
||||
@@ -42,7 +43,7 @@ pub fn Runner(comptime State: type, comptime Global: type, comptime types: anyty
|
||||
const self = try allocator.create(Self);
|
||||
errdefer allocator.destroy(self);
|
||||
|
||||
self.env = try Env.init(allocator, null, .{});
|
||||
self.env = try Env.init(allocator, &base.test_app.platform, .{});
|
||||
errdefer self.env.deinit();
|
||||
|
||||
self.executor = try self.env.newExecutionWorld();
|
||||
|
||||
Reference in New Issue
Block a user