Path: blob/master/test/jdk/sanity/client/SwingSet/src/WindowDemoTest.java
41153 views
/*1* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import org.jtregext.GuiTestListener;24import com.sun.swingset3.demos.window.WindowDemo;25import static com.sun.swingset3.demos.window.WindowDemo.*;26import static org.jemmy2ext.JemmyExt.*;27import static org.testng.AssertJUnit.*;28import javax.swing.UIManager;29import org.testng.annotations.Test;30import org.netbeans.jemmy.ClassReference;31import org.netbeans.jemmy.operators.JButtonOperator;32import org.netbeans.jemmy.operators.JFrameOperator;33import org.netbeans.jemmy.operators.JLabelOperator;34import org.netbeans.jemmy.operators.WindowOperator;35import org.testng.annotations.Listeners;3637/*38* @test39* @key headful40* @summary Verifies SwingSet3 WindowDemo by checking that separate JWindow is41* shown, it contains predefined label and no new windows are opened42* when the "Show JWindow..." button is clicked.43*44* @library /sanity/client/lib/jemmy/src45* @library /sanity/client/lib/Extensions/src46* @library /sanity/client/lib/SwingSet3/src47* @modules java.desktop48* java.logging49* @build org.jemmy2ext.JemmyExt50* @build com.sun.swingset3.demos.window.WindowDemo51* @run testng/timeout=600 WindowDemoTest52*/53@Listeners(GuiTestListener.class)54public class WindowDemoTest {5556@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)57public void test(String lookAndFeel) throws Exception {58UIManager.setLookAndFeel(lookAndFeel);5960new ClassReference(WindowDemo.class.getCanonicalName()).startApplication();6162JFrameOperator frame = new JFrameOperator();6364assertEquals("Only one JWindow is shown", 1, getJWindowCount());6566WindowOperator window = new WindowOperator(getJWindow());6768assertTrue("JFrame is showing", frame.isShowing());69assertFalse("JFrame is not iconified", isIconified(frame));70assertTrue("JWindow is showing", window.isShowing());7172final String labelText = I_HAVE_NO_SYSTEM_BORDER;73JLabelOperator jLabelOperator = new JLabelOperator(window, labelText);74assertEquals("JWindow contains the label with corresponding text", labelText, jLabelOperator.getText());7576new JButtonOperator(frame, SHOW_J_WINDOW).push();7778assertEquals("Only one JWindow is shown", 1, getJWindowCount());79}8081}828384