Skip to content

Commit fbeac98

Browse files
author
Harshitha Onkar
committed
8328379: Convert URLDragTest.html applet test to main
Reviewed-by: abhiscxk, psadhukhan
1 parent 96530bc commit fbeac98

File tree

2 files changed

+40
-79
lines changed

2 files changed

+40
-79
lines changed
Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,34 +21,50 @@
2121
* questions.
2222
*/
2323

24-
/*
25-
test
26-
@bug 8031964
27-
@summary Dragging images from the browser does not work
28-
@author Petr Pchelko : area=dnd
29-
@library ../../regtesthelpers
30-
@build Sysout
31-
@run applet/manual=yesno URLDragTest.html
32-
*/
33-
34-
import test.java.awt.regtesthelpers.Sysout;
35-
36-
import java.applet.Applet;
37-
import java.awt.*;
24+
import java.awt.Color;
25+
import java.awt.Frame;
3826
import java.awt.datatransfer.DataFlavor;
3927
import java.awt.dnd.DnDConstants;
4028
import java.awt.dnd.DropTarget;
4129
import java.awt.dnd.DropTargetAdapter;
4230
import java.awt.dnd.DropTargetDragEvent;
4331
import java.awt.dnd.DropTargetDropEvent;
4432

45-
public class URLDragTest extends Applet {
33+
/*
34+
* @test
35+
* @bug 8031964
36+
* @summary Dragging images from the browser does not work.
37+
* @library /java/awt/regtesthelpers
38+
* @build PassFailJFrame
39+
* @run main/manual URLDragTest
40+
*/
41+
42+
public class URLDragTest {
43+
private static final String INSTRUCTIONS = """
44+
1) When the test starts, open any browser.
45+
2) Drag any image from the browser page onto the RED window.
46+
3) When the image is dropped you should see the list of available
47+
DataFlavors in the log area below the instruction window.
48+
4) If you see application/x-java-url and text/uri-list flavors in
49+
the logs then please press PASS, else FAIL.
50+
""";
4651

52+
public static void main(String[] args) throws Exception {
53+
PassFailJFrame.builder()
54+
.title("Test Instructions")
55+
.instructions(INSTRUCTIONS)
56+
.rows((int) INSTRUCTIONS.lines().count() + 2)
57+
.columns(40)
58+
.logArea(8)
59+
.testUI(URLDragTest::createUI)
60+
.build()
61+
.awaitAndCheck();
62+
}
4763

48-
@Override
49-
public void init() {
50-
setBackground(Color.red);
51-
setDropTarget(new DropTarget(this,
64+
private static Frame createUI() {
65+
Frame frame = new Frame("Browser Image DnD Test");
66+
frame.setBackground(Color.RED);
67+
frame.setDropTarget(new DropTarget(frame,
5268
DnDConstants.ACTION_COPY,
5369
new DropTargetAdapter() {
5470
@Override
@@ -67,22 +83,12 @@ public void drop(DropTargetDropEvent dtde) {
6783
dtde.getCurrentDataFlavorsAsList()
6884
.stream()
6985
.map(DataFlavor::toString)
70-
.forEach(Sysout::println);
86+
.forEach(PassFailJFrame::log);
7187
}
7288
}));
7389

74-
String[] instructions = {
75-
"1) Open the browser.",
76-
"2) Drag any image from the browser page to the red square",
77-
"3) When the image is dropped you should se the list of available DataFlavors",
78-
"4) If you see application/x-java-url and text/uri-list flavors - test PASSED",
79-
"5) Otherwise the test is FAILED"};
80-
Sysout.createDialogWithInstructions(instructions);
81-
}
82-
83-
@Override
84-
public void start() {
85-
setSize(200, 200);
86-
setVisible(true);
90+
frame.setSize(400, 200);
91+
frame.setAlwaysOnTop(true);
92+
return frame;
8793
}
8894
}

test/jdk/java/awt/dnd/URLDragTest/URLDragTest.html

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

0 commit comments

Comments
 (0)