3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
7 using System.Threading.Tasks;
9 namespace Tizen.NUI.Devel.Tests
11 using tlog = Tizen.Log;
14 [Description("public/Common/BaseHandle")]
15 public class PublicBaseHandleTest
17 private const string tag = "NUITEST";
18 private bool flag = false;
23 tlog.Info(tag, "Init() is called!");
29 tlog.Info(tag, "Destroy() is called!");
32 private void baseHandleEventCallback(object sender, EventArgs e)
39 [Description("BaseHandle constructor.")]
40 [Property("SPEC", "Tizen.NUI.BaseHandle.BaseHandle C")]
41 [Property("SPEC_URL", "-")]
42 [Property("CRITERIA", "CONSTR")]
43 [Property("COVPARAM", "")]
44 [Property("AUTHOR", "guowei.wang@samsung.com")]
45 public void BaseHandleConstructor()
47 tlog.Debug(tag, $"BaseHandleConstructor START");
49 var testingTarget = new BaseHandle();
50 Assert.IsNotNull(testingTarget, "null handle");
51 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
53 var swigCMemOwn = testingTarget.SwigCMemOwn;
54 Assert.IsTrue(swigCMemOwn);
56 testingTarget.Dispose();
57 tlog.Debug(tag, $"BaseHandleConstructor END (OK)");
62 [Description("BaseHandle constructor. With BaseHandle")]
63 [Property("SPEC", "Tizen.NUI.BaseHandle.BaseHandle C")]
64 [Property("SPEC_URL", "-")]
65 [Property("CRITERIA", "CONSTR")]
66 [Property("COVPARAM", "BaseHandle")]
67 [Property("AUTHOR", "guowei.wang@samsung.com")]
68 public void BaseHandleConstructorWithBaseHandle()
70 tlog.Debug(tag, $"BaseHandleConstructorWithBaseHandle START");
72 BaseHandle testingTarget = null;
73 using (BaseHandle view = new View())
75 testingTarget = new BaseHandle(view);
76 Assert.IsNotNull(testingTarget, "null handle");
77 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
80 testingTarget.Dispose();
81 tlog.Debug(tag, $"BaseHandleConstructorWithBaseHandle END (OK)");
85 [Description("BaseHandle EqualTo.")]
86 [Property("SPEC", "Tizen.NUI.BaseHandle.EqualTo M")]
87 [Property("SPEC_URL", "-")]
88 [Property("CRITERIA", "MR")]
89 [Property("AUTHOR", "guowei.wang@samsung.com")]
90 public void BaseHandleEqualTo()
92 tlog.Debug(tag, $"BaseHandleEqualTo START");
94 var testingTarget = new View();
95 Assert.IsNotNull(testingTarget, "null handle");
96 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
98 View view = new View();
100 Assert.IsTrue(testingTarget.EqualTo(view), "Should be true!");
103 testingTarget.Dispose();
104 tlog.Debug(tag, $"BaseHandleEqualTo END (OK)");
109 [Description("BaseHandle NotEqualTo.")]
110 [Property("SPEC", "Tizen.NUI.BaseHandle.NotEqualTo M")]
111 [Property("SPEC_URL", "-")]
112 [Property("CRITERIA", "MR")]
113 [Property("AUTHOR", "guowei.wang@samsung.com")]
114 public void BaseHandleNotEqualTo()
116 tlog.Debug(tag, $"BaseHandleNotEqualTo START");
118 var testingTarget = new View();
119 Assert.IsNotNull(testingTarget, "null handle");
120 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
122 using (View view = new View())
124 Assert.IsTrue(testingTarget.NotEqualTo(view), "Should be true!");
127 testingTarget.Dispose();
128 tlog.Debug(tag, $"BaseHandleNotEqualTo END (OK)");
133 [Description("BaseHandle IsEqual.")]
134 [Property("SPEC", "Tizen.NUI.BaseHandle.IsEqual M")]
135 [Property("SPEC_URL", "-")]
136 [Property("CRITERIA", "MR")]
137 [Property("AUTHOR", "guowei.wang@samsung.com")]
138 public void BaseHandleIsEqual()
140 tlog.Debug(tag, $"BaseHandleIsEqual START");
142 var testingTarget = new View();
143 Assert.IsNotNull(testingTarget, "null handle");
144 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
146 View view = new View();
147 view = testingTarget;
148 Assert.IsTrue(testingTarget.IsEqual(view), "Should be true!");
150 testingTarget.Dispose();
151 Assert.IsFalse(testingTarget.IsEqual(view), "Should be true!");
154 tlog.Debug(tag, $"BaseHandleIsEqual END (OK)");
159 [Description("BaseHandle GetTypeName.")]
160 [Property("SPEC", "Tizen.NUI.BaseHandle.GetTypeName M")]
161 [Property("SPEC_URL", "-")]
162 [Property("CRITERIA", "MR")]
163 [Property("AUTHOR", "guowei.wang@samsung.com")]
164 public void BaseHandleGetTypeName()
166 tlog.Debug(tag, $"BaseHandleGetTypeName START");
168 var testingTarget = new TextLabel();
169 Assert.IsNotNull(testingTarget, "null handle");
170 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
172 Assert.AreEqual("TextLabel", testingTarget.GetTypeName(), "Should be equal!");
174 testingTarget.Dispose();
175 tlog.Debug(tag, $"BaseHandleGetTypeName END (OK)");
179 [Description("BaseHandle. Logical Not !.")]
180 [Property("SPEC", "Tizen.NUI.BaseHandle.! M")]
181 [Property("SPEC_URL", "-")]
182 [Property("CRITERIA", "MR")]
183 [Property("AUTHOR", "guowei.wang@samsung.com")]
184 public void BaseHandleLogicalNotWithNullObject()
186 tlog.Debug(tag, $"BaseHandleLogicalNotWithNullObject START");
188 View testingTarget = null;
189 Assert.IsTrue(!testingTarget, "view should be true!");
191 tlog.Debug(tag, $"BaseHandleLogicalNotWithNullObject END (OK)");
196 [Description("BaseHandle bool.")]
197 [Property("SPEC", "Tizen.NUI.BaseHandle.bool M")]
198 [Property("SPEC_URL", "-")]
199 [Property("CRITERIA", "MR")]
200 [Property("AUTHOR", "guowei.wang@samsung.com")]
201 public void BaseHandleBool()
203 tlog.Debug(tag, $"BaseHandleBool START");
205 View testingTarget = null;
206 Assert.IsFalse((bool)testingTarget);
208 testingTarget = new View();
209 Assert.IsTrue((bool)testingTarget);
211 testingTarget.Dispose();
212 tlog.Debug(tag, $"BaseHandleBool END (OK)");
216 [Description("BaseHandle Dispose.")]
217 [Property("SPEC", "Tizen.NUI.BaseHandle.Dispose M")]
218 [Property("SPEC_URL", "-")]
219 [Property("CRITERIA", "MR MCST")]
220 [Property("AUTHOR", "guowei.wang@samsung.com")]
221 public void BaseHandleDispose()
223 tlog.Debug(tag, $"BaseHandleDispose START");
225 var testingTarget = new BaseHandle();
226 Assert.IsNotNull(testingTarget, "null handle");
227 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
232 testingTarget.Dispose();
236 tlog.Error(tag, "Caught Exception" + e.ToString());
237 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
238 Assert.Fail("Caught Exception" + e.ToString());
241 tlog.Debug(tag, $"BaseHandleDispose END (OK)");
246 [Description("BaseHandle GetTypeInfo.")]
247 [Property("SPEC", "Tizen.NUI.BaseHandle.GetTypeInfo M")]
248 [Property("SPEC_URL", "-")]
249 [Property("CRITERIA", "MR")]
250 [Property("AUTHOR", "guowei.wang@samsung.com")]
251 public void BaseHandleGetTypeInfo()
253 tlog.Debug(tag, $"BaseHandleGetTypeInfo START");
255 var testingTarget = new TextLabel();
256 Assert.IsNotNull(testingTarget, "null handle");
257 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
259 TypeInfo typeInfo = TypeRegistry.Get().GetTypeInfo("TextLabel");
263 Assert.True(testingTarget.GetTypeInfo(typeInfo), "Should be true");
267 tlog.Error(tag, "Caught Exception" + e.ToString());
268 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
269 Assert.Fail("Caught Exception" + e.ToString());
273 testingTarget.Dispose();
274 tlog.Debug(tag, $"BaseHandleGetTypeInfo END (OK)");
279 [Description("BaseHandle Equals.")]
280 [Property("SPEC", "Tizen.NUI.BaseHandle.Equals M")]
281 [Property("SPEC_URL", "-")]
282 [Property("CRITERIA", "MR")]
283 [Property("AUTHOR", "guowei.wang@samsung.com")]
284 public void BaseHandleEquals()
286 tlog.Debug(tag, $"BaseHandleEquals START");
288 var testingTarget = new View();
289 Assert.IsNotNull(testingTarget, "null handle");
290 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
294 using (View view = testingTarget as View)
296 Assert.True(testingTarget.Equals(view), "Should be true");
299 using (View view = new View())
301 Assert.False(testingTarget.Equals(view), "Should be false");
306 tlog.Error(tag, "Caught Exception" + e.ToString());
307 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
308 Assert.Fail("Caught Exception" + e.ToString());
311 testingTarget.Dispose();
312 tlog.Debug(tag, $"BaseHandleEquals END (OK)");
317 [Description("BaseHandle GetHashCode.")]
318 [Property("SPEC", "Tizen.NUI.BaseHandle.GetHashCode M")]
319 [Property("SPEC_URL", "-")]
320 [Property("CRITERIA", "MR")]
321 [Property("AUTHOR", "guowei.wang@samsung.com")]
322 public void BaseHandleGetHashCode()
324 tlog.Debug(tag, $"BaseHandleGetHashCode START");
326 var testingTarget = new View();
327 Assert.IsNotNull(testingTarget, "null handle");
328 Assert.IsInstanceOf<BaseHandle>(testingTarget, "Should return BaseHandle instance.");
332 Assert.GreaterOrEqual(testingTarget.GetHashCode(), 0, "Should be true");
336 tlog.Error(tag, "Caught Exception" + e.ToString());
337 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
338 Assert.Fail("Caught Exception" + e.ToString());
341 testingTarget.Dispose();
342 tlog.Debug(tag, $"BaseHandleGetHashCode END (OK)");