8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @bug 4397404 4720930 27 @summary tests that images of all supported native image formats are transfered properly 28 @library ../../regtesthelpers/process/ 29 @build ProcessResults ProcessCommunicator 30 @author gas@sparc.spb.su area=Clipboard 31 @run main ImageTransferTest 32 */ 33 34 import sun.awt.OSInfo; 35 import sun.awt.SunToolkit; 36 import test.java.awt.regtesthelpers.process.ProcessCommunicator; 37 import test.java.awt.regtesthelpers.process.ProcessResults; 38 39 import java.awt.*; 40 import java.awt.datatransfer.DataFlavor; 41 import java.awt.datatransfer.SystemFlavorMap; 42 import java.awt.datatransfer.Transferable; 43 import java.awt.datatransfer.UnsupportedFlavorException; 44 import java.awt.dnd.DnDConstants; 45 import java.awt.dnd.DragSource; 46 import java.awt.dnd.DragSourceAdapter; 47 import java.awt.dnd.DragSourceDropEvent; 48 import java.awt.dnd.DragSourceListener; 49 import java.awt.dnd.DropTarget; 50 import java.awt.dnd.DropTargetAdapter; 51 import java.awt.dnd.DropTargetDropEvent; 52 import java.awt.event.InputEvent; 53 import java.awt.image.BufferedImage; 54 import java.awt.image.MemoryImageSource; 55 import java.util.stream.Stream; 56 57 public class ImageTransferTest { 88 for (int i = 0; i < ids.passedArray.length; i++) { 89 if (ids.passedArray[i]) passedFormats += ids.formats[i] + " "; 90 else { 91 failed = true; 92 failedFormats += ids.formats[i] + " "; 93 } 94 } 95 96 if (failed) { 97 throw new RuntimeException("test failed: images in following " + 98 "native formats are not transferred properly: " + failedFormats); 99 } else { 100 System.err.println("images in following " + 101 "native formats are transferred properly: " + passedFormats); 102 } 103 } 104 } 105 106 107 class Util { 108 public static void sync() { 109 ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); 110 try { 111 Thread.sleep(500); 112 } catch (InterruptedException e) { 113 throw new RuntimeException(e); 114 } 115 } 116 } 117 118 abstract class ImageTransferer { 119 Image image; 120 String[] formats; 121 int fi; // current format index 122 Frame frame = new Frame(); 123 124 125 ImageTransferer() { 126 image = createImage(); 127 frame.setSize(100, 100); 128 } 129 130 private static Image createImage() { 131 int w = 100; 132 int h = 100; | 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @bug 4397404 4720930 27 @summary tests that images of all supported native image formats are transfered properly 28 @library ../../../../lib/testlibrary 29 @library ../../regtesthelpers/process/ 30 @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator 31 @author gas@sparc.spb.su area=Clipboard 32 @run main ImageTransferTest 33 */ 34 35 import test.java.awt.regtesthelpers.process.ProcessCommunicator; 36 import test.java.awt.regtesthelpers.process.ProcessResults; 37 import jdk.testlibrary.OSInfo; 38 39 import java.awt.*; 40 import java.awt.datatransfer.DataFlavor; 41 import java.awt.datatransfer.SystemFlavorMap; 42 import java.awt.datatransfer.Transferable; 43 import java.awt.datatransfer.UnsupportedFlavorException; 44 import java.awt.dnd.DnDConstants; 45 import java.awt.dnd.DragSource; 46 import java.awt.dnd.DragSourceAdapter; 47 import java.awt.dnd.DragSourceDropEvent; 48 import java.awt.dnd.DragSourceListener; 49 import java.awt.dnd.DropTarget; 50 import java.awt.dnd.DropTargetAdapter; 51 import java.awt.dnd.DropTargetDropEvent; 52 import java.awt.event.InputEvent; 53 import java.awt.image.BufferedImage; 54 import java.awt.image.MemoryImageSource; 55 import java.util.stream.Stream; 56 57 public class ImageTransferTest { 88 for (int i = 0; i < ids.passedArray.length; i++) { 89 if (ids.passedArray[i]) passedFormats += ids.formats[i] + " "; 90 else { 91 failed = true; 92 failedFormats += ids.formats[i] + " "; 93 } 94 } 95 96 if (failed) { 97 throw new RuntimeException("test failed: images in following " + 98 "native formats are not transferred properly: " + failedFormats); 99 } else { 100 System.err.println("images in following " + 101 "native formats are transferred properly: " + passedFormats); 102 } 103 } 104 } 105 106 107 class Util { 108 private static Robot srobot = null; 109 public static void sync() { 110 try { 111 if(srobot == null) { 112 srobot = new Robot(); 113 } 114 srobot.waitForIdle(); 115 Thread.sleep(500); 116 } catch (Exception e) { 117 throw new RuntimeException(e); 118 } 119 } 120 } 121 122 abstract class ImageTransferer { 123 Image image; 124 String[] formats; 125 int fi; // current format index 126 Frame frame = new Frame(); 127 128 129 ImageTransferer() { 130 image = createImage(); 131 frame.setSize(100, 100); 132 } 133 134 private static Image createImage() { 135 int w = 100; 136 int h = 100; |