mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
test: inject platform to the serveCDP app
This commit is contained in:
@@ -603,7 +603,7 @@ test "tests:beforeAll" {
|
|||||||
log.opts.format = .logfmt;
|
log.opts.format = .logfmt;
|
||||||
|
|
||||||
test_wg.startMany(3);
|
test_wg.startMany(3);
|
||||||
_ = try Platform.init();
|
const platform = try Platform.init();
|
||||||
|
|
||||||
{
|
{
|
||||||
const address = try std.net.Address.parseIp("127.0.0.1", 9582);
|
const address = try std.net.Address.parseIp("127.0.0.1", 9582);
|
||||||
@@ -619,7 +619,7 @@ test "tests:beforeAll" {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const address = try std.net.Address.parseIp("127.0.0.1", 9583);
|
const address = try std.net.Address.parseIp("127.0.0.1", 9583);
|
||||||
const thread = try std.Thread.spawn(.{}, serveCDP, .{address});
|
const thread = try std.Thread.spawn(.{}, serveCDP, .{ address, &platform });
|
||||||
thread.detach();
|
thread.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,11 +801,12 @@ fn serveHTTPS(address: std.net.Address) !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serveCDP(address: std.net.Address) !void {
|
fn serveCDP(address: std.net.Address, platform: *const Platform) !void {
|
||||||
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
|
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
|
||||||
var app = try App.init(gpa.allocator(), .{
|
var app = try App.init(gpa.allocator(), .{
|
||||||
.run_mode = .serve,
|
.run_mode = .serve,
|
||||||
.tls_verify_host = false,
|
.tls_verify_host = false,
|
||||||
|
.platform = platform,
|
||||||
});
|
});
|
||||||
defer app.deinit();
|
defer app.deinit();
|
||||||
|
|
||||||
|
|||||||
@@ -274,18 +274,12 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn pumpMessageLoop(self: *const Self) bool {
|
pub fn pumpMessageLoop(self: *const Self) bool {
|
||||||
if (comptime builtin.is_test) {
|
// assume it's not-null.
|
||||||
if (self.platform == null) return false;
|
|
||||||
}
|
|
||||||
// assume it's not-null in non-test.
|
|
||||||
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
|
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn runIdleTasks(self: *const Self) void {
|
pub fn runIdleTasks(self: *const Self) void {
|
||||||
if (comptime builtin.is_test) {
|
// assume it's not-null.
|
||||||
if (self.platform == null) return;
|
|
||||||
}
|
|
||||||
// assume it's not-null in non-test.
|
|
||||||
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
|
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user