summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2011-12-20 10:11:58 +0000
committerArtur Signell <artur.signell@itmill.com>2011-12-20 10:11:58 +0000
commit4e9bd2a49142d3dd87f380b1f6e458734c566f7d (patch)
tree6a4023470921d839514f5fceb7ec10b4e42b04ca
parent83ae145f53fed1bd45250f69918454371f43c73a (diff)
downloadvaadin-framework-4e9bd2a49142d3dd87f380b1f6e458734c566f7d.tar.gz
vaadin-framework-4e9bd2a49142d3dd87f380b1f6e458734c566f7d.zip
#5655 Added getClientWidth() and getClientHeight() to WebBrowser and updated test
svn changeset:22453/svn branch:6.8
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java2
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java3
-rw-r--r--src/com/vaadin/terminal/gwt/server/WebBrowser.java38
-rw-r--r--tests/testbench/com/vaadin/tests/application/WebBrowserTest.html35
-rw-r--r--tests/testbench/com/vaadin/tests/application/WebBrowserTest.java13
5 files changed, 72 insertions, 19 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index 22f5cba1e6..acae039e8b 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -567,6 +567,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
browser.updateClientSideDetails(
getHTTPRequestParameter(request, "sw"),
getHTTPRequestParameter(request, "sh"),
+ getHTTPRequestParameter(request, "cw"),
+ getHTTPRequestParameter(request, "ch"),
getHTTPRequestParameter(request, "tzo"),
getHTTPRequestParameter(request, "rtzo"),
getHTTPRequestParameter(request, "dstd"),
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
index 17b92db617..3957c84a71 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
@@ -595,7 +595,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
request.getHeader("user-agent"));
if (request.getParameter("repaintAll") != null) {
browser.updateClientSideDetails(request.getParameter("sw"),
- request.getParameter("sh"), request.getParameter("tzo"),
+ request.getParameter("sh"), request.getParameter("cw"),
+ request.getParameter("ch"), request.getParameter("tzo"),
request.getParameter("rtzo"), request.getParameter("dstd"),
request.getParameter("dston"),
request.getParameter("curdate"),
diff --git a/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/src/com/vaadin/terminal/gwt/server/WebBrowser.java
index 9182ebdc03..cb83d93a72 100644
--- a/src/com/vaadin/terminal/gwt/server/WebBrowser.java
+++ b/src/com/vaadin/terminal/gwt/server/WebBrowser.java
@@ -22,6 +22,8 @@ public class WebBrowser implements Terminal {
private int screenHeight = 0;
private int screenWidth = 0;
+ private int clientHeight = 0;
+ private int clientWidth = 0;
private String browserApplication = null;
private Locale locale;
private String address;
@@ -63,6 +65,24 @@ public class WebBrowser implements Terminal {
}
/**
+ * Gets the height of the client (browser window)
+ *
+ * @return The height of the client or 0 if unknown.
+ */
+ public int getClientHeight() {
+ return clientHeight;
+ }
+
+ /**
+ * Gets the width of the client (browser window)
+ *
+ * @return The width of the client or 0 if unknown.
+ */
+ public int getClientWidth() {
+ return clientWidth;
+ }
+
+ /**
* Get the browser user-agent string.
*
* @return The raw browser userAgent string
@@ -312,6 +332,10 @@ public class WebBrowser implements Terminal {
* Screen width
* @param sh
* Screen height
+ * @param cw
+ * Client width
+ * @param ch
+ * Client height
* @param tzo
* TimeZone offset in minutes from GMT
* @param rtzo
@@ -324,9 +348,9 @@ public class WebBrowser implements Terminal {
* the current date in milliseconds since the epoch
* @param touchDevice
*/
- void updateClientSideDetails(String sw, String sh, String tzo, String rtzo,
- String dstSavings, String dstInEffect, String curDate,
- boolean touchDevice) {
+ void updateClientSideDetails(String sw, String sh, String cw, String ch,
+ String tzo, String rtzo, String dstSavings, String dstInEffect,
+ String curDate, boolean touchDevice) {
if (sw != null) {
try {
screenHeight = Integer.parseInt(sh);
@@ -335,6 +359,14 @@ public class WebBrowser implements Terminal {
screenHeight = screenWidth = 0;
}
}
+ if (cw != null) {
+ try {
+ clientHeight = Integer.parseInt(ch);
+ clientWidth = Integer.parseInt(cw);
+ } catch (final NumberFormatException e) {
+ clientHeight = clientWidth = 0;
+ }
+ }
if (tzo != null) {
try {
// browser->java conversion: min->ms, reverse sign
diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html
index 04bdec4d48..f4dd48f6d0 100644
--- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html
+++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html
@@ -12,32 +12,37 @@
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.WebBrowserTest?restartApplication</td>
- <td></td>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.WebBrowserTest?restartApplication</td>
+ <td></td>
</tr>
<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
</tr>
<!-- Raw offset -->
<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]</td>
- <td>7200000</td>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]</td>
+ <td>7200000</td>
</tr>
<!-- offset to Helsinki -->
<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VLabel[0]</td>
- <td>0</td>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VLabel[0]</td>
+ <td>0</td>
</tr>
<!-- in Helsinki? -->
<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VLabel[0]</td>
- <td>Yes</td>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VLabel[0]</td>
+ <td>Yes</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>browserinfo</td>
</tr>
</tbody></table>
</body>
diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
index 08c9061d45..33a70a942c 100644
--- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
+++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
@@ -35,6 +35,12 @@ public class WebBrowserTest extends TestBase {
final Label containsLabel = new Label("n/a");
containsLabel.setCaption("Browser could be in Helsinki");
+ final Label screenSizeLabel = new Label("n/a");
+ screenSizeLabel.setCaption("Screen size");
+
+ final Label browserSizeLabel = new Label("n/a");
+ browserSizeLabel.setCaption("Client (browser window) size");
+
final Button update = new Button("Get TimeZone from browser",
new Button.ClickListener() {
@@ -71,6 +77,11 @@ public class WebBrowserTest extends TestBase {
curDateLabel.setValue(getBrowser().getCurrentDate()
.toString());
+
+ screenSizeLabel.setValue(getBrowser().getScreenWidth()
+ + " x " + getBrowser().getScreenHeight());
+ browserSizeLabel.setValue(getBrowser().getClientWidth()
+ + " x " + getBrowser().getClientHeight());
}
});
@@ -82,6 +93,8 @@ public class WebBrowserTest extends TestBase {
addComponent(curDateLabel);
addComponent(diffLabel);
addComponent(containsLabel);
+ addComponent(screenSizeLabel);
+ addComponent(browserSizeLabel);
}