[NUI] Update TCs of NUI.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / XamlBinding / TSVectorTypeConverter.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 using System.Reflection;
7 using System.Collections.Generic;
8 using Tizen.NUI.Binding;
9
10 namespace Tizen.NUI.Devel.Tests
11 {
12     using tlog = Tizen.Log;
13
14     [TestFixture]
15     [Description("internal/XamlBinding/VectorTypeConverter")]
16     public class InternalVectorTypeConverterTest
17     {
18         private const string tag = "NUITEST";
19         private string selfpath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "Test_Theme.xaml";
20
21         internal class Vector2TypeConverterImpl : Vector2TypeConverter
22         {
23             public Vector2TypeConverterImpl()
24             { }
25         }
26
27         internal class Vector3TypeConverterImpl : Vector3TypeConverter
28         {
29             public Vector3TypeConverterImpl()
30             { }
31         }
32
33
34         internal class Vector4TypeConverterImpl : Vector4TypeConverter
35         {
36             public Vector4TypeConverterImpl()
37             { }
38         }
39
40         internal class RelativeVector2TypeConverterImpl : RelativeVector2TypeConverter
41         {
42             public RelativeVector2TypeConverterImpl()
43             { }
44         }
45
46         internal class RelativeVector3TypeConverterImpl : RelativeVector3TypeConverter
47         {
48             public RelativeVector3TypeConverterImpl()
49             { }
50         }
51
52         internal class RelativeVector4TypeConverterImpl : RelativeVector4TypeConverter
53         {
54             public RelativeVector4TypeConverterImpl()
55             { }
56         }
57
58         [SetUp]
59         public void Init()
60         {
61             tlog.Info(tag, "Init() is called!");
62         }
63
64         [TearDown]
65         public void Destroy()
66         {
67             tlog.Info(tag, "Destroy() is called!");
68         }
69
70         [Test]
71         [Category("P1")]
72         [Description("Vector2TypeConverter ConvertFromInvariantString")]
73         [Property("SPEC", "Tizen.NUI.Vector2TypeConverter.ConvertFromInvariantString M")]
74         [Property("SPEC_URL", "-")]
75         [Property("CRITERIA", "MR")]
76         public void Vector2TypeConverterConvertFromInvariantString()
77         {
78             tlog.Debug(tag, $"Vector2TypeConverterConvertFromInvariantString START");
79
80             var testingTarget = new Vector2TypeConverterImpl();
81             Assert.IsNotNull(testingTarget, "Can't create success object Vector2TypeConverter.");
82             Assert.IsInstanceOf<Vector2TypeConverter>(testingTarget, "Should return Vector2TypeConverter instance.");
83
84             var result = testingTarget.ConvertFromInvariantString("100");
85             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
86
87             tlog.Debug(tag, $"Vector2TypeConverterConvertFromInvariantString END");
88         }
89
90         [Test]
91         [Category("P2")]
92         [Description("Vector2TypeConverter ConvertFromInvariantString")]
93         [Property("SPEC", "Tizen.NUI.Vector2TypeConverter.ConvertFromInvariantString M")]
94         [Property("SPEC_URL", "-")]
95         [Property("CRITERIA", "MR")]
96         public void Vector2TypeConverterConvertFromInvariantStringNullPath()
97         {
98             tlog.Debug(tag, $"Vector2TypeConverterConvertFromInvariantStringNullPath START");
99
100             var testingTarget = new Vector2TypeConverterImpl();
101             Assert.IsNotNull(testingTarget, "Can't create success object Vector2TypeConverter.");
102             Assert.IsInstanceOf<Vector2TypeConverter>(testingTarget, "Should return Vector2TypeConverter instance.");
103
104             try
105             {
106                 string str = null;
107                 var result = testingTarget.ConvertFromInvariantString(str);
108             }
109             catch (InvalidOperationException)
110             {
111                 tlog.Debug(tag, $"Vector2TypeConverterConvertFromInvariantStringNullPath END");
112                 Assert.Pass("Caught InvalidOperationException : Passed!");
113             }
114         }
115
116         [Test]
117         [Category("P1")]
118         [Description("Vector2TypeConverter ConvertToString")]
119         [Property("SPEC", "Tizen.NUI.Vector2TypeConverter.ConvertToString M")]
120         [Property("SPEC_URL", "-")]
121         [Property("CRITERIA", "MR")]
122         public void Vector2TypeConverterConvertToString()
123         {
124             tlog.Debug(tag, $"Vector2TypeConverterConvertToString START");
125
126             var testingTarget = new Vector2TypeConverterImpl();
127             Assert.IsNotNull(testingTarget, "Can't create success object Vector2TypeConverter.");
128             Assert.IsInstanceOf<Vector2TypeConverter>(testingTarget, "Should return Vector2TypeConverter instance.");
129
130             var result = testingTarget.ConvertToString(0.3f);
131             tlog.Debug(tag, "ConvertToString : " + result);
132
133             tlog.Debug(tag, $"Vector2TypeConverterConvertToString END");
134         }
135
136         [Test]
137         [Category("P1")]
138         [Description("Vector2TypeConverter FromString")]
139         [Property("SPEC", "Tizen.NUI.Vector2TypeConverter.FromString M")]
140         [Property("SPEC_URL", "-")]
141         [Property("CRITERIA", "MR")]
142         public void Vector2TypeConverterFromString()
143         {
144             tlog.Debug(tag, $"Vector2TypeConverterFromString START");
145
146             // length is 2
147             var result = Vector2TypeConverter.FromString("100, 50");
148             tlog.Debug(tag, "FromString : " + result);
149
150             // length is 1
151             result = Vector2TypeConverter.FromString("100");
152             tlog.Debug(tag, "FromString : " + result);
153
154             tlog.Debug(tag, $"Vector2TypeConverterFromString END");
155         }
156
157         [Test]
158         [Category("P2")]
159         [Description("Vector2TypeConverter InvalidOperationException")]
160         [Property("SPEC", "Tizen.NUI.Vector2TypeConverter.FromString M")]
161         [Property("SPEC_URL", "-")]
162         [Property("CRITERIA", "MR")]
163         public void Vector2TypeConverterFromStringInvalidOperationException()
164         {
165             tlog.Debug(tag, $"Vector2TypeConverterFromStringInvalidOperationException START");
166
167             try
168             {
169                 // length is 3
170                 Vector2TypeConverter.FromString("100, 50, 0.0f");
171             }
172             catch (InvalidOperationException)
173             {
174                 tlog.Debug(tag, $"Vector2TypeConverterFromStringInvalidOperationException END");
175                 Assert.Pass("Caught InvalidOperationException : Passed!");
176             }
177         }
178
179         [Test]
180         [Category("P1")]
181         [Description("Vector2TypeConverter ToString")]
182         [Property("SPEC", "Tizen.NUI.Vector2TypeConverter.ToString M")]
183         [Property("SPEC_URL", "-")]
184         [Property("CRITERIA", "MR")]
185         public void Vector2TypeConverterToString()
186         {
187             tlog.Debug(tag, $"Vector2TypeConverterToString START");
188
189             using (Vector2 vec = new Vector2(100, 50))
190             { 
191                 var result = Vector2TypeConverter.ToString(vec);
192                 tlog.Debug(tag, "ToString : " + result);
193             }
194
195             Vector2 val = null;
196             Assert.AreEqual(null, Vector2TypeConverter.ToString(val), "should be equal!");
197
198             tlog.Debug(tag, $"Vector2TypeConverterToString END");
199         }
200
201         [Test]
202         [Category("P1")]
203         [Description("Vector3TypeConverter ConvertFromInvariantString")]
204         [Property("SPEC", "Tizen.NUI.Vector3TypeConverter.ConvertFromInvariantString M")]
205         [Property("SPEC_URL", "-")]
206         [Property("CRITERIA", "MR")]
207         public void Vector3TypeConverterConvertFromInvariantString()
208         {
209             tlog.Debug(tag, $"Vector3TypeConverterConvertFromInvariantString START");
210
211             var testingTarget = new Vector3TypeConverterImpl();
212             Assert.IsNotNull(testingTarget, "Can't create success object Vector3TypeConverter.");
213             Assert.IsInstanceOf<Vector3TypeConverter>(testingTarget, "Should return Vector3TypeConverter instance.");
214
215             // length is 3
216             var result = testingTarget.ConvertFromInvariantString("100, 50, 30");
217             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
218
219             // length is 2
220             result = testingTarget.ConvertFromInvariantString("100, 50");
221             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
222
223             // length is 1
224             result = testingTarget.ConvertFromInvariantString("100");
225             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
226
227             try
228             {
229                 // lenght is 4
230                 result = testingTarget.ConvertFromInvariantString("100, 50, 30, 0.3f");
231             }
232             catch (InvalidOperationException)
233             {
234                 tlog.Debug(tag, $"Vector3TypeConverterConvertFromInvariantString END");
235                 Assert.Pass("Caught InvalidOperationException : Passed!");
236             }
237         }
238
239         [Test]
240         [Category("P1")]
241         [Description("Vector3TypeConverter ConvertToString")]
242         [Property("SPEC", "Tizen.NUI.Vector3TypeConverter.ConvertToString M")]
243         [Property("SPEC_URL", "-")]
244         [Property("CRITERIA", "MR")]
245         public void Vector3TypeConverterConvertToString()
246         {
247             tlog.Debug(tag, $"Vector3TypeConverterConvertToString START");
248
249             var testingTarget = new Vector3TypeConverterImpl();
250             Assert.IsNotNull(testingTarget, "Can't create success object Vector3TypeConverter.");
251             Assert.IsInstanceOf<Vector3TypeConverter>(testingTarget, "Should return Vector3TypeConverter instance.");
252
253             // null
254             var result = testingTarget.ConvertToString(0.3f);
255             tlog.Debug(tag, "ConvertToString : " + result);
256
257             using (Vector3 vec = new Vector3(0.1f, 0.3f, 0.5f))
258             {
259                 result = testingTarget.ConvertToString(vec);
260                 tlog.Debug(tag, "ConvertToString : " + result);
261             }
262
263             tlog.Debug(tag, $"Vector3TypeConverterConvertToString END");
264         }
265
266         [Test]
267         [Category("P1")]
268         [Description("Vector4TypeConverter ConvertFromInvariantString")]
269         [Property("SPEC", "Tizen.NUI.Vector4TypeConverter.ConvertFromInvariantString M")]
270         [Property("SPEC_URL", "-")]
271         [Property("CRITERIA", "MR")]
272         public void Vector4TypeConverterConvertFromInvariantString()
273         {
274             tlog.Debug(tag, $"Vector4TypeConverterConvertFromInvariantString START");
275
276             var testingTarget = new Vector4TypeConverterImpl();
277             Assert.IsNotNull(testingTarget, "Can't create success object Vector4TypeConverter.");
278             Assert.IsInstanceOf<Vector4TypeConverter>(testingTarget, "Should return Vector4TypeConverter instance.");
279
280             // length is 4
281             var result = testingTarget.ConvertFromInvariantString("100, 50, 30, 10");
282             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
283
284             // length is 3
285             result = testingTarget.ConvertFromInvariantString("100, 50, 30");
286             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
287
288             // length is 2
289             result = testingTarget.ConvertFromInvariantString("100, 50");
290             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
291
292             // length is 1
293             result = testingTarget.ConvertFromInvariantString("100");
294             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
295
296             try
297             {
298                 // lenght is 5
299                 result = testingTarget.ConvertFromInvariantString("100, 50, 30, 10, 0.3f");
300             }
301             catch (InvalidOperationException)
302             {
303                 tlog.Debug(tag, $"Vector4TypeConverterConvertFromInvariantString END");
304                 Assert.Pass("Caught InvalidOperationException : Passed!");
305             }
306         }
307
308         [Test]
309         [Category("P1")]
310         [Description("Vector4TypeConverter ConvertToString")]
311         [Property("SPEC", "Tizen.NUI.Vector4TypeConverter.ConvertToString M")]
312         [Property("SPEC_URL", "-")]
313         [Property("CRITERIA", "MR")]
314         public void Vector4TypeConverterConvertToString()
315         {
316             tlog.Debug(tag, $"Vector4TypeConverterConvertToString START");
317
318             var testingTarget = new Vector4TypeConverterImpl();
319             Assert.IsNotNull(testingTarget, "Can't create success object Vector4TypeConverter.");
320             Assert.IsInstanceOf<Vector4TypeConverter>(testingTarget, "Should return Vector4TypeConverter instance.");
321
322             // null
323             var result = testingTarget.ConvertToString(0.3f);
324             tlog.Debug(tag, "ConvertToString : " + result);
325
326             using (Vector4 vec = new Vector4(0.1f, 0.3f, 0.5f, 0.0f))
327             {
328                 result = testingTarget.ConvertToString(vec);
329                 tlog.Debug(tag, "ConvertToString : " + result);
330             }
331
332             tlog.Debug(tag, $"Vector4TypeConverterConvertToString END");
333         }
334
335         [Test]
336         [Category("P1")]
337         [Description("RelativeVector2TypeConverter ConvertFromInvariantString")]
338         [Property("SPEC", "Tizen.NUI.RelativeVector2TypeConverter.ConvertFromInvariantString M")]
339         [Property("SPEC_URL", "-")]
340         [Property("CRITERIA", "MR")]
341         public void RelativeVector2TypeConverterConvertFromInvariantString()
342         {
343             tlog.Debug(tag, $"RelativeVector2TypeConverterConvertFromInvariantString START");
344
345             var testingTarget = new RelativeVector2TypeConverterImpl();
346             Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2TypeConverter.");
347             Assert.IsInstanceOf<RelativeVector2TypeConverter>(testingTarget, "Should return RelativeVector2TypeConverter instance.");
348
349             // length is 2
350             var result = testingTarget.ConvertFromInvariantString("100, 50");
351             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
352
353             // length is 1
354             result = testingTarget.ConvertFromInvariantString("100");
355             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
356
357             try
358             {
359                 // lenght is 3
360                 result = testingTarget.ConvertFromInvariantString("100, 50, 30");
361             }
362             catch (InvalidOperationException)
363             {
364                 tlog.Debug(tag, $"RelativeVector2TypeConverterConvertFromInvariantString END");
365                 Assert.Pass("Caught InvalidOperationException : Passed!");
366             }
367         }
368
369         [Test]
370         [Category("P1")]
371         [Description("RelativeVector2TypeConverter ConvertToString")]
372         [Property("SPEC", "Tizen.NUI.RelativeVector2TypeConverter.ConvertToString M")]
373         [Property("SPEC_URL", "-")]
374         [Property("CRITERIA", "MR")]
375         public void RelativeVector2TypeConverterConvertToString()
376         {
377             tlog.Debug(tag, $"RelativeVector2TypeConverterConvertToString START");
378
379             var testingTarget = new RelativeVector2TypeConverterImpl();
380             Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2TypeConverter.");
381             Assert.IsInstanceOf<RelativeVector2TypeConverter>(testingTarget, "Should return RelativeVector2TypeConverter instance.");
382
383             // null
384             var result = testingTarget.ConvertToString(0.3f);
385             tlog.Debug(tag, "ConvertToString : " + result);
386
387             using (RelativeVector2 vec = new RelativeVector2(0.1f, 0.3f))
388             {
389                 result = testingTarget.ConvertToString(vec);
390                 tlog.Debug(tag, "ConvertToString : " + result);
391             }
392
393             tlog.Debug(tag, $"RelativeVector2TypeConverterConvertToString END");
394         }
395
396         [Test]
397         [Category("P1")]
398         [Description("RelativeVector3TypeConverter ConvertFromInvariantString")]
399         [Property("SPEC", "Tizen.NUI.RelativeVector3TypeConverter.ConvertFromInvariantString M")]
400         [Property("SPEC_URL", "-")]
401         [Property("CRITERIA", "MR")]
402         public void RelativeVector3TypeConverterConvertFromInvariantString()
403         {
404             tlog.Debug(tag, $"RelativeVector3TypeConverterConvertFromInvariantString START");
405
406             var testingTarget = new RelativeVector3TypeConverterImpl();
407             Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector3TypeConverter.");
408             Assert.IsInstanceOf<RelativeVector3TypeConverter>(testingTarget, "Should return RelativeVector3TypeConverter instance.");
409
410             // length is 3
411             var result = testingTarget.ConvertFromInvariantString("100, 50, 30");
412             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
413
414             // length is 2
415             result = testingTarget.ConvertFromInvariantString("100, 50");
416             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
417
418             // length is 1
419             result = testingTarget.ConvertFromInvariantString("100");
420             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
421
422             try
423             {
424                 // lenght is 4
425                 result = testingTarget.ConvertFromInvariantString("100, 50, 30, 10");
426             }
427             catch (InvalidOperationException)
428             {
429                 tlog.Debug(tag, $"RelativeVector3TypeConverterConvertFromInvariantString END");
430                 Assert.Pass("Caught InvalidOperationException : Passed!");
431             }
432         }
433
434         [Test]
435         [Category("P1")]
436         [Description("RelativeVector3TypeConverter ConvertToString")]
437         [Property("SPEC", "Tizen.NUI.RelativeVector3TypeConverter.ConvertToString M")]
438         [Property("SPEC_URL", "-")]
439         [Property("CRITERIA", "MR")]
440         public void RelativeVector3TypeConverterConvertToString()
441         {
442             tlog.Debug(tag, $"RelativeVector3TypeConverterConvertToString START");
443
444             var testingTarget = new RelativeVector3TypeConverterImpl();
445             Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector3TypeConverter.");
446             Assert.IsInstanceOf<RelativeVector3TypeConverter>(testingTarget, "Should return RelativeVector3TypeConverter instance.");
447
448             // null
449             var result = testingTarget.ConvertToString(0.3f);
450             tlog.Debug(tag, "ConvertToString : " + result);
451
452             using (RelativeVector3 vec = new RelativeVector3(0.1f, 0.3f, 0.5f))
453             {
454                 result = testingTarget.ConvertToString(vec);
455                 tlog.Debug(tag, "ConvertToString : " + result);
456             }
457
458             tlog.Debug(tag, $"RelativeVector3TypeConverterConvertToString END");
459         }
460
461         [Test]
462         [Category("P1")]
463         [Description("RelativeVector4TypeConverter ConvertFromInvariantString")]
464         [Property("SPEC", "Tizen.NUI.RelativeVector4TypeConverter.ConvertFromInvariantString M")]
465         [Property("SPEC_URL", "-")]
466         [Property("CRITERIA", "MR")]
467         public void RelativeVector4TypeConverterConvertFromInvariantString()
468         {
469             tlog.Debug(tag, $"RelativeVector4TypeConverterConvertFromInvariantString START");
470
471             var testingTarget = new RelativeVector4TypeConverterImpl();
472             Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector4TypeConverter.");
473             Assert.IsInstanceOf<RelativeVector4TypeConverter>(testingTarget, "Should return RelativeVector4TypeConverter instance.");
474
475             // length is 4
476             var result = testingTarget.ConvertFromInvariantString("100, 50, 30, 10");
477             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
478
479             // length is 3
480             result = testingTarget.ConvertFromInvariantString("100, 50, 30");
481             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
482
483             // length is 2
484             result = testingTarget.ConvertFromInvariantString("100, 50");
485             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
486
487             // length is 1
488             result = testingTarget.ConvertFromInvariantString("100");
489             tlog.Debug(tag, "ConvertFromInvariantString : " + result);
490
491             try
492             {
493                 // lenght is 5
494                 result = testingTarget.ConvertFromInvariantString("100, 50, 30, 10, 0.3f");
495             }
496             catch (InvalidOperationException)
497             {
498                 tlog.Debug(tag, $"RelativeVector4TypeConverterConvertFromInvariantString END");
499                 Assert.Pass("Caught InvalidOperationException : Passed!");
500             }
501         }
502
503         [Test]
504         [Category("P1")]
505         [Description("RelativeVector4TypeConverter ConvertToString")]
506         [Property("SPEC", "Tizen.NUI.RelativeVector4TypeConverter.ConvertToString M")]
507         [Property("SPEC_URL", "-")]
508         [Property("CRITERIA", "MR")]
509         public void RelativeVector4TypeConverterConvertToString()
510         {
511             tlog.Debug(tag, $"RelativeVector4TypeConverterConvertToString START");
512
513             var testingTarget = new RelativeVector4TypeConverterImpl();
514             Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector4TypeConverter.");
515             Assert.IsInstanceOf<RelativeVector4TypeConverter>(testingTarget, "Should return RelativeVector4TypeConverter instance.");
516
517             // null
518             var result = testingTarget.ConvertToString(0.3f);
519             tlog.Debug(tag, "ConvertToString : " + result);
520
521             using (RelativeVector4 vec = new RelativeVector4(0.1f, 0.3f, 0.5f, 0.0f))
522             {
523                 result = testingTarget.ConvertToString(vec);
524                 tlog.Debug(tag, "ConvertToString : " + result);
525             }
526
527             tlog.Debug(tag, $"RelativeVector4TypeConverterConvertToString END");
528         }
529     }
530 }