[NUI] Update TCs of NUI.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Common / TSFrameUpdateCallbackInterface.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 using System.Runtime.InteropServices;
8
9 namespace Tizen.NUI.Devel.Tests
10 {
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("public/Common/FrameUpdateCallbackInterface")]
15     class PublicFrameUpdateCallbackInterfaceTest
16     {
17         private const string tag = "NUITEST";
18
19         internal class MyFrameUpdateCallbackInterface : FrameUpdateCallbackInterface
20         {
21             public MyFrameUpdateCallbackInterface() : base()
22             { }
23
24             public View view = new View()
25             {
26                 Size = new Size(100, 150, 40),
27                 Position = new Position(20, 40),
28                 Color = Color.Cyan
29             };
30
31             public override void OnUpdate(float elapsedSeconds)
32             {
33                 base.GetPosition(view.ID, new Position(100.0f, 150.0f, 0.0f));
34                 base.SetPosition(view.ID, new Position(100.0f, 150.0f, 0.0f));
35                 base.BakePosition(view.ID, new Position(100.0f, 150.0f, 0.0f));
36                 base.GetSize(view.ID, new Size(100.0f, 150.0f, 0.0f));
37                 base.SetSize(view.ID, new Size(100.0f, 150.0f, 0.0f));
38                 base.BakeSize(view.ID, new Size(100.0f, 150.0f, 0.0f));
39                 base.GetScale(view.ID, new Vector3(100.0f, 150.0f, 0.0f));
40                 base.SetScale(view.ID, new Vector3(100.0f, 150.0f, 0.0f));
41                 base.BakeScale(view.ID, new Vector3(100.0f, 150.0f, 0.0f));
42                 base.GetColor(view.ID, new Color(100.0f, 150.0f, 0.0f, 200.0f));
43                 base.SetColor(view.ID, new Color(100.0f, 150.0f, 0.0f, 200.0f));
44                 base.BakeColor(view.ID, new Color(100.0f, 150.0f, 0.0f, 200.0f));
45                 base.GetPositionAndSize(view.ID, new Position(100.0f, 150.0f, 0.0f), new Size(100.0f, 200.0f, 300.0f));
46                 base.OnUpdate(300);
47             }
48         }
49
50         [SetUp]
51         public void Init()
52         {
53             tlog.Info(tag, "Init() is called!");
54         }
55
56         [TearDown]
57         public void Destroy()
58         {
59             tlog.Info(tag, "Destroy() is called!");
60         }
61
62         [Test]
63         [Category("P1")]
64         [Description("FrameUpdateCallbackInterface constructor.")]
65         [Property("SPEC", "Tizen.NUI.FrameUpdateCallbackInterface.FrameUpdateCallbackInterface C")]
66         [Property("SPEC_URL", "-")]
67         [Property("CRITERIA", "CONSTR")]
68         [Property("AUTHOR", "guowei.wang@samsung.com")]
69         public void FrameUpdateCallbackInterfaceConstructor()
70         {
71             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceConstructor START");
72
73             var testingTarget = new FrameUpdateCallbackInterface();
74             Assert.IsNotNull(testingTarget, "Can't create success object FrameUpdateCallbackInterface");
75             Assert.IsInstanceOf<FrameUpdateCallbackInterface>(testingTarget, "Should return FrameUpdateCallbackInterface instance.");
76
77             testingTarget.Dispose();
78             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceConstructor END (OK)");
79         }
80
81         [Test]
82         [Category("P1")]
83         [Description("FrameUpdateCallbackInterface getCPtr.")]
84         [Property("SPEC", "Tizen.NUI.FrameUpdateCallbackInterface.getCPtr C")]
85         [Property("SPEC_URL", "-")]
86         [Property("CRITERIA", "CONSTR")]
87         [Property("AUTHOR", "guowei.wang@samsung.com")]
88         public void FrameUpdateCallbackInterfaceGetCPtr()
89         {
90             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceGetCPtr START");
91
92             var testingTarget = new FrameUpdateCallbackInterface();
93             Assert.IsNotNull(testingTarget, "Can't create success object FrameUpdateCallbackInterface");
94             Assert.IsInstanceOf<FrameUpdateCallbackInterface>(testingTarget, "Should return FrameUpdateCallbackInterface instance.");
95
96             tlog.Debug(tag, "getCPtr : " + FrameUpdateCallbackInterface.getCPtr(testingTarget));
97
98             testingTarget.Dispose();
99             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceGetCPtr END (OK)");
100         }
101
102         [Test]
103         [Category("P1")]
104         [Description("FrameUpdateCallbackInterface OnUpdate.")]
105         [Property("SPEC", "Tizen.NUI.FrameUpdateCallbackInterface.OnUpdate M")]
106         [Property("SPEC_URL", "-")]
107         [Property("CRITERIA", "MR")]
108         [Property("AUTHOR", "guowei.wang@samsung.com")]
109         public void FrameUpdateCallbackInterfaceOnUpdate()
110         {
111             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceOnUpdate START");
112
113             var testingTarget = new MyFrameUpdateCallbackInterface();
114             Assert.IsNotNull(testingTarget, "Can't create success object FrameUpdateCallbackInterface");
115             Assert.IsInstanceOf<FrameUpdateCallbackInterface>(testingTarget, "Should return FrameUpdateCallbackInterface instance.");
116
117             try
118             {
119                 testingTarget.OnUpdate(300);
120             }
121             catch (Exception e)
122             {
123                 tlog.Debug(tag, e.Message.ToString());
124                 Assert.Fail("Caught Exception : Failed!");
125             }
126
127             testingTarget.Dispose();
128             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceOnUpdate END (OK)");
129         }
130
131         [Test]
132         [Category("P1")]
133         [Description("FrameUpdateCallbackInterface AddFrameUpdateCallback.")]
134         [Property("SPEC", "Tizen.NUI.FrameUpdateCallbackInterface.AddFrameUpdateCallback M")]
135         [Property("SPEC_URL", "-")]
136         [Property("CRITERIA", "MR")]
137         [Property("AUTHOR", "guowei.wang@samsung.com")]
138         public void FrameUpdateCallbackInterfaceAddFrameUpdateCallback()
139         {
140             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceAddFrameUpdateCallback START");
141
142             var testingTarget = new MyFrameUpdateCallbackInterface();
143             Assert.IsNotNull(testingTarget, "Can't create success object FrameUpdateCallbackInterface");
144             Assert.IsInstanceOf<FrameUpdateCallbackInterface>(testingTarget, "Should return FrameUpdateCallbackInterface instance.");
145
146             try
147             {
148                 NUIApplication.GetDefaultWindow().AddFrameUpdateCallback(testingTarget);
149                 NUIApplication.GetDefaultWindow().RemoveFrameUpdateCallback(testingTarget);
150             }
151             catch (Exception e)
152             {
153                 Assert.Fail("Caught Exception" + e.ToString());
154             }
155
156             testingTarget.Dispose();
157             tlog.Debug(tag, $"FrameUpdateCallbackInterfaceAddFrameUpdateCallback END (OK)");
158         }
159     }
160 }