Path: blob/master/test/jdk/sanity/client/SwingSet/src/ComboBoxDemoTest.java
41153 views
/*1* Copyright (c) 2010, 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.combobox.ComboBoxDemo;25import static org.testng.AssertJUnit.*;26import javax.swing.UIManager;27import org.testng.annotations.Test;28import org.netbeans.jemmy.ClassReference;29import org.netbeans.jemmy.operators.JComboBoxOperator;30import org.netbeans.jemmy.operators.JFrameOperator;31import static com.sun.swingset3.demos.combobox.ComboBoxDemo.*;32import org.testng.annotations.Listeners;3334/*35* @test36* @key headful37* @summary Verifies ComboBoxes on SwingSet2 ComboBoxDemo page by selecting38* each value of each ComboBox.39*40* @library /sanity/client/lib/jemmy/src41* @library /sanity/client/lib/Extensions/src42* @library /sanity/client/lib/SwingSet3/src43* @modules java.desktop44* java.logging45* @build org.jemmy2ext.JemmyExt46* @build com.sun.swingset3.demos.combobox.ComboBoxDemo47* @run testng/timeout=600 ComboBoxDemoTest48*/49@Listeners(GuiTestListener.class)50public class ComboBoxDemoTest {5152private static enum ComboBoxInfo {5354PRESETS("Presets:"),55HAIR("Hair:"),56EYES_N_NOSE("Eyes & Nose:"),57MOUTH("Mouth:");5859private final String comboBoxName;6061private ComboBoxInfo(String comboBoxName) {62this.comboBoxName = comboBoxName;63}6465}6667@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)68public void test(String lookAndFeel) throws Exception {69UIManager.setLookAndFeel(lookAndFeel);70new ClassReference(ComboBoxDemo.class.getCanonicalName()).startApplication();7172JFrameOperator frame = new JFrameOperator(DEMO_TITLE);73for (ComboBoxInfo comboBoxInfo : ComboBoxInfo.values()) {74comboBoxChecker(frame, comboBoxInfo);75}76}7778private void comboBoxChecker(JFrameOperator jfo, ComboBoxInfo comboBoxInfo) {79JComboBoxOperator jcbo = new JComboBoxOperator(jfo, comboBoxInfo.ordinal());80for (int i = 0; i < jcbo.getItemCount(); i++) {81jcbo.selectItem(i);82jcbo.waitItemSelected(i);83}84}8586}878889