< prev index next >

test/jdk/java/awt/dnd/NoFormatsCrashTest/NoFormatsCrashTest.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 4870762
  27   @summary tests that a drop target JVM doesn't crash if the source doesn't export
  28            data in native formats.
  29   @author das@sparc.spb.su area=dnd
  30   @compile NoFormatsCrashTest.java
  31   @run applet NoFormatsCrashTest.html
  32 */
  33 
  34 // Note there is no @ in front of test above.  This is so that the
  35 //  harness will not mistake this file as a test file.  It should
  36 //  only see the html file as a test file. (the harness runs all
  37 //  valid test files, so it would run this test twice if this file
  38 //  were valid as well as the html file.)
  39 // Also, note the area= after Your Name in the author tag.  Here, you
  40 //  should put which functional area the test falls in.  See the
  41 //  AWT-core home page -> test areas and/or -> AWT team  for a list of
  42 //  areas.
  43 // Note also the 'NoFormatsCrashTest.html' in the run tag.  This should
  44 //  be changed to the name of the test.
  45 
  46 
  47 /**
  48  * NoFormatsCrashTest.java
  49  *
  50  * summary: tests that a drop target JVM doesn't crash if the source doesn't export
  51  *          data in native formats.
  52  */
  53 
  54 import java.applet.Applet;
  55 import java.awt.*;
  56 import java.awt.datatransfer.*;
  57 import java.awt.dnd.*;
  58 import java.awt.event.*;
  59 import java.io.*;
  60 
  61 
  62 //Automated tests should run as applet tests if possible because they
  63 // get their environments cleaned up, including AWT threads, any
  64 // test created threads, and any system resources used by the test
  65 // such as file descriptors.  (This is normally not a problem as
  66 // main tests usually run in a separate VM, however on some platforms
  67 // such as the Mac, separate VMs are not possible and non-applet
  68 // tests will cause problems).  Also, you don't have to worry about
  69 // synchronisation stuff in Applet tests they way you do in main
  70 // tests...
  71 
  72 
  73 public class NoFormatsCrashTest extends Applet {
  74 
  75     final Frame frame = new Frame();
  76     private volatile Process process;
  77 
  78     static final int FRAME_ACTIVATION_TIMEOUT = 2000;
  79 
  80     public static void main(String[] args) {







  81         NoFormatsCrashTest test = new NoFormatsCrashTest();
  82         test.run(args);
  83     }
  84 
  85     public void run(String[] args) {
  86         try {
  87             if (args.length != 4) {
  88                 throw new RuntimeException("Incorrect command line arguments.");
  89             }
  90 
  91             int x = Integer.parseInt(args[0]);
  92             int y = Integer.parseInt(args[1]);
  93             int w = Integer.parseInt(args[2]);
  94             int h = Integer.parseInt(args[3]);
  95 
  96             Panel panel = new DragSourcePanel();
  97 
  98             frame.setTitle("Drag source frame");
  99             frame.setLocation(500, 200);
 100             frame.add(panel);




   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 4870762
  28   @summary tests that a drop target JVM doesn't crash if the source doesn't export
  29            data in native formats.
  30   @run main NoFormatsCrashTest main


  31 */
  32 





















  33 import java.awt.*;
  34 import java.awt.datatransfer.*;
  35 import java.awt.dnd.*;
  36 import java.awt.event.*;
  37 import java.io.*;
  38 
  39 public class NoFormatsCrashTest {












  40 
  41     final Frame frame = new Frame();
  42     private volatile Process process;
  43 
  44     static final int FRAME_ACTIVATION_TIMEOUT = 2000;
  45 
  46     public static void main(String[] args) {
  47         if (args.length > 0 && args[0].equals("main")) {
  48             NoFormatsCrashTest test = new NoFormatsCrashTest();
  49             test.init();
  50             test.start();
  51             return;
  52         }
  53 
  54         NoFormatsCrashTest test = new NoFormatsCrashTest();
  55         test.run(args);
  56     }
  57 
  58     public void run(String[] args) {
  59         try {
  60             if (args.length != 4) {
  61                 throw new RuntimeException("Incorrect command line arguments.");
  62             }
  63 
  64             int x = Integer.parseInt(args[0]);
  65             int y = Integer.parseInt(args[1]);
  66             int w = Integer.parseInt(args[2]);
  67             int h = Integer.parseInt(args[3]);
  68 
  69             Panel panel = new DragSourcePanel();
  70 
  71             frame.setTitle("Drag source frame");
  72             frame.setLocation(500, 200);
  73             frame.add(panel);


< prev index next >