< prev index next >

jdk/test/java/awt/Mixing/OpaqueTest.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 /*
  25   @test
  26   @key headful
  27   @bug 4811096
  28   @summary Tests whether opaque and non-opaque components mix correctly
  29   @author anthony.petrov@...: area=awt.mixing
  30   @library ../regtesthelpers
  31   @modules java.desktop/com.sun.awt
  32   @build Util
  33   @run main OpaqueTest
  34 */
  35 
  36 
  37 /**
  38  * OpaqueTest.java
  39  *
  40  * summary:  OpaqueTest
  41  */
  42 
  43 import java.awt.*;
  44 import java.awt.event.*;
  45 import javax.swing.*;
  46 import test.java.awt.regtesthelpers.Util;
  47 import com.sun.awt.AWTUtilities;
  48 
  49 
  50 
  51 public class OpaqueTest
  52 {
  53 
  54     //*** test-writer defined static variables go here ***
  55 
  56     static String testSeq = new String("");
  57     final static String checkSeq = new String("010000101");
  58 
  59     private static void init()
  60     {
  61         //*** Create instructions for the user here ***
  62 
  63         String[] instructions =
  64         {
  65             "This is an AUTOMATIC test, simply wait until it is done.",
  66             "The result (passed or failed) will be shown in the",
  67             "message window below."


 108         f.add(p);
 109         f.setBounds(50, 50, 400, 400);
 110         f.show();
 111 
 112 
 113         Robot robot = Util.createRobot();
 114         robot.setAutoDelay(20);
 115 
 116         Util.waitForIdle(robot);
 117 
 118         // Move the mouse pointer to the position where both
 119         //    buttons overlap
 120         Point heavyLoc = heavy.getLocationOnScreen();
 121         robot.mouseMove(heavyLoc.x + 5, heavyLoc.y + 5);
 122 
 123         // Now perform the click at this point for 9 times
 124         // In the middle of the process toggle the opaque
 125         // flag value.
 126         for (int i = 0; i < 9; ++i) {
 127             if (i == 3) {
 128                 AWTUtilities.setComponentMixingCutoutShape(light,
 129                         new Rectangle());
 130             }
 131             if (i == 6) {
 132                 AWTUtilities.setComponentMixingCutoutShape(light,
 133                         null);
 134             }
 135 
 136             robot.mousePress(InputEvent.BUTTON1_MASK);
 137             robot.mouseRelease(InputEvent.BUTTON1_MASK);
 138             Util.waitForIdle(robot);
 139         }
 140 
 141         Util.waitForIdle(robot);
 142 
 143         // If the buttons are correctly mixed, the test sequence
 144         // is equal to the check sequence.
 145         if (testSeq.equals(checkSeq)) {
 146             OpaqueTest.pass();
 147         } else {
 148             OpaqueTest.fail("The components changed their visible Z-order in a wrong sequence: '" + testSeq + "' instead of '" + checkSeq + "'");
 149         }
 150     }//End  init()
 151 
 152 
 153 




   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 4811096 8173409
  28   @summary Tests whether opaque and non-opaque components mix correctly
  29   @author anthony.petrov@...: area=awt.mixing
  30   @library ../regtesthelpers

  31   @build Util
  32   @run main OpaqueTest
  33 */
  34 
  35 
  36 /**
  37  * OpaqueTest.java
  38  *
  39  * summary:  OpaqueTest
  40  */
  41 
  42 import java.awt.*;
  43 import java.awt.event.*;
  44 import javax.swing.*;
  45 import test.java.awt.regtesthelpers.Util;

  46 
  47 
  48 
  49 public class OpaqueTest
  50 {
  51 
  52     //*** test-writer defined static variables go here ***
  53 
  54     static String testSeq = new String("");
  55     final static String checkSeq = new String("010000101");
  56 
  57     private static void init()
  58     {
  59         //*** Create instructions for the user here ***
  60 
  61         String[] instructions =
  62         {
  63             "This is an AUTOMATIC test, simply wait until it is done.",
  64             "The result (passed or failed) will be shown in the",
  65             "message window below."


 106         f.add(p);
 107         f.setBounds(50, 50, 400, 400);
 108         f.show();
 109 
 110 
 111         Robot robot = Util.createRobot();
 112         robot.setAutoDelay(20);
 113 
 114         Util.waitForIdle(robot);
 115 
 116         // Move the mouse pointer to the position where both
 117         //    buttons overlap
 118         Point heavyLoc = heavy.getLocationOnScreen();
 119         robot.mouseMove(heavyLoc.x + 5, heavyLoc.y + 5);
 120 
 121         // Now perform the click at this point for 9 times
 122         // In the middle of the process toggle the opaque
 123         // flag value.
 124         for (int i = 0; i < 9; ++i) {
 125             if (i == 3) {
 126                 light.setMixingCutoutShape(new Rectangle());

 127             }
 128             if (i == 6) {
 129                 light.setMixingCutoutShape(null);

 130             }
 131 
 132             robot.mousePress(InputEvent.BUTTON1_MASK);
 133             robot.mouseRelease(InputEvent.BUTTON1_MASK);
 134             Util.waitForIdle(robot);
 135         }
 136 
 137         Util.waitForIdle(robot);
 138 
 139         // If the buttons are correctly mixed, the test sequence
 140         // is equal to the check sequence.
 141         if (testSeq.equals(checkSeq)) {
 142             OpaqueTest.pass();
 143         } else {
 144             OpaqueTest.fail("The components changed their visible Z-order in a wrong sequence: '" + testSeq + "' instead of '" + checkSeq + "'");
 145         }
 146     }//End  init()
 147 
 148 
 149 


< prev index next >