diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-10-04 00:03:38 +0300 |
---|---|---|
committer | Anna Koskinen <anna@vaadin.com> | 2014-11-03 13:16:47 +0200 |
commit | eb94e2a9be2d8ce34620fdedc90425e05785cdd8 (patch) | |
tree | f2c7714b1d541c7b490b83754f7be9c124bf18ee /uitest | |
parent | dda24122a7a0a0491fc5cac69792fe37a826803e (diff) | |
download | vaadin-framework-eb94e2a9be2d8ce34620fdedc90425e05785cdd8.tar.gz vaadin-framework-eb94e2a9be2d8ce34620fdedc90425e05785cdd8.zip |
Fix VCalendar to use correct year of week. (#14783)
Change-Id: Id55ad5ed620bd5c187b70ae2a2d0a4c4adea382a
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java | 39 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java | 41 |
2 files changed, 80 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java new file mode 100644 index 0000000000..c74f2a53e3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.calendar; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Locale; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Calendar; + +public class CalendarWeekSelection extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.US); + + try { + calendar.setStartDate(new SimpleDateFormat("yyyy-MM-dd") + .parse("2013-12-15")); + calendar.setEndDate(new SimpleDateFormat("yyyy-MM-dd") + .parse("2014-01-15")); + } catch (ParseException e) { + e.printStackTrace(); + } + + addComponent(calendar); + } + + @Override + protected Integer getTicketNumber() { + return 14783; + } + + @Override + protected String getTestDescription() { + return "December 2013 - January 2014. Clicking the week 1 " + + "should open the week view for the first week of 2014."; + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java new file mode 100644 index 0000000000..83f41994ae --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java @@ -0,0 +1,41 @@ +package com.vaadin.tests.components.calendar; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class CalendarWeekSelectionTest extends MultiBrowserTest { + + @Test + public void correctYearIsSelected() { + openTestURL(); + + clickOnWeek("1"); + + assertThat(getFirstDayOfTheYear().getText(), is("Wednesday 1/1/14")); + } + + private WebElement getFirstDayOfTheYear() { + WebElement header = findElement(By.className("v-calendar-header-week")); + List<WebElement> headerElements = header.findElements(By.tagName("td")); + + // Wednesday is the first day of 2014. + return headerElements.get(4); + } + + private void clickOnWeek(String week) { + for (WebElement e : findElements(By.className("v-calendar-week-number"))) { + if (e.getText().equals(week)) { + e.click(); + break; + } + } + } +}
\ No newline at end of file |