< prev index next >

test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java

Print this page




   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   @bug 4658741
  27   @summary verifies that getDropSuccess() returns correct value for inter-JVM DnD
  28   @author das@sparc.spb.su area=dnd
  29   @run applet InterJVMGetDropSuccessTest.html
  30 */
  31 
  32 // Note there is no @ in front of test above.  This is so that the
  33 //  harness will not mistake this file as a test file.  It should
  34 //  only see the html file as a test file. (the harness runs all
  35 //  valid test files, so it would run this test twice if this file
  36 //  were valid as well as the html file.)
  37 // Also, note the area= after Your Name in the author tag.  Here, you
  38 //  should put which functional area the test falls in.  See the
  39 //  AWT-core home page -> test areas and/or -> AWT team  for a list of
  40 //  areas.
  41 // Note also the 'InterJVMGetDropSuccessTest.html' in the run tag.  This should
  42 //  be changed to the name of the test.
  43 
  44 
  45 /**
  46  * InterJVMGetDropSuccessTest.java
  47  *
  48  * summary: verifies that getDropSuccess() returns correct value for inter-JVM DnD
  49  */
  50 
  51 import java.applet.Applet;
  52 import java.awt.*;
  53 import java.awt.datatransfer.*;
  54 import java.awt.dnd.*;
  55 import java.awt.event.*;
  56 import java.io.*;
  57 import javax.swing.*;
  58 
  59 
  60 //Automated tests should run as applet tests if possible because they
  61 // get their environments cleaned up, including AWT threads, any
  62 // test created threads, and any system resources used by the test
  63 // such as file descriptors.  (This is normally not a problem as
  64 // main tests usually run in a separate VM, however on some platforms
  65 // such as the Mac, separate VMs are not possible and non-applet
  66 // tests will cause problems).  Also, you don't have to worry about
  67 // synchronisation stuff in Applet tests they way you do in main
  68 // tests...
  69 
  70 
  71 public class InterJVMGetDropSuccessTest extends Applet {
  72 
  73     private int returnCode = Util.CODE_NOT_RETURNED;
  74     private boolean successCodes[] = { true, false };
  75     private int dropCount = 0;
  76 
  77     final Frame frame = new Frame("Target Frame");
  78 
  79     final DropTargetListener dropTargetListener = new DropTargetAdapter() {
  80             public void drop(DropTargetDropEvent dtde) {
  81                 dtde.acceptDrop(DnDConstants.ACTION_COPY);
  82                 dtde.dropComplete(successCodes[dropCount]);
  83                 dropCount++;
  84             }
  85         };
  86     final DropTarget dropTarget = new DropTarget(frame, dropTargetListener);
  87 






  88     public void init() {
  89         frame.setTitle("Test frame");
  90         frame.setBounds(100, 100, 150, 150);
  91     } // init()
  92 
  93     public void start() {
  94 
  95         frame.setVisible(true);
  96 
  97         try {
  98             Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
  99 
 100             Point p = frame.getLocationOnScreen();
 101             Dimension d = frame.getSize();
 102 
 103             String javaPath = System.getProperty("java.home", "");
 104             String command = javaPath + File.separator + "bin" +
 105                 File.separator + "java -cp " + System.getProperty("test.classes", ".") +
 106                 " Child " +
 107                 p.x + " " + p.y + " " + d.width + " " + d.height;




   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 4658741
  28   @summary verifies that getDropSuccess() returns correct value for inter-JVM DnD
  29   @run main InterJVMGetDropSuccessTest

  30 */
  31 




















  32 import java.awt.*;
  33 import java.awt.datatransfer.*;
  34 import java.awt.dnd.*;
  35 import java.awt.event.*;
  36 import java.io.*;












  37 
  38 public class InterJVMGetDropSuccessTest {

  39 
  40     private int returnCode = Util.CODE_NOT_RETURNED;
  41     private boolean successCodes[] = { true, false };
  42     private int dropCount = 0;
  43 
  44     final Frame frame = new Frame("Target Frame");
  45 
  46     final DropTargetListener dropTargetListener = new DropTargetAdapter() {
  47             public void drop(DropTargetDropEvent dtde) {
  48                 dtde.acceptDrop(DnDConstants.ACTION_COPY);
  49                 dtde.dropComplete(successCodes[dropCount]);
  50                 dropCount++;
  51             }
  52         };
  53     final DropTarget dropTarget = new DropTarget(frame, dropTargetListener);
  54 
  55     public static void main(final String[] args) {
  56         InterJVMGetDropSuccessTest app = new InterJVMGetDropSuccessTest();
  57         app.init();
  58         app.start();
  59     }
  60 
  61     public void init() {
  62         frame.setTitle("Test frame");
  63         frame.setBounds(100, 100, 150, 150);
  64     } // init()
  65 
  66     public void start() {
  67 
  68         frame.setVisible(true);
  69 
  70         try {
  71             Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT);
  72 
  73             Point p = frame.getLocationOnScreen();
  74             Dimension d = frame.getSize();
  75 
  76             String javaPath = System.getProperty("java.home", "");
  77             String command = javaPath + File.separator + "bin" +
  78                 File.separator + "java -cp " + System.getProperty("test.classes", ".") +
  79                 " Child " +
  80                 p.x + " " + p.y + " " + d.width + " " + d.height;


< prev index next >