Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Common / TSAsyncImageLoader.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
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using tlog = Tizen.Log;
10
11     [TestFixture]
12     [Description("internal/Common/AsyncImageLoader")]
13     public class InternalAsyncImageLoaderTest
14     {
15         private const string tag = "NUITEST";
16         private string url = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
17         [SetUp]
18         public void Init()
19         {
20             tlog.Info(tag, "Init() is called!");
21         }
22
23         [TearDown]
24         public void Destroy()
25         {
26             tlog.Info(tag, "Destroy() is called!");
27         }
28
29         [Test]
30         [Category("P1")]
31         [Description("AsyncImageLoader constructor.")]
32         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.AsyncImageLoader C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void AsyncImageLoaderConstructor()
37         {
38             tlog.Debug(tag, $"AsyncImageLoaderConstructor START");
39
40             var testingTarget = new AsyncImageLoader();
41             Assert.IsNotNull(testingTarget, "Can't create success object AsyncImageLoader");
42             Assert.IsInstanceOf<AsyncImageLoader>(testingTarget, "Should be an instance of AsyncImageLoader type.");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"AsyncImageLoaderConstructor END (OK)");
46         }
47
48         [Test]
49         [Category("P1")]
50         [Description("AsyncImageLoader constructor. With AsyncImageLoader.")]
51         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.AsyncImageLoader C")]
52         [Property("SPEC_URL", "-")]
53         [Property("CRITERIA", "CONSTR")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         public void AsyncImageLoaderConstructorWithAsyncImageLoader()
56         {
57             tlog.Debug(tag, $"AsyncImageLoaderConstructorWithAsyncImageLoader START");
58
59             using (AsyncImageLoader loader = new AsyncImageLoader())
60             {
61                 var testingTarget = new AsyncImageLoader(loader);
62                 Assert.IsNotNull(testingTarget, "Can't create success object AsyncImageLoader");
63                 Assert.IsInstanceOf<AsyncImageLoader>(testingTarget, "Should be an instance of AsyncImageLoader type.");
64
65                 testingTarget.Dispose();
66             }
67
68             tlog.Debug(tag, $"AsyncImageLoaderConstructorWithAsyncImageLoader END (OK)");
69         }
70
71         [Test]
72         [Category("P1")]
73         [Description("AsyncImageLoader Assign.")]
74         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.Assign M")]
75         [Property("SPEC_URL", "-")]
76         [Property("CRITERIA", "MR")]
77         [Property("AUTHOR", "guowei.wang@samsung.com")]
78         public void AsyncImageLoaderAssign()
79         {
80             tlog.Debug(tag, $"AsyncImageLoaderAssign START");
81
82             using (AsyncImageLoader loader = new AsyncImageLoader())
83             {
84                 var testingTarget = new AsyncImageLoader(loader);
85                 Assert.IsNotNull(testingTarget, "Can't create success object AsyncImageLoader");
86                 Assert.IsInstanceOf<AsyncImageLoader>(testingTarget, "Should be an instance of AsyncImageLoader type.");
87
88                 try
89                 {
90                     testingTarget.Assign(loader);
91                 }
92                 catch (Exception e)
93                 {
94                     tlog.Debug(tag, e.Message.ToString());
95                     Assert.Fail("Caught Exception: Failed!");
96                 }
97
98                 testingTarget.Dispose();
99             }
100
101             tlog.Debug(tag, $"AsyncImageLoaderAssign END (OK)");
102         }
103
104         [Test]
105         [Category("P1")]
106         [Description("AsyncImageLoader DownCast.")]
107         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.DownCast M")]
108         [Property("SPEC_URL", "-")]
109         [Property("CRITERIA", "MR")]
110         [Property("AUTHOR", "guowei.wang@samsung.com")]
111         public void AsyncImageLoaderDownCast()
112         {
113             tlog.Debug(tag, $"AsyncImageLoaderDownCast START");
114
115             using (AsyncImageLoader loader = new AsyncImageLoader())
116             {
117                 try
118                 {
119                     AsyncImageLoader.DownCast(loader);
120                 }
121                 catch (Exception e)
122                 {
123                     tlog.Debug(tag, e.Message.ToString());
124                     Assert.Fail("Caught Exception: Failed!");
125                 }
126             }
127
128             tlog.Debug(tag, $"AsyncImageLoaderDownCast END (OK)");
129         }
130
131         [Test]
132         [Category("P1")]
133         [Description("AsyncImageLoader Load.")]
134         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.Load M")]
135         [Property("SPEC_URL", "-")]
136         [Property("CRITERIA", "MR")]
137         [Property("AUTHOR", "guowei.wang@samsung.com")]
138         public void AsyncImageLoaderLoad()
139         {
140             tlog.Debug(tag, $"AsyncImageLoaderLoad START");
141
142             using (AsyncImageLoader loader = new AsyncImageLoader())
143             {
144                 try
145                 {
146                     loader.Load(url);
147                 }
148                 catch (Exception e)
149                 {
150                     tlog.Debug(tag, e.Message.ToString());
151                     Assert.Fail("Caught Exception: Failed!");
152                 }
153             }
154
155             tlog.Debug(tag, $"AsyncImageLoaderLoad END (OK)");
156         }
157
158         [Test]
159         [Category("P1")]
160         [Description("AsyncImageLoader Load. With dimensions.")]
161         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.Load M")]
162         [Property("SPEC_URL", "-")]
163         [Property("CRITERIA", "MR")]
164         [Property("AUTHOR", "guowei.wang@samsung.com")]
165         public void AsyncImageLoaderLoadWithDimensions()
166         {
167             tlog.Debug(tag, $"AsyncImageLoaderLoadWithDimensions START");
168
169             using (AsyncImageLoader loader = new AsyncImageLoader())
170             {
171                 try
172                 {
173                     loader.Load(url, new Uint16Pair(100, 80));
174                 }
175                 catch (Exception e)
176                 {
177                     tlog.Debug(tag, e.Message.ToString());
178                     Assert.Fail("Caught Exception: Failed!");
179                 }
180             }
181
182             tlog.Debug(tag, $"AsyncImageLoaderLoadWithDimensions END (OK)");
183         }
184
185         [Test]
186         [Category("P1")]
187         [Description("AsyncImageLoader Load. With fittingMode.")]
188         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.Load M")]
189         [Property("SPEC_URL", "-")]
190         [Property("CRITERIA", "MR")]
191         [Property("AUTHOR", "guowei.wang@samsung.com")]
192         public void AsyncImageLoaderLoadWithFittingMode()
193         {
194             tlog.Debug(tag, $"AsyncImageLoaderLoadWithFittingMode START");
195
196             using (AsyncImageLoader loader = new AsyncImageLoader())
197             {
198                 try
199                 {
200                     loader.Load(url, new Uint16Pair(100, 80), FittingModeType.Center, SamplingModeType.Linear, false);
201                 }
202                 catch (Exception e)
203                 {
204                     tlog.Debug(tag, e.Message.ToString());
205                     Assert.Fail("Caught Exception: Failed!");
206                 }
207             }
208
209             tlog.Debug(tag, $"AsyncImageLoaderLoadWithFittingMode END (OK)");
210         }
211
212         [Test]
213         [Category("P1")]
214         [Description("AsyncImageLoader Cancel.")]
215         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.Cancel M")]
216         [Property("SPEC_URL", "-")]
217         [Property("CRITERIA", "MR")]
218         [Property("AUTHOR", "guowei.wang@samsung.com")]
219         public void AsyncImageLoaderCancel()
220         {
221             tlog.Debug(tag, $"AsyncImageLoaderCancel START");
222
223             using (AsyncImageLoader loader = new AsyncImageLoader())
224             {
225                 try
226                 {
227                     loader.Load(url, new Uint16Pair(100, 80), FittingModeType.Center, SamplingModeType.Linear, false);
228                     loader.Cancel(0);
229                 }
230                 catch (Exception e)
231                 {
232                     tlog.Debug(tag, e.Message.ToString());
233                     Assert.Fail("Caught Exception: Failed!");
234                 }
235             }
236
237             tlog.Debug(tag, $"AsyncImageLoaderCancel END (OK)");
238         }
239
240         [Test]
241         [Category("P1")]
242         [Description("AsyncImageLoader CancelAll.")]
243         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.CancelAll M")]
244         [Property("SPEC_URL", "-")]
245         [Property("CRITERIA", "MR")]
246         [Property("AUTHOR", "guowei.wang@samsung.com")]
247         public void AsyncImageLoaderCancelAll()
248         {
249             tlog.Debug(tag, $"AsyncImageLoaderCancelAll START");
250
251             using (AsyncImageLoader loader = new AsyncImageLoader())
252             {
253                 try
254                 {
255                     loader.Load(url, new Uint16Pair(100, 80), FittingModeType.Center, SamplingModeType.Linear, false);
256                     loader.CancelAll();
257                 }
258                 catch (Exception e)
259                 {
260                     tlog.Debug(tag, e.Message.ToString());
261                     Assert.Fail("Caught Exception: Failed!");
262                 }
263             }
264
265             tlog.Debug(tag, $"AsyncImageLoaderCancelAll END (OK)");
266         }
267
268         [Test]
269         [Category("P1")]
270         [Description("AsyncImageLoader ImageLoadedSignal.")]
271         [Property("SPEC", "Tizen.NUI.AsyncImageLoader.ImageLoadedSignal M")]
272         [Property("SPEC_URL", "-")]
273         [Property("CRITERIA", "MR")]
274         [Property("AUTHOR", "guowei.wang@samsung.com")]
275         public void AsyncImageLoaderImageLoadedSignal()
276         {
277             tlog.Debug(tag, $"AsyncImageLoaderImageLoadedSignal START");
278
279             using (AsyncImageLoader loader = new AsyncImageLoader())
280             {
281                 try
282                 {
283                     loader.ImageLoadedSignal();
284                 }
285                 catch (Exception e)
286                 {
287                     tlog.Debug(tag, e.Message.ToString());
288                     Assert.Fail("Caught Exception: Failed!");
289                 }
290             }
291
292             tlog.Debug(tag, $"AsyncImageLoaderImageLoadedSignal END (OK)");
293         }
294     }
295 }