Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JEditorPane/6917744/bug6917744.java
38918 views
/*1* Copyright (c) 2010, 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*/2223/* @test24* @bug 691774425* @summary JScrollPane Page Up/Down keys do not handle correctly html tables with different cells contents26* @author Pavel Porvatov27* @run main bug691774428*/2930import java.awt.*;31import java.awt.event.KeyEvent;32import java.io.IOException;33import javax.swing.*;3435public class bug6917744 {36private static JFrame frame;3738private static JEditorPane editorPane;3940private static JScrollPane scrollPane;4142private static Robot robot;4344public static void main(String[] args) throws Exception {4546robot = new Robot();47robot.setAutoDelay(100);4849SwingUtilities.invokeAndWait(new Runnable() {50public void run() {51frame = new JFrame();5253editorPane = new JEditorPane();5455try {56editorPane.setPage(bug6917744.class.getResource("/test.html"));57} catch (IOException e) {58throw new RuntimeException("HTML resource not found", e);59}6061scrollPane = new JScrollPane(editorPane);6263frame.getContentPane().add(scrollPane);64frame.setSize(400, 300);65frame.setVisible(true);66}67});6869robot.waitForIdle();7071for (int i = 0; i < 50; i++) {72robot.keyPress(KeyEvent.VK_PAGE_DOWN);73robot.keyRelease(KeyEvent.VK_PAGE_DOWN);74}7576robot.waitForIdle();7778// Check that we at the end of document79SwingUtilities.invokeAndWait(new Runnable() {80public void run() {81BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();8283if (model.getValue() + model.getExtent() != model.getMaximum()) {84throw new RuntimeException("Invalid HTML position");85}86}87});8889robot.waitForIdle();9091for (int i = 0; i < 50; i++) {92robot.keyPress(KeyEvent.VK_PAGE_UP);93robot.keyRelease(KeyEvent.VK_PAGE_UP);94}9596robot.waitForIdle();9798// Check that we at the begin of document99SwingUtilities.invokeAndWait(new Runnable() {100public void run() {101BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();102103if (model.getValue() != model.getMinimum()) {104throw new RuntimeException("Invalid HTML position");105}106107frame.dispose();108}109});110}111}112113114