Skip to content

Commit 3a89e00

Browse files
committed
Generic tracing test covering fixed Clock calls
1 parent fdf73be commit 3a89e00

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

playwright/src/test/java/com/microsoft/playwright/TestTracing.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
import com.google.gson.Gson;
2020
import com.google.gson.JsonObject;
21+
import com.microsoft.playwright.options.AriaRole;
2122
import com.microsoft.playwright.options.Location;
23+
import com.microsoft.playwright.options.MouseButton;
24+
2225
import org.junit.jupiter.api.Assumptions;
2326
import org.junit.jupiter.api.BeforeAll;
2427
import org.junit.jupiter.api.Test;
@@ -204,6 +207,68 @@ void traceGroupGroupEnd(@TempDir Path tempDir) throws Exception {
204207
assertEquals(asList("outer group", "Page.navigate", "inner group 1", "Frame.click", "inner group 2", "Page.isVisible"), calls);
205208
}
206209

210+
@Test
211+
void shouldTraceVariousAPIs(@TempDir Path tempDir) throws Exception {
212+
context.tracing().start(new Tracing.StartOptions());
213+
214+
page.clock().install();
215+
216+
page.setContent("<input type='text' />");
217+
page.locator("input").click(new Locator.ClickOptions().setButton(MouseButton.RIGHT));
218+
page.getByRole(AriaRole.TEXTBOX).click();
219+
page.keyboard().type("Hello world this is a very long string what happens when it overflows?");
220+
page.keyboard().press("Control+c");
221+
page.keyboard().down("Shift");
222+
page.keyboard().insertText("Hello world");
223+
page.keyboard().up("Shift");
224+
page.mouse().move(0, 0);
225+
page.mouse().down();
226+
page.mouse().move(100, 200);
227+
page.mouse().wheel(5, 7);
228+
page.mouse().up();
229+
page.clock().fastForward(1000);
230+
page.clock().fastForward("30:00");
231+
page.clock().pauseAt("2050-02-02");
232+
page.clock().runFor(10);
233+
page.clock().setFixedTime("2050-02-02");
234+
page.clock().setSystemTime("2050-02-02");
235+
236+
page.clock().resume();
237+
238+
page.locator("input").click(new Locator.ClickOptions().setButton(MouseButton.RIGHT));
239+
240+
Path traceFile1 = tempDir.resolve("trace1.zip");
241+
context.tracing().stop(new Tracing.StopOptions().setPath(traceFile1));
242+
243+
List<TraceEvent> events = parseTraceEvents(traceFile1);
244+
List<String> calls = events.stream().filter(e -> e.apiName != null).map(e -> e.apiName)
245+
.collect(Collectors.toList());
246+
assertEquals(asList(
247+
"Clock.install",
248+
"Page.setContent",
249+
"Frame.click",
250+
"Frame.click",
251+
"Keyboard.type",
252+
"Keyboard.press",
253+
"Keyboard.down",
254+
"Keyboard.insertText",
255+
"Keyboard.up",
256+
"Mouse.move",
257+
"Mouse.down",
258+
"Mouse.move",
259+
"Mouse.wheel",
260+
"Mouse.up",
261+
"Clock.fastForward",
262+
"Clock.fastForward",
263+
"Clock.pauseAt",
264+
"Clock.runFor",
265+
"Clock.setFixedTime",
266+
"Clock.setSystemTime",
267+
"Clock.resume",
268+
"Frame.click"),
269+
calls);
270+
}
271+
207272
private static class TraceEvent {
208273
String type;
209274
String name;

0 commit comments

Comments
 (0)