Skip to content

Commit

Permalink
[java] Changing return type of Target.getTargets from Set to List
Browse files Browse the repository at this point in the history
Because CDP specification says: "Retrieves a list of available targets."
  • Loading branch information
barancev committed Oct 18, 2019
1 parent fd1fabe commit 2d5cde1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions java/client/src/org/openqa/selenium/devtools/DevTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

import java.io.Closeable;
import java.time.Duration;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -71,7 +71,7 @@ public void createSessionIfThereIsNotOne() {

public void createSession() {
// Figure out the targets.
Set<TargetInfo> infos = connection.sendAndWait(cdpSession, Target.getTargets(), timeout);
List<TargetInfo> infos = connection.sendAndWait(cdpSession, Target.getTargets(), timeout);

// Grab the first "page" type, and glom on to that.
// TODO: Find out which one might be the current one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import static org.openqa.selenium.devtools.ConverterFunctions.map;

Expand Down Expand Up @@ -178,11 +177,11 @@ public static Command<TargetInfo> getTargetInfo(Optional<TargetID> targetId) {
/**
* Retrieves a list of available targets.
*/
public static Command<Set<TargetInfo>> getTargets() {
public static Command<List<TargetInfo>> getTargets() {
return new Command<>(
"Target.getTargets",
ImmutableMap.of(),
ConverterFunctions.map("targetInfos", new TypeToken<Set<TargetInfo>>() {
ConverterFunctions.map("targetInfos", new TypeToken<List<TargetInfo>>() {
}.getType()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.openqa.selenium.devtools.target.model.SessionID;
import org.openqa.selenium.devtools.target.model.TargetInfo;

import java.util.List;
import java.util.Optional;
import java.util.Set;

import static org.openqa.selenium.devtools.inspector.Inspector.detached;
import static org.openqa.selenium.devtools.inspector.Inspector.disable;
Expand All @@ -35,7 +35,7 @@ public class ChromeDevToolsInspectorTest extends DevToolsTestBase {
public void inspectDetached() {
devTools.addListener(detached(), Assert::assertNotNull);
devTools.send(enable());
Set<TargetInfo> targetInfos = devTools.send(Target.getTargets());
List<TargetInfo> targetInfos = devTools.send(Target.getTargets());
targetInfos.forEach(
targetInfo -> {
SessionID sessionId =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.openqa.selenium.devtools.target.model.TargetInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -57,7 +57,7 @@ public void getTargetActivateAndAttach() {
devTools.addListener(attachedToTarget(), Assert::assertNotNull);

driver.get(appServer.whereIs("devToolsConsoleTest.html"));
Set<TargetInfo> allTargets = devTools.send(getTargets());
List<TargetInfo> allTargets = devTools.send(getTargets());

for (TargetInfo target : allTargets) {
validateTarget(target);
Expand All @@ -72,7 +72,7 @@ public void getTargetActivateAndAttach() {

@Test
public void getTargetAndSendMessageToTarget() {
Set<TargetInfo> allTargets = null;
List<TargetInfo> allTargets = null;
SessionID sessionId = null;
TargetInfo targetInfo = null;
driver.get(appServer.whereIs("devToolsConsoleTest.html"));
Expand Down Expand Up @@ -143,7 +143,7 @@ private void validateTargetInfo(TargetInfo targetInfo) {
assertNotNull(targetInfo.getUrl());
}

private void validateTargetsInfos(Set<TargetInfo> targets) {
private void validateTargetsInfos(List<TargetInfo> targets) {
assertNotNull(targets);
assertFalse(targets.isEmpty());
}
Expand Down

0 comments on commit 2d5cde1

Please sign in to comment.