[NUI] integration from DevelNUI to master (#3309)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Common / TSActivatedSignalType.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/Common/ActivatedSignalType")]
13     public class InternalActivatedSignalTypeTest
14     {
15         private const string tag = "NUITEST";
16         private delegate bool dummyCallback(IntPtr signal);
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("ActivatedSignalType constructor.")]
37         [Property("SPEC", "Tizen.NUI.ActivatedSignalType.ActivatedSignalType C")]
38         [Property("SPEC_URL", "-")]
39         [Property("CRITERIA", "CONSTR")]
40         [Property("AUTHOR", "guowei.wang@samsung.com")]
41         public void ActivatedSignalTypeConstructor()
42         {
43             tlog.Debug(tag, $"ActivatedSignalTypeConstructor START");
44
45             using (View view = new View())
46             {
47                 var testingTarget = new ActivatedSignalType(view.SwigCPtr.Handle, false);
48                 Assert.IsNotNull(testingTarget, "Should be not null!");
49                 Assert.IsInstanceOf<ActivatedSignalType>(testingTarget, "Should be an Instance of ActivatedSignalType!");
50
51                 testingTarget.Dispose();
52             }
53
54             tlog.Debug(tag, $"ActivatedSignalTypeConstructor END (OK)");
55         }
56
57         [Test]
58         [Category("P1")]
59         [Description("ActivatedSignalType Empty.")]
60         [Property("SPEC", "Tizen.NUI.ActivatedSignalType.Empty M")]
61         [Property("SPEC_URL", "-")]
62         [Property("CRITERIA", "MR")]
63         [Property("AUTHOR", "guowei.wang@samsung.com")]
64         public void ActivatedSignalTypeEmpty()
65         {
66             tlog.Debug(tag, $"ActivatedSignalTypeEmpty START");
67
68             var testingTarget = new ActivatedSignalType();
69             Assert.IsNotNull(testingTarget, "Should be not null!");
70             Assert.IsInstanceOf<ActivatedSignalType>(testingTarget, "Should be an Instance of ActivatedSignalType!");
71
72             try
73             {
74                 testingTarget.Empty();
75             }
76             catch (Exception e)
77             {
78                 tlog.Debug(tag, e.Message.ToString());
79                 Assert.Fail("Caught Exception: Failed!");
80             }
81
82             testingTarget.Dispose();
83
84             tlog.Debug(tag, $"ActivatedSignalTypeEmpty END (OK)");
85         }
86
87         [Test]
88         [Category("P1")]
89         [Description("ActivatedSignalType GetConnectionCount.")]
90         [Property("SPEC", "Tizen.NUI.ActivatedSignalType.GetConnectionCount M")]
91         [Property("SPEC_URL", "-")]
92         [Property("CRITERIA", "MR")]
93         [Property("AUTHOR", "guowei.wang@samsung.com")]
94         public void ActivatedSignalTypeGetConnectionCount()
95         {
96             tlog.Debug(tag, $"ActivatedSignalTypeGetConnectionCount START");
97
98             var testingTarget = new ActivatedSignalType();
99             Assert.IsNotNull(testingTarget, "Should be not null!");
100             Assert.IsInstanceOf<ActivatedSignalType>(testingTarget, "Should be an Instance of ActivatedSignalType!");
101
102             try
103             {
104                 testingTarget.GetConnectionCount();
105             }
106             catch (Exception e)
107             {
108                 tlog.Debug(tag, e.Message.ToString());
109                 Assert.Fail("Caught Exception: Failed!");
110             }
111
112             testingTarget.Dispose();
113
114             tlog.Debug(tag, $"ActivatedSignalTypeGetConnectionCount END (OK)");
115         }
116
117         [Test]
118         [Category("P1")]
119         [Description("ActivatedSignalType Connect.")]
120         [Property("SPEC", "Tizen.NUI.ActivatedSignalType.Connect M")]
121         [Property("SPEC_URL", "-")]
122         [Property("CRITERIA", "MR")]
123         [Property("AUTHOR", "guowei.wang@samsung.com")]
124         public void ActivatedSignalTypeConnect()
125         {
126             tlog.Debug(tag, $"ActivatedSignalTypeConnect START");
127
128             var testingTarget = new ActivatedSignalType();
129             Assert.IsNotNull(testingTarget, "Should be not null!");
130             Assert.IsInstanceOf<ActivatedSignalType>(testingTarget, "Should be an Instance of ActivatedSignalType!");
131
132             try
133             {
134                 dummyCallback callback = OnDummyCallback;
135                 testingTarget.Connect(callback);
136                 testingTarget.Disconnect(callback);
137             }
138             catch (Exception e)
139             {
140                 tlog.Debug(tag, e.Message.ToString());
141                 Assert.Fail("Caught Exception: Failed!");
142             }
143
144             testingTarget.Dispose();
145
146             tlog.Debug(tag, $"ActivatedSignalTypeConnect END (OK)");
147         }
148
149         [Test]
150         [Category("P1")]
151         [Description("ActivatedSignalType Emit.")]
152         [Property("SPEC", "Tizen.NUI.ActivatedSignalType.Emit M")]
153         [Property("SPEC_URL", "-")]
154         [Property("CRITERIA", "MR")]
155         [Property("AUTHOR", "guowei.wang@samsung.com")]
156         [Obsolete]
157         public void ActivatedSignalTypeEmit()
158         {
159             tlog.Debug(tag, $"ActivatedSignalTypeEmit START");
160             var currentPid = global::System.Diagnostics.Process.GetCurrentProcess().Id;
161             var currentTid = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
162
163             tlog.Debug(tag, $"thread check! main pid={App.mainPid}, current pid={currentPid}, main tid={App.mainTid}, current tid={currentTid}");
164
165             using (InputMethodContext context = new InputMethodContext())
166             {
167                 var testingTarget = new ActivatedSignalType();
168                 Assert.IsNotNull(testingTarget, "Should be not null!");
169                 Assert.IsInstanceOf<ActivatedSignalType>(testingTarget, "Should be an Instance of ActivatedSignalType!");
170
171                 try
172                 {
173                     testingTarget.Emit(context);
174                 }
175                 catch (Exception e)
176                 {
177                     tlog.Debug(tag, e.Message.ToString());
178                     Assert.Fail("Caught Exception: Failed!");
179                 }
180
181                 testingTarget.Dispose();
182             }
183
184             tlog.Debug(tag, $"ActivatedSignalTypeEmit END (OK)");
185         }
186     }
187 }