ca66f63b08dfea20cf061de0a5b7f48b0d994412
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / BaseComponents / TSAnimatedVectorImageView.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.Collections.Generic;
7
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("public/BaseComponents/AnimatedVectorImageView")]
14     public class PublicAnimatedVectorImageViewTest
15     {
16         private const string tag = "NUITEST";
17         private string url = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
18
19         internal class MyAnimatedVectorImageView : AnimatedVectorImageView
20         {
21             public MyAnimatedVectorImageView()
22             { }
23
24             public void OnDispose(DisposeTypes type)
25             {
26                 base.Dispose(type);
27             }
28         }
29
30         [SetUp]
31         public void Init()
32         {
33             tlog.Info(tag, "Init() is called!");
34         }
35
36         [TearDown]
37         public void Destroy()
38         {
39             tlog.Info(tag, "Destroy() is called!");
40         }
41
42         [Test]
43         [Category("P1")]
44         [Description("AnimatedVectorImageView constructor.")]
45         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.AnimatedVectorImageView C")]
46         [Property("SPEC_URL", "-")]
47         [Property("CRITERIA", "CONSTR")]
48         [Property("AUTHOR", "guowei.wang@samsung.com")]
49         public void AnimatedVectorImageViewConstructor()
50         {
51             tlog.Debug(tag, $"AnimatedVectorImageViewConstructor START");
52
53             var testingTarget = new AnimatedVectorImageView();
54             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
55             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
56
57             testingTarget.Dispose();
58             tlog.Debug(tag, $"AnimatedVectorImageViewConstructor END (OK)");
59         }
60
61         [Test]
62         [Category("P1")]
63         [Description("AnimatedVectorImageView constructor. With scale.")]
64         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.AnimatedVectorImageView C")]
65         [Property("SPEC_URL", "-")]
66         [Property("CRITERIA", "CONSTR")]
67         [Property("AUTHOR", "guowei.wang@samsung.com")]
68         public void AnimatedVectorImageViewConstructorWithScale()
69         {
70             tlog.Debug(tag, $"AnimatedVectorImageViewConstructorWithScale START");
71
72             var testingTarget = new AnimatedVectorImageView(0.3f);
73             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
74             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
75
76             testingTarget.Dispose();
77             tlog.Debug(tag, $"AnimatedVectorImageViewConstructorWithScale END (OK)");
78         }
79
80         [Test]
81         [Category("P1")]
82         [Description("AnimatedVectorImageView Dispose.")]
83         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.Dispose M")]
84         [Property("SPEC_URL", "-")]
85         [Property("CRITERIA", "MR")]
86         [Property("AUTHOR", "guowei.wang@samsung.com")]
87         public void AnimatedVectorImageViewDispose()
88         {
89             tlog.Debug(tag, $"AnimatedVectorImageViewDispose START");
90
91             var testingTarget = new MyAnimatedVectorImageView();
92             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
93             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
94
95             try
96             {
97                 testingTarget.OnDispose(DisposeTypes.Explicit);
98             }
99             catch (Exception e)
100             {
101                 tlog.Debug(tag, e.Message.ToString());
102                 Assert.Fail("Caught Exception: Failed!");
103             }
104
105             tlog.Debug(tag, $"AnimatedVectorImageViewDispose END (OK)");
106         }
107
108         [Test]
109         [Category("P1")]
110         [Description("AnimatedVectorImageView ResourceUrl.")]
111         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.ResourceUrl A")]
112         [Property("SPEC_URL", "-")]
113         [Property("CRITERIA", "PRW")]
114         [Property("AUTHOR", "guowei.wang@samsung.com")]
115         public void AnimatedVectorImageViewResourceUrl()
116         {
117             tlog.Debug(tag, $"AnimatedVectorImageViewResourceUrl START");
118
119             var testingTarget = new AnimatedVectorImageView();
120             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
121             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
122
123             testingTarget.ResourceUrl = url;
124             Assert.AreEqual(url, testingTarget.ResourceUrl, "Should be equal");
125
126             /** Set same url */
127             try
128             {
129                 testingTarget.ResourceUrl = url;
130             }
131             catch (Exception e)
132             {
133                 tlog.Debug(tag, e.Message.ToString());
134                 Assert.Fail("Caught Exception: Failed!");
135             }
136
137             testingTarget.Dispose();
138             tlog.Debug(tag, $"AnimatedVectorImageViewResourceUrl END (OK)");
139         }
140
141         [Test]
142         [Category("P1")]
143         [Description("AnimatedVectorImageView RepeatCount.")]
144         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.RepeatCount A")]
145         [Property("SPEC_URL", "-")]
146         [Property("CRITERIA", "PRW")]
147         [Property("AUTHOR", "guowei.wang@samsung.com")]
148         public void AnimatedVectorImageViewRepeatCount()
149         {
150             tlog.Debug(tag, $"AnimatedVectorImageViewRepeatCount START");
151
152             var testingTarget = new AnimatedVectorImageView();
153             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
154             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
155
156             Assert.AreEqual(0, testingTarget.RepeatCount, "Should be equal");
157
158             testingTarget.RepeatCount = 2;
159             Assert.AreEqual(2, testingTarget.RepeatCount, "Should be equal");
160
161             testingTarget.Dispose();
162             tlog.Debug(tag, $"AnimatedVectorImageViewRepeatCount END (OK)");
163         }
164
165         [Test]
166         [Category("P1")]
167         [Description("AnimatedVectorImageView TotalFrame.")]
168         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.TotalFrame A")]
169         [Property("SPEC_URL", "-")]
170         [Property("CRITERIA", "PRO")]
171         [Property("AUTHOR", "guowei.wang@samsung.com")]
172         public void AnimatedVectorImageViewTotalFrame()
173         {
174             tlog.Debug(tag, $"AnimatedVectorImageViewTotalFrame START");
175
176             var testingTarget = new AnimatedVectorImageView();
177             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
178             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
179
180             try
181             {
182                 var result = testingTarget.TotalFrame;
183             }
184             catch (Exception e)
185             {
186                 tlog.Debug(tag, e.Message.ToString());
187                 Assert.Fail("Caught Exception: Failed!");
188             }
189
190             testingTarget.Dispose();
191             tlog.Debug(tag, $"AnimatedVectorImageViewTotalFrame END (OK)");
192         }
193
194         [Test]
195         [Category("P1")]
196         [Description("AnimatedVectorImageView CurrentFrame.")]
197         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.CurrentFrame A")]
198         [Property("SPEC_URL", "-")]
199         [Property("CRITERIA", "PRW")]
200         [Property("AUTHOR", "guowei.wang@samsung.com")]
201         public void AnimatedVectorImageViewCurrentFrame()
202         {
203             tlog.Debug(tag, $"AnimatedVectorImageViewCurrentFrame START");
204
205             var testingTarget = new AnimatedVectorImageView();
206             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
207             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
208
209             testingTarget.ResourceUrl = url;
210             NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(testingTarget);
211
212             try
213             {
214                 testingTarget.CurrentFrame = 200;
215                 var result = testingTarget.CurrentFrame;
216
217                 /** value < 0 */
218                 testingTarget.CurrentFrame = -3;
219                 Assert.AreEqual(0, testingTarget.CurrentFrame, "Should be equal!");
220             }
221             catch (Exception e)
222             {
223                 tlog.Debug(tag, e.Message.ToString());
224                 Assert.Fail("Caught Exception: Failed!");
225             }
226
227             NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(testingTarget);
228
229             testingTarget.Dispose();
230             tlog.Debug(tag, $"AnimatedVectorImageViewCurrentFrame END (OK)");
231         }
232
233         [Test]
234         [Category("P2")]
235         [Description("AnimatedVectorImageView CurrentFrame. ResourceUrl is null.")]
236         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.CurrentFrame A")]
237         [Property("SPEC_URL", "-")]
238         [Property("CRITERIA", "PRW")]
239         [Property("AUTHOR", "guowei.wang@samsung.com")]
240         public void AnimatedVectorImageViewCurrentFrameNotSetResourceUrl()
241         {
242             tlog.Debug(tag, $"AnimatedVectorImageViewCurrentFrameNotSetResourceUrl START");
243
244             var testingTarget = new AnimatedVectorImageView();
245             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
246             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
247
248             try
249             {
250                 testingTarget.CurrentFrame = 3;
251             }
252             catch (InvalidOperationException e)
253             {
254                 tlog.Debug(tag, e.Message.ToString());
255                 testingTarget.Dispose();
256                 tlog.Debug(tag, $"AnimatedVectorImageViewCurrentFrameNotSetResourceUrl END (OK)");
257                 Assert.Pass("Caught InvalidOperationException: Passed!");
258             }
259         }
260
261         [Test]
262         [Category("P1")]
263         [Description("AnimatedVectorImageView RepeatMode.")]
264         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.RepeatMode A")]
265         [Property("SPEC_URL", "-")]
266         [Property("CRITERIA", "PRW")]
267         [Property("AUTHOR", "guowei.wang@samsung.com")]
268         public void AnimatedVectorImageViewRepeatMode()
269         {
270             tlog.Debug(tag, $"AnimatedVectorImageViewRepeatMode START");
271
272             var testingTarget = new AnimatedVectorImageView();
273             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
274             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
275
276             testingTarget.RepeatMode = AnimatedVectorImageView.RepeatModes.Reverse;
277             Assert.AreEqual(AnimatedVectorImageView.RepeatModes.Reverse, testingTarget.RepeatMode, "Should be equal!");
278
279             testingTarget.RepeatMode = AnimatedVectorImageView.RepeatModes.Restart;
280             Assert.AreEqual(AnimatedVectorImageView.RepeatModes.Restart, testingTarget.RepeatMode, "Should be equal!");
281
282             testingTarget.Dispose();
283             tlog.Debug(tag, $"AnimatedVectorImageViewRepeatMode END (OK)");
284         }
285
286         [Test]
287         [Category("P1")]
288         [Description("AnimatedVectorImageView AnimationState.")]
289         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.AnimationState A")]
290         [Property("SPEC_URL", "-")]
291         [Property("CRITERIA", "PRW")]
292         [Property("AUTHOR", "guowei.wang@samsung.com")]
293         public void AnimatedVectorImageViewAnimationState()
294         {
295             tlog.Debug(tag, $"AnimatedVectorImageViewAnimationState START");
296
297             var testingTarget = new AnimatedVectorImageView();
298             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
299             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
300
301             testingTarget.ResourceUrl = url;
302             
303             testingTarget.Play();
304             tlog.Debug(tag, "AnimationState : " + testingTarget.AnimationState);
305
306             testingTarget.Pause();
307             tlog.Debug(tag, "AnimationState : " + testingTarget.AnimationState);
308
309             testingTarget.Play();
310             tlog.Debug(tag, "AnimationState : " + testingTarget.AnimationState);
311
312             testingTarget.Stop();
313             tlog.Debug(tag, "AnimationState : " + testingTarget.AnimationState);
314
315             try
316             {
317                 testingTarget.Stop();
318             }
319             catch (Exception e)
320             {
321                 tlog.Debug(tag, e.Message.ToString());
322                 Assert.Fail("Caught Exception: Failed!");
323             }
324
325             testingTarget.Dispose();
326             tlog.Debug(tag, $"AnimatedVectorImageViewAnimationState END (OK)");
327         }
328
329         [Test]
330         [Category("P1")]
331         [Description("AnimatedVectorImageView SetMinAndMaxFrame.")]
332         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.SetMinAndMaxFrame M")]
333         [Property("SPEC_URL", "-")]
334         [Property("CRITERIA", "MR")]
335         [Property("AUTHOR", "guowei.wang@samsung.com")]
336         public void AnimatedVectorImageViewSetMinAndMaxFrame()
337         {
338             tlog.Debug(tag, $"AnimatedVectorImageViewSetMinAndMaxFrame START");
339
340             var testingTarget = new AnimatedVectorImageView();
341             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
342             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
343
344             try
345             {
346                 testingTarget.SetMinAndMaxFrame(1, 10);
347             }
348             catch (Exception e)
349             {
350                 tlog.Debug(tag, e.Message.ToString());
351                 Assert.Fail("Caught Exception: Failed!");
352             }
353
354             /** minimumFrame > maximumFrame */
355             try
356             {
357                 testingTarget.SetMinAndMaxFrame(10, 1);
358             }
359             catch (Exception e)
360             {
361                 tlog.Debug(tag, e.Message.ToString());
362                 Assert.Fail("Caught Exception: Failed!");
363             }
364
365             testingTarget.Dispose();
366             tlog.Debug(tag, $"AnimatedVectorImageViewSetMinAndMaxFrame END (OK)");
367         }
368
369         [Test]
370         [Category("P1")]
371         [Description("AnimatedVectorImageView SetMinMaxFrame.")]
372         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.SetMinMaxFrame M")]
373         [Property("SPEC_URL", "-")]
374         [Property("CRITERIA", "MR")]
375         [Property("AUTHOR", "guowei.wang@samsung.com")]
376         public void AnimatedVectorImageViewSetMinMaxFrame()
377         {
378             tlog.Debug(tag, $"AnimatedVectorImageViewSetMinMaxFrame START");
379
380             var testingTarget = new AnimatedVectorImageView();
381             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
382             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
383
384             try
385             {
386                 testingTarget.SetMinMaxFrame(1, 10);
387             }
388             catch (Exception e)
389             {
390                 tlog.Debug(tag, e.Message.ToString());
391                 Assert.Fail("Caught Exception: Failed!");
392             }
393
394             testingTarget.Dispose();
395             tlog.Debug(tag, $"AnimatedVectorImageViewSetMinMaxFrame END (OK)");
396         }
397
398         [Test]
399         [Category("P1")]
400         [Description("AnimatedVectorImageView SetMinMaxFrameByMarker.")]
401         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.SetMinMaxFrameByMarker M")]
402         [Property("SPEC_URL", "-")]
403         [Property("CRITERIA", "MR")]
404         [Property("AUTHOR", "guowei.wang@samsung.com")]
405         public void AnimatedVectorImageViewSetMinMaxFrameByMarker()
406         {
407             tlog.Debug(tag, $"AnimatedVectorImageViewSetMinMaxFrameByMarker START");
408
409             var testingTarget = new AnimatedVectorImageView();
410             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
411             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
412
413             string maker = "startframe: 1; endframe: 10";
414
415             try
416             {
417                 testingTarget.SetMinMaxFrameByMarker(maker, null);
418             }
419             catch (Exception e)
420             {
421                 tlog.Debug(tag, e.Message.ToString());
422                 Assert.Fail("Caught Exception: Failed!");
423             }
424
425             testingTarget.Dispose();
426             tlog.Debug(tag, $"AnimatedVectorImageViewSetMinMaxFrameByMarker END (OK)");
427         }
428
429         [Test]
430         [Category("P2")]
431         [Description("AnimatedVectorImageView Play. ResourceUrl is null.")]
432         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.Play M")]
433         [Property("SPEC_URL", "-")]
434         [Property("CRITERIA", "MR")]
435         [Property("AUTHOR", "guowei.wang@samsung.com")]
436         public void AnimatedVectorImageViewPlay()
437         {
438             tlog.Debug(tag, $"AnimatedVectorImageViewPlay START");
439
440             var testingTarget = new AnimatedVectorImageView();
441             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
442             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
443
444             try
445             {
446                 testingTarget.Play();
447             }
448             catch (InvalidOperationException e)
449             {
450                 tlog.Debug(tag, e.Message.ToString());
451                 testingTarget.Dispose();
452                 tlog.Debug(tag, $"AnimatedVectorImageViewPlay END (OK)");
453                 Assert.Pass("Caught InvalidOperationException: Passed!");
454             }
455         }
456
457         [Test]
458         [Category("P1")]
459         [Description("AnimatedVectorImageView Stop. EndAction is Cancel.")]
460         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.Stop M")]
461         [Property("SPEC_URL", "-")]
462         [Property("CRITERIA", "MR")]
463         [Property("AUTHOR", "guowei.wang@samsung.com")]
464         public void AnimatedVectorImageViewStopAsCancel()
465         {
466             tlog.Debug(tag, $"AnimatedVectorImageViewStopAsCancel START");
467
468             var testingTarget = new AnimatedVectorImageView();
469             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
470             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
471
472             testingTarget.ResourceUrl = url;
473
474             testingTarget.Play();
475
476             try
477             {
478                 testingTarget.Stop(AnimatedVectorImageView.EndActions.Cancel);
479             }
480             catch (Exception e)
481             {
482                 tlog.Debug(tag, e.Message.ToString());
483                 Assert.Fail("Caught Exception: Failed!");
484             }
485
486             testingTarget.Dispose();
487             tlog.Debug(tag, $"AnimatedVectorImageViewStopAsCancel END (OK)");
488         }
489
490         [Test]
491         [Category("P1")]
492         [Description("AnimatedVectorImageView Stop. EndAction is Discard.")]
493         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.Stop M")]
494         [Property("SPEC_URL", "-")]
495         [Property("CRITERIA", "MR")]
496         [Property("AUTHOR", "guowei.wang@samsung.com")]
497         public void AnimatedVectorImageViewStopAsDiscard()
498         {
499             tlog.Debug(tag, $"AnimatedVectorImageViewStopAsDiscard START");
500
501             var testingTarget = new AnimatedVectorImageView();
502             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
503             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
504
505             testingTarget.ResourceUrl = url;
506
507             testingTarget.Play();
508
509             try
510             {
511                 testingTarget.Stop(AnimatedVectorImageView.EndActions.Discard);
512             }
513             catch (Exception e)
514             {
515                 tlog.Debug(tag, e.Message.ToString());
516                 Assert.Fail("Caught Exception: Failed!");
517             }
518
519             testingTarget.Dispose();
520             tlog.Debug(tag, $"AnimatedVectorImageViewStopAsDiscard END (OK)");
521         }
522
523         [Test]
524         [Category("P1")]
525         [Description("AnimatedVectorImageView Stop. EndAction is StopFinal.")]
526         [Property("SPEC", "Tizen.NUI.AnimatedVectorImageView.Stop M")]
527         [Property("SPEC_URL", "-")]
528         [Property("CRITERIA", "MR")]
529         [Property("AUTHOR", "guowei.wang@samsung.com")]
530         public void AnimatedVectorImageViewStopAsStopFinal()
531         {
532             tlog.Debug(tag, $"AnimatedVectorImageViewStopAsStopFinal START");
533
534             var testingTarget = new AnimatedVectorImageView();
535             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedVectorImageView");
536             Assert.IsInstanceOf<AnimatedVectorImageView>(testingTarget, "Should be an instance of AnimatedVectorImageView type.");
537
538             testingTarget.ResourceUrl = url;
539
540             testingTarget.Play();
541
542             try
543             {
544                 testingTarget.Stop(AnimatedVectorImageView.EndActions.StopFinal);
545             }
546             catch (Exception e)
547             {
548                 tlog.Debug(tag, e.Message.ToString());
549                 Assert.Fail("Caught Exception: Failed!");
550             }
551
552             testingTarget.Dispose();
553             tlog.Debug(tag, $"AnimatedVectorImageViewStopAsStopFinal END (OK)");
554         }
555     }
556 }