Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/ScrollPane/ScrollPanePreferredSize/ScrollPanePreferredSize.java
47826 views
/*1* Copyright (c) 2012, 2013, 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.Dimension;24import java.awt.Frame;25import java.awt.ScrollPane;26import java.awt.Toolkit;2728/**29* @test30* @bug 712421331* @author Sergey Bylokhov32* @library ../../../../lib/testlibrary/33* @build ExtendedRobot34* @run main ScrollPanePreferredSize35*/36public final class ScrollPanePreferredSize {3738public static void main(final String[] args) {39final Dimension expected = new Dimension(300, 300);40final Frame frame = new Frame();41final ScrollPane sp = new ScrollPane();42sp.setSize(expected);43frame.add(sp);44frame.pack();45frame.setLocationRelativeTo(null);46frame.setVisible(true);47sleep();48final Dimension size = frame.getSize();49if (size.width < expected.width || size.height < expected.height) {50throw new RuntimeException(51"Expected size: >= " + expected + ", actual size: " + size);52}53frame.dispose();54}5556private static void sleep() {57try {58ExtendedRobot robot = new ExtendedRobot();59robot.waitForIdle(500);60} catch (Exception ex) {61ex.printStackTrace();62throw new RuntimeException("Unexpected failure");63}64}65}666768