Skip to content

Commit

Permalink
add a way to add to the list of capabilities to consider to the defau…
Browse files Browse the repository at this point in the history
…lt capability matcher

also enable it to be extensible
  • Loading branch information
lukeis committed Jan 29, 2016
1 parent 3f83743 commit 1504523
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public class DefaultCapabilityMatcher implements CapabilityMatcher {
private static final Logger log = Logger.getLogger(DefaultCapabilityMatcher.class.getName());
private static final String GRID_TOKEN = "_";

// temporary fix to only check to most meaningful desiredCapability params
private final List<String> toConsider = new ArrayList<>();
protected final List<String> toConsider = new ArrayList<>();

public DefaultCapabilityMatcher() {
toConsider.add(CapabilityType.PLATFORM);
Expand All @@ -47,14 +46,20 @@ public DefaultCapabilityMatcher() {

}

/**
* @param capabilityName capability name to have grid match requested with test slot
*/
public void addToConsider(String capabilityName) {
toConsider.add(capabilityName);
}

public boolean matches(Map<String, Object> nodeCapability, Map<String, Object> requestedCapability) {
if (nodeCapability == null || requestedCapability == null) {
return false;
}
for (String key : requestedCapability.keySet()) {
// ignore capabilities that are targeted at grid internal for the
// matching
// TODO freynaud only consider version, browser and OS for now
if (!key.startsWith(GRID_TOKEN) && toConsider.contains(key)) {
if (requestedCapability.get(key) != null) {
String value = requestedCapability.get(key).toString();
Expand Down

0 comments on commit 1504523

Please sign in to comment.