Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java
38828 views
/*1* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.awt.*;2425/*26* @test27* @summary When Frame.setExtendedState(Frame.MAXIMIZED_BOTH)28* is called for a Frame after been called setMaximizedBounds() with29* certain value, Frame bounds must equal to this value.30*31* @library ../../../../lib/testlibrary32* @build ExtendedRobot33* @run main SetMaximizedBounds34*/3536public class SetMaximizedBounds {3738Frame frame;39Rectangle bound;40boolean supported;41ExtendedRobot robot;42static Rectangle max = new Rectangle(100,100,400,400);4344public void doTest() throws Exception {45robot = new ExtendedRobot();4647EventQueue.invokeAndWait( () -> {48frame = new Frame( "TestFrame ");49frame.setLayout(new FlowLayout());5051if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {52supported = true;53frame.setMaximizedBounds(max);54} else {55supported = false;56}5758frame.setSize(200, 200);59frame.setVisible(true);60});6162robot.waitForIdle(2000);63if (supported) {64EventQueue.invokeAndWait( () -> {65frame.setExtendedState(Frame.MAXIMIZED_BOTH);66});67robot.waitForIdle(2000);68bound = frame.getBounds();69if(!bound.equals(max))70throw new RuntimeException("The bounds of the Frame do not equal to what"71+ " is specified when the frame is in Frame.MAXIMIZED_BOTH state");72} else {73System.out.println("Frame.MAXIMIZED_BOTH not supported");74}7576frame.dispose();77}7879public static void main(String[] args) throws Exception {80String os = System.getProperty("os.name").toLowerCase();81System.out.println(os);82if (os.contains("windows") || os.contains("os x"))83new SetMaximizedBounds().doTest();84else85System.out.println("Platform "+os+" is not supported. Supported platforms are Windows and OS X.");86}87}888990