WindowDemoTest.java revision 13978:1993af50385d
1241675Suqs/* 2241675Suqs * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. 3241675Suqs * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4241675Suqs * 5241675Suqs * This code is free software; you can redistribute it and/or modify it 6241675Suqs * under the terms of the GNU General Public License version 2 only, as 7241675Suqs * published by the Free Software Foundation. 8241675Suqs * 9241675Suqs * This code is distributed in the hope that it will be useful, but WITHOUT 10241675Suqs * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11241675Suqs * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12241675Suqs * version 2 for more details (a copy is included in the LICENSE file that 13241675Suqs * accompanied this code). 14241675Suqs * 15241675Suqs * You should have received a copy of the GNU General Public License version 16241675Suqs * 2 along with this work; if not, write to the Free Software Foundation, 17241675Suqs * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18241675Suqs * 19241675Suqs * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20241675Suqs * or visit www.oracle.com if you need additional information or have any 21241675Suqs * questions. 22241675Suqs */ 23241675Suqs 24241675Suqsimport com.sun.swingset3.demos.window.WindowDemo; 25241675Suqsimport static com.sun.swingset3.demos.window.WindowDemo.*; 26241675Suqsimport static org.jemmy2ext.JemmyExt.*; 27241675Suqsimport static org.testng.AssertJUnit.*; 28241675Suqsimport org.testng.annotations.Test; 29241675Suqsimport org.netbeans.jemmy.ClassReference; 30241675Suqsimport org.netbeans.jemmy.operators.JButtonOperator; 31241675Suqsimport org.netbeans.jemmy.operators.JFrameOperator; 32241675Suqsimport org.netbeans.jemmy.operators.JLabelOperator; 33241675Suqsimport org.netbeans.jemmy.operators.WindowOperator; 34241675Suqs 35241675Suqs/* 36241675Suqs * @test 37241675Suqs * @key headful 38241675Suqs * @summary Verifies SwingSet3 WindowDemo by checking that separate JWindow is 39241675Suqs * shown, it contains predefined label and no new windows are opened 40241675Suqs * when the "Show JWindow..." button is clicked. 41241675Suqs * 42241675Suqs * @library /sanity/client/lib/jemmy/src 43241675Suqs * @library /sanity/client/lib/Jemmy2Ext/src 44241675Suqs * @library /sanity/client/lib/SwingSet3/src 45241675Suqs * @build org.jemmy2ext.JemmyExt 46241675Suqs * @build com.sun.swingset3.demos.window.WindowDemo 47241675Suqs * @run testng WindowDemoTest 48241675Suqs */ 49241675Suqspublic class WindowDemoTest { 50241675Suqs 51241675Suqs @Test 52241675Suqs public void test() throws Exception { 53241675Suqs captureDebugInfoOnFail(() -> { 54241675Suqs new ClassReference(WindowDemo.class.getCanonicalName()).startApplication(); 55241675Suqs 56241675Suqs JFrameOperator frame = new JFrameOperator(); 57241675Suqs 58241675Suqs assertEquals("Only one JWindow is shown", 1, getJWindowCount()); 59241675Suqs 60241675Suqs WindowOperator window = new WindowOperator(getJWindow()); 61241675Suqs 62241675Suqs assertTrue("JFrame is showing", frame.isShowing()); 63241675Suqs assertFalse("JFrame is not iconified", isIconified(frame)); 64241675Suqs assertTrue("JWindow is showing", window.isShowing()); 65241675Suqs 66241675Suqs final String labelText = I_HAVE_NO_SYSTEM_BORDER; 67241675Suqs JLabelOperator jLabelOperator = new JLabelOperator(window, labelText); 68241675Suqs assertEquals("JWindow contains the label with corresponding text", labelText, jLabelOperator.getText()); 69241675Suqs 70241675Suqs new JButtonOperator(frame, SHOW_J_WINDOW).push(); 71241675Suqs 72241675Suqs assertEquals("Only one JWindow is shown", 1, getJWindowCount()); 73241675Suqs }); 74241675Suqs } 75241675Suqs 76241675Suqs} 77241675Suqs