b97b8e121dadb50d252b891c0e5b9edcef710c8d
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Events / TSGesture.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/Gesture")]
13     class PublicGestureTest
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("Gesture constructor")]
32         [Property("SPEC", "Tizen.NUI.Gesture.Gesture C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void GestureConstructor()
37         {
38             tlog.Debug(tag, $"GestureConstructor START");
39             
40             var longPressGesture = new LongPressGesture(Gesture.StateType.Cancelled);
41             var gesture = new Gesture(longPressGesture);
42                         
43             longPressGesture.Dispose();
44             gesture.Dispose();
45             tlog.Debug(tag, $"GestureConstructor END (OK)");
46             Assert.Pass("GestureConstructor");
47         }
48
49         [Test]
50         [Category("P1")]
51         [Description("Gesture type")]
52         [Property("SPEC", "Tizen.NUI.Gesture.type A")]
53         [Property("SPEC_URL", "-")]
54         [Property("CRITERIA", "PRW")]
55         [Property("AUTHOR", "guowei.wang@samsung.com")]
56         public void GestureType()
57         {
58             tlog.Debug(tag, $"GestureType START");
59             try
60             {
61                 var longPressGesture = new LongPressGesture(Gesture.StateType.Cancelled);
62                 Assert.IsNotNull(longPressGesture, "Can't create success object LongPressGesture");
63                 var gesture = new Gesture(longPressGesture);
64                 Assert.IsNotNull(gesture, "Can't create success object Gesture");
65                 Assert.IsInstanceOf<Gesture>(gesture, "Should be an instance of Gesture type.");
66                 Gesture.GestureType type = gesture.Type;
67                 Assert.AreEqual(Gesture.GestureType.LongPress, type, "Should be same value");
68
69                 gesture.Dispose();
70                 longPressGesture.Dispose();
71             }
72             catch (Exception e)
73             {
74                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());                
75                 Assert.Fail("Caught Exception" + e.ToString());
76             }
77             tlog.Debug(tag, $"GestureType END (OK)");
78             Assert.Pass("GestureType");
79         }
80
81         [Test]
82         [Category("P1")]
83         [Description("Gesture state")]
84         [Property("SPEC", "Tizen.NUI.Gesture.state A")]
85         [Property("SPEC_URL", "-")]
86         [Property("CRITERIA", "PRW")]
87         [Property("AUTHOR", "guowei.wang@samsung.com")]
88         public void GestureState()
89         {
90             tlog.Debug(tag, $"GestureState START");
91             try
92             {
93                 var longPressGesture = new LongPressGesture(Gesture.StateType.Cancelled);
94                 Assert.IsNotNull(longPressGesture, "Can't create success object LongPressGesture");
95                 var gesture = new Gesture(longPressGesture);
96                 Assert.IsNotNull(gesture, "Can't create success object Gesture");
97                 Assert.IsInstanceOf<Gesture>(gesture, "Should be an instance of Gesture type.");
98                 Gesture.StateType state = gesture.State;
99                 Assert.AreEqual(Gesture.StateType.Cancelled, state, "Should be same value");
100
101                 gesture.Dispose();
102                 longPressGesture.Dispose();
103
104             }
105             catch (Exception e)
106             {
107                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
108                 
109                 Assert.Fail("Caught Exception" + e.ToString());
110             }
111             tlog.Debug(tag, $"GestureState END (OK)");
112             Assert.Pass("GestureState");
113         }
114
115         [Test]
116         [Category("P1")]
117         [Description("Gesture time")]
118         [Property("SPEC", "Tizen.NUI.Gesture.time A")]
119         [Property("SPEC_URL", "-")]
120         [Property("CRITERIA", "PRW")]
121         [Property("AUTHOR", "guowei.wang@samsung.com")]
122         public void GestureTime()
123         {
124             tlog.Debug(tag, $"GestureTime START");
125             try
126             {
127                 var longPressGesture = new LongPressGesture(Gesture.StateType.Cancelled);
128                 Assert.IsNotNull(longPressGesture, "Can't create success object LongPressGesture");
129                 var gesture = new Gesture(longPressGesture);
130                 Assert.IsNotNull(gesture, "Can't create success object Gesture");
131                 Assert.IsInstanceOf<Gesture>(gesture, "Should be an instance of Gesture type.");
132                 uint time = gesture.Time;
133                 Assert.GreaterOrEqual(time, 0, "Should be greater or equal 0");
134
135                 gesture.Dispose();
136                 longPressGesture.Dispose();
137             }
138             catch (Exception e)
139             {
140                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
141                 
142                 Assert.Fail("Caught Exception" + e.ToString());
143             }
144             tlog.Debug(tag, $"GestureTime END (OK)");
145             Assert.Pass("GestureTime");
146         }
147
148
149         [Test]
150         [Category("P1")]
151         [Description("Gesture GetGestureFromPtr")]
152         [Property("SPEC", "Tizen.NUI.Gesture.GetGestureFromPtr M")]
153         [Property("SPEC_URL", "-")]
154         [Property("CRITERIA", "MR")]
155         [Property("AUTHOR", "guowei.wang@samsung.com")]
156         public void GetstureGetGestureFromPtr()
157         {
158             tlog.Debug(tag, $"GetstureGetGestureFromPtr START");
159                         
160             var longPressGesture = new LongPressGesture(Gesture.StateType.Cancelled);            
161             var gesture = new Gesture(longPressGesture);
162                         
163             Gesture ret = Gesture.GetGestureFromPtr(Gesture.getCPtr(gesture).Handle);
164
165             Assert.IsNotNull(ret, "Can't create success object Gesture");
166             Assert.IsInstanceOf<Gesture>(ret, "Should be an instance of Gesture type.");
167                         
168             ret.Dispose();
169             gesture.Dispose();
170             longPressGesture.Dispose();
171                         
172             tlog.Debug(tag, $"GetstureGetGestureFromPtr END (OK)");
173             Assert.Pass("GetstureGetGestureFromPtr");
174         }
175     }
176 }