Skip to content

Commit 654da49

Browse files
committed
Add clean DnD Test
1 parent 5b97d0a commit 654da49

33 files changed

+320
-1128
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

features/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>features</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

tests/org.eclipse.ui.tests.dnd/.classpath

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
4-
<attributes>
5-
<attribute name="module" value="true"/>
6-
</attributes>
7-
</classpathentry>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
84
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
95
<classpathentry kind="src" path="src">
106
<attributes>

tests/org.eclipse.ui.tests.dnd/.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@
2020
<arguments>
2121
</arguments>
2222
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
2328
</buildSpec>
2429
<natures>
2530
<nature>org.eclipse.pde.PluginNature</nature>
2631
<nature>org.eclipse.jdt.core.javanature</nature>
32+
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
2733
</natures>
2834
</projectDescription>

tests/org.eclipse.ui.tests.dnd/META-INF/MANIFEST.MF

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,8 @@ Bundle-ManifestVersion: 2
33
Bundle-Name: Dnd
44
Bundle-SymbolicName: org.eclipse.ui.tests.dnd
55
Bundle-Version: 1.0.0.qualifier
6-
Require-Bundle: org.eclipse.swt,
7-
org.eclipse.jface,
8-
org.junit;bundle-version="4.13.2",
9-
org.eclipse.ui;bundle-version="3.207.300",
10-
org.eclipse.ui.tests;bundle-version="3.15.2100",
11-
org.eclipse.ui.workbench.texteditor;bundle-version="3.19.300",
12-
org.eclipse.core.runtime;bundle-version="3.33.100",
13-
org.eclipse.core.resources;bundle-version="3.22.200",
14-
org.eclipse.ui.tests.harness;bundle-version="1.10.600",
15-
junit-jupiter-api;bundle-version="5.12.2",
16-
junit-platform-suite-api;bundle-version="1.12.2"
6+
Require-Bundle: junit-jupiter-api;bundle-version="5.13.4",
7+
org.eclipse.jface;bundle-version="3.38.0",
8+
org.eclipse.e4.ui.workbench.addons.swt;bundle-version="1.5.800"
179
Automatic-Module-Name: org.eclipse.ui.tests.dnd
1810
Bundle-RequiredExecutionEnvironment: JavaSE-21
19-
Import-Package: org.eclipse.e4.ui.model.application.ui.basic,
20-
org.eclipse.ui.part,
21-
org.junit.jupiter.params;version="[5.12.0,6.0.0)",
22-
org.junit.jupiter.params.provider;version="[5.12.0,6.0.0)",
23-
org.junit.platform.engine.support.descriptor;version="[1.12.0,2.0.0)"
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
1-
###############################################################################
2-
# Copyright (c) 2025 Ali Muhsin KÖKSAL and others.
3-
#
4-
# This program and the accompanying materials
5-
# are made available under the terms of the Eclipse Public License 2.0
6-
# which accompanies this distribution, and is available at
7-
# https://www.eclipse.org/legal/epl-2.0/
8-
#
9-
# SPDX-License-Identifier: EPL-2.0
10-
###############################################################################
11-
121
source.. = src/
132
output.. = bin/
143
bin.includes = META-INF/,\
15-
.,\
16-
test.xml
17-
18-
19-
# Maven properties, see https://github.com/eclipse/tycho/wiki/Tycho-Pomless
20-
pom.model.property.testClass = org.eclipse.ui.tests.dnd.DragTestSuite
21-
pom.model.property.defaultSigning-excludeInnerJars = true
4+
.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.eclipse.ui.tests.dnd;
2+
3+
import org.eclipse.swt.widgets.List;
4+
import org.eclipse.swt.widgets.Table;
5+
import org.eclipse.swt.widgets.TableItem;
6+
import org.eclipse.swt.widgets.Tree;
7+
import org.eclipse.swt.widgets.TreeItem;
8+
import org.eclipse.swt.widgets.Widget;
9+
10+
public class DataTypeValidator {
11+
12+
public boolean isValidDrop(Widget target, Object data) {
13+
if (target == null || data == null) {
14+
System.out.println("Invalid drop: target or data is null");
15+
return false;
16+
}
17+
18+
if (target instanceof List) {
19+
boolean valid = data instanceof String;
20+
if (!valid) System.out.println("Invalid drop: List can only accept String data");
21+
return valid;
22+
} else if (target instanceof Tree) {
23+
boolean valid = data instanceof String || data instanceof TreeItem;
24+
if (!valid) System.out.println("Invalid drop: Tree can only accept String or TreeItem data");
25+
return valid;
26+
} else if (target instanceof Table) {
27+
boolean valid = data instanceof TableItem;
28+
if (!valid) System.out.println("Invalid drop: Table can only accept TableItem data");
29+
return valid;
30+
}
31+
32+
System.out.println("Invalid drop: Unsupported widget type " + target.getClass().getSimpleName());
33+
return false;
34+
}
35+
}

tests/org.eclipse.ui.tests.dnd/src/org/eclipse/ui/tests/dnd/DetachedDropTarget.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/org.eclipse.ui.tests.dnd/src/org/eclipse/ui/tests/dnd/DetachedWindowDragTest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.eclipse.ui.tests.dnd;
2+
3+
import org.eclipse.swt.dnd.DragSourceEvent;
4+
import org.eclipse.swt.widgets.Widget;
5+
import java.util.Arrays;
6+
7+
public class DnDEventFactory {
8+
9+
public DragSourceEvent createDragStartEvent(Widget source, Object... items) {
10+
if (source == null) {
11+
throw new IllegalArgumentException("Source widget cannot be null");
12+
}
13+
14+
DragSourceEvent event = new DragSourceEvent(null);
15+
event.widget = source;
16+
event.data = items != null ? items : new Object[0];
17+
event.detail = 0;
18+
19+
System.out.println("DragStartEvent created for source: " + source
20+
+ " with items: " + Arrays.toString((Object[]) event.data));
21+
22+
return event;
23+
}
24+
25+
public DragSourceEvent createDragSetDataEvent(Widget source, Object data, int operation) {
26+
if (source == null) throw new IllegalArgumentException("Source widget cannot be null");
27+
DragSourceEvent event = new DragSourceEvent(null);
28+
event.widget = source;
29+
event.data = data;
30+
event.detail = operation;
31+
32+
System.out.println("DragSetDataEvent created for source: " + source
33+
+ ", data: " + data + ", operation: " + operation);
34+
return event;
35+
}
36+
37+
public DragSourceEvent createDragFinishedEvent(Widget source, int operation) {
38+
if (source == null) throw new IllegalArgumentException("Source widget cannot be null");
39+
DragSourceEvent event = new DragSourceEvent(null);
40+
event.widget = source;
41+
event.detail = operation;
42+
43+
System.out.println("DragFinishedEvent created for source: " + source
44+
+ ", operation: " + operation);
45+
return event;
46+
}
47+
}

0 commit comments

Comments
 (0)