Path: blob/master/test/jdk/sanity/client/SwingSet/src/TestHelpers.java
41153 views
/*1* Copyright (c) 2018, 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.Point;2526import javax.swing.UIManager;2728import org.netbeans.jemmy.operators.ComponentOperator;29import org.testng.annotations.DataProvider;3031public class TestHelpers {3233public static final long DELAY_BTWN_FRAME_STATE_CHANGE = 2000;3435/**36* A DataProvider having the class name of all the available look and feels37*38* @return a 2d Object array containing the class name of all the available39* look and feels40*/41@DataProvider(name = "availableLookAndFeels")42public static Object[][] provideAvailableLookAndFeels() {43UIManager.LookAndFeelInfo LookAndFeelInfos[]44= UIManager.getInstalledLookAndFeels();45Object[][] lookAndFeels = new Object[LookAndFeelInfos.length][1];46for (int i = 0; i < LookAndFeelInfos.length; i++) {47lookAndFeels[i][0] = LookAndFeelInfos[i].getClassName();48}49return lookAndFeels;50}5152public static void checkChangeLocation(ComponentOperator component,53Point finalLocation) throws InterruptedException {54Point initialLocation = component.getLocation();55component.setLocation(finalLocation);56component.waitComponentLocation(finalLocation);57// TODO This is a workaround for JDK-8210638, this delay has to remove58// after fixing this bug, this is an unstable code.59delayBetweenFrameStateChange();60component.setLocation(initialLocation);61component.waitComponentLocation(initialLocation);62// TODO This is a workaround for JDK-8210638, this delay has to remove63// after fixing this bug, this is an unstable code.64delayBetweenFrameStateChange();65}6667public static void checkChangeSize(ComponentOperator component,68Dimension dimensionFinal) throws InterruptedException {69Dimension dimensionInitial = component.getSize();70component.setSize(dimensionFinal);71component.waitComponentSize(dimensionFinal);72// TODO This is a workaround for JDK-8210638, this delay has to remove73// after fixing this bug, this is an unstable code.74delayBetweenFrameStateChange();75component.setSize(dimensionInitial);76component.waitComponentSize(dimensionInitial);77// TODO This is a workaround for JDK-8210638, this delay has to remove78// after fixing this bug, this is an unstable code.79delayBetweenFrameStateChange();80}8182// TODO This is a workaround for JDK-8210638, this delay has to remove83// after fixing this bug, this is an unstable code.84public static void delayBetweenFrameStateChange()85throws InterruptedException {86Thread.sleep(DELAY_BTWN_FRAME_STATE_CHANGE);87}8889}9091