[NUI] Fix unmatched return values before LazyUpdate (#3937)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / Tizen.NUI.Devel.Tests / testcase / TSImageView.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("public/BaseComponents/ImageView")]
13     public class InternalImageViewTest
14     {
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";
18
19         [SetUp]
20         public void Init()
21         {
22             tlog.Info(tag, "Init() is called!");
23         }
24
25         [TearDown]
26         public void Destroy()
27         {
28             tlog.Info(tag, "Destroy() is called!");
29         }
30
31         [Test]
32         [Category("P1")]
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()
39         {
40             /* TEST CODE */
41             ImageView testView = new ImageView();
42             string testUrl1 = "test1";
43             testView.ResourceUrl = testUrl1;
44
45             Assert.AreEqual(testView.ResourceUrl, testUrl1, "ResourceUrl is not equal");
46
47             testView.Dispose();
48         }
49
50         [Test]
51         [Category("P1")]
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()
58         {
59             /* TEST CODE */
60             ImageView testView = new ImageView(image_path);
61             string testUrl1 = "test1";
62             testView.AlphaMaskURL = testUrl1;
63
64             Assert.AreEqual(testView.AlphaMaskURL, testUrl1, "AlphaMaskURL is not equal");
65
66             testView.Dispose();
67         }
68
69         [Test]
70         [Category("P1")]
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()
77         {
78             /* TEST CODE */
79             ImageView testView = new ImageView(image_path);
80
81             Assert.AreEqual(testView.CropToMask, false, "CropToMask default is false when we don't set mask image url");
82
83             testView.CropToMask = true;
84
85             Assert.AreEqual(testView.CropToMask, true, "CropToMask is not updated");
86
87             testView.CropToMask = false;
88
89             Assert.AreEqual(testView.CropToMask, false, "CropToMask is not updated");
90
91             testView.AlphaMaskURL = mask_path;
92
93             Assert.AreEqual(testView.CropToMask, false, "CropToMask should not changed even we set mask image url");
94
95             testView.Dispose();
96         }
97
98         [Test]
99         [Category("P1")]
100         [Description("internal API test in Ubuntu, ImageView.CropToMask with AlphaMaskURL")]
101         [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.CropToMask")]
102         [Property("SPEC_URL", "-")]
103         [Property("CRITERIA", "PRO")]
104         [Property("AUTHOR", "eunkiki.hong@samsung.com")]
105         public void CropToMask_DEFAULT_GET_VALUE()
106         {
107             /* TEST CODE */
108             ImageView testView = new ImageView(image_path);
109
110             Assert.AreEqual(testView.CropToMask, false, "CropToMask default is false when we don't set mask image url");
111
112             testView.AlphaMaskURL = image_path;
113
114             Assert.AreEqual(testView.CropToMask, true, "CropToMask default is true when we set mask image url");
115
116             testView.Dispose();
117         }
118
119         [Test]
120         [Category("P1")]
121         [Description("internal API test in Ubuntu, ImageView.NaturalSize2D")]
122         [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.NaturalSize2D")]
123         [Property("SPEC_URL", "-")]
124         [Property("CRITERIA", "PRO")]
125         [Property("AUTHOR", "eunkiki.hong@samsung.com")]
126         public void NaturalSize2D_GET_VALUE()
127         {
128             /* TEST CODE */
129             ImageView testView = new ImageView();
130             testView.ResourceUrl = image_path;
131             Size2D result = new Size2D(212, 150); // The size of image_path image.
132             Size2D size = testView.NaturalSize2D;
133
134             Assert.AreEqual(result.Width, size.Width, "NaturalSize Width is not equal");
135             Assert.AreEqual(result.Height, size.Height, "NaturalSize Height is not equal");
136
137             testView.Dispose();
138         }
139
140
141         [Test]
142         [Category("P1")]
143         [Description("internal API test in Ubuntu, ImageView.NaturalSize")]
144         [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.NaturalSize")]
145         [Property("SPEC_URL", "-")]
146         [Property("CRITERIA", "PRO")]
147         [Property("AUTHOR", "eunkiki.hong@samsung.com")]
148         public void NaturalSize_GET_VALUE()
149         {
150             /* TEST CODE */
151             ImageView testView = new ImageView();
152             testView.ResourceUrl = image_path;
153             Vector3 result = new Vector3(212, 150, 0); // The size of image_path image.
154             Vector3 size = testView.NaturalSize;
155
156             Assert.AreEqual(result.X, size.X, "NaturalSize Width is not equal");
157             Assert.AreEqual(result.Y, size.Y, "NaturalSize Height is not equal");
158
159             testView.Dispose();
160         }
161
162         [Test]
163         [Category("P1")]
164         [Description("internal API test in Ubuntu, ImageView.NaturalSize")]
165         [Property("SPEC", "Tizen.NUI.BaseComponents.ImageView.NaturalSize")]
166         [Property("SPEC_URL", "-")]
167         [Property("CRITERIA", "PRO")]
168         [Property("AUTHOR", "eunkiki.hong@samsung.com")]
169         public void NaturalSize_GET_VALUE_as_View_class()
170         {
171             /* TEST CODE */
172             ImageView testView = new ImageView();
173             testView.ResourceUrl = image_path;
174             Vector3 result = new Vector3(212, 150, 0); // The size of image_path image.
175             View testView2 = testView; // Convert class as View.
176             Vector3 size = testView2.NaturalSize; // Check whether virtual ImageView.GetNaturalSize() called well.
177
178             Assert.AreEqual(result.X, size.X, "NaturalSize Width is not equal");
179             Assert.AreEqual(result.Y, size.Y, "NaturalSize Height is not equal");
180
181             testView.Dispose();
182             testView2.Dispose();
183         }
184     }
185 }