-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate webdriver_firefox_port preference to FirefoxDriver, was bei…
…ng ignored. Fixes issue 5172 Signed-off-by: Alexei Barantsev <[email protected]>
- Loading branch information
Showing
8 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
java/client/test/org/openqa/selenium/firefox/FirefoxDriverUtilitiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.openqa.selenium.firefox; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.junit.Test; | ||
import org.openqa.selenium.internal.Lock; | ||
import org.openqa.selenium.internal.SocketLock; | ||
|
||
/** | ||
* FirefoxDriverUtilitiesTest is responsible for tests of FirefoxDriver | ||
* utilities that do not require a browser. | ||
*/ | ||
public class FirefoxDriverUtilitiesTest { | ||
|
||
@Test | ||
public void shouldObtainSocketLockForDefaultPortWhenNotSpecifiedInProfile(){ | ||
Lock lock = FirefoxDriver.obtainLock(new FirefoxProfile()); | ||
|
||
assertTrue("expected lock to be a SocketLock", lock instanceof SocketLock); | ||
|
||
assertEquals(SocketLock.DEFAULT_PORT, ((SocketLock) lock).getLockPort()); | ||
} | ||
|
||
@Test | ||
public void shouldObtainSocketLockForPortSpecifiedInProfile(){ | ||
FirefoxProfile mockProfile = mock(FirefoxProfile.class); | ||
int preferredPort = 2400; | ||
when(mockProfile.getIntegerPreference(FirefoxProfile.PORT_PREFERENCE, SocketLock.DEFAULT_PORT)).thenReturn( | ||
preferredPort); | ||
|
||
Lock lock = FirefoxDriver.obtainLock(mockProfile); | ||
|
||
assertTrue("expected lock to be a SocketLock", lock instanceof SocketLock); | ||
|
||
assertEquals(preferredPort, ((SocketLock) lock).getLockPort()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
java/client/test/org/openqa/selenium/firefox/internal/NewProfileExtensionConnectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.openqa.selenium.firefox.internal; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import org.junit.Test; | ||
import org.openqa.selenium.WebDriverException; | ||
import org.openqa.selenium.firefox.FirefoxBinary; | ||
import org.openqa.selenium.firefox.FirefoxProfile; | ||
import org.openqa.selenium.internal.SocketLock; | ||
|
||
public class NewProfileExtensionConnectionTest { | ||
|
||
@Test | ||
public void canBeConstructed() throws Exception { | ||
new NewProfileExtensionConnection | ||
(makeLock(), new FirefoxBinary(), new FirefoxProfile(), "my-host"); | ||
} | ||
|
||
@Test | ||
public void shouldDefaultToPortSpecifiedInProfileWhenDeterminingNextFreePort() throws Exception { | ||
int expectedPort = 2400; | ||
|
||
FirefoxProfile profile = new FirefoxProfile(); | ||
profile.setPreference(FirefoxProfile.PORT_PREFERENCE, expectedPort); | ||
|
||
NewProfileExtensionConnection connection = new NewProfileExtensionConnection | ||
(makeLock(), new FirefoxBinary(), profile, "my-host"); | ||
|
||
try { | ||
|
||
connection.start(); | ||
|
||
fail("there was an unexpected server listening on " + expectedPort + "; expected connection to fail"); | ||
} catch (WebDriverException e) { | ||
int PORT_PREFERENCE_NOT_PROPAGATED = -1; | ||
assertEquals(expectedPort, | ||
profile.getIntegerPreference(FirefoxProfile.PORT_PREFERENCE, PORT_PREFERENCE_NOT_PROPAGATED)); | ||
} | ||
|
||
} | ||
|
||
private SocketLock makeLock() { | ||
return new SocketLock(4200); | ||
} | ||
} |