jdk/test/sanity/client/SwingSet/src/ToggleButtonDemoTest.java
author amurillo
Mon, 22 Aug 2016 15:27:50 -0700
changeset 40529 7bf112d991eb
parent 39006 fd8c3312d043
permissions -rw-r--r--
8164589: Remove sun/rmi/runtime/Log/6409194/NoConsoleOutput.java from ProblemList Reviewed-by: jwilhelm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     1
/*
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     2
 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     4
 *
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     8
 *
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    13
 * accompanied this code).
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    14
 *
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    18
 *
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    21
 * questions.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    22
 */
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    23
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    24
import org.jtregext.GuiTestListener;
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    25
import com.sun.swingset3.DemoProperties;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    26
import com.sun.swingset3.demos.togglebutton.DirectionPanel;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    27
import com.sun.swingset3.demos.togglebutton.LayoutControlPanel;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    28
import com.sun.swingset3.demos.togglebutton.ToggleButtonDemo;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    29
import static com.sun.swingset3.demos.togglebutton.ToggleButtonDemo.*;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    30
import java.util.function.BiFunction;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    31
import org.jemmy2ext.JemmyExt.ByClassChooser;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    32
import static org.jemmy2ext.JemmyExt.EXACT_STRING_COMPARATOR;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    33
import static org.jemmy2ext.JemmyExt.getBorderTitledJPanelOperator;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    34
import static org.jemmy2ext.JemmyExt.getLabeledContainerOperator;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    35
import static org.testng.AssertJUnit.*;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    36
import org.testng.annotations.Test;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    37
import org.netbeans.jemmy.ClassReference;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    38
import org.netbeans.jemmy.ComponentChooser;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    39
import org.netbeans.jemmy.operators.ContainerOperator;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    40
import org.netbeans.jemmy.operators.JCheckBoxOperator;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    41
import org.netbeans.jemmy.operators.JFrameOperator;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    42
import org.netbeans.jemmy.operators.JRadioButtonOperator;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    43
import org.netbeans.jemmy.operators.JTabbedPaneOperator;
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    44
import org.testng.annotations.Listeners;
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    45
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    46
/*
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    47
 * @test
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    48
 * @key headful
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    49
 * @summary Verifies SwingSet3 ToggleButtonDemo by toggling each radio button,
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    50
 *          each checkbox and each location of the direction dial toggle.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    51
 *          It verifies initial selected values for all the elements and checks
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    52
 *          that those change upon clicking. When toggling radio buttons it
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    53
 *          verifies that other radio buttons in the same group are not longer
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    54
 *          selected.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    55
 *
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    56
 * @library /sanity/client/lib/jemmy/src
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    57
 * @library /sanity/client/lib/Extensions/src
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    58
 * @library /sanity/client/lib/SwingSet3/src
39006
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
    59
 * @modules java.desktop
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
    60
 *          java.logging
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    61
 * @build org.jemmy2ext.JemmyExt
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    62
 * @build com.sun.swingset3.demos.togglebutton.ToggleButtonDemo
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    63
 * @run testng ToggleButtonDemoTest
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    64
 */
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    65
@Listeners(GuiTestListener.class)
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    66
public class ToggleButtonDemoTest {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    67
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    68
    @Test
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    69
    public void test() throws Exception {
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    70
        new ClassReference(ToggleButtonDemo.class.getCanonicalName()).startApplication();
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    71
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    72
        JFrameOperator mainFrame = new JFrameOperator(ToggleButtonDemo.class.getAnnotation(DemoProperties.class).value());
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    73
        JTabbedPaneOperator tabPane = new JTabbedPaneOperator(mainFrame);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    74
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    75
        // Radio Button Toggles
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    76
        testRadioButtons(getBorderTitledJPanelOperator(mainFrame, TEXT_RADIO_BUTTONS), 3, null);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    77
        testRadioButtons(getBorderTitledJPanelOperator(mainFrame, IMAGE_RADIO_BUTTONS), 3, null);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    78
        testRadioButtons(getLabeledContainerOperator(mainFrame, PAD_AMOUNT), 3, (t, i) -> DEFAULT.equals(t));
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    79
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    80
        // switch to the Check Boxes Tab
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    81
        tabPane.selectPage(CHECK_BOXES);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    82
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    83
        // Check Box Toggles
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    84
        ContainerOperator<?> textCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, TEXT_CHECKBOXES);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    85
        testCheckBox(textCheckBoxesJPanel, CHECK1, false);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    86
        testCheckBox(textCheckBoxesJPanel, CHECK2, false);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    87
        testCheckBox(textCheckBoxesJPanel, CHECK3, false);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    88
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    89
        ContainerOperator<?> imageCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, IMAGE_CHECKBOXES);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    90
        testCheckBox(imageCheckBoxesJPanel, CHECK1, false);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    91
        testCheckBox(imageCheckBoxesJPanel, CHECK2, false);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    92
        testCheckBox(imageCheckBoxesJPanel, CHECK3, false);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    93
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    94
        ContainerOperator<?> displayOptionsContainer = getLabeledContainerOperator(mainFrame, DISPLAY_OPTIONS);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    95
        testCheckBox(displayOptionsContainer, PAINT_BORDER, false);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    96
        testCheckBox(displayOptionsContainer, PAINT_FOCUS, true);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    97
        testCheckBox(displayOptionsContainer, ENABLED, true);
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
    98
        testCheckBox(displayOptionsContainer, CONTENT_FILLED, true);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
    99
