Path: blob/master/test/jdk/javax/imageio/ImageWriteParamMisc.java
41145 views
/*1* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 4434870 4434886 4441315 444684226* @summary Checks that miscellaneous ImageWriteParam methods work properly27*/2829import java.awt.Dimension;3031import javax.imageio.ImageWriteParam;3233public class ImageWriteParamMisc {3435public static void main(String[] args) {36test4434870();37test4434886();38test4441315();39test4446842();40}4142public static class ImageWriteParam4434870 extends ImageWriteParam {43public ImageWriteParam4434870() {44super(null);45super.canWriteTiles = true;46super.preferredTileSizes =47new Dimension[] {new Dimension(1, 2), new Dimension(5, 6)};48}49}5051private static void test4434870() {52ImageWriteParam iwp = new ImageWriteParam4434870();53try {54Dimension[] dimensions = iwp.getPreferredTileSizes();55iwp.setTilingMode(ImageWriteParam.MODE_EXPLICIT);56iwp.setTiling(100, 100, 0,0);57throw new RuntimeException("Failed to get IAE!");58} catch (IllegalArgumentException e) {59}60}6162public static class ImageWriteParam4434886 extends ImageWriteParam {63public ImageWriteParam4434886() {64super(null);65super.canWriteTiles = true;66super.canOffsetTiles = true;67}68}6970private static void test4434886() {71ImageWriteParam iwp = new ImageWriteParam4434886();72iwp.setTilingMode(ImageWriteParam.MODE_EXPLICIT);73try {74iwp.setTiling(-1,-2,-3,-4);75throw new RuntimeException("Failed to get IAE!");76} catch (IllegalArgumentException e) {77}78}7980public static class ImageWriteParam4441315 extends ImageWriteParam {81public ImageWriteParam4441315() {82super(null);83super.canWriteProgressive = true;84}85}8687private static void test4441315() {88ImageWriteParam iwp = new ImageWriteParam4441315();89try {90iwp.setProgressiveMode(ImageWriteParam.MODE_EXPLICIT);91throw new RuntimeException("Failed to get IAE!");92} catch (IllegalArgumentException e) {93}94}9596private static void test4446842() {97ImageWriteParam iwp = new ImageWriteParam(null);98try {99iwp.getCompressionTypes();100throw new RuntimeException("Failed to get UOE!");101} catch (UnsupportedOperationException e) {102}103}104}105106107