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();
|
int deviceScaleFactor();
|
||||||
boolean isMobile();
|
boolean isMobile();
|
||||||
boolean hasTouch();
|
boolean hasTouch();
|
||||||
enum BrowserType { CHROMIUM, FIREFOX, WEBKIT}
|
|
||||||
BrowserType defaultBrowserType();
|
BrowserType defaultBrowserType();
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,12 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright.impl;
|
package com.microsoft.playwright.impl;
|
||||||
|
|
||||||
|
import com.microsoft.playwright.BrowserType;
|
||||||
import com.microsoft.playwright.DeviceDescriptor;
|
import com.microsoft.playwright.DeviceDescriptor;
|
||||||
import com.microsoft.playwright.PlaywrightException;
|
import com.microsoft.playwright.PlaywrightException;
|
||||||
|
|
||||||
class DeviceDescriptorImpl implements DeviceDescriptor {
|
class DeviceDescriptorImpl implements DeviceDescriptor {
|
||||||
|
PlaywrightImpl playwright;
|
||||||
private static class ViewportImpl implements Viewport{
|
private static class ViewportImpl implements Viewport{
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
@ -39,7 +41,6 @@ class DeviceDescriptorImpl implements DeviceDescriptor {
|
|||||||
private int deviceScaleFactor;
|
private int deviceScaleFactor;
|
||||||
private boolean isMobile;
|
private boolean isMobile;
|
||||||
private boolean hasTouch;
|
private boolean hasTouch;
|
||||||
// 'chromium' | 'firefox' | 'webkit'
|
|
||||||
private String defaultBrowserType;
|
private String defaultBrowserType;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,9 +71,9 @@ class DeviceDescriptorImpl implements DeviceDescriptor {
|
|||||||
@Override
|
@Override
|
||||||
public BrowserType defaultBrowserType() {
|
public BrowserType defaultBrowserType() {
|
||||||
switch (defaultBrowserType) {
|
switch (defaultBrowserType) {
|
||||||
case "chromium": return BrowserType.CHROMIUM;
|
case "chromium": return playwright.chromium();
|
||||||
case "firefox": return BrowserType.FIREFOX;
|
case "firefox": return playwright.firefox();
|
||||||
case "webkit": return BrowserType.WEBKIT;
|
case "webkit": return playwright.webkit();
|
||||||
default: throw new PlaywrightException("Unknown type: " + defaultBrowserType);
|
default: throw new PlaywrightException("Unknown type: " + defaultBrowserType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright {
|
|||||||
JsonObject o = item.getAsJsonObject();
|
JsonObject o = item.getAsJsonObject();
|
||||||
String name = o.get("name").getAsString();
|
String name = o.get("name").getAsString();
|
||||||
DeviceDescriptorImpl descriptor = gson.fromJson(o.get("descriptor"), DeviceDescriptorImpl.class);
|
DeviceDescriptorImpl descriptor = gson.fromJson(o.get("descriptor"), DeviceDescriptorImpl.class);
|
||||||
|
descriptor.playwright = this;
|
||||||
devices.put(name, descriptor);
|
devices.put(name, descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user