blob: 3cf3161812679f759a35697de7a8ee2a1324d1d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class WebBrowserTimeZoneTest extends MultiBrowserTest {
@Test
public void testBrowserTimeZoneInfo() throws Exception {
openTestURL();
$(ButtonElement.class).first().click();
// 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, int expected) {
String actual = $(LabelElement.class).caption(caption).first()
.getText();
assertEquals(String.format("Unexpected text in label '%s',", caption),
"" + expected, actual);
}
}
|