diff options
author | Artur Signell <artur.signell@itmill.com> | 2012-01-27 14:08:53 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2012-01-27 14:08:53 +0000 |
commit | c2722bfeb2552158c9717110b35518a07e13ab85 (patch) | |
tree | b32ead2ac3b8ab68027e12e9bf97394cbad906f1 /tests/client-side | |
parent | b1ae3cd70e2ca4656bb28f77ca79fe0efd29dd67 (diff) | |
download | vaadin-framework-c2722bfeb2552158c9717110b35518a07e13ab85.tar.gz vaadin-framework-c2722bfeb2552158c9717110b35518a07e13ab85.zip |
#8311 Converted CRLF to LF in all source files
svn changeset:22797/svn branch:6.7
Diffstat (limited to 'tests/client-side')
2 files changed, 446 insertions, 446 deletions
diff --git a/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java b/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java index fe3b724aaf..3535d50529 100644 --- a/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java +++ b/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java @@ -1,77 +1,77 @@ -package com.vaadin.terminal.gwt.client;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-
-public class ApplicationConnectionTestURLGeneration {
-
- private static final String[] URIS = new String[] {
- "http://demo.vaadin.com/", //
- "https://demo.vaadin.com/",
- "http://demo.vaadin.com/foo",
- "http://demo.vaadin.com/foo?f",
- "http://demo.vaadin.com/foo?f=1",
- "http://demo.vaadin.com:1234/foo?a",
- "http://demo.vaadin.com:1234/foo#frag?fakeparam",
- // Jetspeed
- "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__",
- // Liferay generated url
- "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1",
-
- };
- private static final String[] URIS_WITH_ABCD_PARAM = new String[] {
- "http://demo.vaadin.com/?a=b&c=d",
- "https://demo.vaadin.com/?a=b&c=d",
- "http://demo.vaadin.com/foo?a=b&c=d",
- "http://demo.vaadin.com/foo?f&a=b&c=d",
- "http://demo.vaadin.com/foo?f=1&a=b&c=d",
- "http://demo.vaadin.com:1234/foo?a&a=b&c=d",
- "http://demo.vaadin.com:1234/foo?a=b&c=d#frag?fakeparam",
- "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d",
- "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d",
-
- };
-
- private static final String[] URIS_WITH_ABCD_PARAM_AND_FRAGMENT = new String[] {
- "http://demo.vaadin.com/?a=b&c=d#fragment",
- "https://demo.vaadin.com/?a=b&c=d#fragment",
- "http://demo.vaadin.com/foo?a=b&c=d#fragment",
- "http://demo.vaadin.com/foo?f&a=b&c=d#fragment",
- "http://demo.vaadin.com/foo?f=1&a=b&c=d#fragment",
- "http://demo.vaadin.com:1234/foo?a&a=b&c=d#fragment",
- "",
- "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d#fragment",
- "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d#fragment",
-
- };
-
- @Test
- public void testParameterAdding() {
- for (int i = 0; i < URIS.length; i++) {
- // Adding nothing
- assertEquals(URIS[i],
- ApplicationConnection.addGetParameters(URIS[i], ""));
-
- // Adding a=b&c=d
- assertEquals(URIS_WITH_ABCD_PARAM[i],
- ApplicationConnection.addGetParameters(URIS[i], "a=b&c=d"));
-
- // Fragments
- if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) {
- assertEquals(
- URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i],
- ApplicationConnection.addGetParameters(URIS[i]
- + "#fragment", "a=b&c=d"));
-
- // Empty fragment
- assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].replace(
- "#fragment", "#"),
- ApplicationConnection.addGetParameters(URIS[i] + "#",
- "a=b&c=d"));
- }
- }
- }
-}
+package com.vaadin.terminal.gwt.client; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.vaadin.terminal.gwt.client.ApplicationConnection; + +public class ApplicationConnectionTestURLGeneration { + + private static final String[] URIS = new String[] { + "http://demo.vaadin.com/", // + "https://demo.vaadin.com/", + "http://demo.vaadin.com/foo", + "http://demo.vaadin.com/foo?f", + "http://demo.vaadin.com/foo?f=1", + "http://demo.vaadin.com:1234/foo?a", + "http://demo.vaadin.com:1234/foo#frag?fakeparam", + // Jetspeed + "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__", + // Liferay generated url + "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1", + + }; + private static final String[] URIS_WITH_ABCD_PARAM = new String[] { + "http://demo.vaadin.com/?a=b&c=d", + "https://demo.vaadin.com/?a=b&c=d", + "http://demo.vaadin.com/foo?a=b&c=d", + "http://demo.vaadin.com/foo?f&a=b&c=d", + "http://demo.vaadin.com/foo?f=1&a=b&c=d", + "http://demo.vaadin.com:1234/foo?a&a=b&c=d", + "http://demo.vaadin.com:1234/foo?a=b&c=d#frag?fakeparam", + "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d", + "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d", + + }; + + private static final String[] URIS_WITH_ABCD_PARAM_AND_FRAGMENT = new String[] { + "http://demo.vaadin.com/?a=b&c=d#fragment", + "https://demo.vaadin.com/?a=b&c=d#fragment", + "http://demo.vaadin.com/foo?a=b&c=d#fragment", + "http://demo.vaadin.com/foo?f&a=b&c=d#fragment", + "http://demo.vaadin.com/foo?f=1&a=b&c=d#fragment", + "http://demo.vaadin.com:1234/foo?a&a=b&c=d#fragment", + "", + "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d#fragment", + "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d#fragment", + + }; + + @Test + public void testParameterAdding() { + for (int i = 0; i < URIS.length; i++) { + // Adding nothing + assertEquals(URIS[i], + ApplicationConnection.addGetParameters(URIS[i], "")); + + // Adding a=b&c=d + assertEquals(URIS_WITH_ABCD_PARAM[i], + ApplicationConnection.addGetParameters(URIS[i], "a=b&c=d")); + + // Fragments + if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) { + assertEquals( + URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i], + ApplicationConnection.addGetParameters(URIS[i] + + "#fragment", "a=b&c=d")); + + // Empty fragment + assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].replace( + "#fragment", "#"), + ApplicationConnection.addGetParameters(URIS[i] + "#", + "a=b&c=d")); + } + } + } +} diff --git a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java index 183a4d0fe3..f661b6cf15 100644 --- a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java +++ b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java @@ -1,369 +1,369 @@ -package com.vaadin.terminal.gwt.client;
-
-import junit.framework.TestCase;
-
-import com.vaadin.terminal.gwt.client.VBrowserDetails;
-
-public class TestVBrowserDetailsUserAgentParser extends TestCase {
-
- private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6";
- private static final String FIREFOX30_LINUX = "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.0.12) Gecko/2009070811 Ubuntu/9.04 (jaunty) Firefox/3.0.12";
- private static final String FIREFOX35_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729) FirePHP/0.4";
- private static final String FIREFOX36_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)";
- private static final String FIREFOX36B_MAC = "UAString mozilla/5.0 (macintosh; u; intel mac os x 10.6; en-us; rv:1.9.2) gecko/20100115 firefox/3.6";
- private static final String FIREFOX_30B5_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5";
- private static final String FIREFOX_40B7_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7";
- private static final String FIREFOX_40B11_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b11) Gecko/20100101 Firefox/4.0b11";
- private static final String KONQUEROR_LINUX = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Exabot-Thumbnails)";
-
- private static final String IE6_WINDOWS = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
- private static final String IE7_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
-
- private static final String IE8_WINDOWS = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
- private static final String IE8_IN_IE7_MODE_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
-
- private static final String IE9_BETA_IN_IE7_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
- private static final String IE9_BETA_IN_IE8_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
- private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
-
- // "Version/" was added in 10.00
- private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1";
- private static final String OPERA1010_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.10";
- private static final String OPERA1050_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.22 Version/10.50";
-
- private static final String CHROME3_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.198 Safari/532.0";
- private static final String CHROME4_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5";
-
- private static final String SAFARI3_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29";
- private static final String SAFARI4_MAC = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7";
-
- public void testSafari3() {
- VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS);
- assertWebKit(bd);
- assertSafari(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 2);
- assertEngineVersion(bd, 525.0f);
- assertWindows(bd);
- }
-
- public void testSafari4() {
- VBrowserDetails bd = new VBrowserDetails(SAFARI4_MAC);
- assertWebKit(bd);
- assertSafari(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 531f);
- assertMacOSX(bd);
- }
-
- public void testChrome3() {
- VBrowserDetails bd = new VBrowserDetails(CHROME3_MAC);
- assertWebKit(bd);
- assertChrome(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 532.0f);
- assertMacOSX(bd);
- }
-
- public void testChrome4() {
- VBrowserDetails bd = new VBrowserDetails(CHROME4_WINDOWS);
- assertWebKit(bd);
- assertChrome(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 532f);
- assertWindows(bd);
- }
-
- public void testFirefox3() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX30_WINDOWS);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 1.9f);
- assertWindows(bd);
-
- bd = new VBrowserDetails(FIREFOX30_LINUX);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 1.9f);
- assertLinux(bd);
- }
-
- public void testFirefox35() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX35_WINDOWS);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 5);
- assertEngineVersion(bd, 1.9f);
- assertWindows(bd);
- }
-
- public void testFirefox36() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX36_WINDOWS);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 6);
- assertEngineVersion(bd, 1.9f);
- assertWindows(bd);
- }
-
- public void testFirefox30b5() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX_30B5_MAC);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 1.9f);
- assertMacOSX(bd);
- }
-
- public void testFirefox40b11() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B11_WIN);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 2.0f);
- assertWindows(bd);
- }
-
- public void testFirefox40b7() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B7_WIN);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 2.0f);
- assertWindows(bd);
- }
-
- public void testKonquerorLinux() {
- // Just ensure detection does not crash
- VBrowserDetails bd = new VBrowserDetails(KONQUEROR_LINUX);
- assertLinux(bd);
- }
-
- public void testFirefox36b() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX36B_MAC);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 6);
- assertEngineVersion(bd, 1.9f);
- assertMacOSX(bd);
- }
-
- public void testOpera964() {
- VBrowserDetails bd = new VBrowserDetails(OPERA964_WINDOWS);
- assertPresto(bd);
- assertOpera(bd);
- assertBrowserMajorVersion(bd, 9);
- assertBrowserMinorVersion(bd, 64);
- assertWindows(bd);
- }
-
- public void testOpera1010() {
- VBrowserDetails bd = new VBrowserDetails(OPERA1010_WINDOWS);
- assertPresto(bd);
- assertOpera(bd);
- assertBrowserMajorVersion(bd, 10);
- assertBrowserMinorVersion(bd, 10);
- assertWindows(bd);
- }
-
- public void testOpera1050() {
- VBrowserDetails bd = new VBrowserDetails(OPERA1050_WINDOWS);
- assertPresto(bd);
- assertOpera(bd);
- assertBrowserMajorVersion(bd, 10);
- assertBrowserMinorVersion(bd, 50);
- assertWindows(bd);
- }
-
- public void testIE6() {
- VBrowserDetails bd = new VBrowserDetails(IE6_WINDOWS);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 6);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE7() {
- VBrowserDetails bd = new VBrowserDetails(IE7_WINDOWS);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 7);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE8() {
- VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 8);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE8CompatibilityMode() {
- VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS);
- bd.setIEMode(7);
-
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 7);
- assertBrowserMinorVersion(bd, 0);
-
- assertWindows(bd);
- }
-
- public void testIE9() {
- VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 9);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE9InIE7CompatibilityMode() {
- VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE7_MODE_WINDOWS_7);
- // bd.setIE8InCompatibilityMode();
-
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 7);
- assertBrowserMinorVersion(bd, 0);
-
- assertWindows(bd);
- }
-
- public void testIE9InIE8CompatibilityMode() {
- VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE8_MODE_WINDOWS_7);
- // bd.setIE8InCompatibilityMode();
-
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 8);
- assertBrowserMinorVersion(bd, 0);
-
- assertWindows(bd);
- }
-
- /*
- * Helper methods below
- */
-
- private void assertEngineVersion(VBrowserDetails browserDetails,
- float version) {
- assertEquals(version, browserDetails.getBrowserEngineVersion());
-
- }
-
- private void assertBrowserMajorVersion(VBrowserDetails browserDetails,
- int version) {
- assertEquals(version, browserDetails.getBrowserMajorVersion());
-
- }
-
- private void assertBrowserMinorVersion(VBrowserDetails browserDetails,
- int version) {
- assertEquals(version, browserDetails.getBrowserMinorVersion());
-
- }
-
- private void assertGecko(VBrowserDetails browserDetails) {
- // Engine
- assertTrue(browserDetails.isGecko());
- assertFalse(browserDetails.isWebKit());
- assertFalse(browserDetails.isPresto());
- }
-
- private void assertPresto(VBrowserDetails browserDetails) {
- // Engine
- assertFalse(browserDetails.isGecko());
- assertFalse(browserDetails.isWebKit());
- assertTrue(browserDetails.isPresto());
- }
-
- private void assertWebKit(VBrowserDetails browserDetails) {
- // Engine
- assertFalse(browserDetails.isGecko());
- assertTrue(browserDetails.isWebKit());
- assertFalse(browserDetails.isPresto());
- }
-
- private void assertFirefox(VBrowserDetails browserDetails) {
- // Browser
- assertTrue(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertChrome(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertTrue(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertIE(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertTrue(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertOpera(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertTrue(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertSafari(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertTrue(browserDetails.isSafari());
- }
-
- private void assertMacOSX(VBrowserDetails browserDetails) {
- assertFalse(browserDetails.isLinux());
- assertFalse(browserDetails.isWindows());
- assertTrue(browserDetails.isMacOSX());
- }
-
- private void assertWindows(VBrowserDetails browserDetails) {
- assertFalse(browserDetails.isLinux());
- assertTrue(browserDetails.isWindows());
- assertFalse(browserDetails.isMacOSX());
- }
-
- private void assertLinux(VBrowserDetails browserDetails) {
- assertTrue(browserDetails.isLinux());
- assertFalse(browserDetails.isWindows());
- assertFalse(browserDetails.isMacOSX());
- }
-
-}
+package com.vaadin.terminal.gwt.client; + +import junit.framework.TestCase; + +import com.vaadin.terminal.gwt.client.VBrowserDetails; + +public class TestVBrowserDetailsUserAgentParser extends TestCase { + + private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"; + private static final String FIREFOX30_LINUX = "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.0.12) Gecko/2009070811 Ubuntu/9.04 (jaunty) Firefox/3.0.12"; + private static final String FIREFOX35_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729) FirePHP/0.4"; + private static final String FIREFOX36_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)"; + private static final String FIREFOX36B_MAC = "UAString mozilla/5.0 (macintosh; u; intel mac os x 10.6; en-us; rv:1.9.2) gecko/20100115 firefox/3.6"; + private static final String FIREFOX_30B5_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5"; + private static final String FIREFOX_40B7_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7"; + private static final String FIREFOX_40B11_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b11) Gecko/20100101 Firefox/4.0b11"; + private static final String KONQUEROR_LINUX = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Exabot-Thumbnails)"; + + private static final String IE6_WINDOWS = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"; + private static final String IE7_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"; + + private static final String IE8_WINDOWS = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)"; + private static final String IE8_IN_IE7_MODE_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)"; + + private static final String IE9_BETA_IN_IE7_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"; + private static final String IE9_BETA_IN_IE8_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"; + private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; + + // "Version/" was added in 10.00 + private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1"; + private static final String OPERA1010_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.10"; + private static final String OPERA1050_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.22 Version/10.50"; + + private static final String CHROME3_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.198 Safari/532.0"; + private static final String CHROME4_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5"; + + private static final String SAFARI3_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29"; + private static final String SAFARI4_MAC = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7"; + + public void testSafari3() { + VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 2); + assertEngineVersion(bd, 525.0f); + assertWindows(bd); + } + + public void testSafari4() { + VBrowserDetails bd = new VBrowserDetails(SAFARI4_MAC); + assertWebKit(bd); + assertSafari(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 531f); + assertMacOSX(bd); + } + + public void testChrome3() { + VBrowserDetails bd = new VBrowserDetails(CHROME3_MAC); + assertWebKit(bd); + assertChrome(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 532.0f); + assertMacOSX(bd); + } + + public void testChrome4() { + VBrowserDetails bd = new VBrowserDetails(CHROME4_WINDOWS); + assertWebKit(bd); + assertChrome(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 532f); + assertWindows(bd); + } + + public void testFirefox3() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX30_WINDOWS); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 1.9f); + assertWindows(bd); + + bd = new VBrowserDetails(FIREFOX30_LINUX); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 1.9f); + assertLinux(bd); + } + + public void testFirefox35() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX35_WINDOWS); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 5); + assertEngineVersion(bd, 1.9f); + assertWindows(bd); + } + + public void testFirefox36() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX36_WINDOWS); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 6); + assertEngineVersion(bd, 1.9f); + assertWindows(bd); + } + + public void testFirefox30b5() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX_30B5_MAC); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 1.9f); + assertMacOSX(bd); + } + + public void testFirefox40b11() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B11_WIN); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 2.0f); + assertWindows(bd); + } + + public void testFirefox40b7() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B7_WIN); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 2.0f); + assertWindows(bd); + } + + public void testKonquerorLinux() { + // Just ensure detection does not crash + VBrowserDetails bd = new VBrowserDetails(KONQUEROR_LINUX); + assertLinux(bd); + } + + public void testFirefox36b() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX36B_MAC); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 3); + assertBrowserMinorVersion(bd, 6); + assertEngineVersion(bd, 1.9f); + assertMacOSX(bd); + } + + public void testOpera964() { + VBrowserDetails bd = new VBrowserDetails(OPERA964_WINDOWS); + assertPresto(bd); + assertOpera(bd); + assertBrowserMajorVersion(bd, 9); + assertBrowserMinorVersion(bd, 64); + assertWindows(bd); + } + + public void testOpera1010() { + VBrowserDetails bd = new VBrowserDetails(OPERA1010_WINDOWS); + assertPresto(bd); + assertOpera(bd); + assertBrowserMajorVersion(bd, 10); + assertBrowserMinorVersion(bd, 10); + assertWindows(bd); + } + + public void testOpera1050() { + VBrowserDetails bd = new VBrowserDetails(OPERA1050_WINDOWS); + assertPresto(bd); + assertOpera(bd); + assertBrowserMajorVersion(bd, 10); + assertBrowserMinorVersion(bd, 50); + assertWindows(bd); + } + + public void testIE6() { + VBrowserDetails bd = new VBrowserDetails(IE6_WINDOWS); + // assertTrident(bd); + assertIE(bd); + assertBrowserMajorVersion(bd, 6); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + + public void testIE7() { + VBrowserDetails bd = new VBrowserDetails(IE7_WINDOWS); + // assertTrident(bd); + assertIE(bd); + assertBrowserMajorVersion(bd, 7); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + + public void testIE8() { + VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS); + // assertTrident(bd); + assertIE(bd); + assertBrowserMajorVersion(bd, 8); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + + public void testIE8CompatibilityMode() { + VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS); + bd.setIEMode(7); + + // assertTrident(bd); + assertIE(bd); + assertBrowserMajorVersion(bd, 7); + assertBrowserMinorVersion(bd, 0); + + assertWindows(bd); + } + + public void testIE9() { + VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7); + // assertTrident(bd); + assertIE(bd); + assertBrowserMajorVersion(bd, 9); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + + public void testIE9InIE7CompatibilityMode() { + VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE7_MODE_WINDOWS_7); + // bd.setIE8InCompatibilityMode(); + + // assertTrident(bd); + assertIE(bd); + assertBrowserMajorVersion(bd, 7); + assertBrowserMinorVersion(bd, 0); + + assertWindows(bd); + } + + public void testIE9InIE8CompatibilityMode() { + VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE8_MODE_WINDOWS_7); + // bd.setIE8InCompatibilityMode(); + + // assertTrident(bd); + assertIE(bd); + assertBrowserMajorVersion(bd, 8); + assertBrowserMinorVersion(bd, 0); + + assertWindows(bd); + } + + /* + * Helper methods below + */ + + private void assertEngineVersion(VBrowserDetails browserDetails, + float version) { + assertEquals(version, browserDetails.getBrowserEngineVersion()); + + } + + private void assertBrowserMajorVersion(VBrowserDetails browserDetails, + int version) { + assertEquals(version, browserDetails.getBrowserMajorVersion()); + + } + + private void assertBrowserMinorVersion(VBrowserDetails browserDetails, + int version) { + assertEquals(version, browserDetails.getBrowserMinorVersion()); + + } + + private void assertGecko(VBrowserDetails browserDetails) { + // Engine + assertTrue(browserDetails.isGecko()); + assertFalse(browserDetails.isWebKit()); + assertFalse(browserDetails.isPresto()); + } + + private void assertPresto(VBrowserDetails browserDetails) { + // Engine + assertFalse(browserDetails.isGecko()); + assertFalse(browserDetails.isWebKit()); + assertTrue(browserDetails.isPresto()); + } + + private void assertWebKit(VBrowserDetails browserDetails) { + // Engine + assertFalse(browserDetails.isGecko()); + assertTrue(browserDetails.isWebKit()); + assertFalse(browserDetails.isPresto()); + } + + private void assertFirefox(VBrowserDetails browserDetails) { + // Browser + assertTrue(browserDetails.isFirefox()); + assertFalse(browserDetails.isChrome()); + assertFalse(browserDetails.isIE()); + assertFalse(browserDetails.isOpera()); + assertFalse(browserDetails.isSafari()); + } + + private void assertChrome(VBrowserDetails browserDetails) { + // Browser + assertFalse(browserDetails.isFirefox()); + assertTrue(browserDetails.isChrome()); + assertFalse(browserDetails.isIE()); + assertFalse(browserDetails.isOpera()); + assertFalse(browserDetails.isSafari()); + } + + private void assertIE(VBrowserDetails browserDetails) { + // Browser + assertFalse(browserDetails.isFirefox()); + assertFalse(browserDetails.isChrome()); + assertTrue(browserDetails.isIE()); + assertFalse(browserDetails.isOpera()); + assertFalse(browserDetails.isSafari()); + } + + private void assertOpera(VBrowserDetails browserDetails) { + // Browser + assertFalse(browserDetails.isFirefox()); + assertFalse(browserDetails.isChrome()); + assertFalse(browserDetails.isIE()); + assertTrue(browserDetails.isOpera()); + assertFalse(browserDetails.isSafari()); + } + + private void assertSafari(VBrowserDetails browserDetails) { + // Browser + assertFalse(browserDetails.isFirefox()); + assertFalse(browserDetails.isChrome()); + assertFalse(browserDetails.isIE()); + assertFalse(browserDetails.isOpera()); + assertTrue(browserDetails.isSafari()); + } + + private void assertMacOSX(VBrowserDetails browserDetails) { + assertFalse(browserDetails.isLinux()); + assertFalse(browserDetails.isWindows()); + assertTrue(browserDetails.isMacOSX()); + } + + private void assertWindows(VBrowserDetails browserDetails) { + assertFalse(browserDetails.isLinux()); + assertTrue(browserDetails.isWindows()); + assertFalse(browserDetails.isMacOSX()); + } + + private void assertLinux(VBrowserDetails browserDetails) { + assertTrue(browserDetails.isLinux()); + assertFalse(browserDetails.isWindows()); + assertFalse(browserDetails.isMacOSX()); + } + +} |