8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation. Oracle designates this
10 * particular file as subject to the "Classpath" exception as provided
11 * by Oracle in the LICENSE file that accompanied this code.
12 *
13 * This code is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * version 2 for more details (a copy is included in the LICENSE file that
17 * accompanied this code).
18 *
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27
28 import com.sun.glass.ui.monocle.TestLog;
29 import test.robot.com.sun.glass.ui.monocle.TestApplication;
30 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevice;
31 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevices;
32 import javafx.scene.Node;
33 import javafx.scene.input.ClipboardContent;
34 import javafx.scene.input.Dragboard;
35 import javafx.scene.input.InputEvent;
36 import javafx.scene.input.TransferMode;
37 import javafx.scene.shape.Rectangle;
38 import org.junit.Test;
39 import org.junit.runners.Parameterized;
40
41 import java.util.Collection;
42 import test.com.sun.glass.ui.monocle.TestRunnable;
43
44 public class DragAndDropTest extends ParameterizedTestBase {
45
46 public DragAndDropTest(TestTouchDevice device) {
47 super(device);
48 }
49
50
51 @Parameterized.Parameters
52 public static Collection<Object[]> data() {
53 return TestTouchDevices.getTouchDeviceParameters(1);
54 }
55
56 @Test
57 public void testDragOneNodeToAnother() throws Exception {
58 TestRunnable.invokeAndWait(() -> {
59 Node n1 = new Rectangle(10, 10, 10, 10);
60 Node n2 = new Rectangle(210, 10, 10, 10);
61 TestApplication.getRootGroup().getChildren().add(n1);
62 TestApplication.getRootGroup().getChildren().add(n2);
63 n1.setOnDragDetected((event) -> {
64 TestLog.log("Drag detected on n1");
65 Dragboard db = n1.startDragAndDrop(TransferMode.ANY);
66 ClipboardContent content = new ClipboardContent();
67 content.putString("");
68 db.setContent(content);
69 });
70 n2.setOnDragEntered((e) -> TestLog.log("Drag entered on n2"));
71 n2.setOnDragOver((event) -> {
72 TestLog.log("Drag over on n2");
73 event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
74 });
75 n2.setOnDragDropped((e) -> TestLog.log("Drag dropped on n2"));
76 n1.setOnDragDone((e) -> TestLog.log("Drag done on n1"));
77 n1.addEventHandler(InputEvent.ANY, (e) -> TestLog.log(e.toString()));
78 n2.addEventHandler(InputEvent.ANY, (e) -> TestLog.log(e.toString()));
79 });
80 try {
81 int p = device.addPoint(15, 15);
82 device.sync();
83 device.setPoint(p, 110, 15);
84 device.sync();
85 TestLog.waitForLogContaining("Drag detected on n1");
86 TestLog.clear();
87 device.setPoint(p, 215, 15);
88 device.sync();
89 TestLog.waitForLogContaining("Drag entered on n2");
90 TestLog.waitForLogContaining("Drag over on n2");
91 device.removePoint(p);
92 device.sync();
93 TestLog.waitForLogContaining("Drag dropped on n2");
94 TestLog.waitForLogContaining("Drag done on n1");
95 } finally {
96 TestRunnable.invokeAndWait(() -> TestApplication.getRootGroup().getChildren().clear());
97 }
98 }
99
100 }
|
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation. Oracle designates this
10 * particular file as subject to the "Classpath" exception as provided
11 * by Oracle in the LICENSE file that accompanied this code.
12 *
13 * This code is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * version 2 for more details (a copy is included in the LICENSE file that
17 * accompanied this code).
18 *
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27
28 import com.sun.glass.ui.monocle.TestLogShim;
29 import test.robot.com.sun.glass.ui.monocle.TestApplication;
30 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevice;
31 import test.robot.com.sun.glass.ui.monocle.input.devices.TestTouchDevices;
32 import javafx.scene.Node;
33 import javafx.scene.input.ClipboardContent;
34 import javafx.scene.input.Dragboard;
35 import javafx.scene.input.InputEvent;
36 import javafx.scene.input.TransferMode;
37 import javafx.scene.shape.Rectangle;
38 import org.junit.Test;
39 import org.junit.runners.Parameterized;
40
41 import java.util.Collection;
42 import test.com.sun.glass.ui.monocle.TestRunnable;
43
44 public class DragAndDropTest extends ParameterizedTestBase {
45
46 public DragAndDropTest(TestTouchDevice device) {
47 super(device);
48 }
49
50
51 @Parameterized.Parameters
52 public static Collection<Object[]> data() {
53 return TestTouchDevices.getTouchDeviceParameters(1);
54 }
55
56 @Test
57 public void testDragOneNodeToAnother() throws Exception {
58 TestRunnable.invokeAndWait(() -> {
59 Node n1 = new Rectangle(10, 10, 10, 10);
60 Node n2 = new Rectangle(210, 10, 10, 10);
61 TestApplication.getRootGroup().getChildren().add(n1);
62 TestApplication.getRootGroup().getChildren().add(n2);
63 n1.setOnDragDetected((event) -> {
64 TestLogShim.log("Drag detected on n1");
65 Dragboard db = n1.startDragAndDrop(TransferMode.ANY);
66 ClipboardContent content = new ClipboardContent();
67 content.putString("");
68 db.setContent(content);
69 });
70 n2.setOnDragEntered((e) -> TestLogShim.log("Drag entered on n2"));
71 n2.setOnDragOver((event) -> {
72 TestLogShim.log("Drag over on n2");
73 event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
74 });
75 n2.setOnDragDropped((e) -> TestLogShim.log("Drag dropped on n2"));
76 n1.setOnDragDone((e) -> TestLogShim.log("Drag done on n1"));
77 n1.addEventHandler(InputEvent.ANY, (e) -> TestLogShim.log(e.toString()));
78 n2.addEventHandler(InputEvent.ANY, (e) -> TestLogShim.log(e.toString()));
79 });
80 try {
81 int p = device.addPoint(15, 15);
82 device.sync();
83 device.setPoint(p, 110, 15);
84 device.sync();
85 TestLogShim.waitForLogContaining("Drag detected on n1");
86 TestLogShim.clear();
87 device.setPoint(p, 215, 15);
88 device.sync();
89 TestLogShim.waitForLogContaining("Drag entered on n2");
90 TestLogShim.waitForLogContaining("Drag over on n2");
91 device.removePoint(p);
92 device.sync();
93 TestLogShim.waitForLogContaining("Drag dropped on n2");
94 TestLogShim.waitForLogContaining("Drag done on n1");
95 } finally {
96 TestRunnable.invokeAndWait(() -> TestApplication.getRootGroup().getChildren().clear());
97 }
98 }
99
100 }
|