37677
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
   100
        // Direction Button Toggles
9774eca96b01 8154381: SwingSet tests are not auto closed in jtreg
mrkam
parents: 36744
diff changeset
   101
        testToggleButtons(mainFrame);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   102
    }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   103
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   104
    /**
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   105
     * The interface is invoked for each radio button providing its name and
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   106
     * index and it should return whether the radio button has to be selected.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   107
     */
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   108
    private static interface SelectedRadioButton extends BiFunction<String, Integer, Boolean> {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   109
    }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   110
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   111
    /**
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   112
     * Tests a group of radio buttons
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   113
     *
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   114
     * @param parent container containing the buttons
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   115
     * @param radioButtonCount number of radio buttons
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   116
     * @param selectedRadioButton initial selected radio button
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   117
     */
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   118
    private void testRadioButtons(ContainerOperator<?> parent, int radioButtonCount, SelectedRadioButton selectedRadioButton) {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   119
        JRadioButtonOperator[] jrbo = new JRadioButtonOperator[radioButtonCount];
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   120
        for (int i = 0; i < radioButtonCount; i++) {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   121
            jrbo[i] = new JRadioButtonOperator(parent, i);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   122
            if (selectedRadioButton != null && selectedRadioButton.apply(jrbo[i].getText(), i)) {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   123
                assertTrue("Radio Button " + i + " is initially selected", jrbo[i].isSelected());
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   124
            } else {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   125
                assertFalse("Radio Button " + i + " is initially not selected", jrbo[i].isSelected());
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   126
            }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   127
        }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   128
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   129
        for (int i = 0; i < radioButtonCount; i++) {
39006
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   130
            jrbo[i].push();
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   131
            jrbo[i].waitSelected(true);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   132
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   133
            for (int j = 0; j < radioButtonCount; j++) {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   134
                if (i != j) {
39006
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   135
                    jrbo[j].waitSelected(false);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   136
                }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   137
            }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   138
        }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   139
    }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   140
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   141
    /**
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   142
     * Will change the state of the CheckBox then change back to initial state.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   143
     *
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   144
     * @param parent
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   145
     * @param text
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   146
     * @param expectedValue
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   147
     * @throws Exception
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   148
     */
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   149
    private void testCheckBox(ContainerOperator<?> parent, String text, boolean expectedValue) {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   150
39006
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   151
        System.out.println("Testing " + text);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   152
        parent.setComparator(EXACT_STRING_COMPARATOR);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   153
        JCheckBoxOperator jcbo = new JCheckBoxOperator(parent, text);
39006
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   154
        jcbo.waitSelected(expectedValue);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   155
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   156
        // click check box (toggle the state)
39006
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   157
        jcbo.push();
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   158
        jcbo.waitSelected(!expectedValue);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   159
39006
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   160
        jcbo.push();
fd8c3312d043 8157339: Further stabilization for the SwingSet client sanity tests
prr
parents: 37677
diff changeset
   161
        jcbo.waitSelected(expectedValue);
36744
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   162
    }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   163
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   164
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   165
    /*
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   166
     * testDirectionRadioButtons(JFrameOperator) will toggle each position of
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   167
     * the direction radio button panels
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   168
     */
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   169
    private void testToggleButtons(JFrameOperator jfo) {
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   170
        ComponentChooser directionPanelChooser = new ByClassChooser(DirectionPanel.class);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   171
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   172
        String text_Position = LayoutControlPanel.TEXT_POSITION;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   173
        ContainerOperator<?> textPositionContainer = getLabeledContainerOperator(jfo, text_Position);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   174
        ContainerOperator<?> directionPanelOperator = new ContainerOperator<>(textPositionContainer, directionPanelChooser);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   175
        testRadioButtons(directionPanelOperator, 9, (t, i) -> i == 5);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   176
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   177
        // Unfortunately, both directionPanels are in the same parent container
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   178
        // so we have to use indexes here.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   179
        // There is no guarantee that if the UI changes, the code would be still
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   180
        // valid in terms of which directionPanel is checked first. However, it
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   181
        // does guarantee that two different directionPanels are checked.
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   182
        String content_Alignment = LayoutControlPanel.CONTENT_ALIGNMENT;
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   183
        ContainerOperator<?> contentAlignmentContainer = getLabeledContainerOperator(jfo, content_Alignment);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   184
        ContainerOperator<?> directionPanelOperator2 = new ContainerOperator<>(contentAlignmentContainer, directionPanelChooser,
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   185
                contentAlignmentContainer.getSource() == textPositionContainer.getSource() ? 1 : 0);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   186
        testRadioButtons(directionPanelOperator2, 9, (t, i) -> i == 4);
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   187
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   188
    }
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   189
a00905527ec2 8153141: Develop initial set of tests for SwingSet
mrkam
parents:
diff changeset
   190
}