[NUI] Add Layouting(public) TCs.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.TCT / testcase / public / Layouting / TSILayoutParent.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 using System.Collections.Generic;
7
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("public/Layouting/ILayoutParent")]
14     public class PublicILayoutParentTest
15     {
16         private const string tag = "NUITEST";
17         private static bool flagOnILayoutParentAdd;
18         private static bool flagOnILayoutParentRemove;
19
20         [SetUp]
21         public void Init()
22         {
23             tlog.Info(tag, "Init() is called!");
24         }
25
26         [TearDown]
27         public void Destroy()
28         {
29             tlog.Info(tag, "Destroy() is called!");
30         }
31
32         internal class MyILayoutParent : ILayoutParent
33         {
34             public MyILayoutParent() : base()
35             { }
36
37             public void Add(LayoutItem layoutItem)
38             {
39                 flagOnILayoutParentAdd = true;
40             }
41
42             public void Remove(LayoutItem layoutItem)
43             {
44                 flagOnILayoutParentRemove = true;
45             }
46         }
47
48         [Test]
49         [Category("P1")]
50         [Description("ILayoutParent Add")]
51         [Property("SPEC", "Tizen.NUI.ILayoutParent.Add M")]
52         [Property("SPEC_URL", "-")]
53         [Property("CRITERIA", "MR")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         public void ILayoutParentAdd()
56         {
57             tlog.Debug(tag, $"ILayoutParentAdd START");
58
59             flagOnILayoutParentAdd = false;
60             Assert.False(flagOnILayoutParentAdd, "flagOnILayoutParentAdd should be false initial");
61
62             var testingTarget = new MyILayoutParent();
63             Assert.IsNotNull(testingTarget, "null handle");
64             Assert.IsInstanceOf<ILayoutParent>(testingTarget, "Should be an instance of ILayoutParent type.");
65
66             using (LayoutItem layoutItem = new LayoutItem())
67             {
68                 testingTarget.Add(layoutItem);
69                 Assert.IsTrue(flagOnILayoutParentAdd);
70             }
71             
72             tlog.Debug(tag, $"ILayoutParentAdd END (OK)");
73         }
74
75         [Test]
76         [Category("P1")]
77         [Description("ILayoutParent Remove")]
78         [Property("SPEC", "Tizen.NUI.ILayoutParent.Remove M")]
79         [Property("SPEC_URL", "-")]
80         [Property("CRITERIA", "MR")]
81         [Property("AUTHOR", "guowei.wang@samsung.com")]
82         public void ILayoutParentRemove()
83         {
84             tlog.Debug(tag, $"ILayoutParentRemove START");
85
86             flagOnILayoutParentAdd = false;
87             Assert.False(flagOnILayoutParentAdd, "flagOnILayoutParentAdd should be false initial");
88
89             flagOnILayoutParentRemove = false;
90             Assert.False(flagOnILayoutParentRemove, "flagOnILayoutParentRemove should be false initial");
91
92             var testingTarget = new MyILayoutParent();
93             Assert.IsNotNull(testingTarget, "null handle");
94             Assert.IsInstanceOf<ILayoutParent>(testingTarget, "Should be an instance of ILayoutParent type.");
95
96             using (LayoutItem layoutItem = new LayoutItem())
97             {
98                 testingTarget.Add(layoutItem);
99                 Assert.IsTrue(flagOnILayoutParentAdd);
100
101                 testingTarget.Remove(layoutItem);
102                 Assert.IsTrue(flagOnILayoutParentRemove);
103             }
104
105             tlog.Debug(tag, $"ILayoutParentRemove END (OK)");
106         }
107     }
108 }