[NUI] Move Matrix API as public (hidden)
[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                 var result = testingTarget.GetXAxis();
334                 Assert.AreEqual(1.0f, result.X, "Should be equal!");
335                 Assert.AreEqual(2.0f, result.Y, "Should be equal!");
336                 Assert.AreEqual(3.0f, result.Z, "Should be equal!");
337             }
338
339             testingTarget.Dispose();
340             tlog.Debug(tag, $"MatrixSetXAxis END (OK)");
341         }
342
343         [Test]
344         [Category("P1")]
345         [Description("Matrix SetYAxis.")]
346         [Property("SPEC", "Tizen.NUI.Matrix.SetYAxis M")]
347         [Property("SPEC_URL", "-")]
348         [Property("CRITERIA", "MR")]
349         [Property("AUTHOR", "guowei.wang@samsung.com")]
350         public void MatrixSetYAxis()
351         {
352             tlog.Debug(tag, $"MatrixSetYAxis START");
353
354             var testingTarget = new Matrix();
355             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
356             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
357
358
359             using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
360             {
361                 testingTarget.SetYAxis(vector);
362
363                 var result = testingTarget.GetYAxis();
364                 Assert.AreEqual(1.0f, result.X, "Should be equal!");
365                 Assert.AreEqual(2.0f, result.Y, "Should be equal!");
366                 Assert.AreEqual(3.0f, result.Z, "Should be equal!");
367             }
368
369             testingTarget.Dispose();
370             tlog.Debug(tag, $"MatrixSetYAxis END (OK)");
371         }
372
373         [Test]
374         [Category("P1")]
375         [Description("Matrix SetZAxis.")]
376         [Property("SPEC", "Tizen.NUI.Matrix.SetZAxis M")]
377         [Property("SPEC_URL", "-")]
378         [Property("CRITERIA", "MR")]
379         [Property("AUTHOR", "guowei.wang@samsung.com")]
380         public void MatrixSetZAxis()
381         {
382             tlog.Debug(tag, $"MatrixSetZAxis START");
383
384             var testingTarget = new Matrix();
385             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
386             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
387
388
389             using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
390             {
391                 testingTarget.SetZAxis(vector);
392
393                 var result = testingTarget.GetZAxis();
394                 Assert.AreEqual(1.0f, result.X, "Should be equal!");
395                 Assert.AreEqual(2.0f, result.Y, "Should be equal!");
396                 Assert.AreEqual(3.0f, result.Z, "Should be equal!");
397             }
398
399             testingTarget.Dispose();
400             tlog.Debug(tag, $"MatrixSetZAxis END (OK)");
401         }
402
403         [Test]
404         [Category("P1")]
405         [Description("Matrix SetTranslation.")]
406         [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation M")]
407         [Property("SPEC_URL", "-")]
408         [Property("CRITERIA", "MR")]
409         [Property("AUTHOR", "guowei.wang@samsung.com")]
410         public void MatrixGetTranslation()
411         {
412             tlog.Debug(tag, $"MatrixGetTranslation START");
413
414             var testingTarget = new Matrix();
415             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
416             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
417
418             using (Vector4 vector = new Vector4(1.0f, 2.0f, 3.0f, 4.0f))
419             {
420                 testingTarget.SetTranslation(vector);
421
422                 var result = testingTarget.GetTranslation();
423                 Assert.AreEqual(1.0f, result.X, "Should be equal!");
424                 Assert.AreEqual(2.0f, result.Y, "Should be equal!");
425                 Assert.AreEqual(3.0f, result.Z, "Should be equal!");
426                 Assert.AreEqual(4.0f, result.W, "Should be equal!");
427             }
428
429             testingTarget.Dispose();
430             tlog.Debug(tag, $"MatrixGetTranslation END (OK)");
431         }
432
433         [Test]
434         [Category("P1")]
435         [Description("Matrix SetTranslation. With Vector3.")]
436         [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation M")]
437         [Property("SPEC_URL", "-")]
438         [Property("CRITERIA", "MR")]
439         [Property("AUTHOR", "guowei.wang@samsung.com")]
440         public void MatrixSetTranslationWithVector3()
441         {
442             tlog.Debug(tag, $"MatrixSetTranslationWithVector3 START");
443
444             var testingTarget = new Matrix();
445             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
446             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
447
448             using (Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f))
449             {
450                 testingTarget.SetTranslation(vector);
451
452                 var result = testingTarget.GetTranslation3();
453                 Assert.AreEqual(1.0f, result.X, "Should be equal!");
454                 Assert.AreEqual(2.0f, result.Y, "Should be equal!");
455                 Assert.AreEqual(3.0f, result.Z, "Should be equal!");
456             }
457
458             testingTarget.Dispose();
459             tlog.Debug(tag, $"MatrixSetTranslationWithVector3 END (OK)");
460         }
461
462         [Test]
463         [Category("P1")]
464         [Description("Matrix OrthoNormalize.")]
465         [Property("SPEC", "Tizen.NUI.Matrix.OrthoNormalize M")]
466         [Property("SPEC_URL", "-")]
467         [Property("CRITERIA", "MR")]
468         [Property("AUTHOR", "guowei.wang@samsung.com")]
469         public void MatrixOrthoNormalize()
470         {
471             tlog.Debug(tag, $"MatrixOrthoNormalize START");
472
473             var testingTarget = new Matrix();
474             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
475             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
476
477             try
478             {
479                 testingTarget.OrthoNormalize();
480             }
481             catch (Exception e)
482             {
483                 tlog.Debug(tag, e.Message.ToString());
484                 Assert.Fail("Caught Exception : Failed!");
485             }
486
487             tlog.Debug(tag, $"MatrixOrthoNormalize END (OK)");
488         }
489
490         [Test]
491         [Category("P1")]
492         [Description("Matrix Multiply.")]
493         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
494         [Property("SPEC_URL", "-")]
495         [Property("CRITERIA", "MR")]
496         [Property("AUTHOR", "guowei.wang@samsung.com")]
497         public void MatrixMultiply()
498         {
499             tlog.Debug(tag, $"MatrixMultiply START");
500
501             var testingTarget = new Matrix();
502             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
503             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
504
505             using (Matrix lhs = new Matrix(true))
506             {
507                 using (Matrix rhs = new Matrix(false))
508                 {
509                     try
510                     {
511                         Matrix.Multiply(testingTarget, lhs, rhs);
512                     }
513                     catch (Exception e)
514                     {
515                         tlog.Debug(tag, e.Message.ToString());
516                         Assert.Fail("Caught Exception : Failed!");
517                     }
518                 }
519             }
520
521             testingTarget.Dispose();
522             tlog.Debug(tag, $"MatrixMultiply END (OK)");
523         }
524
525         [Test]
526         [Category("P1")]
527         [Description("Matrix MultiplyAssign.")]
528         [Property("SPEC", "Tizen.NUI.Matrix.MultiplyAssign M")]
529         [Property("SPEC_URL", "-")]
530         [Property("CRITERIA", "MR")]
531         [Property("AUTHOR", "eunkiki.hong@samsung.com")]
532         public void MatrixMultiplyAssign()
533         {
534             tlog.Debug(tag, $"MatrixMultiplyAssign START");
535
536             var testingTarget = new Matrix();
537             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
538             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
539
540             using (Matrix rhs = new Matrix(false))
541             {
542                 try
543                 {
544                     testingTarget.MultiplyAssign(rhs);
545                 }
546                 catch (Exception e)
547                 {
548                     tlog.Debug(tag, e.Message.ToString());
549                     Assert.Fail("Caught Exception : Failed!");
550                 }
551             }
552
553             testingTarget.Dispose();
554             tlog.Debug(tag, $"MatrixMultiplyAssign END (OK)");
555         }
556
557         [Test]
558         [Category("P1")]
559         [Description("Matrix Multiply. With Rotation.")]
560         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
561         [Property("SPEC_URL", "-")]
562         [Property("CRITERIA", "MR")]
563         [Property("AUTHOR", "guowei.wang@samsung.com")]
564         public void MatrixMultiplyWithRotation()
565         {
566             tlog.Debug(tag, $"MatrixMultiplyWithRotation START");
567
568             var testingTarget = new Matrix();
569             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
570             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
571
572             using (Matrix lhs = new Matrix(true))
573             {
574                 using (Rotation rhs = new Rotation())
575                 {
576                     try
577                     {
578                         Matrix.Multiply(testingTarget, lhs, rhs);
579                     }
580                     catch (Exception e)
581                     {
582                         tlog.Debug(tag, e.Message.ToString());
583                         Assert.Fail("Caught Exception : Failed!");
584                     }
585                 }
586             }
587
588             testingTarget.Dispose();
589             tlog.Debug(tag, $"MatrixMultiplyWithRotation END (OK)");
590         }
591
592         [Test]
593         [Category("P1")]
594         [Description("Matrix Multiply. With Vector4.")]
595         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
596         [Property("SPEC_URL", "-")]
597         [Property("CRITERIA", "MR")]
598         [Property("AUTHOR", "guowei.wang@samsung.com")]
599         public void MatrixMultiplyWithVector4()
600         {
601             tlog.Debug(tag, $"MatrixMultiplyWithVector4 START");
602
603             var testingTarget = new Matrix();
604             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
605             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
606
607             using (Vector4 vector = new Vector4(1.0f, 2.0f, 3.0f, 4.0f))
608             {
609                 try
610                 {
611                     var ret = testingTarget.Multiply(vector);
612                     ret.Dispose();
613                 }
614                 catch (Exception e)
615                 {
616                     tlog.Debug(tag, e.Message.ToString());
617                     Assert.Fail("Caught Exception : Failed!");
618                 }
619             }
620
621             testingTarget.Dispose();
622             tlog.Debug(tag, $"MatrixMultiplyWithVector4 END (OK)");
623         }
624
625         [Test]
626         [Category("P1")]
627         [Description("Matrix EqualTo.")]
628         [Property("SPEC", "Tizen.NUI.Matrix.EqualTo M")]
629         [Property("SPEC_URL", "-")]
630         [Property("CRITERIA", "MR")]
631         [Property("AUTHOR", "guowei.wang@samsung.com")]
632         public void MatrixEqualTo()
633         {
634             tlog.Debug(tag, $"MatrixEqualTo START");
635
636             var testingTarget = new Matrix();
637             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
638             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
639
640             using (Matrix matrix = new Matrix(true))
641             {
642                 var result = testingTarget.EqualTo(matrix);
643                 tlog.Debug(tag, "EqualTo : " + result);
644                 Assert.AreEqual(true, result, "EqualTo should be true");
645             }
646
647             testingTarget.Dispose();
648             tlog.Debug(tag, $"MatrixEqualTo END (OK)");
649         }
650
651         [Test]
652         [Category("P1")]
653         [Description("Matrix NotEqualTo.")]
654         [Property("SPEC", "Tizen.NUI.Matrix.NotEqualTo M")]
655         [Property("SPEC_URL", "-")]
656         [Property("CRITERIA", "MR")]
657         [Property("AUTHOR", "guowei.wang@samsung.com")]
658         public void MatrixNotEqualTo()
659         {
660             tlog.Debug(tag, $"MatrixNotEqualTo START");
661
662             var testingTarget = new Matrix();
663             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
664             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
665
666             using (Matrix matrix = new Matrix(true))
667             {
668                 var result = testingTarget.NotEqualTo(matrix);
669                 tlog.Debug(tag, "NotEqualTo : " + result);
670                 Assert.AreEqual(false, result, "NotEqualTo should be false");
671             }
672
673             testingTarget.Dispose();
674             tlog.Debug(tag, $"MatrixNotEqualTo END (OK)");
675         }
676
677         [Test]
678         [Category("P1")]
679         [Description("Matrix SetTransformComponents.")]
680         [Property("SPEC", "Tizen.NUI.Matrix.SetTransformComponents M")]
681         [Property("SPEC_URL", "-")]
682         [Property("CRITERIA", "MR")]
683         [Property("AUTHOR", "guowei.wang@samsung.com")]
684         public void MatrixSetTransformComponents()
685         {
686             tlog.Debug(tag, $"MatrixSetTransformComponents START");
687
688             var testingTarget = new Matrix();
689             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
690             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
691
692             using (Vector3 scale = new Vector3(1.0f, 2.0f, 3.0f))
693             {
694                 {
695                     using (Rotation rotation = new Rotation())
696                     {
697                         using (Vector3 translation = new Vector3(3.0f, 2.0f, 1.0f))
698                         {
699                             try
700                             {
701                                 testingTarget.SetTransformComponents(scale, rotation, translation);
702                             }
703                             catch (Exception e)
704                             {
705                                 tlog.Debug(tag, e.Message.ToString());
706                                 Assert.Fail("Caught Exception : Failed!");
707                             }
708                         }
709                     }
710                 }
711             }
712
713             testingTarget.Dispose();
714             tlog.Debug(tag, $"MatrixSetTransformComponents END (OK)");
715         }
716
717         [Test]
718         [Category("P1")]
719         [Description("Matrix SetInverseTransformComponents.")]
720         [Property("SPEC", "Tizen.NUI.Matrix.SetInverseTransformComponents M")]
721         [Property("SPEC_URL", "-")]
722         [Property("CRITERIA", "MR")]
723         [Property("AUTHOR", "guowei.wang@samsung.com")]
724         public void MatrixSetInverseTransformComponents()
725         {
726             tlog.Debug(tag, $"MatrixSetInverseTransformComponents START");
727
728             var testingTarget = new Matrix();
729             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
730             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
731
732             using (Vector3 scale = new Vector3(1.0f, 2.0f, 3.0f))
733             {
734                 {
735                     using (Rotation rotation = new Rotation())
736                     {
737                         using (Vector3 translation = new Vector3(3.0f, 2.0f, 1.0f))
738                         {
739                             try
740                             {
741                                 testingTarget.SetInverseTransformComponents(scale, rotation, translation);
742                             }
743                             catch (Exception e)
744                             {
745                                 tlog.Debug(tag, e.Message.ToString());
746                                 Assert.Fail("Caught Exception : Failed!");
747                             }
748                         }
749                     }
750                 }
751             }
752
753             testingTarget.Dispose();
754             tlog.Debug(tag, $"MatrixSetInverseTransformComponents END (OK)");
755         }
756
757         [Test]
758         [Category("P1")]
759         [Description("Matrix SetInverseTransformComponents.")]
760         [Property("SPEC", "Tizen.NUI.Matrix.SetInverseTransformComponents M")]
761         [Property("SPEC_URL", "-")]
762         [Property("CRITERIA", "MR")]
763         [Property("AUTHOR", "guowei.wang@samsung.com")]
764         public void MatrixSetInverseTransformComponentsWithVector3()
765         {
766             tlog.Debug(tag, $"MatrixSetInverseTransformComponentsWithVector3 START");
767
768             var testingTarget = new Matrix();
769             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
770             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
771
772             using (Vector3 xAxis = new Vector3(1.0f, 2.0f, 3.0f))
773             {
774                 {
775                     using (Vector3 yAxis = new Vector3(3.0f, 4.0f, 5.0f))
776                     {
777                         using (Vector3 zAxis = new Vector3(5.0f, 6.0f, 7.0f))
778                         {
779                             using (Vector3 translation = new Vector3(7.0f, 8.0f, 9.0f))
780                             {
781                                 try
782                                 {
783                                     testingTarget.SetInverseTransformComponents(xAxis, yAxis, zAxis, translation);
784                                 }
785                                 catch (Exception e)
786                                 {
787                                     tlog.Debug(tag, e.Message.ToString());
788                                     Assert.Fail("Caught Exception : Failed!");
789                                 }
790                             }
791                         }
792                     }
793                 }
794             }
795
796             testingTarget.Dispose();
797             tlog.Debug(tag, $"MatrixSetInverseTransformComponentsWithVector3 END (OK)");
798         }
799
800         [Test]
801         [Category("P1")]
802         [Description("Matrix GetTransformComponents.")]
803         [Property("SPEC", "Tizen.NUI.Matrix.GetTransformComponents M")]
804         [Property("SPEC_URL", "-")]
805         [Property("CRITERIA", "MR")]
806         [Property("AUTHOR", "guowei.wang@samsung.com")]
807         public void MatrixGetTransformComponents()
808         {
809             tlog.Debug(tag, $"MatrixGetTransformComponents START");
810
811             var testingTarget = new Matrix();
812             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
813             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
814
815             using (Vector3 position = new Vector3(1.0f, 2.0f, 3.0f))
816             {
817                 {
818                     using (Rotation rotation = new Rotation())
819                     {
820                         using (Vector3 scale = new Vector3(3.0f, 2.0f, 1.0f))
821                         {
822                             try
823                             {
824                                 testingTarget.GetTransformComponents(position, rotation, scale);
825                             }
826                             catch (Exception e)
827                             {
828                                 tlog.Debug(tag, e.Message.ToString());
829                                 Assert.Fail("Caught Exception : Failed!");
830                             }
831                         }
832                     }
833                 }
834             }
835
836             testingTarget.Dispose();
837             tlog.Debug(tag, $"MatrixGetTransformComponents END (OK)");
838         }
839
840         [Test]
841         [Category("P1")]
842         [Description("Matrix ValueOfIndex with signle index.")]
843         [Property("SPEC", "Tizen.NUI.Matrix.ValueOfIndex M")]
844         [Property("SPEC_URL", "-")]
845         [Property("CRITERIA", "MR")]
846         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
847         public void MatrixValueOfIndexSingleIndex()
848         {
849             /* TEST CODE */
850             tlog.Debug(tag, $"MatrixValueOfIndexSingleIndex START");
851
852             float[] arr = new float[16]
853             { 0.0f, 1.0f, 2.0f, 3.0f,
854               0.1f, 1.1f, 2.1f, 3.1f,
855               0.2f, 1.2f, 2.2f, 3.2f,
856               0.3f, 1.3f, 2.3f, 3.3f};
857
858             Matrix testingTarget = new Matrix(arr);
859             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
860             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
861
862             for(uint index = 0; index < 16; ++index)
863             {
864                 float expectResult = (index / 4) * 0.1f + (index % 4) * 1.0f;
865                 Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(index), "The value of index is not correct!");
866             }
867             testingTarget.Dispose();
868             tlog.Debug(tag, $"MatrixValueOfIndexSingleIndex END (OK)");
869         }
870
871         [Test]
872         [Category("P1")]
873         [Description("Matrix ValueOfIndex with double index.")]
874         [Property("SPEC", "Tizen.NUI.Matrix.ValueOfIndex M")]
875         [Property("SPEC_URL", "-")]
876         [Property("CRITERIA", "MR")]
877         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
878         public void MatrixValueOfIndexDoubleIndex()
879         {
880             /* TEST CODE */
881             tlog.Debug(tag, $"MatrixValueOfIndexDoubleIndex START");
882             float[] arr = new float[16]
883             { 0.0f, 1.0f, 2.0f, 3.0f,
884               0.1f, 1.1f, 2.1f, 3.1f,
885               0.2f, 1.2f, 2.2f, 3.2f,
886               0.3f, 1.3f, 2.3f, 3.3f};
887
888             Matrix testingTarget = new Matrix(arr);
889             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
890             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
891
892             for(uint indexRow = 0; indexRow < 4; ++indexRow)
893             {
894                 for(uint indexColumn = 0; indexColumn < 4; ++indexColumn)
895                 {
896                     float expectResult = indexColumn * 0.1f + indexRow * 1.0f;
897                     Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(indexRow, indexColumn), "The value of index is not correct!");
898                 }
899             }
900             testingTarget.Dispose();
901             tlog.Debug(tag, $"MatrixValueOfIndexDoubleIndex END (OK)");
902         }
903
904         [Test]
905         [Category("P1")]
906         [Description("Matrix SetValueAtIndex with signle index.")]
907         [Property("SPEC", "Tizen.NUI.Matrix.SetValueAtIndex M")]
908         [Property("SPEC_URL", "-")]
909         [Property("CRITERIA", "MR")]
910         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
911         public void MatrixSetValueAtIndexSingleIndex()
912         {
913             /* TEST CODE */
914             tlog.Debug(tag, $"MatrixSetValueAtIndexSingleIndex START");
915             Matrix testingTarget = new Matrix(true);
916             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
917             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
918
919             for(uint index = 0; index < 16; ++index)
920             {
921                 float expectResult = (index / 4) * 0.1f + (index % 4) * 1.0f;
922                 testingTarget.SetValueAtIndex(index, expectResult);
923                 Assert.AreEqual(expectResult, testingTarget[index], "The value of index is not correct!");
924             }
925             testingTarget.Dispose();
926             tlog.Debug(tag, $"MatrixSetValueAtIndexSingleIndex END (OK)");
927         }
928
929         [Test]
930         [Category("P1")]
931         [Description("Matrix SetValueAtIndex with double index.")]
932         [Property("SPEC", "Tizen.NUI.Matrix.SetValueAtIndex M")]
933         [Property("SPEC_URL", "-")]
934         [Property("CRITERIA", "MR")]
935         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
936         public void MatrixSetValueAtIndexDoubleIndex()
937         {
938             /* TEST CODE */
939             tlog.Debug(tag, $"MatrixSetValueAtIndexDoubleIndex START");
940             Matrix testingTarget = new Matrix(true);
941             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
942             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
943
944             for(uint indexRow = 0; indexRow < 4; ++indexRow)
945             {
946                 for(uint indexColumn = 0; indexColumn < 4; ++indexColumn)
947                 {
948                     float expectResult = indexColumn * 0.1f + indexRow * 1.0f;
949                     testingTarget.SetValueAtIndex(indexRow, indexColumn, expectResult);
950                     Assert.AreEqual(expectResult, testingTarget.ValueOfIndex(indexRow, indexColumn), "The value of index is not correct!");
951                 }
952             }
953             testingTarget.Dispose();
954             tlog.Debug(tag, $"MatrixSetValueAtIndexDoubleIndex END (OK)");
955         }
956
957         [Test]
958         [Category("P1")]
959         [Description("Test Tizen.NUI.Matrix.operator * with Matrix.")]
960         [Property("SPEC", "Tizen.NUI.Matrix.operator *() A")]
961         [Property("SPEC_URL", "-")]
962         [Property("CRITERIA", "MR")]
963         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
964         public void MatrixMultiplyOperator()
965         {
966             /* TEST CODE */
967             tlog.Debug(tag, $"MatrixMultiplyOperator START");
968             Matrix testingTarget = new Matrix(true);
969             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
970             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
971
972             try
973             {
974                 Matrix rhs = new Matrix(false);
975                 Matrix ret = testingTarget * rhs;
976                 rhs.Dispose();
977                 ret.Dispose();
978             }
979             catch (Exception e)
980             {
981                 tlog.Debug(tag, e.Message.ToString());
982                 Assert.Fail("Caught Exception : Failed!");
983             }
984             testingTarget.Dispose();
985             tlog.Debug(tag, $"MatrixMultiplyOperator END (OK)");
986         }
987
988         [Test]
989         [Category("P1")]
990         [Description("Test Tizen.NUI.Matrix.operator * with Rotation.")]
991         [Property("SPEC", "Tizen.NUI.Matrix.operator *() A")]
992         [Property("SPEC_URL", "-")]
993         [Property("CRITERIA", "MR")]
994         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
995         public void MatrixMultiplyOperatorWithRotation()
996         {
997             /* TEST CODE */
998             tlog.Debug(tag, $"MatrixMultiplyOperatorWithRotation START");
999             Matrix testingTarget = new Matrix(true);
1000             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
1001             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
1002
1003             try
1004             {
1005                 Rotation rhs = new Rotation();
1006                 Matrix ret = testingTarget * rhs;
1007                 rhs.Dispose();
1008                 ret.Dispose();
1009             }
1010             catch (Exception e)
1011             {
1012                 tlog.Debug(tag, e.Message.ToString());
1013                 Assert.Fail("Caught Exception : Failed!");
1014             }
1015             testingTarget.Dispose();
1016             tlog.Debug(tag, $"MatrixMultiplyOperatorWithRotation END (OK)");
1017         }
1018
1019         [Test]
1020         [Category("P1")]
1021         [Description("Test Tizen.NUI.Matrix.operator * with Vector4.")]
1022         [Property("SPEC", "Tizen.NUI.Matrix.operator *() A")]
1023         [Property("SPEC_URL", "-")]
1024         [Property("CRITERIA", "MR")]
1025         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
1026         public void MatrixMultiplyOperatorWithVector4()
1027         {
1028             /* TEST CODE */
1029             tlog.Debug(tag, $"MatrixMultiplyOperatorWithVector4 START");
1030             Matrix testingTarget = new Matrix(true);
1031             Assert.IsNotNull(testingTarget, "Can't create success object Matrix.");
1032             Assert.IsInstanceOf<Matrix>(testingTarget, "Should return Matrix instance.");
1033
1034             try
1035             {
1036                 Vector4 rhs = new Vector4();
1037                 Vector4 ret = testingTarget * rhs;
1038                 rhs.Dispose();
1039                 ret.Dispose();
1040             }
1041             catch (Exception e)
1042             {
1043                 tlog.Debug(tag, e.Message.ToString());
1044                 Assert.Fail("Caught Exception : Failed!");
1045             }
1046             testingTarget.Dispose();
1047             tlog.Debug(tag, $"MatrixMultiplyOperatorWithVector4 END (OK)");
1048         }
1049
1050         [Test]
1051         [Category("P1")]
1052         [Description("Test this[uint index]. Check whether this[uint index] returns expected value or not.")]
1053         [Property("SPEC", "Tizen.NUI.Matrix.this[uint] A")]
1054         [Property("SPEC_URL", "-")]
1055         [Property("CRITERIA", "MR")]
1056         [Property("AUTHOR", "Eunki Hong, eunkiki.hong@samsung.com")]
1057         public void this_SET_GET_VALUE()
1058         {
1059             /* TEST CODE */
1060             tlog.Debug(tag, $"Matrixthis_SET_GET_VALUE START");
1061             Matrix testingTarget = new Matrix(true);
1062             try
1063             {
1064                 testingTarget[0] = 100.0f;
1065                 testingTarget[1] = 200.0f;
1066             }
1067             catch (Exception e)
1068             {
1069                 tlog.Debug(tag, e.Message.ToString());
1070                 Assert.Fail("Caught Exception : Failed!");
1071             }
1072             Assert.AreEqual(100.0f, testingTarget[0], "The value of index[0] is not correct!");
1073             Assert.AreEqual(200.0f, testingTarget[1], "The value of index[1] is not correct!");
1074             testingTarget.Dispose();
1075             tlog.Debug(tag, $"Matrixthis_SET_GET_VALUE END (OK)");
1076         }
1077     }
1078 }