use of org.jenkinsci.test.acceptance.guice.TestScope in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method createController.
/**
* Instantiates a controller through the "TYPE" attribute and {@link JenkinsControllerFactory}.
*/
@Provides
@TestScope
public JenkinsController createController(Injector injector, ExtensionList<JenkinsControllerFactory> factories) throws IOException {
// this is lower case for backward compatibility
String type = System.getenv("type");
if (type == null)
type = System.getenv("TYPE");
if (type == null) {
File socket = getSocket();
if (socket.exists() && !JenkinsControllerPoolProcess.MAIN) {
LOGGER.info("Found pooled jenkins controller listening on socket " + socket.getAbsolutePath());
return new PooledJenkinsController(injector, socket);
} else {
LOGGER.warning("No pooled jenkins controller listening on socket " + socket.getAbsolutePath());
type = "winstone";
}
}
for (JenkinsControllerFactory f : factories) {
if (f.getId().equalsIgnoreCase(type)) {
final JenkinsController c = f.create();
c.postConstruct(injector);
return c;
}
}
throw new AssertionError("Invalid controller type: " + type);
}
use of org.jenkinsci.test.acceptance.guice.TestScope in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method createWebDriver.
/**
* Creates a {@link WebDriver} for each test, then make sure to clean it up at the end.
*/
@Provides
@TestScope
public WebDriver createWebDriver(TestCleaner cleaner, TestName testName, ElasticTime time) throws IOException {
WebDriver base = createWebDriver(cleaner, testName);
// Make sure the window has minimal resolution set, even when out of the visible screen.
// Note - not maximizing here any more because that doesn't do anything.
Dimension oldSize = base.manage().window().getSize();
if (oldSize.height < 1050 || oldSize.width < 1680) {
base.manage().window().setSize(new Dimension(1680, 1050));
}
final EventFiringWebDriver d = new EventFiringWebDriver(base);
d.register(new Scroller());
try {
d.manage().timeouts().pageLoadTimeout(time.seconds(PAGE_LOAD_TIMEOUT), TimeUnit.MILLISECONDS);
d.manage().timeouts().implicitlyWait(time.seconds(IMPLICIT_WAIT_TIMEOUT), TimeUnit.MILLISECONDS);
} catch (UnsupportedCommandException e) {
// sauce labs RemoteWebDriver doesn't support this
LOGGER.info(base + " doesn't support page load timeout");
}
cleaner.addTask(new Statement() {
@Override
public void evaluate() {
switch(getBrowser()) {
case "firefox":
case "saucelabs-firefox":
case "remote-webdriver-firefox":
// https://github.com/mozilla/geckodriver/issues/1151
// https://bugzilla.mozilla.org/show_bug.cgi?id=1264259
// https://bugzilla.mozilla.org/show_bug.cgi?id=1434872
d.navigate().to("about:mozilla");
Alert alert = ExpectedConditions.alertIsPresent().apply(d);
if (alert != null) {
alert.accept();
d.navigate().refresh();
}
}
d.quit();
}
@Override
public String toString() {
return "Close WebDriver after test";
}
});
return d;
}
Aggregations