Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sanity/client/SwingSet/src/TestHelpers.java
41153 views
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
24
import java.awt.Dimension;
25
import java.awt.Point;
26
27
import javax.swing.UIManager;
28
29
import org.netbeans.jemmy.operators.ComponentOperator;
30
import org.testng.annotations.DataProvider;
31
32
public class TestHelpers {
33
34
public static final long DELAY_BTWN_FRAME_STATE_CHANGE = 2000;
35
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
53
public static void checkChangeLocation(ComponentOperator component,
54
Point finalLocation) throws InterruptedException {
55
Point initialLocation = component.getLocation();
56
component.setLocation(finalLocation);
57
component.waitComponentLocation(finalLocation);
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();
61
component.setLocation(initialLocation);
62
component.waitComponentLocation(initialLocation);
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();
66
}
67
68
public static void checkChangeSize(ComponentOperator component,
69
Dimension dimensionFinal) throws InterruptedException {
70
Dimension dimensionInitial = component.getSize();
71
component.setSize(dimensionFinal);
72
component.waitComponentSize(dimensionFinal);
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();
76
component.setSize(dimensionInitial);
77
component.waitComponentSize(dimensionInitial);
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();
81
}
82
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
}
91