From 08f0edbf5a5203595569f0ae755ca4d3e5adb0cc Mon Sep 17 00:00:00 2001 From: Alexander Stepanov Date: Fri, 22 Jan 2016 13:37:46 +0300 Subject: [PATCH] 8146881: [TEST] update some imageio plugins tests to affect TIFF format Reviewed-by: serb, ssadetsky --- jdk/test/javax/imageio/MultiReadTest.java | 4 +- .../imageio/plugins/shared/BitDepth.java | 52 +++++++++++++------ .../shared/ImageWriterCompressionTest.java | 5 +- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/jdk/test/javax/imageio/MultiReadTest.java b/jdk/test/javax/imageio/MultiReadTest.java index daea61610be..2e19d0b360c 100644 --- a/jdk/test/javax/imageio/MultiReadTest.java +++ b/jdk/test/javax/imageio/MultiReadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public class MultiReadTest { private static final int max = 5; public static void main(String[] args) throws IOException { - final String[] formats = { "bmp", "png", "gif", "jpg" }; + final String[] formats = { "bmp", "png", "gif", "jpg", "tif" }; for (String f : formats) { test(f); diff --git a/jdk/test/javax/imageio/plugins/shared/BitDepth.java b/jdk/test/javax/imageio/plugins/shared/BitDepth.java index 9f1e2ee6da9..4e051738590 100644 --- a/jdk/test/javax/imageio/plugins/shared/BitDepth.java +++ b/jdk/test/javax/imageio/plugins/shared/BitDepth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,11 @@ /** * @test - * @bug 4413109 4418221 6607198 + * @bug 4413109 4418221 6607198 8147448 * @run main BitDepth - * @summary Checks that the PNG and JPEG writers can handle various - * BufferedImage types. An optional list of arguments may be used to - * test a different format writer or writers. + * @summary Checks that ImageIO writers for standard formats can handle + * various BufferedImage RGB types. An optional list of arguments + * may be used to test the writers for a different list of formats. */ import java.awt.Color; @@ -81,21 +81,19 @@ public class BitDepth { BufferedImage.TYPE_INT_BGR, BufferedImage.TYPE_3BYTE_BGR, BufferedImage.TYPE_USHORT_565_RGB, - BufferedImage.TYPE_USHORT_555_RGB - }; - - private static final int[] biRGBATypes = { + BufferedImage.TYPE_USHORT_555_RGB, BufferedImage.TYPE_INT_ARGB, BufferedImage.TYPE_INT_ARGB_PRE, BufferedImage.TYPE_4BYTE_ABGR, BufferedImage.TYPE_4BYTE_ABGR_PRE }; - private static final int[] biGrayTypes = { - BufferedImage.TYPE_BYTE_GRAY, - BufferedImage.TYPE_USHORT_GRAY, - BufferedImage.TYPE_BYTE_BINARY - }; + //private static final int[] biGrayTypes = { + // BufferedImage.TYPE_BYTE_GRAY, + // BufferedImage.TYPE_USHORT_GRAY, + // BufferedImage.TYPE_BYTE_BINARY + //}; + private static final String[] biTypeNames = { "CUSTOM", @@ -116,7 +114,7 @@ public class BitDepth { private int width = 80; private int height = 80; - private String[] format = { "png", "jpeg" }; + private String[] format = { "png", "jpeg", "tif", "bmp", "gif" }; public BitDepth(String[] args) throws IOException { if (args.length > 0) { @@ -129,10 +127,28 @@ public class BitDepth { } private void testFormat(String format) throws IOException { + boolean allOK = true; for (int i = 0; i < biRGBTypes.length; i++) { + int type = biRGBTypes[i]; + + + // TODO: remove the following 'if' block after the 8147448 fix + if ( format.toLowerCase().equals("bmp") && ( + (type == BufferedImage.TYPE_INT_ARGB ) || + (type == BufferedImage.TYPE_INT_ARGB_PRE ) || + (type == BufferedImage.TYPE_4BYTE_ABGR ) || + (type == BufferedImage.TYPE_4BYTE_ABGR_PRE ))) { + + System.err.println("cannot use " + biTypeNames[type] + + " for bmp because of JDK-8147448.\t" + + " please update the test after fix of this bug!"); + continue; + } + + System.out.println("Testing " + format + " writer for type " + biTypeNames[type]); File f = testWriteRGB(format, type); @@ -143,6 +159,8 @@ public class BitDepth { allOK = allOK && ok; } + + if (format.equals("png")) { System.out.println("Testing png writer for black stripe"); boolean ok = testPNGByteBinary(); @@ -154,8 +172,8 @@ public class BitDepth { } } - private File testWriteRGB(String format, int type) - throws IOException { + private File testWriteRGB(String format, int type) throws IOException { + BufferedImage bi = new BufferedImage(width, height, type); Graphics2D g = bi.createGraphics(); diff --git a/jdk/test/javax/imageio/plugins/shared/ImageWriterCompressionTest.java b/jdk/test/javax/imageio/plugins/shared/ImageWriterCompressionTest.java index 279e8ed7db1..9f633c0d300 100644 --- a/jdk/test/javax/imageio/plugins/shared/ImageWriterCompressionTest.java +++ b/jdk/test/javax/imageio/plugins/shared/ImageWriterCompressionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,8 +53,7 @@ public class ImageWriterCompressionTest { private static final Set IGNORE_FILE_SUFFIXES = new HashSet(Arrays.asList(new String[] { "bmp", "gif", - "jpg", "jpeg", -// "tif", "tiff" + "jpg", "jpeg" } )); public static void main(String[] args) {