Skip to content

Commit bc7a59d

Browse files
authored
chore: more code reuse, enable 2 tests (#599)
1 parent a073eb0 commit bc7a59d

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,11 +1318,7 @@ private Request waitForRequestImpl(Predicate<Request> predicate, WaitForRequestO
13181318
if (options == null) {
13191319
options = new WaitForRequestOptions();
13201320
}
1321-
List<Waitable<Request>> waitables = new ArrayList<>();
1322-
waitables.add(new WaitableEvent<>(listeners, EventType.REQUEST, predicate));
1323-
waitables.add(createWaitForCloseHelper());
1324-
waitables.add(createWaitableTimeout(options.timeout));
1325-
return runUntil(code, new WaitableRace<>(waitables));
1321+
return waitForEventWithTimeout(EventType.REQUEST, code, predicate, options.timeout);
13261322
}
13271323

13281324
@Override
@@ -1334,12 +1330,7 @@ private Request waitForRequestFinishedImpl(WaitForRequestFinishedOptions options
13341330
if (options == null) {
13351331
options = new WaitForRequestFinishedOptions();
13361332
}
1337-
List<Waitable<Request>> waitables = new ArrayList<>();
1338-
Predicate<Request> predicate = options.predicate;
1339-
waitables.add(new WaitableEvent<>(listeners, EventType.REQUESTFINISHED, predicate));
1340-
waitables.add(createWaitForCloseHelper());
1341-
waitables.add(createWaitableTimeout(options.timeout));
1342-
return runUntil(code, new WaitableRace<>(waitables));
1333+
return waitForEventWithTimeout(EventType.REQUESTFINISHED, code, options.predicate, options.timeout);
13431334
}
13441335

13451336
@Override
@@ -1365,11 +1356,7 @@ private Response waitForResponseImpl(Predicate<Response> predicate, WaitForRespo
13651356
if (options == null) {
13661357
options = new WaitForResponseOptions();
13671358
}
1368-
List<Waitable<Response>> waitables = new ArrayList<>();
1369-
waitables.add(new WaitableEvent<>(listeners, EventType.RESPONSE, predicate));
1370-
waitables.add(createWaitForCloseHelper());
1371-
waitables.add(createWaitableTimeout(options.timeout));
1372-
return runUntil(code, new WaitableRace<>(waitables));
1359+
return waitForEventWithTimeout(EventType.RESPONSE, code, predicate, options.timeout);
13731360
}
13741361

13751362
@Override

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,19 @@ void shouldRespectDeviceScaleFactor() {
115115

116116

117117
@Test
118-
@Disabled("TODO: supported null viewport option")
119118
void shouldNotAllowDeviceScaleFactorWithNullViewport() {
120119
try {
121-
browser.newContext(new Browser.NewContextOptions().setDeviceScaleFactor(1.0));
120+
browser.newContext(new Browser.NewContextOptions().setDeviceScaleFactor(1.0).setViewportSize(null));
122121
fail("did not throw");
123122
} catch (PlaywrightException e) {
124123
assertTrue(e.getMessage().contains("\"deviceScaleFactor\" option is not supported with null \"viewport\""));
125124
}
126125
}
127126

128127
@Test
129-
@Disabled("TODO: supported null viewport option")
130128
void shouldNotAllowIsMobileWithNullViewport() {
131129
try {
132-
browser.newContext(new Browser.NewContextOptions().setIsMobile(true));
130+
browser.newContext(new Browser.NewContextOptions().setIsMobile(true).setViewportSize(null));
133131
fail("did not throw");
134132
} catch (PlaywrightException e) {
135133
assertTrue(e.getMessage().contains("\"isMobile\" option is not supported with null \"viewport\""));

0 commit comments

Comments
 (0)