-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java][bidi]: implement
getClientWindows
method (#14869)
- Loading branch information
Showing
7 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
load("@rules_jvm_external//:defs.bzl", "artifact") | ||
load("//java:defs.bzl", "java_library") | ||
|
||
java_library( | ||
name = "browser", | ||
srcs = glob( | ||
[ | ||
"*.java", | ||
], | ||
), | ||
visibility = [ | ||
"//java/src/org/openqa/selenium/bidi:__subpackages__", | ||
"//java/src/org/openqa/selenium/firefox:__subpackages__", | ||
"//java/src/org/openqa/selenium/remote:__pkg__", | ||
"//java/test/org/openqa/selenium/bidi:__subpackages__", | ||
"//java/test/org/openqa/selenium/grid:__subpackages__", | ||
], | ||
deps = [ | ||
"//java/src/org/openqa/selenium:core", | ||
"//java/src/org/openqa/selenium/bidi", | ||
"//java/src/org/openqa/selenium/bidi/script", | ||
"//java/src/org/openqa/selenium/json", | ||
"//java/src/org/openqa/selenium/remote/http", | ||
artifact("com.google.auto.service:auto-service-annotations"), | ||
], | ||
) |
30 changes: 30 additions & 0 deletions
30
java/src/org/openqa/selenium/bidi/browser/ClientWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.browser; | ||
|
||
public class ClientWindow { | ||
private final String id; | ||
|
||
public ClientWindow(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
java/src/org/openqa/selenium/bidi/browser/ClientWindowInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.browser; | ||
|
||
import java.util.Map; | ||
|
||
public class ClientWindowInfo { | ||
private final String clientWindow; | ||
private final ClientWindowState state; | ||
private final Integer width; | ||
private final Integer height; | ||
private final Integer x; | ||
private final Integer y; | ||
private final boolean active; | ||
|
||
public ClientWindowInfo( | ||
String clientWindow, | ||
ClientWindowState state, | ||
Integer width, | ||
Integer height, | ||
Integer x, | ||
Integer y, | ||
boolean active) { | ||
this.clientWindow = clientWindow; | ||
this.state = state; | ||
this.width = width; | ||
this.height = height; | ||
this.x = x; | ||
this.y = y; | ||
this.active = active; | ||
} | ||
|
||
public static ClientWindowInfo fromJson(Map<String, Object> map) { | ||
return new ClientWindowInfo( | ||
(String) map.get("clientWindow"), | ||
ClientWindowState.fromString((String) map.get("state")), | ||
((Number) map.get("width")).intValue(), | ||
((Number) map.get("height")).intValue(), | ||
((Number) map.get("x")).intValue(), | ||
((Number) map.get("y")).intValue(), | ||
(Boolean) map.get("active")); | ||
} | ||
|
||
public String getClientWindow() { | ||
return clientWindow; | ||
} | ||
|
||
public ClientWindowState getState() { | ||
return state; | ||
} | ||
|
||
public Integer getWidth() { | ||
return width; | ||
} | ||
|
||
public Integer getHeight() { | ||
return height; | ||
} | ||
|
||
public Integer getX() { | ||
return x; | ||
} | ||
|
||
public Integer getY() { | ||
return y; | ||
} | ||
|
||
public boolean isActive() { | ||
return active; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
java/src/org/openqa/selenium/bidi/browser/ClientWindowState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.browser; | ||
|
||
public enum ClientWindowState { | ||
FULLSCREEN("fullscreen"), | ||
MAXIMIZED("maximized"), | ||
MINIMIZED("minimized"), | ||
NORMAL("normal"); | ||
|
||
private final String state; | ||
|
||
ClientWindowState(String state) { | ||
this.state = state; | ||
} | ||
|
||
public String toString() { | ||
return state; | ||
} | ||
|
||
public static ClientWindowState fromString(String state) { | ||
for (ClientWindowState windowState : values()) { | ||
if (windowState.state.equals(state)) { | ||
return windowState; | ||
} | ||
} | ||
throw new IllegalArgumentException("Invalid window state: " + state); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters