summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-09-07 17:39:56 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-09-24 20:53:06 +0300
commitb288329da7c17b2ebf16069621d5fddd9cb5fcc1 (patch)
tree20a15b9c1c0c070bdbcd70579fa6bc3e87444c9f
parent8d4edda40179dee1769de19adaefb3a5521a77ac (diff)
downloadvaadin-framework-b288329da7c17b2ebf16069621d5fddd9cb5fcc1.tar.gz
vaadin-framework-b288329da7c17b2ebf16069621d5fddd9cb5fcc1.zip
WebBrowser.isWindowsPhone() is added (#14425).
Change-Id: Ia279c4da78ca04e0d3727b605e2ce68b99e8cd65
-rw-r--r--client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java10
-rw-r--r--server/src/com/vaadin/server/WebBrowser.java11
-rw-r--r--shared/src/com/vaadin/shared/VBrowserDetails.java12
3 files changed, 32 insertions, 1 deletions
diff --git a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
index e38054e3e4..dd892b19ec 100644
--- a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
+++ b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
@@ -2,6 +2,8 @@ package com.vaadin.client;
import junit.framework.TestCase;
+import org.junit.Assert;
+
import com.vaadin.shared.VBrowserDetails;
public class TestVBrowserDetailsUserAgentParser extends TestCase {
@@ -404,7 +406,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
assertIE(bd);
assertBrowserMajorVersion(bd, 11);
assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
+ assertWindows(bd, true);
}
/*
@@ -538,11 +540,17 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
}
private void assertWindows(VBrowserDetails browserDetails) {
+ assertWindows(browserDetails, false);
+ }
+
+ private void assertWindows(VBrowserDetails browserDetails,
+ boolean isWindowsPhone) {
assertFalse(browserDetails.isLinux());
assertTrue(browserDetails.isWindows());
assertFalse(browserDetails.isMacOSX());
assertFalse(browserDetails.isIOS());
assertFalse(browserDetails.isAndroid());
+ Assert.assertEquals(isWindowsPhone, browserDetails.isWindowsPhone());
}
private void assertLinux(VBrowserDetails browserDetails) {
diff --git a/server/src/com/vaadin/server/WebBrowser.java b/server/src/com/vaadin/server/WebBrowser.java
index af20bcbb8f..5ec4e6b19c 100644
--- a/server/src/com/vaadin/server/WebBrowser.java
+++ b/server/src/com/vaadin/server/WebBrowser.java
@@ -259,6 +259,17 @@ public class WebBrowser implements Serializable {
}
/**
+ * Tests whether the user is using Windows Phone.
+ *
+ * @return true if the user is using Windows Phone, false if the user is not
+ * using Windows Phone or if no information on the browser is
+ * present
+ */
+ public boolean isWindowsPhone() {
+ return browserDetails.isWindowsPhone();
+ }
+
+ /**
* Tests if the browser is run on Android.
*
* @return true if run on Android false if the user is not using Android or
diff --git a/shared/src/com/vaadin/shared/VBrowserDetails.java b/shared/src/com/vaadin/shared/VBrowserDetails.java
index 81a39cdedc..3c89bdb6bb 100644
--- a/shared/src/com/vaadin/shared/VBrowserDetails.java
+++ b/shared/src/com/vaadin/shared/VBrowserDetails.java
@@ -42,6 +42,8 @@ public class VBrowserDetails implements Serializable {
private boolean isOpera = false;
private boolean isIE = false;
+ private boolean isWindowsPhone;
+
private OperatingSystem os = OperatingSystem.UNKNOWN;
public enum OperatingSystem {
@@ -162,6 +164,7 @@ public class VBrowserDetails implements Serializable {
// Operating system
if (userAgent.contains("windows ")) {
os = OperatingSystem.WINDOWS;
+ isWindowsPhone = userAgent.contains("windows phone");
} else if (userAgent.contains("linux")) {
if (userAgent.contains("android")) {
os = OperatingSystem.ANDROID;
@@ -425,6 +428,15 @@ public class VBrowserDetails implements Serializable {
}
/**
+ * Tests if the browser is run on Windows Phone.
+ *
+ * @return true if run on Windows Phone, false otherwise
+ */
+ public boolean isWindowsPhone() {
+ return isWindowsPhone;
+ }
+
+ /**
* Tests if the browser is run on Mac OSX.
*
* @return true if run on Mac OSX, false otherwise