Path: blob/master/test/jdk/sanity/client/SwingSet/src/TabbedPaneDemoTest.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.tabbedpane.TabbedPaneDemo;25import static com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo.*;26import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator;27import static org.testng.AssertJUnit.*;28import javax.swing.UIManager;29import org.testng.annotations.Test;30import org.netbeans.jemmy.ClassReference;31import org.netbeans.jemmy.operators.ContainerOperator;32import org.netbeans.jemmy.operators.JFrameOperator;33import org.netbeans.jemmy.operators.JRadioButtonOperator;34import org.netbeans.jemmy.operators.JTabbedPaneOperator;35import org.testng.annotations.Listeners;3637/*38* @test39* @key headful40* @summary Verifies SwingSet3 TabbedPaneDemo by iterating through tab placement41* positions, opening each tab and verifying the the tab gets selected.42*43* @library /sanity/client/lib/jemmy/src44* @library /sanity/client/lib/Extensions/src45* @library /sanity/client/lib/SwingSet3/src46* @modules java.desktop47* java.logging48* @build org.jemmy2ext.JemmyExt49* @build com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo50* @run testng/timeout=600 TabbedPaneDemoTest51*/52@Listeners(GuiTestListener.class)53public class TabbedPaneDemoTest {5455@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)56public void test(String lookAndFeel) throws Exception {57UIManager.setLookAndFeel(lookAndFeel);58new ClassReference(TabbedPaneDemo.class.getCanonicalName()).startApplication();5960JFrameOperator mainFrame = new JFrameOperator(DEMO_TITLE);6162for (String tp : new String[]{TOP, LEFT, BOTTOM, RIGHT}) {63testTabs(mainFrame, tp);64}65}6667public void testTabs(JFrameOperator mainFrame, String tabPlacement) throws Exception {68ContainerOperator<?> rbCont = getLabeledContainerOperator(mainFrame, TAB_PLACEMENT);69new JRadioButtonOperator(rbCont, tabPlacement).doClick();7071final String[] tabTitles = new String[]{CAMILLE, MIRANDA, EWAN, BOUNCE};72for (int i = 0; i < tabTitles.length; i++) {73String pageTitle = tabTitles[i];74JTabbedPaneOperator tabOperator = new JTabbedPaneOperator(mainFrame);75tabOperator.setVerification(true);76tabOperator.selectPage(pageTitle);77}78}7980}818283