Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Application / TSApplicationSignal.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/ApplicationSignal")]
13     public class InternalApplicationSignalTest
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         [SetUp]
23         public void Init()
24         {
25             tlog.Info(tag, "Init() is called!");
26         }
27
28         [TearDown]
29         public void Destroy()
30         {
31             tlog.Info(tag, "Destroy() is called!");
32         }
33
34         [Test]
35         [Category("P1")]
36         [Description("ApplicationSignal constructor.")]
37         [Property("SPEC", "Tizen.NUI.ApplicationSignal.ApplicationSignal C")]
38         [Property("SPEC_URL", "-")]
39         [Property("CRITERIA", "CONSTR")]
40         [Property("AUTHOR", "guowei.wang@samsung.com")]
41         public void ApplicationSignalConstructor()
42         {
43             tlog.Debug(tag, $"ApplicationSignalConstructor START");
44
45             var testingTarget = new ApplicationSignal();
46
47             Assert.IsNotNull(testingTarget, "should be not null");
48             Assert.IsInstanceOf<ApplicationSignal>(testingTarget, "should be an instance of testing target class!");
49
50             testingTarget.Dispose();
51             tlog.Debug(tag, $"ApplicationSignalConstructor END (OK)");
52         }
53
54         [Test]
55         [Category("P1")]
56         [Description("ApplicationSignal Empty.")]
57         [Property("SPEC", "Tizen.NUI.ApplicationSignal.Empty M")]
58         [Property("SPEC_URL", "-")]
59         [Property("CRITERIA", "MR")]
60         [Property("AUTHOR", "guowei.wang@samsung.com")]
61         public void ApplicationSignalEmpty()
62         {
63             tlog.Debug(tag, $"ApplicationSignalEmpty START");
64
65             var testingTarget = new ApplicationSignal();
66             Assert.IsNotNull(testingTarget, "should be not null");
67             Assert.IsInstanceOf<ApplicationSignal>(testingTarget, "should be an instance of testing target class!");
68
69             var result = testingTarget.Empty();
70             Assert.IsTrue(result);
71
72             testingTarget.Dispose();
73             tlog.Debug(tag, $"ApplicationSignalEmpty END (OK)");
74         }
75
76         [Test]
77         [Category("P1")]
78         [Description("ApplicationSignal GetConnectionCount.")]
79         [Property("SPEC", "Tizen.NUI.ApplicationSignal.GetConnectionCount M")]
80         [Property("SPEC_URL", "-")]
81         [Property("CRITERIA", "MR")]
82         [Property("AUTHOR", "guowei.wang@samsung.com")]
83         public void ApplicationSignalGetConnectionCount()
84         {
85             tlog.Debug(tag, $"ApplicationSignalGetConnectionCount START");
86
87             var testingTarget = new ApplicationSignal();
88             Assert.IsNotNull(testingTarget, "should be not null");
89             Assert.IsInstanceOf<ApplicationSignal>(testingTarget, "should be an instance of testing target class!");
90
91             var result = testingTarget.GetConnectionCount();
92             Assert.IsTrue(result == 0, "result should be 0");
93
94             testingTarget.Dispose();
95             tlog.Debug(tag, $"ApplicationSignalGetConnectionCount END (OK)");
96         }
97
98         [Test]
99         [Category("P1")]
100         [Description("ApplicationSignal connection.")]
101         [Property("SPEC", "Tizen.NUI.ApplicationSignal.Connect M")]
102         [Property("SPEC_URL", "-")]
103         [Property("CRITERIA", "MR")]
104         [Property("AUTHOR", "guowei.wang@samsung.com")]
105         public void ApplicationSignalConnection()
106         {
107             tlog.Debug(tag, $"ApplicationSignalConnection START");
108
109             var testingTarget = new ApplicationSignal();
110             Assert.IsNotNull(testingTarget, "should be not null");
111             Assert.IsInstanceOf<ApplicationSignal>(testingTarget, "should be an instance of testing target class!");
112
113             dummyCallback callback = OnDummyCallback;
114             testingTarget.Connect(callback);
115             testingTarget.Disconnect(callback);
116             testingTarget.Dispose();
117
118             tlog.Debug(tag, $"ApplicationSignalConnection END (OK)");
119         }
120
121         [Test]
122         [Category("P1")]
123         [Description("ApplicationSignal disconnection.")]
124         [Property("SPEC", "Tizen.NUI.ApplicationSignal.Disconnect M")]
125         [Property("SPEC_URL", "-")]
126         [Property("CRITERIA", "MR")]
127         [Property("AUTHOR", "guowei.wang@samsung.com")]
128         public void ApplicationSignalDisconnection()
129         {
130             tlog.Debug(tag, $"ApplicationSignalDisconnection START");
131
132             var testingTarget = new ApplicationSignal();
133             Assert.IsNotNull(testingTarget, "should be not null");
134             Assert.IsInstanceOf<ApplicationSignal>(testingTarget, "should be an instance of testing target class!");
135
136             dummyCallback callback = OnDummyCallback;
137             testingTarget.Connect(callback);
138             testingTarget.Disconnect(callback);
139             testingTarget.Dispose();
140
141             tlog.Debug(tag, $"ApplicationSignalDisconnection END (OK)");
142         }
143
144         [Test]
145         [Category("P1")]
146         [Description("ApplicationSignal Emit.")]
147         [Property("SPEC", "Tizen.NUI.ApplicationSignal.Emit M")]
148         [Property("SPEC_URL", "-")]
149         [Property("CRITERIA", "MR")]
150         [Property("AUTHOR", "guowei.wang@samsung.com")]
151         public void ApplicationSignalEmit()
152         {
153             tlog.Debug(tag, $"ApplicationSignalEmit START");
154             var currentPid = global::System.Diagnostics.Process.GetCurrentProcess().Id;
155             var currentTid = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
156
157             tlog.Debug(tag, $"thread check! main pid={App.mainPid}, current pid={currentPid}, main tid={App.mainTid}, current tid={currentTid}");
158
159             var testingTarget = Tizen.NUI.Application.Instance.PauseSignal();
160             Assert.IsNotNull(testingTarget, "should be not null");
161             Assert.IsInstanceOf<ApplicationSignal>(testingTarget, "should be an instance of testing target class!");
162
163             testingTarget.Emit(Tizen.NUI.Application.Current);
164
165             testingTarget.Dispose();
166             tlog.Debug(tag, $"ApplicationSignalEmit END (OK)");
167         }
168     }
169 }