modules/graphics/src/test/java/test/com/sun/javafx/scene/transform/TransformUtilsTest.java
Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:
*** 21,47 ****
* 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.scene.transform;
! import com.sun.javafx.test.TransformHelper;
import javafx.scene.transform.Transform;
import com.sun.javafx.geom.transform.Affine3D;
import java.util.LinkedList;
import java.util.List;
! import javafx.scene.transform.TransformOperationsTest;
import javafx.scene.transform.Translate;
import static org.junit.Assert.*;
import org.junit.Test;
public class TransformUtilsTest {
@Test
public void shouldCreateCorrectImmutableTransform() {
! Transform t = TransformUtils.immutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
TransformHelper.assertMatrix(t,
--- 21,49 ----
* 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.scene.transform;
! import test.com.sun.javafx.test.TransformHelper;
import javafx.scene.transform.Transform;
import com.sun.javafx.geom.transform.Affine3D;
+ import com.sun.javafx.scene.transform.TransformUtils;
+ import com.sun.javafx.scene.transform.TransformUtilsShim;
import java.util.LinkedList;
import java.util.List;
! import test.javafx.scene.transform.TransformOperationsTest;
import javafx.scene.transform.Translate;
import static org.junit.Assert.*;
import org.junit.Test;
public class TransformUtilsTest {
@Test
public void shouldCreateCorrectImmutableTransform() {
! Transform t = TransformUtilsShim.getImmutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
TransformHelper.assertMatrix(t,
*** 53,63 ****
@Test
public void immutableTransformShouldApplyCorrectly() {
Affine3D a = new Affine3D();
a.translate(10, 20);
! Transform t = TransformUtils.immutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
t.impl_apply(a);
--- 55,65 ----
@Test
public void immutableTransformShouldApplyCorrectly() {
Affine3D a = new Affine3D();
a.translate(10, 20);
! Transform t = TransformUtilsShim.getImmutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
t.impl_apply(a);
*** 68,78 ****
9, 10, 11, 12);
}
@Test
public void immutableTransformShouldCopyCorrectly() {
! Transform src = TransformUtils.immutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
Transform t = src.clone();
--- 70,80 ----
9, 10, 11, 12);
}
@Test
public void immutableTransformShouldCopyCorrectly() {
! Transform src = TransformUtilsShim.getImmutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
Transform t = src.clone();
*** 82,92 ****
5, 6, 7, 8,
9, 10, 11, 12);
}
@Test public void testImmutableTransformToString() {
! final Transform trans = TransformUtils.immutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
String s = trans.toString();
--- 84,94 ----
5, 6, 7, 8,
9, 10, 11, 12);
}
@Test public void testImmutableTransformToString() {
! Transform trans = TransformUtilsShim.getImmutableTransform(
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12);
String s = trans.toString();
*** 97,122 ****
@Test public void testImmutableTransformState() {
int counter = 0;
for (Object o : TransformOperationsTest.getParams()) {
Object[] arr = (Object[]) o;
! if (arr[0] instanceof TransformUtils.ImmutableTransform) {
! TransformUtils.ImmutableTransform t =
! (TransformUtils.ImmutableTransform) arr[0];
TransformHelper.assertStateOk("Checking state of transform #" +
(counter++) + " of TransformOperationsTest", t,
! t.getState3d(), t.getState2d());
}
}
}
@Test public void testReusedImmutableTransform() {
int counter = 0;
for (Object o : TransformOperationsTest.getParams()) {
Object[] arr = (Object[]) o;
! if (arr[0] instanceof TransformUtils.ImmutableTransform) {
Transform t = (Transform) arr[0];
// reusing
--- 99,125 ----
@Test public void testImmutableTransformState() {
int counter = 0;
for (Object o : TransformOperationsTest.getParams()) {
Object[] arr = (Object[]) o;
! if (arr[0] instanceof TransformUtilsShim.ImmutableTransformShim) {
! TransformUtilsShim.ImmutableTransformShim t =
! (TransformUtilsShim.ImmutableTransformShim) arr[0];
TransformHelper.assertStateOk("Checking state of transform #" +
(counter++) + " of TransformOperationsTest", t,
! TransformUtilsShim.getImmutableState3d(t),
! TransformUtilsShim.getImmutableState2d(t));
}
}
}
@Test public void testReusedImmutableTransform() {
int counter = 0;
for (Object o : TransformOperationsTest.getParams()) {
Object[] arr = (Object[]) o;
! if (arr[0] instanceof TransformUtilsShim.ImmutableTransformShim) {
Transform t = (Transform) arr[0];
// reusing
*** 129,141 ****
+ counter + " of TransformOperationsTest", reuse, returned);
TransformHelper.assertStateOk(
"Checking reusing immutable transform to values of #"
+ counter + " of TransformOperationsTest",
! (TransformUtils.ImmutableTransform) returned,
! ((TransformUtils.ImmutableTransform) returned).getState3d(),
! ((TransformUtils.ImmutableTransform) returned).getState2d());
TransformHelper.assertMatrix("Checking reusing immutable "
+ "transform to values of #" + counter
+ " of TransformOperationsTest", returned, t);
--- 132,144 ----
+ counter + " of TransformOperationsTest", reuse, returned);
TransformHelper.assertStateOk(
"Checking reusing immutable transform to values of #"
+ counter + " of TransformOperationsTest",
! returned,
! (TransformUtilsShim.getImmutableState3d(returned)),
! (TransformUtilsShim.getImmutableState2d(returned)));
TransformHelper.assertMatrix("Checking reusing immutable "
+ "transform to values of #" + counter
+ " of TransformOperationsTest", returned, t);
*** 146,158 ****
+ counter + " of TransformOperationsTest", returned2, t);
TransformHelper.assertStateOk(
"Checking reusing immutable transform to values of #"
+ counter + " of TransformOperationsTest",
! (TransformUtils.ImmutableTransform) returned2,
! ((TransformUtils.ImmutableTransform) returned2).getState3d(),
! ((TransformUtils.ImmutableTransform) returned2).getState2d());
TransformHelper.assertMatrix("Checking reusing immutable "
+ "transform to values of #" + counter
+ " of TransformOperationsTest", returned2, t);
--- 149,161 ----
+ counter + " of TransformOperationsTest", returned2, t);
TransformHelper.assertStateOk(
"Checking reusing immutable transform to values of #"
+ counter + " of TransformOperationsTest",
! returned2,
! TransformUtilsShim.getImmutableState3d(returned),
! TransformUtilsShim.getImmutableState2d(returned));
TransformHelper.assertMatrix("Checking reusing immutable "
+ "transform to values of #" + counter
+ " of TransformOperationsTest", returned2, t);
*** 161,185 ****
}
}
@Test public void testConcatenatedImmutableTransform() {
! List<TransformUtils.ImmutableTransform> ts = new LinkedList<>();
for (Object o : TransformOperationsTest.getParams()) {
Object[] arr = (Object[]) o;
! if (arr[0] instanceof TransformUtils.ImmutableTransform) {
! ts.add((TransformUtils.ImmutableTransform) arr[0]);
}
}
int outer = 0;
! for (TransformUtils.ImmutableTransform t1 : ts) {
int inner = 0;
! for (TransformUtils.ImmutableTransform t2 : ts) {
int orig = 0;
// reusing
! for (TransformUtils.ImmutableTransform t3 : ts) {
Transform clone = t3.clone();
Transform conc = TransformUtils.immutableTransform(
clone, t1, t2);
assertSame("Checking state of concatenation of "
--- 164,188 ----
}
}
@Test public void testConcatenatedImmutableTransform() {
! List<TransformUtilsShim.ImmutableTransformShim> ts = new LinkedList<>();
for (Object o : TransformOperationsTest.getParams()) {
Object[] arr = (Object[]) o;
! if (arr[0] instanceof TransformUtilsShim.ImmutableTransformShim) {
! ts.add((TransformUtilsShim.ImmutableTransformShim) arr[0]);
}
}
int outer = 0;
! for (TransformUtilsShim.ImmutableTransformShim t1 : ts) {
int inner = 0;
! for (TransformUtilsShim.ImmutableTransformShim t2 : ts) {
int orig = 0;
// reusing
! for (TransformUtilsShim.ImmutableTransformShim t3 : ts) {
Transform clone = t3.clone();
Transform conc = TransformUtils.immutableTransform(
clone, t1, t2);
assertSame("Checking state of concatenation of "
*** 189,201 ****
TransformHelper.assertStateOk(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" reusing #" + orig +
" of TransformOperationsTest",
! (TransformUtils.ImmutableTransform) conc,
! ((TransformUtils.ImmutableTransform) conc).getState3d(),
! ((TransformUtils.ImmutableTransform) conc).getState2d());
TransformHelper.assertMatrix(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" reusing #" + orig +
" of TransformOperationsTest", conc,
--- 192,204 ----
TransformHelper.assertStateOk(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" reusing #" + orig +
" of TransformOperationsTest",
! (TransformUtilsShim.ImmutableTransformShim) conc,
! TransformUtilsShim.getImmutableState3d(conc),
! TransformUtilsShim.getImmutableState2d(conc));
TransformHelper.assertMatrix(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" reusing #" + orig +
" of TransformOperationsTest", conc,
*** 215,227 ****
" of TransformOperationsTest", conc2, t2);
TransformHelper.assertStateOk(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" of TransformOperationsTest",
! (TransformUtils.ImmutableTransform) conc2,
! ((TransformUtils.ImmutableTransform) conc2).getState3d(),
! ((TransformUtils.ImmutableTransform) conc2).getState2d());
TransformHelper.assertMatrix(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" of TransformOperationsTest", conc2,
TransformHelper.concatenate(t1, t2));
--- 218,230 ----
" of TransformOperationsTest", conc2, t2);
TransformHelper.assertStateOk(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" of TransformOperationsTest",
! (TransformUtilsShim.ImmutableTransformShim) conc2,
! TransformUtilsShim.getImmutableState3d(conc2),
! TransformUtilsShim.getImmutableState2d(conc2));
TransformHelper.assertMatrix(
"Checking state of concatenation of "
+ "transform #" + outer + " and #" + inner +
" of TransformOperationsTest", conc2,
TransformHelper.concatenate(t1, t2));