< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   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   @key headful
  27   @bug 4397404 4720930
  28   @summary tests that images of all supported native image formats are transfered properly
  29   @library ../../../../lib/testlibrary
  30   @library ../../regtesthelpers/process/
  31   @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator
  32   @author gas@sparc.spb.su area=Clipboard
  33   @run main ImageTransferTest
  34 */
  35 
  36 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
  37 import test.java.awt.regtesthelpers.process.ProcessResults;
  38 import jdk.testlibrary.OSInfo;
  39 
  40 import java.awt.*;
  41 import java.awt.datatransfer.DataFlavor;
  42 import java.awt.datatransfer.SystemFlavorMap;
  43 import java.awt.datatransfer.Transferable;
  44 import java.awt.datatransfer.UnsupportedFlavorException;
  45 import java.awt.dnd.DnDConstants;
  46 import java.awt.dnd.DragSource;
  47 import java.awt.dnd.DragSourceAdapter;
  48 import java.awt.dnd.DragSourceDropEvent;
  49 import java.awt.dnd.DragSourceListener;
  50 import java.awt.dnd.DropTarget;
  51 import java.awt.dnd.DropTargetAdapter;
  52 import java.awt.dnd.DropTargetDropEvent;
  53 import java.awt.event.InputEvent;
  54 import java.awt.image.BufferedImage;
  55 import java.awt.image.MemoryImageSource;
  56 import java.util.stream.Stream;
  57 
  58 public class ImageTransferTest {
  59     public static void main(String[] arg) throws Exception {
  60         ImageDragSource ids = new ImageDragSource();

  61         ids.frame.setLocation(100, 100);
  62         ids.frame.setVisible(true);
  63         Util.sync();
  64         String classpath = System.getProperty("java.class.path");
  65         String[] args = new String[ids.formats.length + 4];
  66         args[0] = "200";
  67         args[1] = "100";
  68         args[2] = args[3] = "150";
  69 
  70         System.arraycopy(ids.formats, 0, args, 4, ids.formats.length);
  71         ProcessResults pres = ProcessCommunicator.executeChildProcess(ImageDropTarget.class, classpath, args);
  72 
  73         if (pres.getStdErr() != null && pres.getStdErr().length() > 0) {
  74             System.err.println("========= Child VM System.err ========");
  75             System.err.print(pres.getStdErr());
  76             System.err.println("======================================");
  77         }
  78 
  79         if (pres.getStdOut() != null && pres.getStdOut().length() > 0) {
  80             System.err.println("========= Child VM System.out ========");


 345             System.exit(1);
 346         }
 347         if (fi < formats.length - 1) {
 348             leaveFormat(formats[++fi]);
 349         } else {
 350             new Thread(() -> {
 351                 try {
 352                     Thread.sleep(500);
 353                 } catch (InterruptedException e) {
 354                     e.printStackTrace();
 355                 }
 356                 System.exit(0);
 357             }).start();
 358         }
 359     }
 360 
 361 
 362     public static void main(String[] args) {
 363         try {
 364             ImageDropTarget idt = new ImageDropTarget();

 365 
 366             int x = Integer.parseInt(args[0]);
 367             int y = Integer.parseInt(args[1]);
 368             startPoint = new Point(Integer.parseInt(args[2]), Integer.parseInt(args[3]));
 369 
 370             idt.formats = new String[args.length - 4];
 371             System.arraycopy(args, 4, idt.formats, 0, args.length - 4);
 372             leaveFormat(idt.formats[0]);
 373 
 374             idt.frame.setLocation(x, y);
 375             idt.frame.setVisible(true);
 376             Util.sync();
 377 
 378             idt.startImageDrag();
 379         } catch (Throwable e) {
 380             e.printStackTrace();
 381             System.exit(1);
 382         }
 383     }
 384 


   1 /*
   2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   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  * @key headful
  27  * @bug 4397404 4720930 8197926
  28  * @summary tests that images of all supported native image formats are transfered properly
  29  * @library ../../../../lib/testlibrary
  30  * @library ../../regtesthelpers/process/
  31  * @build jdk.testlibrary.OSInfo ProcessResults ProcessCommunicator
  32  * @author gas@sparc.spb.su area=Clipboard
  33  * @run main ImageTransferTest
  34  */
  35 
  36 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
  37 import test.java.awt.regtesthelpers.process.ProcessResults;
  38 import jdk.testlibrary.OSInfo;
  39 
  40 import java.awt.*;
  41 import java.awt.datatransfer.DataFlavor;
  42 import java.awt.datatransfer.SystemFlavorMap;
  43 import java.awt.datatransfer.Transferable;
  44 import java.awt.datatransfer.UnsupportedFlavorException;
  45 import java.awt.dnd.DnDConstants;
  46 import java.awt.dnd.DragSource;
  47 import java.awt.dnd.DragSourceAdapter;
  48 import java.awt.dnd.DragSourceDropEvent;
  49 import java.awt.dnd.DragSourceListener;
  50 import java.awt.dnd.DropTarget;
  51 import java.awt.dnd.DropTargetAdapter;
  52 import java.awt.dnd.DropTargetDropEvent;
  53 import java.awt.event.InputEvent;
  54 import java.awt.image.BufferedImage;
  55 import java.awt.image.MemoryImageSource;
  56 import java.util.stream.Stream;
  57 
  58 public class ImageTransferTest {
  59     public static void main(String[] arg) throws Exception {
  60         ImageDragSource ids = new ImageDragSource();
  61         ids.frame.setUndecorated(true);
  62         ids.frame.setLocation(100, 100);
  63         ids.frame.setVisible(true);
  64         Util.sync();
  65         String classpath = System.getProperty("java.class.path");
  66         String[] args = new String[ids.formats.length + 4];
  67         args[0] = "200";
  68         args[1] = "100";
  69         args[2] = args[3] = "150";
  70 
  71         System.arraycopy(ids.formats, 0, args, 4, ids.formats.length);
  72         ProcessResults pres = ProcessCommunicator.executeChildProcess(ImageDropTarget.class, classpath, args);
  73 
  74         if (pres.getStdErr() != null && pres.getStdErr().length() > 0) {
  75             System.err.println("========= Child VM System.err ========");
  76             System.err.print(pres.getStdErr());
  77             System.err.println("======================================");
  78         }
  79 
  80         if (pres.getStdOut() != null && pres.getStdOut().length() > 0) {
  81             System.err.println("========= Child VM System.out ========");


 346             System.exit(1);
 347         }
 348         if (fi < formats.length - 1) {
 349             leaveFormat(formats[++fi]);
 350         } else {
 351             new Thread(() -> {
 352                 try {
 353                     Thread.sleep(500);
 354                 } catch (InterruptedException e) {
 355                     e.printStackTrace();
 356                 }
 357                 System.exit(0);
 358             }).start();
 359         }
 360     }
 361 
 362 
 363     public static void main(String[] args) {
 364         try {
 365             ImageDropTarget idt = new ImageDropTarget();
 366             idt.frame.setUndecorated(true);
 367 
 368             int x = Integer.parseInt(args[0]);
 369             int y = Integer.parseInt(args[1]);
 370             startPoint = new Point(Integer.parseInt(args[2]), Integer.parseInt(args[3]));
 371 
 372             idt.formats = new String[args.length - 4];
 373             System.arraycopy(args, 4, idt.formats, 0, args.length - 4);
 374             leaveFormat(idt.formats[0]);
 375 
 376             idt.frame.setLocation(x, y);
 377             idt.frame.setVisible(true);
 378             Util.sync();
 379 
 380             idt.startImageDrag();
 381         } catch (Throwable e) {
 382             e.printStackTrace();
 383             System.exit(1);
 384         }
 385     }
 386 


< prev index next >