--- old/test/jdk/java/awt/dnd/ImageTransferTest/ImageTransferTest.java 2018-02-15 15:04:21.612942000 +0530 +++ new/test/jdk/java/awt/dnd/ImageTransferTest/ImageTransferTest.java 2018-02-15 15:04:21.372822000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -22,16 +22,16 @@ */ /* - @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 -*/ + * @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; @@ -58,48 +58,55 @@ public class ImageTransferTest { public static void main(String[] arg) throws Exception { ImageDragSource ids = new ImageDragSource(); - 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]; - args[0] = "200"; - args[1] = "100"; - args[2] = args[3] = "150"; - - System.arraycopy(ids.formats, 0, args, 4, ids.formats.length); - ProcessResults pres = ProcessCommunicator.executeChildProcess(ImageDropTarget.class, classpath, args); - - if (pres.getStdErr() != null && pres.getStdErr().length() > 0) { - System.err.println("========= Child VM System.err ========"); - System.err.print(pres.getStdErr()); - System.err.println("======================================"); - } - - if (pres.getStdOut() != null && pres.getStdOut().length() > 0) { - System.err.println("========= Child VM System.out ========"); - System.err.print(pres.getStdOut()); - System.err.println("======================================"); - } - - boolean failed = false; - String passedFormats = ""; - String failedFormats = ""; - - for (int i = 0; i < ids.passedArray.length; i++) { - if (ids.passedArray[i]) passedFormats += ids.formats[i] + " "; - else { - failed = true; - failedFormats += ids.formats[i] + " "; + 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]; + args[0] = "200"; + args[1] = "100"; + args[2] = args[3] = "150"; + + System.arraycopy(ids.formats, 0, args, 4, ids.formats.length); + ProcessResults pres = ProcessCommunicator.executeChildProcess(ImageDropTarget.class, classpath, args); + + if (pres.getStdErr() != null && pres.getStdErr().length() > 0) { + System.err.println("========= Child VM System.err ========"); + System.err.print(pres.getStdErr()); + System.err.println("======================================"); + } + + if (pres.getStdOut() != null && pres.getStdOut().length() > 0) { + System.err.println("========= Child VM System.out ========"); + System.err.print(pres.getStdOut()); + System.err.println("======================================"); + } + + boolean failed = false; + String passedFormats = ""; + String failedFormats = ""; + + for (int i = 0; i < ids.passedArray.length; i++) { + if (ids.passedArray[i]) passedFormats += ids.formats[i] + " "; + else { + failed = true; + failedFormats += ids.formats[i] + " "; + } + } + + if (failed) { + throw new RuntimeException("test failed: images in following " + + "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(); } - } - - if (failed) { - throw new RuntimeException("test failed: images in following " + - "native formats are not transferred properly: " + failedFormats); - } else { - System.err.println("images in following " + - "native formats are transferred properly: " + passedFormats); } } } @@ -261,6 +268,7 @@ class ImageDropTarget extends ImageTransferer { private final Robot robot; + private static ImageDropTarget idt; private static Point startPoint, endPoint = new Point(250, 150); ImageDropTarget() throws AWTException { @@ -317,6 +325,9 @@ try { Thread.sleep(1000); } catch (InterruptedException e) { + if (idt.frame != null) { + idt.frame.dispose(); + } e.printStackTrace(); // Exit from the child process System.exit(1); @@ -341,6 +352,9 @@ 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); } @@ -359,9 +373,10 @@ } - public static void main(String[] args) { + public static void main(String[] args) throws Exception { + idt = new ImageDropTarget(); try { - ImageDropTarget idt = new ImageDropTarget(); + idt.frame.setUndecorated(true); int x = Integer.parseInt(args[0]); int y = Integer.parseInt(args[1]); @@ -377,6 +392,9 @@ idt.startImageDrag(); } catch (Throwable e) { + if (idt.frame != null) { + idt.frame.dispose(); + } e.printStackTrace(); System.exit(1); } @@ -415,3 +433,4 @@ } } } +