Skip to content

Commit

Permalink
Fixed timing issues in CalendarNavigationIT
Browse files Browse the repository at this point in the history
Change-Id: I1ef654ed93765839cf6df47220685f832230cd58
  • Loading branch information
alvarezguille committed Oct 20, 2015
1 parent f944282 commit 2959c55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.vaadin.testUI;

import java.util.Locale;
import static java.util.Calendar.DAY_OF_MONTH;

import javax.servlet.annotation.WebServlet;

Expand All @@ -10,7 +10,6 @@
import com.vaadin.tests.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Calendar;
import com.vaadin.ui.HorizontalLayout;

public class CalendarUI extends AbstractTestUI {

Expand All @@ -21,43 +20,24 @@ public static class Servlet extends VaadinServlet {

@Override
protected void setup(VaadinRequest request) {
setLocale(new Locale("en", "US"));
final Calendar calendar = new Calendar();
calendar.setWidth("100%");

Button monthView = new Button("Month view");
monthView.setId("month-view");
monthView.addClickListener(new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event) {
java.util.Calendar juCalendar = java.util.Calendar
java.util.Calendar javaCalendar = java.util.Calendar
.getInstance();
juCalendar.set(java.util.Calendar.DAY_OF_MONTH, 1);
calendar.setStartDate(juCalendar.getTime());
juCalendar.set(java.util.Calendar.DAY_OF_MONTH, juCalendar
.getActualMaximum(java.util.Calendar.DAY_OF_MONTH));
calendar.setEndDate(juCalendar.getTime());
javaCalendar.set(DAY_OF_MONTH, 1);
calendar.setStartDate(javaCalendar.getTime());
javaCalendar.set(DAY_OF_MONTH,
javaCalendar.getActualMaximum(DAY_OF_MONTH));
calendar.setEndDate(javaCalendar.getTime());
}
});

Button weekView = new Button("Week view");
weekView.setId("week-view");
weekView.addClickListener(new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event) {
java.util.Calendar juCalendar = java.util.Calendar
.getInstance();
juCalendar.set(java.util.Calendar.DAY_OF_WEEK,
java.util.Calendar.MONDAY);
calendar.setStartDate(juCalendar.getTime());
juCalendar.set(java.util.Calendar.DAY_OF_WEEK,
java.util.Calendar.SUNDAY);
System.out.println(juCalendar.getTime());
calendar.setEndDate(juCalendar.getTime());
}
});
HorizontalLayout buttonLayout = new HorizontalLayout(monthView,
weekView);

addComponents(buttonLayout, calendar);
addComponents(monthView, calendar);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ public void calendarNavigation_backAndForwardInWeekView_navigationWorks() {
String originalFirstDay = calendarElement.getDayHeaders().get(0)
.getText();

calendarElement.next();

calendarElement.back();
calendarElement.waitForVaadin();
assertNotEquals(originalFirstDay, calendarElement.getDayHeaders()
.get(0).getText());

calendarElement.back();
calendarElement.next();
calendarElement.waitForVaadin();

assertEquals(originalFirstDay, calendarElement.getDayHeaders().get(0)
.getText());
Expand All @@ -47,6 +48,7 @@ public void calendarNavigation_backAndForwardInWeekView_navigationWorks() {
@Test(expected = IllegalStateException.class)
public void calendarNavigation_navigationInMonthView_exceptionThrown() {
$(ButtonElement.class).get(0).click();
calendarElement.waitForVaadin();

assertTrue(calendarElement.hasMonthView());

Expand Down

0 comments on commit 2959c55

Please sign in to comment.