diff options
author | Denis <denis@vaadin.com> | 2016-12-27 16:37:43 +0200 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2016-12-27 16:37:43 +0200 |
commit | c66e5959745b13a95239873059ccd92acc14144a (patch) | |
tree | 0f329ed1e4c9b66c5ca1b84c4ac29ab04df9ce6f /uitest/src/test | |
parent | 95626bc699d61e48669a7bc333907e64be883e5a (diff) | |
download | vaadin-framework-c66e5959745b13a95239873059ccd92acc14144a.tar.gz vaadin-framework-c66e5959745b13a95239873059ccd92acc14144a.zip |
Clean up calendar tests. (#8094)
Diffstat (limited to 'uitest/src/test')
19 files changed, 24 insertions, 1638 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java deleted file mode 100644 index 5cd234336c..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests if long event which began before the view period is shown (#15242) - */ -public class BeanItemContainerLongEventTest extends MultiBrowserTest { - - @Override - protected String getDeploymentPath() { - return "/run/BeanItemContainerTestUI?restartApplication"; - } - - @Override - protected void openTestURL(String... parameters) { - driver.get(getTestUrl()); - } - - @Test - public void testEventDisplayedInWeekView() { - openTestURL(); - WebElement target = driver - .findElements(By.className("v-calendar-week-number")).get(1); - target.click(); - target = driver.findElement(By.className("v-calendar-event")); - Assert.assertEquals("Wrong event name", "Long event", target.getText()); - } - - @Test - public void testEventDisplayedInDayView() { - openTestURL(); - WebElement target = driver - .findElements(By.className("v-calendar-day-number")).get(5); - target.click(); - target = driver.findElement(By.className("v-calendar-event")); - Assert.assertEquals("Wrong event name", "Long event", target.getText()); - } - -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java deleted file mode 100644 index 809bd316af..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.tests.tb3.PrivateTB3Configuration; - -/** - * Test that calendar action event source is the calendar, not a private nested - * class in it. - * - * The related code is not browser dependent so only running on a single - * browser. - * - * @author Vaadin Ltd - */ -public class CalendarActionEventSourceTest extends PrivateTB3Configuration { - @Test - public void testActionEventSourceIsCalendarForEmptyCell() throws Exception { - openTestURL(); - - // perform action on empty cell - WebElement element = getDriver() - .findElement(By.className("v-calendar-spacer")); - performAction(element); - - checkEventSourceIsCalendar(); - } - - @Test - public void testActionEventSourceIsCalendarForEvent() throws Exception { - openTestURL(); - - // perform action on calendar event - WebElement element = getDriver() - .findElement(By.className("v-calendar-event")); - performAction(element); - - checkEventSourceIsCalendar(); - } - - private void performAction(WebElement element) { - // right click - new Actions(getDriver()).contextClick(element).perform(); - WebElement menuItem = getDriver() - .findElement(By.className("gwt-MenuItem")); - menuItem.click(); - } - - private void checkEventSourceIsCalendar() { - String calendarObject = getDriver().findElement(By.id("calendarlabel")) - .getText(); - String actionSourceObject = getDriver() - .findElement(By.id("senderlabel")).getText(); - Assert.assertEquals( - "Calendar action event source must be the calendar itself", - calendarObject, actionSourceObject); - } - - @Override - protected Class<?> getUIClass() { - return CalendarActionEventSource.class; - } - -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java deleted file mode 100644 index e901d531b3..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import static org.hamcrest.MatcherAssert.assertThat; - -import java.io.IOException; -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests: Vaadin Calendar: Navigation to invisible days of week (#12243) - * - * @author Vaadin Ltd - */ -public class CalendarBackwardForwardTest extends MultiBrowserTest { - - @Test - public void testCalendar() throws InterruptedException, IOException { - openTestURL(); - - openWeekView(); - openDayView(); - clickCalendarNext(); - - WebElement headerDayElement = getDriver() - .findElement(By.className("v-calendar-header-day")); - - assertThat("This day should be Monday 9/9/13", - headerDayElement.getText().equals("Monday 9/9/13")); - - for (int i = 0; i < 6; i++) { - clickCalendarBack(); - } - - headerDayElement = getDriver() - .findElement(By.className("v-calendar-header-day")); - - assertThat("This day should be Friday 8/30/13", - headerDayElement.getText().equals("Friday 8/30/13")); - } - - private void openWeekView() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-week-number")); - - for (WebElement webElement : elements) { - if (webElement.getText().equals("36")) { - webElement.click(); - break; - } - } - } - - private void openDayView() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-header-day")); - - for (WebElement webElement : elements) { - if (webElement.getText().contains("Friday 9/6/13")) { - webElement.click(); - break; - } - } - } - - private void clickCalendarNext() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-next")); - - elements.get(0).click(); - } - - private void clickCalendarBack() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-back")); - - elements.get(0).click(); - } - -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarDisabledTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarDisabledTest.java deleted file mode 100644 index dc1be07676..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarDisabledTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.vaadin.tests.components.calendar; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import com.vaadin.testbench.customelements.CalendarElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class CalendarDisabledTest extends MultiBrowserTest { - - @Override - protected Class<?> getUIClass() { - return CalendarReadOnly.class; - } - - @Override - public void setup() throws Exception { - super.setup(); - - openTestURL("restartApplication&disabled"); - } - - private CalendarElement getCalendar() { - return $(CalendarElement.class).first(); - } - - @Test - public void weekViewCannotBeOpenedFromMonthView() { - tryOpenWeekView(); - assertCalendarInMonthView(); - } - - @Test - public void dayViewCannotBeOpenedFromMonthView() { - tryOpenDayView(); - assertCalendarInMonthView(); - } - - private void tryOpenDayView() { - getCalendar().getDayNumbers().get(0).click(); - } - - private void tryOpenWeekView() { - getCalendar().getWeekNumbers().get(0).click(); - } - - private void assertCalendarInMonthView() { - assertTrue("Calendar wasn't in month view.", - getCalendar().hasMonthView()); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java deleted file mode 100644 index b51a75c027..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.customelements.CalendarElement; -import com.vaadin.testbench.elements.CheckBoxElement; -import com.vaadin.testbench.elements.NativeSelectElement; -import com.vaadin.tests.tb3.SingleBrowserTest; - -public class CalendarHtmlInEventsTest extends SingleBrowserTest { - - private NativeSelectElement periodSelect; - private CheckBoxElement htmlAllowed; - private CalendarElement calendar; - - @Override - public void setup() throws Exception { - super.setup(); - openTestURL(); - periodSelect = $(NativeSelectElement.class).first(); - htmlAllowed = $(CheckBoxElement.class).first(); - calendar = $(CalendarElement.class).first(); - } - - @Test - public void monthViewEventCaptions() { - Assert.assertEquals(getMonthEvent(0).getText(), - "12:00 AM <b>Hello</b> <u>world</u>!"); - - // Switch to HTML mode - click(htmlAllowed); - Assert.assertEquals("1. HTML in event caption: true", getLogRow(0)); - - Assert.assertEquals(getMonthEvent(0).getText(), - "12:00 AM Hello world!"); - } - - @Test - public void weekViewEventCaptions() { - periodSelect.selectByText("Week"); - Assert.assertEquals("4:00 AM\n<b>Hello</b> <u>world</u>!", - getWeekEvent(1).getText()); - - // Switch to HTML mode - click(htmlAllowed); - Assert.assertEquals("1. HTML in event caption: true", getLogRow(0)); - - Assert.assertEquals("4:00 AM\nHello world!", getWeekEvent(1).getText()); - } - - @Test - public void dayViewEventCaptions() { - periodSelect.selectByText("Day"); - Assert.assertEquals("3:00 AM\n<b>Hello</b> <u>world</u>!", - getWeekEvent(0).getText()); - - // Switch to HTML mode - click(htmlAllowed); - Assert.assertEquals("1. HTML in event caption: true", getLogRow(0)); - Assert.assertEquals("3:00 AM\nHello world!", getWeekEvent(0).getText()); - } - - private WebElement getMonthEvent(int dayInCalendar) { - return getMonthDay(dayInCalendar) - .findElement(By.className("v-calendar-event")); - } - - private WebElement getWeekEvent(int dayInCalendar) { - return getWeekDay(dayInCalendar) - .findElement(By.className("v-calendar-event")); - } - - private WebElement getMonthDay(int i) { - return calendar.findElements(By.className("v-calendar-month-day")) - .get(i); - } - - private WebElement getWeekDay(int i) { - return calendar.findElements(By.className("v-calendar-day-times")) - .get(i); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java deleted file mode 100644 index ee0cd0dce7..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.DndActionsTest; - -/** - * Test to check how DnD works for regular (not all day event) in calendar month - * view. - * - * @author Vaadin Ltd - */ -public class CalendarMonthViewDndEventTest extends DndActionsTest { - - @Test - public void dragAndDropEventToNextDay() { - openTestURL(); - - 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(); - - // 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(); - - long origStart = getTime("start"); - long origEnd = getTime("end"); - - if (moveRight) { - dragAndDrop(event, event.getSize().getWidth() + 5, 0); - } else { - dragAndDrop(event, -width / 2, 0); - } - - 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), 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; - 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 = findElement(By.className(style)); - return Long.parseLong(start.getText()); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java deleted file mode 100644 index 8c0e83084f..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.remote.DesiredCapabilities; - -import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.NotificationElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests opening and closing of calendar notifications. - * - * @since - * @author Vaadin Ltd - */ -public class CalendarNotificationsTest extends MultiBrowserTest { - - @Override - protected Class<?> getUIClass() { - return NotificationTestUI.class; - } - - @Override - protected DesiredCapabilities getDesiredCapabilities() { - DesiredCapabilities desiredCapabilities = new DesiredCapabilities( - super.getDesiredCapabilities()); - desiredCapabilities.setCapability("enablePersistentHover", false); - desiredCapabilities.setCapability("requireWindowFocus", true); - - return desiredCapabilities; - } - - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - // TODO: IE testing is pending on #14312. For now, IE testing is handled - // with a logger. - return getBrowsersExcludingIE(); - } - - @Test - public void notificationTest() throws Exception { - openTestURL(); - - WebElement day = findElements(By.className("v-calendar-day-number")) - .get(2); - // IE8 requires you to click on the text part to fire the event - new Actions(getDriver()).moveToElement(day, 83, 11).click().perform(); - - Assert.assertTrue("There should be a notification", - $(NotificationElement.class).exists()); - - // move the mouse around a bit - new Actions(getDriver()).moveByOffset(5, 5).moveByOffset(100, 100) - .perform(); - - // wait until the notification has animated out - sleep(1000); - - Assert.assertFalse("There should be no notification on the page", - $(NotificationElement.class).exists()); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java deleted file mode 100644 index 0640f19b0d..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.remote.DesiredCapabilities; - -import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.NotificationElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests opening and closing of calendar notifications. - * - * @since - * @author Vaadin Ltd - */ -public class CalendarNotificationsTestIE extends MultiBrowserTest { - - @Override - protected Class<?> getUIClass() { - return CalendarNotifications.class; - } - - @Override - protected boolean requireWindowFocusForIE() { - return true; - } - - @Override - protected boolean usePersistentHoverForIE() { - return false; - } - - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - return getIEBrowsersOnly(); - } - - @Test - public void notificationTest() throws Exception { - openTestURL(); - - WebElement day = findElements(By.className("v-calendar-day-number")) - .get(2); - // IE8 requires you to click on the text part to fire the event - new Actions(getDriver()).moveToElement(day, - day.getSize().getWidth() - 3, day.getSize().getHeight() / 2) - .click().perform(); - - // check that a notification was opened, this is done with a log instead - // of a screenshot or element presence check due to problems with IE - // webdriver - String text = findElement(By.id("Log")) - .findElement(By.className("v-label")).getText(); - Assert.assertTrue("Notification should've opened", - "1. Opening a notification".equals(text)); - - // move the mouse around a bit - new Actions(getDriver()).moveByOffset(5, 5).moveByOffset(100, 100) - .perform(); - - // wait until the notification has animated out - sleep(1000); - - Assert.assertFalse("There should be no notification on the page", - $(NotificationElement.class).exists()); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java deleted file mode 100644 index af49d39a00..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.DndActionsTest; - -/** - * Test to check ability to reschedule events unlimited times. - * - * @author Vaadin Ltd - */ -public class CalendarRescheduleEventTest extends DndActionsTest { - - @Test - public void rescheduleEventSeveralTimes() { - openTestURL(); - - // Reschedule event for the first time - int y = rescheduleEvent(20); - - WebElement startElement = getDriver() - .findElement(By.className("start")); - WebElement endElement = getDriver().findElement(By.className("end")); - - long start = Long.parseLong(startElement.getText()); - long end = Long.parseLong(endElement.getText()); - - long duration = end - start; - - // Reschedule event for the second time - int yNew = rescheduleEvent(20); - - startElement = getDriver().findElement(By.className("start")); - endElement = getDriver().findElement(By.className("end")); - - long newStart = Long.parseLong(startElement.getText()); - long newEnd = Long.parseLong(endElement.getText()); - - Assert.assertTrue( - "Second rescheduling did not change the event start time", - newStart > start); - Assert.assertEquals( - "Duration of the event after second rescheduling has been changed", - duration, newEnd - newStart); - Assert.assertTrue( - "Second rescheduling did not change the event Y coordinate", - yNew > y); - } - - /* - * DnD event by Y axis - */ - private int rescheduleEvent(int yOffset) { - WebElement eventCaption = getDriver() - .findElement(By.className("v-calendar-event-caption")); - - dragAndDrop(eventCaption, 0, yOffset); - - eventCaption = getDriver() - .findElement(By.className("v-calendar-event-caption")); - return eventCaption.getLocation().getY(); - } - -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java deleted file mode 100644 index 00e4039318..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import java.io.IOException; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.DndActionsTest; - -/** - * - * @author Vaadin Ltd - */ -public class CalendarResizeOverlappingEventsTest extends DndActionsTest { - - private int noOverlapWidth; - private int oneOverlapWidth; - private int twoOverlapsWidth; - - private WebElement firstEvent; - private WebElement secondEvent; - private WebElement thirdEvent; - - private WebElement firstEventBottomResize; - private WebElement secondEventBottomResize; - private WebElement thirdEventBottomResize; - - @Test - public void testCalendarResizeOverlappingEvents() - throws InterruptedException, IOException { - - openTestURL(); - initParams(); - doTest(); - } - - private void doTest() { - assertWidths(noOverlapWidth, noOverlapWidth, noOverlapWidth); - - dragAndDrop(firstEventBottomResize, 240); - assertWidths(oneOverlapWidth, oneOverlapWidth, oneOverlapWidth); - - dragAndDrop(secondEventBottomResize, 240); - assertWidths(twoOverlapsWidth, twoOverlapsWidth, twoOverlapsWidth); - - dragAndDrop(secondEventBottomResize, -240); - dragAndDrop(firstEventBottomResize, -240); - assertWidths(noOverlapWidth, noOverlapWidth, noOverlapWidth); - - } - - private void assertWidths(int firstEventExpectedWidth, - int secondEventExpectedWidth, int thirdEventExpectedWidth) { - int widthTolerance = 5; - String errorMessage = "Wrong event width after resizing, expected [%d] (+/-%d), obtained [%d]"; - - int actualWidth = firstEvent.getSize().getWidth(); - int expectedWidth = firstEventExpectedWidth; - Assert.assertTrue( - String.format(errorMessage, expectedWidth, widthTolerance, - actualWidth), - isAproximateWidth(actualWidth, expectedWidth, widthTolerance)); - - actualWidth = secondEvent.getSize().getWidth(); - expectedWidth = secondEventExpectedWidth; - Assert.assertTrue( - String.format(errorMessage, expectedWidth, widthTolerance, - actualWidth), - isAproximateWidth(actualWidth, expectedWidth, widthTolerance)); - - actualWidth = thirdEvent.getSize().getWidth(); - expectedWidth = thirdEventExpectedWidth; - Assert.assertTrue( - String.format(errorMessage, expectedWidth, widthTolerance, - actualWidth), - isAproximateWidth(actualWidth, expectedWidth, widthTolerance)); - } - - private boolean isAproximateWidth(int actualWidth, int expectedWidth, - int tolerance) { - return Math.abs(expectedWidth - actualWidth) <= tolerance; - } - - private void dragAndDrop(WebElement element, int yOffset) { - dragAndDrop(element, 0, yOffset); - } - - private void initParams() { - WebElement dateSlot = getDriver() - .findElement(By.className("v-datecellslot")); - int dateSlotWidth = dateSlot.getSize().getWidth(); - noOverlapWidth = dateSlotWidth; - oneOverlapWidth = dateSlotWidth / 2; - twoOverlapsWidth = dateSlotWidth / 3; - - Comparator<WebElement> startTimeComparator = new Comparator<WebElement>() { - @Override - public int compare(WebElement e1, WebElement e2) { - int e1Top = e1.getLocation().getY(); - int e2Top = e2.getLocation().getY(); - return e1Top - e2Top; - } - }; - - List<WebElement> eventElements = getDriver() - .findElements(By.className("v-calendar-event-content")); - Collections.sort(eventElements, startTimeComparator); - firstEvent = eventElements.get(0); - secondEvent = eventElements.get(1); - thirdEvent = eventElements.get(2); - - List<WebElement> resizeBottomElements = getDriver() - .findElements(By.className("v-calendar-event-resizebottom")); - Collections.sort(resizeBottomElements, startTimeComparator); - firstEventBottomResize = resizeBottomElements.get(0); - secondEventBottomResize = resizeBottomElements.get(1); - thirdEventBottomResize = resizeBottomElements.get(2); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest.java deleted file mode 100644 index b6f8be7368..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import java.io.IOException; -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests calendar via prepared screenshots 'Calendar event not shown correctly - * when partially out of view' (#7261) - */ -public class CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest - extends MultiBrowserTest { - - @Test - public void testCalendar() throws InterruptedException, IOException { - openTestURL(); - - openWeekView(); - compareScreen("weekview"); - - openDayView(); - compareScreen("dayview"); - } - - private void openWeekView() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-week-number")); - - for (WebElement webElement : elements) { - if (webElement.getText().equals("36")) { - webElement.click(); - break; - } - } - } - - private void openDayView() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-header-day")); - - for (WebElement webElement : elements) { - if (webElement.getText().contains("Thursday 9/5/13")) { - webElement.click(); - break; - } - } - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarVisibleHoursTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarVisibleHoursTest.java deleted file mode 100644 index 5033047bd0..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarVisibleHoursTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import java.io.IOException; -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests calendar via prepared screenshots calendar visible hours of day invalid - * shows invalid dates(week/day view) (#12521) - */ -public class CalendarVisibleHoursTest extends MultiBrowserTest { - - @Test - public void testCalendar() throws InterruptedException, IOException { - openTestURL(); - - openWeekView(); - compareScreen("weekview"); - - openDayView(); - - compareScreen("dayview"); - } - - private void openWeekView() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-week-number")); - - for (WebElement webElement : elements) { - if (webElement.getText().equals("36")) { - webElement.click(); - break; - } - } - } - - private void openDayView() { - List<WebElement> elements = getDriver() - .findElements(By.className("v-calendar-header-day")); - - for (WebElement webElement : elements) { - if (webElement.getText().contains("Thursday 9/5/13")) { - webElement.click(); - break; - } - } - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java deleted file mode 100644 index facf44775b..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.vaadin.tests.components.calendar; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class CalendarWeekSelectionTest extends MultiBrowserTest { - - @Test - public void correctYearIsSelected() { - openTestURL(); - - clickOnWeek("1"); - - assertThat(getFirstDayOfTheYear().getText(), is("Wednesday 1/1/14")); - } - - private WebElement getFirstDayOfTheYear() { - WebElement header = findElement(By.className("v-calendar-header-week")); - List<WebElement> headerElements = header.findElements(By.tagName("td")); - - // Wednesday is the first day of 2014. - return headerElements.get(4); - } - - private void clickOnWeek(String week) { - for (WebElement e : findElements( - By.className("v-calendar-week-number"))) { - if (e.getText().equals(week)) { - e.click(); - break; - } - } - } -}
\ No newline at end of file diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetailsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetailsTest.java deleted file mode 100644 index 3ac6a2b0c3..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetailsTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.By; -import com.vaadin.tests.components.table.DndTableTargetDetailsTest; - -/** - * Test for mouse details in CalendarTargetDetails class when DnD target is a - * calendar. - * - * @author Vaadin Ltd - */ -public class DndCalendarTargetDetailsTest extends DndTableTargetDetailsTest { - - @Override - protected WebElement getTarget() { - return findElement(By.className("v-datecellslot-even")); - } - -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java deleted file mode 100644 index 156100310c..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.vaadin.tests.components.calendar; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import org.junit.Assert; -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 eventIsClickableWhenNotMovableInMonthView() { - getEvent().click(); - Assert.assertEquals("1. Clicked on foo", getLogRow(0)); - } - - @Test - public void eventIsNotMovableInWeekView() { - openWeekView(); - assertEventCannotBeMoved(); - } - - @Test - public void eventIsClickableWhenNotMovableInWeekView() { - openWeekView(); - getEvent().findElement(By.className("v-calendar-event-caption")) - .click(); - Assert.assertEquals("1. Clicked on foo", getLogRow(0)); - } - - 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 diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCaseTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCaseTest.java deleted file mode 100644 index 84e5f452e4..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCaseTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.StaleElementReferenceException; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.parallel.BrowserUtil; -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests that calendar week and day views are correct when using - * setFirstVisibleHourOfDay() and the end event time is 00:00 of the following - * day - */ -public class SetFirstVisibleHourOfDaySpecialCaseTest extends MultiBrowserTest { - - @Override - protected boolean requireWindowFocusForIE() { - return true; - } - - @Test - public void testDayView() { - openTestURL(); - - // open day view - clickElement("v-calendar-day-number", "5"); - - // first of all check if event is present in calendar view - waitForElementPresent(By.className("v-calendar-event-content")); - - // check that event has correct height - WebElement event = getDriver() - .findElement(By.className("v-calendar-event-content")); - WebElement dateSlot = getDriver() - .findElement(By.className("v-datecellslot")); - - Assert.assertEquals( - "The height of shown part of calendar event should be equal to 16 datecell slots", - dateSlot.getSize().getHeight() * 16, - event.getSize().getHeight()); - } - - @Test - public void testWeekView() { - openTestURL(); - - // open week view - clickElement("v-calendar-week-number", "36"); - - // first of all check if event is present in calendar view - waitForElementPresent(By.className("v-calendar-event-content")); - - // check that event has correct height - WebElement event = getDriver() - .findElement(By.className("v-calendar-event-content")); - WebElement dateSlot = getDriver() - .findElement(By.className("v-datecellslot")); - - Assert.assertEquals( - "The height of shown part of calendar event should be equal to 16 datecell slots", - dateSlot.getSize().getHeight() * 16, - event.getSize().getHeight()); - } - - private void clickElement(String className, String text) { - List<WebElement> elements = findElements(By.className(className)); - - boolean found = false; - for (WebElement webElement : elements) { - if (webElement.getText().equals(text)) { - webElement.click(); - if (BrowserUtil.isIE8(getDesiredCapabilities())) { - try { - // sometimes the element only gets focus from click and - // we need to click the text, which is in the right edge - // of the element - testBenchElement(webElement) - .click(webElement.getSize().getWidth() - 5, 9); - } catch (StaleElementReferenceException e) { - // the first click succeeded after all - } - } - found = true; - break; - } - } - - if (!found) { - Assert.fail("Element " + className + " with text " + text - + " not found."); - } - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDayTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDayTest.java deleted file mode 100644 index 11464ac7bb..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDayTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.calendar; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Tests that calendar week and day views are correct when using - * setFirstVisibleHourOfDay() - */ -public class SetFirstVisibleHourOfDayTest extends MultiBrowserTest { - - @Override - protected boolean requireWindowFocusForIE() { - return true; - } - - @Test - public void testDayView() { - openTestURL(); - waitForElementPresent(By.className("v-calendar")); - - // open day view - clickElement("v-calendar-day-number", "5"); - - // first of all check if event is present in calendar view - waitForElementPresent(By.className("v-calendar-event-content")); - - WebElement event = getDriver() - .findElement(By.className("v-calendar-event-content")); - WebElement dateSlot = getDriver() - .findElement(By.className("v-datecellslot")); - - Assert.assertEquals( - "The height of shown part of calendar event should be equal to 12 datecell slots", - dateSlot.getSize().getHeight() * 12, - event.getSize().getHeight()); - } - - @Test - public void testWeekView() { - openTestURL(); - waitForElementPresent(By.className("v-calendar")); - - // open week view - clickElement("v-calendar-week-number", "36"); - - // first of all check if event is present in calendar view - waitForElementPresent(By.className("v-calendar-event-content")); - - WebElement event = getDriver() - .findElement(By.className("v-calendar-event-content")); - WebElement dateSlot = getDriver() - .findElement(By.className("v-datecellslot")); - - Assert.assertEquals( - "The height of shown part of calendar event should be equal to 12 datecell slots", - dateSlot.getSize().getHeight() * 12, - event.getSize().getHeight()); - } - - private void clickElement(String className, String text) { - List<WebElement> elements = findElements(By.className(className)); - - boolean found = false; - for (WebElement webElement : elements) { - if (webElement.getText().equals(text)) { - webElement.click(); - found = true; - break; - } - } - - if (!found) { - Assert.fail("Element " + className + " with text " + text - + " not found."); - } - } - -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarReadOnlyTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java index da8dec927b..8228419db1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarReadOnlyTest.java +++ b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java @@ -1,4 +1,4 @@ -package com.vaadin.tests.components.calendar; +package com.vaadin.tests.smoke; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; @@ -14,100 +14,66 @@ import com.vaadin.testbench.By; import com.vaadin.testbench.customelements.CalendarElement; import com.vaadin.tests.tb3.MultiBrowserTest; -public class CalendarReadOnlyTest extends MultiBrowserTest { +public class CalendarSmokeTest extends MultiBrowserTest { - @Override - public void setup() throws Exception { - super.setup(); + @Test + public void calendarSmokeTest() { + openTestURL(); - openTestURL("restartApplication&readonly"); + smokeTest(); } @Test - public void weekViewCanBeOpenedFromMonthView() { + public void readOnlyCalendarSmokeTest() { + openTestURL("restartApplication&readonly"); + + smokeTest(); + } + + private void smokeTest() { openWeekView(); assertTrue("Calendar wasn't in week view.", getCalendar().hasWeekView()); - } + reload(); - @Test - public void dayViewCanBeOpenedFromMonthView() { openDayView(); - assertTrue("Calendar wasn't in day view.", getCalendar().hasDayView()); - } + reload(); - @Test - public void dayViewCanBeOpenedFromWeekView() { openWeekView(); - getCalendar().getDayHeaders().get(0).click(); - assertTrue("Calendar wasn't in day view.", getCalendar().hasDayView()); - } + reload(); - @Test - public void weekViewCanBeBrowsedForwards() { openWeekView(); - String firstDayOfCurrentWeek = getVisibleFirstDay(); getCalendar().next(); - String firstDayOfNextWeek = getVisibleFirstDay(); - assertThat("Week didn't change.", firstDayOfCurrentWeek, is(not(firstDayOfNextWeek))); - } - - @Test - public void weekViewCanBeBrowsedBackwards() { - openWeekView(); - - String firstDayOfCurrentWeek = getVisibleFirstDay(); - getCalendar().back(); - - String firstDayOfPreviousWeek = getVisibleFirstDay(); - - assertThat("Week didn't change.", firstDayOfCurrentWeek, - is(not(firstDayOfPreviousWeek))); - } + reload(); - @Test - public void dayViewCanBeBrowsedForwards() { openDayView(); - String currentDay = getVisibleFirstDay(); getCalendar().next(); - String nextDay = getVisibleFirstDay(); - assertThat("Day didn't change.", currentDay, is(not(nextDay))); - } + reload(); - @Test - public void dayViewCanBeBrowsedBackwards() { openDayView(); - - String currentDay = getVisibleFirstDay(); + currentDay = getVisibleFirstDay(); getCalendar().back(); - String previousDay = getVisibleFirstDay(); - assertThat("Day didn't change.", currentDay, is(not(previousDay))); - } + reload(); - @Test - public void hiddenEventsCanBeExpanded() { WebElement dayWithEvents = getFirstDayWithEvents(); - assertThat("Incorrect event count.", getVisibleEvents(dayWithEvents).size(), is(2)); - toggleExpandEvents(dayWithEvents).click(); assertThat("Incorrect event count.", getVisibleEvents(dayWithEvents).size(), is(4)); - toggleExpandEvents(dayWithEvents).click(); assertThat("Incorrect event count.", getVisibleEvents(dayWithEvents).size(), is(2)); @@ -139,6 +105,10 @@ public class CalendarReadOnlyTest extends MultiBrowserTest { return null; } + private void reload() { + getDriver().navigate().refresh(); + } + private WebElement toggleExpandEvents(WebElement dayWithEvents) { return dayWithEvents .findElement(By.className("v-calendar-bottom-spacer")); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSortTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSortTest.java deleted file mode 100644 index 9519a68317..0000000000 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSortTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.v7.tests.components.calendar; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -/** - * Check how event sorting works in calendar month and week views. - * - * @author Vaadin Ltd - */ -public class CalendarEventsSortTest extends MultiBrowserTest { - - @Test - public void testByDuration() { - openTestURL(); - - checkSortByDuration(true); - } - - @Test - public void testByStartDate() { - openTestURL(); - - checkSortByStartDate(true); - } - - @Test - public void testByProvider() { - openTestURL(); - - List<WebElement> events = findElements( - By.className("v-calendar-event-month")); - checkProviderOrder(events); - } - - @Test - public void testWeekByDuration() { - openTestURL(); - - findElement(By.className("view")).click(); - - checkSortByDuration(false); - } - - @Test - public void testWeekByStartDate() { - openTestURL(); - - findElement(By.className("view")).click(); - - checkSortByStartDate(false); - } - - @Test - public void testWeekByProvider() { - openTestURL(); - - findElement(By.className("view")).click(); - - List<WebElement> events = findElements( - By.className("v-calendar-event-caption")); - checkProviderOrder(events); - } - - private void checkSortByStartDate(boolean month) { - sort("by-start-date", false); - - String style = month ? "v-calendar-event-month" - : "v-calendar-event-caption"; - List<WebElement> events = findElements(By.className(style)); - checkStartDateOrderDesc(events); - - sort("by-start-date", true); - - events = findElements(By.className(style)); - checkStartDateOrderAsc(events); - } - - private void sort(String style, boolean ascending) { - findElement(By.className(style)).click(); - - if (!isElementPresent( - By.cssSelector('.' + style + (ascending ? ".asc" : ".desc")))) { - findElement(By.className(style)).click(); - } - } - - private void checkSortByDuration(boolean month) { - sort("by-duration", false); - - String style = month ? "v-calendar-event-month" - : "v-calendar-event-caption"; - - List<WebElement> events = findElements(By.className(style)); - checkDurationOrderDesc(events); - - sort("by-duration", true); - events = findElements(By.className(style)); - checkDurationOrderAsc(events); - } - - private void checkDurationOrderDesc(List<WebElement> events) { - Assert.assertTrue( - "'Second' event should be the first when sorted by duration", - events.get(0).getText().endsWith("second")); - Assert.assertTrue( - "'Third' event should be the second when sorted by duration", - events.get(1).getText().endsWith("third")); - Assert.assertTrue( - "'First' event should be the third when sorted by duration", - events.get(2).getText().endsWith("first")); - } - - private void checkDurationOrderAsc(List<WebElement> events) { - Assert.assertTrue( - "'First' event should be the first when sorted by duration", - events.get(0).getText().endsWith("first")); - Assert.assertTrue( - "'Third' event should be the second when sorted by duration", - events.get(1).getText().endsWith("third")); - Assert.assertTrue( - "'Second' event should be the third when sorted by duration", - events.get(2).getText().endsWith("second")); - } - - private void checkStartDateOrderDesc(List<WebElement> events) { - Assert.assertTrue( - "'Third' event should be the first when sorted by start date", - events.get(0).getText().endsWith("third")); - Assert.assertTrue( - "'Second' event should be the second when sorted by start date", - events.get(1).getText().endsWith("second")); - Assert.assertTrue( - "'First' event should be the third when sorted by start date", - events.get(2).getText().endsWith("first")); - } - - private void checkStartDateOrderAsc(List<WebElement> events) { - Assert.assertTrue( - "'First' event should be the first when sorted by start date", - events.get(0).getText().endsWith("first")); - Assert.assertTrue( - "'Second' event should be the second when sorted by start date", - events.get(1).getText().endsWith("second")); - Assert.assertTrue( - "'Third' event should be the third when sorted by start date", - events.get(2).getText().endsWith("third")); - } - - private void checkProviderOrder(List<WebElement> events) { - Assert.assertTrue( - "'First' event should be the first when sorted by provider", - events.get(0).getText().endsWith("first")); - Assert.assertTrue( - "'Second' event should be the second when sorted by provider", - events.get(1).getText().endsWith("second")); - Assert.assertTrue( - "'Third' event should be the third when sorted by provider", - events.get(2).getText().endsWith("third")); - } - -} |