[NUI] Remove some TCs which are not effective.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Common / TSPropertyNotification.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 using System.Threading.Tasks;
7
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("public/Common/PropertyNotification")]
14     class PublicPropertyNotificationTest
15     {
16         private const string tag = "NUITEST";
17
18         [SetUp]
19         public void Init()
20         {
21             tlog.Info(tag, "Init() is called!");
22         }
23
24         [TearDown]
25         public void Destroy()
26         {
27             tlog.Info(tag, "Destroy() is called!");
28         }
29
30         [Test]
31         [Category("P1")]
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()
39         {
40             tlog.Debug(tag, $"PropertyNotificationConstructor START");
41
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!");
45
46             testintTarget.Dispose();
47             tlog.Debug(tag, $"PropertyNotificationConstructor END (OK)");
48         }
49
50         [Test]
51         [Category("P1")]
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()
59         {
60             tlog.Debug(tag, $"PropertyNotificationConstructorWithPropertyNotification START");
61
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!");
65
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!");
69
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!");
73
74             testingTarget.Dispose();
75             dummy.Dispose();
76             view.Dispose();
77             tlog.Debug(tag, $"PropertyNotificationConstructorWithPropertyNotification END (OK)");
78         }
79
80         [Test]
81         [Category("P1")]
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()
88         {
89             tlog.Debug(tag, $"PropertyNotificationGetTarget START");
90
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!");
94
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!");
98
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!");
102
103             result.Dispose();
104             testingTarget.Dispose();
105             view.Dispose();
106             tlog.Debug(tag, $"PropertyNotificationGetTarget END (OK)");
107         }
108
109         [Test]
110         [Category("P1")]
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()
117         {
118             tlog.Debug(tag, $"PropertyNotificationGetCondition START");
119
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!");
123
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!");
127
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!");
131
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!");
135
136             Assert.IsTrue(result == dummycondition);
137
138             result.Dispose();
139             dummyNotification.Dispose();
140             dummycondition.Dispose();
141             dummyView.Dispose();
142             tlog.Debug(tag, $"PropertyNotificationGetCondition END (OK)");
143         }
144
145         [Test]
146         [Category("P1")]
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()
153         {
154             tlog.Debug(tag, $"PropertyNotificationGetTargetProperty START");
155
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!");
159
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!");
163
164             Assert.AreEqual(13, testingTarget.GetTargetProperty(), "Retrive testingTarget.GetTargetProperty() should equal to 13.");
165
166             testingTarget.Dispose();
167             view.Dispose();
168             tlog.Debug(tag, $"PropertyNotificationGetTargetProperty END (OK)");
169         }
170
171         [Test]
172         [Category("P1")]
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()
179         {
180             tlog.Debug(tag, $"PropertyNotificationGetNotifyMode START");
181
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!");
186
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);
191
192             testingTarget.Dispose();
193             view.Dispose();
194             tlog.Debug(tag, $"PropertyNotificationGetNotifyMode END (OK)");
195         }
196
197         [Test]
198         [Category("P1")]
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()
205         {
206             tlog.Debug(tag, $"PropertyNotificationSetNotifyMode START");
207
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!");
212
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);
218
219             testingTarget.Dispose();
220             view.Dispose();
221             tlog.Debug(tag, $"PropertyNotificationSetNotifyMode END (OK)");
222         }
223
224         [Test]
225         [Category("P1")]
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()
232         {
233             tlog.Debug(tag, $"PropertyNotificationGetNotifyResult START");
234
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!");
238
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!");
242
243             testingTarget.SetNotifyMode(PropertyNotification.NotifyMode.NotifyOnChanged);
244             testingTarget.Notified += (obj, e) =>
245             {
246                 tlog.Fatal("TCT", "Notified!");
247             };
248             view.Position = new Position(0.0f, 0.0f, 0.0f);
249             Assert.AreEqual(false, testingTarget.GetNotifyResult(), "Should be equal!");
250
251             testingTarget.Dispose();
252             view.Dispose();
253             tlog.Debug(tag, $"PropertyNotificationGetNotifyResult END (OK)");
254         }
255
256         [Test]
257         [Category("P1")]
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()
264         {
265             tlog.Debug(tag, $"PropertyNotificationDispose START");
266
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!");
270
271             try
272             {
273                 testingTarget.Dispose();
274             }
275             catch (Exception e)
276             {
277                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
278                 Assert.Fail("Caught Exception" + e.ToString());
279             }
280
281             tlog.Debug(tag, $"PropertyNotificationDispose END (OK)");
282         }
283
284         [Test]
285         [Category("P1")]
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()
292         {
293             tlog.Debug(tag, $"PropertyNotificationDownCast START");
294
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!");
298
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!");
303
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!");
307
308             Window.Instance.Remove(view);
309             testingTarget.Dispose();
310             view.Dispose();
311             tlog.Debug(tag, $"PropertyNotificationDownCast END (OK)");
312         }
313
314         [Test]
315         [Category("P1")]
316         [Description("PropertyNotification Assign")]
317         [Property("SPEC", "Tizen.NUI.PropertyNotification.Assign M")]
318         [Property("SPEC_URL", "-")]
319         [Property("CRITERIA", "MR")]
320         [Property("AUTHOR", "guowei.wang@samsung.com")]
321         public void PropertyNotificationAssign()
322         {
323             tlog.Debug(tag, $"PropertyNotificationAssign START");
324
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!");
328             Window.Instance.Add(view);
329
330             var dummy1 = view.AddPropertyNotification("positionX", PropertyCondition.GreaterThan(100.0f));
331             Assert.IsNotNull(dummy1, "should not be null.");
332             Assert.IsInstanceOf<PropertyNotification>(dummy1, "should be an instance of PropertyNotification class!");
333
334             var dummy2 = view.AddPropertyNotification("positionY", PropertyCondition.GreaterThan(100.0f));
335             Assert.IsNotNull(dummy2, "should not be null.");
336             Assert.IsInstanceOf<PropertyNotification>(dummy2, "should be an instance of PropertyNotification class!");
337
338             var testingTarget = dummy2.Assign(dummy1);
339             Assert.IsNotNull(testingTarget, "should not be null.");
340             Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
341
342             Window.Instance.Remove(view);
343             testingTarget.Dispose();
344             dummy2.Dispose();
345             dummy1.Dispose();
346             view.Dispose();
347             tlog.Debug(tag, $"PropertyNotificationAssign END (OK)");
348         }
349
350         [Test]
351         [Category("P2")]
352         [Description("PropertyNotification Assign, negative")]
353         [Property("SPEC", "Tizen.NUI.PropertyNotification.Assign M")]
354         [Property("SPEC_URL", "-")]
355         [Property("CRITERIA", "MR")]
356         [Property("AUTHOR", "guowei.wang@samsung.com")]
357         public void PropertyNotificationAssignNegative()
358         {
359             tlog.Debug(tag, $"PropertyNotificationAssignNegative START");
360
361             View view = new View();
362             Window.Instance.Add(view);
363
364             var testingTarget = view.AddPropertyNotification("positionX", PropertyCondition.GreaterThan(100.0f));
365             Assert.IsNotNull(testingTarget, "should not be null.");
366             Assert.IsInstanceOf<PropertyNotification>(testingTarget, "should be an instance of PropertyNotification class!");
367
368             try
369             {
370                 testingTarget.Assign(null);
371             }
372             catch (ArgumentNullException e)
373             {
374                 tlog.Debug(tag, e.Message.ToString());
375                 
376                 Window.Instance.Remove(view);
377                 testingTarget.Dispose();
378                 view.Dispose();
379                 Assert.Pass("Caught ArgumentNullException : Passed!");
380
381                 tlog.Debug(tag, $"PropertyNotificationAssignNegative END (OK)");
382             }
383         }
384
385         [Test]
386         [Category("P1")]
387         [Description("PropertyNotification.NotifyEventArgs constructor")]
388         [Property("SPEC", "Tizen.NUI.PropertyNotification.NotifyEventArgs.NotifyEventArgs C")]
389         [Property("SPEC_URL", " - ")]
390         [Property("CRITERIA", "CONSTR")]
391         [Property("AUTHOR", "guowei.wang@samsung.com")]
392         public void PropertyNotificationNotifyEventArgsContructor()
393         {
394             tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsContructor START");
395
396             var testingTarget = new PropertyNotification.NotifyEventArgs();
397             Assert.NotNull(testingTarget, "Should be not null");
398             Assert.IsInstanceOf<PropertyNotification.NotifyEventArgs>(testingTarget, "Should be an instance of PropertyNotification.PropertyNotificationNotifyEventArgs");
399
400             tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsContructor END (OK)");
401         }
402
403         [Test]
404         [Category("P1")]
405         [Description("PropertyNotification.NotifyEventArgs GetTargetProperty")]
406         [Property("SPEC", "Tizen.NUI.PropertyNotification.NotifyEventArgs.PropertyNotification A")]
407         [Property("SPEC_URL", " - ")]
408         [Property("CRITERIA", "PRW")]
409         [Property("AUTHOR", "guowei.wang@samsung.com")]
410         public void PropertyNotificationNotifyEventArgsGetTargetProperty()
411         {
412             tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsGetTargetProperty START");
413
414             var view = new View();
415             Assert.IsNotNull(view, "should not be null.");
416             Assert.IsInstanceOf<View>(view, "should be an instance of View class!");
417
418             var dummy = view.AddPropertyNotification("PositionX", PropertyCondition.GreaterThan(100.0f));
419             Assert.IsNotNull(dummy, "should not be null.");
420             Assert.IsInstanceOf<PropertyNotification>(dummy, "should be an instance of PropertyNotification class!");
421
422             var testingTarget = new PropertyNotification.NotifyEventArgs();
423             Assert.NotNull(testingTarget, "Should be not null");
424             Assert.IsInstanceOf<PropertyNotification.NotifyEventArgs>(testingTarget, "Should be an instance of PropertyNotification.PropertyNotificationNotifyEventArgs");
425
426             testingTarget.PropertyNotification = dummy;
427             Assert.AreEqual(13, testingTarget.PropertyNotification.GetTargetProperty(), "Should be equal!");
428
429             dummy.Dispose();
430             view.Dispose();
431
432             tlog.Debug(tag, $"PropertyNotificationNotifyEventArgsGetTargetProperty END (OK)");
433         }
434     }
435 }