diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-08-24 11:59:51 +0300 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-09-12 16:45:03 +0300 |
commit | 0999abd4b3cd0628ab7f22aca765b7e06ca6eb69 (patch) | |
tree | 6d2583cdb32892fd67c94829f74eb23c3ff72d25 /uitest | |
parent | 7b1cd46d2e3add7870ecdc0094e4cfb6fca3cc47 (diff) | |
download | vaadin-framework-0999abd4b3cd0628ab7f22aca765b7e06ca6eb69.tar.gz vaadin-framework-0999abd4b3cd0628ab7f22aca765b7e06ca6eb69.zip |
Update DateCellDayEvent size on updateSizes in Connector (#13233).
Change-Id: Ib3142cc62e95ce0e31bb8746eacd5ca4580c1865
Diffstat (limited to 'uitest')
4 files changed, 240 insertions, 20 deletions
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java new file mode 100644 index 0000000000..824ad0941f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java @@ -0,0 +1,105 @@ +/* + * 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.Date; +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.components.calendar.event.BasicEvent; +import com.vaadin.ui.components.calendar.event.BasicEventProvider; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider.EventSetChangeEvent; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider.EventSetChangeListener; + +/** + * Test UI to check ability to reschedule events unlimited times. + * + * @author Vaadin Ltd + */ +public class CalendarRescheduleEvent extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Calendar calendar = new Calendar("Test calendar"); + final java.util.Calendar cal = getAdjustedCalendar(1); + + Date from = cal.getTime(); + + cal.add(java.util.Calendar.HOUR, 1); + Date to = cal.getTime(); + + final BasicEvent basicEvent = new BasicEvent("event", "description", + from, to); + + HorizontalLayout info = new HorizontalLayout(); + info.setSpacing(true); + info.setMargin(true); + addComponent(info); + final Label startLbl = new Label(); + startLbl.addStyleName("start"); + info.addComponent(startLbl); + + final Label endLbl = new Label(); + endLbl.addStyleName("end"); + info.addComponent(endLbl); + + BasicEventProvider provider = new BasicEventProvider(); + provider.addEvent(basicEvent); + calendar.setEventProvider(provider); + provider.addEventSetChangeListener(new EventSetChangeListener() { + + @Override + public void eventSetChange(EventSetChangeEvent event) { + List<CalendarEvent> events = event.getProvider().getEvents( + new Date(0), new Date(Long.MAX_VALUE)); + CalendarEvent calEvent = events.get(0); + Date startEvent = calEvent.getStart(); + Date endEvent = calEvent.getEnd(); + + startLbl.setValue(String.valueOf(startEvent.getTime())); + endLbl.setValue(String.valueOf(endEvent.getTime())); + } + }); + + addComponent(calendar); + } + + @Override + protected String getTestDescription() { + return "It should be possible to reschedule events unlimited times."; + } + + @Override + protected Integer getTicketNumber() { + return 13233; + } + + private java.util.Calendar getAdjustedCalendar(int hour) { + final java.util.Calendar cal = java.util.Calendar.getInstance(); + + cal.set(java.util.Calendar.HOUR_OF_DAY, hour); + cal.set(java.util.Calendar.MINUTE, 0); + cal.set(java.util.Calendar.SECOND, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + return cal; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java new file mode 100644 index 0000000000..fb8cce7d53 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java @@ -0,0 +1,82 @@ +/* + * 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 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/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java index f664149cce..e3e5606089 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java @@ -24,15 +24,14 @@ 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.MultiBrowserTest; +import com.vaadin.tests.tb3.DndActionsTest; /** * * @author Vaadin Ltd */ -public class CalendarResizeOverlappingEventsTest extends MultiBrowserTest { +public class CalendarResizeOverlappingEventsTest extends DndActionsTest { private int noOverlapWidth; private int oneOverlapWidth; @@ -100,23 +99,7 @@ public class CalendarResizeOverlappingEventsTest extends MultiBrowserTest { } private void dragAndDrop(WebElement element, int yOffset) { - /* - * Selenium doesn't properly drag and drop items in IE8. It tries to - * start dragging an element from a position above the element itself. - */ - if (BrowserUtil.isIE8(getDesiredCapabilities())) { - Actions action = new Actions(getDriver()); - action.moveToElement(element); - action.moveByOffset(0, 1); - action.clickAndHold(); - action.moveByOffset(0, yOffset); - action.release(); - action.build().perform(); - } else { - Actions action = new Actions(getDriver()); - action.dragAndDropBy(element, 0, yOffset); - action.build().perform(); - } + dragAndDrop(element, 0, yOffset); } private void initParams() { diff --git a/uitest/src/com/vaadin/tests/tb3/DndActionsTest.java b/uitest/src/com/vaadin/tests/tb3/DndActionsTest.java new file mode 100644 index 0000000000..e755a00a0d --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/DndActionsTest.java @@ -0,0 +1,50 @@ +/* + * 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.tb3; + +import org.junit.Ignore; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +/** + * Base class for TestBench 3+ tests that use DnD. This class contains utility + * methods for DnD operations. + * + * @author Vaadin Ltd + */ +@Ignore +public abstract class DndActionsTest extends MultiBrowserTest { + + public void dragAndDrop(WebElement element, int xOffset, int yOffset) { + /* + * Selenium doesn't properly drag and drop items in IE8. It tries to + * start dragging an element from a position above the element itself. + */ + if (BrowserUtil.isIE8(getDesiredCapabilities())) { + Actions action = new Actions(getDriver()); + action.moveToElement(element); + action.moveByOffset(0, 1); + action.clickAndHold(); + action.moveByOffset(xOffset, yOffset); + action.release(); + action.build().perform(); + } else { + Actions action = new Actions(getDriver()); + action.dragAndDropBy(element, xOffset, yOffset); + action.build().perform(); + } + } +} |