5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.sun.javafx.sg.prism;
26
27 import com.sun.javafx.collections.FloatArraySyncer;
28 import com.sun.javafx.collections.IntegerArraySyncer;
29 import java.util.Arrays;
30 import static org.junit.Assert.assertArrayEquals;
31 import org.junit.Test;
32
33 public class NGTriangleMeshTest {
34
35 private static final float EPSILON_FLOAT = 1e-5f;
36
37 /**
38 * Test of syncFaceSmoothingGroups method, of class NGTriangleMesh.
39 */
40 @Test
41 public void testSyncFaceSmoothingGroups() {
42 final int[] faceSmoothingGroups = new int[]{0, 1, 2, 3, 4, 5};
43 NGTriangleMesh instance = new NGTriangleMesh();
44 instance.syncFaceSmoothingGroups((array, fromAndLengthIndices) -> faceSmoothingGroups);
45 int[] actuals = instance.test_getFaceSmoothingGroups();
46 int[] expecteds = new int[]{0, 1, 2, 3, 4, 5};
47 assertArrayEquals(expecteds, actuals);
48 }
49
50 /**
51 * Test of syncFaceSmoothingGroups method, of class NGTriangleMesh.
52 */
53 @Test
54 public void testSyncFaceSmoothingGroups2() {
55 final int[] faceSmoothingGroups = new int[]{0, 1, 2, 3, 4, 5};
56 NGTriangleMesh instance = new NGTriangleMesh();
57 instance.syncFaceSmoothingGroups((array, fromAndLengthIndices) -> faceSmoothingGroups);
58 instance.syncFaceSmoothingGroups((array, fromAndLengthIndices) -> {
59 Arrays.fill(array, 1, 1 + 4, 1);
60 return array;
61 });
62 int[] actuals = instance.test_getFaceSmoothingGroups();
63 int[] expecteds = new int[]{0, 1, 1, 1, 1, 5};
64 assertArrayEquals(expecteds, actuals);
65 }
66
67 /**
68 * Test of syncPoints method, of class NGTriangleMesh.
69 */
70 @Test
71 public void testSyncPoints() {
72 final float[] points = new float[]{0, 1, 2, 3, 4, 5};
73 NGTriangleMesh instance = new NGTriangleMesh();
74 instance.syncPoints((array, fromAndLengthIndices) -> points);
75 float[] actuals = instance.test_getPoints();
76 float[] expecteds = new float[]{0, 1, 2, 3, 4, 5};
77 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
78 }
79
80 /**
81 * Test of syncPoints method, of class NGTriangleMesh.
82 */
83 @Test
84 public void testSyncPoints2() {
85 final float[] points = new float[]{0, 1, 2, 3, 4, 5};
86 NGTriangleMesh instance = new NGTriangleMesh();
87 instance.syncPoints((array, fromAndLengthIndices) -> points);
88 instance.syncPoints((array, fromAndLengthIndices) -> {
89 Arrays.fill(array, 1, 1 + 4, 1);
90 return array;
91 });
92 float[] actuals = instance.test_getPoints();
93 float[] expecteds = new float[]{0, 1, 1, 1, 1, 5};
94 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
95 }
96
97 /**
98 * Test of syncNormals method, of class NGTriangleMesh.
99 */
100 @Test
101 public void testSyncNormals() {
102 final float[] normals = new float[]{0, 1, 2, 3, 4, 5};
103 NGTriangleMesh instance = new NGTriangleMesh();
104 instance.syncNormals((array, fromAndLengthIndices) -> normals);
105 float[] actuals = instance.test_getNormals();
106 float[] expecteds = new float[]{0, 1, 2, 3, 4, 5};
107 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
108 }
109
110 /**
111 * Test of syncNormals method, of class NGTriangleMesh.
112 */
113 @Test
114 public void testSyncNormals2() {
115 final float[] normals = new float[]{0, 1, 2, 3, 4, 5};
116 NGTriangleMesh instance = new NGTriangleMesh();
117 instance.syncNormals((array, fromAndLengthIndices) -> normals);
118 instance.syncNormals((array, fromAndLengthIndices) -> {
119 Arrays.fill(array, 1, 1 + 4, 1);
120 return array;
121 });
122 float[] actuals = instance.test_getNormals();
123 float[] expecteds = new float[]{0, 1, 1, 1, 1, 5};
124 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
125 }
126
127 /**
128 * Test of syncTexCoords method, of class NGTriangleMesh.
129 */
130 @Test
131 public void testSyncTexCoords() {
132 final float[] texcoords = new float[]{0, 1, 2, 3, 4, 5};
133 NGTriangleMesh instance = new NGTriangleMesh();
134 instance.syncTexCoords((array, fromAndLengthIndices) -> texcoords);
135 float[] actuals = instance.test_getTexCoords();
136 float[] expecteds = new float[]{0, 1, 2, 3, 4, 5};
137 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
138 }
139
140 /**
141 * Test of syncTexCoords method, of class NGTriangleMesh.
142 */
143 @Test
144 public void testSyncTexCoords2() {
145 final float[] texcoords = new float[]{0, 1, 2, 3, 4, 5};
146 NGTriangleMesh instance = new NGTriangleMesh();
147 instance.syncTexCoords((array, fromAndLengthIndices) -> texcoords);
148 instance.syncTexCoords((array, fromAndLengthIndices) -> {
149 Arrays.fill(array, 1, 1 + 4, 1);
150 return array;
151 });
152 float[] actuals = instance.test_getTexCoords();
153 float[] expecteds = new float[]{0, 1, 1, 1, 1, 5};
154 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
155 }
156
157 /**
158 * Test of syncFaces method, of class NGTriangleMesh.
159 */
160 @Test
161 public void testSyncFaces() {
162 final int[] faces = new int[]{0, 1, 2, 3, 4, 5};
163 NGTriangleMesh instance = new NGTriangleMesh();
164 instance.syncFaces((array, fromAndLengthIndices) -> faces);
165 int[] actuals = instance.test_getFaces();
166 int[] expecteds = new int[]{0, 1, 2, 3, 4, 5};
167 assertArrayEquals(expecteds, actuals);
168 }
169
170 /**
171 * Test of syncFaces method, of class NGTriangleMesh.
172 */
173 @Test
174 public void testSyncFaces2() {
175 final int[] faces = new int[]{0, 1, 2, 3, 4, 5};
176 NGTriangleMesh instance = new NGTriangleMesh();
177 instance.syncFaces((array, fromAndLengthIndices) -> faces);
178 instance.syncFaces((array, fromAndLengthIndices) -> {
179 Arrays.fill(array, 1, 1 + 4, 1);
180 return array;
181 });
182 int[] actuals = instance.test_getFaces();
183 int[] expecteds = new int[]{0, 1, 1, 1, 1, 5};
184 assertArrayEquals(expecteds, actuals);
185 }
186 }
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package test.com.sun.javafx.sg.prism;
26
27 import com.sun.javafx.collections.FloatArraySyncer;
28 import com.sun.javafx.collections.IntegerArraySyncer;
29 import com.sun.javafx.sg.prism.NGTriangleMeshShim;
30 import java.util.Arrays;
31 import static org.junit.Assert.assertArrayEquals;
32 import org.junit.Test;
33
34 public class NGTriangleMeshTest {
35
36 private static final float EPSILON_FLOAT = 1e-5f;
37
38 /**
39 * Test of syncFaceSmoothingGroups method, of class NGTriangleMesh.
40 */
41 @Test
42 public void testSyncFaceSmoothingGroups() {
43 final int[] faceSmoothingGroups = new int[]{0, 1, 2, 3, 4, 5};
44 NGTriangleMeshShim instance = new NGTriangleMeshShim();
45 instance.syncFaceSmoothingGroups((array, fromAndLengthIndices) -> faceSmoothingGroups);
46 int[] actuals = instance.test_getFaceSmoothingGroups();
47 int[] expecteds = new int[]{0, 1, 2, 3, 4, 5};
48 assertArrayEquals(expecteds, actuals);
49 }
50
51 /**
52 * Test of syncFaceSmoothingGroups method, of class NGTriangleMesh.
53 */
54 @Test
55 public void testSyncFaceSmoothingGroups2() {
56 final int[] faceSmoothingGroups = new int[]{0, 1, 2, 3, 4, 5};
57 NGTriangleMeshShim instance = new NGTriangleMeshShim();
58 instance.syncFaceSmoothingGroups((array, fromAndLengthIndices) -> faceSmoothingGroups);
59 instance.syncFaceSmoothingGroups((array, fromAndLengthIndices) -> {
60 Arrays.fill(array, 1, 1 + 4, 1);
61 return array;
62 });
63 int[] actuals = instance.test_getFaceSmoothingGroups();
64 int[] expecteds = new int[]{0, 1, 1, 1, 1, 5};
65 assertArrayEquals(expecteds, actuals);
66 }
67
68 /**
69 * Test of syncPoints method, of class NGTriangleMesh.
70 */
71 @Test
72 public void testSyncPoints() {
73 final float[] points = new float[]{0, 1, 2, 3, 4, 5};
74 NGTriangleMeshShim instance = new NGTriangleMeshShim();
75 instance.syncPoints((array, fromAndLengthIndices) -> points);
76 float[] actuals = instance.test_getPoints();
77 float[] expecteds = new float[]{0, 1, 2, 3, 4, 5};
78 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
79 }
80
81 /**
82 * Test of syncPoints method, of class NGTriangleMesh.
83 */
84 @Test
85 public void testSyncPoints2() {
86 final float[] points = new float[]{0, 1, 2, 3, 4, 5};
87 NGTriangleMeshShim instance = new NGTriangleMeshShim();
88 instance.syncPoints((array, fromAndLengthIndices) -> points);
89 instance.syncPoints((array, fromAndLengthIndices) -> {
90 Arrays.fill(array, 1, 1 + 4, 1);
91 return array;
92 });
93 float[] actuals = instance.test_getPoints();
94 float[] expecteds = new float[]{0, 1, 1, 1, 1, 5};
95 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
96 }
97
98 /**
99 * Test of syncNormals method, of class NGTriangleMesh.
100 */
101 @Test
102 public void testSyncNormals() {
103 final float[] normals = new float[]{0, 1, 2, 3, 4, 5};
104 NGTriangleMeshShim instance = new NGTriangleMeshShim();
105 instance.syncNormals((array, fromAndLengthIndices) -> normals);
106 float[] actuals = instance.test_getNormals();
107 float[] expecteds = new float[]{0, 1, 2, 3, 4, 5};
108 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
109 }
110
111 /**
112 * Test of syncNormals method, of class NGTriangleMesh.
113 */
114 @Test
115 public void testSyncNormals2() {
116 final float[] normals = new float[]{0, 1, 2, 3, 4, 5};
117 NGTriangleMeshShim instance = new NGTriangleMeshShim();
118 instance.syncNormals((array, fromAndLengthIndices) -> normals);
119 instance.syncNormals((array, fromAndLengthIndices) -> {
120 Arrays.fill(array, 1, 1 + 4, 1);
121 return array;
122 });
123 float[] actuals = instance.test_getNormals();
124 float[] expecteds = new float[]{0, 1, 1, 1, 1, 5};
125 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
126 }
127
128 /**
129 * Test of syncTexCoords method, of class NGTriangleMesh.
130 */
131 @Test
132 public void testSyncTexCoords() {
133 final float[] texcoords = new float[]{0, 1, 2, 3, 4, 5};
134 NGTriangleMeshShim instance = new NGTriangleMeshShim();
135 instance.syncTexCoords((array, fromAndLengthIndices) -> texcoords);
136 float[] actuals = instance.test_getTexCoords();
137 float[] expecteds = new float[]{0, 1, 2, 3, 4, 5};
138 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
139 }
140
141 /**
142 * Test of syncTexCoords method, of class NGTriangleMesh.
143 */
144 @Test
145 public void testSyncTexCoords2() {
146 final float[] texcoords = new float[]{0, 1, 2, 3, 4, 5};
147 NGTriangleMeshShim instance = new NGTriangleMeshShim();
148 instance.syncTexCoords((array, fromAndLengthIndices) -> texcoords);
149 instance.syncTexCoords((array, fromAndLengthIndices) -> {
150 Arrays.fill(array, 1, 1 + 4, 1);
151 return array;
152 });
153 float[] actuals = instance.test_getTexCoords();
154 float[] expecteds = new float[]{0, 1, 1, 1, 1, 5};
155 assertArrayEquals(expecteds, actuals, EPSILON_FLOAT);
156 }
157
158 /**
159 * Test of syncFaces method, of class NGTriangleMesh.
160 */
161 @Test
162 public void testSyncFaces() {
163 final int[] faces = new int[]{0, 1, 2, 3, 4, 5};
164 NGTriangleMeshShim instance = new NGTriangleMeshShim();
165 instance.syncFaces((array, fromAndLengthIndices) -> faces);
166 int[] actuals = instance.test_getFaces();
167 int[] expecteds = new int[]{0, 1, 2, 3, 4, 5};
168 assertArrayEquals(expecteds, actuals);
169 }
170
171 /**
172 * Test of syncFaces method, of class NGTriangleMesh.
173 */
174 @Test
175 public void testSyncFaces2() {
176 final int[] faces = new int[]{0, 1, 2, 3, 4, 5};
177 NGTriangleMeshShim instance = new NGTriangleMeshShim();
178 instance.syncFaces((array, fromAndLengthIndices) -> faces);
179 instance.syncFaces((array, fromAndLengthIndices) -> {
180 Arrays.fill(array, 1, 1 + 4, 1);
181 return array;
182 });
183 int[] actuals = instance.test_getFaces();
184 int[] expecteds = new int[]{0, 1, 1, 1, 1, 5};
185 assertArrayEquals(expecteds, actuals);
186 }
187 }
|