diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-11-09 23:15:28 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-02-04 10:21:22 +0000 |
commit | 49c150af5b7b3515e67c432362246ca7673e71fe (patch) | |
tree | 8eff70eb5b5dda52ffe6585a385587ccfea7e5e2 /uitest | |
parent | bd8931f0cd8ed05c9891f4f5eb3646bc3d4bc989 (diff) | |
download | vaadin-framework-49c150af5b7b3515e67c432362246ca7673e71fe.tar.gz vaadin-framework-49c150af5b7b3515e67c432362246ca7673e71fe.zip |
Check if event move is allowed also in month view. (#15174)
Change-Id: Ie4f01a74d3f2a8e388aed0c2d8b1a99384cb042f
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandler.java | 52 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java | 56 |
2 files changed, 108 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandler.java b/uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandler.java new file mode 100644 index 0000000000..c2dfdb26c1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandler.java @@ -0,0 +1,52 @@ +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; +import com.vaadin.ui.components.calendar.CalendarComponentEvents; +import com.vaadin.ui.components.calendar.event.BasicEvent; + +public class NullEventMoveHandler extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + Calendar calendar = getCalendar(); + + calendar.setHandler((CalendarComponentEvents.EventMoveHandler) null); + + addComponent(calendar); + } + + private Calendar getCalendar() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.US); + + try { + calendar.setStartDate(new SimpleDateFormat("yyyy-MM-dd") + .parse("2014-06-01")); + calendar.setEndDate(new SimpleDateFormat("yyyy-MM-dd") + .parse("2014-06-30")); + + BasicEvent event = new BasicEvent("foo", "bar", + new SimpleDateFormat("yyyy-MM-dd").parse("2014-06-01")); + + calendar.addEvent(event); + } catch (ParseException e) { + e.printStackTrace(); + } + return calendar; + } + + @Override + protected Integer getTicketNumber() { + return 15174; + } + + @Override + protected String getTestDescription() { + return "Events should not be movable when EventMoveHandler is null."; + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java b/uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java new file mode 100644 index 0000000000..c40cd9ce97 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java @@ -0,0 +1,56 @@ +package com.vaadin.tests.components.calendar; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.DndActionsTest; + +public class NullEventMoveHandlerTest extends DndActionsTest { + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + } + + @Test + public void eventIsNotMovableInMonthView() { + assertEventCannotBeMoved(); + } + + @Test + public void eventIsNotMovableInWeekView() { + openWeekView(); + assertEventCannotBeMoved(); + } + + private void assertEventCannotBeMoved() { + int originalPosition = getEventXPosition(); + + moveEventToNextDay(); + + assertThat("Event position changed.", getEventXPosition(), + is(originalPosition)); + } + + private void openWeekView() { + getDriver().findElement(By.className("v-calendar-week-number")).click(); + } + + private void moveEventToNextDay() { + WebElement event = getEvent(); + dragAndDrop(event, event.getSize().getWidth() + 5, 0); + } + + private int getEventXPosition() { + return getEvent().getLocation().getX(); + } + + private WebElement getEvent() { + return getDriver().findElement(By.className("v-calendar-event")); + } +}
\ No newline at end of file |