[NUI] Make PrimaryCursorPosition property public
[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
62             tlog.Debug(tag, $"LottieAnimationViewURL END (OK)");
63         }
64
65         [Test]
66         [Category("P1")]
67         [Description("LottieAnimationView RedrawInScalingDown.")]
68         [Property("SPEC", "Tizen.NUI.LottieAnimationView.RedrawInScalingDown A")]
69         [Property("SPEC_URL", "-")]
70         [Property("CRITERIA", "PRW")]
71         [Property("AUTHOR", "guowei.wang@samsung.com")]
72         public void LottieAnimationViewRedrawInScalingDown()
73         {
74             tlog.Debug(tag, $"LottieAnimationViewRedrawInScalingDown START");
75
76             using (Uint16Pair size = new Uint16Pair(40, 60))
77             {
78                 var testingTarget = new LottieAnimationView(1.0f, true);
79                 Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
80                 Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
81
82                 testingTarget.URL = lottieFilePath;
83
84                 PropertyMap map = new PropertyMap();
85                 map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
86                     .Add(ImageVisualProperty.URL, new PropertyValue(url))
87                     .Add(ImageVisualProperty.LoopCount, new PropertyValue(2));
88                 testingTarget.Image = map;
89
90                 testingTarget.RedrawInScalingDown = true;
91                 Assert.IsTrue(testingTarget.RedrawInScalingDown);
92             }
93
94             tlog.Debug(tag, $"LottieAnimationViewRedrawInScalingDown END (OK)");
95         }
96
97         [Test]
98         [Category("P1")]
99         [Description("LottieAnimationView SetMinMaxFrameByMarker.")]
100         [Property("SPEC", "Tizen.NUI.LottieAnimationView.SetMinMaxFrameByMarker M")]
101         [Property("SPEC_URL", "-")]
102         [Property("CRITERIA", "MR")]
103         [Property("AUTHOR", "guowei.wang@samsung.com")]
104         public void LottieAnimationViewSetMinMaxFrameByMarker()
105         {
106             tlog.Debug(tag, $"LottieAnimationViewSetMinMaxFrameByMarker START");
107
108             var testingTarget = new LottieAnimationView();
109             Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
110             Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
111
112             testingTarget.URL = lottieFilePath;
113
114             string maker = "startframe: 1; endframe: 10";
115
116             try
117             {
118                 testingTarget.SetMinMaxFrameByMarker(maker, null);
119             }
120             catch (Exception e)
121             {
122                 tlog.Debug(tag, e.Message.ToString());
123                 Assert.Fail("Caught Exception: Failed!");
124             }
125
126             tlog.Debug(tag, $"LottieAnimationViewSetMinMaxFrameByMarker END (OK)");
127         }
128
129         [Test]
130         [Category("P1")]
131         [Description("LottieAnimationView GetMinMaxFrame.")]
132         [Property("SPEC", "Tizen.NUI.LottieAnimationView.GetMinMaxFrame M")]
133         [Property("SPEC_URL", "-")]
134         [Property("CRITERIA", "MR")]
135         [Property("AUTHOR", "guowei.wang@samsung.com")]
136         public void LottieAnimationViewGetMinMaxFrame()
137         {
138             tlog.Debug(tag, $"LottieAnimationViewGetMinMaxFrame START");
139
140             var testingTarget = new LottieAnimationView();
141             Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
142             Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
143
144             testingTarget.URL = lottieFilePath;
145
146             PropertyMap map = new PropertyMap();
147             map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
148                 .Add(ImageVisualProperty.URL, new PropertyValue(url))
149                 .Add(ImageVisualProperty.LoopCount, new PropertyValue(2))
150                 .Add(ImageVisualProperty.PlayRange, new PropertyValue(50));
151             testingTarget.Image = map;
152
153             string maker = "startframe: 1; endframe: 10";
154             testingTarget.SetMinMaxFrameByMarker(maker, null);
155
156             try
157             {
158                 testingTarget.GetMinMaxFrame();    
159             }
160             catch (Exception e)
161             {
162                 tlog.Debug(tag, e.Message.ToString());
163                 Assert.Fail("Caught Exception: Failed!");
164             }
165
166             tlog.Debug(tag, $"LottieAnimationViewGetMinMaxFrame END (OK)");
167         }
168
169         [Test]
170         [Category("P1")]
171         [Description("LottieAnimationView Finished.")]
172         [Property("SPEC", "Tizen.NUI.LottieAnimationView.Finished M")]
173         [Property("SPEC_URL", "-")]
174         [Property("CRITERIA", "MR")]
175         [Property("AUTHOR", "guowei.wang@samsung.com")]
176         public void LottieAnimationViewFinished()
177         {
178             tlog.Debug(tag, $"LottieAnimationViewFinished START");
179
180             var testingTarget = new LottieAnimationView();
181             Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
182             Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
183
184             testingTarget.URL = lottieFilePath;
185             NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(testingTarget);
186
187             testingTarget.Finished += OnFinishedEvent;
188             testingTarget.Finished -= OnFinishedEvent;
189
190             NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(testingTarget);
191
192             tlog.Debug(tag, $"LottieAnimationViewFinished END (OK)");
193         }
194
195         [Test]
196         [Category("P1")]
197         [Description("LottieAnimationView VisualEvent.")]
198         [Property("SPEC", "Tizen.NUI.LottieAnimationView.VisualEvent M")]
199         [Property("SPEC_URL", "-")]
200         [Property("CRITERIA", "MR")]
201         [Property("AUTHOR", "guowei.wang@samsung.com")]
202         public void LottieAnimationViewVisualEvent()
203         {
204             tlog.Debug(tag, $"LottieAnimationViewVisualEvent START");
205
206             var testingTarget = new LottieAnimationView();
207             Assert.IsNotNull(testingTarget, "Can't create success object LottieAnimationView");
208             Assert.IsInstanceOf<LottieAnimationView>(testingTarget, "Should be an instance of LottieAnimationView type.");
209
210             testingTarget.URL = lottieFilePath;
211             NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(testingTarget);
212
213             testingTarget.VisualEvent += OnVisualEvent;
214             testingTarget.VisualEvent -= OnVisualEvent;
215
216             NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(testingTarget);
217
218             tlog.Debug(tag, $"LottieAnimationViewVisualEvent END (OK)");
219         }
220
221         [Test]
222         [Category("P1")]
223         [Description("LottieFrameInfo constructor.")]
224         [Property("SPEC", "Tizen.NUI.LottieFrameInfo.LottieFrameInfo C")]
225         [Property("SPEC_URL", "-")]
226         [Property("CRITERIA", "CONSTR")]
227         [Property("AUTHOR", "guowei.wang@samsung.com")]
228         public void LottieFrameInfoConstructor()
229         {
230             tlog.Debug(tag, $"LottieFrameInfoConstructor START");
231
232             var testingTarget = new LottieFrameInfo(0, 10);
233             Assert.IsNotNull(testingTarget, "Can't create success object LottieFrameInfo");
234             Assert.IsInstanceOf<LottieFrameInfo>(testingTarget, "Should be an instance of LottieFrameInfo type.");
235
236             var result = testingTarget.StartFrame;
237             Assert.AreEqual(0, result, "should be equal!");
238
239             result = testingTarget.EndFrame;
240             Assert.AreEqual(10, result, "should be equal!");
241
242             tlog.Debug(tag, $"LottieFrameInfoConstructor END (OK)");
243         }
244
245         [Test]
246         [Category("P1")]
247         [Description("LottieFrameInfo constructor.")]
248         [Property("SPEC", "Tizen.NUI.LottieFrameInfo.LottieFrameInfo C")]
249         [Property("SPEC_URL", "-")]
250         [Property("CRITERIA", "CONSTR")]
251         [Property("AUTHOR", "guowei.wang@samsung.com")]
252         public void LottieFrameInfoConstructorWithStillImageFrame()
253         {
254             tlog.Debug(tag, $"LottieFrameInfoConstructorWithStillImageFrame START");
255
256             var testingTarget = new LottieFrameInfo(300);
257             Assert.IsNotNull(testingTarget, "Can't create success object LottieFrameInfo");
258             Assert.IsInstanceOf<LottieFrameInfo>(testingTarget, "Should be an instance of LottieFrameInfo type.");
259
260             var result = testingTarget.IsStillImage();
261             tlog.Debug(tag, "IsStillImage : " + result);
262
263             tlog.Debug(tag, $"LottieFrameInfoConstructorWithStillImageFrame END (OK)");
264         }
265
266         [Test]
267         [Category("P1")]
268         [Description("LottieFrameInfo constructor.")]
269         [Property("SPEC", "Tizen.NUI.LottieFrameInfo.LottieFrameInfo C")]
270         [Property("SPEC_URL", "-")]
271         [Property("CRITERIA", "CONSTR")]
272         [Property("AUTHOR", "guowei.wang@samsung.com")]
273         public void LottieFrameInfoConstructorWithPair()
274         {
275             tlog.Debug(tag, $"LottieFrameInfoConstructorWithPair START");
276
277             LottieFrameInfo testingTarget = (0, 10);
278             Assert.IsNotNull(testingTarget, "Can't create success object LottieFrameInfo");
279             Assert.IsInstanceOf<LottieFrameInfo>(testingTarget, "Should be an instance of LottieFrameInfo type.");
280
281             tlog.Debug(tag, $"LottieFrameInfoConstructorWithPair END (OK)");
282         }
283
284         [Test]
285         [Category("P1")]
286         [Description("LottieFrameInfo constructor.")]
287         [Property("SPEC", "Tizen.NUI.LottieFrameInfo.LottieFrameInfo C")]
288         [Property("SPEC_URL", "-")]
289         [Property("CRITERIA", "CONSTR")]
290         [Property("AUTHOR", "guowei.wang@samsung.com")]
291         public void LottieFrameInfoConstructorWithString()
292         {
293             tlog.Debug(tag, $"LottieFrameInfoConstructorWithString START");
294
295             LottieFrameInfo dummy1 = "0, 10";
296             Assert.IsNotNull(dummy1, "Can't create success object LottieFrameInfo");
297             Assert.IsInstanceOf<LottieFrameInfo>(dummy1, "Should be an instance of LottieFrameInfo type.");
298
299             // length == 1
300             LottieFrameInfo dummy2 = "10";
301             Assert.IsNotNull(dummy2, "Can't create success object LottieFrameInfo");
302             Assert.IsInstanceOf<LottieFrameInfo>(dummy2, "Should be an instance of LottieFrameInfo type.");
303
304             tlog.Debug(tag, $"LottieFrameInfoConstructorWithString END (OK)");
305         }
306
307         public void OnFinishedEvent(object sender, EventArgs e) { }
308
309         private void OnVisualEvent(object sender, LottieAnimationView.VisualEventSignalArgs e) { }
310     }
311 }