diff options
author | John Ahlroos <john@vaadin.com> | 2013-05-30 16:19:47 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-06-03 11:07:19 +0000 |
commit | 84bf5a77e678f6d8a73f71d42fea2300b4f174cc (patch) | |
tree | 2ed75e51eeea42700edccf2ba571fac7ab6c6a77 /uitest | |
parent | 03830aeb46d93d675fa01c35ce3700e30a4a9c7d (diff) | |
download | vaadin-framework-84bf5a77e678f6d8a73f71d42fea2300b4f174cc.tar.gz vaadin-framework-84bf5a77e678f6d8a73f71d42fea2300b4f174cc.zip |
Enabled drag & drop to Calendar #11048
Change-Id: I2dcc1f7159a6283cfbc0baafe6cba66530bf0a45
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.html | 59 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java | 123 |
2 files changed, 182 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.html new file mode 100644 index 0000000000..425f95c529 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.html @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:7171/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.calendar.CalendarDragAndDrop?restartApplication</td> + <td></td> +</tr> +<!--// Test drag and drop in month view--> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]/domChild[0]/domChild[0]</td> + <td>76,7</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[5]/domChild[0]/domChild[2]</td> + <td>54,9</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[5]/domChild[0]/domChild[1]</td> + <td>12:00 AM Event 10</td> +</tr> +<!--//Test drag and drop in week view--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]</td> + <td>7,85</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[11]/domChild[0]/domChild[0]</td> + <td>34,12</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[15]</td> + <td>75,9</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]</td> + <td>7:30 AM: Event 13</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java new file mode 100644 index 0000000000..7477fc84ce --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java @@ -0,0 +1,123 @@ +/* + * 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 java.util.GregorianCalendar; +import java.util.Locale; + +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +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.Table; +import com.vaadin.ui.Table.TableDragMode; +import com.vaadin.ui.Table.TableTransferable; +import com.vaadin.ui.components.calendar.CalendarTargetDetails; +import com.vaadin.ui.components.calendar.event.BasicEvent; + +public class CalendarDragAndDrop extends AbstractTestUI { + + private Calendar calendar; + + private Table table; + + private class TestDropHandler implements DropHandler { + + @Override + public void drop(DragAndDropEvent event) { + CalendarTargetDetails details = (CalendarTargetDetails) event + .getTargetDetails(); + + TableTransferable transferable = (TableTransferable) event + .getTransferable(); + + calendar.addEvent(new BasicEvent(transferable.getItemId() + .toString(), "This event was dragged here", details + .getDropTime())); + + table.removeItem(transferable.getItemId()); + } + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + } + + @Override + protected void setup(VaadinRequest request) { + setSizeFull(); + getContent().setSizeFull(); + getLayout().setSizeFull(); + + HorizontalLayout root = new HorizontalLayout(); + root.setSizeFull(); + addComponent(root); + + Locale locale = new Locale("en", "US"); + GregorianCalendar cal = new GregorianCalendar(locale); + cal.set(2013, 0, 1); + + calendar = new Calendar(); + calendar.setId("Calendar"); + calendar.setLocale(locale); + calendar.setDropHandler(new TestDropHandler()); + calendar.setSizeFull(); + root.addComponent(calendar); + + calendar.setStartDate(cal.getTime()); + cal.add(java.util.Calendar.MONTH, 1); + calendar.setEndDate(cal.getTime()); + + table = new Table(); + table.setSizeFull(); + table.setDragMode(TableDragMode.ROW); + table.addGeneratedColumn("COLUMN", new Table.ColumnGenerator() { + + @Override + public Object generateCell(Table source, Object itemId, + Object columnId) { + return itemId; + } + }); + + for (int eventNum = 1; eventNum < 50; eventNum++) { + table.addItem("Event " + eventNum); + } + + root.addComponent(table); + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + return 11048; + } + +} |