[NUI] Add Visuals(Public) TCs.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.TCT / testcase / public / Visuals / TSVisualBase.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/Visuals/VisualBase")]
13     public class PublicVisualBaseTest
14     {
15         private const string tag = "NUITEST";
16
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("VisualBase constructor.")]
32         [Property("SPEC", "Tizen.NUI.VisualBase.VisualBase C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void VisualBaseConstructor()
37         {
38             tlog.Debug(tag, $"VisualBaseConstructor START");
39
40             var testingTarget = new VisualBase();
41             Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
42             Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"VisualBaseConstructor END (OK)");
46         }
47
48         [Test]
49         [Category("P1")]
50         [Description("VisualBase Name.")]
51         [Property("SPEC", "Tizen.NUI.VisualBase.Name A")]
52         [Property("SPEC_URL", "-")]
53         [Property("CRITERIA", "PRW")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         public void VisualBaseName()
56         {
57             tlog.Debug(tag, $"VisualBaseName START");
58
59             VisualFactory visualfactory = VisualFactory.Instance;
60
61             PropertyMap propertyMap = new PropertyMap();
62             propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
63             propertyMap.Insert(TextVisualProperty.Text, new PropertyValue("Hello Goodbye"));
64             
65             var testingTarget = visualfactory.CreateVisual(propertyMap);
66             Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
67             Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
68
69             testingTarget.Name = "VisualBase1";
70             Assert.AreEqual("VisualBase1", testingTarget.Name, "Name function does not work, return incorrect name.");
71
72             testingTarget.Dispose();
73             tlog.Debug(tag, $"VisualBaseName END (OK)");
74         }
75
76         [Test]
77         [Category("P1")]
78         [Description("VisualBase SetTransformAndSize.")]
79         [Property("SPEC", "Tizen.NUI.VisualBase.SetTransformAndSize M")]
80         [Property("SPEC_URL", "-")]
81         [Property("CRITERIA", "MR MCST")]
82         [Property("AUTHOR", "guowei.wang@samsung.com")]
83         public void VisualBaseSetTransformAndSize()
84         {
85             tlog.Debug(tag, $"VisualBaseSetTransformAndSize START");
86
87             try
88             {
89                 VisualFactory visualfactory = VisualFactory.Instance;
90
91                 PropertyMap propertyMap = new PropertyMap();
92                 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
93                 propertyMap.Insert(Visual.Property.Type, new PropertyValue("Hello Goodbye"));
94                 
95                 var testingTarget = visualfactory.CreateVisual(propertyMap);
96                 Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
97                 Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
98
99                 using (Vector2 vec2 = new Vector2(2.0f, 0.8f))
100                 {
101                     testingTarget.SetTransformAndSize(propertyMap, vec2);
102                 }
103
104                 testingTarget.Dispose();
105             }
106             catch (Exception e)
107             {
108                 tlog.Error(tag, "Caught Exception" + e.ToString());
109                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
110                 Assert.IsTrue(e is ArgumentException, "Argument Exception Not Recieved");
111             }
112
113             tlog.Debug(tag, $"VisualBaseSetTransformAndSize END (OK)");
114         }
115
116         [Test]
117         [Category("P1")]
118         [Description("VisualBase GetHeightForWidth.")]
119         [Property("SPEC", "Tizen.NUI.VisualBase.GetHeightForWidth M")]
120         [Property("SPEC_URL", "-")]
121         [Property("CRITERIA", "MR")]
122         [Property("AUTHOR", "guowei.wang@samsung.com")]
123         public void VisualBaseGetHeightForWidth()
124         {
125             tlog.Debug(tag, $"VisualBaseGetHeightForWidth START");
126
127             VisualFactory visualfactory = VisualFactory.Instance;
128
129             using (PropertyMap propertyMap = new PropertyMap())
130             {
131                 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
132                 propertyMap.Insert(Visual.Property.Type, new PropertyValue(""));
133                 
134                 var testingTarget = visualfactory.CreateVisual(propertyMap);
135                 Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
136                 Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
137
138                 Assert.AreEqual(0.0f, testingTarget.GetHeightForWidth(0.0f), "The height got from GetHeightForWidth is not correct.");
139
140                 testingTarget.Dispose();
141             }
142
143             tlog.Debug(tag, $"VisualBaseGetHeightForWidth END (OK)");
144         }
145
146         [Test]
147         [Category("P1")]
148         [Description("VisualBase GetWidthForHeight.")]
149         [Property("SPEC", "Tizen.NUI.VisualBase.GetWidthForHeight M")]
150         [Property("SPEC_URL", "-")]
151         [Property("CRITERIA", "MR")]
152         [Property("AUTHOR", "guowei.wang@samsung.com")]
153         public void VisualBaseGetWidthForHeight()
154         {
155             tlog.Debug(tag, $"VisualBaseGetWidthForHeight START");
156
157             VisualFactory visualfactory = VisualFactory.Instance;
158
159             using (PropertyMap propertyMap = new PropertyMap())
160             {
161                 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
162                 propertyMap.Insert(Visual.Property.Type, new PropertyValue(""));
163
164                 var testingTarget = visualfactory.CreateVisual(propertyMap);
165                 Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
166                 Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
167
168                 Assert.AreEqual(0.0f, testingTarget.GetWidthForHeight(0.0f), "The Width got from GetWidthForHeight is not correct.");
169
170                 testingTarget.Dispose();
171             }
172
173             tlog.Debug(tag, $"VisualBaseGetWidthForHeight END (OK)");
174         }
175
176         [Test]
177         [Category("P1")]
178         [Description("VisualBase GetNaturalSize.")]
179         [Property("SPEC", "Tizen.NUI.VisualBase.GetNaturalSize M")]
180         [Property("SPEC_URL", "-")]
181         [Property("CRITERIA", "MR")]
182         [Property("AUTHOR", "guowei.wang@samsung.com")]
183         public void VisualBaseGetNaturalSize()
184         {
185             tlog.Debug(tag, $"VisualBaseGetNaturalSize START");
186
187             try
188             {
189                 VisualFactory visualfactory = VisualFactory.Instance;
190
191                 using (PropertyMap propertyMap = new PropertyMap())
192                 {
193                     propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
194
195                     var testingTarget = visualfactory.CreateVisual(propertyMap);
196                     Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
197                     Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
198
199                     using (Size2D size2d = new Size2D(1, 2))
200                     {
201                         testingTarget.GetNaturalSize(size2d);
202                         Assert.AreEqual(0.0f, size2d.Height, "The Height got from GetNaturalSize is not right");
203                         Assert.AreEqual(0.0f, size2d.Width, "The Width got from GetNaturalSize is not right");
204                     }
205
206                     testingTarget.Dispose();
207                 }
208
209                 visualfactory.Dispose();
210             }
211             catch (Exception e)
212             {
213                 tlog.Error(tag, "Caught Exception" + e.ToString());
214                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
215                 Assert.Fail("Caught Exception" + e.ToString());
216             }
217
218             tlog.Debug(tag, $"VisualBaseGetNaturalSize END (OK)");
219         }
220
221         [Test]
222         [Category("P1")]
223         [Description("VisualBase DepthIndex.")]
224         [Property("SPEC", "Tizen.NUI.VisualBase.DepthIndex A")]
225         [Property("SPEC_URL", "-")]
226         [Property("CRITERIA", "PRW")]
227         [Property("AUTHOR", "guowei.wang@samsung.com")]
228         public void VisualBaseDepthIndex()
229         {
230             tlog.Debug(tag, $"VisualBaseDepthIndex START");
231
232             VisualFactory visualfactory = VisualFactory.Instance;
233
234             using (PropertyMap propertyMap = new PropertyMap())
235             {
236                 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
237                 propertyMap.Insert(Visual.Property.Type, new PropertyValue("Hello Goodbye"));
238                 
239                 var testingTarget = visualfactory.CreateVisual(propertyMap);
240                 Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
241                 Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
242
243                 testingTarget.DepthIndex = 1;
244                 Assert.AreEqual(1, testingTarget.DepthIndex, "The DepthIndex got from DepthIndex is not right");
245
246                 testingTarget.Dispose();
247             }
248             
249             visualfactory.Dispose();
250             tlog.Debug(tag, $"VisualBaseDepthIndex END (OK)");
251         }
252
253         [Test]
254         [Category("P1")]
255         [Description("VisualBase Creation.")]
256         [Property("SPEC", "Tizen.NUI.VisualBase.Creation A")]
257         [Property("SPEC_URL", "-")]
258         [Property("CRITERIA", "PRO")]
259         [Property("AUTHOR", "guowei.wang@samsung.com")]
260         public void VisualBaseCreation()
261         {
262             tlog.Debug(tag, $"VisualBaseCreation START");
263
264             try
265             {
266                 VisualFactory visualfactory = VisualFactory.Instance;
267
268                 using (PropertyMap propertyMap = new PropertyMap())
269                 {
270                     propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
271                     propertyMap.Insert(TextVisualProperty.Text, new PropertyValue("Hello"));
272                     propertyMap.Insert(TextVisualProperty.PointSize, new PropertyValue(10.0f));
273
274                     var testingTarget = visualfactory.CreateVisual(propertyMap);
275                     Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
276                     Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
277
278                     var result = testingTarget.Creation;
279                     Assert.IsNotNull(result, "Can't create success object VisualBase");
280                     Assert.IsInstanceOf<PropertyMap>(result, "Should return PropertyMap instance.");
281
282                     testingTarget.Dispose();
283                     result.Dispose();
284                 }
285
286                 visualfactory.Dispose();
287             }
288             catch (Exception e)
289             {
290                 tlog.Error(tag, "Caught Exception" + e.ToString());
291                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
292                 Assert.IsTrue(e is ArgumentException, "Argument Exception Not Recieved");
293             }
294
295             tlog.Debug(tag, $"VisualBaseCreation END (OK)");
296         }
297
298         [Test]
299         [Category("P1")]
300         [Description("VisualBase Dispose.")]
301         [Property("SPEC", "Tizen.NUI.VisualBase.Dispose M")]
302         [Property("SPEC_URL", "-")]
303         [Property("CRITERIA", "MR MCST")]
304         [Property("AUTHOR", "guowei.wang@samsung.com")]
305         public void VisualBaseDispose()
306         {
307             tlog.Debug(tag, $"VisualBaseDispose START");
308
309             var testingTarget = new VisualBase();
310             Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
311             Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
312             try
313             {
314                 testingTarget.Dispose();
315             }
316             catch (Exception e)
317             {
318                 Assert.Fail("Caught Exception" + e.ToString());
319             }
320
321             testingTarget.Dispose();
322             tlog.Debug(tag, $"VisualBaseDispose END (OK)");
323         }
324     }
325 }