Skip to content

Commit

Permalink
Restoring DefaultCapabilityMatcher.addToConsider method deleted by mi…
Browse files Browse the repository at this point in the history
…stake.
  • Loading branch information
barancev committed Dec 2, 2017
1 parent 6e95a66 commit 472078c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.safari.SafariOptions;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -140,14 +141,21 @@ public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Objec
}
}

private final List<Validator> validators = ImmutableList.of(
new PlatformValidator(),
new AliasedPropertyValidator(CapabilityType.BROWSER_NAME, "browser"),
new AliasedPropertyValidator(CapabilityType.BROWSER_VERSION, CapabilityType.VERSION),
new SimplePropertyValidator(CapabilityType.APPLICATION_NAME),
new FirefoxSpecificValidator(),
new SafariSpecificValidator()
);
private final List<Validator> validators = new ArrayList<>();
{
validators.addAll(Arrays.asList(
new PlatformValidator(),
new AliasedPropertyValidator(CapabilityType.BROWSER_NAME, "browser"),
new AliasedPropertyValidator(CapabilityType.BROWSER_VERSION, CapabilityType.VERSION),
new SimplePropertyValidator(CapabilityType.APPLICATION_NAME),
new FirefoxSpecificValidator(),
new SafariSpecificValidator()
));
}

public void addToConsider(String capabilityName) {
validators.add(new SimplePropertyValidator(capabilityName));
}

public boolean matches(Map<String, Object> providedCapabilities, Map<String, Object> requestedCapabilities) {
return providedCapabilities != null && requestedCapabilities != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public void unknownPlatformMatchingTest() {
assertFalse(matcher.matches(ImmutableMap.of(CapabilityType.PLATFORM, "PS/2"), requested));
}

@Test
public void canAddAttributeMatcher() {
matcher.addToConsider("my:capability");
Map<String, Object> requested = ImmutableMap.of("my:capability", "cheese");
assertTrue(matcher.matches(ImmutableMap.of("my:capability", "cheese"), requested));
assertFalse(matcher.matches(ImmutableMap.of("my:capability", "milk"), requested));
}

@Test
public void nullEmptyValues() {
Map<String, Object> requested = new HashMap<>();
Expand Down

0 comments on commit 472078c

Please sign in to comment.