Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLeo Ufimtsev2017-07-06 15:37:15 +0000
committerLeo Ufimtsev2017-07-10 23:21:42 +0000
commit312536ccb36a859b8382faaab8a5ecca81484fab (patch)
tree12429c3776776cf76ad64488ac40452501dee8a1 /tests
parentd6da324571507c31acfc69e626eb3826c5f88ac0 (diff)
downloadeclipse.platform.swt-312536ccb36a859b8382faaab8a5ecca81484fab.tar.gz
eclipse.platform.swt-312536ccb36a859b8382faaab8a5ecca81484fab.tar.xz
eclipse.platform.swt-312536ccb36a859b8382faaab8a5ecca81484fab.zip
Bug 519328 - [All] Add "Bug Snippets" folder to org.eclipse.swt.testsI20170710-2000
project Adding an initial snippet for Bug 212416. Change-Id: Ia77ce9997d3c4075cd58606974029905ce70327e Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests/.classpath1
-rw-r--r--tests/org.eclipse.swt.tests/BugSnippets/Bug497705_BrowserDragDetect.java89
-rw-r--r--tests/org.eclipse.swt.tests/BugSnippets/BugTemplate.java29
3 files changed, 119 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests/.classpath b/tests/org.eclipse.swt.tests/.classpath
index da01b5cead..110579ab01 100644
--- a/tests/org.eclipse.swt.tests/.classpath
+++ b/tests/org.eclipse.swt.tests/.classpath
@@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="JUnit Tests"/>
<classpathentry kind="src" path="data"/>
+ <classpathentry kind="src" path="BugSnippets"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/tests/org.eclipse.swt.tests/BugSnippets/Bug497705_BrowserDragDetect.java b/tests/org.eclipse.swt.tests/BugSnippets/Bug497705_BrowserDragDetect.java
new file mode 100644
index 0000000000..1af84a4046
--- /dev/null
+++ b/tests/org.eclipse.swt.tests/BugSnippets/Bug497705_BrowserDragDetect.java
@@ -0,0 +1,89 @@
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetAdapter;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Title: Browser does not send DragDetect
+ * How to run: Run snippet. Try to drag text from the browser (left), onto Label (right)
+ * Expected results: "Drag started" should be printed in the console.
+ * Actual results: Nothing is printed in console. DragSource has no impact on browser.
+ * GTK version(s): all
+ *
+ * This snippet has been adopted from Snippet78
+ */
+public class Bug497705_BrowserDragDetect {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ final Browser b = new Browser (shell, SWT.BORDER);
+ b.setText ("TEXT");
+ final Label label2 = new Label (shell, SWT.BORDER);
+ setDrag (b); //doesn't seem to have an effect.
+ setDrop (label2);
+ shell.setSize (200, 200);
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+
+ public static void setDrag(final Browser browser) {
+
+ Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+
+ final DragSource source = new DragSource (browser, operations);
+ source.setTransfer(types);
+ source.addDragListener (new DragSourceListener () {
+ @Override
+ public void dragStart(DragSourceEvent event) {
+ event.doit = (browser.getText ().length () != 0);
+ System.out.println("Drag started"); //not ran.
+ }
+ @Override
+ public void dragSetData (DragSourceEvent event) {
+ event.data = browser.getText ();
+ }
+ @Override
+ public void dragFinished(DragSourceEvent event) {
+ if (event.detail == DND.DROP_MOVE)
+ browser.setText ("");
+ }
+ });
+ }
+
+ public static void setDrop (final Label label) {
+ Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ DropTarget target = new DropTarget(label, operations);
+ target.setTransfer(types);
+ target.addDropListener (new DropTargetAdapter() {
+ @Override
+ public void drop(DropTargetEvent event) {
+ if (event.data == null) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ label.setText ((String) event.data);
+ }
+ });
+ }
+}
diff --git a/tests/org.eclipse.swt.tests/BugSnippets/BugTemplate.java b/tests/org.eclipse.swt.tests/BugSnippets/BugTemplate.java
new file mode 100644
index 0000000000..7249499420
--- /dev/null
+++ b/tests/org.eclipse.swt.tests/BugSnippets/BugTemplate.java
@@ -0,0 +1,29 @@
+
+
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Description:
+ * Steps to reproduce:
+ * Expected results:
+ * Actual results:
+ */
+public class BugTemplate {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+
+
+
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}

Back to the top