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