3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
7 namespace Tizen.NUI.Devel.Tests
9 using tlog = Tizen.Log;
12 [Description("public/BaseComponents/ImageView")]
13 public class InternalImageViewTest
15 private const string tag = "NUITEST";
16 private string image_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "Image.png";
17 private string mask_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "star-mod.png";
22 tlog.Info(tag, "Init() is called!");
28 tlog.Info(tag, "Destroy() is called!");
33 [Description("internal API test in Ubuntu, ImageView.ResourceUrl")]
34 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.ResourceUrl")]
35 [Property("SPEC_URL", "-")]
36 [Property("CRITERIA", "PRO")]
37 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
38 public void ResourceUrl_SET_GET_VALUE()
41 ImageView testView = new ImageView();
42 string testUrl1 = "test1";
43 testView.ResourceUrl = testUrl1;
45 Assert.AreEqual(testView.ResourceUrl, testUrl1, "ResourceUrl is not equal");
52 [Description("internal API test in Ubuntu, ImageView.AlphaMaskURL")]
53 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.AlphaMaskURL")]
54 [Property("SPEC_URL", "-")]
55 [Property("CRITERIA", "PRO")]
56 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
57 public void AlphaMaskURL_SET_GET_VALUE()
60 ImageView testView = new ImageView(image_path);
61 string testUrl1 = "test1";
62 testView.AlphaMaskURL = testUrl1;
64 Assert.AreEqual(testView.AlphaMaskURL, testUrl1, "AlphaMaskURL is not equal");
71 [Description("internal API test in Ubuntu, ImageView.CropToMask")]
72 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.CropToMask")]
73 [Property("SPEC_URL", "-")]
74 [Property("CRITERIA", "PRO")]
75 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
76 public void CropToMask_SET_GET_VALUE()
79 ImageView testView = new ImageView(image_path);
81 Assert.AreEqual(testView.CropToMask, false, "CropToMask default is false when we don't set mask image url");
83 testView.CropToMask = true;
85 Assert.AreEqual(testView.CropToMask, true, "CropToMask is not updated");
87 testView.CropToMask = false;
89 Assert.AreEqual(testView.CropToMask, false, "CropToMask is not updated");
91 testView.AlphaMaskURL = mask_path;
93 Assert.AreEqual(testView.CropToMask, false, "CropToMask should not changed even we set mask image url");
100 [Description("internal API test in Ubuntu, ImageView.PreMultipliedAlpha")]
101 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.PreMultipliedAlpha")]
102 [Property("SPEC_URL", "-")]
103 [Property("CRITERIA", "PRO")]
104 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
105 public void PreMultipliedAlpha_SET_GET_VALUE()
108 ImageView testView = new ImageView(image_path);
110 testView.PreMultipliedAlpha = true;
112 Assert.AreEqual(testView.PreMultipliedAlpha, true, "PreMultipliedAlpha is not updated");
114 testView.PreMultipliedAlpha = false;
116 Assert.AreEqual(testView.PreMultipliedAlpha, false, "PreMultipliedAlpha is not updated");
123 [Description("internal API test in Ubuntu, ImageView.CropToMask with AlphaMaskURL")]
124 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.CropToMask")]
125 [Property("SPEC_URL", "-")]
126 [Property("CRITERIA", "PRO")]
127 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
128 public void CropToMask_DEFAULT_GET_VALUE()
131 ImageView testView = new ImageView(image_path);
133 Assert.AreEqual(testView.CropToMask, false, "CropToMask default is false when we don't set mask image url");
135 testView.AlphaMaskURL = image_path;
137 Assert.AreEqual(testView.CropToMask, true, "CropToMask default is true when we set mask image url");
144 [Description("internal API test in Ubuntu, ImageView.NaturalSize2D")]
145 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.NaturalSize2D")]
146 [Property("SPEC_URL", "-")]
147 [Property("CRITERIA", "PRO")]
148 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
149 public void NaturalSize2D_GET_VALUE()
152 ImageView testView = new ImageView();
153 testView.ResourceUrl = image_path;
154 Size2D result = new Size2D(212, 150); // The size of image_path image.
155 Size2D size = testView.NaturalSize2D;
157 Assert.AreEqual(result.Width, size.Width, "NaturalSize Width is not equal");
158 Assert.AreEqual(result.Height, size.Height, "NaturalSize Height is not equal");
166 [Description("internal API test in Ubuntu, ImageView.NaturalSize")]
167 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.NaturalSize")]
168 [Property("SPEC_URL", "-")]
169 [Property("CRITERIA", "PRO")]
170 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
171 public void NaturalSize_GET_VALUE()
174 ImageView testView = new ImageView();
175 testView.ResourceUrl = image_path;
176 Vector3 result = new Vector3(212, 150, 0); // The size of image_path image.
177 Vector3 size = testView.NaturalSize;
179 Assert.AreEqual(result.X, size.X, "NaturalSize Width is not equal");
180 Assert.AreEqual(result.Y, size.Y, "NaturalSize Height is not equal");
187 [Description("internal API test in Ubuntu, ImageView.NaturalSize")]
188 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.NaturalSize")]
189 [Property("SPEC_URL", "-")]
190 [Property("CRITERIA", "PRO")]
191 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
192 public void NaturalSize_GET_VALUE_as_View_class()
195 ImageView testView = new ImageView();
196 testView.ResourceUrl = image_path;
197 Vector3 result = new Vector3(212, 150, 0); // The size of image_path image.
198 View testView2 = testView; // Convert class as View.
199 Vector3 size = testView2.NaturalSize; // Check whether virtual ImageView.GetNaturalSize() called well.
201 Assert.AreEqual(result.X, size.X, "NaturalSize Width is not equal");
202 Assert.AreEqual(result.Y, size.Y, "NaturalSize Height is not equal");
210 [Description("internal API test in Ubuntu, ImageView.Image with ResourceUrl")]
211 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.Image")]
212 [Property("SPEC_URL", "-")]
213 [Property("CRITERIA", "PRO")]
214 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
215 public void Image_GET_VALUE_After_Set_ResourceUrl()
218 ImageView testView = new ImageView();
219 string resultUrl1 = "";
221 PropertyMap map1 = testView.Image;
223 bool ret1 = (map1.Find(ImageVisualProperty.URL)?.Get(out resultUrl1) ?? false) && string.IsNullOrEmpty(resultUrl1);
225 Assert.AreEqual(false, ret1, "map don't have ResourceUrl");
227 string testUrl1 = "test1";
228 testView.ResourceUrl = testUrl1;
230 PropertyMap map2 = testView.Image;
232 bool ret2 = (map2.Find(ImageVisualProperty.URL)?.Get(out resultUrl1) ?? false) && !string.IsNullOrEmpty(resultUrl1);
234 Assert.AreEqual(true, ret2, "map must have ResourceUrl");
235 Assert.AreEqual(testUrl1, resultUrl1, "...and That value must be equal what we added");
242 [Description("internal API test in Ubuntu, ImageView.Image with something")]
243 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.Image")]
244 [Property("SPEC_URL", "-")]
245 [Property("CRITERIA", "PRO")]
246 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
247 public void Image_GET_VALUE_After_Set_something()
250 ImageView testView = new ImageView();
251 string resultString = "";
252 bool resultBool = false;
254 using(PropertyMap map = testView.Image)
256 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && string.IsNullOrEmpty(resultString);
257 Assert.AreEqual(false, ret, "map don't have ResourceUrl");
258 ret = map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false;
259 Assert.AreEqual(false, ret, "map don't have AlphaMaskURL");
260 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
261 Assert.AreEqual(false, ret, "map don't have CropToMask");
262 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
263 Assert.AreEqual(false, ret, "map don't have SynchronousLoading");
266 string testUrl1 = "test1";
267 testView.AlphaMaskURL = testUrl1;
268 testView.CropToMask = true;
269 testView.SynchronousLoading = true;
271 using(PropertyMap map = testView.Image)
273 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && string.IsNullOrEmpty(resultString);
274 Assert.AreEqual(false, ret, "map don't have ResourceUrl");
275 ret = (map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false) && string.IsNullOrEmpty(resultString);
276 Assert.AreEqual(false, ret, "map don't have AlphaMaskURL cause ResoureUrl is empty");
277 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
278 Assert.AreEqual(false, ret, "map don't have CropToMask cause ResoureUrl is empty");
279 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
280 Assert.AreEqual(false, ret, "map don't have SynchronousLoading cause ResoureUrl is empty");
283 testView.ResourceUrl = image_path;
285 using(PropertyMap map = testView.Image)
287 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
288 Assert.AreEqual(true, ret, "map must have ResourceUrl");
289 Assert.AreEqual(image_path, resultString, "...and That value must be equal what we added");
290 ret = (map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
291 Assert.AreEqual(true, ret, "map must have AlphaMaskURL");
292 Assert.AreEqual(testUrl1, resultString, "...and That value must be equal what we added");
293 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
294 Assert.AreEqual(true, ret, "map must have CropToMask");
295 Assert.AreEqual(true, resultBool, "...and That value must be equal what we added");
296 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
297 Assert.AreEqual(true, ret, "map must have SynchronousLoading");
298 Assert.AreEqual(true, resultBool, "...and That value must be equal what we added");
301 // Insert empty resource Url
302 testView.ResourceUrl = "";
304 using(PropertyMap map = testView.Image)
306 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && string.IsNullOrEmpty(resultString);
307 Assert.AreEqual(false, ret, "map don't have ResourceUrl");
308 ret = (map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false) && string.IsNullOrEmpty(resultString);
309 Assert.AreEqual(false, ret, "map don't have AlphaMaskURL cause ResoureUrl is empty");
310 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
311 Assert.AreEqual(false, ret, "map don't have CropToMask cause ResoureUrl is empty");
312 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
313 Assert.AreEqual(false, ret, "map don't have SynchronousLoading cause ResoureUrl is empty");
316 // Insert valid resource Url
317 testView.ResourceUrl = mask_path;
319 using(PropertyMap map = testView.Image)
321 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
322 Assert.AreEqual(true, ret, "map must have ResourceUrl");
323 Assert.AreEqual(mask_path, resultString, "...and That value must be equal what we added");
324 ret = (map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
325 Assert.AreEqual(true, ret, "map must have AlphaMaskURL");
326 Assert.AreEqual(testUrl1, resultString, "...and That value must be equal what we added");
327 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
328 Assert.AreEqual(true, ret, "map must have CropToMask");
329 Assert.AreEqual(true, resultBool, "...and That value must be equal what we added");
330 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
331 Assert.AreEqual(true, ret, "map must have SynchronousLoading");
332 Assert.AreEqual(true, resultBool, "...and That value must be equal what we added");
340 [Description("internal API test in Ubuntu, set ImageView.Image and check cached properties changed")]
341 [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.Image")]
342 [Property("SPEC_URL", "-")]
343 [Property("CRITERIA", "PRO")]
344 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
345 public void Image_SET_VALUE_After_Set_something()
348 ImageView testView = new ImageView();
349 string resultString = "";
350 bool resultBool = false;
352 using(PropertyMap map = testView.Image)
354 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && string.IsNullOrEmpty(resultString);
355 Assert.AreEqual(false, ret, "map don't have ResourceUrl");
356 ret = map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false;
357 Assert.AreEqual(false, ret, "map don't have AlphaMaskURL");
358 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
359 Assert.AreEqual(false, ret, "map don't have CropToMask");
360 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
361 Assert.AreEqual(false, ret, "map don't have SynchronousLoading");
364 string testUrl1 = "test1";
365 string testUrl2 = "test2";
366 testView.ResourceUrl = testUrl1;
367 testView.AlphaMaskURL = testUrl2;
368 testView.CropToMask = true;
369 testView.SynchronousLoading = true;
371 using(PropertyMap map = testView.Image)
373 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
374 Assert.AreEqual(true, ret, "map must have ResourceUrl");
375 Assert.AreEqual(testUrl1, resultString, "...and That value must be equal what we added");
376 ret = (map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
377 Assert.AreEqual(true, ret, "map must have AlphaMaskURL");
378 Assert.AreEqual(testUrl2, resultString, "...and That value must be equal what we added");
379 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
380 Assert.AreEqual(true, ret, "map must have CropToMask");
381 Assert.AreEqual(true, resultBool, "...and That value must be equal what we added");
382 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
383 Assert.AreEqual(true, ret, "map must have SynchronousLoading");
384 Assert.AreEqual(true, resultBool, "...and That value must be equal what we added");
387 // Update Image map by PropertyMap.
388 // Cached property map will be overwrited.
389 using(PropertyMap setImageMap = new PropertyMap())
391 setImageMap[ImageVisualProperty.URL] = new PropertyValue(image_path);
392 setImageMap[ImageVisualProperty.AlphaMaskURL] = new PropertyValue(mask_path);
393 setImageMap[ImageVisualProperty.CropToMask] = new PropertyValue(false);
394 setImageMap[ImageVisualProperty.SynchronousLoading] = new PropertyValue(false);
395 testView.Image = setImageMap;
398 using(PropertyMap map = testView.Image)
400 bool ret = (map.Find(ImageVisualProperty.URL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
401 Assert.AreEqual(true, ret, "map must have ResourceUrl");
402 Assert.AreEqual(image_path, resultString, "...and That value must be equal what we added");
403 ret = (map.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out resultString) ?? false) && !string.IsNullOrEmpty(resultString);
404 Assert.AreEqual(true, ret, "map must have AlphaMaskURL");
405 Assert.AreEqual(mask_path, resultString, "...and That value must be equal what we added");
406 ret = map.Find(ImageVisualProperty.CropToMask)?.Get(out resultBool) ?? false;
407 Assert.AreEqual(true, ret, "map must have CropToMask");
408 Assert.AreEqual(false, resultBool, "...and That value must be equal what we added");
409 ret = map.Find(ImageVisualProperty.SynchronousLoading)?.Get(out resultBool) ?? false;
410 Assert.AreEqual(true, ret, "map must have SynchronousLoading");
411 Assert.AreEqual(false, resultBool, "...and That value must be equal what we added");
417 [Description("internal API test in Ubuntu, Container.DisposeRecursively")]
418 [Property("SPEC", "Tizen.NUI.Common.Container.DisposeRecursively M")]
419 [Property("SPEC_URL", "-")]
420 [Property("CRITERIA", "MR")]
421 [Property("AUTHOR", "eunkiki.hong@samsung.com")]
422 public void DisposeRecursively_VALUE()
425 View testParent = new View();
426 View testChildL0 = new View();
427 View testChildL1 = new View();
429 testParent.Add(testChildL0);
430 testChildL0.Add(testChildL1);
432 Assert.AreEqual(false, testParent.Disposed, "View should not disposed yet.");
433 Assert.AreEqual(false, testChildL0.Disposed, "View should not disposed yet.");
434 Assert.AreEqual(false, testChildL1.Disposed, "View should not disposed yet.");
436 testParent.DisposeRecursively();
438 Assert.AreEqual(true, testParent.Disposed, "View should be disposed now.");
439 Assert.AreEqual(true, testChildL0.Disposed, "View should be disposed now.");
440 Assert.AreEqual(true, testChildL1.Disposed, "View should be disposed now.");