< prev index next >

test/sanity/client/SwingSet/src/TabbedPaneDemoTest.java

Print this page




  26 import static com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo.*;
  27 import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator;
  28 import static org.testng.AssertJUnit.*;
  29 import org.testng.annotations.Test;
  30 import org.netbeans.jemmy.ClassReference;
  31 import org.netbeans.jemmy.operators.ContainerOperator;
  32 import org.netbeans.jemmy.operators.JFrameOperator;
  33 import org.netbeans.jemmy.operators.JRadioButtonOperator;
  34 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
  35 import org.testng.annotations.Listeners;
  36 
  37 /*
  38  * @test
  39  * @key headful
  40  * @summary Verifies SwingSet3 TabbedPaneDemo by iterating through tab placement
  41  *          positions, opening each tab and verifying the the tab gets selected.
  42  *
  43  * @library /sanity/client/lib/jemmy/src
  44  * @library /sanity/client/lib/Extensions/src
  45  * @library /sanity/client/lib/SwingSet3/src

  46  * @build org.jemmy2ext.JemmyExt
  47  * @build com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo
  48  * @run testng TabbedPaneDemoTest
  49  */
  50 @Listeners(GuiTestListener.class)
  51 public class TabbedPaneDemoTest {
  52 
  53     @Test
  54     public void test() throws Exception {
  55         new ClassReference(TabbedPaneDemo.class.getCanonicalName()).startApplication();
  56 
  57         JFrameOperator mainFrame = new JFrameOperator(DEMO_TITLE);
  58 
  59         for (String tp : new String[]{TOP, LEFT, BOTTOM, RIGHT}) {
  60             testTabs(mainFrame, tp);
  61         }
  62     }
  63 
  64     public void testTabs(JFrameOperator mainFrame, String tabPlacement) throws Exception {
  65         ContainerOperator<?> rbCont = getLabeledContainerOperator(mainFrame, TAB_PLACEMENT);
  66         new JRadioButtonOperator(rbCont, tabPlacement).doClick();
  67 
  68         final String[] tabTitles = new String[]{CAMILLE, MIRANDA, EWAN, BOUNCE};
  69         for (int i = 0; i < tabTitles.length; i++) {
  70             String pageTitle = tabTitles[i];
  71             JTabbedPaneOperator tabOperator = new JTabbedPaneOperator(mainFrame);

  72             tabOperator.selectPage(pageTitle);
  73 
  74             assertEquals("Selected tab is selected", i, tabOperator.getSelectedIndex());
  75         }
  76     }
  77 
  78 }


  26 import static com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo.*;
  27 import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator;
  28 import static org.testng.AssertJUnit.*;
  29 import org.testng.annotations.Test;
  30 import org.netbeans.jemmy.ClassReference;
  31 import org.netbeans.jemmy.operators.ContainerOperator;
  32 import org.netbeans.jemmy.operators.JFrameOperator;
  33 import org.netbeans.jemmy.operators.JRadioButtonOperator;
  34 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
  35 import org.testng.annotations.Listeners;
  36 
  37 /*
  38  * @test
  39  * @key headful
  40  * @summary Verifies SwingSet3 TabbedPaneDemo by iterating through tab placement
  41  *          positions, opening each tab and verifying the the tab gets selected.
  42  *
  43  * @library /sanity/client/lib/jemmy/src
  44  * @library /sanity/client/lib/Extensions/src
  45  * @library /sanity/client/lib/SwingSet3/src
  46  * @modules java.desktop
  47  * @build org.jemmy2ext.JemmyExt
  48  * @build com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo
  49  * @run testng TabbedPaneDemoTest
  50  */
  51 @Listeners(GuiTestListener.class)
  52 public class TabbedPaneDemoTest {
  53 
  54     @Test
  55     public void test() throws Exception {
  56         new ClassReference(TabbedPaneDemo.class.getCanonicalName()).startApplication();
  57 
  58         JFrameOperator mainFrame = new JFrameOperator(DEMO_TITLE);
  59 
  60         for (String tp : new String[]{TOP, LEFT, BOTTOM, RIGHT}) {
  61             testTabs(mainFrame, tp);
  62         }
  63     }
  64 
  65     public void testTabs(JFrameOperator mainFrame, String tabPlacement) throws Exception {
  66         ContainerOperator<?> rbCont = getLabeledContainerOperator(mainFrame, TAB_PLACEMENT);
  67         new JRadioButtonOperator(rbCont, tabPlacement).doClick();
  68 
  69         final String[] tabTitles = new String[]{CAMILLE, MIRANDA, EWAN, BOUNCE};
  70         for (int i = 0; i < tabTitles.length; i++) {
  71             String pageTitle = tabTitles[i];
  72             JTabbedPaneOperator tabOperator = new JTabbedPaneOperator(mainFrame);
  73             tabOperator.setVerification(true);
  74             tabOperator.selectPage(pageTitle);


  75         }
  76     }
  77 
  78 }
< prev index next >