[NUI] Update TCs of NUI.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Common / TSViewImpl.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/ViewImpl")]
13     public class InternalViewImplTest
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("ViewImpl New.")]
32         [Property("SPEC", "Tizen.NUI.ViewImpl.New M")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "MR")]
35         [Property("COVPARAM", "")]
36         [Property("AUTHOR", "guowei.wang@samsung.com")]
37         public void ViewImplNew()
38         {
39             tlog.Debug(tag, $"ViewImplNew START");
40
41             var testingTarget = ViewImpl.New();
42             Assert.IsNotNull(testingTarget, "null handle");
43             Assert.IsInstanceOf<View>(testingTarget, "Should return View instance.");
44
45             testingTarget.Dispose();
46             tlog.Debug(tag, $"ViewImplNew END (OK)");
47         }
48
49         [Test]
50         [Category("P1")]
51         [Description("ViewImpl getCPtr.")]
52         [Property("SPEC", "Tizen.NUI.ViewImpl.getCPtr M")]
53         [Property("SPEC_URL", "-")]
54         [Property("CRITERIA", "MR")]
55         [Property("COVPARAM", "")]
56         [Property("AUTHOR", "guowei.wang@samsung.com")]
57         public void ViewImplGetCPtr()
58         {
59             tlog.Debug(tag, $"ViewImplGetCPtr START");
60
61             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
62             {
63                 var testingTarget = new ViewWrapper("CustomView", impl);
64                 Assert.IsNotNull(testingTarget, "should be not null");
65                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
66
67                 var result = ViewWrapperImpl.getCPtr(testingTarget.viewWrapperImpl);
68                 tlog.Debug(tag, "getCptr : " + result);
69
70                 testingTarget.Dispose();
71             }
72
73             tlog.Debug(tag, $"ViewImplGetCPtr END (OK)");
74         }
75
76         [Test]
77         [Category("P1")]
78         [Description("ViewImpl SetStyleName.")]
79         [Property("SPEC", "Tizen.NUI.ViewImpl.SetStyleName M")]
80         [Property("SPEC_URL", "-")]
81         [Property("CRITERIA", "MR")]
82         [Property("COVPARAM", "")]
83         [Property("AUTHOR", "guowei.wang@samsung.com")]
84         public void ViewImplSetStyleName()
85         {
86             tlog.Debug(tag, $"ViewImplSetStyleName START");
87
88             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
89             {
90                 var testingTarget = new ViewWrapper("CustomView", impl);
91                 Assert.IsNotNull(testingTarget, "should be not null");
92                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
93
94                 testingTarget.viewWrapperImpl.SetStyleName("style");
95                 var result = testingTarget.viewWrapperImpl.GetStyleName();
96                 tlog.Debug(tag, "StyleName : " + result);
97
98                 testingTarget.Dispose();
99             }
100
101             tlog.Debug(tag, $"ViewImplSetStyleName END (OK)");
102         }
103
104         [Test]
105         [Category("P1")]
106         [Description("ViewImpl SetBackgroundColor.")]
107         [Property("SPEC", "Tizen.NUI.ViewImpl.SetBackgroundColor M")]
108         [Property("SPEC_URL", "-")]
109         [Property("CRITERIA", "MR")]
110         [Property("COVPARAM", "")]
111         [Property("AUTHOR", "guowei.wang@samsung.com")]
112         public void ViewImplSetBackgroundColor()
113         {
114             tlog.Debug(tag, $"ViewImplSetBackgroundColor START");
115
116             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
117             {
118                 var testingTarget = new ViewWrapper("CustomView", impl);
119                 Assert.IsNotNull(testingTarget, "should be not null");
120                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
121
122                 using (Vector4 color = new Vector4(0.3f, 0.5f, 0.9f, 1.0f))
123                 {
124                     testingTarget.viewWrapperImpl.SetBackgroundColor(color);
125                     //tlog.Debug(tag, "BackgroundColor : " + wrapper.viewWrapperImpl.GetBackgroundColor());
126                 }
127
128                 testingTarget.Dispose();
129             }
130
131             tlog.Debug(tag, $"ViewImplSetBackgroundColor END (OK)");
132         }
133
134         [Test]
135         [Category("P1")]
136         [Description("ViewImpl SetBackground.")]
137         [Property("SPEC", "Tizen.NUI.ViewImpl.SetBackground M")]
138         [Property("SPEC_URL", "-")]
139         [Property("CRITERIA", "MR")]
140         [Property("COVPARAM", "")]
141         [Property("AUTHOR", "guowei.wang@samsung.com")]
142         public void ViewImplSetBackground()
143         {
144             tlog.Debug(tag, $"ViewImplSetBackground START");
145
146             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
147             {
148                 var testingTarget = new ViewWrapper("CustomView", impl);
149                 Assert.IsNotNull(testingTarget, "should be not null");
150                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
151
152                 using (ColorVisual colorVisual = new ColorVisual())
153                 {
154                     colorVisual.Color = Color.Cyan;
155
156                     try
157                     {
158                         testingTarget.viewWrapperImpl.SetBackground(colorVisual.OutputVisualMap);
159                     }
160                     catch (Exception e)
161                     {
162                         tlog.Debug(tag, e.Message.ToString());
163                         Assert.Fail("Caught Exception : Failed!");
164                     }
165                 }
166
167                 testingTarget.viewWrapperImpl.ClearBackground();
168
169                 testingTarget.Dispose();
170             }
171
172             tlog.Debug(tag, $"ViewImplSetBackground END (OK)");
173         }
174
175         [Test]
176         [Category("P1")]
177         [Description("ViewImpl EnableGestureDetection.")]
178         [Property("SPEC", "Tizen.NUI.ViewImpl.EnableGestureDetection M")]
179         [Property("SPEC_URL", "-")]
180         [Property("CRITERIA", "MR")]
181         [Property("COVPARAM", "")]
182         [Property("AUTHOR", "guowei.wang@samsung.com")]
183         public void ViewImplEnableGestureDetection()
184         {
185             tlog.Debug(tag, $"ViewImplEnableGestureDetection START");
186
187             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
188             {
189                 var testingTarget = new ViewWrapper("CustomView", impl);
190                 Assert.IsNotNull(testingTarget, "should be not null");
191                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
192
193                 try
194                 {
195                     testingTarget.viewWrapperImpl.EnableGestureDetection(Gesture.GestureType.LongPress);
196                     testingTarget.viewWrapperImpl.DisableGestureDetection(Gesture.GestureType.LongPress);
197                 }
198                 catch (Exception e)
199                 {
200                     tlog.Debug(tag, e.Message.ToString());
201                     Assert.Fail("Caught Exception : Failed!");
202                 }
203
204                 testingTarget.Dispose();
205             }
206
207             tlog.Debug(tag, $"ViewImplEnableGestureDetection (OK)");
208         }
209
210         [Test]
211         [Category("P1")]
212         [Description("ViewImpl GetPinchGestureDetector.")]
213         [Property("SPEC", "Tizen.NUI.ViewImpl.GetPinchGestureDetector M")]
214         [Property("SPEC_URL", "-")]
215         [Property("CRITERIA", "MR")]
216         [Property("COVPARAM", "")]
217         [Property("AUTHOR", "guowei.wang@samsung.com")]
218         public void ViewImplGetGestureDetector()
219         {
220             tlog.Debug(tag, $"ViewImplGetGestureDetector START");
221
222             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
223             {
224                 var testingTarget = new ViewWrapper("CustomView", impl);
225                 Assert.IsNotNull(testingTarget, "should be not null");
226                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
227
228                 var pinchGesture = testingTarget.viewWrapperImpl.GetPinchGestureDetector();
229                 Assert.IsInstanceOf<PinchGestureDetector>(pinchGesture, "should be an instance of testing target class!");
230
231                 var panGesture = testingTarget.viewWrapperImpl.GetPanGestureDetector();
232                 Assert.IsInstanceOf<PanGestureDetector>(panGesture, "should be an instance of testing target class!");
233
234                 var tapGesture = testingTarget.viewWrapperImpl.GetTapGestureDetector();
235                 Assert.IsInstanceOf<TapGestureDetector>(tapGesture, "should be an instance of testing target class!");
236
237                 var pressGesture = testingTarget.viewWrapperImpl.GetLongPressGestureDetector();
238                 Assert.IsInstanceOf<LongPressGestureDetector>(pressGesture, "should be an instance of testing target class!");
239
240                 testingTarget.Dispose();
241             }
242
243             tlog.Debug(tag, $"ViewImplGetGestureDetector (OK)");
244         }
245
246         [Test]
247         [Category("P1")]
248         [Description("ViewImpl SetKeyInputFocus.")]
249         [Property("SPEC", "Tizen.NUI.ViewImpl.SetKeyInputFocus M")]
250         [Property("SPEC_URL", "-")]
251         [Property("CRITERIA", "MR")]
252         [Property("COVPARAM", "")]
253         [Property("AUTHOR", "guowei.wang@samsung.com")]
254         public void ViewImplSetKeyInputFocus()
255         {
256             tlog.Debug(tag, $"ViewImplSetKeyInputFocus START");
257
258             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
259             {
260                 var testingTarget = new ViewWrapper("CustomView", impl);
261                 Assert.IsNotNull(testingTarget, "should be not null");
262                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
263
264                 testingTarget.viewWrapperImpl.SetKeyInputFocus();
265                 var result = testingTarget.viewWrapperImpl.HasKeyInputFocus();
266                 tlog.Debug(tag, "HasKeyInputFocus : " + result);
267                 testingTarget.viewWrapperImpl.ClearKeyInputFocus();
268
269                 testingTarget.Dispose();
270             }
271
272             tlog.Debug(tag, $"ViewImplSetKeyInputFocus (OK)");
273         }
274
275         [Test]
276         [Category("P1")]
277         [Description("ViewImpl KeyEventSignal.")]
278         [Property("SPEC", "Tizen.NUI.ViewImpl.KeyEventSignal M")]
279         [Property("SPEC_URL", "-")]
280         [Property("CRITERIA", "MR")]
281         [Property("COVPARAM", "")]
282         [Property("AUTHOR", "guowei.wang@samsung.com")]
283         public void ViewImplSignal()
284         {
285             tlog.Debug(tag, $"ViewImplSignal START");
286
287             using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
288             {
289                 var testingTarget = new ViewWrapper("CustomView", impl);
290                 Assert.IsNotNull(testingTarget, "should be not null");
291                 Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
292
293                 var signal = testingTarget.viewWrapperImpl.KeyEventSignal();
294                 Assert.IsInstanceOf<ControlKeySignal>(signal, "Should return ControlKeySignal instance.");
295
296                 var focusGained = testingTarget.viewWrapperImpl.KeyInputFocusGainedSignal();
297                 Assert.IsInstanceOf<KeyInputFocusSignal>(focusGained, "Should return ControlKeySignal instance.");
298
299                 var focusLost = testingTarget.viewWrapperImpl.KeyInputFocusLostSignal();
300                 Assert.IsInstanceOf<KeyInputFocusSignal>(focusLost, "Should return ControlKeySignal instance.");
301
302                 testingTarget.Dispose();
303             }
304
305             tlog.Debug(tag, $"ViewImplSignal (OK)");
306         }
307
308         //[Test]
309         //[Category("P1")]
310         //[Description("ViewImpl EmitKeyEventSignal.")]
311         //[Property("SPEC", "Tizen.NUI.ViewImpl.EmitKeyEventSignal M")]
312         //[Property("SPEC_URL", "-")]
313         //[Property("CRITERIA", "MR")]
314         //[Property("COVPARAM", "")]
315         //[Property("AUTHOR", "guowei.wang@samsung.com")]
316         //public void ViewImplEmitKeyEventSignal()
317         //{
318         //    tlog.Debug(tag, $"ViewImplEmitKeyEventSignal START");
319
320         //    using (ViewWrapperImpl impl = new ViewWrapperImpl(CustomViewBehaviour.ViewBehaviourDefault))
321         //    {
322         //        var testingTarget = new ViewWrapper("CustomView", impl);
323         //        Assert.IsNotNull(testingTarget, "should be not null");
324         //        Assert.IsInstanceOf<ViewWrapper>(testingTarget, "should be an instance of testing target class!");
325
326         //        using (Key key = new Key())
327         //        {
328         //            var result = testingTarget.viewWrapperImpl.EmitKeyEventSignal(key);
329         //            tlog.Debug(tag, "EmitKeyEventSignal : " + result);
330         //        }
331
332         //        testingTarget.Dispose();
333         //    }
334
335         //    tlog.Debug(tag, $"ViewImplEmitKeyEventSignal (OK)");
336         //}
337     }
338 }