mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-12-27 01:44:01 +00:00
chore: unflake tracing test (#1822)
This commit is contained in:
parent
1fb593e1e2
commit
0cf8c4e17f
@ -57,6 +57,13 @@ public class TestChromiumTracing extends TestBase {
|
||||
}
|
||||
}
|
||||
|
||||
private static void rafraf(Page page) {
|
||||
int count = 2;
|
||||
for (int i = 0; i < count; i++) {
|
||||
page.evaluate("() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRunWithCustomCategoriesIfProvided(@TempDir Path tempDir) throws IOException {
|
||||
try (Page page = browser.newPage()) {
|
||||
@ -64,7 +71,7 @@ public class TestChromiumTracing extends TestBase {
|
||||
browser.startTracing(page, new Browser.StartTracingOptions()
|
||||
.setPath(outputTraceFile)
|
||||
.setCategories(asList("disabled-by-default-cc.debug")));
|
||||
page.evaluate("() => 1 + 1");
|
||||
rafraf(page);
|
||||
browser.stopTracing();
|
||||
try (FileReader fileReader = new FileReader(outputTraceFile.toFile())) {
|
||||
JsonObject traceJson = new Gson().fromJson(fileReader, JsonObject.class);
|
||||
@ -75,7 +82,7 @@ public class TestChromiumTracing extends TestBase {
|
||||
boolean hasTraceEvents = traceJson.getAsJsonArray("traceEvents").asList().stream()
|
||||
.anyMatch(event -> {
|
||||
JsonObject eventObj = (JsonObject) event;
|
||||
return eventObj.has("cat") &&
|
||||
return eventObj.has("cat") &&
|
||||
eventObj.get("cat").getAsString().equals("disabled-by-default-cc.debug");
|
||||
});
|
||||
assertTrue(hasTraceConfig || hasTraceEvents);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user