Release 9.0.0.16429
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Application / TSWatchTimeSignal.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 namespace Tizen.NUI.Devel.Tests
7 {
8     using tlog = Tizen.Log;
9
10     [TestFixture]
11     [Description("internal/Application/WatchTimeSignal")]
12     public class InternalWatchTimeSignalTest
13     {
14         private const string tag = "NUITEST";
15         private delegate bool dummyCallback(IntPtr application);
16         private bool OnDummyCallback(IntPtr data)
17         {
18             return false;
19         }
20
21         private bool IsWearable()
22         {
23             string value;
24             var result = Tizen.System.Information.TryGetValue("tizen.org/feature/profile", out value);
25             if (result && value.Equals("wearable"))
26             {
27                 return true;
28             }
29
30             return false;
31         }
32
33         [SetUp]
34         public void Init()
35         {
36             tlog.Info(tag, "Init() is called!");
37         }
38
39         [TearDown]
40         public void Destroy()
41         {
42             tlog.Info(tag, "Destroy() is called!");
43         }
44
45         [Test]
46         [Description("WatchTimeSignal constructor")]
47         [Property("AUTHOR", "guowei.wang@samsung.com")]
48         public void WatchTimeSignalConstructor()
49         {
50             tlog.Debug(tag, $"WatchTimeSignalConstructor START");
51
52             if (IsWearable())
53             {
54                 var testingTarget = new WatchTimeSignal();
55
56                 Assert.IsNotNull(testingTarget, "should be not null");
57                 Assert.IsInstanceOf<WatchTimeSignal>(testingTarget, "should be an instance of testing target class!");
58
59                 testingTarget.Dispose();
60                 tlog.Debug(tag, $"WatchTimeSignalConstructor END (OK)");
61             }
62             else
63             {
64                 tlog.Debug(tag, $"WatchTimeSignalConstructor END (OK)");
65                 Assert.Pass("Not Supported profile");
66             }
67         }
68
69         [Test]
70         [Description("WatchTimeSignal Empty")]
71         [Property("AUTHOR", "guowei.wang@samsung.com")]
72         public void WatchTimeSignalEmpty()
73         {
74             tlog.Debug(tag, $"WatchTimeSignalEmpty START");
75
76             if (IsWearable())
77             {
78                 var testingTarget = new WatchTimeSignal();
79                 Assert.IsNotNull(testingTarget, "should be not null");
80                 Assert.IsInstanceOf<WatchTimeSignal>(testingTarget, "should be an instance of testing target class!");
81
82                 var result = testingTarget.Empty();
83                 Assert.IsTrue(result);
84
85                 testingTarget.Dispose();
86                 tlog.Debug(tag, $"WatchTimeSignalEmpty END (OK)");
87             }
88             else
89             {
90                 tlog.Debug(tag, $"WatchTimeSignalEmpty END (OK)");
91                 Assert.Pass("Not Supported profile");
92             }
93         }
94
95         [Test]
96         [Description("WatchTimeSignal GetConnectionCount")]
97         [Property("AUTHOR", "guowei.wang@samsung.com")]
98         public void WatchTimeSignalGetConnectionCount()
99         {
100             tlog.Debug(tag, $"WatchTimeSignalGetConnectionCount START");
101
102             if (IsWearable())
103             {
104                 var testingTarget = new WatchTimeSignal();
105                 Assert.IsNotNull(testingTarget, "should be not null");
106                 Assert.IsInstanceOf<WatchTimeSignal>(testingTarget, "should be an instance of testing target class!");
107
108                 var result = testingTarget.GetConnectionCount();
109                 Assert.IsTrue(result == 0, "result should be 0");
110
111                 testingTarget.Dispose();
112                 tlog.Debug(tag, $"WatchTimeSignalGetConnectionCount END (OK)");
113             }
114             else
115             {
116                 tlog.Debug(tag, $"WatchTimeSignalGetConnectionCount END (OK)");
117                 Assert.Pass("Not Supported profile");
118             }
119         }
120
121         [Test]
122         [Description("WatchTimeSignal Connection")]
123         [Property("AUTHOR", "guowei.wang@samsung.com")]
124         public void WatchTimeSignalConnection()
125         {
126             tlog.Debug(tag, $"WatchTimeSignalConnection START");
127
128             if (IsWearable())
129             {
130                 var testingTarget = new WatchTimeSignal();
131                 Assert.IsNotNull(testingTarget, "should be not null");
132                 Assert.IsInstanceOf<WatchTimeSignal>(testingTarget, "should be an instance of testing target class!");
133
134                 dummyCallback callback = OnDummyCallback;
135                 testingTarget.Connect(callback);
136                 testingTarget.Disconnect(callback);
137                 testingTarget.Dispose();
138                 tlog.Debug(tag, $"WatchTimeSignalConnection END (OK)");
139             }
140             else
141             {
142                 tlog.Debug(tag, $"WatchTimeSignalConnection END (OK)");
143                 Assert.Pass("Not Supported profile");
144             }
145         }
146
147         [Test]
148         [Description("WatchTimeSignal Disconnection")]
149         [Property("AUTHOR", "guowei.wang@samsung.com")]
150         public void WatchTimeSignalDisconnection()
151         {
152             tlog.Debug(tag, $"WatchTimeSignalDisconnection START");
153
154             if (IsWearable())
155             {
156                 var testingTarget = new WatchTimeSignal();
157                 Assert.IsNotNull(testingTarget, "should be not null");
158                 Assert.IsInstanceOf<WatchTimeSignal>(testingTarget, "should be an instance of testing target class!");
159
160                 dummyCallback callback = OnDummyCallback;
161                 testingTarget.Connect(callback);
162                 testingTarget.Disconnect(callback);
163                 testingTarget.Dispose();
164                 tlog.Debug(tag, $"WatchTimeSignalDisconnection END (OK)");
165             }
166             else
167             {
168                 tlog.Debug(tag, $"WatchTimeSignalDisconnection END (OK)");
169                 Assert.Pass("Not Supported profile");
170             }
171         }
172
173         [Test]
174         [Description("WatchTimeSignal Emit")]
175         [Property("AUTHOR", "guowei.wang@samsung.com")]
176         public void WatchTimeSignalEmit()
177         {
178             tlog.Debug(tag, $"WatchTimeSignalEmit START");
179
180             if (IsWearable())
181             {
182                 var currentPid = global::System.Diagnostics.Process.GetCurrentProcess().Id;
183                 var currentTid = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
184
185                 tlog.Debug(tag, $"thread check! main pid={App.mainPid}, current pid={currentPid}, main tid={App.mainTid}, current tid={currentTid}");
186
187                 var testingTarget = new WatchTimeSignal();
188                 Assert.IsNotNull(testingTarget, "should be not null");
189                 Assert.IsInstanceOf<WatchTimeSignal>(testingTarget, "should be an instance of testing target class!");
190
191                 Application application = new Application();
192                 WatchTime watchTime = new WatchTime();
193                 testingTarget.Emit(application, watchTime);
194
195                 application.Dispose();
196                 watchTime.Dispose();
197                 testingTarget.Dispose();
198                 tlog.Debug(tag, $"WatchTimeSignalEmit END (OK)");
199             }
200             else
201             {
202                 tlog.Debug(tag, $"WatchTimeSignalEmit END (OK)");
203                 Assert.Pass("Not Supported profile");
204             }           
205         }
206     }
207 }