< prev index next >

test/jdk/java/awt/dnd/ImageTransferTest/ImageTransferTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2014, 2016, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2014, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,39 **** * or visit www.oracle.com if you need additional information or have any * questions. */ /* ! @test ! @key headful ! @bug 4397404 4720930 ! @summary tests that images of all supported native image formats are transfered properly ! @library ../../../../lib/testlibrary ! @library ../../regtesthelpers/process/ ! @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator ! @author gas@sparc.spb.su area=Clipboard ! @run main ImageTransferTest ! */ import test.java.awt.regtesthelpers.process.ProcessCommunicator; import test.java.awt.regtesthelpers.process.ProcessResults; import jdk.testlibrary.OSInfo; --- 20,39 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ /* ! * @test ! * @key headful ! * @bug 4397404 4720930 8197926 ! * @summary tests that images of all supported native image formats are transfered properly ! * @library ../../../../lib/testlibrary ! * @library ../../regtesthelpers/process/ ! * @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator ! * @author gas@sparc.spb.su area=Clipboard ! * @run main ImageTransferTest ! */ import test.java.awt.regtesthelpers.process.ProcessCommunicator; import test.java.awt.regtesthelpers.process.ProcessResults; import jdk.testlibrary.OSInfo;
*** 56,65 **** --- 56,67 ---- import java.util.stream.Stream; public class ImageTransferTest { public static void main(String[] arg) throws Exception { ImageDragSource ids = new ImageDragSource(); + try { + ids.frame.setUndecorated(true); ids.frame.setLocation(100, 100); ids.frame.setVisible(true); Util.sync(); String classpath = System.getProperty("java.class.path"); String[] args = new String[ids.formats.length + 4];
*** 99,108 **** --- 101,115 ---- "native formats are not transferred properly: " + failedFormats); } else { System.err.println("images in following " + "native formats are transferred properly: " + passedFormats); } + } finally { + if (ids.frame != null) { + ids.frame.dispose(); + } + } } } class Util {
*** 259,268 **** --- 266,276 ---- } class ImageDropTarget extends ImageTransferer { private final Robot robot; + private static ImageDropTarget idt; private static Point startPoint, endPoint = new Point(250, 150); ImageDropTarget() throws AWTException { DropTargetAdapter dropTargetAdapter = new DropTargetAdapter() { @Override
*** 315,324 **** --- 323,335 ---- leaveFormat(formats[fi]); new Thread(() -> { try { Thread.sleep(1000); } catch (InterruptedException e) { + if (idt.frame != null) { + idt.frame.dispose(); + } e.printStackTrace(); // Exit from the child process System.exit(1); } robot.mouseMove(startPoint.x, startPoint.y);
*** 339,348 **** --- 350,362 ---- void notifyTransferSuccess(boolean status) { if (status) { System.err.println("format passed: " + formats[fi]); } else { + if (idt.frame != null) { + idt.frame.dispose(); + } System.err.println("format failed: " + formats[fi]); System.exit(1); } if (fi < formats.length - 1) { leaveFormat(formats[++fi]);
*** 357,369 **** }).start(); } } ! public static void main(String[] args) { try { ! ImageDropTarget idt = new ImageDropTarget(); int x = Integer.parseInt(args[0]); int y = Integer.parseInt(args[1]); startPoint = new Point(Integer.parseInt(args[2]), Integer.parseInt(args[3])); --- 371,384 ---- }).start(); } } ! public static void main(String[] args) throws Exception { ! idt = new ImageDropTarget(); try { ! idt.frame.setUndecorated(true); int x = Integer.parseInt(args[0]); int y = Integer.parseInt(args[1]); startPoint = new Point(Integer.parseInt(args[2]), Integer.parseInt(args[3]));
*** 375,384 **** --- 390,402 ---- idt.frame.setVisible(true); Util.sync(); idt.startImageDrag(); } catch (Throwable e) { + if (idt.frame != null) { + idt.frame.dispose(); + } e.printStackTrace(); System.exit(1); } }
*** 413,417 **** --- 431,436 ---- } else { throw new UnsupportedFlavorException(flavor); } } } +
< prev index next >