[NUI] Write comments for Matrix and Matrix3
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / Tizen.NUI.Devel.Tests / testcase / public / Common / TSMatrix.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI;
5
6 namespace Tizen.NUI.Devel.Tests
7 {
8     using tlog = Tizen.Log;
9
10     [TestFixture]
11     [Description("public/Common/Matrix")]
12     public class MatrixTest
13     {
14         private const string tag = "NUITEST";
15
16         [SetUp]
17         public void Init()
18         {
19             tlog.Info(tag, "Init() is called!");
20         }
21
22         [TearDown]
23         public void Destroy()
24         {
25             tlog.Info(tag, "Destroy() is called!");
26         }
27
28         [Test]
29         [Category("P1")]
30         [Description("Matrix constructor.")]
31         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
32         [Property("SPEC_URL", "-")]
33         [Property("CRITERIA", "CONSTR")]
34         [Property("AUTHOR", "guowei.wang@samsung.com")]
35         public void MatrixConstructor()
36         {
37             tlog.Debug(tag, $"MatrixConstructor START");
38
39             var testingTarget = new Matrix();
40             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
41             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
42
43             testingTarget.Dispose();
44             tlog.Debug(tag, $"MatrixConstructor END (OK)");
45         }
46
47         [Test]
48         [Category("P1")]
49         [Description("Matrix constructor. With boolean.")]
50         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
51         [Property("SPEC_URL", "-")]
52         [Property("CRITERIA", "CONSTR")]
53         [Property("AUTHOR", "guowei.wang@samsung.com")]
54         public void MatrixConstructorWithBoolean()
55         {
56             tlog.Debug(tag, $"MatrixConstructorWithBoolean START");
57
58             var testingTarget = new Matrix(true);
59             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
60             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
61
62             testingTarget.Dispose();
63             tlog.Debug(tag, $"MatrixConstructorWithBoolean END (OK)");
64         }
65
66         [Test]
67         [Category("P1")]
68         [Description("Matrix constructor. With float array.")]
69         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
70         [Property("SPEC_URL", "-")]
71         [Property("CRITERIA", "CONSTR")]
72         [Property("AUTHOR", "guowei.wang@samsung.com")]
73         public void MatrixConstructorWithFloatArray()
74         {
75             tlog.Debug(tag, $"MatrixConstructorWithFloatArray START");
76
77             float[] arr = new float[16]
78             { 0.0f, 1.0f, 2.0f, 3.0f,
79               0.1f, 1.1f, 2.1f, 3.1f,
80               0.2f, 1.2f, 2.2f, 3.2f,
81               0.3f, 1.3f, 2.3f, 3.3f};
82
83             var testingTarget = new Matrix(arr);
84             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
85             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
86
87             testingTarget.Dispose();
88             tlog.Debug(tag, $"MatrixConstructorWithFloatArray END (OK)");
89         }
90
91         [Test]
92         [Category("P1")]
93         [Description("Matrix constructor. With Rotation.")]
94         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
95         [Property("SPEC_URL", "-")]
96         [Property("CRITERIA", "CONSTR")]
97         [Property("AUTHOR", "guowei.wang@samsung.com")]
98         public void MatrixConstructorWithRotation()
99         {
100             tlog.Debug(tag, $"MatrixConstructorWithRotation START");
101
102             using (Rotation rotation = new Rotation())
103             {
104                 var testingTarget = new Matrix(rotation);
105                 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
106                 Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
107
108                 testingTarget.Dispose();
109             }
110
111             tlog.Debug(tag, $"MatrixConstructorWithRotation END (OK)");
112         }
113
114         [Test]
115         [Category("P1")]
116         [Description("Matrix constructor. With Matrix.")]
117         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
118         [Property("SPEC_URL", "-")]
119         [Property("CRITERIA", "CONSTR")]
120         [Property("AUTHOR", "guowei.wang@samsung.com")]
121         public void MatrixConstructorWithMatrix()
122         {
123             tlog.Debug(tag, $"MatrixConstructorWithMatrix START");
124
125             using (Matrix martrix = new Matrix(true))
126             {
127                 var testingTarget = new Matrix(martrix);
128                 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
129                 Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
130
131                 testingTarget.Dispose();
132             }
133
134             tlog.Debug(tag, $"MatrixConstructorWithMatrix END (OK)");
135         }
136
137         [Test]
138         [Category("P1")]
139         [Description("Matrix Assign.")]
140         [Property("SPEC", "Tizen.NUI.Matrix.Assign M")]
141         [Property("SPEC_URL", "-")]
142         [Property("CRITERIA", "MR")]
143         [Property("AUTHOR", "guowei.wang@samsung.com")]
144         public void MatrixAssign()
145         {
146             tlog.Debug(tag, $"MatrixAssign START");
147
148             using (Matrix martrix = new Matrix(true))
149             {
150                 var testingTarget = martrix.Assign(martrix);
151                 Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
152                 Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
153
154                 testingTarget.Dispose();
155             }
156
157             tlog.Debug(tag, $"MatrixAssign END (OK)");
158         }
159
160         [Test]
161         [Category("P1")]
162         [Description("Matrix Identity.")]
163         [Property("SPEC", "Tizen.NUI.Matrix.Identity A")]
164         [Property("SPEC_URL", "-")]
165         [Property("CRITERIA", "PRO")]
166         [Property("AUTHOR", "guowei.wang@samsung.com")]
167         public void MatrixIdentity()
168         {
169             tlog.Debug(tag, $"MatrixIdentity START");
170
171             try
172             {
173                 var result = Matrix.Identity;
174                 tlog.Debug(tag, "Identity : " + result);
175             }
176             catch (Exception e)
177             {
178                 tlog.Debug(tag, e.Message.ToString());
179                 Assert.Fail("Caught Exception : Failed!");
180             }
181
182             tlog.Debug(tag, $"MatrixIdentity END (OK)");
183         }
184
185         [Test]
186         [Category("P1")]
187         [Description("Matrix SetIdentity.")]
188         [Property("SPEC", "Tizen.NUI.Matrix.SetIdentity M")]
189         [Property("SPEC_URL", "-")]
190         [Property("CRITERIA", "MR")]
191         [Property("AUTHOR", "guowei.wang@samsung.com")]
192         public void MatrixSetIdentity()
193         {
194             tlog.Debug(tag, $"MatrixSetIdentity START");
195
196             var testingTarget = new Matrix();
197             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
198             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
199
200             try
201             {
202                 testingTarget.SetIdentity();
203             }
204             catch (Exception e)
205             {
206                 tlog.Debug(tag, e.Message.ToString());
207                 Assert.Fail("Caught Exception : Failed!");
208             }
209
210             testingTarget.Dispose();
211             tlog.Debug(tag, $"MatrixSetIdentity END (OK)");
212         }
213
214         [Test]
215         [Category("P1")]
216         [Description("Matrix SetIdentityAndScale.")]
217         [Property("SPEC", "Tizen.NUI.Matrix.SetIdentityAndScale M")]
218         [Property("SPEC_URL", "-")]
219         [Property("CRITERIA", "MR")]
220         [Property("AUTHOR", "guowei.wang@samsung.com")]
221         public void MatrixSetIdentityAndScale()
222         {
223             tlog.Debug(tag, $"MatrixSetIdentityAndScale START");
224
225             var testingTarget = new Matrix();
226             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
227             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
228
229             try
230             {
231                 using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
232                 {
233                     testingTarget.SetIdentityAndScale(vector);
234                 }
235             }
236             catch (Exception e)
237             {
238                 tlog.Debug(tag, e.Message.ToString());
239                 Assert.Fail("Caught Exception : Failed!");
240             }
241
242             testingTarget.Dispose();
243             tlog.Debug(tag, $"MatrixSetIdentityAndScale END (OK)");
244         }
245
246         [Test]
247         [Category("P1")]
248         [Description("Matrix Invert.")]
249         [Property("SPEC", "Tizen.NUI.Matrix.Invert M")]
250         [Property("SPEC_URL", "-")]
251         [Property("CRITERIA", "MR")]
252         [Property("AUTHOR", "guowei.wang@samsung.com")]
253         public void MatrixInvert()
254         {
255             tlog.Debug(tag, $"MatrixInvert START");
256
257             // Initialize as invertable matrix
258             float[] arr = new float[16]
259             { 0.0f, 2.0f, 0.0f, 0.0f,
260               1.0f, 0.0f, 0.0f, 0.0f,
261               0.0f, 0.0f, 0.0f, 4.0f,
262               0.0f, 0.0f, 3.0f, 0.0f};
263
264             var testingTarget = new Matrix(arr);
265             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
266             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
267
268             try
269             {
270                 var result = testingTarget.Invert();
271                 tlog.Debug(tag, "Invert : " + result);
272                 Assert.AreEqual(true, result, "Invert should be successed");
273             }
274             catch (Exception e)
275             {
276                 tlog.Debug(tag, e.Message.ToString());
277                 Assert.Fail("Caught Exception : Failed!");
278             }
279
280             testingTarget.Dispose();
281             tlog.Debug(tag, $"MatrixInvert END (OK)");
282         }
283
284         [Test]
285         [Category("P1")]
286         [Description("Matrix Transpose.")]
287         [Property("SPEC", "Tizen.NUI.Matrix.Transpose M")]
288         [Property("SPEC_URL", "-")]
289         [Property("CRITERIA", "MR")]
290         [Property("AUTHOR", "guowei.wang@samsung.com")]
291         public void MatrixTranspose()
292         {
293             tlog.Debug(tag, $"MatrixTranspose START");
294
295             var testingTarget = new Matrix();
296             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
297             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
298
299             try
300             {
301                 testingTarget.Transpose();
302             }
303             catch (Exception e)
304             {
305                 tlog.Debug(tag, e.Message.ToString());
306                 Assert.Fail("Caught Exception : Failed!");
307             }
308
309             testingTarget.Dispose();
310             tlog.Debug(tag, $"MatrixTranspose END (OK)");
311         }
312
313         [Test]
314         [Category("P1")]
315         [Description("Matrix SetXAxis.")]
316         [Property("SPEC", "Tizen.NUI.Matrix.SetXAxis M")]
317         [Property("SPEC_URL", "-")]
318         [Property("CRITERIA", "MR")]
319         [Property("AUTHOR", "guowei.wang@samsung.com")]
320         public void MatrixSetXAxis()
321         {
322             tlog.Debug(tag, $"MatrixSetXAxis START");
323
324             var testingTarget = new Matrix();
325             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
326             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
327
328
329             using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
330             {
331                 testingTarget.SetXAxis(vector);
332
333                 using (var result = testingTarget.GetXAxis())
334                 {
335                     Assert.AreEqual(1.0f, result.X, "Should be equal!");
336                     Assert.AreEqual(2.0f, result.Y, "Should be equal!");
337                     Assert.AreEqual(3.0f, result.Z, "Should be equal!");
338                 }
339             }
340             
341
342             testingTarget.Dispose();
343             tlog.Debug(tag, $"MatrixSetXAxis END (OK)");
344         }
345
346         [Test]
347         [Category("P1")]
348         [Description("Matrix SetYAxis.")]
349         [Property("SPEC", "Tizen.NUI.Matrix.SetYAxis M")]
350         [Property("SPEC_URL", "-")]
351         [Property("CRITERIA", "MR")]
352         [Property("AUTHOR", "guowei.wang@samsung.com")]
353         public void MatrixSetYAxis()
354         {
355             tlog.Debug(tag, $"MatrixSetYAxis START");
356
357             var testingTarget = new Matrix();
358             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
359             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
360
361
362             using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
363             {
364                 testingTarget.SetYAxis(vector);
365
366                 using (var result = testingTarget.GetYAxis())
367                 {
368                     Assert.AreEqual(1.0f, result.X, "Should be equal!");
369                     Assert.AreEqual(2.0f, result.Y, "Should be equal!");
370                     Assert.AreEqual(3.0f, result.Z, "Should be equal!");
371                 }
372             }
373
374             testingTarget.Dispose();
375             tlog.Debug(tag, $"MatrixSetYAxis END (OK)");
376         }
377
378         [Test]
379         [Category("P1")]
380         [Description("Matrix SetZAxis.")]
381         [Property("SPEC", "Tizen.NUI.Matrix.SetZAxis M")]
382         [Property("SPEC_URL", "-")]
383         [Property("CRITERIA", "MR")]
384         [Property("AUTHOR", "guowei.wang@samsung.com")]
385         public void MatrixSetZAxis()
386         {
387             tlog.Debug(tag, $"MatrixSetZAxis START");
388
389             var testingTarget = new Matrix();
390             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
391             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
392
393
394             using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
395             {
396                 testingTarget.SetZAxis(vector);
397
398                 using (var result = testingTarget.GetZAxis())
399                 {
400                     Assert.AreEqual(1.0f, result.X, "Should be equal!");
401                     Assert.AreEqual(2.0f, result.Y, "Should be equal!");
402                     Assert.AreEqual(3.0f, result.Z, "Should be equal!");
403                 }
404             }
405
406             testingTarget.Dispose();
407             tlog.Debug(tag, $"MatrixSetZAxis END (OK)");
408         }
409
410         [Test]
411         [Category("P1")]
412         [Description("Matrix SetTranslation.")]
413         [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation M")]
414         [Property("SPEC_URL", "-")]
415         [Property("CRITERIA", "MR")]
416         [Property("AUTHOR", "guowei.wang@samsung.com")]
417         public void MatrixGetTranslation()
418         {
419             tlog.Debug(tag, $"MatrixGetTranslation START");
420
421             var testingTarget = new Matrix();
422             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
423             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
424
425             using (Vector4 vector = new Vector4(1.0f, 2.0f, 3.0f, 4.0f))
426             {
427                 testingTarget.SetTranslation(vector);
428
429                 using (var result = testingTarget.GetTranslation())
430                 {
431                     Assert.AreEqual(1.0f, result.X, "Should be equal!");
432                     Assert.AreEqual(2.0f, result.Y, "Should be equal!");
433                     Assert.AreEqual(3.0f, result.Z, "Should be equal!");
434                     Assert.AreEqual(4.0f, result.W, "Should be equal!");
435                 }
436             }
437
438             testingTarget.Dispose();
439             tlog.Debug(tag, $"MatrixGetTranslation END (OK)");
440         }
441
442         [Test]
443         [Category("P1")]
444         [Description("Matrix SetTranslation. With Vector3.")]
445         [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation M")]
446         [Property("SPEC_URL", "-")]
447         [Property("CRITERIA", "MR")]
448         [Property("AUTHOR", "guowei.wang@samsung.com")]
449         public void MatrixSetTranslationWithVector3()
450         {
451             tlog.Debug(tag, $"MatrixSetTranslationWithVector3 START");
452
453             var testingTarget = new Matrix();
454             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
455             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
456
457             using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
458             {
459                 testingTarget.SetTranslation(vector);
460
461                 using (var result = testingTarget.GetTranslation3())
462                 {
463                     Assert.AreEqual(1.0f, result.X, "Should be equal!");
464                     Assert.AreEqual(2.0f, result.Y, "Should be equal!");
465                     Assert.AreEqual(3.0f, result.Z, "Should be equal!");
466                 }
467             }
468
469             testingTarget.Dispose();
470             tlog.Debug(tag, $"MatrixSetTranslationWithVector3 END (OK)");
471         }
472
473         [Test]
474         [Category("P1")]
475         [Description("Matrix OrthoNormalize.")]
476         [Property("SPEC", "Tizen.NUI.Matrix.OrthoNormalize M")]
477         [Property("SPEC_URL", "-")]
478         [Property("CRITERIA", "MR")]
479         [Property("AUTHOR", "guowei.wang@samsung.com")]
480         public void MatrixOrthoNormalize()
481         {
482             tlog.Debug(tag, $"MatrixOrthoNormalize START");
483
484             var testingTarget = new Matrix();
485             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
486             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
487
488             try
489             {
490                 testingTarget.OrthoNormalize();
491             }
492             catch (Exception e)
493             {
494                 tlog.Debug(tag, e.Message.ToString());
495                 Assert.Fail("Caught Exception : Failed!");
496             }
497
498             tlog.Debug(tag, $"MatrixOrthoNormalize END (OK)");
499         }
500
501         [Test]
502         [Category("P1")]
503         [Description("Matrix Multiply.")]
504         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
505         [Property("SPEC_URL", "-")]
506         [Property("CRITERIA", "MR")]
507         [Property("AUTHOR", "guowei.wang@samsung.com")]
508         public void MatrixMultiply()
509         {
510             tlog.Debug(tag, $"MatrixMultiply START");
511
512             var testingTarget = new Matrix();
513             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
514             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
515
516             using (Matrix lhs = new Matrix(true))
517             {
518                 using (Matrix rhs = new Matrix(false))
519                 {
520                     try
521                     {
522                         Matrix.Multiply(testingTarget, lhs, rhs);
523                     }
524                     catch (Exception e)
525                     {
526                         tlog.Debug(tag, e.Message.ToString());
527                         Assert.Fail("Caught Exception : Failed!");
528                     }
529                 }
530             }
531
532             testingTarget.Dispose();
533             tlog.Debug(tag, $"MatrixMultiply END (OK)");
534         }
535
536         [Test]
537         [Category("P1")]
538         [Description("Matrix MultiplyAssign.")]
539         [Property("SPEC", "Tizen.NUI.Matrix.MultiplyAssign M")]
540         [Property("SPEC_URL", "-")]
541         [Property("CRITERIA", "MR")]
542         [Property("AUTHOR", "eunkiki.hong@samsung.com")]
543         public void MatrixMultiplyAssign()
544         {
545             tlog.Debug(tag, $"MatrixMultiplyAssign START");
546
547             var testingTarget = new Matrix();
548             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
549             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
550
551             using (Matrix rhs = new Matrix(false))
552             {
553                 try
554                 {
555                     testingTarget.MultiplyAssign(rhs);
556                 }
557                 catch (Exception e)
558                 {
559                     tlog.Debug(tag, e.Message.ToString());
560                     Assert.Fail("Caught Exception : Failed!");
561                 }
562             }
563
564             testingTarget.Dispose();
565             tlog.Debug(tag, $"MatrixMultiplyAssign END (OK)");
566         }
567
568         [Test]
569         [Category("P1")]
570         [Description("Matrix Multiply. With Rotation.")]
571         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
572         [Property("SPEC_URL", "-")]
573         [Property("CRITERIA", "MR")]
574         [Property("AUTHOR", "guowei.wang@samsung.com")]
575         public void MatrixMultiplyWithRotation()
576         {
577             tlog.Debug(tag, $"MatrixMultiplyWithRotation START");
578
579             var testingTarget = new Matrix();
580             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
581             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
582
583             using (Matrix lhs = new Matrix(true))
584             {
585                 using (Rotation rhs = new Rotation())
586                 {
587                     try
588                     {
589                         Matrix.Multiply(testingTarget, lhs, rhs);
590                     }
591                     catch (Exception e)
592                     {
593                         tlog.Debug(tag, e.Message.ToString());
594                         Assert.Fail("Caught Exception : Failed!");
595                     }
596                 }
597             }
598
599             testingTarget.Dispose();
600             tlog.Debug(tag, $"MatrixMultiplyWithRotation END (OK)");
601         }
602
603         [Test]
604         [Category("P1")]
605         [Description("Matrix Multiply. With Vector4.")]
606         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
607         [Property("SPEC_URL", "-")]
608         [Property("CRITERIA", "MR")]
609         [Property("AUTHOR", "guowei.wang@samsung.com")]
610         public void MatrixMultiplyWithVector4()
611         {
612             tlog.Debug(tag, $"MatrixMultiplyWithVector4 START");
613
614             var testingTarget = new Matrix();
615             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
616             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
617
618             using (Vector4 vector = new Vector4(1.0f, 2.0f, 3.0f, 4.0f))
619             {
620                 try
621                 {
622                     var ret = testingTarget.Multiply(vector);
623                     ret.Dispose();
624                 }
625                 catch (Exception e)
626                 {
627                     tlog.Debug(tag, e.Message.ToString());
628                     Assert.Fail("Caught Exception : Failed!");
629                 }
630             }
631
632             testingTarget.Dispose();
633             tlog.Debug(tag, $"MatrixMultiplyWithVector4 END (OK)");
634         }
635
636         [Test]
637         [Category("P1")]
638         [Description("Matrix EqualTo.")]
639         [Property("SPEC", "Tizen.NUI.Matrix.EqualTo M")]
640         [Property("SPEC_URL", "-")]
641         [Property("CRITERIA", "MR")]
642         [Property("AUTHOR", "guowei.wang@samsung.com")]
643         public void MatrixEqualTo()
644         {
645             tlog.Debug(tag, $"MatrixEqualTo START");
646
647             var testingTarget = new Matrix();
648             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
649             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
650
651             using (Matrix matrix = new Matrix(true))
652             {
653                 var result = testingTarget.EqualTo(matrix);
654                 tlog.Debug(tag, "EqualTo : " + result);
655                 Assert.AreEqual(true, result, "EqualTo should be true");
656             }
657
658             testingTarget.Dispose();
659             tlog.Debug(tag, $"MatrixEqualTo END (OK)");
660         }
661
662         [Test]
663         [Category("P1")]
664         [Description("Matrix NotEqualTo.")]
665         [Property("SPEC", "Tizen.NUI.Matrix.NotEqualTo M")]
666         [Property("SPEC_URL", "-")]
667         [Property("CRITERIA", "MR")]
668         [Property("AUTHOR", "guowei.wang@samsung.com")]
669         public void MatrixNotEqualTo()
670         {
671             tlog.Debug(tag, $"MatrixNotEqualTo START");
672
673             var testingTarget = new Matrix();
674             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
675             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
676
677             using (Matrix matrix = new Matrix(true))
678             {
679                 var result = testingTarget.NotEqualTo(matrix);
680                 tlog.Debug(tag, "NotEqualTo : " + result);
681                 Assert.AreEqual(false, result, "NotEqualTo should be false");
682             }
683
684             testingTarget.Dispose();
685             tlog.Debug(tag, $"MatrixNotEqualTo END (OK)");
686         }
687
688         [Test]
689         [Category("P1")]
690         [Description("Matrix SetTransformComponents.")]
691         [Property("SPEC", "Tizen.NUI.Matrix.SetTransformComponents M")]
692         [Property("SPEC_URL", "-")]
693         [Property("CRITERIA", "MR")]
694         [Property("AUTHOR", "guowei.wang@samsung.com")]
695         public void MatrixSetTransformComponents()
696         {
697             tlog.Debug(tag, $"MatrixSetTransformComponents START");
698
699             var testingTarget = new Matrix();
700             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
701             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
702
703             using (Vector3 scale = new Vector3(1.0f, 2.0f, 3.0f))
704             {
705                 {
706                     using (Rotation rotation = new Rotation())
707                     {
708                         using (Vector3 translation = new Vector3(3.0f, 2.0f, 1.0f))
709                         {
710                             try
711                             {
712                                 testingTarget.SetTransformComponents(scale, rotation, translation);
713                             }
714                             catch (Exception e)
715                             {
716                                 tlog.Debug(tag, e.Message.ToString());
717                                 Assert.Fail("Caught Exception : Failed!");
718                             }
719                         }
720                     }
721                 }
722             }
723
724             testingTarget.Dispose();
725             tlog.Debug(tag, $"MatrixSetTransformComponents END (OK)");
726         }
727
728         [Test]
729         [Category("P1")]
730         [Description("Matrix SetInverseTransformComponents.")]
731         [Property("SPEC", "Tizen.NUI.Matrix.SetInverseTransformComponents M")]
732         [Property("SPEC_URL", "-")]
733         [Property("CRITERIA", "MR")]
734         [Property("AUTHOR", "guowei.wang@samsung.com")]
735         public void MatrixSetInverseTransformComponents()
736         {
737             tlog.Debug(tag, $"MatrixSetInverseTransformComponents START");
738
739             var testingTarget = new Matrix();
740             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
741             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
742
743             using (Vector3 scale = new Vector3(1.0f, 2.0f, 3.0f))
744             {
745                 {
746                     using (Rotation rotation = new Rotation())
747                     {
748                         using (Vector3 translation = new Vector3(3.0f, 2.0f, 1.0f))
749                         {
750                             try
751                             {
752                                 testingTarget.SetInverseTransformComponents(scale, rotation, translation);
753                             }
754                             catch (Exception e)
755                             {
756                                 tlog.Debug(tag, e.Message.ToString());
757                                 Assert.Fail("Caught Exception : Failed!");
758                             }
759                         }
760                     }
761                 }
762             }
763
764             testingTarget.Dispose();
765             tlog.Debug(tag, $"MatrixSetInverseTransformComponents END (OK)");
766         }
767
768         [Test]
769         [Category("P1")]
770         [Description("Matrix SetInverseTransformComponents.")]
771         [Property("SPEC", "Tizen.NUI.Matrix.SetInverseTransformComponents M")]
772         [Property("SPEC_URL", "-")]
773         [Property("CRITERIA", "MR")]
774         [Property("AUTHOR", "guowei.wang@samsung.com")]
775         public void MatrixSetInverseTransformComponentsWithVector3()
776         {
777             tlog.Debug(tag, $"MatrixSetInverseTransformComponentsWithVector3 START");
778
779             var testingTarget = new Matrix();
780             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
781             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
782
783             using (Vector3 xAxis = new Vector3(1.0f, 2.0f, 3.0f))
784             {
785                 {
786                     using (Vector3 yAxis = new Vector3(3.0f, 4.0f, 5.0f))
787                     {
788                         using (Vector3 zAxis = new Vector3(5.0f, 6.0f, 7.0f))
789                         {
790                             using (Vector3 translation = new Vector3(7.0f, 8.0f, 9.0f))
791                             {
792                                 try
793                                 {
794                                     testingTarget.SetInverseTransformComponents(xAxis, yAxis, zAxis, translation);
795                                 }
796                                 catch (Exception e)
797                                 {
798                                     tlog.Debug(tag, e.Message.ToString());
799                                     Assert.Fail("Caught Exception : Failed!");
800                                 }
801                             }
802                         }
803                     }
804                 }
805             }
806
807             testingTarget.Dispose();
808             tlog.Debug(tag, $"MatrixSetInverseTransformComponentsWithVector3 END (OK)");
809         }
810
811         [Test]
812         [Category("P1")]
813         [Description("Matrix GetTransformComponents.")]
814         [Property("SPEC", "Tizen.NUI.Matrix.GetTransformComponents M")]
815         [Property("SPEC_URL", "-")]
816         [Property("CRITERIA", "MR")]
817         [Property("AUTHOR", "guowei.wang@samsung.com")]
818         public void MatrixGetTransformComponents()
819         {
820             tlog.Debug(tag, $"MatrixGetTransformComponents START");
821
822             var testingTarget = new Matrix();
823             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
824             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
825
826             using (Vector3 position = new Vector3(1.0f, 2.0f, 3.0f))
827             {
828                 {
829                     using (Rotation rotation = new Rotation())
830                     {
831                         using (Vector3 scale = new Vector3(3.0f, 2.0f, 1.0f))
832                         {
833                             try
834                             {
835                                 testingTarget.GetTransformComponents(position, rotation, scale);
836                             }
837                             catch (Exception e)
838                             {
839                                 tlog.Debug(tag, e.Message.ToString());
840                                 Assert.Fail("Caught Exception : Failed!");
841                             }
842                         }
843                     }
844                 }
845             }
846
847             testingTarget.Dispose();
848             tlog.Debug(tag, $"MatrixGetTransformComponents END (OK)");
849         }
850
851         [Test]
852         [Category("P1")]
853         [Description("Matrix ValueOfIndex with signle index.")]
854         [Property("SPEC", "Tizen.NUI.Matrix.ValueOfIndex M")]
855         [Property("SPEC_URL", "-")]
856         [Property("CRITERIA", "MR")]
857         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
858         public void MatrixValueOfIndexSingleIndex()
859         {
860             /* TEST CODE */
861             tlog.Debug(tag, $"MatrixValueOfIndexSingleIndex START");
862
863             float[] arr = new float[16]
864             { 0.0f, 1.0f, 2.0f, 3.0f,
865               0.1f, 1.1f, 2.1f, 3.1f,
866               0.2f, 1.2f, 2.2f, 3.2f,
867               0.3f, 1.3f, 2.3f, 3.3f};
868
869             Matrix testingTarget = new Matrix(arr);
870             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
871             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
872
873             for(uint index = 0; index < 16; ++index)
874             {
875                 float expectResult = (index / 4) * 0.1f + (index % 4) * 1.0f;
876                 Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(index), "The value of index is not correct!");
877             }
878             testingTarget.Dispose();
879             tlog.Debug(tag, $"MatrixValueOfIndexSingleIndex END (OK)");
880         }
881
882         [Test]
883         [Category("P1")]
884         [Description("Matrix ValueOfIndex with double index.")]
885         [Property("SPEC", "Tizen.NUI.Matrix.ValueOfIndex M")]
886         [Property("SPEC_URL", "-")]
887         [Property("CRITERIA", "MR")]
888         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
889         public void MatrixValueOfIndexDoubleIndex()
890         {
891             /* TEST CODE */
892             tlog.Debug(tag, $"MatrixValueOfIndexDoubleIndex START");
893             float[] arr = new float[16]
894             { 0.0f, 1.0f, 2.0f, 3.0f,
895               0.1f, 1.1f, 2.1f, 3.1f,
896               0.2f, 1.2f, 2.2f, 3.2f,
897               0.3f, 1.3f, 2.3f, 3.3f};
898
899             Matrix testingTarget = new Matrix(arr);
900             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
901             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
902
903             for(uint indexRow = 0; indexRow < 4; ++indexRow)
904             {
905                 for(uint indexColumn = 0; indexColumn < 4; ++indexColumn)
906                 {
907                     float expectResult = indexColumn * 0.1f + indexRow * 1.0f;
908                     Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(indexRow, indexColumn), "The value of index is not correct!");
909                 }
910             }
911             testingTarget.Dispose();
912             tlog.Debug(tag, $"MatrixValueOfIndexDoubleIndex END (OK)");
913         }
914
915         [Test]
916         [Category("P1")]
917         [Description("Matrix SetValueAtIndex with signle index.")]
918         [Property("SPEC", "Tizen.NUI.Matrix.SetValueAtIndex M")]
919         [Property("SPEC_URL", "-")]
920         [Property("CRITERIA", "MR")]
921         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
922         public void MatrixSetValueAtIndexSingleIndex()
923         {
924             /* TEST CODE */
925             tlog.Debug(tag, $"MatrixSetValueAtIndexSingleIndex START");
926             Matrix testingTarget = new Matrix(true);
927             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
928             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
929
930             for(uint index = 0; index < 16; ++index)
931             {
932                 float expectResult = (index / 4) * 0.1f + (index % 4) * 1.0f;
933                 testingTarget.SetValueAtIndex(index, expectResult);
934                 Assert.AreEqual(expectResult, testingTarget[index], "The value of index is not correct!");
935             }
936             testingTarget.Dispose();
937             tlog.Debug(tag, $"MatrixSetValueAtIndexSingleIndex END (OK)");
938         }
939
940         [Test]
941         [Category("P1")]
942         [Description("Matrix SetValueAtIndex with double index.")]
943         [Property("SPEC", "Tizen.NUI.Matrix.SetValueAtIndex M")]
944         [Property("SPEC_URL", "-")]
945         [Property("CRITERIA", "MR")]
946         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
947         public void MatrixSetValueAtIndexDoubleIndex()
948         {
949             /* TEST CODE */
950             tlog.Debug(tag, $"MatrixSetValueAtIndexDoubleIndex START");
951             Matrix testingTarget = new Matrix(true);
952             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
953             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
954
955             for(uint indexRow = 0; indexRow < 4; ++indexRow)
956             {
957                 for(uint indexColumn = 0; indexColumn < 4; ++indexColumn)
958                 {
959                     float expectResult = indexColumn * 0.1f + indexRow * 1.0f;
960                     testingTarget.SetValueAtIndex(indexRow, indexColumn, expectResult);
961                     Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(indexRow, indexColumn), "The value of index is not correct!");
962                 }
963             }
964             testingTarget.Dispose();
965             tlog.Debug(tag, $"MatrixSetValueAtIndexDoubleIndex END (OK)");
966         }
967
968         [Test]
969         [Category("P1")]
970         [Description("Test Tizen.NUI.Matrix.operator * with Matrix.")]
971         [Property("SPEC", "Tizen.NUI.Matrix.operator *() A")]
972         [Property("SPEC_URL", "-")]
973         [Property("CRITERIA", "MR")]
974         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
975         public void MatrixMultiplyOperator()
976         {
977             /* TEST CODE */
978             tlog.Debug(tag, $"MatrixMultiplyOperator START");
979             Matrix testingTarget = new Matrix(true);
980             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
981             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
982
983             try
984             {
985                 Matrix rhs = new Matrix(false);
986                 Matrix ret = testingTarget * rhs;
987                 rhs.Dispose();
988                 ret.Dispose();
989             }
990             catch (Exception e)
991             {
992                 tlog.Debug(tag, e.Message.ToString());
993                 Assert.Fail("Caught Exception : Failed!");
994             }
995             testingTarget.Dispose();
996             tlog.Debug(tag, $"MatrixMultiplyOperator END (OK)");
997         }
998
999         [Test]
1000         [Category("P1")]
1001         [Description("Test Tizen.NUI.Matrix.operator * with Rotation.")]
1002         [Property("SPEC", "Tizen.NUI.Matrix.operator *() A")]
1003         [Property("SPEC_URL", "-")]
1004         [Property("CRITERIA", "MR")]
1005         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
1006         public void MatrixMultiplyOperatorWithRotation()
1007         {
1008             /* TEST CODE */
1009             tlog.Debug(tag, $"MatrixMultiplyOperatorWithRotation START");
1010             Matrix testingTarget = new Matrix(true);
1011             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
1012             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
1013
1014             try
1015             {
1016                 Rotation lhs = new Rotation();
1017                 Matrix ret = lhs * testingTarget;
1018                 lhs.Dispose();
1019                 ret.Dispose();
1020             }
1021             catch (Exception e)
1022             {
1023                 tlog.Debug(tag, e.Message.ToString());
1024                 Assert.Fail("Caught Exception : Failed!");
1025             }
1026             testingTarget.Dispose();
1027             tlog.Debug(tag, $"MatrixMultiplyOperatorWithRotation END (OK)");
1028         }
1029
1030         [Test]
1031         [Category("P1")]
1032         [Description("Test Tizen.NUI.Matrix.operator * with Vector4.")]
1033         [Property("SPEC", "Tizen.NUI.Matrix.operator *() A")]
1034         [Property("SPEC_URL", "-")]
1035         [Property("CRITERIA", "MR")]
1036         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
1037         public void MatrixMultiplyOperatorWithVector4()
1038         {
1039             /* TEST CODE */
1040             tlog.Debug(tag, $"MatrixMultiplyOperatorWithVector4 START");
1041             Matrix testingTarget = new Matrix(true);
1042             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
1043             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
1044
1045             try
1046             {
1047                 Vector4 rhs = new Vector4();
1048                 Vector4 ret = testingTarget * rhs;
1049                 rhs.Dispose();
1050                 ret.Dispose();
1051             }
1052             catch (Exception e)
1053             {
1054                 tlog.Debug(tag, e.Message.ToString());
1055                 Assert.Fail("Caught Exception : Failed!");
1056             }
1057             testingTarget.Dispose();
1058             tlog.Debug(tag, $"MatrixMultiplyOperatorWithVector4 END (OK)");
1059         }
1060
1061         [Test]
1062         [Category("P1")]
1063         [Description("Test this[uint index]. Check whether this[uint index] returns expected value or not.")]
1064         [Property("SPEC", "Tizen.NUI.Matrix.this[uint] A")]
1065         [Property("SPEC_URL", "-")]
1066         [Property("CRITERIA", "MR")]
1067         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
1068         public void this_SET_GET_VALUE()
1069         {
1070             /* TEST CODE */
1071             tlog.Debug(tag, $"Matrixthis_SET_GET_VALUE START");
1072             Matrix testingTarget = new Matrix(true);
1073             try
1074             {
1075                 testingTarget[0] = 100.0f;
1076                 testingTarget[1] = 200.0f;
1077             }
1078             catch (Exception e)
1079             {
1080                 tlog.Debug(tag, e.Message.ToString());
1081                 Assert.Fail("Caught Exception : Failed!");
1082             }
1083             Assert.AreEqual(100.0f, testingTarget[0], "The value of index[0] is not correct!");
1084             Assert.AreEqual(200.0f, testingTarget[1], "The value of index[1] is not correct!");
1085             testingTarget.Dispose();
1086             tlog.Debug(tag, $"Matrixthis_SET_GET_VALUE END (OK)");
1087         }
1088     }
1089 }