Skip to content

Commit

Permalink
[grid]: platformName is empty should be considered as enum ANY instea…
Browse files Browse the repository at this point in the history
…d of WINDOWS (#15036)

Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Jan 6, 2025
1 parent 75aab75 commit 81f435d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
14 changes: 13 additions & 1 deletion java/src/org/openqa/selenium/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public enum Platform {

/** Never returned, but can be used to request a browser running on any version of Windows. */
WINDOWS("") {
WINDOWS("windows") {
@Override
public Platform family() {
return null;
Expand Down Expand Up @@ -302,6 +302,18 @@ public String toString() {
}
},

SEQUOIA("sequoia", "os x 15.0", "macos 15.0") {
@Override
public Platform family() {
return MAC;
}

@Override
public String toString() {
return "macOS 15.0";
}
},

/** Many platforms have UNIX traits, amongst them LINUX, Solaris and BSD. */
UNIX("solaris", "bsd") {
@Override
Expand Down
32 changes: 32 additions & 0 deletions java/test/org/openqa/selenium/PlatformTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import static org.openqa.selenium.Platform.IOS;
import static org.openqa.selenium.Platform.LINUX;
import static org.openqa.selenium.Platform.MAC;
import static org.openqa.selenium.Platform.SEQUOIA;
import static org.openqa.selenium.Platform.UNIX;
import static org.openqa.selenium.Platform.VISTA;
import static org.openqa.selenium.Platform.WIN11;
import static org.openqa.selenium.Platform.WIN8;
import static org.openqa.selenium.Platform.WIN8_1;
import static org.openqa.selenium.Platform.WINDOWS;
Expand Down Expand Up @@ -57,6 +59,11 @@ void testWin81IsWindows() {
assertThat(WIN8_1.is(WINDOWS)).isTrue();
}

@Test
void testWindows11IsWindows() {
assertThat(WIN11.is(WINDOWS)).isTrue();
}

@Test
void testLinuxIsUnix() {
assertThat(LINUX.is(UNIX)).isTrue();
Expand Down Expand Up @@ -165,16 +172,41 @@ void testWindowsIsWindows() {
assertThat(WINDOWS).isEqualTo(Platform.fromString("windows"));
}

@Test
void testWindowsIsNotEmpty() {
assertThat(WINDOWS).isNotEqualTo(Platform.fromString(""));
}

@Test
void canParseMacOsXCorrectly() {
assertThat(Platform.fromString("Mac OS X")).isEqualTo(MAC);
}

@Test
void testAnyIsFromStringEmpty() {
assertThat(ANY).isEqualTo(Platform.fromString(""));
}

@Test
void testAnyIsFromStringAny() {
assertThat(ANY).isEqualTo(Platform.fromString("any"));
}

@Test
void testAnyIsNotFromStringWindows() {
assertThat(ANY).isNotEqualTo(Platform.fromString("windows"));
}

@Test
void catalinaIsMac() {
assertThat(CATALINA.is(MAC)).isTrue();
}

@Test
void sequoiaIsMac() {
assertThat(SEQUOIA.is(MAC)).isTrue();
}

@Test
void canParseCatalinaFromOSName() {
assertThat(Platform.fromString("macOS 10.15")).isEqualTo(CATALINA);
Expand Down

0 comments on commit 81f435d

Please sign in to comment.