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/Visuals/VisualBase")]
13 public class PublicVisualBaseTest
15 private const string tag = "NUITEST";
20 tlog.Info(tag, "Init() is called!");
26 tlog.Info(tag, "Destroy() is called!");
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()
38 tlog.Debug(tag, $"VisualBaseConstructor START");
40 var testingTarget = new VisualBase();
41 Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
42 Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
44 testingTarget.Dispose();
45 tlog.Debug(tag, $"VisualBaseConstructor END (OK)");
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()
57 tlog.Debug(tag, $"VisualBaseName START");
59 VisualFactory visualfactory = VisualFactory.Instance;
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"));
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.");
69 testingTarget.Name = "VisualBase1";
70 Assert.AreEqual("VisualBase1", testingTarget.Name, "Name function does not work, return incorrect name.");
72 testingTarget.Dispose();
73 tlog.Debug(tag, $"VisualBaseName END (OK)");
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()
85 tlog.Debug(tag, $"VisualBaseSetTransformAndSize START");
89 VisualFactory visualfactory = VisualFactory.Instance;
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"));
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.");
99 using (Vector2 vec2 = new Vector2(2.0f, 0.8f))
101 testingTarget.SetTransformAndSize(propertyMap, vec2);
104 testingTarget.Dispose();
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");
113 tlog.Debug(tag, $"VisualBaseSetTransformAndSize END (OK)");
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()
125 tlog.Debug(tag, $"VisualBaseGetHeightForWidth START");
127 VisualFactory visualfactory = VisualFactory.Instance;
129 using (PropertyMap propertyMap = new PropertyMap())
131 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
132 propertyMap.Insert(Visual.Property.Type, new PropertyValue(""));
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.");
138 Assert.AreEqual(0.0f, testingTarget.GetHeightForWidth(0.0f), "The height got from GetHeightForWidth is not correct.");
140 testingTarget.Dispose();
143 tlog.Debug(tag, $"VisualBaseGetHeightForWidth END (OK)");
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()
155 tlog.Debug(tag, $"VisualBaseGetWidthForHeight START");
157 VisualFactory visualfactory = VisualFactory.Instance;
159 using (PropertyMap propertyMap = new PropertyMap())
161 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
162 propertyMap.Insert(Visual.Property.Type, new PropertyValue(""));
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.");
168 Assert.AreEqual(0.0f, testingTarget.GetWidthForHeight(0.0f), "The Width got from GetWidthForHeight is not correct.");
170 testingTarget.Dispose();
173 tlog.Debug(tag, $"VisualBaseGetWidthForHeight END (OK)");
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()
185 tlog.Debug(tag, $"VisualBaseGetNaturalSize START");
189 VisualFactory visualfactory = VisualFactory.Instance;
191 using (PropertyMap propertyMap = new PropertyMap())
193 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
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.");
199 using (Size2D size2d = new Size2D(1, 2))
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");
206 testingTarget.Dispose();
209 visualfactory.Dispose();
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());
218 tlog.Debug(tag, $"VisualBaseGetNaturalSize END (OK)");
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()
230 tlog.Debug(tag, $"VisualBaseDepthIndex START");
232 VisualFactory visualfactory = VisualFactory.Instance;
234 using (PropertyMap propertyMap = new PropertyMap())
236 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
237 propertyMap.Insert(Visual.Property.Type, new PropertyValue("Hello Goodbye"));
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.");
243 testingTarget.DepthIndex = 1;
244 Assert.AreEqual(1, testingTarget.DepthIndex, "The DepthIndex got from DepthIndex is not right");
246 testingTarget.Dispose();
249 visualfactory.Dispose();
250 tlog.Debug(tag, $"VisualBaseDepthIndex END (OK)");
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()
262 tlog.Debug(tag, $"VisualBaseCreation START");
266 VisualFactory visualfactory = VisualFactory.Instance;
268 using (PropertyMap propertyMap = new PropertyMap())
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));
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.");
278 var result = testingTarget.Creation;
279 Assert.IsNotNull(result, "Can't create success object VisualBase");
280 Assert.IsInstanceOf<PropertyMap>(result, "Should return PropertyMap instance.");
282 testingTarget.Dispose();
286 visualfactory.Dispose();
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");
295 tlog.Debug(tag, $"VisualBaseCreation END (OK)");
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()
307 tlog.Debug(tag, $"VisualBaseDispose START");
309 var testingTarget = new VisualBase();
310 Assert.IsNotNull(testingTarget, "Can't create success object VisualBase");
311 Assert.IsInstanceOf<VisualBase>(testingTarget, "Should return VisualBase instance.");
314 testingTarget.Dispose();
318 Assert.Fail("Caught Exception" + e.ToString());
321 testingTarget.Dispose();
322 tlog.Debug(tag, $"VisualBaseDispose END (OK)");