Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Utility / TSPagePanSignal.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/Utility/PagePanSignal")]
13     public class InternalPagePanSignalTest
14     {
15         private const string tag = "NUITEST";
16
17         private delegate bool dummyCallback(IntPtr pagePanSignal);
18         private bool OnDummyCallback(IntPtr data)
19         {
20             return false;
21         }
22
23         [SetUp]
24         public void Init()
25         {
26             tlog.Info(tag, "Init() is called!");
27         }
28
29         [TearDown]
30         public void Destroy()
31         {
32             tlog.Info(tag, "Destroy() is called!");
33         }
34
35         [Test]
36         [Category("P1")]
37         [Description("PagePanSignal constructor.")]
38         [Property("SPEC", "Tizen.NUI.PagePanSignal.PagePanSignal C")]
39         [Property("SPEC_URL", "-")]
40         [Property("CRITERIA", "CONSTR")]
41         [Property("AUTHOR", "guowei.wang@samsung.com")]
42         public void PagePanSignalConstructor()
43         {
44             tlog.Debug(tag, $"PagePanSignalConstructor START");
45
46             using (View view = new View())
47             {
48                 view.Size = new Size(20, 40);
49                 view.BackgroundColor = Color.Cyan;
50
51                 var testingTarget = new PagePanSignal(view.SwigCPtr.Handle, false);
52                 Assert.IsNotNull(testingTarget, "Should be not null!");
53                 Assert.IsInstanceOf<PagePanSignal>(testingTarget, "Should be an Instance of PagePanSignal!");
54
55                 testingTarget.Dispose();
56             }
57
58             tlog.Debug(tag, $"PagePanSignalConstructor END (OK)");
59         }
60
61         [Test]
62         [Category("P1")]
63         [Description("PagePanSignal Empty.")]
64         [Property("SPEC", "Tizen.NUI.PagePanSignal.Empty M")]
65         [Property("SPEC_URL", "-")]
66         [Property("CRITERIA", "MR")]
67         [Property("AUTHOR", "guowei.wang@samsung.com")]
68         public void PagePanSignaEmpty()
69         {
70             tlog.Debug(tag, $"PagePanSignaEmpty START");
71
72             using (View view = new View())
73             {
74                 view.Size = new Size(20, 40);
75                 view.BackgroundColor = Color.Cyan;
76
77                 var testingTarget = new PagePanSignal(view.SwigCPtr.Handle, false);
78                 Assert.IsNotNull(testingTarget, "Should be not null!");
79                 Assert.IsInstanceOf<PagePanSignal>(testingTarget, "Should be an Instance of PagePanSignal!");
80
81                 try
82                 {
83                     testingTarget.Empty();
84                 }
85                 catch (Exception e)
86                 {
87                     tlog.Debug(tag, e.Message.ToString());
88                     Assert.Fail("Caught Exception: Failed!");
89                 }
90
91                 testingTarget.Dispose();
92             }
93
94             tlog.Debug(tag, $"PagePanSignaEmpty END (OK)");
95         }
96
97         [Test]
98         [Category("P1")]
99         [Description("PagePanSignal GetConnectionCount.")]
100         [Property("SPEC", "Tizen.NUI.PagePanSignal.GetConnectionCount M")]
101         [Property("SPEC_URL", "-")]
102         [Property("CRITERIA", "MR")]
103         [Property("AUTHOR", "guowei.wang@samsung.com")]
104         public void PagePanSignaGetConnectionCount()
105         {
106             tlog.Debug(tag, $"PagePanSignaGetConnectionCount START");
107
108             using (View view = new View())
109             {
110                 view.Size = new Size(20, 40);
111                 view.BackgroundColor = Color.Cyan;
112
113                 var testingTarget = new PagePanSignal(view.SwigCPtr.Handle, false);
114                 Assert.IsNotNull(testingTarget, "Should be not null!");
115                 Assert.IsInstanceOf<PagePanSignal>(testingTarget, "Should be an Instance of PagePanSignal!");
116
117                 try
118                 {
119                     testingTarget.GetConnectionCount();
120                 }
121                 catch (Exception e)
122                 {
123                     tlog.Debug(tag, e.Message.ToString());
124                     Assert.Fail("Caught Exception: Failed!");
125                 }
126
127                 testingTarget.Dispose();
128             }
129
130             tlog.Debug(tag, $"PagePanSignaGetConnectionCount END (OK)");
131         }
132
133         [Test]
134         [Category("P1")]
135         [Description("PagePanSignal Connect.")]
136         [Property("SPEC", "Tizen.NUI.PagePanSignal.Connect M")]
137         [Property("SPEC_URL", "-")]
138         [Property("CRITERIA", "MR")]
139         [Property("AUTHOR", "guowei.wang@samsung.com")]
140         public void PagePanSignaConnect()
141         {
142             tlog.Debug(tag, $"PagePanSignaConnect START");
143
144             var testingTarget = new PagePanSignal();
145             Assert.IsNotNull(testingTarget, "Should be not null!");
146             Assert.IsInstanceOf<PagePanSignal>(testingTarget, "Should be an Instance of PagePanSignal!");
147
148             try
149             {
150                 dummyCallback callback = OnDummyCallback;
151                 testingTarget.Connect(callback);
152                 testingTarget.Disconnect(callback);
153             }
154             catch (Exception e)
155             {
156                 tlog.Debug(tag, e.Message.ToString());
157                 Assert.Fail("Caught Exception: Failed!");
158             }
159
160             testingTarget.Dispose();
161
162             tlog.Debug(tag, $"PagePanSignaConnect END (OK)");
163         }
164
165         [Test]
166         [Category("P1")]
167         [Description("PagePanSignal Emit.")]
168         [Property("SPEC", "Tizen.NUI.PagePanSignal.Emit M")]
169         [Property("SPEC_URL", "-")]
170         [Property("CRITERIA", "MR")]
171         [Property("AUTHOR", "guowei.wang@samsung.com")]
172         public void PagePanSignalEmit()
173         {
174             tlog.Debug(tag, $"PagePanSignalEmit START");
175             var currentPid = global::System.Diagnostics.Process.GetCurrentProcess().Id;
176             var currentTid = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
177
178             tlog.Debug(tag, $"thread check! main pid={App.mainPid}, current pid={currentPid}, main tid={App.mainTid}, current tid={currentTid}");
179
180             using (View view = new View())
181             {
182                 var testingTarget = new PagePanSignal();
183                 Assert.IsNotNull(testingTarget, "Should be not null!");
184                 Assert.IsInstanceOf<PagePanSignal>(testingTarget, "Should be an Instance of PagePanSignal!");
185
186                 try
187                 {
188                     testingTarget.Emit(new PageTurnView(view.SwigCPtr.Handle, false));
189                 }
190                 catch (Exception e)
191                 {
192                     tlog.Debug(tag, e.Message.ToString());
193                     Assert.Fail("Caught Exception: Failed!");
194                 }
195
196                 testingTarget.Dispose();
197             }
198
199             tlog.Debug(tag, $"PagePanSignalEmit END (OK)");
200         }
201     }
202 }