1 /* 2 * Copyright (c) 2004, 2014, 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 java.awt.*; 25 26 /* 27 * @test 28 * @summary Construct a Undecorated Frame, zoom it from the normal state and 29 * back forth using Frame.ZOOMED and Frame.NORMAL. Iconofy from the 30 * zoomed state and back forth using Frame.ICONIFIED and Frame.NORMAL 31 * and check the zoomed size is same as the screen size. Check the 32 * location of the frame after restoration from zoom or icon. 33 * @author Aruna Samji 34 * @library ../../../lib/testlibrary 35 * @build ExtendedRobot 36 * @run main TaskZoomUndFrameChangeState 37 */ 38 39 public class TaskZoomUndFrameChangeState extends Task<GUIZoomFrame> { 40 41 public static void main (String[] args) throws Exception { 42 new TaskZoomUndFrameChangeState(GUIZoomFrame.class, new ExtendedRobot()).runTask(); 43 } 44 45 TaskZoomUndFrameChangeState(Class guiClass, ExtendedRobot robot) throws Exception { 46 super(guiClass, robot); 47 } 48 49 public void task() throws Exception { 50 EventQueue.invokeAndWait(() -> { 51 gui.frame1.setLayout(null); 52 gui.frame1.setUndecorated(true); 53 gui.frame1.setVisible(true); 54 gui.frame1.removeAll(); 55 if (gui.frame1.getExtendedState() != Frame.NORMAL) 56 gui.frame1.setExtendedState(Frame.NORMAL); 57 }); 58 robot.waitForIdle(1000); 59 60 Point frameOrigin = gui.frame1.getLocationOnScreen(); 61 62 EventQueue.invokeAndWait(() -> 63 gui.frame1.setExtendedState(Frame.ICONIFIED) 64 ); 65 robot.waitForIdle(1000); 66 67 //To check whether the bitwise mask for ICONIFIED state is set... 68 if (gui.frame1.getExtendedState() != Frame.ICONIFIED) 69 throw new RuntimeException("The bitwise mask Frame.ICONIFIED is " + 70 "not set when the frame is in ICONIFIED state"); 71 72 //To check whether the Frame is iconified programmatically.......... 73 if (! gui.iconify) 74 throw new RuntimeException("Frame is not Iconified"); 75 76 //Normalising the Frame.... 77 EventQueue.invokeAndWait(() -> 78 gui.frame1.setExtendedState(Frame.NORMAL) 79 ); 80 robot.waitForIdle(1000); 81 82 //To check whether the bitwise mask for NORMAL state is set... 83 if (gui.frame1.getExtendedState() != Frame.NORMAL) 84 throw new RuntimeException("The bitwise mask Frame.NORMAL is " + 85 "not set when the frame is in NORMAL state after Iconofied"); 86 87 //To check whether the Frame is normalised programmatically.......... 88 if (! gui.normal) 89 throw new RuntimeException("Frame is not restored to normal after Iconofied"); 90 91 Point newposition = gui.frame1.getLocationOnScreen(); 92 93 if((frameOrigin.x != newposition.x)&(frameOrigin.y != newposition.y)) 94 throw new RuntimeException("The frame is not positioned back to " + 95 "the original place on the screen after Iconified"); 96 97 robot.waitForIdle(1000); 98 99 //To check whether the state is supported in the platform.... 100 if (Toolkit.getDefaultToolkit().isFrameStateSupported( 101 Frame.MAXIMIZED_HORIZ)){ 102 //System.out.println("Frame.MAXIMIZED_HORIZ is supported"); 103 //Maximising the Frame horizontally......... 104 EventQueue.invokeAndWait(() -> 105 gui.frame1.setExtendedState(Frame.MAXIMIZED_HORIZ) 106 ); 107 robot.waitForIdle(1000); 108 109 //To check whether the bitwise mask for MAXIMIZED_HORIZ state is set... 110 if (gui.frame1.getExtendedState() != Frame.MAXIMIZED_HORIZ) 111 throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_HOR " + 112 "is not set when the frame is in MAXIMIZED_HOR state"); 113 114 //To check whether the Frame is maximized horizontally.......... 115 if (! gui.maxHor) 116 throw new RuntimeException("Frame is not maximized horizontally"); 117 118 EventQueue.invokeAndWait(() -> 119 gui.frame1.setExtendedState(Frame.NORMAL) 120 ); 121 robot.waitForIdle(1000); 122 } 123 124 //To check whether the state is supported in the platform.... 125 if (Toolkit.getDefaultToolkit().isFrameStateSupported( 126 Frame.MAXIMIZED_VERT)){ 127 //System.out.println("Frame.MAXIMIZED_VERT is supported"); 128 //Maximising the Frame vertically......... 129 EventQueue.invokeAndWait(() -> 130 gui.frame1.setExtendedState(Frame.MAXIMIZED_VERT) 131 ); 132 robot.waitForIdle(1000); 133 134 //To check whether the bitwise mask for MAXIMIZED_VERT state is set... 135 if (gui.frame1.getExtendedState() != Frame.MAXIMIZED_VERT) 136 throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_VERT " + 137 "is not set when the frame is in MAXIMIZED_VERT state"); 138 139 //To check whether the Frame is maximized vertically.......... 140 if (! gui.maxVer) 141 throw new RuntimeException("Frame is not maximized vertically"); 142 143 EventQueue.invokeAndWait(() -> 144 gui.frame1.setExtendedState(Frame.NORMAL) 145 ); 146 robot.waitForIdle(1000); 147 } 148 149 robot.waitForIdle(1000); 150 151 if (Toolkit.getDefaultToolkit().isFrameStateSupported 152 (Frame.MAXIMIZED_BOTH)){ 153 //Maximising the Frame fully......... 154 EventQueue.invokeAndWait(() -> 155 gui.frame1.setExtendedState(Frame.MAXIMIZED_BOTH) 156 ); 157 }; 158 robot.waitForIdle(1000); 159 160 //To check whether the state is supported in the platform.... 161 if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)){ 162 //To check whether the bitwise mask for MAXIMIZED_BOTH state is set... 163 if (gui.frame1.getExtendedState() != Frame.MAXIMIZED_BOTH) 164 throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_BOTH " + 165 "is not set when the frame is in MAXIMIZED_BOTH state"); 166 167 //To check whether the Frame is maximized fully.......... 168 if (! gui.maxBoth) 169 throw new RuntimeException("Frame is not maximized fully"); 170 } 171 172 //Normalising the Frame.... 173 EventQueue.invokeAndWait(() -> 174 gui.frame1.setExtendedState(Frame.NORMAL) 175 ); 176 robot.waitForIdle(1000); 177 178 //To check whether the bitwise mask for NORMAL state is set... 179 if (gui.frame1.getExtendedState() != Frame.NORMAL) 180 throw new RuntimeException("The bitwise mask Frame.NORMAL is not " + 181 "set when the frame is in NORMAL state after Zoomed"); 182 183 //To check whether the Frame is normalised programmatically.......... 184 if (! gui.normal) 185 throw new RuntimeException("Frame is not restored to normal after Zoomed"); 186 } 187 }