1
0
mirror of synced 2026-08-04 22:46:55 +00:00

chore: more code reuse, enable 2 tests (#599)

This commit is contained in:
Yury Semikhatsky
2021-09-10 08:08:37 -07:00
committed by GitHub
parent a073eb07ae
commit bc7a59d852
2 changed files with 5 additions and 20 deletions
@@ -1318,11 +1318,7 @@ public class PageImpl extends ChannelOwner implements Page {
if (options == null) {
options = new WaitForRequestOptions();
}
List<Waitable<Request>> waitables = new ArrayList<>();
waitables.add(new WaitableEvent<>(listeners, EventType.REQUEST, predicate));
waitables.add(createWaitForCloseHelper());
waitables.add(createWaitableTimeout(options.timeout));
return runUntil(code, new WaitableRace<>(waitables));
return waitForEventWithTimeout(EventType.REQUEST, code, predicate, options.timeout);
}
@Override
@@ -1334,12 +1330,7 @@ public class PageImpl extends ChannelOwner implements Page {
if (options == null) {
options = new WaitForRequestFinishedOptions();
}
List<Waitable<Request>> waitables = new ArrayList<>();
Predicate<Request> predicate = options.predicate;
waitables.add(new WaitableEvent<>(listeners, EventType.REQUESTFINISHED, predicate));
waitables.add(createWaitForCloseHelper());
waitables.add(createWaitableTimeout(options.timeout));
return runUntil(code, new WaitableRace<>(waitables));
return waitForEventWithTimeout(EventType.REQUESTFINISHED, code, options.predicate, options.timeout);
}
@Override
@@ -1365,11 +1356,7 @@ public class PageImpl extends ChannelOwner implements Page {
if (options == null) {
options = new WaitForResponseOptions();
}
List<Waitable<Response>> waitables = new ArrayList<>();
waitables.add(new WaitableEvent<>(listeners, EventType.RESPONSE, predicate));
waitables.add(createWaitForCloseHelper());
waitables.add(createWaitableTimeout(options.timeout));
return runUntil(code, new WaitableRace<>(waitables));
return waitForEventWithTimeout(EventType.RESPONSE, code, predicate, options.timeout);
}
@Override
@@ -115,10 +115,9 @@ public class TestBrowserContextBasic extends TestBase {
@Test
@Disabled("TODO: supported null viewport option")
void shouldNotAllowDeviceScaleFactorWithNullViewport() {
try {
browser.newContext(new Browser.NewContextOptions().setDeviceScaleFactor(1.0));
browser.newContext(new Browser.NewContextOptions().setDeviceScaleFactor(1.0).setViewportSize(null));
fail("did not throw");
} catch (PlaywrightException e) {
assertTrue(e.getMessage().contains("\"deviceScaleFactor\" option is not supported with null \"viewport\""));
@@ -126,10 +125,9 @@ public class TestBrowserContextBasic extends TestBase {
}
@Test
@Disabled("TODO: supported null viewport option")
void shouldNotAllowIsMobileWithNullViewport() {
try {
browser.newContext(new Browser.NewContextOptions().setIsMobile(true));
browser.newContext(new Browser.NewContextOptions().setIsMobile(true).setViewportSize(null));
fail("did not throw");
} catch (PlaywrightException e) {
assertTrue(e.getMessage().contains("\"isMobile\" option is not supported with null \"viewport\""));