jdk/test/javax/swing/JTextArea/4697612/bug4697612.java
author serb
Tue, 29 Mar 2016 17:03:18 +0300
changeset 36787 402e5e40f6e5
parent 28071 3acb75b8df45
child 40128 e635645d2a8a
permissions -rw-r--r--
7179078: Remove @beaninfo processing from the makefiles Reviewed-by: erikj, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     1
/*
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     4
 *
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     7
 * published by the Free Software Foundation.
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     8
 *
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    13
 * accompanied this code).
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    14
 *
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    18
 *
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    21
 * questions.
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    22
 */
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    23
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    24
/*
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    25
 * @test
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    26
 * @bug 4697612 6244705
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    27
 * @author Peter Zhelezniakov
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    28
 * @library ../../regtesthelpers
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    29
 * @build Util
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    30
 * @run main bug4697612
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    31
 */
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    32
import java.io.*;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    33
import java.awt.*;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    34
import java.awt.event.*;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    35
import javax.swing.*;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    36
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    37
import javax.swing.text.BadLocationException;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    38
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    39
public class bug4697612 {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    40
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    41
    static final int FRAME_WIDTH = 300;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    42
    static final int FRAME_HEIGHT = 300;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    43
    static final int FONT_HEIGHT = 16;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    44
    private static volatile int frameHeight;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    45
    private static volatile int fontHeight;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    46
    private static JFrame frame;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    47
    private static JTextArea text;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    48
    private static JScrollPane scroller;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    49
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    50
    public static void main(String[] args) throws Throwable {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    51
        Robot robot = new Robot();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    52
        robot.setAutoDelay(100);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    53
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    54
        SwingUtilities.invokeAndWait(new Runnable() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    55
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    56
            @Override
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    57
            public void run() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    58
                createAndShowGUI();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    59
            }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    60
        });
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    61
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 11500
diff changeset
    62
        robot.waitForIdle();
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    63
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    64
        SwingUtilities.invokeAndWait(new Runnable() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    65
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    66
            @Override
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    67
            public void run() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    68
                text.requestFocus();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    69
            }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    70
        });
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    71
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 11500
diff changeset
    72
        robot.waitForIdle();
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    73
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    74
        // 4697612: pressing PgDn + PgUp should not alter caret position
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    75
        Util.hitKeys(robot, KeyEvent.VK_HOME);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    76
        Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    77
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    78
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    79
        int pos0 = getTextCaretPosition();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    80
        int caretHeight = getTextCaretHeight();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    81
        fontHeight = FONT_HEIGHT;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    82
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    83
        // iterate two times, for different (even and odd) font height
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    84
        for (int i = 0; i < 2; i++) {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    85
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    86
            SwingUtilities.invokeAndWait(new Runnable() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    87
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    88
                public void run() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    89
                    text.setFont(text.getFont().deriveFont(fontHeight));
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    90
                }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    91
            });
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    92
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    93
            frameHeight = FRAME_HEIGHT;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    94
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    95
            for (int j = 0; j < caretHeight; j++) {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    96
                SwingUtilities.invokeAndWait(new Runnable() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    97
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    98
                    public void run() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
    99
                        frame.setSize(FRAME_WIDTH, frameHeight);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   100
                    }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   101
                });
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   102
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 11500
diff changeset
   103
                robot.waitForIdle();
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   104
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   105
                Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   106
                Util.hitKeys(robot, KeyEvent.VK_PAGE_UP);
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 11500
diff changeset
   107
                robot.waitForIdle();
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   108
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   109
                int pos = getTextCaretPosition();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   110
                if (pos0 != pos) {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   111
                    throw new RuntimeException("Failed 4697612: PgDn & PgUp keys scroll by different amounts");
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   112
                }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   113
                frameHeight++;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   114
            }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   115
            fontHeight++;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   116
        }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   117
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   118
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   119
        // 6244705: pressing PgDn at the very bottom should not scroll
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   120
        LookAndFeel laf = UIManager.getLookAndFeel();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   121
        if (laf.getID().equals("Aqua")) {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   122
            Util.hitKeys(robot, KeyEvent.VK_END);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   123
        } else {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   124
            Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_END);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   125
        }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   126
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 11500
diff changeset
   127
        robot.waitForIdle();
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   128
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   129
        pos0 = getScrollerViewPosition();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   130
        Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 11500
diff changeset
   131
        robot.waitForIdle();
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   132
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   133
        int pos = getScrollerViewPosition();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   134
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   135
        if (pos0 != pos) {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   136
            throw new RuntimeException("Failed 6244705: PgDn at the bottom causes scrolling");
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   137
        }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   138
    }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   139
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   140
    private static int getTextCaretPosition() throws Exception {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   141
        final int[] result = new int[1];
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   142
        SwingUtilities.invokeAndWait(new Runnable() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   143
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   144
            @Override
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   145
            public void run() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   146
                result[0] = text.getCaretPosition();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   147
            }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   148
        });
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   149
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   150
        return result[0];
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   151
    }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   152
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   153
    private static int getTextCaretHeight() throws Exception {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   154
        final int[] result = new int[1];
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   155
        SwingUtilities.invokeAndWait(new Runnable() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   156
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   157
            @Override
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   158
            public void run() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   159
                try {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   160
                    int pos0 = text.getCaretPosition();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   161
                    Rectangle dotBounds = text.modelToView(pos0);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   162
                    result[0] = dotBounds.height;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   163
                } catch (BadLocationException ex) {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   164
                    throw new RuntimeException(ex);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   165
                }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   166
            }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   167
        });
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   168
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   169
        return result[0];
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   170
    }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   171
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   172
    private static int getScrollerViewPosition() throws Exception {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   173
        final int[] result = new int[1];
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   174
        SwingUtilities.invokeAndWait(new Runnable() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   175
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   176
            @Override
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   177
            public void run() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   178
                result[0] = scroller.getViewport().getViewPosition().y;
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   179
            }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   180
        });
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   181
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   182
        return result[0];
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   183
    }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   184
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   185
    private static void createAndShowGUI() {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   186
        frame = new JFrame();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   187
        frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
28071
3acb75b8df45 8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 11500
diff changeset
   188
        frame.setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
11500
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   189
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   190
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   191
        text = new JTextArea();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   192
        try {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   193
            InputStream is =
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   194
                    bug4697612.class.getResourceAsStream("bug4697612.txt");
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   195
            text.read(new InputStreamReader(is), null);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   196
        } catch (IOException e) {
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   197
            throw new Error(e);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   198
        }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   199
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   200
        scroller = new JScrollPane(text);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   201
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   202
        frame.getContentPane().add(scroller);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   203
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   204
        frame.pack();
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   205
        frame.setVisible(true);
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   206
    }
36442b344961 7121765: closed/javax/swing/JTextArea/4697612/bug4697612.java fails on MacOS on Aqua L&F
alexsch
parents:
diff changeset
   207
}