[NUI] Add Animation(Public) TCs.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.TCT / testcase / public / Animation / TSKeyFrames.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("public/Animation/KeyFrames")]
13     public class PublicKeyFramesTest
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("KeyFrames constructor")]
32         [Property("SPEC", "Tizen.NUI.KeyFrames.KeyFrames C")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "CONSTR")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void KeyFramesConstructor()
37         {
38             tlog.Debug(tag, $"KeyFramesConstructor START");
39
40             var testingTarget = new KeyFrames();
41             Assert.IsNotNull(testingTarget, "should be not null");
42             Assert.IsInstanceOf<KeyFrames>(testingTarget, "should be an instance of KeyFrames class!");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"KeyFramesConstructor END (OK)");
46         }
47
48         [Test]
49         [Category("P1")]
50         [Description("KeyFrames Add. Add a key frame with object value ")]
51         [Property("SPEC", "Tizen.NUI.KeyFrames.Add M")]
52         [Property("SPEC_URL", "-")]
53         [Property("CRITERIA", "MR")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         public void KeyFramesAddWithObject()
56         {
57             tlog.Debug(tag, $"KeyFramesAddWithObject START");
58
59             var testingTarget = new KeyFrames();
60             Assert.IsNotNull(testingTarget, "should be not null");
61             Assert.IsInstanceOf<KeyFrames>(testingTarget, "should be an instance of KeyFrames class!");
62
63             Position pos = new Position(10.0f, 20.0f, 30.0f);
64             testingTarget.Add(0.3f, pos);
65
66             var result = testingTarget.GetType().ToString();
67             Assert.IsTrue("Vector3" == result);
68
69             testingTarget.Dispose();
70             tlog.Debug(tag, $"KeyFramesAddWithObject END (OK)");
71         }
72
73         [Test]
74         [Category("P1")]
75         [Description("KeyFrames Add. Add a key frame with object value and alpha function")]
76         [Property("SPEC", "Tizen.NUI.KeyFrames.Add M")]
77         [Property("SPEC_URL", "-")]
78         [Property("CRITERIA", "MR")]
79         [Property("AUTHOR", "guowei.wang@samsung.com")]
80         public void KeyFramesAddWithObjectAndAlphaFunc()
81         {
82             tlog.Debug(tag, $"KeyFramesAddWithObjectAndAlphaFunc START");
83
84             var testingTarget = new KeyFrames();
85             Assert.IsNotNull(testingTarget, "should be not null");
86             Assert.IsInstanceOf<KeyFrames>(testingTarget, "should be an instance of KeyFrames class!");
87
88             Position pos = new Position(10.0f, 20.0f, 30.0f);
89             AlphaFunction linear = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
90             try
91             {
92                 testingTarget.Add(0.3f, pos, linear);
93                 Assert.IsTrue("Vector3" == testingTarget.GetType().ToString());
94             }
95             catch (Exception e)
96             {
97                 tlog.Error(tag, "Caught Exception" + e.ToString());
98                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
99                 Assert.Fail("Caught Exception" + e.ToString());
100             }
101
102             pos.Dispose();
103             linear.Dispose();
104             testingTarget.Dispose();
105             tlog.Debug(tag, $"KeyFramesAddWithObjectAndAlphaFunc END (OK)");
106         }
107
108         [Test]
109         [Category("P1")]
110         [Description("KeyFrames GetType")]
111         [Property("SPEC", "Tizen.NUI.KeyFrames.GetType M")]
112         [Property("SPEC_URL", "-")]
113         [Property("CRITERIA", "MR")]
114         [Property("AUTHOR", "guowei.wang@samsung.com")]
115         public void KeyFramesGetType()
116         {
117             tlog.Debug(tag, $"KeyFramesGetType START");
118
119             var testingTarget = new KeyFrames();
120             Assert.IsNotNull(testingTarget, "should be not null");
121             Assert.IsInstanceOf<KeyFrames>(testingTarget, "should be an instance of KeyFrames class!");
122
123             Color color = Color.Yellow;
124             testingTarget.Add(0.3f, color);
125
126             var result = testingTarget.GetType().ToString();
127             Assert.IsTrue("Vector4" == result);
128
129             testingTarget.Dispose();
130             tlog.Debug(tag, $"KeyFramesGetType END (OK)");
131         }
132
133         [Test]
134         [Category("P1")]
135         [Description("KeyFrames Add. Add a key frame with property value ")]
136         [Property("SPEC", "Tizen.NUI.KeyFrames.Add M")]
137         [Property("SPEC_URL", "-")]
138         [Property("CRITERIA", "MR")]
139         [Property("AUTHOR", "guowei.wang@samsung.com")]
140         public void KeyFramesAddWithPropertyValue()
141         {
142             tlog.Debug(tag, $"KeyFramesAddWithPropertyValue START");
143
144             var testingTarget = new KeyFrames();
145             Assert.IsNotNull(testingTarget, "should be not null");
146             Assert.IsInstanceOf<KeyFrames>(testingTarget, "should be an instance of KeyFrames class!");
147
148             PropertyValue dummy = new PropertyValue(true);
149             testingTarget.Add(0.3f, dummy);
150
151             var result = testingTarget.GetType().ToString();
152             Assert.IsTrue("Boolean" == result);
153
154             dummy.Dispose();
155             testingTarget.Dispose();
156             tlog.Debug(tag, $"KeyFramesAddWithPropertyValue END (OK)");
157         }
158
159         [Test]
160         [Category("P1")]
161         [Description("KeyFrames Add. Add a key frame with object property and alpha function")]
162         [Property("SPEC", "Tizen.NUI.KeyFrames.Add M")]
163         [Property("SPEC_URL", "-")]
164         [Property("CRITERIA", "MR")]
165         [Property("AUTHOR", "guowei.wang@samsung.com")]
166         public void KeyFramesAddWithPropertyValueAndAlphaFunc()
167         {
168             tlog.Debug(tag, $"KeyFramesAddWithPropertyValueAndAlphaFunc START");
169
170             var testingTarget = new KeyFrames();
171             Assert.IsNotNull(testingTarget, "should be not null");
172             Assert.IsInstanceOf<KeyFrames>(testingTarget, "should be an instance of KeyFrames class!");
173
174             PropertyValue dummy = new PropertyValue(true);
175             AlphaFunction ease = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut);
176             try
177             {
178                 testingTarget.Add(0.3f, dummy, ease);
179                 Assert.IsTrue("Boolean" == testingTarget.GetType().ToString());
180             }
181             catch (Exception e)
182             {
183                 tlog.Error(tag, "Caught Exception" + e.ToString());
184                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
185                 Assert.Fail("Caught Exception" + e.ToString());
186             }
187
188             dummy.Dispose();
189             ease.Dispose();
190             testingTarget.Dispose();
191             tlog.Debug(tag, $"KeyFramesAddWithPropertyValueAndAlphaFunc END (OK)");
192         }
193     }
194 }