3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
7 namespace Tizen.NUI.Devel.Tests
9 using tlog = Tizen.Log;
12 [Description("public/Common/Matrix")]
13 public class PublicMatrixTest
15 private const string tag = "NUITEST";
20 tlog.Info(tag, "Init() is called!");
26 tlog.Info(tag, "Destroy() is called!");
31 [Description("Matrix constructor, with bool")]
32 [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
33 [Property("SPEC_URL", "-")]
34 [Property("CRITERIA", "CONSTR")]
35 [Property("AUTHOR", "guowei.wang@samsung.com")]
36 public void MatrixConstructorwithbool()
38 tlog.Debug(tag, $"MatrixConstructorwithbool START");
40 Matrix testingTarget = new Matrix(false);
41 Assert.IsNotNull(testingTarget, "Should be not null!");
42 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
44 testingTarget.Dispose();
45 tlog.Debug(tag, $"MatrixConstructorwithbool END (OK)");
50 [Description("Matrix constructor, with Rotation")]
51 [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
52 [Property("SPEC_URL", "-")]
53 [Property("CRITERIA", "CONSTR")]
54 [Property("AUTHOR", "guowei.wang@samsung.com")]
55 public void MatrixConstructorwithRotation()
57 tlog.Debug(tag, $"MatrixConstructorwithRotation START");
59 Rotation obj = new Rotation();
60 Matrix testingTarget = new Matrix(obj);
61 Assert.IsNotNull(testingTarget, "Should be not null!");
62 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
64 testingTarget.Dispose();
65 tlog.Debug(tag, $"MatrixConstructorwithRotation END (OK)");
70 [Description("Matrix constructor, with Matrix")]
71 [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
72 [Property("SPEC_URL", "-")]
73 [Property("CRITERIA", "CONSTR")]
74 [Property("AUTHOR", "guowei.wang@samsung.com")]
75 public void MatrixConstructorwithMatrix()
77 tlog.Debug(tag, $"MatrixConstructorwithMatrix START");
79 Matrix matrix = new Matrix();
80 matrix.SetXAxis(new Vector3(1.0f, 2.0f, 3.0f));
81 matrix.SetYAxis(new Vector3(1.0f, 2.0f, 3.0f));
82 matrix.SetZAxis(new Vector3(1.0f, 2.0f, 3.0f));
84 var testingTarget = new Matrix(matrix);
85 Assert.IsNotNull(testingTarget, "Should be not null!");
86 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
90 testingTarget.Invert();
94 tlog.Debug(tag, e.Message.ToString());
95 Assert.Fail("Caught Exception : Failed!");
98 testingTarget.Dispose();
99 tlog.Debug(tag, $"MatrixConstructorwithMatrix END (OK)");
104 [Description("Matrix constructor, with array")]
105 [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
106 [Property("SPEC_URL", "-")]
107 [Property("CRITERIA", "CONSTR")]
108 [Property("AUTHOR", "guowei.wang@samsung.com")]
109 public void MatrixConstructorwithArray()
111 tlog.Debug(tag, $"MatrixConstructorwithArray START");
113 var array = new float[3] { 1.0f, 3.0f, 5.0f };
114 var testingTarget = new Matrix(array);
115 Assert.IsNotNull(testingTarget, "Should be not null!");
116 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
120 testingTarget.OrthoNormalize();
124 tlog.Debug(tag, e.Message);
125 Assert.Fail("Caught Exception : Failed!");
128 testingTarget.Dispose();
129 tlog.Debug(tag, $"MatrixConstructorwithArray END (OK)");
134 [Description("Matrix GetYAxis.")]
135 [Property("SPEC", "Tizen.NUI.Matrix.GetYAxis M")]
136 [Property("SPEC_URL", "-")]
137 [Property("CRITERIA", "MR")]
138 [Property("AUTHOR", "guowei.wang@samsung.com")]
139 public void MatrixGetYAxis()
141 tlog.Debug(tag, $"MatrixGetYAxis START");
143 var testingTarget = new Matrix();
144 Assert.IsNotNull(testingTarget, "Should be not null!");
145 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
149 testingTarget.GetYAxis();
153 tlog.Debug(tag, e.Message.ToString());
154 Assert.Fail("Caught Exception : Failed!");
157 tlog.Debug(tag, $"MatrixGetYAxis END (OK)");
162 [Description("Matrix GetZAxis.")]
163 [Property("SPEC", "Tizen.NUI.Matrix.GetZAxis M")]
164 [Property("SPEC_URL", "-")]
165 [Property("CRITERIA", "MR")]
166 [Property("AUTHOR", "guowei.wang@samsung.com")]
167 public void MatrixGetZAxis()
169 tlog.Debug(tag, $"MatrixGetZAxis START");
171 var testingTarget = new Matrix();
172 Assert.IsNotNull(testingTarget, "Should be not null!");
173 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
177 testingTarget.GetZAxis();
181 tlog.Debug(tag, e.Message.ToString());
182 Assert.Fail("Caught Exception : Failed!");
185 tlog.Debug(tag, $"MatrixGetZAxis END (OK)");
190 [Description("Matrix SetXAxis.")]
191 [Property("SPEC", "Tizen.NUI.Matrix.SetXAxis M")]
192 [Property("SPEC_URL", "-")]
193 [Property("CRITERIA", "MR")]
194 [Property("AUTHOR", "guowei.wang@samsung.com")]
195 public void MatrixSetXAxis()
197 tlog.Debug(tag, $"MatrixSetXAxis START");
199 var testingTarget = new Matrix();
200 Assert.IsNotNull(testingTarget, "Should be not null!");
201 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
205 Vector3 axis = new Vector3(1.0f, 2.0f, 3.0f);
206 testingTarget.SetXAxis(axis);
210 tlog.Debug(tag, e.Message.ToString());
211 Assert.Fail("Caught Exception : Failed!");
214 tlog.Debug(tag, $"MatrixSetXAxis END (OK)");
219 [Description("Matrix SetYAxis.")]
220 [Property("SPEC", "Tizen.NUI.Matrix.SetYAxis M")]
221 [Property("SPEC_URL", "-")]
222 [Property("CRITERIA", "MR")]
223 [Property("AUTHOR", "guowei.wang@samsung.com")]
224 public void MatrixSetYAxis()
226 tlog.Debug(tag, $"MatrixSetYAxis START");
228 var testingTarget = new Matrix();
229 Assert.IsNotNull(testingTarget, "Should be not null!");
230 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
234 Vector3 axis = new Vector3(1.0f, 2.0f, 3.0f);
235 testingTarget.SetYAxis(axis);
239 tlog.Debug(tag, e.Message.ToString());
240 Assert.Fail("Caught Exception : Failed!");
243 tlog.Debug(tag, $"MatrixSetYAxis END (OK)");
248 [Description("Matrix SetZAxis.")]
249 [Property("SPEC", "Tizen.NUI.Matrix.SetZAxis M")]
250 [Property("SPEC_URL", "-")]
251 [Property("CRITERIA", "MR")]
252 [Property("AUTHOR", "guowei.wang@samsung.com")]
253 public void MatrixSetZAxis()
255 tlog.Debug(tag, $"MatrixSetZAxis START");
257 var testingTarget = new Matrix();
258 Assert.IsNotNull(testingTarget, "Should be not null!");
259 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
263 Vector3 axis = new Vector3(1.0f, 2.0f, 3.0f);
264 testingTarget.SetZAxis(axis);
268 tlog.Debug(tag, e.Message.ToString());
269 Assert.Fail("Caught Exception : Failed!");
272 tlog.Debug(tag, $"MatrixSetZAxis END (OK)");
277 [Description("Matrix GetTranslation.")]
278 [Property("SPEC", "Tizen.NUI.Matrix.GetTranslation M")]
279 [Property("SPEC_URL", "-")]
280 [Property("CRITERIA", "MR")]
281 [Property("AUTHOR", "guowei.wang@samsung.com")]
282 public void MatrixGetTranslation()
284 tlog.Debug(tag, $"MatrixGetTranslation START");
286 var testingTarget = new Matrix();
287 Assert.IsNotNull(testingTarget, "Should be not null!");
288 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
292 testingTarget.GetTranslation();
296 tlog.Debug(tag, e.Message.ToString());
297 Assert.Fail("Caught Exception : Failed!");
300 tlog.Debug(tag, $"MatrixGetTranslation END (OK)");
305 [Description("Matrix GetTranslation3.")]
306 [Property("SPEC", "Tizen.NUI.Matrix.GetTranslation3 M")]
307 [Property("SPEC_URL", "-")]
308 [Property("CRITERIA", "MR")]
309 [Property("AUTHOR", "guowei.wang@samsung.com")]
310 public void MatrixGetTranslation3()
312 tlog.Debug(tag, $"MatrixGetTranslation3 START");
314 var testingTarget = new Matrix();
315 Assert.IsNotNull(testingTarget, "Should be not null!");
316 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
320 testingTarget.GetTranslation3();
324 tlog.Debug(tag, e.Message.ToString());
325 Assert.Fail("Caught Exception : Failed!");
328 tlog.Debug(tag, $"MatrixGetTranslation3 END (OK)");
333 [Description("Matrix SetTranslation.")]
334 [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation vector4 M")]
335 [Property("SPEC_URL", "-")]
336 [Property("CRITERIA", "MR")]
337 [Property("AUTHOR", "guowei.wang@samsung.com")]
338 public void MatrixSetTranslationwithVector4()
340 tlog.Debug(tag, $"MatrixSetTranslationwithVector4 START");
342 var testingTarget = new Matrix();
343 Assert.IsNotNull(testingTarget, "Should be not null!");
344 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
348 Vector4 translation = new Vector4(0.3f, 0.5f, 0.8f, 1.0f);
349 testingTarget.SetTranslation(translation);
353 tlog.Debug(tag, e.Message.ToString());
354 Assert.Fail("Caught Exception : Failed!");
357 tlog.Debug(tag, $"MatrixSetTranslationwithVector4 END (OK)");
362 [Description("Matrix SetTranslation.")]
363 [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation vector3 M")]
364 [Property("SPEC_URL", "-")]
365 [Property("CRITERIA", "MR")]
366 [Property("AUTHOR", "guowei.wang@samsung.com")]
367 public void MatrixSetTranslationwithVector3()
369 tlog.Debug(tag, $"MatrixSetTranslationwithVector3 START");
371 var testingTarget = new Matrix();
372 Assert.IsNotNull(testingTarget, "Should be not null!");
373 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
377 Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f);
378 testingTarget.SetTranslation(vector);
382 tlog.Debug(tag, e.Message.ToString());
383 Assert.Fail("Caught Exception : Failed!");
386 tlog.Debug(tag, $"MatrixSetTranslationwithVector3 END (OK)");
391 [Description("Matrix IDENTITY.")]
392 [Property("SPEC", "Tizen.NUI.Matrix.IDENTITY A")]
393 [Property("SPEC_URL", "-")]
394 [Property("CRITERIA", "PRO")]
395 [Property("AUTHOR", "guowei.wang@samsung.com")]
396 public void MatrixIDENTITY()
398 tlog.Debug(tag, $"MatrixIDENTITY START");
400 var testingTarget = Matrix.IDENTITY;
401 Assert.IsNotNull(testingTarget, "Should be not null!");
402 Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
404 tlog.Debug(tag, $"MatrixIDENTITY END (OK)");
409 [Description("Matrix Multiply, (Matrix result, Matrix lhs, Matrix rhs)")]
410 [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
411 [Property("SPEC_URL", "-")]
412 [Property("CRITERIA", "PRO")]
413 [Property("AUTHOR", "guowei.wang@samsung.com")]
414 public void MatrixMultiply()
416 tlog.Debug(tag, $"MatrixMultiply START");
418 Matrix lhs = new Matrix();
419 using (Vector3 vec = new Vector3(1.0f, 2.0f, 3.0f))
426 Matrix rhs = new Matrix();
427 using (Vector3 vec = new Vector3(2.0f, 3.0f, 4.0f))
436 Matrix result = new Matrix();
437 Matrix.Multiply(result, lhs, rhs);
441 tlog.Debug(tag, e.Message);
442 Assert.Fail("Caught Exception : Failed!");
445 tlog.Debug(tag, $"MatrixMultiply END (OK)");
450 [Description("Matrix Multiply, (Matrix result, Matrix lhs, Rotation rhs)")]
451 [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
452 [Property("SPEC_URL", "-")]
453 [Property("CRITERIA", "PRO")]
454 [Property("AUTHOR", "guowei.wang@samsung.com")]
455 public void MatrixMultiplyWithRotation()
457 tlog.Debug(tag, $"MatrixMultiplyWithRotation START");
459 Matrix lhs = new Matrix();
460 using (Vector3 vec = new Vector3(1.0f, 2.0f, 3.0f))
469 Matrix result = new Matrix();
470 Rotation rhs = new Rotation(new Radian(6.0f), new Vector3(1.0f, 2.0f, 3.0f));
471 Matrix.Multiply(result, lhs, rhs);
475 tlog.Debug(tag, e.Message);
476 Assert.Fail("Caught Exception : Failed!");
479 tlog.Debug(tag, $"MatrixMultiplyWithRotation END (OK)");