modules/graphics/src/test/java/test/com/sun/javafx/sg/prism/NGCircleTest.java
Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:
*** 21,33 ****
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package com.sun.javafx.sg.prism;
import com.sun.javafx.geom.RectBounds;
import com.sun.prism.paint.Color;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
--- 21,35 ----
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package test.com.sun.javafx.sg.prism;
import com.sun.javafx.geom.RectBounds;
+ import com.sun.javafx.sg.prism.NGCircle;
+ import com.sun.javafx.sg.prism.NGNodeShim;
import com.sun.prism.paint.Color;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
*** 46,65 ****
circle.updateCircle(10, 10, 5);
}
@Test
public void testSupportsOpaqueRegion() {
! assertTrue(circle.supportsOpaqueRegions());
}
@Test
public void hasOpaqueRegionIfRadiusIsGreaterThanZero() {
! assertTrue(circle.hasOpaqueRegion());
circle.updateCircle(10, 10, 0);
! assertFalse(circle.hasOpaqueRegion());
circle.updateCircle(10, 10, .0001f);
! assertTrue(circle.hasOpaqueRegion());
}
@Test
public void opaqueRegionLiesWithinCircle() {
RectBounds or = new RectBounds();
--- 48,67 ----
circle.updateCircle(10, 10, 5);
}
@Test
public void testSupportsOpaqueRegion() {
! assertTrue(NGNodeShim.supportsOpaqueRegions(circle));
}
@Test
public void hasOpaqueRegionIfRadiusIsGreaterThanZero() {
! assertTrue(NGNodeShim.hasOpaqueRegion(circle));
circle.updateCircle(10, 10, 0);
! assertFalse(NGNodeShim.hasOpaqueRegion(circle));
circle.updateCircle(10, 10, .0001f);
! assertTrue(NGNodeShim.hasOpaqueRegion(circle));
}
@Test
public void opaqueRegionLiesWithinCircle() {
RectBounds or = new RectBounds();
*** 72,82 ****
10f,
13.321f // some random number
};
for (float r : radiusValues) {
circle.updateCircle(10, 10, r);
! or = circle.computeOpaqueRegion(or);
assertNotNull(or);
assertTrue(circle.getShape().contains(or.getMinX(), or.getMinY(), or.getWidth(), or.getHeight()));
}
}
--- 74,84 ----
10f,
13.321f // some random number
};
for (float r : radiusValues) {
circle.updateCircle(10, 10, r);
! or = NGNodeShim.computeOpaqueRegion(circle, or);
assertNotNull(or);
assertTrue(circle.getShape().contains(or.getMinX(), or.getMinY(), or.getWidth(), or.getHeight()));
}
}
*** 88,98 ****
* than what the implementation uses. So I will compute the wider box
* and a narrower box and make sure the implementation is between the two.
*/
@Test
public void testComputeOpaqueRegion() {
! RectBounds or = circle.computeOpaqueRegion(new RectBounds());
// First we will compute with the highest precision we can.
float r = 5; // same as the ellipse
float side = 2*r / (float) Math.sqrt(2);
float halfSide = side / 2f;
--- 90,100 ----
* than what the implementation uses. So I will compute the wider box
* and a narrower box and make sure the implementation is between the two.
*/
@Test
public void testComputeOpaqueRegion() {
! RectBounds or = NGNodeShim.computeOpaqueRegion(circle, new RectBounds());
// First we will compute with the highest precision we can.
float r = 5; // same as the ellipse
float side = 2*r / (float) Math.sqrt(2);
float halfSide = side / 2f;