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