Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8328379: Convert URLDragTest.html applet test to main #3002

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,34 +21,49 @@
* questions.
*/

/*
test
@bug 8031964
@summary Dragging images from the browser does not work
@author Petr Pchelko : area=dnd
@library ../../regtesthelpers
@build Sysout
@run applet/manual=yesno URLDragTest.html
*/

import test.java.awt.regtesthelpers.Sysout;

import java.applet.Applet;
import java.awt.*;
import java.awt.Color;
import java.awt.Frame;
import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetAdapter;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;

public class URLDragTest extends Applet {
/*
* @test
* @bug 8031964
* @summary Dragging images from the browser does not work.
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual URLDragTest
*/

public class URLDragTest {
private static final String INSTRUCTIONS =
"1) When the test starts, open any browser.\n" +
"2) Drag any image from the browser page onto the RED window.\n" +
"3) When the image is dropped you should see the list of available\n" +
" DataFlavors in the log area below the instruction window.\n" +
"4) If you see application/x-java-url and text/uri-list flavors in\n" +
" the logs then please press PASS, else FAIL.\n";

public static void main(String[] args) throws Exception {
PassFailJFrame.builder()
.title("Test Instructions")
.instructions(INSTRUCTIONS)
.rows((int) INSTRUCTIONS.lines().count() + 2)
.columns(40)
.logArea(8)
.testUI(URLDragTest::createUI)
.build()
.awaitAndCheck();
}

@Override
public void init() {
setBackground(Color.red);
setDropTarget(new DropTarget(this,
private static Frame createUI() {
Frame frame = new Frame("Browser Image DnD Test");
frame.setBackground(Color.RED);
frame.setDropTarget(new DropTarget(frame,
DnDConstants.ACTION_COPY,
new DropTargetAdapter() {
@Override
Expand All @@ -67,22 +82,12 @@ public void drop(DropTargetDropEvent dtde) {
dtde.getCurrentDataFlavorsAsList()
.stream()
.map(DataFlavor::toString)
.forEach(Sysout::println);
.forEach(PassFailJFrame::log);
}
}));

String[] instructions = {
"1) Open the browser.",
"2) Drag any image from the browser page to the red square",
"3) When the image is dropped you should se the list of available DataFlavors",
"4) If you see application/x-java-url and text/uri-list flavors - test PASSED",
"5) Otherwise the test is FAILED"};
Sysout.createDialogWithInstructions(instructions);
}

@Override
public void start() {
setSize(200, 200);
setVisible(true);
frame.setSize(400, 200);
frame.setAlwaysOnTop(true);
return frame;
}
}
45 changes: 0 additions & 45 deletions test/jdk/java/awt/dnd/URLDragTest/URLDragTest.html

This file was deleted.