Path: blob/master/test/jdk/sanity/client/SwingSet/src/ScrollPaneDemoTest.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.scrollpane.ScrollPaneDemo;25import static com.sun.swingset3.demos.scrollpane.ScrollPaneDemo.DEMO_TITLE;26import static org.testng.AssertJUnit.*;27import javax.swing.UIManager;28import org.testng.annotations.Test;29import org.netbeans.jemmy.ClassReference;30import org.netbeans.jemmy.operators.JFrameOperator;31import org.netbeans.jemmy.operators.JScrollPaneOperator;32import org.testng.annotations.Listeners;3334/*35* @test36* @key headful37* @summary Verifies SwingSet3 ScrollPaneDemo by scrolling to bottom, to top,38* to left and to right and checking scroll bar values.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.scrollpane.ScrollPaneDemo47* @run testng/timeout=600 ScrollPaneDemoTest48*/49@Listeners(GuiTestListener.class)50public class ScrollPaneDemoTest {5152@Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)53public void test(String lookAndFeel) throws Exception {54UIManager.setLookAndFeel(lookAndFeel);5556new ClassReference(ScrollPaneDemo.class.getName()).startApplication();5758JFrameOperator frame = new JFrameOperator(DEMO_TITLE);59JScrollPaneOperator jspo = new JScrollPaneOperator(frame);6061// Set initial scrollbar positions62int initialVerticalValue = jspo.getVerticalScrollBar().getValue();63int initialHorizontalValue = jspo.getHorizontalScrollBar().getValue();6465System.out.println("Initial Vertical Value = " + jspo.getVerticalScrollBar().getValue());66System.out.println("Initial HoriZontal Value = " + jspo.getHorizontalScrollBar().getValue());6768// Check scroll to Bottom69{70jspo.scrollToBottom();71int currentValue = jspo.getVerticalScrollBar().getValue();72System.out.println("Final Value = " + currentValue);73assertTrue("Scroll to Bottom of Pane "74+ "(initialVerticalValue, actual value: " + initialVerticalValue + " "75+ "< currentValue, actual value = " + currentValue + ")",76initialVerticalValue < currentValue);77}7879// Check scroll to Top80{81jspo.scrollToTop();82int currentValue = jspo.getVerticalScrollBar().getValue();83System.out.println("Top Scroll Final Value = " + currentValue);84assertTrue("Scroll to Top of Pane "85+ "(initialVerticalValue, actual value: " + initialVerticalValue + " "86+ "> currentValue, actual value = " + currentValue + ")",87initialVerticalValue > currentValue);88}8990// Check scroll to Left91{92jspo.scrollToLeft();93int currentValue = jspo.getHorizontalScrollBar().getValue();94System.out.println("Scroll to Left Final Value = " + currentValue);95assertTrue("Scroll to Left of Pane "96+ "(initialHorizontalValue, actual value: " + initialHorizontalValue + " "97+ "> currentValue, actual value = " + currentValue + ")",98initialHorizontalValue > currentValue);99}100101// Check scroll to Right102{103jspo.scrollToRight();104int currentValue = jspo.getHorizontalScrollBar().getValue();105System.out.println("Scroll to Right Final Value = " + currentValue);106assertTrue("Scroll to Right of Pane "107+ "(initialHorizontalValue, actual value: " + initialHorizontalValue + " "108+ "< currentValue, actual value = " + currentValue + ")",109initialHorizontalValue < currentValue);110}111}112113}114115116