51886
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, 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 |
|
44131
|
24 |
import java.awt.Dimension;
|
|
25 |
import java.awt.Point;
|
51886
|
26 |
|
50661
|
27 |
import javax.swing.UIManager;
|
51886
|
28 |
|
44131
|
29 |
import org.netbeans.jemmy.operators.ComponentOperator;
|
50661
|
30 |
import org.testng.annotations.DataProvider;
|
44131
|
31 |
|
|
32 |
public class TestHelpers {
|
|
33 |
|
51886
|
34 |
public static final long DELAY_BTWN_FRAME_STATE_CHANGE = 2000;
|
|
35 |
|
50661
|
36 |
/**
|
|
37 |
* A DataProvider having the class name of all the available look and feels
|
|
38 |
*
|
|
39 |
* @return a 2d Object array containing the class name of all the available
|
|
40 |
* look and feels
|
|
41 |
*/
|
|
42 |
@DataProvider(name = "availableLookAndFeels")
|
|
43 |
public static Object[][] provideAvailableLookAndFeels() {
|
|
44 |
UIManager.LookAndFeelInfo LookAndFeelInfos[]
|
|
45 |
= UIManager.getInstalledLookAndFeels();
|
|
46 |
Object[][] lookAndFeels = new Object[LookAndFeelInfos.length][1];
|
|
47 |
for (int i = 0; i < LookAndFeelInfos.length; i++) {
|
|
48 |
lookAndFeels[i][0] = LookAndFeelInfos[i].getClassName();
|
|
49 |
}
|
|
50 |
return lookAndFeels;
|
|
51 |
}
|
|
52 |
|
44131
|
53 |
public static void checkChangeLocation(ComponentOperator component,
|
51886
|
54 |
Point finalLocation) throws InterruptedException {
|
44131
|
55 |
Point initialLocation = component.getLocation();
|
|
56 |
component.setLocation(finalLocation);
|
|
57 |
component.waitComponentLocation(finalLocation);
|
51886
|
58 |
// TODO This is a workaround for JDK-8210638, this delay has to remove
|
|
59 |
// after fixing this bug, this is an unstable code.
|
|
60 |
delayBetweenFrameStateChange();
|
44131
|
61 |
component.setLocation(initialLocation);
|
50661
|
62 |
component.waitComponentLocation(initialLocation);
|
51886
|
63 |
// TODO This is a workaround for JDK-8210638, this delay has to remove
|
|
64 |
// after fixing this bug, this is an unstable code.
|
|
65 |
delayBetweenFrameStateChange();
|
44131
|
66 |
}
|
|
67 |
|
|
68 |
public static void checkChangeSize(ComponentOperator component,
|
51886
|
69 |
Dimension dimensionFinal) throws InterruptedException {
|
44131
|
70 |
Dimension dimensionInitial = component.getSize();
|
|
71 |
component.setSize(dimensionFinal);
|
|
72 |
component.waitComponentSize(dimensionFinal);
|
51886
|
73 |
// TODO This is a workaround for JDK-8210638, this delay has to remove
|
|
74 |
// after fixing this bug, this is an unstable code.
|
|
75 |
delayBetweenFrameStateChange();
|
44131
|
76 |
component.setSize(dimensionInitial);
|
50661
|
77 |
component.waitComponentSize(dimensionInitial);
|
51886
|
78 |
// TODO This is a workaround for JDK-8210638, this delay has to remove
|
|
79 |
// after fixing this bug, this is an unstable code.
|
|
80 |
delayBetweenFrameStateChange();
|
44131
|
81 |
}
|
50661
|
82 |
|
51886
|
83 |
// TODO This is a workaround for JDK-8210638, this delay has to remove
|
|
84 |
// after fixing this bug, this is an unstable code.
|
|
85 |
public static void delayBetweenFrameStateChange()
|
|
86 |
throws InterruptedException {
|
|
87 |
Thread.sleep(DELAY_BTWN_FRAME_STATE_CHANGE);
|
|
88 |
}
|
|
89 |
|
|
90 |
} |