78756481c2283a79bf8aa5af84219b36a37db73e
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Transition / TSTransitionSet.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/TransitionSet")]
13     class TSTransitionSet
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("TransitionSet constructor.")]
32         [Property("SPEC", "Tizen.NUI.TransitionSet.TransitionSet C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void TransitionSetConstructor()
37         {
38             tlog.Debug(tag, $"TransitionSetConstructor START");
39
40             var testingTarget = new TransitionSet();
41             Assert.IsNotNull(testingTarget, "Should be not null!");
42             Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"TransitionSetConstructor END (OK)");
46         }
47
48         [Test]
49         [Category("P1")]
50         [Description("TransitionSet DownCast.")]
51         [Property("SPEC", "Tizen.NUI.TransitionSet.DownCast M")]
52         [Property("SPEC_URL", "-")]
53         [Property("CRITERIA", "MR")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         public void TransitionSetDownCast()
56         {
57             tlog.Debug(tag, $"TransitionSetDownCast START");
58
59             using (TransitionSet transitionSet = new TransitionSet())
60             {
61                 var testingTarget = TransitionSet.DownCast(transitionSet);
62                 Assert.IsNotNull(testingTarget, "Should be not null!");
63                 Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
64
65                 testingTarget.Dispose();
66             }
67
68             tlog.Debug(tag, $"TransitionSetDownCast END (OK)");
69         }
70
71         [Test]
72         [Category("P1")]
73         [Description("TransitionSet AddTransition.")]
74         [Property("SPEC", "Tizen.NUI.TransitionSet.AddTransition M")]
75         [Property("SPEC_URL", "-")]
76         [Property("CRITERIA", "MR")]
77         [Property("AUTHOR", "guowei.wang@samsung.com")]
78         public void TransitionSetAddTransition()
79         {
80             tlog.Debug(tag, $"TransitionSetAddTransition START");
81
82             View view = new View()
83             {
84                 Name = "view",
85                 TransitionOptions = new TransitionOptions(Window.Instance)
86             };
87             view.TransitionOptions.TransitionTag = "Transition";
88             view.TransitionOptions.EnableTransition = true;
89
90             TransitionItemBase transitionItemBase = null;
91             using (TimePeriod timePeriod = new TimePeriod(500))
92             {
93                 using (AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default))
94                 {
95                     transitionItemBase = new TransitionItemBase(view, true, timePeriod, alphaFunction);
96                 }
97             }
98
99             var testingTarget = new TransitionSet();
100             Assert.IsNotNull(testingTarget, "Should be not null!");
101             Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
102
103             try
104             {
105                 testingTarget.AddTransition(transitionItemBase);
106             }
107             catch (Exception e)
108             {
109                 tlog.Error(tag, "Caught Exception" + e.ToString());
110                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
111                 Assert.Fail("Caught Exception" + e.ToString());
112             }
113
114             view.Dispose();
115             transitionItemBase.Dispose();
116             testingTarget.Dispose();
117             tlog.Debug(tag, $"TransitionSetAddTransition END (OK)");
118         }
119
120         //[Test]
121         //[Category("P1")]
122         //[Description("TransitionSet Finished.")]
123         //[Property("SPEC", "Tizen.NUI.TransitionSet.Finished A")]
124         //[Property("SPEC_URL", "-")]
125         //[Property("CRITERIA", "PRW")]
126         //[Property("AUTHOR", "guowei.wang@samsung.com")]
127         //public void TransitionSetFinished()
128         //{
129         //    tlog.Debug(tag, $"TransitionSetFinished START");
130
131         //    using (View view = new View())
132         //    {
133         //        var testingTarget = new TransitionSet(view.SwigCPtr.Handle, false);
134         //        Assert.IsNotNull(testingTarget, "Should be not null!");
135         //        Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
136
137         //        testingTarget.Finished += MyOnFinished;
138         //        testingTarget.Finished -= MyOnFinished;
139
140         //        testingTarget.Dispose();
141         //    }
142
143         //    tlog.Debug(tag, $"TransitionSetFinished END (OK)");
144         //}
145
146         //private void MyOnFinished(object sender, EventArgs e) { }
147
148         [Test]
149         [Category("P1")]
150         [Description("TransitionSet GetTransitionAt.")]
151         [Property("SPEC", "Tizen.NUI.TransitionSet.GetTransitionAt M")]
152         [Property("SPEC_URL", "-")]
153         [Property("CRITERIA", "MR")]
154         [Property("AUTHOR", "guowei.wang@samsung.com")]
155         public void TransitionSetGetTransitionAt()
156         {
157             tlog.Debug(tag, $"TransitionSetGetTransitionAt START");
158
159             using (View view = new View())
160             {
161                 var testingTarget = new TransitionSet(view.SwigCPtr.Handle, false);
162                 Assert.IsNotNull(testingTarget, "Should be not null!");
163                 Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
164
165                 try
166                 {
167                     testingTarget.GetTransitionAt(0);
168                 }
169                 catch (Exception e)
170                 {
171                     tlog.Error(tag, "Caught Exception" + e.ToString());
172                     LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
173                     Assert.Fail("Caught Exception" + e.ToString());
174                 }
175             }
176
177             tlog.Debug(tag, $"TransitionSetGetTransitionAt END (OK)");
178         }
179
180         [Test]
181         [Category("P1")]
182         [Description("TransitionSet GetTransitionCount.")]
183         [Property("SPEC", "Tizen.NUI.TransitionSet.GetTransitionCount M")]
184         [Property("SPEC_URL", "-")]
185         [Property("CRITERIA", "MR")]
186         [Property("AUTHOR", "guowei.wang@samsung.com")]
187         public void TransitionSetGetTransitionCount()
188         {
189             tlog.Debug(tag, $"TransitionSetGetTransitionCount START");
190
191             using (View view = new View())
192             {
193                 var testingTarget = new TransitionSet(view.SwigCPtr.Handle, false);
194                 Assert.IsNotNull(testingTarget, "Should be not null!");
195                 Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
196
197                 try
198                 {
199                     testingTarget.GetTransitionCount();
200                 }
201                 catch (Exception e)
202                 {
203                     tlog.Error(tag, "Caught Exception" + e.ToString());
204                     LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
205                     Assert.Fail("Caught Exception" + e.ToString());
206                 }
207             }
208
209             tlog.Debug(tag, $"TransitionSetGetTransitionCount END (OK)");
210         }
211
212         [Test]
213         [Category("P1")]
214         [Description("TransitionSet Play.")]
215         [Property("SPEC", "Tizen.NUI.TransitionSet.Play M")]
216         [Property("SPEC_URL", "-")]
217         [Property("CRITERIA", "MR")]
218         [Property("AUTHOR", "guowei.wang@samsung.com")]
219         public void TransitionSetPlay()
220         {
221             tlog.Debug(tag, $"TransitionSetPlay START");
222
223             using (View view = new View())
224             {
225                 var testingTarget = new TransitionSet(view.SwigCPtr.Handle, false);
226                 Assert.IsNotNull(testingTarget, "Should be not null!");
227                 Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
228
229                 try
230                 {
231                     testingTarget.Play();
232                 }
233                 catch (Exception e)
234                 {
235                     tlog.Error(tag, "Caught Exception" + e.ToString());
236                     LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
237                     Assert.Fail("Caught Exception" + e.ToString());
238                 }
239             }
240
241             tlog.Debug(tag, $"TransitionSetPlay END (OK)");
242         }
243
244         [Test]
245         [Category("P1")]
246         [Description("TransitionSet Assign.")]
247         [Property("SPEC", "Tizen.NUI.TransitionSet.Assign M")]
248         [Property("SPEC_URL", "-")]
249         [Property("CRITERIA", "MR")]
250         [Property("AUTHOR", "guowei.wang@samsung.com")]
251         public void TransitionSetAssign()
252         {
253             tlog.Debug(tag, $"TransitionSetAssign START");
254
255             using (View view = new View())
256             {
257                 var testingTarget = new TransitionSet(view.SwigCPtr.Handle, false);
258                 Assert.IsNotNull(testingTarget, "Should be not null!");
259                 Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
260
261                 try
262                 {
263                     testingTarget.Assign(testingTarget);
264                 }
265                 catch (Exception e)
266                 {
267                     tlog.Error(tag, "Caught Exception" + e.ToString());
268                     LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
269                     Assert.Fail("Caught Exception" + e.ToString());
270                 }
271             }
272
273             tlog.Debug(tag, $"TransitionSetAssign END (OK)");
274         }
275
276         [Test]
277         [Category("P1")]
278         [Description("TransitionSet FinishedSignal.")]
279         [Property("SPEC", "Tizen.NUI.TransitionSet.FinishedSignal M")]
280         [Property("SPEC_URL", "-")]
281         [Property("CRITERIA", "MR")]
282         [Property("AUTHOR", "guowei.wang@samsung.com")]
283         public void TransitionSetFinishedSignal()
284         {
285             tlog.Debug(tag, $"TransitionSetFinishedSignal START");
286
287             using (View view = new View())
288             {
289                 var testingTarget = new TransitionSet(view.SwigCPtr.Handle, false);
290                 Assert.IsNotNull(testingTarget, "Should be not null!");
291                 Assert.IsInstanceOf<TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");
292
293                 try
294                 {
295                     testingTarget.FinishedSignal();
296                 }
297                 catch (Exception e)
298                 {
299                     tlog.Error(tag, "Caught Exception" + e.ToString());
300                     LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
301                     Assert.Fail("Caught Exception" + e.ToString());
302                 }
303             }
304
305             tlog.Debug(tag, $"TransitionSetFinishedSignal END (OK)");
306         }
307     }
308 }