test/jdk/javax/imageio/ImageWriteParamMisc.java
changeset 47216 71c04702a3d5
parent 45351 f7f615a3aaff
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 2001, 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 /*
       
    25  * @test
       
    26  * @bug 4434870 4434886 4441315 4446842
       
    27  * @summary Checks that miscellaneous ImageWriteParam methods work properly
       
    28  */
       
    29 
       
    30 import java.awt.Dimension;
       
    31 
       
    32 import javax.imageio.ImageWriteParam;
       
    33 
       
    34 public class ImageWriteParamMisc {
       
    35 
       
    36     public static void main(String[] args) {
       
    37         test4434870();
       
    38         test4434886();
       
    39         test4441315();
       
    40         test4446842();
       
    41     }
       
    42 
       
    43     public static class ImageWriteParam4434870 extends ImageWriteParam {
       
    44         public ImageWriteParam4434870() {
       
    45             super(null);
       
    46             super.canWriteTiles = true;
       
    47             super.preferredTileSizes =
       
    48                 new Dimension[] {new Dimension(1, 2), new Dimension(5, 6)};
       
    49         }
       
    50     }
       
    51 
       
    52     private static void test4434870() {
       
    53         ImageWriteParam iwp = new ImageWriteParam4434870();
       
    54         try {
       
    55             Dimension[] dimensions = iwp.getPreferredTileSizes();
       
    56             iwp.setTilingMode(ImageWriteParam.MODE_EXPLICIT);
       
    57             iwp.setTiling(100, 100, 0,0);
       
    58             throw new RuntimeException("Failed to get IAE!");
       
    59         } catch (IllegalArgumentException e) {
       
    60         }
       
    61     }
       
    62 
       
    63     public static class ImageWriteParam4434886 extends ImageWriteParam {
       
    64         public ImageWriteParam4434886() {
       
    65             super(null);
       
    66             super.canWriteTiles = true;
       
    67             super.canOffsetTiles = true;
       
    68         }
       
    69     }
       
    70 
       
    71     private static void test4434886() {
       
    72         ImageWriteParam iwp = new ImageWriteParam4434886();
       
    73         iwp.setTilingMode(ImageWriteParam.MODE_EXPLICIT);
       
    74         try {
       
    75             iwp.setTiling(-1,-2,-3,-4);
       
    76             throw new RuntimeException("Failed to get IAE!");
       
    77         } catch (IllegalArgumentException e) {
       
    78         }
       
    79     }
       
    80 
       
    81     public static class ImageWriteParam4441315 extends ImageWriteParam {
       
    82         public ImageWriteParam4441315() {
       
    83             super(null);
       
    84             super.canWriteProgressive = true;
       
    85         }
       
    86     }
       
    87 
       
    88     private static void test4441315() {
       
    89         ImageWriteParam iwp = new ImageWriteParam4441315();
       
    90         try {
       
    91             iwp.setProgressiveMode(ImageWriteParam.MODE_EXPLICIT);
       
    92             throw new RuntimeException("Failed to get IAE!");
       
    93         } catch (IllegalArgumentException e) {
       
    94         }
       
    95     }
       
    96 
       
    97     private static void test4446842() {
       
    98         ImageWriteParam iwp = new ImageWriteParam(null);
       
    99         try {
       
   100             iwp.getCompressionTypes();
       
   101             throw new RuntimeException("Failed to get UOE!");
       
   102         } catch (UnsupportedOperationException e) {
       
   103         }
       
   104     }
       
   105 }