< prev index next >

test/java/awt/SplashScreen/FullscreenAfterSplash/FullScreenAfterSplash.java

Print this page
rev 14565 : 8140329: [TEST_BUG] test FullScreenAfterSplash.java failed because image was not generated
Reviewed-by: serb, arapte
Contributed-by: rahul.d.singh@oracle.com
   1 /*
   2 * Copyright (c) 2013, 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 import sun.awt.OSInfo;
  25 
  26 import java.awt.*;
  27 import java.awt.Robot;
  28 import java.awt.event.InputEvent;
  29 import java.lang.InterruptedException;
  30 import java.lang.System;
  31 import java.lang.Thread;
  32 import java.lang.reflect.Method;
  33 import java.lang.reflect.Proxy;
  34 import javax.swing.*;


  35 
  36 /*
  37  * @test
  38  * @bug 8024185
  39  * @summary Native Mac OS X full screen does not work after showing the splash
  40  * @requires (os.family == "mac")
  41  * @library ../
  42  * @build GenerateTestImage
  43  * @run main GenerateTestImage
  44  * @author Petr Pchelko area=awt.event
  45  * @run main/othervm -splash:test.png FullScreenAfterSplash
  46  */
  47 public class FullScreenAfterSplash {
  48 
  49     private static JFrame frame;
  50 
  51     private static volatile boolean windowEnteringFullScreen = false;
  52     private static volatile boolean windowEnteredFullScreen = false;
  53 
  54     public static void main(String[] args) throws Exception {
  55 
  56         if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
  57             System.out.println("The test is applicable only to Mac OS X. Passed");
  58             return;
  59         }
  60         try {
  61             //Move the mouse out, because it could interfere with the test.
  62             Robot r = new Robot();
  63             r.mouseMove(0, 0);
  64             sleep();
  65 
  66             SwingUtilities.invokeAndWait(FullScreenAfterSplash::createAndShowGUI);
  67             sleep();
  68 
  69             Point fullScreenButtonPos = frame.getLocation();
  70             fullScreenButtonPos.translate(frame.getWidth() - 10, 10);



  71             r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y);
  72 
  73             //Cant use waitForIdle for full screen transition.
  74             int waitCount = 0;
  75             while (!windowEnteringFullScreen) {
  76                 r.mousePress(InputEvent.BUTTON1_MASK);
  77                 r.mouseRelease(InputEvent.BUTTON1_MASK);
  78                 Thread.sleep(100);
  79                 if (waitCount++ > 10) {
  80                     System.err.println("Can't enter full screen mode. Failed.");
  81                     System.exit(1);
  82                 }
  83             }
  84 
  85             waitCount = 0;
  86             while (!windowEnteredFullScreen) {
  87                 Thread.sleep(100);
  88                 if (waitCount++ > 10) {
  89                     System.err.println("Can't enter full screen mode. Failed.");
  90                     System.exit(1);


   1 /*
   2 * Copyright (c) 2013, 2017, 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 import sun.awt.OSInfo;
  25 
  26 import java.awt.*;
  27 import java.awt.Robot;
  28 import java.awt.event.InputEvent;
  29 import java.lang.InterruptedException;
  30 import java.lang.System;
  31 import java.lang.Thread;
  32 import java.lang.reflect.Method;
  33 import java.lang.reflect.Proxy;
  34 import javax.swing.JFrame;
  35 import javax.swing.SwingUtilities;
  36 import javax.swing.WindowConstants;
  37 
  38 /*
  39  * @test
  40  * @bug 8024185
  41  * @summary Native Mac OS X full screen does not work after showing the splash
  42  * @requires (os.family == "mac")
  43  * @library ../
  44  * @build GenerateTestImage
  45  * @run main GenerateTestImage
  46  * @author Petr Pchelko area=awt.event
  47  * @run main/othervm -splash:test.png FullScreenAfterSplash
  48  */
  49 public class FullScreenAfterSplash {
  50 
  51     private static JFrame frame;
  52 
  53     private static volatile boolean windowEnteringFullScreen = false;
  54     private static volatile boolean windowEnteredFullScreen = false;
  55 
  56     public static void main(String[] args) throws Exception {
  57 




  58         try {
  59             //Move the mouse out, because it could interfere with the test.
  60             Robot r = new Robot();
  61             r.mouseMove(0, 0);
  62             sleep();
  63 
  64             SwingUtilities.invokeAndWait(FullScreenAfterSplash::createAndShowGUI);
  65             sleep();
  66 
  67             Point fullScreenButtonPos = frame.getLocation();
  68             if(System.getProperty("os.version").equals("10.9"))
  69                 fullScreenButtonPos.translate(frame.getWidth() - 10, frame.getHeight()/2);
  70             else
  71                 fullScreenButtonPos.translate(55,frame.getHeight()/2);
  72             r.mouseMove(fullScreenButtonPos.x, fullScreenButtonPos.y);
  73 
  74             //Cant use waitForIdle for full screen transition.
  75             int waitCount = 0;
  76             while (!windowEnteringFullScreen) {
  77                 r.mousePress(InputEvent.BUTTON1_MASK);
  78                 r.mouseRelease(InputEvent.BUTTON1_MASK);
  79                 Thread.sleep(100);
  80                 if (waitCount++ > 10) {
  81                     System.err.println("Can't enter full screen mode. Failed.");
  82                     System.exit(1);
  83                 }
  84             }
  85 
  86             waitCount = 0;
  87             while (!windowEnteredFullScreen) {
  88                 Thread.sleep(100);
  89                 if (waitCount++ > 10) {
  90                     System.err.println("Can't enter full screen mode. Failed.");
  91                     System.exit(1);


< prev index next >