Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Widget / TSWidgetViewSignal.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 using System.Collections.Generic;
7
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("internal/Widget/WidgetViewSignal")]
14     public class WidgetViewSignalTests
15     {
16         private const string tag = "NUITEST";
17         private delegate void SignalCallback();
18
19         private static void MyDelegate()
20         {
21             Log.Fatal("TCT", "[TestCase][AddIdle][NUIApplication] Pass");
22         }
23
24         [SetUp]
25         public void Init()
26         {
27             Tizen.Log.Info(tag, "Init() is called!");
28         }
29
30         [TearDown]
31         public void Destroy()
32         {
33             Tizen.Log.Info(tag, "Destroy() is called!");
34         }
35
36         [Test]
37         [Category("P1")]
38         [Description("WidgetViewSignal constructor.")]
39         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.WidgetViewSignal C")]
40         [Property("SPEC_URL", "-")]
41         [Property("CRITERIA", "CONSTR")]
42         [Property("AUTHOR", "guowei.wang@samsung.com")]
43         public void WidgetViewSignalConstructor()
44         {
45             tlog.Debug(tag, $"WidgetViewSignalConstructor START");
46
47             var testingTarget = new WidgetViewSignal() ;
48             Assert.IsNotNull(testingTarget, "Should be not null!");
49             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
50
51             testingTarget.Dispose();
52             tlog.Debug(tag, $"WidgetViewSignalConstructor END (OK)");
53         }
54
55         [Test]
56         [Category("P1")]
57         [Description("WidgetViewSignal Dispose.")]
58         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.Dispose M")]
59         [Property("SPEC_URL", "-")]
60         [Property("CRITERIA", "MR MCST")]
61         [Property("AUTHOR", "guowei.wang@samsung.com")]
62         public void WidgetViewSignalDispose()
63         {
64             tlog.Debug(tag, $"WidgetViewSignalDispose START");
65
66             var testingTarget = new WidgetViewSignal();
67             Assert.IsNotNull(testingTarget, "Should be not null!");
68             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
69
70             try
71             {
72                 testingTarget.Dispose();
73             }
74             catch (Exception e)
75             {
76                 Assert.Fail("Caught Exception" + e.ToString());
77             }
78
79             testingTarget.Dispose();
80             tlog.Debug(tag, $"WidgetViewSignalDispose END (OK)");
81         }
82
83         [Test]
84         [Category("P1")]
85         [Description("WidgetViewSignal Empty.")]
86         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.Empty M")]
87         [Property("SPEC_URL", "-")]
88         [Property("CRITERIA", "MR")]
89         [Property("AUTHOR", "guowei.wang@samsung.com")]
90         public void WidgetViewSignalEmpty()
91         {
92             tlog.Debug(tag, $"WidgetViewSignalEmpty START");
93
94             var testingTarget = new WidgetViewSignal();
95             Assert.IsNotNull(testingTarget, "Should be not null!");
96             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
97
98             Assert.IsTrue(testingTarget.Empty(), "Should be true here!");
99
100             testingTarget.Dispose();
101             tlog.Debug(tag, $"WidgetViewSignalEmpty END (OK)");
102         }
103
104         [Test]
105         [Category("P1")]
106         [Description("WidgetViewSignal GetConnectionCount.")]
107         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.GetConnectionCount M")]
108         [Property("SPEC_URL", "-")]
109         [Property("CRITERIA", "MR")]
110         [Property("AUTHOR", "guowei.wang@samsung.com")]
111         public void WidgetViewSignalGetConnectionCount()
112         {
113             tlog.Debug(tag, $"WidgetViewSignalGetConnectionCount START");
114
115             var testingTarget = new WidgetViewSignal();
116             Assert.IsNotNull(testingTarget, "Should be not null!");
117             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
118
119             Assert.AreEqual(0, testingTarget.GetConnectionCount(), "Should be zero here!");
120
121             testingTarget.Dispose();
122             tlog.Debug(tag, $"WidgetViewSignalGetConnectionCount END (OK)");
123         }
124
125         [Test]
126         [Category("P1")]
127         [Description("WidgetViewSignal Connect.")]
128         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.Connect M")]
129         [Property("SPEC_URL", "-")]
130         [Property("CRITERIA", "MR")]
131         [Property("AUTHOR", "guowei.wang@samsung.com")]
132         public void WidgetViewSignalConnect()
133         {
134             tlog.Debug(tag, $"WidgetViewSignalConnect START");
135
136             var testingTarget = new WidgetViewSignal();
137             Assert.IsNotNull(testingTarget, "Should be not null!");
138             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
139
140             try
141             {
142                 SignalCallback signalCallback = new SignalCallback(MyDelegate);
143                 testingTarget.Connect(signalCallback);
144                 Assert.AreEqual(1, testingTarget.GetConnectionCount(), "Should be one here!");
145             }
146             catch (Exception e)
147             {
148                 Assert.Fail("Caught Exception" + e.ToString());
149             }
150
151             testingTarget.Dispose();
152             tlog.Debug(tag, $"WidgetViewSignalConnect END (OK)");
153         }
154
155         [Test]
156         [Category("P2")]
157         [Description("WidgetViewSignal Connect. With null.")]
158         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.Connect M")]
159         [Property("SPEC_URL", "-")]
160         [Property("CRITERIA", "MR")]
161         [Property("AUTHOR", "guowei.wang@samsung.com")]
162         public void WidgetViewSignalConnectWithNull()
163         {
164             tlog.Debug(tag, $"WidgetViewSignalConnectWithNull START");
165
166             var testingTarget = new WidgetViewSignal();
167             Assert.IsNotNull(testingTarget, "Should be not null!");
168             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
169
170             try
171             {
172                 testingTarget.Connect(null);
173                 Assert.Fail("Should throw the ArgumentNullException!");
174             }
175             catch (ArgumentNullException e)
176             {
177                 Assert.True(true);
178             }
179
180             testingTarget.Dispose();
181             tlog.Debug(tag, $"WidgetViewSignalConnectWithNull END (OK)");
182         }
183
184         [Test]
185         [Category("P1")]
186         [Description("WidgetViewSignal Disconnect")]
187         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.Disconnect M")]
188         [Property("SPEC_URL", "-")]
189         [Property("CRITERIA", "MR")]
190         [Property("AUTHOR", "guowei.wang@samsung.com")]
191         public void WidgetViewSignalDisconnect()
192         {
193             tlog.Debug(tag, $"WidgetViewSignalDisconnect START");
194
195             var testingTarget = new WidgetViewSignal();
196             Assert.IsNotNull(testingTarget, "Should be not null!");
197             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
198
199             SignalCallback signalCallback = new SignalCallback(MyDelegate);
200
201             try
202             {
203                 testingTarget.Connect(signalCallback);
204                 Assert.AreEqual(1, testingTarget.GetConnectionCount(), "Should be one here!");
205                 
206                 testingTarget.Disconnect(signalCallback);
207                 Assert.AreEqual(0, testingTarget.GetConnectionCount(), "Should be zero here!");
208             }
209             catch (Exception e)
210             {
211                 Assert.Fail("Caught Exception" + e.ToString());
212             }
213
214             testingTarget.Dispose();
215             tlog.Debug(tag, $"WidgetViewSignalDisconnect END (OK)");
216         }
217
218         [Test]
219         [Category("P2")]
220         [Description("WidgetViewSignal Disconnect. With null.")]
221         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.Disconnect M")]
222         [Property("SPEC_URL", "-")]
223         [Property("CRITERIA", "MR")]
224         [Property("AUTHOR", "guowei.wang@samsung.com")]
225         public void WidgetViewSignalDisconnectWithNull()
226         {
227             tlog.Debug(tag, $"WidgetViewSignalDisconnect START");
228
229             var testingTarget = new WidgetViewSignal();
230             Assert.IsNotNull(testingTarget, "Should be not null!");
231             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
232
233             try
234             {
235                 testingTarget.Disconnect(null);
236                 Assert.Fail("Should throw the ArgumentNullException!");
237             }
238             catch (ArgumentNullException e)
239             {
240                 Assert.True(true);
241             }
242
243             testingTarget.Dispose();
244             tlog.Debug(tag, $"WidgetViewSignalDisconnect END (OK)");
245         }
246
247         [Test]
248         [Category("P2")]
249         [Description("WidgetViewSignal Emit. With null.")]
250         [Property("SPEC", "Tizen.NUI.WidgetViewSignal.Emit M")]
251         [Property("SPEC_URL", "-")]
252         [Property("CRITERIA", "MR")]
253         [Property("AUTHOR", "guowei.wang@samsung.com")]
254         public void WidgetViewSignalEmitWithNull()
255         {
256             tlog.Debug(tag, $"WidgetViewSignalEmitWithNull START");
257
258             var testingTarget = new WidgetViewSignal();
259             Assert.IsNotNull(testingTarget, "Should be not null!");
260             Assert.IsInstanceOf<WidgetViewSignal>(testingTarget, "Should be an Instance of WidgetViewSignal!");
261             
262             try
263             {
264                 testingTarget.Emit(null);
265                 Assert.Fail("Should throw the ArgumentNullException!");
266             }
267             catch (ArgumentNullException e)
268             {
269                 Assert.True(true);
270             }
271
272             testingTarget.Dispose();
273             tlog.Debug(tag, $"WidgetViewSignalEmitWithNull END (OK)");
274         }
275     }
276
277 }