[NUI] Update TCs of NUI.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Common / TSCustomActorImpl.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/CustomActorImpl")]
13     public class InternalCustomActorImplTest
14     {
15         private const string tag = "NUITEST";
16         private View actor = null;
17
18         internal class MyCustomActorImpl : CustomActorImpl
19         {
20             public MyCustomActorImpl(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
21             { 
22             }
23         }
24
25         [SetUp]
26         public void Init()
27         {
28             tlog.Info(tag, "Init() is called!");
29             actor = new View() { Size = new Size(100, 200) };
30         }
31
32         [TearDown]
33         public void Destroy()
34         {
35             actor.Dispose();
36             tlog.Info(tag, "Destroy() is called!");
37         }
38
39         [Test]
40         [Category("P1")]
41         [Description("CustomActorImpl constructor.")]
42         [Property("SPEC", "Tizen.NUI.CustomActorImpl.CustomActorImpl C")]
43         [Property("SPEC_URL", "-")]
44         [Property("CRITERIA", "CONSTR")]
45         [Property("AUTHOR", "guowei.wang@samsung.com")]
46         public void CustomActorImplConstructor()
47         {
48             tlog.Debug(tag, $"CustomActorImplConstructor START");
49
50             var testingTarget = new CustomActorImpl(actor.SwigCPtr.Handle, false);
51             Assert.IsNotNull(testingTarget, "Should be not null!");
52             Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
53
54             testingTarget.Dispose();
55             tlog.Debug(tag, $"CustomActorImplConstructor END (OK)");
56         }
57
58         [Test]
59         [Category("P1")]
60         [Description("CustomActorImpl IsRelayoutEnabled.")]
61         [Property("SPEC", "Tizen.NUI.CustomActorImpl.IsRelayoutEnabled M")]
62         [Property("SPEC_URL", "-")]
63         [Property("CRITERIA", "MR")]
64         [Property("AUTHOR", "guowei.wang@samsung.com")]
65         public void CustomActorImplIsRelayoutEnabled()
66         {
67             tlog.Debug(tag, $"CustomActorImplIsRelayoutEnabled START");
68
69             using (View view = new View())
70             {
71                 var testingTarget = NDalic.GetImplementation(view);
72                 Assert.IsNotNull(testingTarget, "Should be not null!");
73                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
74
75                 tlog.Debug(tag, "getCPtr : " + CustomActorImpl.getCPtr(testingTarget));
76
77                 var result = testingTarget.IsRelayoutEnabled();
78                 tlog.Debug(tag, "IsRelayoutEnabled : " + result);
79
80                 testingTarget.Dispose();
81             }
82
83             tlog.Debug(tag, $"CustomActorImplIsRelayoutEnabled END (OK)");
84         }
85
86         [Test]
87         [Category("P1")]
88         [Description("CustomActorImpl RelayoutDependentOnChildren.")]
89         [Property("SPEC", "Tizen.NUI.CustomActorImpl.RelayoutDependentOnChildren M")]
90         [Property("SPEC_URL", "-")]
91         [Property("CRITERIA", "MR")]
92         [Property("AUTHOR", "guowei.wang@samsung.com")]
93         public void CustomActorImplRelayoutDependentOnChildren()
94         {
95             tlog.Debug(tag, $"CustomActorImplRelayoutDependentOnChildren START");
96
97             using (View view = new View())
98             {
99                 var testingTarget = NDalic.GetImplementation(view);
100                 Assert.IsNotNull(testingTarget, "Should be not null!");
101                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
102
103                 var result = testingTarget.RelayoutDependentOnChildren();
104                 tlog.Debug(tag, "RelayoutDependentOnChildren : " + result);
105
106                 result = testingTarget.RelayoutDependentOnChildren(DimensionType.Height);
107                 tlog.Debug(tag, "RelayoutDependentOnChildren : " + result);
108
109                 testingTarget.Dispose();
110             }
111
112             tlog.Debug(tag, $"CustomActorImplRelayoutDependentOnChildren END (OK)");
113         }
114
115
116         [Test]
117         [Category("P1")]
118         [Description("CustomActorImpl Self.")]
119         [Property("SPEC", "Tizen.NUI.CustomActorImpl.Self M")]
120         [Property("SPEC_URL", "-")]
121         [Property("CRITERIA", "MR")]
122         [Property("AUTHOR", "guowei.wang@samsung.com")]
123         public void CustomActorImplSelf()
124         {
125             tlog.Debug(tag, $"CustomActorImplSelf START");
126
127             using (View view = new View())
128             {
129                 var testingTarget = NDalic.GetImplementation(view).Self();
130                 Assert.IsNotNull(testingTarget, "Should be not null!");
131                 Assert.IsInstanceOf<CustomActor>(testingTarget, "Should be an Instance of CustomActor!");
132
133                 testingTarget.Dispose();
134             }
135
136             tlog.Debug(tag, $"CustomActorImplSelf END (OK)");
137         }
138
139         [Test]
140         [Category("P1")]
141         [Description("CustomActorImpl OnSceneConnection.")]
142         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnSceneConnection M")]
143         [Property("SPEC_URL", "-")]
144         [Property("CRITERIA", "MR")]
145         [Property("AUTHOR", "guowei.wang@samsung.com")]
146         public void CustomActorImplOnSceneConnection()
147         {
148             tlog.Debug(tag, $"CustomActorImplOnSceneConnection START");
149
150             using (View view = new View())
151             {
152                 var testingTarget = NDalic.GetImplementation(view);
153                 Assert.IsNotNull(testingTarget, "Should be not null!");
154                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
155
156                 try
157                 {
158                     testingTarget.OnSceneConnection(1);
159                     testingTarget.OnSceneDisconnection();
160                 }
161                 catch (Exception e)
162                 {
163                     tlog.Debug(tag, e.Message.ToString());
164                     Assert.Fail("Caught Exception : Failed!");
165                 }
166
167                 testingTarget.Dispose();
168             }
169
170             tlog.Debug(tag, $"CustomActorImplOnSceneConnection END (OK)");
171         }
172
173         [Test]
174         [Category("P1")]
175         [Description("CustomActorImpl OnChildAdd.")]
176         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnChildAdd M")]
177         [Property("SPEC_URL", "-")]
178         [Property("CRITERIA", "MR")]
179         [Property("AUTHOR", "guowei.wang@samsung.com")]
180         public void CustomActorImplOnChildAdd()
181         {
182             tlog.Debug(tag, $"CustomActorImplOnChildAdd START");
183
184             using (View view = new View())
185             {
186                 var testingTarget = NDalic.GetImplementation(view);
187                 Assert.IsNotNull(testingTarget, "Should be not null!");
188                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
189
190                 using (View child = new View())
191                 {
192                     try
193                     {
194                         testingTarget.OnChildAdd(child);
195                         
196                         var result = testingTarget.CalculateChildSize(child, DimensionType.Width);
197                         tlog.Debug(tag, "CalculateChildSize : " + result);
198
199                         testingTarget.OnChildRemove(child);
200                     }
201                     catch (Exception e)
202                     {
203                         tlog.Debug(tag, e.Message.ToString());
204                         Assert.Fail("Caught Exception : Failed!");
205                     }
206                 }
207
208                 testingTarget.Dispose();
209             }
210
211             tlog.Debug(tag, $"CustomActorImplOnChildAdd END (OK)");
212         }
213
214         [Test]
215         [Category("P1")]
216         [Description("CustomActorImpl OnPropertySet.")]
217         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnPropertySet M")]
218         [Property("SPEC_URL", "-")]
219         [Property("CRITERIA", "MR")]
220         [Property("AUTHOR", "guowei.wang@samsung.com")]
221         public void CustomActorImplOnPropertySet()
222         {
223             tlog.Debug(tag, $"CustomActorImplOnPropertySet START");
224
225             using (View view = new View())
226             {
227                 var testingTarget = NDalic.GetImplementation(view);
228                 Assert.IsNotNull(testingTarget, "Should be not null!");
229                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
230
231                 try
232                 {
233
234                     testingTarget.OnPropertySet(View.Property.OPACITY, new PropertyValue(0.3f));
235                 }
236                 catch (Exception e)
237                 {
238                     tlog.Debug(tag, e.Message.ToString());
239                     Assert.Fail("Caught Exception : Failed!");
240                 }
241
242                 testingTarget.Dispose();
243             }
244
245             tlog.Debug(tag, $"CustomActorImplOnPropertySet END (OK)");
246         }
247
248         [Test]
249         [Category("P1")]
250         [Description("CustomActorImpl OnLayoutNegotiated.")]
251         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnLayoutNegotiated M")]
252         [Property("SPEC_URL", "-")]
253         [Property("CRITERIA", "MR")]
254         [Property("AUTHOR", "guowei.wang@samsung.com")]
255         public void CustomActorImplOnLayoutNegotiated()
256         {
257             tlog.Debug(tag, $"CustomActorImplOnLayoutNegotiated START");
258
259             using (View view = new View())
260             {
261                 var testingTarget = NDalic.GetImplementation(view);
262                 Assert.IsNotNull(testingTarget, "Should be not null!");
263                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
264
265                 try
266                 {
267                     testingTarget.OnLayoutNegotiated(100.0f, DimensionType.Width);
268                 }
269                 catch (Exception e)
270                 {
271                     tlog.Debug(tag, e.Message.ToString());
272                     Assert.Fail("Caught Exception : Failed!");
273                 }
274
275                 testingTarget.Dispose();
276             }
277
278             tlog.Debug(tag, $"CustomActorImplOnLayoutNegotiated END (OK)");
279         }
280
281         [Test]
282         [Category("P1")]
283         [Description("CustomActorImpl OnSetResizePolicy.")]
284         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnSetResizePolicy M")]
285         [Property("SPEC_URL", "-")]
286         [Property("CRITERIA", "MR")]
287         [Property("AUTHOR", "guowei.wang@samsung.com")]
288         public void CustomActorImplOnSetResizePolicy()
289         {
290             tlog.Debug(tag, $"CustomActorImplOnSetResizePolicy START");
291
292             using (View view = new View())
293             {
294                 var testingTarget = NDalic.GetImplementation(view);
295                 Assert.IsNotNull(testingTarget, "Should be not null!");
296                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
297
298                 try
299                 {
300                     testingTarget.OnSetResizePolicy(ResizePolicyType.Fixed, DimensionType.Width);
301                 }
302                 catch (Exception e)
303                 {
304                     tlog.Debug(tag, e.Message.ToString());
305                     Assert.Fail("Caught Exception : Failed!");
306                 }
307
308                 testingTarget.Dispose();
309             }
310
311             tlog.Debug(tag, $"CustomActorImplOnSetResizePolicy END (OK)");
312         }
313
314         [Test]
315         [Category("P1")]
316         [Description("CustomActorImpl OnCalculateRelayoutSize.")]
317         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnCalculateRelayoutSize M")]
318         [Property("SPEC_URL", "-")]
319         [Property("CRITERIA", "MR")]
320         [Property("AUTHOR", "guowei.wang@samsung.com")]
321         public void CustomActorImplOnCalculateRelayoutSize()
322         {
323             tlog.Debug(tag, $"CustomActorImplOnCalculateRelayoutSize START");
324
325             using (View view = new View())
326             {
327                 var testingTarget = NDalic.GetImplementation(view);
328                 Assert.IsNotNull(testingTarget, "Should be not null!");
329                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
330
331                 try
332                 {
333                     testingTarget.OnCalculateRelayoutSize(DimensionType.AllDimensions);
334                 }
335                 catch (Exception e)
336                 {
337                     tlog.Debug(tag, e.Message.ToString());
338                     Assert.Fail("Caught Exception : Failed!");
339                 }
340
341                 testingTarget.Dispose();
342             }
343
344             tlog.Debug(tag, $"CustomActorImplOnCalculateRelayoutSize END (OK)");
345         }
346
347         [Test]
348         [Category("P1")]
349         [Description("CustomActorImpl GetHeightForWidth.")]
350         [Property("SPEC", "Tizen.NUI.CustomActorImpl.GetHeightForWidth M")]
351         [Property("SPEC_URL", "-")]
352         [Property("CRITERIA", "MR")]
353         [Property("AUTHOR", "guowei.wang@samsung.com")]
354         public void CustomActorImplGetHeightForWidth()
355         {
356             tlog.Debug(tag, $"CustomActorImplGetHeightForWidth START");
357
358             using (View view = new View())
359             {
360                 var testingTarget = NDalic.GetImplementation(view);
361                 Assert.IsNotNull(testingTarget, "Should be not null!");
362                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
363
364                 var size = testingTarget.GetNaturalSize();
365                 Assert.IsInstanceOf<Vector3>(size, "Should be an Instance of Vector3!");
366
367                 var result = testingTarget.GetHeightForWidth(100.0f);
368                 tlog.Debug(tag, "GetHeightForWidth : " + result);
369
370                 result = testingTarget.GetWidthForHeight(50.0f);
371                 tlog.Debug(tag, "GetWidthForHeight : " + result);
372       
373                 testingTarget.Dispose();
374             }
375
376             tlog.Debug(tag, $"CustomActorImplGetHeightForWidth END (OK)");
377         }
378
379         [Test]
380         [Category("P1")]
381         [Description("CustomActorImpl OnSizeAnimation.")]
382         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnSizeAnimation M")]
383         [Property("SPEC_URL", "-")]
384         [Property("CRITERIA", "MR")]
385         [Property("AUTHOR", "guowei.wang@samsung.com")]
386         public void CustomActorImplOnSizeAnimation()
387         {
388             tlog.Debug(tag, $"CustomActorImplOnSizeAnimation START");
389
390             using (View view = new View())
391             {
392                 var testingTarget = NDalic.GetImplementation(view);
393                 Assert.IsNotNull(testingTarget, "Should be not null!");
394                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
395
396                 try
397                 {
398                     using (Animation ani = new Animation(300))
399                     {
400                         using (Vector3 vector = new Vector3(100.0f, 20.0f, 80.0f))
401                         {
402                             testingTarget.OnSizeAnimation(ani, vector);
403                         }
404                     }
405                 }
406                 catch (Exception e)
407                 {
408                     tlog.Debug(tag, e.Message.ToString());
409                     Assert.Fail("Caught Exception : Failed!");
410                 }
411
412                 testingTarget.Dispose();
413             }
414
415             tlog.Debug(tag, $"CustomActorImplOnSizeAnimation END (OK)");
416         }
417
418         [Test]
419         [Category("P1")]
420         [Description("CustomActorImpl OnSizeSet.")]
421         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnSizeSet M")]
422         [Property("SPEC_URL", "-")]
423         [Property("CRITERIA", "MR")]
424         [Property("AUTHOR", "guowei.wang@samsung.com")]
425         public void CustomActorImplOnSizeSet()
426         {
427             tlog.Debug(tag, $"CustomActorImplOnSizeSet START");
428
429             using (View view = new View())
430             {
431                 var testingTarget = NDalic.GetImplementation(view);
432                 Assert.IsNotNull(testingTarget, "Should be not null!");
433                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
434
435                 try
436                 {
437                     using (Vector3 vector = new Vector3(100.0f, 20.0f, 80.0f))
438                     {
439                         testingTarget.OnSizeSet(vector);
440                     }
441                 }
442                 catch (Exception e)
443                 {
444                     tlog.Debug(tag, e.Message.ToString());
445                     Assert.Fail("Caught Exception : Failed!");
446                 }
447
448                 testingTarget.Dispose();
449             }
450
451             tlog.Debug(tag, $"CustomActorImplOnSizeSet END (OK)");
452         }
453
454         [Test]
455         [Category("P1")]
456         [Description("CustomActorImpl OnRelayout.")]
457         [Property("SPEC", "Tizen.NUI.CustomActorImpl.OnRelayout M")]
458         [Property("SPEC_URL", "-")]
459         [Property("CRITERIA", "MR")]
460         [Property("AUTHOR", "guowei.wang@samsung.com")]
461         public void CustomActorImplOnRelayout()
462         {
463             tlog.Debug(tag, $"CustomActorImplOnRelayout START");
464
465             using (View view = new View())
466             {
467                 var testingTarget = NDalic.GetImplementation(view);
468                 Assert.IsNotNull(testingTarget, "Should be not null!");
469                 Assert.IsInstanceOf<CustomActorImpl>(testingTarget, "Should be an Instance of CustomActorImpl!");
470
471                 using (Vector2 vector = new Vector2(100.0f, 20.0f))
472                 {
473                     using (RelayoutContainer container = new RelayoutContainer(view.SwigCPtr.Handle, false))
474                     {
475                         try
476                         {
477                             testingTarget.OnRelayout(vector, container);
478                         }
479                         catch (Exception e)
480                         {
481                             tlog.Debug(tag, e.Message.ToString());
482                             Assert.Fail("Caught Exception : Failed!");
483                         }
484                     }
485                 }
486
487                 testingTarget.Dispose();
488             }
489
490             tlog.Debug(tag, $"CustomActorImplOnRelayout END (OK)");
491         }
492     }
493 }