Skip to content

Commit 1504523

Browse files
committed
add a way to add to the list of capabilities to consider to the default capability matcher
also enable it to be extensible
1 parent 3f83743 commit 1504523

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

java/server/src/org/openqa/grid/internal/utils/DefaultCapabilityMatcher.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public class DefaultCapabilityMatcher implements CapabilityMatcher {
3636
private static final Logger log = Logger.getLogger(DefaultCapabilityMatcher.class.getName());
3737
private static final String GRID_TOKEN = "_";
3838

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

4241
public DefaultCapabilityMatcher() {
4342
toConsider.add(CapabilityType.PLATFORM);
@@ -47,14 +46,20 @@ public DefaultCapabilityMatcher() {
4746

4847
}
4948

49+
/**
50+
* @param capabilityName capability name to have grid match requested with test slot
51+
*/
52+
public void addToConsider(String capabilityName) {
53+
toConsider.add(capabilityName);
54+
}
55+
5056
public boolean matches(Map<String, Object> nodeCapability, Map<String, Object> requestedCapability) {
5157
if (nodeCapability == null || requestedCapability == null) {
5258
return false;
5359
}
5460
for (String key : requestedCapability.keySet()) {
5561
// ignore capabilities that are targeted at grid internal for the
5662
// matching
57-
// TODO freynaud only consider version, browser and OS for now
5863
if (!key.startsWith(GRID_TOKEN) && toConsider.contains(key)) {
5964
if (requestedCapability.get(key) != null) {
6065
String value = requestedCapability.get(key).toString();

0 commit comments

Comments
 (0)