27d1e4396e812fce77575cf3890c9b6f6fc22435
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Application / TSWatchApplication.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 static Tizen.NUI.WatchApplication;
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("internal/Application/WatchApplication")]
14     public class InternalWatchApplicationTest
15     {
16         private const string tag = "NUITEST";
17         private string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
18
19         internal class MyWatchApplication : WatchApplication
20         {
21             public MyWatchApplication(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
22             { }
23
24             public void OnReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
25             {
26                 base.ReleaseSwigCPtr(swigCPtr);
27             }
28         }
29
30         private bool IsWearable()
31         {
32             string value;
33             var result = Tizen.System.Information.TryGetValue("tizen.org/feature/profile", out value);
34             if (result && value.Equals("wearable"))
35             {
36                 return true;
37             }
38
39             return false;
40         }
41
42         [SetUp]
43         public void Init()
44         {
45             tlog.Info(tag, "Init() is called!");
46         }
47
48         [TearDown]
49         public void Destroy()
50         {
51             tlog.Info(tag, "Destroy() is called!");
52         }
53
54         [Test]
55         [Category("P1")]
56         [Description("WatchApplication constructor.")]
57         [Property("SPEC", "Tizen.NUI.WatchApplication.WatchApplication C")]
58         [Property("SPEC_URL", "-")]
59         [Property("CRITERIA", "CONSTR")]
60         [Property("AUTHOR", "guowei.wang@samsung.com")]
61         public void WatchApplicationConstructor()
62         {
63             tlog.Debug(tag, $"WatchApplicationConstructor START");
64
65             using (ImageView imageView = new ImageView())
66             {
67                 var testingTarget = new WatchApplication(imageView.SwigCPtr.Handle, false);
68                 Assert.IsNotNull(testingTarget, "should be not null");
69                 Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
70
71                 testingTarget.Dispose();
72             }
73
74             tlog.Debug(tag, $"WatchApplicationConstructor END (OK)");
75         }
76
77         //[Test]
78         //[Category("P1")]
79         //[Description("WatchApplication constructor. With WatchApplication.")]
80         //[Property("SPEC", "Tizen.NUI.WatchApplication.WatchApplication C")]
81         //[Property("SPEC_URL", "-")]
82         //[Property("CRITERIA", "CONSTR")]
83         //[Property("AUTHOR", "guowei.wang@samsung.com")]
84         //public void WatchApplicationConstructorWithApplication()
85         //{
86         //    tlog.Debug(tag, $"WatchApplicationConstructorWithApplication START");
87
88         //    using (ImageView imageView = new ImageView())
89         //    {
90         //        WatchApplication watchApplication = new WatchApplication(imageView.SwigCPtr.Handle, false);
91         //        Assert.IsNotNull(watchApplication, "should be not null");
92         //        Assert.IsInstanceOf<WatchApplication>(watchApplication, "should be an instance of testing target class!");
93
94         //        try
95         //        {
96         //            new WatchApplication(watchApplication);
97         //        }
98         //        catch (Exception e)
99         //        {
100         //            /** Unable to find an entry point named 'CSharp_Dali_new_WatchApplication__SWIG_1' in shared library 'libdali2-csharp-binder.so' */
101         //            tlog.Debug(tag, e.Message.ToString());
102         //            Assert.Fail("Caught Exception: Failed!");
103         //        }
104
105         //        watchApplication.Dispose();
106         //    }
107
108         //    tlog.Debug(tag, $"WatchApplicationConstructorWithApplication END (OK)");
109         //}
110
111         [Test]
112         [Category("P1")]
113         [Description("WatchApplication.TimeTickEventArgs. Application.")]
114         [Property("SPEC", "Tizen.NUI.WatchApplication.TimeTickEventArgs.Application A")]
115         [Property("SPEC_URL", "-")]
116         [Property("CRITERIA", "PRW")]
117         [Property("AUTHOR", "guowei.wang@samsung.com")]
118         public void WatchApplicationTimeTickEventArgsApplication()
119         {
120             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplication START");
121
122             var testingTarget = new TimeTickEventArgs();
123             Assert.IsNotNull(testingTarget, "should be not null");
124             Assert.IsInstanceOf<TimeTickEventArgs>(testingTarget, "should be an instance of testing target class!");
125
126             Widget widget = new Widget();
127             var application = new WidgetApplication(widget.GetIntPtr(), false);
128             testingTarget.Application = application;
129             Assert.IsNotNull(testingTarget.Application, "should be not null.");
130
131             widget.Dispose();
132             widget = null;
133             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplication END (OK)");
134         }
135
136         [Test]
137         [Category("P1")]
138         [Description("WatchApplication.TimeTickEventArgs. WatchTime.")]
139         [Property("SPEC", "Tizen.NUI.WatchApplication.TimeTickEventArgs.WatchTime A")]
140         [Property("SPEC_URL", "-")]
141         [Property("CRITERIA", "PRW")]
142         [Property("AUTHOR", "guowei.wang@samsung.com")]
143         public void WatchApplicationTimeTickEventArgsWatchTime()
144         {
145             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTime START");
146
147             var testingTarget = new TimeTickEventArgs();
148             Assert.IsNotNull(testingTarget, "should be not null");
149             Assert.IsInstanceOf<TimeTickEventArgs>(testingTarget, "should be an instance of testing target class!");
150
151             Widget widget = new Widget();
152             using (WatchTime time = new WatchTime(widget.GetIntPtr(), false))
153             {
154                 testingTarget.WatchTime = time;
155                 Assert.IsNotNull(testingTarget.WatchTime);
156             }
157
158             widget.Dispose();
159             widget = null;
160             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTime END (OK)");
161         }
162
163         //[Test]
164         //[Category("P1")]
165         //[Description("WatchApplication.TimeTick.")]
166         //[Property("SPEC", "Tizen.NUI.WatchApplication.TimeTick A")]
167         //[Property("SPEC_URL", "-")]
168         //[Property("CRITERIA", "PRW")]
169         //[Property("AUTHOR", "guowei.wang@samsung.com")]
170         //public void WatchApplicationTimeTick()
171         //{
172         //    tlog.Debug(tag, $"WatchApplicationTimeTick START");
173
174         //    using (ImageView imageView = new ImageView())
175         //    {
176         //        var testingTarget = new WatchApplication(imageView.SwigCPtr.Handle, false);
177         //        Assert.IsNotNull(testingTarget, "should be not null");
178         //        Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
179
180         //        /** Unable to find an entry point named 'CSharp_Dali_WatchApplication_TimeTickSignal' in shared library 'libdali2-csharp-binder.so' */
181         //        testingTarget.TimeTick += MyOnTimeTick;
182         //        testingTarget.TimeTick -= MyOnTimeTick;
183
184         //        testingTarget.Dispose();
185         //    }
186
187         //    tlog.Debug(tag, $"WatchApplicationTimeTick END (OK)");
188         //}
189
190         //[Test]
191         //[Category("P1")]
192         //[Description("WatchApplication.TimeTickSignal.")]
193         //[Property("SPEC", "Tizen.NUI.WatchApplication.TimeTickSignal A")]
194         //[Property("SPEC_URL", "-")]
195         //[Property("CRITERIA", "PRW")]
196         //[Property("AUTHOR", "guowei.wang@samsung.com")]
197         //public void WatchApplicationTimeTickSignal()
198         //{
199         //    tlog.Debug(tag, $"WatchApplicationTimeTickSignal START");
200
201         //    using (ImageView imageView = new ImageView())
202         //    {
203         //        var testingTarget = new WatchApplication(imageView.SwigCPtr.Handle, false);
204         //        Assert.IsNotNull(testingTarget, "should be not null");
205         //        Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
206
207         //        try
208         //        {
209         //            testingTarget.TimeTickSignal();
210         //        }
211         //        catch (Exception e)
212         //        {
213         //            /** Unable to find an entry point named 'CSharp_Dali_WatchApplication_TimeTickSignal' in shared library 'libdali2-csharp-binder.so' */
214         //            tlog.Debug(tag, e.Message.ToString());
215         //            Assert.Fail("Caught Exception: Failed!");
216         //        }
217         //    }
218
219         //    tlog.Debug(tag, $"WatchApplicationTimeTickSignal END (OK)");
220         //}
221
222         private void MyOnTimeTick(object sender, TimeTickEventArgs e) { }
223
224         [Test]
225         [Category("P1")]
226         [Description("WatchApplication.AmbientTickEventArgs. Application.")]
227         [Property("SPEC", "Tizen.NUI.WatchApplication.TimeTickEventArgs.Application A")]
228         [Property("SPEC_URL", "-")]
229         [Property("CRITERIA", "PRW")]
230         [Property("AUTHOR", "guowei.wang@samsung.com")]
231         public void WatchApplicationAmbientTickEventArgsApplication()
232         {
233             tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplication START");
234
235             var testingTarget = new AmbientTickEventArgs();
236             Assert.IsNotNull(testingTarget, "should be not null");
237             Assert.IsInstanceOf<AmbientTickEventArgs>(testingTarget, "should be an instance of AmbientTickEventArgs class!");
238
239             Widget widget = new Widget();
240             var application = new WidgetApplication(widget.GetIntPtr(), false);
241             testingTarget.Application = application;
242             Assert.IsNotNull(testingTarget.Application, "should be not null.");
243
244             widget.Dispose();
245             widget = null;
246             tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplication END (OK)");
247         }
248
249         [Test]
250         [Category("P1")]
251         [Description("WatchApplication.AmbientTickEventArgs.WatchTime")]
252         [Property("SPEC", "Tizen.NUI.WatchApplication.AmbientTickEventArgs.WatchTime A")]
253         [Property("SPEC_URL", "-")]
254         [Property("CRITERIA", "PRW")]
255         [Property("AUTHOR", "guowei.wang@samsung.com")]
256         public void WatchApplicationAmbientTickArgsWatchTime()
257         {
258             tlog.Debug(tag, $"WatchApplicationAmbientTickArgsWatchTime START");
259
260             var testingTarget = new AmbientTickEventArgs();
261             Assert.IsNotNull(testingTarget, "should be not null");
262             Assert.IsInstanceOf<AmbientTickEventArgs>(testingTarget, "should be an instance of testing target class!");
263
264             Widget widget = new Widget();
265             using (WatchTime time = new WatchTime(widget.GetIntPtr(), false))
266             {
267                 testingTarget.WatchTime = time;
268                 Assert.IsNotNull(testingTarget.WatchTime);
269             }
270
271             widget.Dispose();
272             widget = null;
273             tlog.Debug(tag, $"WatchApplicationAmbientTickArgsWatchTime END (OK)");
274         }
275
276         //[Test]
277         //[Category("P1")]
278         //[Description("WatchApplication.AmbientTick.")]
279         //[Property("SPEC", "Tizen.NUI.WatchApplication.AmbientTick A")]
280         //[Property("SPEC_URL", "-")]
281         //[Property("CRITERIA", "PRW")]
282         //[Property("AUTHOR", "guowei.wang@samsung.com")]
283         //public void WatchApplicationAmbientTick()
284         //{
285         //    tlog.Debug(tag, $"WatchApplicationAmbientTick START");
286
287         //    using (ImageView imageView = new ImageView())
288         //    {
289         //        var testingTarget = new WatchApplication(imageView.SwigCPtr.Handle, false);
290         //        Assert.IsNotNull(testingTarget, "should be not null");
291         //        Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
292
293         //        /** Unable to find an entry point named 'CSharp_Dali_WatchApplication_AmbientTickSignal' in shared library 'libdali2-csharp-binder.so' */
294         //        testingTarget.AmbientTick += MyOnAmbientTick;
295         //        testingTarget.AmbientTick -= MyOnAmbientTick;
296
297         //        testingTarget.Dispose();
298         //    }
299
300         //    tlog.Debug(tag, $"WatchApplicationAmbientTick END (OK)");
301         //}
302
303         //private void MyOnAmbientTick(object sender, AmbientTickEventArgs e) { }
304
305         //[Test]
306         //[Category("P1")]
307         //[Description("WatchApplication.AmbientTickSignal.")]
308         //[Property("SPEC", "Tizen.NUI.WatchApplication.AmbientTickSignal A")]
309         //[Property("SPEC_URL", "-")]
310         //[Property("CRITERIA", "PRW")]
311         //[Property("AUTHOR", "guowei.wang@samsung.com")]
312         //public void WatchApplicationAmbientTickSignal()
313         //{
314         //    tlog.Debug(tag, $"WatchApplicationAmbientTickSignal START");
315
316         //    using (ImageView imageView = new ImageView())
317         //    {
318         //        var testingTarget = new WatchApplication(imageView.SwigCPtr.Handle, false);
319         //        Assert.IsNotNull(testingTarget, "should be not null");
320         //        Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
321
322         //        try
323         //        {
324         //            testingTarget.AmbientTickSignal();
325         //        }
326         //        catch (Exception e)
327         //        {
328         //            /** Unable to find an entry point named 'CSharp_Dali_WatchApplication_AmbientTickSignal' in shared library 'libdali2-csharp-binder.so' */
329         //            tlog.Debug(tag, e.Message.ToString());
330         //            Assert.Fail("Caught Exception: Failed!");
331         //        }
332         //    }
333
334         //    tlog.Debug(tag, $"WatchApplicationAmbientTickSignal END (OK)");
335         //}
336
337         [Test]
338         [Category("P1")]
339         [Description("WatchApplication.AmbientChangedEventArgs. Application.")]
340         [Property("SPEC", "Tizen.NUI.WatchApplication.TimeTickEventArgs.WatchTime A")]
341         [Property("SPEC_URL", "-")]
342         [Property("CRITERIA", "PRW")]
343         [Property("AUTHOR", "guowei.wang@samsung.com")]
344         public void WatchApplicationAmbientChangedEventArgsApplication()
345         {
346             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplication START");
347
348             var testingTarget = new AmbientChangedEventArgs();
349             Assert.IsNotNull(testingTarget, "should be not null");
350             Assert.IsInstanceOf<AmbientChangedEventArgs>(testingTarget, "should be an instance of AmbientChangedEventArgs class!");
351
352             Widget widget = new Widget();
353             var application = new WidgetApplication(widget.GetIntPtr(), false);
354             testingTarget.Application = application;
355             Assert.IsNotNull(testingTarget.Application, "should be not null.");
356
357             widget.Dispose();
358             widget = null;
359             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplication END (OK)");
360         }
361
362         [Test]
363         [Category("P1")]
364         [Description("WatchApplication.AmbientChangedEventArgs. Changed.")]
365         [Property("SPEC", "Tizen.NUI.WatchApplication.AmbientChangedEventArgs.Changed A")]
366         [Property("SPEC_URL", "-")]
367         [Property("CRITERIA", "PRW")]
368         [Property("AUTHOR", "guowei.wang@samsung.com")]
369         public void WatchApplicationAmbientChangedEventArgsChangedSet()
370         {
371             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedSet START");
372
373             var testingTarget = new AmbientChangedEventArgs();
374             Assert.IsNotNull(testingTarget, "should be not null");
375             Assert.IsInstanceOf<AmbientChangedEventArgs>(testingTarget, "should be an instance of AmbientChangedEventArgs class!");
376
377             testingTarget.Changed = true;
378             Assert.AreEqual(true, testingTarget.Changed, "Retrieved result should be equal to true. ");
379
380             testingTarget.Changed = false;
381             Assert.AreEqual(false, testingTarget.Changed, "Retrieved result should be equal to true. ");
382
383             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedSet END (OK)");
384         }
385
386         //[Test]
387         //[Category("P1")]
388         //[Description("WatchApplication.AmbientChanged.")]
389         //[Property("SPEC", "Tizen.NUI.WatchApplication.AmbientChanged A")]
390         //[Property("SPEC_URL", "-")]
391         //[Property("CRITERIA", "PRW")]
392         //[Property("AUTHOR", "guowei.wang@samsung.com")]
393         //public void WatchApplicationAmbientChanged()
394         //{
395         //    tlog.Debug(tag, $"WatchApplicationAmbientChanged START");
396
397         //    using (ImageView imageView = new ImageView())
398         //    {
399         //        var testingTarget = new WatchApplication(imageView.SwigCPtr.Handle, false);
400         //        Assert.IsNotNull(testingTarget, "should be not null");
401         //        Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
402
403         //        /** Unable to find an entry point named 'CSharp_Dali_WatchApplication_AmbientChangedSignal' in shared library 'libdali2-csharp-binder.so' */
404         //        testingTarget.AmbientChanged += MyOnAmbientChanged;
405         //        testingTarget.AmbientChanged -= MyOnAmbientChanged;
406
407         //        testingTarget.Dispose();
408         //    }
409
410         //    tlog.Debug(tag, $"WatchApplicationAmbientChanged END (OK)");
411         //}
412
413         //private void MyOnAmbientChanged(object sender, AmbientChangedEventArgs e) { }
414
415         //[Test]
416         //[Category("P1")]
417         //[Description("WatchApplication.AmbientChangedSignal.")]
418         //[Property("SPEC", "Tizen.NUI.WatchApplication.AmbientChangedSignal A")]
419         //[Property("SPEC_URL", "-")]
420         //[Property("CRITERIA", "PRW")]
421         //[Property("AUTHOR", "guowei.wang@samsung.com")]
422         //public void WatchApplicationAmbientChangedSignal()
423         //{
424         //    tlog.Debug(tag, $"WatchApplicationAmbientChangedSignal START");
425
426         //    using (ImageView imageView = new ImageView())
427         //    {
428         //        var testingTarget = new WatchApplication(imageView.SwigCPtr.Handle, false);
429         //        Assert.IsNotNull(testingTarget, "should be not null");
430         //        Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
431
432         //        try
433         //        {
434         //            testingTarget.AmbientChangedSignal();
435         //        }
436         //        catch (Exception e)
437         //        {
438         //            /** Unable to find an entry point named 'CSharp_Dali_WatchApplication_AmbientChangedSignal' in shared library 'libdali2-csharp-binder.so' */
439         //            tlog.Debug(tag, e.Message.ToString());
440         //            Assert.Fail("Caught Exception: Failed!");
441         //        }
442         //    }
443
444         //    tlog.Debug(tag, $"WatchApplicationAmbientChangedSignal END (OK)");
445         //}
446     }
447 }