Skip to content

Commit 99fb82e

Browse files
committed
Turn CDP into a generic so that mocks can be injected for testing
ADD CDP testing helpers (mock Browser, Session, Page and Client). These are placeholders until tests are added which use them. Added a couple CDP tests.
1 parent 09505db commit 99fb82e

File tree

5 files changed

+466
-255
lines changed

5 files changed

+466
-255
lines changed

src/cdp/browser.zig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,41 @@ fn getWindowForTarget(cmd: anytype) !void {
8080
fn setWindowBounds(cmd: anytype) !void {
8181
return cmd.sendResult(null, .{});
8282
}
83+
84+
const testing = @import("testing.zig");
85+
test "cdp.browser: getVersion" {
86+
var ctx = testing.context();
87+
defer ctx.deinit();
88+
89+
try ctx.processMessage(.{
90+
.id = 32,
91+
.sessionID = "leto",
92+
.method = "Browser.getVersion",
93+
});
94+
95+
try ctx.expectSentCount(1);
96+
try ctx.expectSentResult(.{
97+
.protocolVersion = PROTOCOL_VERSION,
98+
.product = PRODUCT,
99+
.revision = REVISION,
100+
.userAgent = USER_AGENT,
101+
.jsVersion = JS_VERSION,
102+
}, .{ .id = 32, .index = 0 });
103+
}
104+
105+
test "cdp.browser: getWindowForTarget" {
106+
var ctx = testing.context();
107+
defer ctx.deinit();
108+
109+
try ctx.processMessage(.{
110+
.id = 33,
111+
.sessionId = "leto",
112+
.method = "Browser.getWindowForTarget",
113+
});
114+
115+
try ctx.expectSentCount(1);
116+
try ctx.expectSentResult(.{
117+
.windowId = DEV_TOOLS_WINDOW_ID,
118+
.bounds = .{ .windowState = "normal" },
119+
}, .{ .id = 33, .index = 0, .session_id = "leto" });
120+
}

0 commit comments

Comments
 (0)