aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java b/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java
index bc74927ee1..3cf3161812 100644
--- a/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java
@@ -2,7 +2,10 @@ package com.vaadin.tests.application;
import static org.junit.Assert.assertEquals;
+import java.util.Date;
+
import org.junit.Test;
+import org.openqa.selenium.JavascriptExecutor;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.LabelElement;
@@ -13,15 +16,23 @@ public class WebBrowserTimeZoneTest extends MultiBrowserTest {
public void testBrowserTimeZoneInfo() throws Exception {
openTestURL();
$(ButtonElement.class).first().click();
- assertLabelText("Browser raw offset", "7200000");
- assertLabelText("Browser to Europe/Helsinki offset difference", "0");
- assertLabelText("Browser could be in Helsinki", "Yes");
+
+ // Ask TimeZone from browser
+ String tzOffset = ((JavascriptExecutor) getDriver())
+ .executeScript("return new Date().getTimezoneOffset()")
+ .toString();
+
+ // Translate the same way as Vaadin should
+ int offsetMillis = -Integer.parseInt(tzOffset) * 60 * 1000;
+
+ // Check that server got the same value.
+ assertLabelText("Browser offset", offsetMillis);
}
- private void assertLabelText(String caption, String expected) {
+ private void assertLabelText(String caption, int expected) {
String actual = $(LabelElement.class).caption(caption).first()
.getText();
assertEquals(String.format("Unexpected text in label '%s',", caption),
- expected, actual);
+ "" + expected, actual);
}
}