jdk/test/javax/swing/JSlider/6794831/bug6794831.java
author dfuchs
Tue, 28 Jul 2015 11:30:55 +0200
changeset 31929 1e2ee502d1be
parent 23683 2d5bf8043a38
child 40128 e635645d2a8a
permissions -rw-r--r--
8132256: jaxp: Investigate removal of com/sun/org/apache/bcel/internal/util/ClassPath.java Summary: com/sun/org/apache/bcel/internal/util/ClassPath.java removed Reviewed-by: joehw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2488
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     1
/*
23683
2d5bf8043a38 8023475: [TEST BUG] Test javax/swing/JSlider/6794831/bug6794831.java does not wait long enough for test results
serb
parents: 5506
diff changeset
     2
 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
2488
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     4
 *
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     8
 *
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    13
 * accompanied this code).
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    14
 *
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2488
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2488
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2488
diff changeset
    21
 * questions.
2488
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    22
 */
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    23
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    24
/* @test
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    25
 * @bug 6794831
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    26
 * @summary Infinite loop while painting ticks on Slider with maximum=MAX_INT
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    27
 * @author Pavel Porvatov
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    28
   @run main bug6794831
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    29
 */
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    30
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    31
import javax.swing.*;
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    32
import javax.swing.plaf.basic.BasicSliderUI;
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    33
import java.awt.image.BufferedImage;
23683
2d5bf8043a38 8023475: [TEST BUG] Test javax/swing/JSlider/6794831/bug6794831.java does not wait long enough for test results
serb
parents: 5506
diff changeset
    34
import java.lang.reflect.InvocationTargetException;
2488
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    35
import java.util.concurrent.CountDownLatch;
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    36
import java.util.concurrent.TimeUnit;
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    37
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    38
public class bug6794831 {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    39
    private final CountDownLatch countDownLatch = new CountDownLatch(1);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    40
23683
2d5bf8043a38 8023475: [TEST BUG] Test javax/swing/JSlider/6794831/bug6794831.java does not wait long enough for test results
serb
parents: 5506
diff changeset
    41
    public static void main(String args[])
2d5bf8043a38 8023475: [TEST BUG] Test javax/swing/JSlider/6794831/bug6794831.java does not wait long enough for test results
serb
parents: 5506
diff changeset
    42
            throws InterruptedException, InvocationTargetException {
2488
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    43
        new bug6794831().run();
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    44
    }
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    45
23683
2d5bf8043a38 8023475: [TEST BUG] Test javax/swing/JSlider/6794831/bug6794831.java does not wait long enough for test results
serb
parents: 5506
diff changeset
    46
    private void run() throws InterruptedException, InvocationTargetException {
2d5bf8043a38 8023475: [TEST BUG] Test javax/swing/JSlider/6794831/bug6794831.java does not wait long enough for test results
serb
parents: 5506
diff changeset
    47
        SwingUtilities.invokeAndWait(new Runnable() {
2488
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    48
            public void run() {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    49
                for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    50
                    try {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    51
                        UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    52
                    } catch (Exception e) {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    53
                        fail(e.getMessage());
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    54
                    }
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    55
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    56
                    BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    57
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    58
                    // Test 1
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    59
                    JSlider slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    60
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    61
                    slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    62
                    slider.setPaintTicks(true);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    63
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    64
                    ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    65
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    66
                    // Test 2
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    67
                    slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    68
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    69
                    slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    70
                    slider.setPaintTicks(true);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    71
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    72
                    ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    73
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    74
                    // Test 3
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    75
                    slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    76
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    77
                    slider.setOrientation(JSlider.VERTICAL);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    78
                    slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    79
                    slider.setPaintTicks(true);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    80
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    81
                    ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    82
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    83
                    // Test 4
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    84
                    slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    85
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    86
                    slider.setOrientation(JSlider.VERTICAL);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    87
                    slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    88
                    slider.setPaintTicks(true);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    89
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    90
                    ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    91
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    92
                    countDownLatch.countDown();
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    93
                }
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    94
            }
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    95
        });
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    96
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    97
        if (countDownLatch.await(3000, TimeUnit.MILLISECONDS)) {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    98
            System.out.println("bug6794831 passed");
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
    99
        } else {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   100
            fail("bug6794831 failed");
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   101
        }
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   102
    }
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   103
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   104
    private static void fail(String msg) {
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   105
        throw new RuntimeException(msg);
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   106
    }
4d54c9133cda 6794831: Infinite loop while painting ticks on Slider with maximum=MAX_INT
rupashka
parents:
diff changeset
   107
}