diff options
author | Leonid Rozenblyum <lrozenblyum@gmail.com> | 2015-11-04 12:18:46 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-11-11 10:09:45 +0000 |
commit | 91dcac26f683314d176a7763f53dad158c36e3df (patch) | |
tree | 7c95e3458ae0db6150b3af53bd8fd320f020a4e2 /server/tests | |
parent | d18d2fb7edd7901bab603bbce02d561808300ab3 (diff) | |
download | vaadin-framework-91dcac26f683314d176a7763f53dad158c36e3df.tar.gz vaadin-framework-91dcac26f683314d176a7763f53dad158c36e3df.zip |
Specify custom first day of week for Calendar #19227
Added possibility to provide first day of week independent of Locale.
(the Calendar code has been reformatted according to Eclipse 'Save
action'). Unit-tests added. UI test extended.
Change-Id: I3e3531228c139ce2014a1227e47c12e7896a6f87
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java index 95b4aecdb3..1592fb6c38 100644 --- a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java @@ -216,6 +216,60 @@ public class CalendarBasicsTest { calendar.isClientChangeAllowed()); } + // regression test to ensure old functionality is not broken + @Test + public void defaultFirstDayOfWeek() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.GERMAN); + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.MONDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test + public void customFirstDayOfWeek() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.GERMAN); + calendar.setFirstDayOfWeek(java.util.Calendar.SUNDAY); + + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.SUNDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test + public void customFirstDayOfWeekCanSetEvenBeforeLocale() { + Calendar calendar = new Calendar(); + calendar.setFirstDayOfWeek(java.util.Calendar.SUNDAY); + + calendar.setLocale(Locale.GERMAN); + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.SUNDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test + public void customFirstDayOfWeekSetNullRestoresDefault() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.GERMAN); + calendar.setFirstDayOfWeek(java.util.Calendar.SUNDAY); + calendar.setFirstDayOfWeek(null); + // simulating consequences of markAsDirty + calendar.beforeClientResponse(true); + assertEquals(java.util.Calendar.MONDAY, calendar.getInternalCalendar() + .getFirstDayOfWeek()); + } + + @Test(expected = IllegalArgumentException.class) + public void customFirstDayOfWeekValidation() { + Calendar calendar = new Calendar(); + int someWrongDayOfWeek = 10; + calendar.setFirstDayOfWeek(someWrongDayOfWeek); + } + private static class TestCalendar extends Calendar { TestCalendar(boolean connectorEnabled) { isConnectorEnabled = connectorEnabled; |