summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-02-12 14:57:13 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-02-19 15:19:46 +0200
commitfd8078d691f6b6eec407882280730104f5027e3d (patch)
tree1e9e3dac572d9951a55d6d00e935167c6056eb27 /uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
parentf4e002e36be983b16c6324255780fd7e74710d68 (diff)
downloadvaadin-framework-fd8078d691f6b6eec407882280730104f5027e3d.tar.gz
vaadin-framework-fd8078d691f6b6eec407882280730104f5027e3d.zip
Use TestBench-4.0.2
- Based on TB4 Parallel testing. - Browser setup no longer uses static capabilities. - Some code cleanup here and there. Change-Id: I5c419316cd36f4f5041eaa8da8fda3d8b46596c4
Diffstat (limited to 'uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java')
-rw-r--r--uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
index 38c94dda7d..5b4f4df788 100644
--- a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
+++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
@@ -19,28 +19,14 @@ import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import java.util.HashMap;
-import java.util.Map;
-
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
+import com.vaadin.testbench.parallel.BrowserUtil;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class VerifyBrowserVersionTest extends MultiBrowserTest {
- private Map<DesiredCapabilities, String> expectedUserAgent = new HashMap<DesiredCapabilities, String>();
-
- {
- expectedUserAgent.put(Browser.FIREFOX.getDesiredCapabilities(), "Firefox/");
- expectedUserAgent.put(Browser.IE8.getDesiredCapabilities(), "MSIE ");
- expectedUserAgent.put(Browser.IE9.getDesiredCapabilities(), "MSIE ");
- expectedUserAgent.put(Browser.IE10.getDesiredCapabilities(), "MSIE ");
- expectedUserAgent.put(Browser.IE11.getDesiredCapabilities(), "Trident/7.0; rv:");
- expectedUserAgent.put(Browser.CHROME.getDesiredCapabilities(), "Chrome/");
- expectedUserAgent.put(Browser.PHANTOMJS.getDesiredCapabilities(), "PhantomJS/");
- }
-
@Test
public void verifyUserAgent() {
openTestURL();
@@ -48,11 +34,31 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest {
DesiredCapabilities desiredCapabilities = getDesiredCapabilities();
assertThat(vaadinElementById("userAgent").getText(),
- containsString(expectedUserAgent.get(desiredCapabilities)
- + desiredCapabilities.getVersion()));
+ containsString(getExpectedUserAgentString(desiredCapabilities)
+ + desiredCapabilities.getVersion()));
assertThat(vaadinElementById("touchDevice").getText(),
- is("Touch device? No"));
+ is("Touch device? No"));
+ }
+
+ private String getExpectedUserAgentString(DesiredCapabilities dCap) {
+ if (BrowserUtil.isIE(dCap)) {
+ if (!BrowserUtil.isIE(dCap, 11)) {
+ // IE8-10
+ return "MSIE ";
+ } else {
+ // IE11
+ return "Trident/7.0; rv:";
+ }
+ } else if (BrowserUtil.isFirefox(dCap)) {
+ return "Firefox/";
+ } else if (BrowserUtil.isChrome(dCap)) {
+ return "Chrome/";
+ } else if (BrowserUtil.isPhantomJS(dCap)) {
+ return "PhantomJS/";
+ }
+ throw new UnsupportedOperationException(
+ "Test is being run on unknown browser.");
}
}