[NUI] Make PrimaryCursorPosition property public
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / BaseComponents / TSAnimatedImageView.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/AnimatedImageView")]
14     public class PublicAnimatedImageViewTest
15     {
16         private const string tag = "NUITEST";
17         private string url = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
18
19         internal class MyAnimatedImageView : AnimatedImageView
20         {
21             public MyAnimatedImageView()
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("AnimatedImageView constructor.")]
45         [Property("SPEC", "Tizen.NUI.AnimatedImageView.AnimatedImageView C")]
46         [Property("SPEC_URL", "-")]
47         [Property("CRITERIA", "CONSTR")]
48         [Property("AUTHOR", "guowei.wang@samsung.com")]
49         public void AnimatedImageViewConstructor()
50         {
51             tlog.Debug(tag, $"AnimatedImageViewConstructor START");
52
53             var testingTarget = new AnimatedImageView();
54             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
55             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
56
57             testingTarget.Dispose();
58             tlog.Debug(tag, $"AnimatedImageViewConstructor END (OK)");
59         }
60
61         [Test]
62         [Category("P1")]
63         [Description("AnimatedImageView Dispose.")]
64         [Property("SPEC", "Tizen.NUI.AnimatedImageView.Dispose M")]
65         [Property("SPEC_URL", "-")]
66         [Property("CRITERIA", "MR")]
67         [Property("AUTHOR", "guowei.wang@samsung.com")]
68         public void AnimatedImageViewDispose()
69         {
70             tlog.Debug(tag, $"AnimatedImageViewDispose START");
71
72             var testingTarget = new MyAnimatedImageView();
73             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
74             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
75
76             try
77             {
78                 testingTarget.OnDispose(DisposeTypes.Explicit);
79             }
80             catch (Exception e)
81             {
82                 tlog.Debug(tag, e.Message.ToString());
83                 Assert.Fail("Caught Exception: Failed!");
84             }
85            
86             tlog.Debug(tag, $"AnimatedImageViewDispose END (OK)");
87         }
88
89         [Test]
90         [Category("P1")]
91         [Description("AnimatedImageView ResourceUrl.")]
92         [Property("SPEC", "Tizen.NUI.AnimatedImageView.ResourceUrl A")]
93         [Property("SPEC_URL", "-")]
94         [Property("CRITERIA", "PRW")]
95         [Property("AUTHOR", "guowei.wang@samsung.com")]
96         public void AnimatedImageViewResourceUrl()
97         {
98             tlog.Debug(tag, $"AnimatedImageViewResourceUrl START");
99
100             var testingTarget = new AnimatedImageView();
101             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
102             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
103
104             testingTarget.ResourceUrl = url;
105             Assert.AreEqual(url, testingTarget.ResourceUrl, "Should be equal");
106
107             testingTarget.Dispose();
108             tlog.Debug(tag, $"AnimatedImageViewResourceUrl END (OK)");
109         }
110
111         [Test]
112         [Category("P1")]
113         [Description("AnimatedImageView URLs.")]
114         [Property("SPEC", "Tizen.NUI.AnimatedImageView.URLs A")]
115         [Property("SPEC_URL", "-")]
116         [Property("CRITERIA", "PRO")]
117         [Property("AUTHOR", "guowei.wang@samsung.com")]
118         public void AnimatedImageViewURLs()
119         {
120             tlog.Debug(tag, $"AnimatedImageViewURLs START");
121
122             var testingTarget = new AnimatedImageView();
123             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
124             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
125
126             Assert.IsNotNull(testingTarget.URLs);
127
128             testingTarget.Dispose();
129             tlog.Debug(tag, $"AnimatedImageViewURLs END (OK)");
130         }
131
132         [Test]
133         [Category("P1")]
134         [Description("AnimatedImageView BatchSize.")]
135         [Property("SPEC", "Tizen.NUI.AnimatedImageView.BatchSize A")]
136         [Property("SPEC_URL", "-")]
137         [Property("CRITERIA", "PRW")]
138         [Property("AUTHOR", "guowei.wang@samsung.com")]
139         public void AnimatedImageViewBatchSize()
140         {
141             tlog.Debug(tag, $"AnimatedImageViewBatchSize START");
142
143             var testingTarget = new AnimatedImageView();
144             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
145             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
146
147             Assert.AreEqual(1, testingTarget.BatchSize, "Should be equal!");
148
149             testingTarget.BatchSize = 2;
150             Assert.AreEqual(2, testingTarget.BatchSize, "Should be equal!");
151
152             testingTarget.Dispose();
153             tlog.Debug(tag, $"AnimatedImageViewBatchSize END (OK)");
154         }
155
156         [Test]
157         [Category("P1")]
158         [Description("AnimatedImageView CacheSize.")]
159         [Property("SPEC", "Tizen.NUI.AnimatedImageView.CacheSize A")]
160         [Property("SPEC_URL", "-")]
161         [Property("CRITERIA", "PRW")]
162         [Property("AUTHOR", "guowei.wang@samsung.com")]
163         public void AnimatedImageViewCacheSize()
164         {
165             tlog.Debug(tag, $"AnimatedImageViewCacheSize START");
166
167             var testingTarget = new AnimatedImageView();
168             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
169             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
170
171             Assert.AreEqual(1, testingTarget.CacheSize, "Should be equal!");
172
173             testingTarget.CacheSize = 2;
174             Assert.AreEqual(2, testingTarget.CacheSize, "Should be equal!");
175
176             testingTarget.Dispose();
177             tlog.Debug(tag, $"AnimatedImageViewCacheSize END (OK)");
178         }
179
180         [Test]
181         [Category("P1")]
182         [Description("AnimatedImageView FrameDelay.")]
183         [Property("SPEC", "Tizen.NUI.AnimatedImageView.FrameDelay A")]
184         [Property("SPEC_URL", "-")]
185         [Property("CRITERIA", "PRW")]
186         [Property("AUTHOR", "guowei.wang@samsung.com")]
187         public void AnimatedImageViewFrameDelay()
188         {
189             tlog.Debug(tag, $"AnimatedImageViewFrameDelay START");
190
191             var testingTarget = new AnimatedImageView();
192             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
193             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
194
195             testingTarget.FrameDelay = 300;
196             Assert.AreEqual(300, testingTarget.FrameDelay, "Should be equal!");
197
198             testingTarget.Dispose();
199             tlog.Debug(tag, $"AnimatedImageViewFrameDelay END (OK)");
200         }
201
202         [Test]
203         [Category("P1")]
204         [Description("AnimatedImageView LoopCount.")]
205         [Property("SPEC", "Tizen.NUI.AnimatedImageView.LoopCount A")]
206         [Property("SPEC_URL", "-")]
207         [Property("CRITERIA", "PRW")]
208         [Property("AUTHOR", "guowei.wang@samsung.com")]
209         public void AnimatedImageViewLoopCount()
210         {
211             tlog.Debug(tag, $"AnimatedImageViewLoopCount START");
212
213             var testingTarget = new AnimatedImageView();
214             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
215             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
216
217             testingTarget.LoopCount = 3;
218             Assert.AreEqual(3, testingTarget.LoopCount, "Should be equal!");
219
220             testingTarget.Dispose();
221             tlog.Debug(tag, $"AnimatedImageViewLoopCount END (OK)");
222         }
223
224         [Test]
225         [Category("P1")]
226         [Description("AnimatedImageView StopBehavior.")]
227         [Property("SPEC", "Tizen.NUI.AnimatedImageView.StopBehavior A")]
228         [Property("SPEC_URL", "-")]
229         [Property("CRITERIA", "PRW")]
230         [Property("AUTHOR", "guowei.wang@samsung.com")]
231         public void AnimatedImageViewStopBehavior()
232         {
233             tlog.Debug(tag, $"AnimatedImageViewStopBehavior START");
234
235             var testingTarget = new AnimatedImageView();
236             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
237             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
238
239             testingTarget.StopBehavior = AnimatedImageView.StopBehaviorType.MinimumFrame;
240             Assert.AreEqual(AnimatedImageView.StopBehaviorType.MinimumFrame, testingTarget.StopBehavior, "Should be equal!");
241
242             testingTarget.Dispose();
243             tlog.Debug(tag, $"AnimatedImageViewStopBehavior END (OK)");
244         }
245
246         [Test]
247         [Category("P1")]
248         [Description("AnimatedImageView TotalFrame.")]
249         [Property("SPEC", "Tizen.NUI.AnimatedImageView.TotalFrame A")]
250         [Property("SPEC_URL", "-")]
251         [Property("CRITERIA", "PR")]
252         [Property("AUTHOR", "guowei.wang@samsung.com")]
253         public void AnimatedImageViewTotalFrame()
254         {
255             tlog.Debug(tag, $"AnimatedImageViewTotalFrame START");
256
257             var testingTarget = new AnimatedImageView();
258             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
259             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
260
261             using (PropertyMap map = new PropertyMap())
262             {
263                 map.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
264                 map.Insert(ImageVisualProperty.URL, new PropertyValue(url));
265                 map.Insert(ImageVisualProperty.Border, new PropertyValue(new Extents(4, 4, 4, 4)));
266                 map.Insert(ImageVisualProperty.TotalFrameNumber, new PropertyValue(ImageVisualProperty.TotalFrameNumber));
267
268                 testingTarget.Image = map;
269
270                 try
271                 {
272                     var resutl = testingTarget.TotalFrame;
273                 }
274                 catch (Exception e)
275                 {
276                     tlog.Debug(tag, e.Message.ToString());
277                     Assert.Fail("Caught Exception: Failed!");
278                 }
279             }
280
281             testingTarget.Dispose();
282             tlog.Debug(tag, $"AnimatedImageViewTotalFrame END (OK)");
283         }
284
285         [Test]
286         [Category("P1")]
287         [Description("AnimatedImageView CurrentFrame.")]
288         [Property("SPEC", "Tizen.NUI.AnimatedImageView.CurrentFrame A")]
289         [Property("SPEC_URL", "-")]
290         [Property("CRITERIA", "PRW")]
291         [Property("AUTHOR", "guowei.wang@samsung.com")]
292         public void AnimatedImageViewCurrentFrame()
293         {
294             tlog.Debug(tag, $"AnimatedImageViewCurrentFrame START");
295
296             var testingTarget = new AnimatedImageView();
297             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
298             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
299
300             using (PropertyMap map = new PropertyMap())
301             {
302                 map.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
303                 map.Insert(ImageVisualProperty.URL, new PropertyValue(url));
304                 map.Insert(ImageVisualProperty.Border, new PropertyValue(new Extents(4, 4, 4, 4)));
305                 map.Insert(ImageVisualProperty.TotalFrameNumber, new PropertyValue(30));
306                 map.Insert(ImageVisualProperty.CurrentFrameNumber, new PropertyValue(0));
307
308                 testingTarget.Image = map;
309
310                 try
311                 {
312                     testingTarget.CurrentFrame = 15;
313                     var resutl = testingTarget.CurrentFrame;
314                 }
315                 catch (Exception e)
316                 {
317                     tlog.Debug(tag, e.Message.ToString());
318                     Assert.Fail("Caught Exception: Failed!");
319                 }
320             }
321
322             testingTarget.Dispose();
323             tlog.Debug(tag, $"AnimatedImageViewCurrentFrame END (OK)");
324         }
325
326         [Test]
327         [Category("P1")]
328         [Description("AnimatedImageView Play.")]
329         [Property("SPEC", "Tizen.NUI.AnimatedImageView.Play M")]
330         [Property("SPEC_URL", "-")]
331         [Property("CRITERIA", "MR")]
332         [Property("AUTHOR", "guowei.wang@samsung.com")]
333         public void AnimatedImageViewPlay()
334         {
335             tlog.Debug(tag, $"AnimatedImageViewPlay START");
336
337             var testingTarget = new AnimatedImageView();
338             Assert.IsNotNull(testingTarget, "Can't create success object AnimatedImageView");
339             Assert.IsInstanceOf<AnimatedImageView>(testingTarget, "Should be an instance of AnimatedImageView type.");
340
341             using (PropertyMap map = new PropertyMap())
342             {
343                 map.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
344                 map.Insert(ImageVisualProperty.URL, new PropertyValue(url));
345                 map.Insert(ImageVisualProperty.AlphaMaskURL, new PropertyValue(url));
346                 map.Insert(ImageVisualProperty.AuxiliaryImageURL, new PropertyValue(url));
347                 map.Insert(ImageVisualProperty.Border, new PropertyValue(new Extents(4, 4, 4, 4)));
348                 map.Insert(ImageVisualProperty.TotalFrameNumber, new PropertyValue(30));
349                 map.Insert(ImageVisualProperty.CurrentFrameNumber, new PropertyValue(0));
350
351                 testingTarget.Image = map;
352
353                 testingTarget.BatchSize = 2;
354                 testingTarget.CacheSize = 2;
355                 testingTarget.LoopCount = 3;
356                 testingTarget.StopBehavior = AnimatedImageView.StopBehaviorType.MinimumFrame;
357
358                 try
359                 {
360                     testingTarget.Play();
361                 }
362                 catch (Exception e)
363                 {
364                     testingTarget.Dispose();
365                     tlog.Debug(tag, e.Message.ToString());
366                     tlog.Debug(tag, $"AnimatedImageViewPlay END (OK)");
367                     Assert.Pass("Passed!");
368                 }
369             }
370             testingTarget?.Dispose();
371             tlog.Debug(tag, $"AnimatedImageViewPlay END (OK)");
372         }
373     }
374 }