1 /* 2 * Copyright (c) 2011, 2013, 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 * @summary <rdar://problem/3967850> Confirm that windows of 0,0 size correctly report themselves as 0,0 27 * @summary com.apple.junit.java.awt.Window 28 * @run junit R3967850MinWindowSize 29 */ 30 31 import junit.framework.*; 32 import java.awt.*; 33 34 public class R3967850MinWindowSize extends TestCase { 35 36 // This test confirms that we correctly report windows with 0,0 size 37 // 38 // See bug <rdar://problem/3967850> JCK: Window2003 test started failing between 1/11 and 1/14 39 // 40 // Even though when creating windows of size 0,0 we may still internally be creating windows that 41 // have a minimum size of 1,1 (see also bug 3969845), we should report the size as 0,0 if asked. 42 // 43 // TODO: This begs to be generalized a little more, so we create several windows with various parameters, 44 // and expect specific size reports from them. A loop with a vector of parameters and expected results. 45 // 46 47 public static Test suite() { 48 return new TestSuite(R3967850MinWindowSize.class); 49 } 50 51 public static void main (String[] args) throws RuntimeException { 52 TestResult tr = junit.textui.TestRunner.run(suite()); 53 if ((tr.errorCount() != 0) || (tr.failureCount() != 0)) { 54 throw new RuntimeException("### FAILED: unexpected JUnit errors or failures."); 55 } 56 } 57 58 public void testDefaultWindow() throws Exception { 59 Frame frame = new Frame("Default Window"); 60 Window win = new Window(frame); 61 win.pack(); 62 Dimension winSize = win.getSize(); 63 Dimension winPreferredSize = win.getPreferredSize(); 64 // System.out.println("win.getSize " + win.getSize()); 65 // System.out.println("win.getPreferredSize " + win.getPreferredSize()); 66 assertEquals("expected default window width to be 0", 0, winSize.width); 67 assertEquals("expected default window height to be 0", 0, winSize.height); 68 assertEquals("expected window size and preferred size to match", winSize, winPreferredSize); 69 win.dispose(); 70 frame.dispose(); 71 } 72 73 } 74