[NUI] Add Application(Internal & Public) TCs.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.TCT / 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         private bool IsWearable()
20         {
21             string value;
22             var result = Tizen.System.Information.TryGetValue("tizen.org/feature/profile", out value);
23             if (result && value.Equals("wearable"))
24             {
25                 return true;
26             }
27
28             return false;
29         }
30
31         [SetUp]
32         public void Init()
33         {
34             tlog.Info(tag, "Init() is called!");
35         }
36
37         [TearDown]
38         public void Destroy()
39         {
40             tlog.Info(tag, "Destroy() is called!");
41         }
42
43         [Test]
44         [Description("WatchApplication new")]
45         [Property("AUTHOR", "guowei.wang@samsung.com")]
46         public void WatchApplicationNew()
47         {
48             tlog.Debug(tag, $"WatchApplicationNew START");
49
50             if (IsWearable())
51             {
52                 var testingTarget = Tizen.NUI.WatchApplication.New();
53                 Assert.IsNotNull(testingTarget, "should be not null");
54                 Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
55
56                 testingTarget.Dispose();
57                 tlog.Debug(tag, $"WatchApplicationNew END (OK)");
58             }
59             else
60             {
61                 tlog.Debug(tag, $"WatchApplicationNew END (OK)");
62                 Assert.Pass("Not Supported profile");
63             }
64         }
65
66         [Test]
67         [Description("WatchApplication new with strings")]
68         [Property("AUTHOR", "guowei.wang@samsung.com")]
69         public void WatchApplicationNewWithStrings()
70         {
71             tlog.Debug(tag, $"WatchApplicationNewWithStrings START");
72
73             if (IsWearable())
74             {
75                 var dummy = new string[3];
76                 var testingTarget = Tizen.NUI.WatchApplication.New(dummy);
77                 Assert.IsNotNull(testingTarget, "should be not null");
78                 Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
79
80                 testingTarget.Dispose();
81                 tlog.Debug(tag, $"WatchApplicationNewWithStrings END (OK)");
82             }
83             else
84             {
85                 tlog.Debug(tag, $"WatchApplicationNewWithStrings END (OK)");
86                 Assert.Pass("Not Supported profile");
87             }
88         }
89
90         [Test]
91         [Description("WatchApplication new with strings and stylesheet")]
92         [Property("AUTHOR", "guowei.wang@samsung.com")]
93         public void WatchApplicationNewWithStringsAndStylesheet()
94         {
95             tlog.Debug(tag, $"WatchApplicationNewWithStringsAndStylesheet START");
96
97             if (IsWearable())
98             {
99                 var args = new string[] { "Dali-demo" };
100                 var stylesheet = resource + "/style/Test_Style_Manager.json";
101                 var testingTarget = Tizen.NUI.WatchApplication.New(args, stylesheet);
102                 Assert.IsNotNull(testingTarget, "should be not null");
103                 Assert.IsInstanceOf<WatchApplication>(testingTarget, "should be an instance of testing target class!");
104
105                 testingTarget.Dispose();
106                 tlog.Debug(tag, $"WatchApplicationNewWithStringsAndStylesheet END (OK)");
107             }
108             else
109             {
110                 tlog.Debug(tag, $"WatchApplicationNewWithStringsAndStylesheet END (OK)");
111                 Assert.Pass("Not Supported profile");
112             }
113         }
114
115         [Test]
116         [Description("WatchApplication TimeTickEventArgs:Application get")]
117         [Property("AUTHOR", "guowei.wang@samsung.com")]
118         public void WatchApplicationTimeTickEventArgsApplicationGet()
119         {
120             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplicationGet START");
121
122             if (IsWearable())
123             {
124                 TimeTickEventArgs dummy = new TimeTickEventArgs();
125                 var testingTarget = dummy.Application;
126                 Assert.IsNotNull(testingTarget, "should be not null");
127                 Assert.IsInstanceOf<Application>(testingTarget, "should be an instance of testing target class!");
128
129                 testingTarget.Dispose();
130                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplicationGet END (OK)");
131             }
132             else
133             {
134                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplicationGet END (OK)");
135                 Assert.Pass("Not Supported profile");
136             }
137         }
138
139         [Test]
140         [Description("WatchApplication TimeTickEventArgs:Application set")]
141         [Property("AUTHOR", "guowei.wang@samsung.com")]
142         public void WatchApplicationTimeTickEventArgsApplicationSet()
143         {
144             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplicationSet START");
145
146             if (IsWearable())
147             {
148                 var dummyApplication = new Application();
149                 Assert.IsNotNull(dummyApplication, "should be not null");
150                 Assert.IsInstanceOf<Application>(dummyApplication, "should be an instance of testing target class!");
151
152                 TimeTickEventArgs testingTarget = new TimeTickEventArgs();
153                 testingTarget.Application = dummyApplication;
154
155                 var result = testingTarget.Application;
156                 Assert.IsNotNull(result, "should be not null.");
157                 Assert.AreEqual(dummyApplication, result, "Retrieved result should be equal to dummyApplication. ");
158
159                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplicationSet END (OK)");
160             }
161             else
162             {
163                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsApplicationSet END (OK)");
164                 Assert.Pass("Not Supported profile");
165             }
166         }
167
168         [Test]
169         [Description("WatchApplication TimeTickEventArgs:WatchTime get")]
170         [Property("AUTHOR", "guowei.wang@samsung.com")]
171         public void WatchApplicationTimeTickEventArgsWatchTimeGet()
172         {
173             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTimeGet START");
174
175             if (IsWearable())
176             {
177                 TimeTickEventArgs dummy = new TimeTickEventArgs();
178                 var testingTarget = dummy.WatchTime;
179                 Assert.IsNotNull(testingTarget, "should be not null");
180                 Assert.IsInstanceOf<WatchTime>(testingTarget, "should be an instance of testing target class!");
181
182                 testingTarget.Dispose();
183                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTimeGet END (OK)");
184             }
185             else
186             {
187                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTimeGet END (OK)");
188                 Assert.Pass("Not Supported profile");
189             }
190         }
191
192         [Test]
193         [Description("WatchApplication TimeTickEventArgs:WatchTime set")]
194         [Property("AUTHOR", "guowei.wang@samsung.com")]
195         public void WatchApplicationTimeTickEventArgsWatchTimeSet()
196         {
197             tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTimeSet START");
198
199             if (IsWearable())
200             {
201                 var dummyWatchTime = new WatchTime();
202                 Assert.IsNotNull(dummyWatchTime, "should be not null");
203                 Assert.IsInstanceOf<WatchTime>(dummyWatchTime, "should be an instance of testing target class!");
204
205                 TimeTickEventArgs testingTarget = new TimeTickEventArgs();
206                 testingTarget.WatchTime = dummyWatchTime;
207
208                 var result = testingTarget.WatchTime;
209                 Assert.IsNotNull(result, "should be not null.");
210                 Assert.AreEqual(dummyWatchTime, result, "Retrieved result should be equal to dummyApplication. ");
211
212                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTimeSet END (OK)");
213             }
214             else
215             {
216                 tlog.Debug(tag, $"WatchApplicationTimeTickEventArgsWatchTimeSet END (OK)");
217                 Assert.Pass("Not Supported profile");
218             }
219         }
220
221         [Test]
222         [Description("WatchApplication AmbientTickEventArgs:Application get")]
223         [Property("AUTHOR", "guowei.wang@samsung.com")]
224         public void WatchApplicationAmbientTickEventArgsApplicationGet()
225         {
226             tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplicationGet START");
227
228             if (IsWearable())
229             {
230                 AmbientTickEventArgs dummy = new AmbientTickEventArgs();
231                 var testingTarget = dummy.Application;
232                 Assert.IsNotNull(testingTarget, "should be not null");
233                 Assert.IsInstanceOf<Application>(testingTarget, "should be an instance of testing target class!");
234
235                 testingTarget.Dispose();
236                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplicationGet END (OK)");
237             }
238             else
239             {
240                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplicationGet END (OK)");
241                 Assert.Pass("Not Supported profile");
242             }
243         }
244
245         [Test]
246         [Description("WatchApplication AmbientTickEventArgs:Application set")]
247         [Property("AUTHOR", "guowei.wang@samsung.com")]
248         public void WatchApplicationAmbientTickEventArgsApplicationSet()
249         {
250             tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplicationSet START");
251
252             if (IsWearable())
253             {
254                 var application = new Application();
255                 Assert.IsNotNull(application, "should be not null");
256                 Assert.IsInstanceOf<Application>(application, "should be an instance of testing target class!");
257
258                 AmbientTickEventArgs testingTarget = new AmbientTickEventArgs();
259                 testingTarget.Application = application;
260
261                 var result = testingTarget.Application;
262                 Assert.IsNotNull(result, "should be not null.");
263                 Assert.AreEqual(application, result, "Retrieved result should be equal to dummyApplication. ");
264
265                 application.Dispose();
266                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplicationSet END (OK)");
267             }
268             else
269             {
270                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsApplicationSet END (OK)");
271                 Assert.Pass("Not Supported profile");
272             }
273         }
274
275         [Test]
276         [Description("WatchApplication AmbientTickEventArgs:WatchTime get")]
277         [Property("AUTHOR", "guowei.wang@samsung.com")]
278         public void WatchApplicationAmbientTickEventArgsWatchTimeGet()
279         {
280             tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsWatchTimeGet START");
281
282             if (IsWearable())
283             {
284                 AmbientTickEventArgs dummy = new AmbientTickEventArgs();
285                 var testingTarget = dummy.WatchTime;
286                 Assert.IsNotNull(testingTarget, "should be not null");
287                 Assert.IsInstanceOf<WatchTime>(testingTarget, "should be an instance of testing target class!");
288
289                 testingTarget.Dispose();
290                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsWatchTimeGet END (OK)");
291             }
292             else
293             {
294                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsWatchTimeGet END (OK)");
295                 Assert.Pass("Not Supported profile");
296             }
297         }
298
299         [Test]
300         [Description("WatchApplication AmbientTickEventArgs:WatchTime set")]
301         [Property("AUTHOR", "guowei.wang@samsung.com")]
302         public void WatchApplicationAmbientTickEventArgsWatchTimeSet()
303         {
304             tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsWatchTimeSet START");
305
306             if (IsWearable())
307             {
308                 var dummyWatchTime = new WatchTime();
309                 Assert.IsNotNull(dummyWatchTime, "should be not null");
310                 Assert.IsInstanceOf<WatchTime>(dummyWatchTime, "should be an instance of testing target class!");
311
312                 AmbientTickEventArgs testingTarget = new AmbientTickEventArgs();
313                 testingTarget.WatchTime = dummyWatchTime;
314
315                 var result = testingTarget.WatchTime;
316                 Assert.IsNotNull(result, "should be not null.");
317                 Assert.AreEqual(dummyWatchTime, result, "Retrieved result should be equal to dummyApplication. ");
318
319                 dummyWatchTime.Dispose();
320                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsWatchTimeSet END (OK)");
321             }
322             else
323             {
324                 tlog.Debug(tag, $"WatchApplicationAmbientTickEventArgsWatchTimeSet END (OK)");
325                 Assert.Pass("Not Supported profile");
326             }
327         }
328
329         [Test]
330         [Description("WatchApplication AmbientChangedEventArgs:Application get")]
331         [Property("AUTHOR", "guowei.wang@samsung.com")]
332         public void WatchApplicationAmbientChangedEventArgsApplicationGet()
333         {
334             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplicationGet START");
335
336             if (IsWearable())
337             {
338                 AmbientChangedEventArgs dummy = new AmbientChangedEventArgs();
339                 var testingTarget = dummy.Application;
340                 Assert.IsNotNull(testingTarget, "should be not null");
341                 Assert.IsInstanceOf<Application>(testingTarget, "should be an instance of testing target class!");
342
343                 testingTarget.Dispose();
344                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplicationGet END (OK)");
345             }
346             else
347             {
348                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplicationGet END (OK)");
349                 Assert.Pass("Not Supported profile");
350             }
351         }
352
353         [Test]
354         [Description("WatchApplication AmbientChangedEventArgs:Application set")]
355         [Property("AUTHOR", "guowei.wang@samsung.com")]
356         public void WatchApplicationAmbientChangedEventArgsApplicationSet()
357         {
358             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplicationSet START");
359
360             if (IsWearable())
361             {
362                 var dummyApplication = new Application();
363                 Assert.IsNotNull(dummyApplication, "should be not null");
364                 Assert.IsInstanceOf<Application>(dummyApplication, "should be an instance of testing target class!");
365
366                 AmbientChangedEventArgs testingTarget = new AmbientChangedEventArgs();
367                 testingTarget.Application = dummyApplication;
368
369                 var result = testingTarget.Application;
370                 Assert.IsNotNull(result, "should be not null.");
371                 Assert.AreEqual(dummyApplication, result, "Retrieved result should be equal to dummyApplication. ");
372
373                 dummyApplication.Dispose();
374                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplicationSet END (OK)");
375             }
376             else
377             {
378                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsApplicationSet END (OK)");
379                 Assert.Pass("Not Supported profile");
380             }
381         }
382
383         [Test]
384         [Description("WatchApplication AmbientChangedEventArgs:Changed get")]
385         [Property("AUTHOR", "guowei.wang@samsung.com")]
386         public void WatchApplicationAmbientChangedEventArgsChangedGet()
387         {
388             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedGet START");
389
390             if (IsWearable())
391             {
392                 AmbientChangedEventArgs testingTarget = new AmbientChangedEventArgs();
393                 var result = testingTarget.Changed;
394                 Assert.IsNotNull(result, "should be not null");
395
396                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedGet END (OK)");
397             }
398             else
399             {
400                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedGet END (OK)");
401                 Assert.Pass("Not Supported profile");
402             }
403         }
404
405         [Test]
406         [Description("WatchApplication AmbientChangedEventArgs:Changed set")]
407         [Property("AUTHOR", "guowei.wang@samsung.com")]
408         public void WatchApplicationAmbientChangedEventArgsChangedSet()
409         {
410             tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedSet START");
411
412             if (IsWearable())
413             {
414                 AmbientChangedEventArgs testingTarget = new AmbientChangedEventArgs();
415                 testingTarget.Changed = true;
416
417                 var result = testingTarget.Changed;
418                 Assert.IsNotNull(result, "should be not null.");
419                 Assert.AreEqual(true, result, "Retrieved result should be equal to true. ");
420                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedSet END (OK)");
421             }
422             else
423             {
424                 tlog.Debug(tag, $"WatchApplicationAmbientChangedEventArgsChangedSet END (OK)");
425                 Assert.Pass("Not Supported profile");
426             }
427         }
428     }
429 }