TabbedPaneDemoTest.java revision 13978:1993af50385d
1296907Smmel/* 2296907Smmel * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. 3296907Smmel * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4296907Smmel * 5296907Smmel * This code is free software; you can redistribute it and/or modify it 6296907Smmel * under the terms of the GNU General Public License version 2 only, as 7296907Smmel * published by the Free Software Foundation. 8296907Smmel * 9296907Smmel * This code is distributed in the hope that it will be useful, but WITHOUT 10296907Smmel * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11296907Smmel * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12296907Smmel * version 2 for more details (a copy is included in the LICENSE file that 13296907Smmel * accompanied this code). 14296907Smmel * 15296907Smmel * You should have received a copy of the GNU General Public License version 16296907Smmel * 2 along with this work; if not, write to the Free Software Foundation, 17296907Smmel * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18296907Smmel * 19296907Smmel * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20296907Smmel * or visit www.oracle.com if you need additional information or have any 21296907Smmel * questions. 22296907Smmel */ 23296907Smmel 24296907Smmelimport com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo; 25296907Smmelimport static com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo.*; 26296907Smmelimport static org.jemmy2ext.JemmyExt.getLabeledContainerOperator; 27296907Smmelimport static org.testng.AssertJUnit.*; 28296907Smmelimport org.testng.annotations.Test; 29296907Smmelimport org.netbeans.jemmy.ClassReference; 30296907Smmelimport org.netbeans.jemmy.operators.ContainerOperator; 31296907Smmelimport org.netbeans.jemmy.operators.JFrameOperator; 32296907Smmelimport org.netbeans.jemmy.operators.JRadioButtonOperator; 33296907Smmelimport org.netbeans.jemmy.operators.JTabbedPaneOperator; 34296907Smmelimport static org.jemmy2ext.JemmyExt.captureDebugInfoOnFail; 35296907Smmel 36296907Smmel/* 37296907Smmel * @test 38296907Smmel * @key headful 39296907Smmel * @summary Verifies SwingSet3 TabbedPaneDemo by iterating through tab placement 40296907Smmel * positions, opening each tab and verifying the the tab gets selected. 41296907Smmel * 42296907Smmel * @library /sanity/client/lib/jemmy/src 43296907Smmel * @library /sanity/client/lib/Jemmy2Ext/src 44296907Smmel * @library /sanity/client/lib/SwingSet3/src 45296907Smmel * @build org.jemmy2ext.JemmyExt 46296907Smmel * @build com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo 47296907Smmel * @run testng TabbedPaneDemoTest 48296907Smmel */ 49296907Smmelpublic class TabbedPaneDemoTest { 50296907Smmel 51296907Smmel @Test 52296907Smmel public void test() throws Exception { 53296907Smmel captureDebugInfoOnFail(() -> { 54296907Smmel new ClassReference(TabbedPaneDemo.class.getCanonicalName()).startApplication(); 55296907Smmel 56296907Smmel JFrameOperator mainFrame = new JFrameOperator(DEMO_TITLE); 57296907Smmel 58296907Smmel for (String tp : new String[]{TOP, LEFT, BOTTOM, RIGHT}) { 59296907Smmel testTabs(mainFrame, tp); 60296907Smmel } 61296907Smmel }); 62296907Smmel } 63296907Smmel 64296907Smmel public void testTabs(JFrameOperator mainFrame, String tabPlacement) throws Exception { 65296907Smmel ContainerOperator<?> rbCont = getLabeledContainerOperator(mainFrame, TAB_PLACEMENT); 66296907Smmel new JRadioButtonOperator(rbCont, tabPlacement).doClick(); 67296907Smmel 68296907Smmel final String[] tabTitles = new String[]{CAMILLE, MIRANDA, EWAN, BOUNCE}; 69296907Smmel for (int i = 0; i < tabTitles.length; i++) { 70296907Smmel String pageTitle = tabTitles[i]; 71296907Smmel JTabbedPaneOperator tabOperator = new JTabbedPaneOperator(mainFrame); 72296907Smmel tabOperator.selectPage(pageTitle); 73296907Smmel 74296907Smmel assertEquals("Selected tab is selected", i, tabOperator.getSelectedIndex()); 75296907Smmel } 76296907Smmel } 77296907Smmel 78296907Smmel} 79296907Smmel