@Test
 @Ignore(platforms = WINDOWS, value = "Unable to set env vars on runtime on Windows")
 public void launcherPrioritizesEnvironmentalLauncher() throws IOException {
   environment.set(LAUNCHER_ENV_VAR, resources.fakeFile().getPath());
   OperaSettings settings = new OperaSettings();
   settings.setLauncher(resources.executableBinary());
   assertEquals(resources.fakeFile(), settings.getLauncher());
 }
  @Test
  public void autostartDisabled() {
    OperaSettings settings = new OperaSettings();
    settings.autostart(false);

    try {
      new TestOperaDesktopDriver(settings);
      fail("Expected exception");
    } catch (WebDriverException e) {
      assertThat(e.getCause(), instanceOf(ResponseNotReceivedException.class));
      assertThat(e.getMessage(), containsString("No response in a timely fashion"));
    }
  }
  @Test
  public void surplusCapabilitiesAreIncludedWhenConvertedToCapabilities() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("foo", "bar");

    settings.merge(capabilities);

    for (Map.Entry<String, ?> capability : settings.toCapabilities().asMap().entrySet()) {
      if (capability.getKey().equals("foo") && capability.getValue().equals("bar")) {
        return;
      }
    }

    fail("Surplus capabilities not included in OperaSettings#toCapabilities()");
  }
  @Test
  public void canBeConvertedToCapabilities() {
    Capabilities capabilities = settings.toCapabilities();

    assertNotNull(capabilities);
    assertTrue(capabilities.asMap().size() > 0);
    assertEquals(true, capabilities.getCapability(AUTOSTART.getCapability()));
  }
  @Test
  @NeedsLocalEnvironment
  public void browserDoesNotQuit() {
    OperaSettings settings = new OperaSettings();
    settings.setDetach(true);

    driver = new TestOperaDesktopDriver(settings);
    int processID = driver.utils().getPID();
    driver.quit();

    // Driver should be shut down, and there should be no connection to browser
    assertFalse(driver.getServices().isConnected());

    // But browser should be running
    assertTrue(ProcessManager.isPidRunning(processID));

    ProcessManager.killPID(processID);
  }
  @Test
  public void testBadLauncher() throws IOException {
    assertTrue("Imposter launcher exists", resources.executableBinary().exists());
    settings.setLauncher(resources.executableBinary());

    try {
      runner = new OperaLauncherRunner(settings);
      fail("Did not throw OperaRunnerException");
    } catch (OperaRunnerException e) {
      assertTrue("Throws timeout error", e.getMessage().toLowerCase().contains("timeout"));
    }
  }
  @Test
  public void displayCanBeSetOnLinuxOnly() {
    Exception ex = null;
    try {
      settings.setDisplay(7);
    } catch (UnsupportedOperationException e) {
      ex = e;
    }

    if (!Platform.getCurrent().is(LINUX) && ex == null) {
      fail("Expected exception on setting the framebuffer display");
    }
  }
 @Test
 public void toJsonConvertsEverythingElseToStrings() throws IOException, JSONException {
   assertEquals("127.0.0.1", settings.toJson().get("host"));
 }
 @Test
 public void toJsonConvertsArgumentsToJson() throws IOException, JSONException {
   assertFalse(settings.toJson().get("arguments") instanceof OperaArguments);
 }
Ejemplo n.º 10
0
 @Test
 public void toJsonConvertsProfileToJson() throws IOException, JSONException {
   assertFalse(settings.toJson().get("profile") instanceof OperaProfile);
 }
Ejemplo n.º 11
0
 @Test
 public void productCanBeSet() {
   settings.setProduct(CORE);
   assertEquals(CORE, settings.getProduct());
 }
Ejemplo n.º 12
0
 @Test
 public void loggingLevelCanBeSet() {
   settings.logging().setLevel(Level.WARNING);
   assertEquals(Level.WARNING, settings.logging().getLevel());
 }
Ejemplo n.º 13
0
 @Test
 public void loggingFileCanBeSet() throws IOException {
   settings.logging().setFile(resources.textFile());
   assertEquals(resources.textFile(), settings.logging().getFile());
 }
Ejemplo n.º 14
0
 @Test
 public void supportsPdIsFalseIfProfileIsEmptyString() {
   settings.setProfile("");
   assertFalse(settings.supportsPd());
 }
Ejemplo n.º 15
0
 @Test
 public void supportsPdIsFalseIfProductIsCore() {
   settings.setProduct(CORE);
   assertFalse(settings.supportsPd());
 }
Ejemplo n.º 16
0
 @Test
 public void supportsDebugProxyIsFalseIfDefaultServerPort() {
   settings.setPort((int) SERVER_DEFAULT_PORT_IDENTIFIER.getValue());
   assertFalse(settings.supportsDebugProxy());
 }
Ejemplo n.º 17
0
 @Test
 public void supportsPdIsTrueByDefault() {
   assertTrue(settings.supportsPd());
 }
Ejemplo n.º 18
0
 @Test
 public void supportsDebugProxyIsTrueByDefault() {
   assertTrue(settings.supportsDebugProxy());
 }
Ejemplo n.º 19
0
 @Test
 public void backendCanBeSet() {
   settings.setBackend("hardware");
   assertEquals("hardware", settings.getBackend());
 }
Ejemplo n.º 20
0
 @Test
 public void backendIsSoftware() {
   assertEquals("software", settings.getBackend());
 }
Ejemplo n.º 21
0
 @Test
 public void stringRepresentation() {
   assertNotNull(settings.toString());
 }
Ejemplo n.º 22
0
 @Test
 public void detachCanBeSet() {
   settings.setDetach(true);
   assertTrue(settings.hasDetach());
 }
Ejemplo n.º 23
0
 @Test
 public void loggingLevelIsInfo() {
   assertEquals(Level.INFO, settings.logging().getLevel());
 }
Ejemplo n.º 24
0
 @Test
 public void detachIsFalse() {
   assertFalse(settings.hasDetach());
 }
Ejemplo n.º 25
0
 @Test
 public void loggingFileIsNull() {
   assertNull(settings.logging().getFile());
 }
Ejemplo n.º 26
0
 @Test
 public void noRestartCanBeSet() {
   settings.noRestart(true);
   assertTrue(settings.noRestart());
 }
Ejemplo n.º 27
0
 @Test(expected = WebDriverException.class)
 public void loggingFileToInvalidFileThrowsException() {
   settings.logging().setFile(resources.fakeFile());
 }
Ejemplo n.º 28
0
 @Test
 public void toJsonConvertsBooleansToIntegers() throws IOException, JSONException {
   assertEquals(1, settings.toJson().get("autostart"));
 }
Ejemplo n.º 29
0
 @Test
 public void supportsPdIsFalseIfProductIsCoreAndProfileIsSet() {
   settings.setProduct(CORE);
   settings.setProfile(new OperaProfile());
   assertFalse(settings.supportsPd());
 }
Ejemplo n.º 30
0
 @Test
 public void productIsDesktop() {
   assertEquals(DESKTOP, settings.getProduct());
 }