mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53: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;
|
||||
|
||||
test_wg.startMany(3);
|
||||
_ = try Platform.init();
|
||||
const platform = try Platform.init();
|
||||
|
||||
{
|
||||
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 thread = try std.Thread.spawn(.{}, serveCDP, .{address});
|
||||
const thread = try std.Thread.spawn(.{}, serveCDP, .{ address, &platform });
|
||||
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 app = try App.init(gpa.allocator(), .{
|
||||
.run_mode = .serve,
|
||||
.tls_verify_host = false,
|
||||
.platform = platform,
|
||||
});
|
||||
defer app.deinit();
|
||||
|
||||
|
||||
@@ -274,18 +274,12 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
}
|
||||
|
||||
pub fn pumpMessageLoop(self: *const Self) bool {
|
||||
if (comptime builtin.is_test) {
|
||||
if (self.platform == null) return false;
|
||||
}
|
||||
// assume it's not-null in non-test.
|
||||
// assume it's not-null.
|
||||
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
|
||||
}
|
||||
|
||||
pub fn runIdleTasks(self: *const Self) void {
|
||||
if (comptime builtin.is_test) {
|
||||
if (self.platform == null) return;
|
||||
}
|
||||
// assume it's not-null in non-test.
|
||||
// assume it's not-null.
|
||||
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user