jdk/test/sanity/client/SwingSet/src/ToggleButtonDemoTest.java
changeset 37677 9774eca96b01
parent 36744 a00905527ec2
child 39006 fd8c3312d043
equal deleted inserted replaced
37676:24ef455da1b0 37677:9774eca96b01
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
       
    24 import org.jtregext.GuiTestListener;
    24 import com.sun.swingset3.DemoProperties;
    25 import com.sun.swingset3.DemoProperties;
    25 import com.sun.swingset3.demos.togglebutton.DirectionPanel;
    26 import com.sun.swingset3.demos.togglebutton.DirectionPanel;
    26 import com.sun.swingset3.demos.togglebutton.LayoutControlPanel;
    27 import com.sun.swingset3.demos.togglebutton.LayoutControlPanel;
    27 import com.sun.swingset3.demos.togglebutton.ToggleButtonDemo;
    28 import com.sun.swingset3.demos.togglebutton.ToggleButtonDemo;
    28 import static com.sun.swingset3.demos.togglebutton.ToggleButtonDemo.*;
    29 import static com.sun.swingset3.demos.togglebutton.ToggleButtonDemo.*;
    38 import org.netbeans.jemmy.operators.ContainerOperator;
    39 import org.netbeans.jemmy.operators.ContainerOperator;
    39 import org.netbeans.jemmy.operators.JCheckBoxOperator;
    40 import org.netbeans.jemmy.operators.JCheckBoxOperator;
    40 import org.netbeans.jemmy.operators.JFrameOperator;
    41 import org.netbeans.jemmy.operators.JFrameOperator;
    41 import org.netbeans.jemmy.operators.JRadioButtonOperator;
    42 import org.netbeans.jemmy.operators.JRadioButtonOperator;
    42 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
    43 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
    43 import static org.jemmy2ext.JemmyExt.captureDebugInfoOnFail;
    44 import org.testng.annotations.Listeners;
    44 
    45 
    45 /*
    46 /*
    46  * @test
    47  * @test
    47  * @key headful
    48  * @key headful
    48  * @summary Verifies SwingSet3 ToggleButtonDemo by toggling each radio button,
    49  * @summary Verifies SwingSet3 ToggleButtonDemo by toggling each radio button,
    51  *          that those change upon clicking. When toggling radio buttons it
    52  *          that those change upon clicking. When toggling radio buttons it
    52  *          verifies that other radio buttons in the same group are not longer
    53  *          verifies that other radio buttons in the same group are not longer
    53  *          selected.
    54  *          selected.
    54  *
    55  *
    55  * @library /sanity/client/lib/jemmy/src
    56  * @library /sanity/client/lib/jemmy/src
    56  * @library /sanity/client/lib/Jemmy2Ext/src
    57  * @library /sanity/client/lib/Extensions/src
    57  * @library /sanity/client/lib/SwingSet3/src
    58  * @library /sanity/client/lib/SwingSet3/src
    58  * @build org.jemmy2ext.JemmyExt
    59  * @build org.jemmy2ext.JemmyExt
    59  * @build com.sun.swingset3.demos.togglebutton.ToggleButtonDemo
    60  * @build com.sun.swingset3.demos.togglebutton.ToggleButtonDemo
    60  * @run testng ToggleButtonDemoTest
    61  * @run testng ToggleButtonDemoTest
    61  */
    62  */
       
    63 @Listeners(GuiTestListener.class)
    62 public class ToggleButtonDemoTest {
    64 public class ToggleButtonDemoTest {
    63 
    65 
    64     @Test
    66     @Test
    65     public void test() throws Exception {
    67     public void test() throws Exception {
    66         captureDebugInfoOnFail(() -> {
    68         new ClassReference(ToggleButtonDemo.class.getCanonicalName()).startApplication();
    67             new ClassReference(ToggleButtonDemo.class.getCanonicalName()).startApplication();
       
    68 
    69 
    69             JFrameOperator mainFrame = new JFrameOperator(ToggleButtonDemo.class.getAnnotation(DemoProperties.class).value());
    70         JFrameOperator mainFrame = new JFrameOperator(ToggleButtonDemo.class.getAnnotation(DemoProperties.class).value());
    70             JTabbedPaneOperator tabPane = new JTabbedPaneOperator(mainFrame);
    71         JTabbedPaneOperator tabPane = new JTabbedPaneOperator(mainFrame);
    71 
    72 
    72             // Radio Button Toggles
    73         // Radio Button Toggles
    73             testRadioButtons(getBorderTitledJPanelOperator(mainFrame, TEXT_RADIO_BUTTONS), 3, null);
    74         testRadioButtons(getBorderTitledJPanelOperator(mainFrame, TEXT_RADIO_BUTTONS), 3, null);
    74             testRadioButtons(getBorderTitledJPanelOperator(mainFrame, IMAGE_RADIO_BUTTONS), 3, null);
    75         testRadioButtons(getBorderTitledJPanelOperator(mainFrame, IMAGE_RADIO_BUTTONS), 3, null);
    75             testRadioButtons(getLabeledContainerOperator(mainFrame, PAD_AMOUNT), 3, (t, i) -> DEFAULT.equals(t));
    76         testRadioButtons(getLabeledContainerOperator(mainFrame, PAD_AMOUNT), 3, (t, i) -> DEFAULT.equals(t));
    76 
    77 
    77             // switch to the Check Boxes Tab
    78         // switch to the Check Boxes Tab
    78             tabPane.selectPage(CHECK_BOXES);
    79         tabPane.selectPage(CHECK_BOXES);
    79 
    80 
    80             // Check Box Toggles
    81         // Check Box Toggles
    81             ContainerOperator<?> textCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, TEXT_CHECKBOXES);
    82         ContainerOperator<?> textCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, TEXT_CHECKBOXES);
    82             testCheckBox(textCheckBoxesJPanel, CHECK1, false);
    83         testCheckBox(textCheckBoxesJPanel, CHECK1, false);
    83             testCheckBox(textCheckBoxesJPanel, CHECK2, false);
    84         testCheckBox(textCheckBoxesJPanel, CHECK2, false);
    84             testCheckBox(textCheckBoxesJPanel, CHECK3, false);
    85         testCheckBox(textCheckBoxesJPanel, CHECK3, false);
    85 
    86 
    86             ContainerOperator<?> imageCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, IMAGE_CHECKBOXES);
    87         ContainerOperator<?> imageCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, IMAGE_CHECKBOXES);
    87             testCheckBox(imageCheckBoxesJPanel, CHECK1, false);
    88         testCheckBox(imageCheckBoxesJPanel, CHECK1, false);
    88             testCheckBox(imageCheckBoxesJPanel, CHECK2, false);
    89         testCheckBox(imageCheckBoxesJPanel, CHECK2, false);
    89             testCheckBox(imageCheckBoxesJPanel, CHECK3, false);
    90         testCheckBox(imageCheckBoxesJPanel, CHECK3, false);
    90 
    91 
    91             ContainerOperator<?> displayOptionsContainer = getLabeledContainerOperator(mainFrame, DISPLAY_OPTIONS);
    92         ContainerOperator<?> displayOptionsContainer = getLabeledContainerOperator(mainFrame, DISPLAY_OPTIONS);
    92             testCheckBox(displayOptionsContainer, PAINT_BORDER, false);
    93         testCheckBox(displayOptionsContainer, PAINT_BORDER, false);
    93             testCheckBox(displayOptionsContainer, PAINT_FOCUS, true);
    94         testCheckBox(displayOptionsContainer, PAINT_FOCUS, true);
    94             testCheckBox(displayOptionsContainer, ENABLED, true);
    95         testCheckBox(displayOptionsContainer, ENABLED, true);
    95             testCheckBox(displayOptionsContainer, CONTENT_FILLED, true);
    96         testCheckBox(displayOptionsContainer, CONTENT_FILLED, true);
    96 
    97 
    97             // Direction Button Toggles
    98         // Direction Button Toggles
    98             testToggleButtons(mainFrame);
    99         testToggleButtons(mainFrame);
    99         });
       
   100     }
   100     }
   101 
   101 
   102     /**
   102     /**
   103      * The interface is invoked for each radio button providing its name and
   103      * The interface is invoked for each radio button providing its name and
   104      * index and it should return whether the radio button has to be selected.
   104      * index and it should return whether the radio button has to be selected.