Ejemplo n.º 1
0
 @Test
 public void testToday() {
   calendar.openPopup();
   executeJSFromElement(today);
   CalendarDay selectedDay = calendar.openPopup().getDayPicker().getSelectedDay();
   assertEquals(selectedDay.getDayNumber().intValue(), todayMidday.getDayOfMonth());
 }
Ejemplo n.º 2
0
 @Test
 @Use(field = "todayControlMode", enumeration = true)
 public void testTodayControlMode() {
   calendarAttributes.set(CalendarAttributes.todayControlMode, todayControlMode.value);
   switch (todayControlMode) {
     case HIDDEN:
       assertNotVisible(calendar.openPopup().getFooterControls().getTodayButtonElement());
       break;
     case NULL:
     case SELECT:
       // set date to tomorrow
       calendar.setDateTime(todayMidday.plusDays(1));
       // set date with calendar's 'Today' button,
       // this will scroll and select todays day
       MetamerPage.waitRequest(calendar.openPopup().getFooterControls(), WaitRequestType.NONE)
           .todayDate();
       CalendarDay selectedDay = calendar.openPopup().getDayPicker().getSelectedDay();
       assertNotNull(selectedDay);
       assertTrue(selectedDay.is(DayType.todayDay));
       break;
     case SCROLL:
       calendar.setDateTime(todayMidday.plusMonths(1));
       // set date with calendar's 'Today' button,
       // this will only scroll to today but will not select it
       MetamerPage.waitRequest(calendar.openPopup().getFooterControls(), WaitRequestType.NONE)
           .todayDate();
       // no selected day should be in calendar
       assertNull(calendar.openPopup().getDayPicker().getSelectedDay());
       // but view of day picker should will change to current month
       assertEquals(
           calendar.openPopup().getHeaderControls().getYearAndMonth().getMonthOfYear(),
           todayMidday.getMonthOfYear());
       break;
   }
 }
Ejemplo n.º 3
0
 @Test
 public void testSetValue() {
   calendarAttributes.set(CalendarAttributes.showApplyButton, Boolean.FALSE);
   // setValue sets the date to 10 Oct of 2012
   MetamerPage.waitRequest(setValue, MetamerPage.WaitRequestType.XHR).click();
   CalendarDay selectedDay = calendar.openPopup().getDayPicker().getSelectedDay();
   assertNotNull(selectedDay);
   assertEquals(selectedDay.getDayNumber().intValue(), 10);
 }
Ejemplo n.º 4
0
  @Test
  public void testDayDisableFunction() {
    calendarAttributes.set(CalendarAttributes.dayDisableFunction, "disableTuesdays");
    int tuesdayDay = 3;
    // switch to next month to refresh classes
    calendar.openPopup().getHeaderControls().nextMonth();
    DayPicker proxiedDayPicker = calendar.openPopup().getProxiedDayPicker();
    CalendarDays tuesdays = proxiedDayPicker.getSpecificDays(tuesdayDay);
    tuesdays.removeSpecificDays(DayType.boundaryDay);
    for (CalendarDay tuesday : tuesdays) {
      assertFalse(tuesday.is(DayType.clickable), "All tuesdays should not be enabled.");
    }

    calendarAttributes.set(CalendarAttributes.dayDisableFunction, "null");

    tuesdays = proxiedDayPicker.getSpecificDays(tuesdayDay);
    tuesdays.removeSpecificDays(DayType.boundaryDay);

    for (CalendarDay tuesday : tuesdays) {
      assertTrue(tuesday.is(DayType.clickable), "All tuesdays should be enabled.");
    }
  }
Ejemplo n.º 5
0
  @Test
  public void testDayClassFunction() {
    int tuesdayDay = 3;
    calendarAttributes.set(CalendarAttributes.dayClassFunction, "yellowTuesdays");
    // switch to next month to refresh classes
    calendar.openPopup().getHeaderControls().nextMonth();
    DayPicker proxiedDayPicker = calendar.openPopup().getProxiedDayPicker();
    CalendarDays tuesdays = proxiedDayPicker.getSpecificDays(tuesdayDay);
    tuesdays.removeSpecificDays(DayType.boundaryDay);

    for (CalendarDay tuesday : tuesdays) {
      assertTrue(tuesday.containsStyleClass("yellowDay"), "All tuesdays should be yellow.");
    }

    calendarAttributes.set(CalendarAttributes.dayClassFunction, "null");

    tuesdays = proxiedDayPicker.getSpecificDays(tuesdayDay);
    tuesdays.removeSpecificDays(DayType.boundaryDay);

    for (CalendarDay tuesday : tuesdays) {
      assertFalse(tuesday.containsStyleClass("yellowDay"), "All tuesdays should not be yellow.");
    }
  }