[NUI] Update NUI.Devel to fix block and crash issues.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Events / TSGestureDetector.cs
1 using NUnit.Framework;
2 using NUnit.Framework.TUnit;
3 using System;
4 using Tizen.NUI;
5 using Tizen.NUI.BaseComponents;
6
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using tlog = Tizen.Log;
10         
11     [TestFixture]
12     [Description("public/Events/GestureDetector")]
13     class PublicGestureDetectorTest
14     {
15         private const string tag = "NUITEST";
16
17         [SetUp]
18         public void Init()
19         {
20             tlog.Info(tag, "Init() is called!");
21         }
22
23         [TearDown]
24         public void Destroy()
25         {
26             tlog.Info(tag, "Destroy() is called!");
27         }
28
29         [Test]
30         [Category("P1")]
31         [Description("GestureDetector constructor")]
32         [Property("SPEC", "Tizen.NUI.GestureDetector.GestureDetector C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void GestureDetectorConstructor()
37         {
38             tlog.Debug(tag, $"GestureDetectorConstructor START");
39                         
40             var testingTarget = new GestureDetector();
41             Assert.IsNotNull(testingTarget, "should be not null");
42             Assert.IsInstanceOf<GestureDetector>(testingTarget, "should be an instance of testing target class!");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"GestureDetectorConstructor END (OK)");
46             Assert.Pass("GestureDetectorConstructor");
47         }
48
49         //[Test]
50         //[Category("P1")]
51         //[Description("GestureDetector constructor")]
52         //[Property("SPEC", "Tizen.NUI.GestureDetector.GestureDetector C")]
53         //[Property("SPEC_URL", "-")]
54         //[Property("CRITERIA", "CONSTR")]
55         //[Property("AUTHOR", "guowei.wang@samsung.com")]
56         //public void GestureDetectorConstructorWithGestureDetector()
57         //{
58         //    tlog.Debug(tag, $"GestureDetectorConstructorWithGestureDetector START");
59
60         //    using (GestureDetector detector = new GestureDetector())
61         //    {
62         //        var testingTarget = new GestureDetector(detector);
63         //        Assert.IsNotNull(testingTarget, "should be not null");
64         //        Assert.IsInstanceOf<GestureDetector>(testingTarget, "should be an instance of testing target class!");
65
66         //        testingTarget.Dispose();
67         //    }
68
69         //    tlog.Debug(tag, $"GestureDetectorConstructorWithGestureDetector END (OK)");
70         //    Assert.Pass("GestureDetectorConstructor");
71         //}
72
73         [Test]
74         [Category("P1")]
75         [Description("GestureDetector Attach")]
76         [Property("SPEC", "Tizen.NUI.GestureDetector.Attach M")]
77         [Property("SPEC_URL", "-")]
78         [Property("CRITERIA", "MR")]
79         [Property("AUTHOR", "guowei.wang@samsung.com")]
80         public void GestureDetectorAttach()
81         {
82             tlog.Debug(tag, $"GestureDetectorAttach START");
83
84             var testingTarget = new LongPressGestureDetector();
85             Assert.IsNotNull(testingTarget, "should be not null");
86             Assert.IsInstanceOf<LongPressGestureDetector>(testingTarget, "should be an instance of testing target class!");
87
88             using (View view = new View())
89             {
90                 Window.Instance.GetDefaultLayer().Add(view);
91                 testingTarget.Attach(view);
92                 testingTarget.Detach(view);
93                 Window.Instance.GetDefaultLayer().Remove(view);
94             }
95
96             testingTarget.Dispose();
97             tlog.Debug(tag, $"GestureDetectorAttach END (OK)");
98             Assert.Pass("GestureDetectorAttach");
99         }
100
101         [Test]
102         [Category("P1")]
103         [Description("GestureDetector DetachAll")]
104         [Property("SPEC", "Tizen.NUI.GestureDetector.DetachAll M")]
105         [Property("SPEC_URL", "-")]
106         [Property("CRITERIA", "MR")]
107         [Property("AUTHOR", "guowei.wang@samsung.com")]
108         public void GestureDetectorDetachAll()
109         {
110             tlog.Debug(tag, $"GestureDetectorDetachAll START");
111
112             var testingTarget = new LongPressGestureDetector();
113             Assert.IsNotNull(testingTarget, "should be not null");
114             Assert.IsInstanceOf<LongPressGestureDetector>(testingTarget, "should be an instance of testing target class!");
115
116             using (View view = new View())
117             {
118                 testingTarget.Attach(view);
119                 testingTarget.DetachAll();
120             }
121
122             testingTarget.Dispose();            
123             tlog.Debug(tag, $"GestureDetectorDetachAll END (OK)");
124             Assert.Pass("GestureDetectorDetachAll");
125         }
126
127         [Test]
128         [Category("P1")]
129         [Description("GestureDetector GetAttachedViewCount")]
130         [Property("SPEC", "Tizen.NUI.GestureDetector.GetAttachedViewCount M")]
131         [Property("SPEC_URL", "-")]
132         [Property("CRITERIA", "MR")]
133         [Property("AUTHOR", "guowei.wang@samsung.com")]
134         public void GestureDetectorGetAttachedViewCount()
135         {
136             tlog.Debug(tag, $"GestureDetectorGetAttachedViewCount START");
137
138             var testingTarget = new LongPressGestureDetector();
139             Assert.IsNotNull(testingTarget, "should be not null");
140             Assert.IsInstanceOf<LongPressGestureDetector>(testingTarget, "should be an instance of testing target class!");
141
142             using (View view = new View())
143             {
144                 testingTarget.Attach(view);
145                 tlog.Debug(tag, "AttachedViewCount : " + testingTarget.GetAttachedViewCount());
146
147                 testingTarget.Detach(view);
148             }
149
150             testingTarget.Dispose();            
151             tlog.Debug(tag, $"GestureDetectorGetAttachedViewCount END (OK)");
152             Assert.Pass("GestureDetectorGetAttachedViewCount");
153         }
154
155         [Test]
156         [Category("P1")]
157         [Description("GestureDetector GetAttachedView")]
158         [Property("SPEC", "Tizen.NUI.GestureDetector.GetAttachedView M")]
159         [Property("SPEC_URL", "-")]
160         [Property("CRITERIA", "MR")]
161         [Property("AUTHOR", "guowei.wang@samsung.com")]
162         public void GestureDetectorGetAttachedView()
163         {
164             tlog.Debug(tag, $"GestureDetectorGetAttachedView START");
165
166             var testingTarget = new LongPressGestureDetector();
167             Assert.IsNotNull(testingTarget, "should be not null");
168             Assert.IsInstanceOf<LongPressGestureDetector>(testingTarget, "should be an instance of testing target class!");
169
170             using (View view = new View())
171             {
172                 testingTarget.Attach(view);
173                 testingTarget.GetAttachedView(0);
174                 testingTarget.Detach(view);
175             }
176
177             testingTarget.Dispose();            
178             tlog.Debug(tag, $"GestureDetectorGetAttachedView END (OK)");
179             Assert.Pass("GestureDetectorGetAttachedView");
180         }
181
182         //[Test]
183         //[Category("P1")]
184         //[Description("GestureDetector Assign")]
185         //[Property("SPEC", "Tizen.NUI.GestureDetector.Assign M")]
186         //[Property("SPEC_URL", "-")]
187         //[Property("CRITERIA", "MR")]
188         //[Property("AUTHOR", "guowei.wang@samsung.com")]
189         //public void GestureDetectorAssign()
190         //{
191         //    tlog.Debug(tag, $"GestureDetectorAssign START");
192
193         //    using (GestureDetector detector = new GestureDetector())
194         //    {
195         //        var testingTarget = detector.Assign(detector);
196         //        Assert.IsNotNull(testingTarget, "should be not null");
197         //        Assert.IsInstanceOf<GestureDetector>(testingTarget, "should be an instance of testing target class!");
198         //    }
199
200         //    tlog.Debug(tag, $"GestureDetectorAssign END (OK)");
201         //    Assert.Pass("GestureDetectorAssign");
202         //}
203
204         [Test]
205         [Category("P1")]
206         [Description("GestureDetector DownCast")]
207         [Property("SPEC", "Tizen.NUI.GestureDetector.DownCast M")]
208         [Property("SPEC_URL", "-")]
209         [Property("CRITERIA", "MR")]
210         [Property("AUTHOR", "guowei.wang@samsung.com")]
211         public void GestureDetectorDownCast()
212         {
213             tlog.Debug(tag, $"GestureDetectorDownCast START");
214
215             using (GestureDetector detector = new GestureDetector())
216             {
217                 var testingTarget = GestureDetector.DownCast(detector);
218                 Assert.IsInstanceOf<GestureDetector>(testingTarget, "should be an instance of testing target class!");
219
220                 testingTarget.Dispose();
221             }
222             
223             tlog.Debug(tag, $"GestureDetectorDownCast END (OK)");
224             Assert.Pass("GestureDetectorDownCast");
225         }
226
227         [Test]
228         [Category("P1")]
229         [Description("GestureDetector getCPtr")]
230         [Property("SPEC", "Tizen.NUI.GestureDetector.getCPtr M")]
231         [Property("SPEC_URL", "-")]
232         [Property("CRITERIA", "MR")]
233         [Property("AUTHOR", "guowei.wang@samsung.com")]
234         public void GestureDetectorgetCPtr()
235         {
236             tlog.Debug(tag, $"GestureDetectorgetCPtr START");
237
238             var testingTarget = new GestureDetector();
239             Assert.IsNotNull(testingTarget, "should be not null");
240             Assert.IsInstanceOf<GestureDetector>(testingTarget, "should be an instance of testing target class!");
241
242             try
243             {
244                 GestureDetector.getCPtr(testingTarget);
245             }
246             catch (Exception e)
247             {
248                 tlog.Debug(tag, e.Message.ToString());
249                 Assert.Fail("Caught Exception : Failed!");
250             }
251
252             testingTarget.Dispose();
253             tlog.Debug(tag, $"GestureDetectorgetCPtr END (OK)");
254             Assert.Pass("GestureDetectorgetCPtr");
255         }
256     }
257 }