mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-09-08 21:01:00 +00:00
fix: return object instead of enum from defaultBrowserType (#129)
This commit is contained in:
parent
612dc5838e
commit
62bbb89f02
@ -26,6 +26,5 @@ public interface DeviceDescriptor {
|
||||
int deviceScaleFactor();
|
||||
boolean isMobile();
|
||||
boolean hasTouch();
|
||||
enum BrowserType { CHROMIUM, FIREFOX, WEBKIT}
|
||||
BrowserType defaultBrowserType();
|
||||
}
|
||||
|
@ -16,10 +16,12 @@
|
||||
|
||||
package com.microsoft.playwright.impl;
|
||||
|
||||
import com.microsoft.playwright.BrowserType;
|
||||
import com.microsoft.playwright.DeviceDescriptor;
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
|
||||
class DeviceDescriptorImpl implements DeviceDescriptor {
|
||||
PlaywrightImpl playwright;
|
||||
private static class ViewportImpl implements Viewport{
|
||||
private int width;
|
||||
private int height;
|
||||
@ -39,7 +41,6 @@ class DeviceDescriptorImpl implements DeviceDescriptor {
|
||||
private int deviceScaleFactor;
|
||||
private boolean isMobile;
|
||||
private boolean hasTouch;
|
||||
// 'chromium' | 'firefox' | 'webkit'
|
||||
private String defaultBrowserType;
|
||||
|
||||
@Override
|
||||
@ -70,9 +71,9 @@ class DeviceDescriptorImpl implements DeviceDescriptor {
|
||||
@Override
|
||||
public BrowserType defaultBrowserType() {
|
||||
switch (defaultBrowserType) {
|
||||
case "chromium": return BrowserType.CHROMIUM;
|
||||
case "firefox": return BrowserType.FIREFOX;
|
||||
case "webkit": return BrowserType.WEBKIT;
|
||||
case "chromium": return playwright.chromium();
|
||||
case "firefox": return playwright.firefox();
|
||||
case "webkit": return playwright.webkit();
|
||||
default: throw new PlaywrightException("Unknown type: " + defaultBrowserType);
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright {
|
||||
JsonObject o = item.getAsJsonObject();
|
||||
String name = o.get("name").getAsString();
|
||||
DeviceDescriptorImpl descriptor = gson.fromJson(o.get("descriptor"), DeviceDescriptorImpl.class);
|
||||
descriptor.playwright = this;
|
||||
devices.put(name, descriptor);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user