Release 9.0.0.16429
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Transition / TSTransitionItem.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/Transition/TransitionItem")]
13     class TSTransitionItem
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("TransitionItem constructor.")]
32         [Property("SPEC", "Tizen.NUI.TransitionItem.TransitionItem C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void TransitionItemConstructor()
37         {
38             tlog.Debug(tag, $"TransitionItemConstructor START");
39
40             View currentView = new View()
41             {
42                 Name = "currentPage",
43                 TransitionOptions = new TransitionOptions(Window.Instance)
44             };
45             currentView.TransitionOptions.TransitionTag = "Transition";
46             currentView.TransitionOptions.EnableTransition = true;
47
48             View newView = new View()
49             {
50                 Name = "newPage",
51                 TransitionOptions = new TransitionOptions(Window.Instance)
52             };
53             newView.TransitionOptions.TransitionTag = "Transition";
54             newView.TransitionOptions.EnableTransition = true;
55
56             AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default);
57             TimePeriod timePeriod = new TimePeriod(500);
58
59             var testingTarget = new TransitionItem(currentView, newView, timePeriod, alphaFunction);
60             Assert.IsNotNull(testingTarget, "Should be not null!");
61             Assert.IsInstanceOf<TransitionItem>(testingTarget, "Should be an Instance of TransitionItem!");
62
63             newView.Dispose();
64             currentView.Dispose();
65             timePeriod.Dispose();
66             alphaFunction.Dispose();
67             testingTarget.Dispose();
68             tlog.Debug(tag, $"TransitionItemConstructor END (OK)");
69         }
70
71         [Test]
72         [Category("P1")]
73         [Description("TransitionItem ShowSourceAfterFinished.")]
74         [Property("SPEC", "Tizen.NUI.TransitionItem.ShowSourceAfterFinished A")]
75         [Property("SPEC_URL", "-")]
76         [Property("CRITERIA", "PROW")]
77         [Property("AUTHOR", "guowei.wang@samsung.com")]
78         public void TransitionItemShowSourceAfterFinished()
79         {
80             tlog.Debug(tag, $"TransitionItemShowSourceAfterFinished START");
81
82             View currentView = new View()
83             {
84                 Name = "currentPage",
85                 TransitionOptions = new TransitionOptions(Window.Instance)
86             };
87             currentView.TransitionOptions.TransitionTag = "Transition";
88             currentView.TransitionOptions.EnableTransition = true;
89
90             View newView = new View()
91             {
92                 Name = "newPage",
93                 TransitionOptions = new TransitionOptions(Window.Instance)
94             };
95             newView.TransitionOptions.TransitionTag = "Transition";
96             newView.TransitionOptions.EnableTransition = true;
97
98             AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default);
99             TimePeriod timePeriod = new TimePeriod(500);
100
101             var testingTarget = new TransitionItem(currentView, newView, timePeriod, alphaFunction);
102             Assert.IsNotNull(testingTarget, "Should be not null!");
103             Assert.IsInstanceOf<TransitionItem>(testingTarget, "Should be an Instance of TransitionItem!");
104
105             try
106             {
107                 testingTarget.ShowSourceAfterFinished = true;
108             }
109             catch (Exception e)
110             {
111                 tlog.Error(tag, "Caught Exception" + e.ToString());
112                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
113                 Assert.Fail("Caught Exception" + e.ToString());
114             }
115
116             newView.Dispose();
117             currentView.Dispose();
118             timePeriod.Dispose();
119             alphaFunction.Dispose();
120             testingTarget.Dispose();
121             tlog.Debug(tag, $"TransitionItemShowSourceAfterFinished END (OK)");
122         }
123
124         [Test]
125         [Category("P1")]
126         [Description("TransitionItem Assign.")]
127         [Property("SPEC", "Tizen.NUI.TransitionItem.Assign M")]
128         [Property("SPEC_URL", "-")]
129         [Property("CRITERIA", "MR")]
130         [Property("AUTHOR", "guowei.wang@samsung.com")]
131         public void TransitionItemAssign()
132         {
133             tlog.Debug(tag, $"TransitionItemAssign START");
134
135             View currentView = new View()
136             {
137                 Name = "currentPage",
138                 TransitionOptions = new TransitionOptions(Window.Instance)
139             };
140             currentView.TransitionOptions.TransitionTag = "Transition";
141             currentView.TransitionOptions.EnableTransition = true;
142
143             View newView = new View()
144             {
145                 Name = "newPage",
146                 TransitionOptions = new TransitionOptions(Window.Instance)
147             };
148             newView.TransitionOptions.TransitionTag = "Transition";
149             newView.TransitionOptions.EnableTransition = true;
150
151             AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default);
152             TimePeriod timePeriod = new TimePeriod(500);
153
154             var testingTarget = new TransitionItem(currentView, newView, timePeriod, alphaFunction);
155             Assert.IsNotNull(testingTarget, "Should be not null!");
156             Assert.IsInstanceOf<TransitionItem>(testingTarget, "Should be an Instance of TransitionItem!");
157
158             using (TransitionItem rhs = new TransitionItem(testingTarget))
159             {
160                 var result = testingTarget.Assign(rhs);
161                 Assert.IsNotNull(result, "Should be not null!");
162                 Assert.IsInstanceOf<TransitionItem>(result, "Should be an Instance of TransitionItem!");
163             }
164
165             currentView?.Dispose();
166             newView?.Dispose();
167             timePeriod?.Dispose();
168             alphaFunction?.Dispose();
169             testingTarget?.Dispose();
170             tlog.Debug(tag, $"TransitionItemAssign END (OK)");
171         }
172
173         [Test]
174         [Category("P1")]
175         [Description("TransitionItem Dispose.")]
176         [Property("SPEC", "Tizen.NUI.TransitionItem.Dispose M")]
177         [Property("SPEC_URL", "-")]
178         [Property("CRITERIA", "MR")]
179         [Property("AUTHOR", "guowei.wang@samsung.com")]
180         public void TransitionItemDispose()
181         {
182             tlog.Debug(tag, $"TransitionItemDispose START");
183
184             View currentView = new View()
185             {
186                 Name = "currentPage",
187                 TransitionOptions = new TransitionOptions(Window.Instance)
188             };
189             currentView.TransitionOptions.TransitionTag = "Transition";
190             currentView.TransitionOptions.EnableTransition = true;
191
192             View newView = new View()
193             {
194                 Name = "newPage",
195                 TransitionOptions = new TransitionOptions(Window.Instance)
196             };
197             newView.TransitionOptions.TransitionTag = "Transition";
198             newView.TransitionOptions.EnableTransition = true;
199
200             AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default);
201             TimePeriod timePeriod = new TimePeriod(500);
202
203             var testingTarget = new TransitionItem(currentView, newView, timePeriod, alphaFunction);
204             Assert.IsNotNull(testingTarget, "Should be not null!");
205             Assert.IsInstanceOf<TransitionItem>(testingTarget, "Should be an Instance of TransitionItem!");
206
207             try
208             {
209                 testingTarget.Dispose();
210             }
211             catch (Exception e)
212             {
213                 tlog.Error(tag, "Caught Exception" + e.ToString());
214                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
215                 Assert.Fail("Caught Exception" + e.ToString());
216             }
217
218             currentView?.Dispose();
219             newView?.Dispose();
220             timePeriod?.Dispose();
221             alphaFunction?.Dispose();
222             tlog.Debug(tag, $"TransitionItemDispose END (OK)");
223         }
224     }
225 }