Skip to content

Commit

Permalink
Attempt to get DevMode working again
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Dec 11, 2018
1 parent 68d43e7 commit 3bf3cdb
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion java/client/test/org/openqa/selenium/build/DevMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,34 @@

package org.openqa.selenium.build;

import com.google.common.collect.ImmutableSet;

import java.util.Set;
import java.util.function.Supplier;

public class DevMode {

// There is absolutely no way that this is going to be fragile. No way. Nada. Nope.
private static final Set<Supplier<Boolean>> DEV_MODE_CHECKS = ImmutableSet.of(
// Check for IntelliJ
() -> System.getProperty("java.class.path", "").contains("idea_rt.jar"),

// Check for Eclipse
() -> {
try {
Class.forName("org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader");
return true;
} catch (ReflectiveOperationException e) {
return false;
}
},

// Allow someone to set a system property
() -> Boolean.getBoolean("selenium.dev-mode")
);

public static boolean isInDevMode() {
return false;//isInDevMode("/org/openqa/selenium/remote/isDisplayed.js");
return DEV_MODE_CHECKS.stream().map(Supplier::get).reduce(Boolean::logicalOr).orElse(false);
}

public static boolean isInDevMode(String nameOfRequiredResource) {
Expand Down

0 comments on commit 3bf3cdb

Please sign in to comment.