[NUI][NUI.Devel] Update TCs of NUI.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / 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.Components;
5 using Tizen.NUI.BaseComponents;
6
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using tlog = Tizen.Log;
10
11     [TestFixture]
12     [Description("public/Common/Matrix")]
13     public class PublicMatrixTest
14     {
15         private const string tag = "NUITEST";
16
17         [SetUp]
18         public void Init()
19         {
20             tlog.Info(tag, "Init() is called!");
21         }
22
23         [TearDown]
24         public void Destroy()
25         {
26             tlog.Info(tag, "Destroy() is called!");
27         }
28
29         [Test]
30         [Category("P1")]
31         [Description("Matrix constructor, with bool")]
32         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void MatrixConstructorwithbool()
37         {
38             tlog.Debug(tag, $"MatrixConstructorwithbool START");
39
40             Matrix testingTarget = new Matrix(false);
41             Assert.IsNotNull(testingTarget, "Should be not null!");
42             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"MatrixConstructorwithbool END (OK)");
46         }
47
48         [Test]
49         [Category("P1")]
50         [Description("Matrix constructor, with Rotation")]
51         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
52         [Property("SPEC_URL", "-")]
53         [Property("CRITERIA", "CONSTR")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         public void MatrixConstructorwithRotation()
56         {
57             tlog.Debug(tag, $"MatrixConstructorwithRotation START");
58
59             Rotation obj = new Rotation();
60             Matrix testingTarget = new Matrix(obj);
61             Assert.IsNotNull(testingTarget, "Should be not null!");
62             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
63
64             testingTarget.Dispose();
65             tlog.Debug(tag, $"MatrixConstructorwithRotation END (OK)");
66         }
67
68         [Test]
69         [Category("P1")]
70         [Description("Matrix constructor, with Matrix")]
71         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
72         [Property("SPEC_URL", "-")]
73         [Property("CRITERIA", "CONSTR")]
74         [Property("AUTHOR", "guowei.wang@samsung.com")]
75         public void MatrixConstructorwithMatrix()
76         {
77             tlog.Debug(tag, $"MatrixConstructorwithMatrix START");
78
79             Matrix matrix = new Matrix();
80             matrix.SetXAxis(new Vector3(1.0f, 2.0f, 3.0f));
81             matrix.SetYAxis(new Vector3(1.0f, 2.0f, 3.0f));
82             matrix.SetZAxis(new Vector3(1.0f, 2.0f, 3.0f));
83
84             var testingTarget = new Matrix(matrix);
85             Assert.IsNotNull(testingTarget, "Should be not null!");
86             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
87
88             try
89             {
90                 testingTarget.Invert();
91             }
92             catch (Exception e)
93             {
94                 tlog.Debug(tag, e.Message.ToString());
95                 Assert.Fail("Caught Exception : Failed!");
96             }
97
98             testingTarget.Dispose();
99             tlog.Debug(tag, $"MatrixConstructorwithMatrix END (OK)");
100         }
101
102         [Test]
103         [Category("P1")]
104         [Description("Matrix constructor, with array")]
105         [Property("SPEC", "Tizen.NUI.Matrix.Matrix C")]
106         [Property("SPEC_URL", "-")]
107         [Property("CRITERIA", "CONSTR")]
108         [Property("AUTHOR", "guowei.wang@samsung.com")]
109         public void MatrixConstructorwithArray()
110         {
111             tlog.Debug(tag, $"MatrixConstructorwithArray START");
112
113             var array = new float[3] { 1.0f, 3.0f, 5.0f };
114             var testingTarget = new Matrix(array);
115             Assert.IsNotNull(testingTarget, "Should be not null!");
116             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
117
118             try
119             {
120                 testingTarget.OrthoNormalize();
121             }
122             catch (Exception e)
123             {
124                 tlog.Debug(tag, e.Message);
125                 Assert.Fail("Caught Exception : Failed!");
126             }
127
128             testingTarget.Dispose();
129             tlog.Debug(tag, $"MatrixConstructorwithArray END (OK)");
130         }
131
132         [Test]
133         [Category("P1")]
134         [Description("Matrix GetYAxis.")]
135         [Property("SPEC", "Tizen.NUI.Matrix.GetYAxis M")]
136         [Property("SPEC_URL", "-")]
137         [Property("CRITERIA", "MR")]
138         [Property("AUTHOR", "guowei.wang@samsung.com")]
139         public void MatrixGetYAxis()
140         {
141             tlog.Debug(tag, $"MatrixGetYAxis START");
142
143             var testingTarget = new Matrix();
144             Assert.IsNotNull(testingTarget, "Should be not null!");
145             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
146
147             try
148             {
149                 testingTarget.GetYAxis();
150             }
151             catch (Exception e)
152             {
153                 tlog.Debug(tag, e.Message.ToString());
154                 Assert.Fail("Caught Exception : Failed!");
155             }
156
157             tlog.Debug(tag, $"MatrixGetYAxis END (OK)");
158         }
159
160         [Test]
161         [Category("P1")]
162         [Description("Matrix GetZAxis.")]
163         [Property("SPEC", "Tizen.NUI.Matrix.GetZAxis M")]
164         [Property("SPEC_URL", "-")]
165         [Property("CRITERIA", "MR")]
166         [Property("AUTHOR", "guowei.wang@samsung.com")]
167         public void MatrixGetZAxis()
168         {
169             tlog.Debug(tag, $"MatrixGetZAxis START");
170
171             var testingTarget = new Matrix();
172             Assert.IsNotNull(testingTarget, "Should be not null!");
173             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
174
175             try
176             {
177                 testingTarget.GetZAxis();
178             }
179             catch (Exception e)
180             {
181                 tlog.Debug(tag, e.Message.ToString());
182                 Assert.Fail("Caught Exception : Failed!");
183             }
184
185             tlog.Debug(tag, $"MatrixGetZAxis END (OK)");
186         }
187
188         [Test]
189         [Category("P1")]
190         [Description("Matrix SetXAxis.")]
191         [Property("SPEC", "Tizen.NUI.Matrix.SetXAxis M")]
192         [Property("SPEC_URL", "-")]
193         [Property("CRITERIA", "MR")]
194         [Property("AUTHOR", "guowei.wang@samsung.com")]
195         public void MatrixSetXAxis()
196         {
197             tlog.Debug(tag, $"MatrixSetXAxis START");
198
199             var testingTarget = new Matrix();
200             Assert.IsNotNull(testingTarget, "Should be not null!");
201             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
202
203             try
204             {
205                 Vector3 axis = new Vector3(1.0f, 2.0f, 3.0f);
206                 testingTarget.SetXAxis(axis);
207             }
208             catch (Exception e)
209             {
210                 tlog.Debug(tag, e.Message.ToString());
211                 Assert.Fail("Caught Exception : Failed!");
212             }
213
214             tlog.Debug(tag, $"MatrixSetXAxis END (OK)");
215         }
216
217         [Test]
218         [Category("P1")]
219         [Description("Matrix SetYAxis.")]
220         [Property("SPEC", "Tizen.NUI.Matrix.SetYAxis M")]
221         [Property("SPEC_URL", "-")]
222         [Property("CRITERIA", "MR")]
223         [Property("AUTHOR", "guowei.wang@samsung.com")]
224         public void MatrixSetYAxis()
225         {
226             tlog.Debug(tag, $"MatrixSetYAxis START");
227
228             var testingTarget = new Matrix();
229             Assert.IsNotNull(testingTarget, "Should be not null!");
230             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
231
232             try
233             {
234                 Vector3 axis = new Vector3(1.0f, 2.0f, 3.0f);
235                 testingTarget.SetYAxis(axis);
236             }
237             catch (Exception e)
238             {
239                 tlog.Debug(tag, e.Message.ToString());
240                 Assert.Fail("Caught Exception : Failed!");
241             }
242
243             tlog.Debug(tag, $"MatrixSetYAxis END (OK)");
244         }
245
246         [Test]
247         [Category("P1")]
248         [Description("Matrix SetZAxis.")]
249         [Property("SPEC", "Tizen.NUI.Matrix.SetZAxis M")]
250         [Property("SPEC_URL", "-")]
251         [Property("CRITERIA", "MR")]
252         [Property("AUTHOR", "guowei.wang@samsung.com")]
253         public void MatrixSetZAxis()
254         {
255             tlog.Debug(tag, $"MatrixSetZAxis START");
256
257             var testingTarget = new Matrix();
258             Assert.IsNotNull(testingTarget, "Should be not null!");
259             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
260
261             try
262             {
263                 Vector3 axis = new Vector3(1.0f, 2.0f, 3.0f);
264                 testingTarget.SetZAxis(axis);
265             }
266             catch (Exception e)
267             {
268                 tlog.Debug(tag, e.Message.ToString());
269                 Assert.Fail("Caught Exception : Failed!");
270             }
271
272             tlog.Debug(tag, $"MatrixSetZAxis END (OK)");
273         }
274
275         [Test]
276         [Category("P1")]
277         [Description("Matrix GetTranslation.")]
278         [Property("SPEC", "Tizen.NUI.Matrix.GetTranslation M")]
279         [Property("SPEC_URL", "-")]
280         [Property("CRITERIA", "MR")]
281         [Property("AUTHOR", "guowei.wang@samsung.com")]
282         public void MatrixGetTranslation()
283         {
284             tlog.Debug(tag, $"MatrixGetTranslation START");
285
286             var testingTarget = new Matrix();
287             Assert.IsNotNull(testingTarget, "Should be not null!");
288             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
289
290             try
291             {
292                 testingTarget.GetTranslation();
293             }
294             catch (Exception e)
295             {
296                 tlog.Debug(tag, e.Message.ToString());
297                 Assert.Fail("Caught Exception : Failed!");
298             }
299
300             tlog.Debug(tag, $"MatrixGetTranslation END (OK)");
301         }
302
303         [Test]
304         [Category("P1")]
305         [Description("Matrix GetTranslation3.")]
306         [Property("SPEC", "Tizen.NUI.Matrix.GetTranslation3 M")]
307         [Property("SPEC_URL", "-")]
308         [Property("CRITERIA", "MR")]
309         [Property("AUTHOR", "guowei.wang@samsung.com")]
310         public void MatrixGetTranslation3()
311         {
312             tlog.Debug(tag, $"MatrixGetTranslation3 START");
313
314             var testingTarget = new Matrix();
315             Assert.IsNotNull(testingTarget, "Should be not null!");
316             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
317
318             try
319             {
320                 testingTarget.GetTranslation3();
321             }
322             catch (Exception e)
323             {
324                 tlog.Debug(tag, e.Message.ToString());
325                 Assert.Fail("Caught Exception : Failed!");
326             }
327
328             tlog.Debug(tag, $"MatrixGetTranslation3 END (OK)");
329         }
330
331         [Test]
332         [Category("P1")]
333         [Description("Matrix SetTranslation.")]
334         [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation vector4 M")]
335         [Property("SPEC_URL", "-")]
336         [Property("CRITERIA", "MR")]
337         [Property("AUTHOR", "guowei.wang@samsung.com")]
338         public void MatrixSetTranslationwithVector4()
339         {
340             tlog.Debug(tag, $"MatrixSetTranslationwithVector4 START");
341
342             var testingTarget = new Matrix();
343             Assert.IsNotNull(testingTarget, "Should be not null!");
344             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
345
346             try
347             {
348                 Vector4 translation = new Vector4(0.3f, 0.5f, 0.8f, 1.0f);
349                 testingTarget.SetTranslation(translation);
350             }
351             catch (Exception e)
352             {
353                 tlog.Debug(tag, e.Message.ToString());
354                 Assert.Fail("Caught Exception : Failed!");
355             }
356
357             tlog.Debug(tag, $"MatrixSetTranslationwithVector4 END (OK)");
358         }
359
360         [Test]
361         [Category("P1")]
362         [Description("Matrix SetTranslation.")]
363         [Property("SPEC", "Tizen.NUI.Matrix.SetTranslation vector3 M")]
364         [Property("SPEC_URL", "-")]
365         [Property("CRITERIA", "MR")]
366         [Property("AUTHOR", "guowei.wang@samsung.com")]
367         public void MatrixSetTranslationwithVector3()
368         {
369             tlog.Debug(tag, $"MatrixSetTranslationwithVector3 START");
370
371             var testingTarget = new Matrix();
372             Assert.IsNotNull(testingTarget, "Should be not null!");
373             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
374
375             try
376             {
377                 Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f);
378                 testingTarget.SetTranslation(vector);
379             }
380             catch (Exception e)
381             {
382                 tlog.Debug(tag, e.Message.ToString());
383                 Assert.Fail("Caught Exception : Failed!");
384             }
385
386             tlog.Debug(tag, $"MatrixSetTranslationwithVector3 END (OK)");
387         }
388
389         [Test]
390         [Category("P1")]
391         [Description("Matrix IDENTITY.")]
392         [Property("SPEC", "Tizen.NUI.Matrix.IDENTITY A")]
393         [Property("SPEC_URL", "-")]
394         [Property("CRITERIA", "PRO")]
395         [Property("AUTHOR", "guowei.wang@samsung.com")]
396         public void MatrixIDENTITY()
397         {
398             tlog.Debug(tag, $"MatrixIDENTITY START");
399
400             var testingTarget = Matrix.IDENTITY;
401             Assert.IsNotNull(testingTarget, "Should be not null!");
402             Assert.IsInstanceOf<Matrix>(testingTarget, "Should be an Instance of Matrix!");
403
404             tlog.Debug(tag, $"MatrixIDENTITY END (OK)");
405         }
406
407         [Test]
408         [Category("P1")]
409         [Description("Matrix Multiply, (Matrix result, Matrix lhs, Matrix rhs)")]
410         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
411         [Property("SPEC_URL", "-")]
412         [Property("CRITERIA", "PRO")]
413         [Property("AUTHOR", "guowei.wang@samsung.com")]
414         public void MatrixMultiply()
415         {
416             tlog.Debug(tag, $"MatrixMultiply START");
417
418             Matrix lhs = new Matrix();
419             using (Vector3 vec = new Vector3(1.0f, 2.0f, 3.0f))
420             {
421                 lhs.SetXAxis(vec);
422                 lhs.SetYAxis(vec);
423                 lhs.SetZAxis(vec);
424             }
425
426             Matrix rhs = new Matrix();
427             using (Vector3 vec = new Vector3(2.0f, 3.0f, 4.0f))
428             {
429                 rhs.SetXAxis(vec);
430                 rhs.SetYAxis(vec);
431                 rhs.SetZAxis(vec);
432             }
433
434             try
435             {
436                 Matrix result = new Matrix();
437                 Matrix.Multiply(result, lhs, rhs);
438             }
439             catch (Exception e)
440             {
441                 tlog.Debug(tag, e.Message);
442                 Assert.Fail("Caught Exception : Failed!");
443             }
444
445             tlog.Debug(tag, $"MatrixMultiply END (OK)");
446         }
447
448         [Test]
449         [Category("P1")]
450         [Description("Matrix Multiply, (Matrix result, Matrix lhs, Rotation rhs)")]
451         [Property("SPEC", "Tizen.NUI.Matrix.Multiply M")]
452         [Property("SPEC_URL", "-")]
453         [Property("CRITERIA", "PRO")]
454         [Property("AUTHOR", "guowei.wang@samsung.com")]
455         public void MatrixMultiplyWithRotation()
456         {
457             tlog.Debug(tag, $"MatrixMultiplyWithRotation START");
458
459             Matrix lhs = new Matrix();
460             using (Vector3 vec = new Vector3(1.0f, 2.0f, 3.0f))
461             {
462                 lhs.SetXAxis(vec);
463                 lhs.SetYAxis(vec);
464                 lhs.SetZAxis(vec);
465             }
466
467             try
468             {
469                 Matrix result = new Matrix();
470                 Rotation rhs = new Rotation(new Radian(6.0f), new Vector3(1.0f, 2.0f, 3.0f));
471                 Matrix.Multiply(result, lhs, rhs);
472             }
473             catch (Exception e)
474             {
475                 tlog.Debug(tag, e.Message);
476                 Assert.Fail("Caught Exception : Failed!");
477             }
478
479             tlog.Debug(tag, $"MatrixMultiplyWithRotation END (OK)");
480         }
481     }
482 }