Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Frame/SetIconImagesCrashTest/SetIconImagesCrashTest.java
41154 views
1
/*
2
* Copyright (c) 2016, 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
/*
25
* @test
26
* @key headful
27
* @bug 8166980
28
* @summary Test to check Window.setIconImages() does not result in crash when
29
* a frame is shown
30
* @run main/othervm SetIconImagesCrashTest
31
* @run main/othervm -Dsun.java2d.uiScale=2 SetIconImagesCrashTest
32
*/
33
34
import java.awt.Color;
35
import java.awt.Graphics;
36
import java.awt.Window;
37
import java.awt.Frame;
38
import java.util.List;
39
import java.awt.image.BufferedImage;
40
import java.util.ArrayList;
41
import javax.swing.SwingUtilities;
42
43
public class SetIconImagesCrashTest {
44
45
public static void main(String[] args) throws Exception {
46
47
List<BufferedImage> imageList = new ArrayList<BufferedImage>();
48
imageList.add(new BufferedImage(200, 200,
49
BufferedImage.TYPE_BYTE_BINARY));
50
51
for (int i = 0; i < 10; i++) {
52
Frame f = new Frame();
53
test(f, imageList);
54
}
55
}
56
57
public static void test(final Window window,
58
final List<BufferedImage> imageList) throws Exception {
59
60
SwingUtilities.invokeAndWait(new Runnable() {
61
@Override
62
public void run() {
63
for (BufferedImage image : imageList) {
64
Graphics graphics = image.getGraphics();
65
graphics.setColor(Color.RED);
66
graphics.fillRect(
67
0, 0, image.getWidth(), image.getHeight());
68
graphics.dispose();
69
}
70
71
window.setIconImages(imageList);
72
window.setSize(200, 200);
73
window.setVisible(true);
74
}
75
});
76
77
while (!window.isVisible()) {
78
Thread.sleep((long) (20));
79
}
80
81
Thread.sleep((long) (50));
82
83
SwingUtilities.invokeAndWait(new Runnable() {
84
@Override
85
public void run() {
86
window.setVisible(false);
87
window.dispose();
88
}
89
});
90
}
91
}
92
93
94