test/jdk/javax/imageio/ImageTypeSpecifierTest.java
author erikj
Fri, 06 Apr 2018 02:52:24 +0200
changeset 49540 9704789737c1
parent 47216 71c04702a3d5
permissions -rw-r--r--
8201222: JDK-8199539 broke the OpenJDK build Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45351
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     1
/*
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     2
 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     4
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     8
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    13
 * accompanied this code).
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    14
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    18
 *
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    21
 * questions.
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    22
 */
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    23
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    24
/*
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    25
 * @test
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    26
 * @bug 4429934 4429950 4430991 4430993
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    27
 * @summary Checks various aspects of ImageTypeSpecifier functionality
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    28
 */
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    29
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    30
import java.awt.color.ColorSpace;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    31
import java.awt.image.BufferedImage;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    32
import java.awt.image.ColorModel;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    33
import java.awt.image.DataBuffer;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    34
import java.awt.image.SampleModel;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    35
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    36
import javax.imageio.ImageTypeSpecifier;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    37
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    38
public class ImageTypeSpecifierTest {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    39
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    40
    private static void fail(String message) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    41
        throw new RuntimeException(message);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    42
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    43
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    44
    private static void test4429934() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    45
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    46
            ImageTypeSpecifier itspecifier =
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    47
                new ImageTypeSpecifier(null, null);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    48
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    49
        } catch( IllegalArgumentException e ) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    50
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    51
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    52
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    53
            ImageTypeSpecifier itspecifier = new ImageTypeSpecifier(null);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    54
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    55
        } catch (IllegalArgumentException e ) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    56
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    57
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    58
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    59
    private static void test4429950() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    60
        createPackedTest();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    61
        createInterleavedTest();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    62
        createBandedTest();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    63
        createIndexedTest();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    64
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    65
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    66
    public static void createPackedTest() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    67
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    68
        int rmask = 0x00ff0000;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    69
        int gmask = 0x0000ff00;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    70
        int bmask = 0x000000ff;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    71
        int amask = 0xff000000;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    72
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    73
            ImageTypeSpecifier.createPacked(null, rmask, gmask, bmask, amask, 0,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    74
false);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    75
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    76
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    77
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    78
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    79
        ColorSpace cs1 = ColorSpace.getInstance(ColorSpace.CS_GRAY);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    80
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    81
            ImageTypeSpecifier.createPacked
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    82
                (cs1, rmask, gmask, bmask, amask, 0, false);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    83
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    84
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    85
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    86
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    87
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    88
            ImageTypeSpecifier.createPacked(cs, 0, 0, 0, 0, 0, false);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    89
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    90
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    91
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    92
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    93
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    94
            ImageTypeSpecifier.createPacked(cs, rmask, gmask, bmask, amask, -1,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    95
false);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    96
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    97
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    98
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
    99
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   100
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   101
    public static void createInterleavedTest() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   102
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   103
        int[] bandOffsets = {0,0,0,0};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   104
        int dataType = 0;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   105
        boolean hasAlpha = true;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   106
        boolean isAlphaPremultiplied = true;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   107
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   108
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   109
            ImageTypeSpecifier.createInterleaved
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   110
                (null, bandOffsets, dataType, hasAlpha, isAlphaPremultiplied);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   111
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   112
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   113
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   114
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   115
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   116
            ImageTypeSpecifier.createInterleaved
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   117
                (cs, null, dataType, hasAlpha, isAlphaPremultiplied);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   118
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   119
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   120
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   121
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   122
        int[] bad_bandOffsets = {0,100,1000};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   123
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   124
            ImageTypeSpecifier.createInterleaved
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   125
                (cs, bad_bandOffsets, dataType, hasAlpha, isAlphaPremultiplied);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   126
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   127
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   128
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   129
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   130
        int[] bad_bandOffsets_1 = {};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   131
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   132
            ImageTypeSpecifier.createInterleaved
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   133
                (cs, bad_bandOffsets_1, dataType, hasAlpha, isAlphaPremultiplied);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   134
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   135
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   136
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   137
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   138
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   139
    public static void createBandedTest() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   140
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   141
        int[] bankIndices = {0, 100, 1000, 10000};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   142
        int[] bandOffsets = {0, 100, 1000, 10000};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   143
        int dataType = 0;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   144
        boolean hasAlpha = true;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   145
        boolean isAlphaPremultiplied = true;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   146
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   147
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   148
            ImageTypeSpecifier.createBanded(null, bankIndices, bandOffsets,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   149
                dataType, hasAlpha, isAlphaPremultiplied);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   150
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   151
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   152
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   153
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   154
        int[] bad_bankIndices = {};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   155
        int[] bad_bandOffsets = {};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   156
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   157
            ImageTypeSpecifier.createBanded(cs, bad_bankIndices, bad_bandOffsets,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   158
                dataType, hasAlpha, isAlphaPremultiplied);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   159
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   160
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   161
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   162
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   163
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   164
            ImageTypeSpecifier.createBanded(cs, bankIndices, bandOffsets,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   165
                99999, hasAlpha, isAlphaPremultiplied);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   166
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   167
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   168
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   169
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   170
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   171
    public static void createGrayscaleTest() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   172
        int bits = 8;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   173
        int dataType = DataBuffer.TYPE_BYTE;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   174
        boolean isSigned = true;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   175
        // testcase 1
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   176
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   177
            ImageTypeSpecifier.createGrayscale(100, dataType, isSigned);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   178
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   179
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   180
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   181
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   182
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   183
            ImageTypeSpecifier.createGrayscale(10, dataType, isSigned);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   184
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   185
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   186
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   187
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   188
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   189
            ImageTypeSpecifier.createGrayscale(bits, 100, isSigned);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   190
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   191
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   192
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   193
   }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   194
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   195
   public static void createIndexedTest() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   196
        byte[] redLUT = {0};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   197
        byte[] greenLUT = {0};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   198
        byte[] blueLUT = {0};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   199
        byte[] alphaLUT = {0};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   200
        int bits = 8;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   201
        int dataType = DataBuffer.TYPE_BYTE;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   202
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   203
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   204
            ImageTypeSpecifier.createIndexed(redLUT, greenLUT,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   205
                blueLUT, alphaLUT, 0, dataType);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   206
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   207
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   208
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   209
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   210
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   211
            ImageTypeSpecifier.createIndexed(redLUT, greenLUT,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   212
                blueLUT, alphaLUT, 17, dataType);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   213
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   214
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   215
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   216
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   217
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   218
            ImageTypeSpecifier.createIndexed(redLUT, greenLUT,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   219
                blueLUT, alphaLUT, 10, dataType);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   220
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   221
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   222
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   223
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   224
        byte[] greenLUT_4 = {};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   225
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   226
            ImageTypeSpecifier.createIndexed(redLUT, greenLUT_4,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   227
                blueLUT, alphaLUT, bits, dataType);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   228
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   229
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   230
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   231
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   232
        byte[] redLUT_5 = {};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   233
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   234
            ImageTypeSpecifier.createIndexed(redLUT_5, greenLUT,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   235
                blueLUT, alphaLUT, bits, dataType);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   236
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   237
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   238
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   239
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   240
        byte[] alphaLUT_6 = {};
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   241
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   242
            ImageTypeSpecifier.createIndexed(redLUT, greenLUT,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   243
                blueLUT, alphaLUT_6 , bits, dataType);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   244
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   245
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   246
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   247
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   248
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   249
            ImageTypeSpecifier.createIndexed(redLUT, greenLUT,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   250
                blueLUT, alphaLUT , bits, 100);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   251
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   252
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   253
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   254
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   255
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   256
    private static void test4430991() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   257
        ImageTypeSpecifier itspecifier;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   258
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   259
        itspecifier = ImageTypeSpecifier.createFromBufferedImageType
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   260
            (BufferedImage.TYPE_INT_RGB);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   261
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   262
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   263
            itspecifier.createBufferedImage(Integer.MAX_VALUE,
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   264
                                            Integer.MAX_VALUE);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   265
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   266
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   267
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   268
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   269
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   270
            itspecifier.getSampleModel(Integer.MAX_VALUE, Integer.MAX_VALUE);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   271
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   272
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   273
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   274
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   275
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   276
    private static void test4430993() {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   277
        ImageTypeSpecifier itspecifier;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   278
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   279
        int bits = 32;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   280
        int rmask = 0x00ff0000;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   281
        int gmask = 0x0000ff00;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   282
        int bmask = 0x000000ff;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   283
        ColorModel dcm = new java.awt.image.DirectColorModel
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   284
            (bits, rmask, gmask, bmask);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   285
        int[] bandOffsets = new int[2];
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   286
        bandOffsets[1] = 1;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   287
        SampleModel sm = new java.awt.image.ComponentSampleModel
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   288
            (DataBuffer.TYPE_SHORT, 1, 1, 2, 2, bandOffsets);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   289
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   290
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   291
            itspecifier = new ImageTypeSpecifier(dcm, sm);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   292
            fail("Failed to get IAE!");
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   293
        } catch (IllegalArgumentException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   294
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   295
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   296
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   297
    public static void main(String[] args) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   298
        try {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   299
            test4429934();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   300
            test4429950();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   301
            test4430991();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   302
            test4430993();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   303
        } catch (RuntimeException e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   304
            throw e;
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   305
        } catch (Exception e) {
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   306
            e.printStackTrace();
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   307
            System.out.println("Unexpected exception: " + e);
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   308
        }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   309
    }
f7f615a3aaff 8177628: Opensource unit/regression tests for ImageIO
serb
parents:
diff changeset
   310
}