summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-11-08 14:05:07 +0200
committerSauli Tähkäpää <sauli@vaadin.com>2014-11-17 15:47:51 +0200
commit4372afc9dfe85d77a756790e902df02b6837bac8 (patch)
tree65182bd2fbaf611353f2c370211fe64f8b8348e5 /uitest/src
parent1d0ff12e73ce94942b2251406035929419ffc004 (diff)
downloadvaadin-framework-4372afc9dfe85d77a756790e902df02b6837bac8.tar.gz
vaadin-framework-4372afc9dfe85d77a756790e902df02b6837bac8.zip
Unit test correction for moving any event in month calendar view(#12413)
Change-Id: I6e80c77f758a451ffb23c5487e7a25f3c0eed3c7
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java76
1 files changed, 57 insertions, 19 deletions
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java
index 2efcd1f88d..3248804eed 100644
--- a/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java
@@ -34,13 +34,20 @@ public class CalendarMonthViewDndEventTest extends DndActionsTest {
public void dragAndDropEventToNextDay() {
openTestURL();
- WebElement event = getDriver().findElement(
- By.className("v-calendar-event"));
+ WebElement calendar = findElement(By.className("v-calendar"));
+ int calendarRight = calendar.getLocation().getX()
+ + calendar.getSize().getWidth();
+
+ WebElement event = findElement(By.className("v-calendar-event"));
int x = event.getLocation().getX();
int width = event.getSize().getWidth();
- WebElement cell = getDriver().findElement(
- By.className("v-calendar-month-day"));
+ // does calendar have space on the right for one more event (i.e. day
+ // cell on the right).
+ boolean moveRight = event.getLocation().getX() + 2
+ * event.getSize().getWidth() <= calendarRight;
+
+ WebElement cell = getParentCell(event, "v-calendar-month-day");
int cellY = cell.getLocation().getY();
int cellHeight = cell.getSize().getHeight();
@@ -48,34 +55,65 @@ public class CalendarMonthViewDndEventTest extends DndActionsTest {
long origStart = getTime("start");
long origEnd = getTime("end");
- dragAndDrop(event, event.getSize().getWidth() + 5, 0);
+ if (moveRight) {
+ dragAndDrop(event, event.getSize().getWidth() + 5, 0);
+ } else {
+ dragAndDrop(event, -width / 2, 0);
+ }
- event = getDriver().findElement(By.className("v-calendar-event"));
+ event = findElement(By.className("v-calendar-event"));
int newX = event.getLocation().getX();
int newY = event.getLocation().getY();
Assert.assertTrue(
- "Moved event has wrong Y position (not the same row)",
- newY >= cellY && newY < cellY + cellHeight);
- Assert.assertTrue(
- "Moved event has wrong X position (not after original event)",
- newX >= x + width - 1);
+ "Moved event has wrong Y position (not the same row), new Y position="
+ + newY + ", cell Y position=" + cellY
+ + ", cell height=" + cellHeight, newY >= cellY
+ && newY < cellY + cellHeight);
+ if (moveRight) {
+ Assert.assertTrue(
+ "Moved event has wrong X position (not after original event)",
+ newX >= x + width - 1);
+ } else {
+ width = event.getSize().getWidth();
+ Assert.assertTrue(
+ "Moved event has wrong X position (not after original event)",
+ x >= newX + width - 1);
+ }
long start = getTime("start");
long end = getTime("end");
int day = 24 * 3600000;
- Assert.assertEquals(
- "Start date of moved event is not next day, same time",
- origStart + day, start);
- Assert.assertEquals(
- "End date of moved event is not next day, same time", origEnd
- + day, end);
+ if (moveRight) {
+ Assert.assertEquals(
+ "Start date of moved event is not next day, same time",
+ origStart + day, start);
+ Assert.assertEquals(
+ "End date of moved event is not next day, same time",
+ origEnd + day, end);
+ } else {
+ Assert.assertEquals(
+ "Start date of moved event is not previous day, same time",
+ origStart - day, start);
+ Assert.assertEquals(
+ "End date of moved event is not previous day, same time",
+ origEnd - day, end);
+
+ }
+ }
+
+ private WebElement getParentCell(WebElement element, String style) {
+ WebElement parent = element;
+ do {
+ // ".." xpath expression chooses the parent of the element
+ parent = parent.findElement(By.xpath(".."));
+ } while (!parent.getAttribute("class").contains(style));
+ return parent;
}
private long getTime(String style) {
- WebElement start = getDriver().findElement(By.className(style));
+ WebElement start = findElement(By.className(style));
return Long.parseLong(start.getText());
}
-
}