3 using NUnit.Framework.TUnit;
6 namespace Tizen.NUI.Devel.Tests
8 using tlog = Tizen.Log;
11 [Description("public/Common/Matrix3")]
12 public class Matrix3Test
14 private const string tag = "NUITEST";
19 tlog.Info(tag, "Init() is called!");
25 tlog.Info(tag, "Destroy() is called!");
30 [Description("Matrix3 constructor.")]
31 [Property("SPEC", "Tizen.NUI.Matrix3.Matrix3 C")]
32 [Property("SPEC_URL", "-")]
33 [Property("CRITERIA", "CONSTR")]
34 [Property("AUTHOR", "guowei.wang@samsung.com")]
35 public void Matrix3Constructor()
37 tlog.Debug(tag, $"Matrix3Constructor START");
39 var testingTarget = new Matrix3();
40 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
41 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
43 testingTarget.Dispose();
44 tlog.Debug(tag, $"Matrix3Constructor END (OK)");
49 [Description("Matrix3 constructor. With Martrix")]
50 [Property("SPEC", "Tizen.NUI.Matrix3.Matrix3 C")]
51 [Property("SPEC_URL", "-")]
52 [Property("CRITERIA", "CONSTR")]
53 [Property("AUTHOR", "guowei.wang@samsung.com")]
54 public void Matrix3ConstructorWithMartrix()
56 tlog.Debug(tag, $"Matrix3ConstructorWithMartrix START");
58 using (Matrix matrix = new Matrix())
60 var testingTarget = new Matrix3(matrix);
61 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
62 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
64 testingTarget.Dispose();
67 tlog.Debug(tag, $"Matrix3ConstructorWithMartrix END (OK)");
72 [Description("Matrix3 constructor. With Martrix3")]
73 [Property("SPEC", "Tizen.NUI.Matrix3.Matrix3 C")]
74 [Property("SPEC_URL", "-")]
75 [Property("CRITERIA", "CONSTR")]
76 [Property("AUTHOR", "guowei.wang@samsung.com")]
77 public void Matrix3ConstructorWithMartrix3()
79 tlog.Debug(tag, $"Matrix3ConstructorWithMartrix3 START");
81 using (Matrix3 matrix = new Matrix3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f))
83 var testingTarget = new Matrix3(matrix);
84 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
85 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
87 testingTarget.Dispose();
90 tlog.Debug(tag, $"Matrix3ConstructorWithMartrix3 END (OK)");
95 [Description("Matrix3 IDENTITY.")]
96 [Property("SPEC", "Tizen.NUI.Matrix3.IDENTITY A")]
97 [Property("SPEC_URL", "-")]
98 [Property("CRITERIA", "PRO")]
99 [Property("AUTHOR", "guowei.wang@samsung.com")]
100 public void Matrix3IDENTITY()
102 tlog.Debug(tag, $"Matrix3IDENTITY START");
106 var result = Matrix3.IDENTITY;
107 tlog.Debug(tag, "IDENTITY : " + result);
111 tlog.Debug(tag, e.Message.ToString());
112 Assert.Fail("Caught Exception : Failed!");
115 tlog.Debug(tag, $"Matrix3IDENTITY END (OK)");
120 [Description("Matrix3 Assign.")]
121 [Property("SPEC", "Tizen.NUI.Matrix3.Assign M")]
122 [Property("SPEC_URL", "-")]
123 [Property("CRITERIA", "MR")]
124 [Property("AUTHOR", "guowei.wang@samsung.com")]
125 public void Matrix3Assign()
127 tlog.Debug(tag, $"Matrix3Assign START");
129 using (Matrix3 matrix = new Matrix3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f))
131 var testingTarget = matrix.Assign(matrix);
132 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
133 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
135 testingTarget.Dispose();
138 tlog.Debug(tag, $"Matrix3Assign END (OK)");
143 [Description("Matrix3 Assign. With Matrix.")]
144 [Property("SPEC", "Tizen.NUI.Matrix3.Assign M")]
145 [Property("SPEC_URL", "-")]
146 [Property("CRITERIA", "MR")]
147 [Property("AUTHOR", "guowei.wang@samsung.com")]
148 public void Matrix3AssignWithMatrix()
150 tlog.Debug(tag, $"Matrix3AssignWithMatrix START");
152 using (Matrix3 matrix3 = new Matrix3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f))
154 using (Matrix matrix = new Matrix(true))
156 var testingTarget = matrix3.Assign(matrix);
157 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
158 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
160 testingTarget.Dispose();
164 tlog.Debug(tag, $"Matrix3AssignWithMatrix END (OK)");
169 [Description("Matrix3 EqualTo.")]
170 [Property("SPEC", "Tizen.NUI.Matrix3.EqualTo M")]
171 [Property("SPEC_URL", "-")]
172 [Property("CRITERIA", "MR")]
173 [Property("AUTHOR", "guowei.wang@samsung.com")]
174 public void Matrix3EqualTo()
176 tlog.Debug(tag, $"Matrix3EqualTo START");
178 var testingTarget = new Matrix3();
179 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
180 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix instance.");
182 using (Matrix3 matrix3 = new Matrix3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f))
184 var result = testingTarget.EqualTo(matrix3);
185 tlog.Debug(tag, "EqualTo : " + result);
186 Assert.AreEqual(false, result, "EqualTo should be false");
189 testingTarget.Dispose();
190 tlog.Debug(tag, $"MatrixEqualTo END (OK)");
195 [Description("Matrix3 NotEqualTo.")]
196 [Property("SPEC", "Tizen.NUI.Matrix3.NotEqualTo M")]
197 [Property("SPEC_URL", "-")]
198 [Property("CRITERIA", "MR")]
199 [Property("AUTHOR", "guowei.wang@samsung.com")]
200 public void Matrix3NotEqualTo()
202 tlog.Debug(tag, $"Matrix3NotEqualTo START");
204 var testingTarget = new Matrix3();
205 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
206 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
208 using (Matrix3 matrix3 = new Matrix3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f))
210 var result = testingTarget.NotEqualTo(matrix3);
211 tlog.Debug(tag, "NotEqualTo : " + result);
212 Assert.AreEqual(true, result, "NotEqualTo should be true");
215 testingTarget.Dispose();
216 tlog.Debug(tag, $"Matrix3NotEqualTo END (OK)");
221 [Description("Matrix3 SetIdentity.")]
222 [Property("SPEC", "Tizen.NUI.Matrix3.SetIdentity M")]
223 [Property("SPEC_URL", "-")]
224 [Property("CRITERIA", "MR")]
225 [Property("AUTHOR", "guowei.wang@samsung.com")]
226 public void Matrix3SetIdentity()
228 tlog.Debug(tag, $"Matrix3SetIdentity START");
230 var testingTarget = new Matrix3();
231 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
232 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
236 testingTarget.SetIdentity();
240 tlog.Debug(tag, e.Message.ToString());
241 Assert.Fail("Caught Exception : Failed!");
244 testingTarget.Dispose();
245 tlog.Debug(tag, $"Matrix3SetIdentity END (OK)");
250 [Description("Matrix3 Invert.")]
251 [Property("SPEC", "Tizen.NUI.Matrix3.Invert M")]
252 [Property("SPEC_URL", "-")]
253 [Property("CRITERIA", "MR")]
254 [Property("AUTHOR", "guowei.wang@samsung.com")]
255 public void Matrix3Invert()
257 tlog.Debug(tag, $"Matrix3Invert START");
259 // Initialize as invertable matrix
260 var testingTarget = new Matrix3(1.0f, 0.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 0.0f, 3.0f);
261 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
262 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
264 var result = testingTarget.Invert();
265 tlog.Debug(tag, "Invert :" + result);
266 Assert.AreEqual(true, result, "Invert should be successed");
268 testingTarget.Dispose();
269 tlog.Debug(tag, $"Matrix3Invert END (OK)");
274 [Description("Matrix3 Transpose.")]
275 [Property("SPEC", "Tizen.NUI.Matrix3.Transpose M")]
276 [Property("SPEC_URL", "-")]
277 [Property("CRITERIA", "MR")]
278 [Property("AUTHOR", "guowei.wang@samsung.com")]
279 public void Matrix3Transpose()
281 tlog.Debug(tag, $"Matrix3Transpose START");
283 var testingTarget = new Matrix3();
284 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
285 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
287 var result = testingTarget.Transpose();
288 tlog.Debug(tag, "Transpose : " + result);
290 testingTarget.Dispose();
291 tlog.Debug(tag, $"Matrix3Transpose END (OK)");
296 [Description("Matrix3 Scale.")]
297 [Property("SPEC", "Tizen.NUI.Matrix3.Scale M")]
298 [Property("SPEC_URL", "-")]
299 [Property("CRITERIA", "MR")]
300 [Property("AUTHOR", "guowei.wang@samsung.com")]
301 public void Matrix3Scale()
303 tlog.Debug(tag, $"Matrix3Scale START");
305 var testingTarget = new Matrix3();
306 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
307 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
311 testingTarget.Scale(0.3f);
315 tlog.Debug(tag, e.Message.ToString());
316 Assert.Fail("Caught Exception : Failed!");
319 testingTarget.Dispose();
320 tlog.Debug(tag, $"Matrix3Scale END (OK)");
325 [Description("Matrix3 Magnitude.")]
326 [Property("SPEC", "Tizen.NUI.Matrix3.Magnitude M")]
327 [Property("SPEC_URL", "-")]
328 [Property("CRITERIA", "MR")]
329 [Property("AUTHOR", "guowei.wang@samsung.com")]
330 public void Matrix3Magnitude()
332 tlog.Debug(tag, $"Matrix3Magnitude START");
334 var testingTarget = new Matrix3();
335 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
336 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
338 var result = testingTarget.Magnitude();
339 tlog.Debug(tag, "Magnitude : " + result);
341 testingTarget.Dispose();
342 tlog.Debug(tag, $"Matrix3Magnitude END (OK)");
347 [Description("Matrix3 ScaledInverseTranspose.")]
348 [Property("SPEC", "Tizen.NUI.Matrix3.ScaledInverseTranspose M")]
349 [Property("SPEC_URL", "-")]
350 [Property("CRITERIA", "MR")]
351 [Property("AUTHOR", "guowei.wang@samsung.com")]
352 public void Matrix3ScaledInverseTranspose()
354 tlog.Debug(tag, $"Matrix3ScaledInverseTranspose START");
356 var testingTarget = new Matrix3();
357 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
358 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
360 var result = testingTarget.ScaledInverseTranspose();
361 tlog.Debug(tag, "ScaledInverseTranspose : " + result);
363 testingTarget.Dispose();
364 tlog.Debug(tag, $"Matrix3ScaledInverseTranspose END (OK)");
369 [Description("Matrix3 Multiply.")]
370 [Property("SPEC", "Tizen.NUI.Matrix3.Multiply M")]
371 [Property("SPEC_URL", "-")]
372 [Property("CRITERIA", "MR")]
373 [Property("AUTHOR", "guowei.wang@samsung.com")]
374 public void Matrix3Multiply()
376 tlog.Debug(tag, $"Matrix3Multiply START");
378 var testingTarget = new Matrix3();
379 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
380 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
382 using (Matrix3 lhs = new Matrix3())
384 using (Matrix3 rhs = new Matrix3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f))
388 Matrix3.Multiply(testingTarget, lhs, rhs);
392 tlog.Debug(tag, e.Message.ToString());
393 Assert.Fail("Caught Exception : Failed!");
398 testingTarget.Dispose();
399 tlog.Debug(tag, $"Matrix3Multiply END (OK)");
404 [Description("Matrix3 MultiplyAssign.")]
405 [Property("SPEC", "Tizen.NUI.Matrix3.MultiplyAssign M")]
406 [Property("SPEC_URL", "-")]
407 [Property("CRITERIA", "MR")]
408 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
409 public void Matrix3MultiplyAssign()
411 tlog.Debug(tag, $"Matrix3MultiplyAssign START");
413 var testingTarget = new Matrix3();
414 Assert.IsNotNull(testingTarget, "Can't create success object Matrix3.");
415 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix3 instance.");
417 using (Matrix3 rhs = new Matrix3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f))
421 testingTarget.MultiplyAssign(rhs);
425 tlog.Debug(tag, e.Message.ToString());
426 Assert.Fail("Caught Exception : Failed!");
430 testingTarget.Dispose();
431 tlog.Debug(tag, $"Matrix3MultiplyAssign END (OK)");
437 [Description("Matrix ValueOfIndex with signle index.")]
438 [Property("SPEC", "Tizen.NUI.Matrix.ValueOfIndex M")]
439 [Property("SPEC_URL", "-")]
440 [Property("CRITERIA", "MR")]
441 [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
442 public void Matrix3ValueOfIndexSingleIndex()
445 tlog.Debug(tag, $"Matrix3ValueOfIndexSingleIndex START");
447 Matrix3 testingTarget = new Matrix3(0.0f, 1.0f, 2.0f, 0.1f, 1.1f, 2.1f, 0.2f, 1.2f, 2.2f);
448 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
449 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix instance.");
451 for(uint index = 0; index < 9; ++index)
453 float expectResult = (index / 3) * 0.1f + (index % 3) * 1.0f;
454 Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(index), "The value of index is not correct!");
456 testingTarget.Dispose();
457 tlog.Debug(tag, $"Matrix3ValueOfIndexSingleIndex END (OK)");
462 [Description("Matrix3 ValueOfIndex with double index.")]
463 [Property("SPEC", "Tizen.NUI.Matrix3.ValueOfIndex M")]
464 [Property("SPEC_URL", "-")]
465 [Property("CRITERIA", "MR")]
466 [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
467 public void Matrix3ValueOfIndexDoubleIndex()
470 tlog.Debug(tag, $"Matrix3ValueOfIndexDoubleIndex START");
472 Matrix3 testingTarget = new Matrix3(0.0f, 1.0f, 2.0f, 0.1f, 1.1f, 2.1f, 0.2f, 1.2f, 2.2f);
473 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
474 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix instance.");
476 for(uint indexRow = 0; indexRow < 3; ++indexRow)
478 for(uint indexColumn = 0; indexColumn < 3; ++indexColumn)
480 float expectResult = indexColumn * 0.1f + indexRow * 1.0f;
481 Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(indexRow, indexColumn), "The value of index is not correct!");
484 testingTarget.Dispose();
485 tlog.Debug(tag, $"Matrix3ValueOfIndexDoubleIndex END (OK)");
490 [Description("Matrix3 SetValueAtIndex with signle index.")]
491 [Property("SPEC", "Tizen.NUI.Matrix3.SetValueAtIndex M")]
492 [Property("SPEC_URL", "-")]
493 [Property("CRITERIA", "MR")]
494 [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
495 public void Matrix3SetValueAtIndexSingleIndex()
498 tlog.Debug(tag, $"Matrix3SetValueAtIndexSingleIndex START");
499 Matrix3 testingTarget = new Matrix3();
500 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
501 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix instance.");
503 for(uint index = 0; index < 9; ++index)
505 float expectResult = (index / 3) * 0.1f + (index % 3) * 1.0f;
506 testingTarget.SetValueAtIndex(index, expectResult);
507 Assert.AreEqual(expectResult, testingTarget[index], "The value of index is not correct!");
509 testingTarget.Dispose();
510 tlog.Debug(tag, $"Matrix3SetValueAtIndexSingleIndex END (OK)");
515 [Description("Matrix3 SetValueAtIndex with double index.")]
516 [Property("SPEC", "Tizen.NUI.Matrix3.SetValueAtIndex M")]
517 [Property("SPEC_URL", "-")]
518 [Property("CRITERIA", "MR")]
519 [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
520 public void Matrix3SetValueAtIndexDoubleIndex()
523 tlog.Debug(tag, $"Matrix3SetValueAtIndexDoubleIndex START");
524 Matrix3 testingTarget = new Matrix3();
525 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
526 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix instance.");
528 for(uint indexRow = 0; indexRow < 3; ++indexRow)
530 for(uint indexColumn = 0; indexColumn < 3; ++indexColumn)
532 float expectResult = indexColumn * 0.1f + indexRow * 1.0f;
533 testingTarget.SetValueAtIndex(indexRow, indexColumn, expectResult);
534 Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(indexRow, indexColumn), "The value of index is not correct!");
537 testingTarget.Dispose();
538 tlog.Debug(tag, $"Matrix3SetValueAtIndexDoubleIndex END (OK)");
543 [Description("Test Tizen.NUI.Matrix3.operator * with Matrix3.")]
544 [Property("SPEC", "Tizen.NUI.Matrix3.operator *() A")]
545 [Property("SPEC_URL", "-")]
546 [Property("CRITERIA", "MR")]
547 [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
548 public void Matrix3MultiplyOperator()
551 tlog.Debug(tag, $"Matrix3MultiplyOperator START");
552 Matrix3 testingTarget = new Matrix3();
553 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
554 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix instance.");
558 Matrix3 rhs = new Matrix3(1.0f, 0.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 0.0f, 3.0f);
559 Matrix3 ret = testingTarget * rhs;
565 tlog.Debug(tag, e.Message.ToString());
566 Assert.Fail("Caught Exception : Failed!");
568 testingTarget.Dispose();
569 tlog.Debug(tag, $"Matrix3MultiplyOperator END (OK)");
574 [Description("Test Tizen.NUI.Matrix3.operator * with Vector3.")]
575 [Property("SPEC", "Tizen.NUI.Matrix3.operator *() A")]
576 [Property("SPEC_URL", "-")]
577 [Property("CRITERIA", "MR")]
578 [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
579 public void Matrix3MultiplyOperatorWithVector3()
582 tlog.Debug(tag, $"Matrix3MultiplyOperatorWithVector3 START");
583 Matrix3 testingTarget = new Matrix3();
584 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
585 Assert.IsInstanceOf<Matrix3>(testingTarget, "Should return Matrix instance.");
589 Vector3 rhs = new Vector3();
590 Vector3 ret = testingTarget * rhs;
596 tlog.Debug(tag, e.Message.ToString());
597 Assert.Fail("Caught Exception : Failed!");
599 testingTarget.Dispose();
600 tlog.Debug(tag, $"Matrix3MultiplyOperatorWithVector4 END (OK)");
605 [Description("Test this[uint index]. Check whether this[uint index] returns expected value or not.")]
606 [Property("SPEC", "Tizen.NUI.Matrix3.this[uint] A")]
607 [Property("SPEC_URL", "-")]
608 [Property("CRITERIA", "MR")]
609 [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
610 public void this_SET_GET_VALUE()
613 tlog.Debug(tag, $"Matrix3this_SET_GET_VALUE START");
614 Matrix3 testingTarget = new Matrix3();
617 testingTarget[0] = 100.0f;
618 testingTarget[1] = 200.0f;
622 tlog.Debug(tag, e.Message.ToString());
623 Assert.Fail("Caught Exception : Failed!");
625 Assert.AreEqual(100.0f, testingTarget[0], "The value of index[0] is not correct!");
626 Assert.AreEqual(200.0f, testingTarget[1], "The value of index[1] is not correct!");
627 testingTarget.Dispose();
628 tlog.Debug(tag, $"Matrix3this_SET_GET_VALUE END (OK)");