summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/dd/StartHtml5Drag.java
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com/vaadin/tests/dd/StartHtml5Drag.java')
-rw-r--r--uitest/src/com/vaadin/tests/dd/StartHtml5Drag.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/dd/StartHtml5Drag.java b/uitest/src/com/vaadin/tests/dd/StartHtml5Drag.java
new file mode 100644
index 0000000000..609b2fe4fc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/dd/StartHtml5Drag.java
@@ -0,0 +1,66 @@
+package com.vaadin.tests.dd;
+
+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.ClassResource;
+import com.vaadin.server.Sizeable;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.DragAndDropWrapper;
+import com.vaadin.ui.DragAndDropWrapper.DragStartMode;
+import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.Label;
+
+public class StartHtml5Drag extends TestBase {
+
+ @Override
+ protected void setup() {
+ DragAndDropWrapper dragStart = new DragAndDropWrapper(new Label(
+ "Drag me"));
+ dragStart.setDragStartMode(DragStartMode.HTML5);
+ dragStart.setHTML5DataFlavor("Text", "HTML5!");
+ addComponent(dragStart);
+
+ DragAndDropWrapper dropTarget = new DragAndDropWrapper(new Label(
+ "over here"));
+ dropTarget.setDropHandler(new DropHandler() {
+
+ @Override
+ public AcceptCriterion getAcceptCriterion() {
+ return AcceptAll.get();
+ }
+
+ @Override
+ public void drop(DragAndDropEvent event) {
+ getWindows()
+ .iterator()
+ .next()
+ .showNotification(
+ ((WrapperTransferable) event.getTransferable())
+ .getText());
+ }
+ });
+ addComponent(dropTarget);
+
+ Embedded iframe = new Embedded("", new ClassResource("html5drop.htm"));
+ iframe.setType(Embedded.TYPE_BROWSER);
+ iframe.setWidth(400, Sizeable.UNITS_PIXELS);
+ iframe.setHeight(400, Sizeable.UNITS_PIXELS);
+ addComponent(iframe);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Should work. Try to e.g. drag the 'Hello Vaadin user' "
+ + "label to native text editor application. In text "
+ + "editor app 'HTML5!' text should appear.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7833;
+ }
+}