[NUI] Update NUI.Devel to fix block and crash issues.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / BaseComponents / TSLottieAnimationView.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/LottieAnimationView")]
14     public class PublicLottieAnimationViewTest
15     {
16         private const string tag = "NUITEST";
17         private string url = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/picture.png";
18         private string lottieFilePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/lottie.json";
19
20         [SetUp]
21         public void Init()
22         {
23             tlog.Info(tag, "Init() is called!");
24         }
25
26         [TearDown]
27         public void Destroy()
28         {
29             tlog.Info(tag, "Destroy() is called!");
30         }
31
32         [Test]
33         [Category("P1")]
34         [Description("LottieAnimationView URL.")]
35         [Property("SPEC", "Tizen.NUI.LottieAnimationView.URL A")]
36         [Property("SPEC_URL", "-")]
37         [Property("CRITERIA", "PRW")]
38         [Property("AUTHOR", "guowei.wang@samsung.com")]
39         public void LottieAnimationViewURL()
40         {
41             tlog.Debug(tag, $"LottieAnimationViewURL START");
42
43             using (Uint16Pair size = new Uint16Pair(40, 60))
44             {
45                 var testingTarget = new LottieAnimationView(1.0f, true);
46                 Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
47                 Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
48
49                 testingTarget.URL = lottieFilePath;
50
51                 try
52                 {
53                     var result = testingTarget.URL;
54                 }
55                 catch (Exception e)
56                 {
57                     tlog.Debug(tag, e.Message.ToString());
58                     Assert.Fail("Caught Exception: Failed!");
59                 }
60
61                 testingTarget.Dispose();
62             }
63
64             tlog.Debug(tag, $"LottieAnimationViewURL END (OK)");
65         }
66
67         [Test]
68         [Category("P1")]
69         [Description("LottieAnimationView RedrawInScalingDown.")]
70         [Property("SPEC", "Tizen.NUI.LottieAnimationView.RedrawInScalingDown A")]
71         [Property("SPEC_URL", "-")]
72         [Property("CRITERIA", "PRW")]
73         [Property("AUTHOR", "guowei.wang@samsung.com")]
74         public void LottieAnimationViewRedrawInScalingDown()
75         {
76             tlog.Debug(tag, $"LottieAnimationViewRedrawInScalingDown START");
77
78             using (Uint16Pair size = new Uint16Pair(40, 60))
79             {
80                 var testingTarget = new LottieAnimationView(1.0f, true);
81                 Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
82                 Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
83
84                 testingTarget.URL = lottieFilePath;
85
86                 PropertyMap map = new PropertyMap();
87                 map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
88                     .Add(ImageVisualProperty.URL, new PropertyValue(url))
89                     .Add(ImageVisualProperty.LoopCount, new PropertyValue(2));
90                 testingTarget.Image = map;
91
92                 testingTarget.RedrawInScalingDown = true;
93                 Assert.IsTrue(testingTarget.RedrawInScalingDown);
94
95                 testingTarget.Dispose();
96             }
97
98             tlog.Debug(tag, $"LottieAnimationViewRedrawInScalingDown END (OK)");
99         }
100
101         [Test]
102         [Category("P1")]
103         [Description("LottieAnimationView SetMinMaxFrameByMarker.")]
104         [Property("SPEC", "Tizen.NUI.LottieAnimationView.SetMinMaxFrameByMarker M")]
105         [Property("SPEC_URL", "-")]
106         [Property("CRITERIA", "MR")]
107         [Property("AUTHOR", "guowei.wang@samsung.com")]
108         public void LottieAnimationViewSetMinMaxFrameByMarker()
109         {
110             tlog.Debug(tag, $"LottieAnimationViewSetMinMaxFrameByMarker START");
111
112             var testingTarget = new LottieAnimationView();
113             Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
114             Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
115
116             testingTarget.URL = lottieFilePath;
117
118             string maker = "startframe: 1; endframe: 10";
119
120             try
121             {
122                 testingTarget.SetMinMaxFrameByMarker(maker, null);
123             }
124             catch (Exception e)
125             {
126                 tlog.Debug(tag, e.Message.ToString());
127                 Assert.Fail("Caught Exception: Failed!");
128             }
129
130             testingTarget.Dispose();
131             tlog.Debug(tag, $"LottieAnimationViewSetMinMaxFrameByMarker END (OK)");
132         }
133
134         [Test]
135         [Category("P1")]
136         [Description("LottieAnimationView GetMinMaxFrame.")]
137         [Property("SPEC", "Tizen.NUI.LottieAnimationView.GetMinMaxFrame M")]
138         [Property("SPEC_URL", "-")]
139         [Property("CRITERIA", "MR")]
140         [Property("AUTHOR", "guowei.wang@samsung.com")]
141         public void LottieAnimationViewGetMinMaxFrame()
142         {
143             tlog.Debug(tag, $"LottieAnimationViewGetMinMaxFrame START");
144
145             var testingTarget = new LottieAnimationView();
146             Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
147             Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
148
149             testingTarget.URL = lottieFilePath;
150
151             PropertyMap map = new PropertyMap();
152             map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
153                 .Add(ImageVisualProperty.URL, new PropertyValue(url))
154                 .Add(ImageVisualProperty.LoopCount, new PropertyValue(2))
155                 .Add(ImageVisualProperty.PlayRange, new PropertyValue(50));
156             testingTarget.Image = map;
157
158             string maker = "startframe: 1; endframe: 10";
159             testingTarget.SetMinMaxFrameByMarker(maker, null);
160
161             try
162             {
163                 testingTarget.GetMinMaxFrame();    
164             }
165             catch (Exception e)
166             {
167                 tlog.Debug(tag, e.Message.ToString());
168                 Assert.Fail("Caught Exception: Failed!");
169             }
170
171             testingTarget.Dispose();
172             tlog.Debug(tag, $"LottieAnimationViewGetMinMaxFrame END (OK)");
173         }
174
175         [Test]
176         [Category("P1")]
177         [Description("LottieAnimationView Finished.")]
178         [Property("SPEC", "Tizen.NUI.LottieAnimationView.Finished M")]
179         [Property("SPEC_URL", "-")]
180         [Property("CRITERIA", "MR")]
181         [Property("AUTHOR", "guowei.wang@samsung.com")]
182         public void LottieAnimationViewFinished()
183         {
184             tlog.Debug(tag, $"LottieAnimationViewFinished START");
185
186             var testingTarget = new LottieAnimationView();
187             Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
188             Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
189
190             testingTarget.URL = lottieFilePath;
191             NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(testingTarget);
192
193             testingTarget.Finished += OnFinishedEvent;
194             testingTarget.Finished -= OnFinishedEvent;
195
196             NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(testingTarget);
197
198             testingTarget.Dispose();
199             tlog.Debug(tag, $"LottieAnimationViewFinished END (OK)");
200         }
201
202         public void OnFinishedEvent(object sender, EventArgs e)
203         { 
204             // not implemented
205         }
206     }
207 }