< prev index next >
test/java/awt/image/multiresolution/MultiResolutionIcon/MultiResIconTest.java
Print this page
rev 15820 : 8167159: [PIT][TEST_BUG] java/awt/image/multiresolution/MultiResolutionIcon/MultiResIconTest.java
@@ -23,15 +23,17 @@
/**
* @test
* @key headful
* @bug 8149371
+ * @requires (os.family == "linux" | os.family == "mac")
* @summary multi-res. image: -Dsun.java2d.uiScale does not work for Window
* icons (some ambiguity for Window.setIconImages()?)
* @run main/othervm/manual -Dsun.java2d.uiScale=2 MultiResIconTest
*/
import java.awt.Color;
+import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -56,10 +58,11 @@
private static JButton passButton;
private static JButton failButton;
private static JDialog f;
private static CountDownLatch latch;
private static TestFrame frame;
+ private static boolean testPassed = true;
private static BufferedImage generateImage(int x, Color c) {
BufferedImage img = new BufferedImage(x, x, BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
@@ -68,19 +71,10 @@
g.setColor(Color.WHITE);
g.fillRect(x / 3, x / 3, x / 3, x / 3);
return img;
}
- public MultiResIconTest() {
- try {
- latch = new CountDownLatch(1);
- createUI();
- latch.await();
- } catch (Exception ex) {
- }
- }
-
private static void createUI() throws Exception {
SwingUtilities.invokeAndWait(() -> {
frame = new TestFrame();
f = new JDialog(frame);
f.setTitle("Instruction Dialog");
@@ -113,14 +107,14 @@
failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
+ testPassed = false;
latch.countDown();
f.dispose();
frame.dispose();
- throw new RuntimeException("Test Failed");
}
});
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
@@ -189,10 +183,14 @@
public void paint(Graphics gr) {
gr.drawImage(IMG, 0, 0, this);
}
}
- public static void main(String[] args) {
- new MultiResIconTest();
+ public static void main(String[] args) throws Exception {
+ latch = new CountDownLatch(1);
+ new MultiResIconTest().createUI();
+ latch.await();
+ if (!testPassed) {
+ throw new RuntimeException("Test Failed");
+ }
}
}
-
< prev index next >