< prev index next >

test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java

Print this page




   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 import java.awt.*;
  25 import java.awt.datatransfer.DataFlavor;
  26 import java.awt.event.*;
  27 import java.applet.Applet;
  28 import java.io.File;
  29 import java.util.ArrayList;
  30 
  31 import jdk.test.lib.Platform;
  32 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
  33 import test.java.awt.regtesthelpers.process.ProcessResults;
  34 import test.java.awt.regtesthelpers.Util;
  35 
  36 import static java.lang.Thread.sleep;
  37 
  38 public class MissedHtmlAndRtfBug extends Applet {
  39 
  40     public void init() {
  41         setLayout(new BorderLayout());
  42     }//End  init()









  43 
  44     public void start() {
  45         if (!Platform.isOSX() && !Platform.isWindows()) {
  46             System.out.println("This test is for Windows and Mac only. Passed.");
  47             return;
  48         }
  49 
  50         final Frame sourceFrame = new Frame("Source frame");
  51         final SourcePanel sourcePanel = new SourcePanel();
  52         sourceFrame.add(sourcePanel);
  53         sourceFrame.pack();
  54         sourceFrame.addWindowListener(new WindowAdapter() {
  55             @Override
  56             public void windowClosing(WindowEvent e) {
  57                 sourceFrame.dispose();
  58             }
  59         });
  60         sourceFrame.setVisible(true);
  61 
  62         Util.waitForIdle(null);


 161     }
 162 
 163 
 164     enum InterprocessArguments {
 165         TARGET_FRAME_X_POSITION_ARGUMENT,
 166         TARGET_FRAME_Y_POSITION_ARGUMENT,
 167         DRAG_SOURCE_POINT_X_ARGUMENT,
 168         DRAG_SOURCE_POINT_Y_ARGUMENT,
 169         DATA_FLAVOR_NAMES;
 170 
 171         int extractInt(String[] args) {
 172             return Integer.parseInt(args[this.ordinal()]);
 173         }
 174 
 175         String[] extractStringArray(String[] args) {
 176             return args[this.ordinal()].replaceAll("\"", "").split(",");
 177         }
 178     }
 179 
 180     public static void main(String[] args) throws InterruptedException {





 181         Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extractInt(args),
 182                 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extractInt(args));
 183         Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extractInt(args),
 184                 InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extractInt(args));
 185         String[] names = InterprocessArguments.DATA_FLAVOR_NAMES.extractStringArray(args);
 186 
 187         DataFlavor df = DataFlavorSearcher.getByteDataFlavorForNative(names);
 188         try {
 189             new MissedHtmlAndRtfBug(targetFrameLocation, dragSourcePoint, df);
 190         } catch (InterruptedException e) {
 191             e.printStackTrace();
 192         }
 193         sleep(5000);
 194         System.exit(InterprocessMessages.NO_DROP_HAPPENED);
 195     }
 196 
 197 
 198 }


   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 import java.awt.*;
  25 import java.awt.datatransfer.DataFlavor;
  26 import java.awt.event.*;

  27 import java.io.File;
  28 import java.util.ArrayList;
  29 
  30 import jdk.test.lib.Platform;
  31 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
  32 import test.java.awt.regtesthelpers.process.ProcessResults;
  33 import test.java.awt.regtesthelpers.Util;
  34 
  35 import static java.lang.Thread.sleep;
  36 
  37 /*
  38     @test
  39     @key headful
  40     @bug 8005932 8017456
  41     @summary Java 7 on mac os x only provides text clipboard formats
  42     @library ../../regtesthelpers
  43     @library ../../regtesthelpers/process
  44     @library /test/lib
  45     @build Util
  46     @build ProcessResults ProcessCommunicator
  47     @build jdk.test.lib.Platform
  48     @run main/othervm MissedHtmlAndRtfBug main
  49  */
  50 public class MissedHtmlAndRtfBug {
  51 
  52     public void start() {
  53         if (!Platform.isOSX() && !Platform.isWindows()) {
  54             System.out.println("This test is for Windows and Mac only. Passed.");
  55             return;
  56         }
  57 
  58         final Frame sourceFrame = new Frame("Source frame");
  59         final SourcePanel sourcePanel = new SourcePanel();
  60         sourceFrame.add(sourcePanel);
  61         sourceFrame.pack();
  62         sourceFrame.addWindowListener(new WindowAdapter() {
  63             @Override
  64             public void windowClosing(WindowEvent e) {
  65                 sourceFrame.dispose();
  66             }
  67         });
  68         sourceFrame.setVisible(true);
  69 
  70         Util.waitForIdle(null);


 169     }
 170 
 171 
 172     enum InterprocessArguments {
 173         TARGET_FRAME_X_POSITION_ARGUMENT,
 174         TARGET_FRAME_Y_POSITION_ARGUMENT,
 175         DRAG_SOURCE_POINT_X_ARGUMENT,
 176         DRAG_SOURCE_POINT_Y_ARGUMENT,
 177         DATA_FLAVOR_NAMES;
 178 
 179         int extractInt(String[] args) {
 180             return Integer.parseInt(args[this.ordinal()]);
 181         }
 182 
 183         String[] extractStringArray(String[] args) {
 184             return args[this.ordinal()].replaceAll("\"", "").split(",");
 185         }
 186     }
 187 
 188     public static void main(String[] args) throws InterruptedException {
 189         if (args.length > 0 && args[0].equals("main")) {
 190             new MissedHtmlAndRtfBug().start();
 191             return;
 192         }
 193 
 194         Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extractInt(args),
 195                 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extractInt(args));
 196         Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extractInt(args),
 197                 InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extractInt(args));
 198         String[] names = InterprocessArguments.DATA_FLAVOR_NAMES.extractStringArray(args);
 199 
 200         DataFlavor df = DataFlavorSearcher.getByteDataFlavorForNative(names);
 201         try {
 202             new MissedHtmlAndRtfBug(targetFrameLocation, dragSourcePoint, df);
 203         } catch (InterruptedException e) {
 204             e.printStackTrace();
 205         }
 206         sleep(5000);
 207         System.exit(InterprocessMessages.NO_DROP_HAPPENED);
 208     }
 209 
 210 
 211 }
< prev index next >