Skip to content

Commit

Permalink
Always compare more specific platform to less specific one
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Jun 27, 2014
1 parent 52197cf commit 6b58d26
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ class SafariExtensions {
*/
private static File getSafariDataDirectory() {
Platform current = Platform.getCurrent();
if (Platform.MAC.is(current)) {
if (current.is(Platform.MAC)) {
return new File("/Users/" + System.getenv("USER"), "Library/Safari");
} else if (Platform.WINDOWS.is(current)) {
} else if (current.is(Platform.WINDOWS)) {
return new File(System.getenv("APPDATA"), "Apple Computer/Safari");
}

Expand Down
4 changes: 2 additions & 2 deletions java/client/src/org/openqa/selenium/safari/SessionData.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static SessionData forCurrentPlatform() {
Platform current = Platform.getCurrent();

Iterable<File> files = ImmutableList.of();
if (Platform.MAC.is(current)) {
if (current.is(Platform.MAC)) {
File libraryDir = new File("/Users", System.getenv("USER") + "/Library");
files = ImmutableList.of(
new File(libraryDir, "Caches/com.apple.Safari/Cache.db"),
Expand All @@ -38,7 +38,7 @@ public static SessionData forCurrentPlatform() {
new File(libraryDir, "Safari/Databases"));
}

if (Platform.WINDOWS.is(current)) {
if (current.is(Platform.WINDOWS)) {
File appDataDir = new File(System.getenv("APPDATA"), "Apple Computer/Safari");
File localDataDir = new File(System.getenv("LOCALAPPDATA"), "Apple Computer/Safari");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.JavascriptEnabled;

import org.openqa.selenium.testing.TestUtilities;
import org.openqa.selenium.testing.drivers.SauceDriver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.openqa.selenium.testing.TestUtilities;

@RunWith(Suite.class)
@Suite.SuiteClasses({
Expand All @@ -39,7 +40,7 @@ public class SafariDriverTests {

@BeforeClass
public static void isSupportedPlatform() {
Platform current = Platform.getCurrent();
assumeTrue(Platform.MAC.is(current) || Platform.WINDOWS.is(current));
Platform current = TestUtilities.getEffectivePlatform();
assumeTrue(current.is(Platform.MAC) || current.is(Platform.WINDOWS));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean shouldIgnore(Ignore ignoreAnnotation) {
for (Ignore.Driver value : ignoreAnnotation.value()) {
if (ignored.contains(value) || value == Ignore.Driver.ALL) {
for (Platform platform : ignoreAnnotation.platforms()) {
if (platform.is(currentPlatform)) {
if (currentPlatform.is(platform)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.openqa.selenium.testing.JavascriptEnabled;
import org.openqa.selenium.testing.NativeEventsRequired;
import org.openqa.selenium.testing.NeedsLocalEnvironment;
import org.openqa.selenium.testing.TestUtilities;

import java.util.Arrays;
import java.util.Set;
Expand Down Expand Up @@ -131,7 +132,7 @@ private boolean isIgnoredBecauseOfNativeEvents(NativeEventsRequired annotation)
}

// We only have native events on Linux and Windows.
Platform platform = Platform.getCurrent();
Platform platform = TestUtilities.getEffectivePlatform();
return !(platform.is(LINUX) || platform.is(WINDOWS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void registerDefaults(Platform current) {
private void registerDriverProviders(Platform current) {
for (DriverProvider provider : ServiceLoader.load(DriverProvider.class)) {
Capabilities caps = provider.getProvidedCapabilities();
if (caps.getPlatform() == null || caps.getPlatform().is(current)) {
if (caps.getPlatform() == null || caps.getPlatform() == Platform.ANY || current.is(caps.getPlatform())) {
factory.registerDriverProvider(caps, provider);
} else {
log.info("Driver provider " + provider + " registration is skipped: registration capabilities "
Expand Down

0 comments on commit 6b58d26

Please sign in to comment.