Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

WebBrowserTimeZoneTest.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.vaadin.tests.application;
  2. import static org.junit.Assert.assertEquals;
  3. import java.util.Date;
  4. import org.junit.Test;
  5. import org.openqa.selenium.JavascriptExecutor;
  6. import com.vaadin.testbench.elements.ButtonElement;
  7. import com.vaadin.testbench.elements.LabelElement;
  8. import com.vaadin.tests.tb3.MultiBrowserTest;
  9. public class WebBrowserTimeZoneTest extends MultiBrowserTest {
  10. @Test
  11. public void testBrowserTimeZoneInfo() throws Exception {
  12. openTestURL();
  13. $(ButtonElement.class).first().click();
  14. // Ask TimeZone from browser
  15. String tzOffset = ((JavascriptExecutor) getDriver())
  16. .executeScript("return new Date().getTimezoneOffset()")
  17. .toString();
  18. // Translate the same way as Vaadin should
  19. int offsetMillis = -Integer.parseInt(tzOffset) * 60 * 1000;
  20. // Check that server got the same value.
  21. assertLabelText("Browser offset", offsetMillis);
  22. }
  23. private void assertLabelText(String caption, int expected) {
  24. String actual = $(LabelElement.class).caption(caption).first()
  25. .getText();
  26. assertEquals(String.format("Unexpected text in label '%s',", caption),
  27. "" + expected, actual);
  28. }
  29. }