--- old/test/java/awt/geom/Path2D/Path2DCopyConstructor.java 2017-04-20 08:16:38.524645970 +0200 +++ new/test/java/awt/geom/Path2D/Path2DCopyConstructor.java 2017-04-20 08:16:38.412640006 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -34,9 +34,10 @@ /** * @test - * @bug 8076419 + * @bug 8076419, 8078192 * @summary Check Path2D copy constructor (trims arrays) * and constructor with zero capacity + * and Path2D.trimToSize() * @run main Path2DCopyConstructor */ public class Path2DCopyConstructor { @@ -179,58 +180,180 @@ } static void test(Path2D p2d, boolean isEmpty) { - testEqual(new Path2D.Float(p2d), p2d); - testEqual(new Path2D.Double(p2d), p2d); - testEqual(new GeneralPath(p2d), p2d); - - testIterator(new Path2D.Float(p2d), p2d); - testIterator(new Path2D.Double(p2d), p2d); - testIterator((Path2D) p2d.clone(), p2d); - - testFlattening(new Path2D.Float(p2d), p2d); - testFlattening(new Path2D.Double(p2d), p2d); - testFlattening((Path2D) p2d.clone(), p2d); - - testAddMove(new Path2D.Float(p2d)); - testAddMove(new Path2D.Double(p2d)); - testAddMove((Path2D) p2d.clone()); + Path2D c; + Path2D.Float pf; + Path2D.Double pd; + GeneralPath gp; + + pf = new Path2D.Float(p2d); + testEqual(pf, p2d); + testEqual(pf.trimToSize(), p2d); + pd = new Path2D.Double(p2d); + testEqual(pd, p2d); + testEqual(pf.trimToSize(), p2d); + c = (Path2D)p2d.clone(); + testEqual(c, p2d); + testEqual(c.trimToSize(), p2d); + gp = new GeneralPath(p2d); + testEqual(gp, p2d); + testEqual(gp.trimToSize(), p2d); + + pf = new Path2D.Float(p2d); + testIterator(pf, p2d); + testIterator(pf.trimToSize(), p2d); + pd = new Path2D.Double(p2d); + testIterator(pd, p2d); + testIterator(pf.trimToSize(), p2d); + c = (Path2D)p2d.clone(); + testIterator(c, p2d); + testIterator(c.trimToSize(), p2d); + gp = new GeneralPath(p2d); + testIterator(gp, p2d); + testIterator(gp.trimToSize(), p2d); + + pf = new Path2D.Float(p2d); + testFlattening(pf, p2d); + testFlattening(pf.trimToSize(), p2d); + pd = new Path2D.Double(p2d); + testFlattening(pd, p2d); + testFlattening(pf.trimToSize(), p2d); + c = (Path2D)p2d.clone(); + testFlattening(c, p2d); + testFlattening(c.trimToSize(), p2d); + gp = new GeneralPath(p2d); + testFlattening(gp, p2d); + testFlattening(gp.trimToSize(), p2d); + + pf = new Path2D.Float(p2d); + testAddMove(pf); + testAddMove(pf.trimToSize()); + pd = new Path2D.Double(p2d); + testAddMove(pd); + testAddMove(pf.trimToSize()); + c = (Path2D)p2d.clone(); + testAddMove(c); + testAddMove(c.trimToSize()); + gp = new GeneralPath(p2d); + testAddMove(gp); + testAddMove(gp.trimToSize()); // These should expect exception if empty - testAddLine(new Path2D.Float(p2d), isEmpty); - testAddLine(new Path2D.Double(p2d), isEmpty); - testAddLine((Path2D) p2d.clone(), isEmpty); - - testAddQuad(new Path2D.Float(p2d), isEmpty); - testAddQuad(new Path2D.Double(p2d), isEmpty); - testAddQuad((Path2D) p2d.clone(), isEmpty); - - testAddCubic(new Path2D.Float(p2d), isEmpty); - testAddCubic(new Path2D.Double(p2d), isEmpty); - testAddCubic((Path2D) p2d.clone(), isEmpty); - - testAddClose(new Path2D.Float(p2d), isEmpty); - testAddClose(new Path2D.Double(p2d), isEmpty); - testAddClose((Path2D) p2d.clone(), isEmpty); - - testGetBounds(new Path2D.Float(p2d), p2d); - testGetBounds(new Path2D.Double(p2d), p2d); - testGetBounds((Path2D) p2d.clone(), p2d); - - testTransform(new Path2D.Float(p2d)); - testTransform(new Path2D.Double(p2d)); - testTransform((Path2D) p2d.clone()); - - testIntersect(new Path2D.Float(p2d), p2d); - testIntersect(new Path2D.Double(p2d), p2d); - testIntersect((Path2D) p2d.clone(), p2d); - - testContains(new Path2D.Float(p2d), p2d); - testContains(new Path2D.Double(p2d), p2d); - testContains((Path2D) p2d.clone(), p2d); - - testGetCurrentPoint(new Path2D.Float(p2d), p2d); - testGetCurrentPoint(new Path2D.Double(p2d), p2d); - testGetCurrentPoint((Path2D) p2d.clone(), p2d); + pf = new Path2D.Float(p2d); + testAddLine(pf, isEmpty); + testAddLine(pf.trimToSize(), isEmpty); + pd = new Path2D.Double(p2d); + testAddLine(pd, isEmpty); + testAddLine(pf.trimToSize(), isEmpty); + c = (Path2D)p2d.clone(); + testAddLine(c, isEmpty); + testAddLine(c.trimToSize(), isEmpty); + gp = new GeneralPath(p2d); + testAddLine(gp, isEmpty); + testAddLine(gp.trimToSize(), isEmpty); + + pf = new Path2D.Float(p2d); + testAddQuad(pf, isEmpty); + testAddQuad(pf.trimToSize(), isEmpty); + pd = new Path2D.Double(p2d); + testAddQuad(pd, isEmpty); + testAddQuad(pf.trimToSize(), isEmpty); + c = (Path2D)p2d.clone(); + testAddQuad(c, isEmpty); + testAddQuad(c.trimToSize(), isEmpty); + gp = new GeneralPath(p2d); + testAddQuad(gp, isEmpty); + testAddQuad(gp.trimToSize(), isEmpty); + + pf = new Path2D.Float(p2d); + testAddCubic(pf, isEmpty); + testAddCubic(pf.trimToSize(), isEmpty); + pd = new Path2D.Double(p2d); + testAddCubic(pd, isEmpty); + testAddCubic(pf.trimToSize(), isEmpty); + c = (Path2D)p2d.clone(); + testAddCubic(c, isEmpty); + testAddCubic(c.trimToSize(), isEmpty); + gp = new GeneralPath(p2d); + testAddCubic(gp, isEmpty); + testAddCubic(gp.trimToSize(), isEmpty); + + pf = new Path2D.Float(p2d); + testAddClose(pf, isEmpty); + testAddClose(pf.trimToSize(), isEmpty); + pd = new Path2D.Double(p2d); + testAddClose(pd, isEmpty); + testAddClose(pf.trimToSize(), isEmpty); + c = (Path2D)p2d.clone(); + testAddClose(c, isEmpty); + testAddClose(c.trimToSize(), isEmpty); + gp = new GeneralPath(p2d); + testAddClose(gp, isEmpty); + testAddClose(gp.trimToSize(), isEmpty); + + pf = new Path2D.Float(p2d); + testGetBounds(pf, p2d); + testGetBounds(pf.trimToSize(), p2d); + pd = new Path2D.Double(p2d); + testGetBounds(pd, p2d); + testGetBounds(pf.trimToSize(), p2d); + c = (Path2D)p2d.clone(); + testGetBounds(c, p2d); + testGetBounds(c.trimToSize(), p2d); + gp = new GeneralPath(p2d); + testGetBounds(gp, p2d); + testGetBounds(gp.trimToSize(), p2d); + + pf = new Path2D.Float(p2d); + testTransform(pf); + testTransform(pf.trimToSize()); + pd = new Path2D.Double(p2d); + testTransform(pd); + testTransform(pf.trimToSize()); + c = (Path2D)p2d.clone(); + testTransform(c); + testTransform(c.trimToSize()); + gp = new GeneralPath(p2d); + testTransform(gp); + testTransform(gp.trimToSize()); + + pf = new Path2D.Float(p2d); + testIntersect(pf, p2d); + testIntersect(pf.trimToSize(), p2d); + pd = new Path2D.Double(p2d); + testIntersect(pd, p2d); + testIntersect(pf.trimToSize(), p2d); + c = (Path2D)p2d.clone(); + testIntersect(c, p2d); + testIntersect(c.trimToSize(), p2d); + gp = new GeneralPath(p2d); + testIntersect(gp, p2d); + testIntersect(gp.trimToSize(), p2d); + + pf = new Path2D.Float(p2d); + testContains(pf, p2d); + testContains(pf.trimToSize(), p2d); + pd = new Path2D.Double(p2d); + testContains(pd, p2d); + testContains(pf.trimToSize(), p2d); + c = (Path2D)p2d.clone(); + testContains(c, p2d); + testContains(c.trimToSize(), p2d); + gp = new GeneralPath(p2d); + testContains(gp, p2d); + testContains(gp.trimToSize(), p2d); + + pf = new Path2D.Float(p2d); + testGetCurrentPoint(pf, p2d); + testGetCurrentPoint(pf.trimToSize(), p2d); + pd = new Path2D.Double(p2d); + testGetCurrentPoint(pd, p2d); + testGetCurrentPoint(pf.trimToSize(), p2d); + c = (Path2D)p2d.clone(); + testGetCurrentPoint(c, p2d); + testGetCurrentPoint(c.trimToSize(), p2d); + gp = new GeneralPath(p2d); + testGetCurrentPoint(gp, p2d); + testGetCurrentPoint(gp.trimToSize(), p2d); } static void testEqual(Path2D pathA, Path2D pathB) {