3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Threading.Tasks;
8 namespace Tizen.NUI.Devel.Tests
10 using tlog = Tizen.Log;
13 [Description("public/Common/PropertyNotification")]
14 class PublicPropertyNotificationTest
16 private const string tag = "NUITEST";
21 tlog.Info(tag, "Init() is called!");
27 tlog.Info(tag, "Destroy() is called!");
32 [Description("PropertyNotification constructor")]
33 [Property("SPEC", "Tizen.NUI.PropertyNotification.PropertyNotification C")]
34 [Property("SPEC_URL", "-")]
35 [Property("CRITERIA", "CONSTR")]
36 [Property("COVPARAM", "")]
37 [Property("AUTHOR", "guowei.wang@samsung.com")]
38 public void PropertyNotificationConstructor()
40 tlog.Debug(tag, $"PropertyNotificationConstructor START");
42 var testintTarget = new Tizen.NUI.PropertyNotification();
43 Assert.IsNotNull(testintTarget, "should not be null.");
44 Assert.IsInstanceOf<PropertyNotification>(testintTarget, "should be an instance of PropertyNotification class!");
46 testintTarget.Dispose();
47 tlog.Debug(tag, $"PropertyNotificationConstructor END (OK)");
52 [Description("PropertyNotification constructor. With PropertyNotification instance")]
53 [Property("SPEC", "Tizen.NUI.PropertyNotification.PropertyNotification C")]
54 [Property("SPEC_URL", "-")]
55 [Property("CRITERIA", "CONSTR")]
56 [Property("COVPARAM", "PropertyNotification")]
57 [Property("AUTHOR", "guowei.wang@samsung.com")]
58 public void PropertyNotificationConstructorWithPropertyNotification()
60 tlog.Debug(tag, $"PropertyNotificationConstructorWithPropertyNotification START");
62 var view = new View();
63 Assert.IsNotNull(view, "should not be null.");
64 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
66 var dummy = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
67 Assert.IsNotNull(dummy, "should not be null.");
68 Assert.IsInstanceOf<PropertyNotification>(dummy, "should be an instance of PropertyNotification class!");
70 var testingTarget = new Tizen.NUI.PropertyNotification(dummy);
71 Assert.IsNotNull(testingTarget, "should not be null.");
72 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
74 testingTarget.Dispose();
77 tlog.Debug(tag, $"PropertyNotificationConstructorWithPropertyNotification END (OK)");
82 [Description("PropertyNotification GetTarget")]
83 [Property("SPEC", "Tizen.NUI.PropertyNotification.GetTarget M")]
84 [Property("SPEC_URL", "-")]
85 [Property("CRITERIA", "MR")]
86 [Property("AUTHOR", "guowei.wang@samsung.com")]
87 public void PropertyNotificationGetTarget()
89 tlog.Debug(tag, $"PropertyNotificationGetTarget START");
91 var view = new View();
92 Assert.IsNotNull(view, "should not be null.");
93 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
95 var testingTarget = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
96 Assert.IsNotNull(testingTarget, "should not be null.");
97 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
99 var result = testingTarget.GetTarget();
100 Assert.IsNotNull(result, "Should be not null!");
101 Assert.IsInstanceOf<Animatable>(result, "should be an instance of Animatable class!");
104 testingTarget.Dispose();
106 tlog.Debug(tag, $"PropertyNotificationGetTarget END (OK)");
111 [Description("PropertyNotification GetCondition")]
112 [Property("SPEC", "Tizen.NUI.PropertyNotification.GetCondition M")]
113 [Property("SPEC_URL", "-")]
114 [Property("CRITERIA", "MR")]
115 [Property("AUTHOR", "guowei.wang@samsung.com")]
116 public void PropertyNotificationGetCondition()
118 tlog.Debug(tag, $"PropertyNotificationGetCondition START");
120 var dummyView = new View();
121 Assert.IsNotNull(dummyView, "should not be null.");
122 Assert.IsInstanceOf<View>(dummyView, "should be an instance of View class!");
124 var dummycondition = PropertyCondition.GreaterThan(100.0f);
125 Assert.IsNotNull(dummycondition, "should not be null.");
126 Assert.IsInstanceOf<PropertyCondition>(dummycondition, "should be an instance of PropertyCondition class!");
128 var dummyNotification = dummyView.AddPropertyNotification("PositionX", dummycondition);
129 Assert.IsNotNull(dummyNotification, "should not be null.");
130 Assert.IsInstanceOf<PropertyNotification>(dummyNotification, "should be an instance of PropertyNotification class!");
132 var result = dummyNotification.GetCondition();
133 Assert.IsNotNull(result, "should not be null.");
134 Assert.IsInstanceOf<PropertyCondition>(result, "should be an instance of PropertyCondition class!");
136 Assert.IsTrue(result == dummycondition);
139 dummyNotification.Dispose();
140 dummycondition.Dispose();
142 tlog.Debug(tag, $"PropertyNotificationGetCondition END (OK)");
147 [Description("PropertyNotification GetTargetProperty")]
148 [Property("SPEC", "Tizen.NUI.PropertyNotification.GetTargetProperty M")]
149 [Property("SPEC_URL", "-")]
150 [Property("CRITERIA", "MR")]
151 [Property("AUTHOR", "guowei.wang@samsung.com")]
152 public void PropertyNotificationGetTargetProperty()
154 tlog.Debug(tag, $"PropertyNotificationGetTargetProperty START");
156 var view = new View();
157 Assert.IsNotNull(view, "should not be null.");
158 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
160 var testingTarget = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
161 Assert.IsNotNull(testingTarget, "should not be null.");
162 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
164 Assert.AreEqual(13, testingTarget.GetTargetProperty(), "Retrive testingTarget.GetTargetProperty() should equal to 13.");
166 testingTarget.Dispose();
168 tlog.Debug(tag, $"PropertyNotificationGetTargetProperty END (OK)");
173 [Description("PropertyNotification GetNotifyMode")]
174 [Property("SPEC", "Tizen.NUI.PropertyNotification.GetNotifyMode M")]
175 [Property("SPEC_URL", "-")]
176 [Property("CRITERIA", "MR")]
177 [Property("AUTHOR", "guowei.wang@samsung.com")]
178 public void PropertyNotificationGetNotifyMode()
180 tlog.Debug(tag, $"PropertyNotificationGetNotifyMode START");
182 View view = new View();
183 var testingTarget = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
184 Assert.IsNotNull(testingTarget, "should not be null.");
185 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
187 var result = testingTarget.GetNotifyMode();
188 Assert.IsNotNull(result, "should not be null.");
189 Assert.IsInstanceOf<PropertyNotification.NotifyMode>(result, "should be an instance of PropertyNotification.NotifyMode class!");
190 Assert.IsTrue(PropertyNotification.NotifyMode.NotifyOnTrue == result);
192 testingTarget.Dispose();
194 tlog.Debug(tag, $"PropertyNotificationGetNotifyMode END (OK)");
199 [Description("PropertyNotification SetNotifyMode")]
200 [Property("SPEC", "Tizen.NUI.PropertyNotification.SetNotifyMode M")]
201 [Property("SPEC_URL", "-")]
202 [Property("CRITERIA", "MR")]
203 [Property("AUTHOR", "guowei.wang@samsung.com")]
204 public void PropertyNotificationSetNotifyMode()
206 tlog.Debug(tag, $"PropertyNotificationSetNotifyMode START");
208 View view = new View();
209 var testingTarget = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
210 Assert.IsNotNull(testingTarget, "should not be null.");
211 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
213 testingTarget.SetNotifyMode(PropertyNotification.NotifyMode.NotifyOnChanged);
214 var result = testingTarget.GetNotifyMode();
215 Assert.IsNotNull(result, "should not be null.");
216 Assert.IsInstanceOf<PropertyNotification.NotifyMode>(result, "should be an instance of PropertyNotification.NotifyMode class!");
217 Assert.IsTrue(PropertyNotification.NotifyMode.NotifyOnChanged == result);
219 testingTarget.Dispose();
221 tlog.Debug(tag, $"PropertyNotificationSetNotifyMode END (OK)");
226 [Description("PropertyNotification GetNotifyResult.")]
227 [Property("SPEC", "Tizen.NUI.PropertyNotification.GetNotifyResult M")]
228 [Property("SPEC_URL", "-")]
229 [Property("CRITERIA", "MR")]
230 [Property("AUTHOR", "guowei.wang@samsung.com")]
231 public void PropertyNotificationGetNotifyResult()
233 tlog.Debug(tag, $"PropertyNotificationGetNotifyResult START");
235 var view = new View();
236 Assert.IsNotNull(view, "should not be null.");
237 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
239 var testingTarget = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
240 Assert.IsNotNull(testingTarget, "should not be null.");
241 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
243 testingTarget.SetNotifyMode(PropertyNotification.NotifyMode.NotifyOnChanged);
244 testingTarget.Notified += (obj, e) =>
246 tlog.Fatal("TCT", "Notified!");
248 view.Position = new Position(0.0f, 0.0f, 0.0f);
249 Assert.AreEqual(false, testingTarget.GetNotifyResult(), "Should be equal!");
251 testingTarget.Dispose();
253 tlog.Debug(tag, $"PropertyNotificationGetNotifyResult END (OK)");
258 [Description("PropertyNotification Dispose")]
259 [Property("SPEC", "Tizen.NUI.PropertyNotification.Dispose M")]
260 [Property("SPEC_URL", "-")]
261 [Property("CRITERIA", "MR MCST")]
262 [Property("AUTHOR", "guowei.wang@samsung.com")]
263 public void PropertyNotificationDispose()
265 tlog.Debug(tag, $"PropertyNotificationDispose START");
267 var testingTarget = new PropertyNotification();
268 Assert.IsNotNull(testingTarget, "should not be null.");
269 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
273 testingTarget.Dispose();
277 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
278 Assert.Fail("Caught Exception" + e.ToString());
281 tlog.Debug(tag, $"PropertyNotificationDispose END (OK)");
286 [Description("PropertyNotification DownCast")]
287 [Property("SPEC", "Tizen.NUI.PropertyNotification.DownCast M")]
288 [Property("SPEC_URL", "-")]
289 [Property("CRITERIA", "MR")]
290 [Property("AUTHOR", "guowei.wang@samsung.com")]
291 public void PropertyNotificationDownCast()
293 tlog.Debug(tag, $"PropertyNotificationDownCast START");
295 var view = new View();
296 Assert.IsNotNull(view, "should not be null.");
297 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
299 Window.Instance.Add(view);
300 var testingTarget = view.AddPropertyNotification("positionX", PropertyCondition.GreaterThan(100.0f));
301 Assert.IsNotNull(testingTarget, "should not be null.");
302 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
304 var result = PropertyNotification.DownCast(testingTarget);
305 Assert.IsNotNull(result, "should not be null.");
306 Assert.IsInstanceOf<PropertyNotification>(result, "should be an instance of PropertyNotification class!");
308 Window.Instance.Remove(view);
309 testingTarget.Dispose();
311 tlog.Debug(tag, $"PropertyNotificationDownCast END (OK)");
316 [Description("PropertyNotification NotifySignal")]
317 [Property("SPEC", "Tizen.NUI.PropertyNotification.NotifySignal M")]
318 [Property("SPEC_URL", "-")]
319 [Property("CRITERIA", "MR")]
320 [Property("AUTHOR", "guowei.wang@samsung.com")]
321 public async Task PropertyNotificationNotifySignal()
323 tlog.Debug(tag, $"PropertyNotificationNotifySignal START");
325 var view = new View();
326 Assert.IsNotNull(view, "should not be null.");
327 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
329 Window.Instance.Add(view);
330 var testingTarget = view.AddPropertyNotification("positionX", PropertyCondition.GreaterThan(100.0f));
331 Assert.IsNotNull(testingTarget, "should not be null.");
332 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
334 testingTarget.SetNotifyMode(PropertyNotification.NotifyMode.NotifyOnChanged);
336 testingTarget.Notified += (obj, e) =>
340 view.Position = new Position(300.0f, 0.0f, 0.0f);
341 await Task.Delay(200);
343 var result = testingTarget.NotifySignal();
344 Assert.IsNotNull(result, "Should be not null");
345 Assert.IsInstanceOf<PropertyNotifySignal>(result, "Should be an instance of propertyNotifySignal");
347 Window.Instance.Remove(view);
348 testingTarget.Dispose();
350 tlog.Debug(tag, $"PropertyNotificationNotifySignal END (OK)");
355 [Description("PropertyNotification Assign")]
356 [Property("SPEC", "Tizen.NUI.PropertyNotification.Assign M")]
357 [Property("SPEC_URL", "-")]
358 [Property("CRITERIA", "MR")]
359 [Property("AUTHOR", "guowei.wang@samsung.com")]
360 public void PropertyNotificationAssign()
362 tlog.Debug(tag, $"PropertyNotificationAssign START");
364 var view = new View();
365 Assert.IsNotNull(view, "should not be null.");
366 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
367 Window.Instance.Add(view);
369 var dummy1 = view.AddPropertyNotification("positionX", PropertyCondition.GreaterThan(100.0f));
370 Assert.IsNotNull(dummy1, "should not be null.");
371 Assert.IsInstanceOf<PropertyNotification>(dummy1, "should be an instance of PropertyNotification class!");
373 var dummy2 = view.AddPropertyNotification("positionY", PropertyCondition.GreaterThan(100.0f));
374 Assert.IsNotNull(dummy2, "should not be null.");
375 Assert.IsInstanceOf<PropertyNotification>(dummy2, "should be an instance of PropertyNotification class!");
377 var testingTarget = dummy2.Assign(dummy1);
378 Assert.IsNotNull(testingTarget, "should not be null.");
379 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
381 Window.Instance.Remove(view);
382 testingTarget.Dispose();
386 tlog.Debug(tag, $"PropertyNotificationAssign END (OK)");
391 [Description("PropertyNotification Assign, negative")]
392 [Property("SPEC", "Tizen.NUI.PropertyNotification.Assign M")]
393 [Property("SPEC_URL", "-")]
394 [Property("CRITERIA", "MR")]
395 [Property("AUTHOR", "guowei.wang@samsung.com")]
396 public void PropertyNotificationAssignNegative()
398 tlog.Debug(tag, $"PropertyNotificationAssignNegative START");
400 var view = new View();
401 Assert.IsNotNull(view, "should not be null.");
402 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
403 Window.Instance.Add(view);
405 var testingTarget = view.AddPropertyNotification("positionX", PropertyCondition.GreaterThan(100.0f));
406 Assert.IsNotNull(testingTarget, "should not be null.");
407 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
411 testingTarget.Assign(null);
412 Assert.Fail("Should throw the System.ArgumentNullException!");
414 catch (ArgumentNullException e)
419 Window.Instance.Remove(view);
420 testingTarget.Dispose();
422 tlog.Debug(tag, $"PropertyNotificationAssignNegative END (OK)");
427 [Description("PropertyNotification.NotifyEventArgs constructor")]
428 [Property("SPEC", "Tizen.NUI.PropertyNotification.NotifyEventArgs.NotifyEventArgs C")]
429 [Property("SPEC_URL", " - ")]
430 [Property("CRITERIA", "CONSTR")]
431 [Property("AUTHOR", "guowei.wang@samsung.com")]
432 public void PropertyNotificationNotifyEventArgsContructor()
434 tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsContructor START");
436 var testingTarget = new PropertyNotification.NotifyEventArgs();
437 Assert.NotNull(testingTarget, "Should be not null");
438 Assert.IsInstanceOf<PropertyNotification.NotifyEventArgs>(testingTarget, "Should be an instance of PropertyNotification.PropertyNotificationNotifyEventArgs");
440 tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsContructor END (OK)");
445 [Description("PropertyNotification.NotifyEventArgs GetTargetProperty")]
446 [Property("SPEC", "Tizen.NUI.PropertyNotification.NotifyEventArgs.PropertyNotification A")]
447 [Property("SPEC_URL", " - ")]
448 [Property("CRITERIA", "PRW")]
449 [Property("AUTHOR", "guowei.wang@samsung.com")]
450 public void PropertyNotificationNotifyEventArgsGetTargetProperty()
452 tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsGetTargetProperty START");
454 var view = new View();
455 Assert.IsNotNull(view, "should not be null.");
456 Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
458 var dummy = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
459 Assert.IsNotNull(dummy, "should not be null.");
460 Assert.IsInstanceOf<PropertyNotification>(dummy, "should be an instance of PropertyNotification class!");
462 var testingTarget = new PropertyNotification.NotifyEventArgs();
463 Assert.NotNull(testingTarget, "Should be not null");
464 Assert.IsInstanceOf<PropertyNotification.NotifyEventArgs>(testingTarget, "Should be an instance of PropertyNotification.PropertyNotificationNotifyEventArgs");
466 testingTarget.PropertyNotification = dummy;
467 Assert.AreEqual(13, testingTarget.PropertyNotification.GetTargetProperty(), "Should be equal!");
472 tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsGetTargetProperty END (OK)");
477 [Description("PropertyNotification Notified")]
478 [Property("SPEC", "Tizen.NUI.PropertyNotification.Notified E")]
479 [Property("SPEC_URL", "-")]
480 [Property("CRITERIA", "EVL")]
481 [Property("AUTHOR", "guowei.wang@samsung.com")]
482 public async Task PropertyNotificationNotified()
484 tlog.Debug(tag, $"PropertyNotificationNotified START");
486 View view = new View();
487 Window.Instance.Add(view);
488 var testingTarget = view.AddPropertyNotification("positionX", PropertyCondition.GreaterThan(100.0f));
489 Assert.IsNotNull(testingTarget, "should not be null.");
490 Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
492 testingTarget.SetNotifyMode(PropertyNotification.NotifyMode.NotifyOnChanged);
494 testingTarget.Notified += (obj, e) =>
499 view.Position = new Position(300.0f, 0.0f, 0.0f);
500 await Task.Delay(200);
501 Assert.AreEqual(true, flag, "Should be equal!");
503 Window.Instance.Remove(view);
504 testingTarget.Dispose();
506 tlog.Debug(tag, $"PropertyNotificationNotified END (OK)");