Skip to content

Commit

Permalink
All Platforms have a family.
Browse files Browse the repository at this point in the history
For `Platform` values that represent a platform family,
that value is itself.
  • Loading branch information
shs96c committed Aug 29, 2017
1 parent ce962bd commit 1080c91
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions java/client/src/org/openqa/selenium/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public enum Platform {
/**
* Never returned, but can be used to request a browser running on any version of Windows.
*/
WINDOWS("") {},
WINDOWS("") {
@Override
public Platform family() {
return WINDOWS;
}
},

/**
* For versions of Windows that "feel like" Windows XP. These are ones that store files in
Expand Down Expand Up @@ -79,7 +84,12 @@ public Platform family() {
}
},

MAC("mac", "darwin", "macOS", "os x") {},
MAC("mac", "darwin", "macOS", "os x") {
@Override
public Platform family() {
return MAC;
}
},

SNOW_LEOPARD("snow leopard", "os x 10.6") {
@Override
Expand Down Expand Up @@ -150,12 +160,17 @@ public String toString() {
/**
* Many platforms have UNIX traits, amongst them LINUX, Solaris and BSD.
*/
UNIX("solaris", "bsd") {},
UNIX("solaris", "bsd") {
@Override
public Platform family() {
return UNIX;
}
},

LINUX("linux") {
@Override
public Platform family() {
return UNIX;
return LINUX;
}
},

Expand All @@ -166,20 +181,20 @@ public Platform family() {
}
},

/**
* Provide a temporary workaround for an issue where platformName was being overridden by
* platform for external providers.
*/
@Deprecated
IOS("iOS") {
@Override
public Platform family() { return MAC; }
public Platform family() { return IOS; }
},

/**
* Never returned, but can be used to request a browser running on any operating system.
*/
ANY("") {
@Override
public Platform family() {
return ANY;
}

@Override
public boolean is(Platform compareWith) {
return this == compareWith;
Expand All @@ -190,7 +205,7 @@ public boolean is(Platform compareWith) {
private int minorVersion = 0;
private int majorVersion = 0;

private Platform(String... partOfOsName) {
Platform(String... partOfOsName) {
this.partOfOsName = partOfOsName;
}

Expand Down Expand Up @@ -340,9 +355,7 @@ public boolean is(Platform compareWith) {
*
* @return the family platform for the current one
*/
public Platform family() {
return ANY;
}
public abstract Platform family();

private boolean isCurrentPlatform(String osName, String matchAgainst) {
return osName.contains(matchAgainst);
Expand Down

0 comments on commit 1080c91

Please sign in to comment.