jdk/test/javax/swing/plaf/nimbus/AbstractRegionPainter/PaintContextScaleValidation.java
changeset 47160 ac5434728c3b
equal deleted inserted replaced
47159:8261a0f79e90 47160:ac5434728c3b
       
     1 /*
       
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    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
       
    21  * questions.
       
    22  */
       
    23 
       
    24 import java.awt.Dimension;
       
    25 import java.awt.Graphics2D;
       
    26 import java.awt.Insets;
       
    27 
       
    28 import javax.swing.JComponent;
       
    29 import javax.swing.plaf.nimbus.AbstractRegionPainter;
       
    30 
       
    31 /**
       
    32  * @test
       
    33  * @bug 8134256
       
    34  */
       
    35 public final class PaintContextScaleValidation extends AbstractRegionPainter {
       
    36 
       
    37     public static void main(final String[] args) {
       
    38         final PaintContextScaleValidation t = new PaintContextScaleValidation();
       
    39         t.test(0, 0);
       
    40         t.test(0, 1);
       
    41         t.test(1, 0);
       
    42     }
       
    43 
       
    44     private void test(final double maxH, final double maxV) {
       
    45         try {
       
    46             new PaintContext(new Insets(1, 1, 1, 1), new Dimension(1, 1), false,
       
    47                              null, maxH, maxV);
       
    48         } catch (final IllegalArgumentException ignored) {
       
    49             return; // expected exception
       
    50         }
       
    51         throw new RuntimeException("IllegalArgumentException was not thrown");
       
    52     }
       
    53 
       
    54     @Override
       
    55     protected PaintContext getPaintContext() {
       
    56         return null;
       
    57     }
       
    58 
       
    59     @Override
       
    60     protected void doPaint(final Graphics2D g, final JComponent c,
       
    61                            final int width, final int height,
       
    62                            final Object[] extendedCacheKeys) {
       
    63     }
       
    64 }