pjfanning commented on code in PR #1534: URL: https://github.com/apache/poi/pull/1534#discussion_r4467481582
########## poi-ooxml/src/test/java/org/apache/poi/sl/tests/draw/TestDrawShape.java: ########## @@ -0,0 +1,79 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.apache.poi.sl.tests.draw; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assumptions.assumeFalse; + +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; + +import org.apache.poi.sl.draw.DrawShape; +import org.apache.poi.sl.tests.SLCommonUtils; +import org.apache.poi.sl.usermodel.AutoShape; +import org.apache.poi.sl.usermodel.SlideShow; +import org.apache.poi.sl.usermodel.SlideShowFactory; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class TestDrawShape { + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testApplyTransformFlip(boolean xslf) throws IOException { + assumeFalse(!xslf && SLCommonUtils.xslfOnly()); + + Rectangle2D anchor = new Rectangle2D.Double(100, 50, 200, 100); + Point2D topLeft = new Point2D.Double(100, 50); + + try (SlideShow<?,?> ppt = SlideShowFactory.create(xslf)) { + AutoShape<?,?> shape = ppt.createSlide().createAutoShape(); + shape.setAnchor(anchor); + + // no flip, no rotation: the transform must be left untouched + assertEquals(topLeft, transform(shape, topLeft)); + + shape.setFlipHorizontal(true); + assertEquals(new Point2D.Double(300, 50), transform(shape, topLeft)); + + shape.setFlipHorizontal(false); + shape.setFlipVertical(true); + assertEquals(new Point2D.Double(100, 150), transform(shape, topLeft)); + + shape.setFlipHorizontal(true); + assertEquals(new Point2D.Double(300, 150), transform(shape, topLeft)); Review Comment: This sequence never calls `setFlipVertical(false)`, so only the horizontal half of the `HSLFShape` setter fix is tested. If the `setFlipVertical` change were reverted to the unconditional `| FLAG_FLIPVERT`, this test would still pass. Could you add a step that clears the vertical flag and asserts the result? For example, `setFlipVertical(false)` here should give `(300, 50)`. ########## poi-ooxml/src/test/java/org/apache/poi/sl/tests/draw/TestDrawShape.java: ########## @@ -0,0 +1,79 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.apache.poi.sl.tests.draw; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assumptions.assumeFalse; + +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; + +import org.apache.poi.sl.draw.DrawShape; +import org.apache.poi.sl.tests.SLCommonUtils; +import org.apache.poi.sl.usermodel.AutoShape; +import org.apache.poi.sl.usermodel.SlideShow; +import org.apache.poi.sl.usermodel.SlideShowFactory; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class TestDrawShape { + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testApplyTransformFlip(boolean xslf) throws IOException { Review Comment: This only covers flips with zero rotation on a top-level shape, which leaves a few related paths untested: - `applyTransform` uses a different order per format: flip then rotate for HSLF, rotate then flip for XSLF. At rotation 0 the order makes no difference, so swapping the branches would still pass. - The `horzFlip ^ vertFlip` text compensation in `DrawTextShape` has no coverage. - Flips inherited from a parent group have no coverage. A search of the xslf, sl and hslf test trees found no other flip tests. Could you add a rotated flip case, plus a flipped text or group case? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
