JUnit minor fixes (#1486)
This commit is contained in:
committed by
GitHub
parent
36705817bf
commit
de1d6a6b36
@@ -4,20 +4,15 @@ import com.microsoft.playwright.APIRequest;
|
||||
import com.microsoft.playwright.Browser;
|
||||
import com.microsoft.playwright.BrowserType;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.options.ViewportSize;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class Options {
|
||||
public String baseUrl;
|
||||
public Path storageStatePath;
|
||||
public ViewportSize viewportSize;
|
||||
public String channel;
|
||||
public Boolean headless;
|
||||
public String browserName;
|
||||
public String deviceName;
|
||||
public BrowserType.LaunchOptions launchOptions;
|
||||
public Browser.NewContextOptions contextOption;
|
||||
public Browser.NewContextOptions contextOptions;
|
||||
public APIRequest.NewContextOptions apiRequestOptions;
|
||||
public Playwright.CreateOptions playwrightCreateOptions;
|
||||
|
||||
@@ -39,12 +34,12 @@ public class Options {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Browser.NewContextOptions getContextOption() {
|
||||
return contextOption;
|
||||
public Browser.NewContextOptions getContextOptions() {
|
||||
return contextOptions;
|
||||
}
|
||||
|
||||
public Options setContextOption(Browser.NewContextOptions contextOption) {
|
||||
this.contextOption = contextOption;
|
||||
public Options setContextOptions(Browser.NewContextOptions contextOptions) {
|
||||
this.contextOptions = contextOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -66,15 +61,6 @@ public class Options {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Path getStorageStatePath() {
|
||||
return storageStatePath;
|
||||
}
|
||||
|
||||
public Options setStorageStatePath(Path storageStatePath) {
|
||||
this.storageStatePath = storageStatePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBrowserName() {
|
||||
return browserName;
|
||||
}
|
||||
@@ -110,13 +96,4 @@ public class Options {
|
||||
this.headless = headless;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewportSize getViewportSize() {
|
||||
return viewportSize;
|
||||
}
|
||||
|
||||
public Options setViewportSize(ViewportSize viewportSize) {
|
||||
this.viewportSize = viewportSize;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-9
@@ -49,7 +49,7 @@ public class BrowserContextExtension implements ParameterResolver, AfterEachCall
|
||||
}
|
||||
|
||||
private static Browser.NewContextOptions getContextOptions(Playwright playwright, Options options) {
|
||||
Browser.NewContextOptions contextOptions = Utils.clone(options.getContextOption());
|
||||
Browser.NewContextOptions contextOptions = Utils.clone(options.getContextOptions());
|
||||
if (contextOptions == null) {
|
||||
contextOptions = new Browser.NewContextOptions();
|
||||
}
|
||||
@@ -58,10 +58,6 @@ public class BrowserContextExtension implements ParameterResolver, AfterEachCall
|
||||
contextOptions.setBaseURL(options.getBaseUrl());
|
||||
}
|
||||
|
||||
if (options.getStorageStatePath() != null) {
|
||||
contextOptions.setStorageStatePath(options.getStorageStatePath());
|
||||
}
|
||||
|
||||
if (options.getDeviceName() != null) {
|
||||
DeviceDescriptor deviceDescriptor = DeviceDescriptor.findByName(playwright, options.getDeviceName());
|
||||
if (deviceDescriptor == null) {
|
||||
@@ -76,10 +72,6 @@ public class BrowserContextExtension implements ParameterResolver, AfterEachCall
|
||||
contextOptions.hasTouch = deviceDescriptor.hasTouch;
|
||||
}
|
||||
|
||||
if (options.getViewportSize() != null) {
|
||||
contextOptions.setViewportSize(options.getViewportSize());
|
||||
}
|
||||
|
||||
return contextOptions;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -7,7 +7,6 @@ import java.util.regex.Pattern;
|
||||
|
||||
import static com.microsoft.playwright.junit.ServerLifecycle.serverMap;
|
||||
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@FixtureTest
|
||||
@@ -20,7 +19,7 @@ public class TestFixtureContextOptions {
|
||||
return new Options()
|
||||
.setApiRequestOptions(new APIRequest.NewContextOptions()
|
||||
.setBaseURL(serverMap.get(TestFixtureContextOptions.class).EMPTY_PAGE))
|
||||
.setContextOption(new Browser.NewContextOptions()
|
||||
.setContextOptions(new Browser.NewContextOptions()
|
||||
.setBaseURL(serverMap.get(TestFixtureContextOptions.class).EMPTY_PAGE));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user