1 /* 2 * Copyright (c) 2019, 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package quality.metal; 27 28 import org.junit.Test; 29 import quality.util.RenderUtil; 30 31 import javax.swing.*; 32 import java.awt.*; 33 import java.awt.image.BufferedImage; 34 35 public class MetalRenderTest { 36 37 @Test 38 public void testMetal() throws Exception { 39 BufferedImage bi = RenderUtil.capture(120, 120, 40 graphics2D -> { 41 graphics2D.setColor(Color.GREEN); 42 graphics2D.fillRect(10, 10, 50, 50); 43 graphics2D.setColor(Color.RED); 44 graphics2D.fillOval(30, 30, 150, 150); 45 46 }); 47 RenderUtil.checkImage(bi, "metal", "geom.png"); 48 } 49 @Test 50 public void testMetal1() throws Exception { 51 JFrame[] f = new JFrame[1]; 52 SwingUtilities.invokeAndWait(() -> { 53 f[0] = new JFrame(); 54 55 f[0].setSize(300, 300); 56 // for frame border effects, 57 // e.g. rounded frame 58 f[0].setVisible(true); 59 }); 60 61 Thread.sleep(4000); 62 } 63 64 @Test 65 public void testMetal2() throws Exception { 66 Frame[] f = new Frame[1]; 67 SwingUtilities.invokeAndWait(() -> { 68 f[0] = new Frame(); 69 70 f[0].setSize(300, 300); 71 // for frame border effects, 72 // e.g. rounded frame 73 f[0].setVisible(true); 74 }); 75 76 Thread.sleep(4000); 77 } 78 }