jdk/test/sanity/client/SwingSet/src/ProgressBarDemoTest.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.demos.progressbar.ProgressBarDemo;
    25 import com.sun.swingset3.demos.progressbar.ProgressBarDemo;
    25 import static com.sun.swingset3.demos.progressbar.ProgressBarDemo.*;
    26 import static com.sun.swingset3.demos.progressbar.ProgressBarDemo.*;
    26 import java.awt.Component;
    27 import java.awt.Component;
    27 import static org.testng.AssertJUnit.*;
    28 import static org.testng.AssertJUnit.*;
    28 import org.testng.annotations.Test;
    29 import org.testng.annotations.Test;
    29 import org.netbeans.jemmy.ClassReference;
    30 import org.netbeans.jemmy.ClassReference;
    30 import org.netbeans.jemmy.ComponentChooser;
    31 import org.netbeans.jemmy.ComponentChooser;
    31 import org.netbeans.jemmy.operators.JButtonOperator;
    32 import org.netbeans.jemmy.operators.JButtonOperator;
    32 import org.netbeans.jemmy.operators.JFrameOperator;
    33 import org.netbeans.jemmy.operators.JFrameOperator;
    33 import org.netbeans.jemmy.operators.JProgressBarOperator;
    34 import org.netbeans.jemmy.operators.JProgressBarOperator;
    34 import static org.jemmy2ext.JemmyExt.captureDebugInfoOnFail;
    35 import org.testng.annotations.Listeners;
    35 
    36 
    36 /*
    37 /*
    37  * @test
    38  * @test
    38  * @key headful
    39  * @key headful
    39  * @summary Verifies SwingSet3 ProgressBarDemo page by pressing start and stop
    40  * @summary Verifies SwingSet3 ProgressBarDemo page by pressing start and stop
    40  *          buttons and checking the progress bar and the buttons state.
    41  *          buttons and checking the progress bar and the buttons state.
    41  *
    42  *
    42  * @library /sanity/client/lib/jemmy/src
    43  * @library /sanity/client/lib/jemmy/src
    43  * @library /sanity/client/lib/Jemmy2Ext/src
    44  * @library /sanity/client/lib/Extensions/src
    44  * @library /sanity/client/lib/SwingSet3/src
    45  * @library /sanity/client/lib/SwingSet3/src
    45  * @build org.jemmy2ext.JemmyExt
    46  * @build org.jemmy2ext.JemmyExt
    46  * @build com.sun.swingset3.demos.progressbar.ProgressBarDemo
    47  * @build com.sun.swingset3.demos.progressbar.ProgressBarDemo
    47  * @run testng ProgressBarDemoTest
    48  * @run testng ProgressBarDemoTest
    48  */
    49  */
       
    50 @Listeners(GuiTestListener.class)
    49 public class ProgressBarDemoTest {
    51 public class ProgressBarDemoTest {
    50 
    52 
    51     @Test
    53     @Test
    52     public void test() throws Exception {
    54     public void test() throws Exception {
    53         captureDebugInfoOnFail(() -> {
       
    54             new ClassReference(ProgressBarDemo.class.getCanonicalName()).startApplication();
       
    55 
    55 
    56             JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
    56         new ClassReference(ProgressBarDemo.class.getCanonicalName()).startApplication();
    57 
    57 
    58             JButtonOperator startButton = new JButtonOperator(frame, START_BUTTON);
    58         JFrameOperator frame = new JFrameOperator(DEMO_TITLE);
    59             JButtonOperator stopButton = new JButtonOperator(frame, STOP_BUTTON);
       
    60             JProgressBarOperator jpbo = new JProgressBarOperator(frame);
       
    61 
    59 
    62             // Check that progress completes and corect enable/disable of start/stop buttons
    60         JButtonOperator startButton = new JButtonOperator(frame, START_BUTTON);
    63             checkCompleteProgress(frame, startButton, stopButton, jpbo);
    61         JButtonOperator stopButton = new JButtonOperator(frame, STOP_BUTTON);
       
    62         JProgressBarOperator jpbo = new JProgressBarOperator(frame);
    64 
    63 
    65             // Check progess bar progression and start/stop button disabled/enabled states
    64         // Check that progress completes and corect enable/disable of start/stop buttons
    66             checkStartStop(frame, startButton, stopButton, jpbo);
    65         checkCompleteProgress(frame, startButton, stopButton, jpbo);
    67         });
    66 
       
    67         // Check progess bar progression and start/stop button disabled/enabled states
       
    68         checkStartStop(frame, startButton, stopButton, jpbo);
    68     }
    69     }
    69 
    70 
    70     // Check that progress completes and corect enable/disable of start/stop buttons
    71     // Check that progress completes and corect enable/disable of start/stop buttons
    71     public void checkStartStop(JFrameOperator frame, JButtonOperator startButton, JButtonOperator stopButton, JProgressBarOperator progressBar) throws Exception {
    72     public void checkStartStop(JFrameOperator frame, JButtonOperator startButton, JButtonOperator stopButton, JProgressBarOperator progressBar) throws Exception {
    72         int initialProgress = progressBar.getValue();
    73         int initialProgress = progressBar.getValue();