Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Application / TSNUIWidgetCoreBackend.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 Tizen.Applications.CoreBackend;
8
9 namespace Tizen.NUI.Devel.Tests
10 {
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("internal/Application/NUIWidgetCoreBackend")]
15     public class InternalNUIWidgetCoreBackendTest
16     {
17         private const string tag = "NUITEST";
18         private string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
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         [Test]
33         [Category("P1")]
34         [Description("NUIWidgetCoreBackend constructor.")]
35         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.NUIWidgetCoreBackend C")]
36         [Property("SPEC_URL", "-")]
37         [Property("CRITERIA", "CONSTR")]
38         [Property("AUTHOR", "guowei.wang@samsung.com")]
39         public void NUIWidgetCoreBackendConstructor()
40         {
41             tlog.Debug(tag, $"NUIWidgetCoreBackendConstructor START");
42
43             var testingTarget = new NUIWidgetCoreBackend();
44             Assert.IsNotNull(testingTarget, "should be not null");
45             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
46
47             testingTarget.Dispose();
48             tlog.Debug(tag, $"NUIWidgetCoreBackendConstructor END (OK)");
49         }
50
51         [Test]
52         [Category("P1")]
53         [Description("NUIWidgetCoreBackend AddEventHandler.")]
54         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.AddEventHandler A")]
55         [Property("SPEC_URL", "-")]
56         [Property("CRITERIA", "PRW")]
57         [Property("AUTHOR", "guowei.wang@samsung.com")]
58         public void NUIWidgetCoreBackendAddEventHandler()
59         {
60             tlog.Debug(tag, $"NUIWidgetCoreBackendAddEventHandler START");
61
62             var testingTarget = new NUIWidgetCoreBackend();
63             Assert.IsNotNull(testingTarget, "should be not null");
64             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
65
66             try
67             {
68                 testingTarget.AddEventHandler(EventType.PreCreated, MyOnPreCreate);
69                 testingTarget.AddEventHandler<Tizen.Applications.LowBatteryEventArgs>(EventType.LowBattery, MyOnLowBattery);
70             }
71             catch (Exception e)
72             {
73                 tlog.Debug(tag, e.Message.ToString());
74                 Assert.Fail("Caught Exception: Failed!");
75             }
76
77             testingTarget.Dispose();
78             tlog.Debug(tag, $"NUIWidgetCoreBackendAddEventHandler END (OK)");
79         }
80
81         private void MyOnLowBattery(Tizen.Applications.LowBatteryEventArgs obj) { }
82         private void MyOnPreCreate() { }
83
84         [Test]
85         [Category("P1")]
86         [Description("NUIWidgetCoreBackend constructor. With stylesheet")]
87         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.NUIWidgetCoreBackend C")]
88         [Property("SPEC_URL", "-")]
89         [Property("CRITERIA", "CONSTR")]
90         [Property("AUTHOR", "guowei.wang@samsung.com")]
91         public void NUIWidgetCoreBackendConstructorWithStylesheet()
92         {
93             tlog.Debug(tag, $"NUIWidgetCoreBackendConstructorWithStylesheet START");
94
95             var dummy = resource + "style/Test_Style_Manager.json";
96             var testingTarget = new NUIWidgetCoreBackend(dummy);
97             Assert.IsNotNull(testingTarget, "should be not null");
98             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
99
100             testingTarget.Dispose();
101             tlog.Debug(tag, $"NUIWidgetCoreBackendConstructorWithStylesheet END (OK)");
102         }
103
104         [Test]
105         [Category("P1")]
106         [Description("NUIWidgetCoreBackend dispose.")]
107         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.Dispose M")]
108         [Property("SPEC_URL", "-")]
109         [Property("CRITERIA", "MR")]
110         [Property("AUTHOR", "guowei.wang@samsung.com")]
111         public void NUIWidgetCoreBackendDispose()
112         {
113             tlog.Debug(tag, $"NUIWidgetCoreBackendDispose START");
114
115             var testingTarget = new NUIWidgetCoreBackend();
116             Assert.IsNotNull(testingTarget, "should be not null");
117             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
118
119             try
120             {
121                 testingTarget.Dispose();
122             }
123             catch (Exception e)
124             {
125                 tlog.Error(tag, "Caught Exception" + e.ToString());
126                 Assert.Fail("Caught Exception" + e.ToString());
127             }
128
129             tlog.Debug(tag, $"NUIWidgetCoreBackendDispose END (OK)");
130         }
131
132         [Test]
133         [Category("P1")]
134         [Description("NUIWidgetCoreBackend exit.")]
135         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.Exit M")]
136         [Property("SPEC_URL", "-")]
137         [Property("CRITERIA", "MR")]
138         [Property("AUTHOR", "guowei.wang@samsung.com")]
139         public void NUIWidgetCoreBackendExit()
140         {
141             tlog.Debug(tag, $"NUIWidgetCoreBackendExit START");
142
143             var testingTarget = new NUIWidgetCoreBackend();
144             Assert.IsNotNull(testingTarget, "should be not null");
145             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
146
147             try
148             {
149                 testingTarget.Exit();
150             }
151             catch (Exception e)
152             {
153                 tlog.Error(tag, "Caught Exception" + e.ToString());
154                 Assert.Fail("Caught Exception" + e.ToString());
155             }
156
157             testingTarget.Dispose();
158             tlog.Debug(tag, $"NUIWidgetCoreBackendExit END (OK)");
159         }
160
161         [Test]
162         [Category("P1")]
163         [Description("NUIWidgetCoreBackend RegisterWidgetInfo.")]
164         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.RegisterWidgetInfo M")]
165         [Property("SPEC_URL", "-")]
166         [Property("CRITERIA", "MR")]
167         [Property("AUTHOR", "guowei.wang@samsung.com")]
168         public void NUIWidgetCoreBackendRegisterWidgetInfo()
169         {
170             tlog.Debug(tag, $"NUIWidgetCoreBackendRegisterWidgetInfo START");
171
172             var testingTarget = new NUIWidgetCoreBackend();
173             Assert.IsNotNull(testingTarget, "should be not null");
174             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
175
176             var widgetInfo = new Dictionary<global::System.Type, string>();
177             testingTarget.RegisterWidgetInfo(widgetInfo);
178
179             testingTarget.Dispose();
180             tlog.Debug(tag, $"NUIWidgetCoreBackendRegisterWidgetInfo END (OK)");
181         }
182
183         [Test]
184         [Category("P1")]
185         [Description("NUIWidgetCoreBackend AddWidgetInfo.")]
186         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.AddWidgetInfo M")]
187         [Property("SPEC_URL", "-")]
188         [Property("CRITERIA", "MR")]
189         [Property("AUTHOR", "guowei.wang@samsung.com")]
190         public void NUIWidgetCoreBackendAddWidgetInfo()
191         {
192             tlog.Debug(tag, $"NUIWidgetCoreBackendAddWidgetInfo START");
193
194             var testingTarget = new NUIWidgetCoreBackend();
195             Assert.IsNotNull(testingTarget, "should be not null");
196             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
197
198             var widgetInfo = new Dictionary<global::System.Type, string>();
199             testingTarget.AddWidgetInfo(widgetInfo);
200
201             testingTarget.Dispose();
202             tlog.Debug(tag, $"NUIWidgetCoreBackendAddWidgetInfo END (OK)");
203         }
204
205         [Test]
206         [Category("P1")]
207         [Description("NUIWidgetCoreBackend WidgetApplicationHandle.")]
208         [Property("SPEC", "Tizen.NUI.NUIWidgetCoreBackend.WidgetApplicationHandle A")]
209         [Property("SPEC_URL", "-")]
210         [Property("CRITERIA", "PRO")]
211         [Property("AUTHOR", "guowei.wang@samsung.com")]
212         public void NUIWidgetCoreBackendWidgetApplicationHandle()
213         {
214             tlog.Debug(tag, $"NUIWidgetCoreBackendWidgetApplicationHandle START");
215
216             var testingTarget = new NUIWidgetCoreBackend();
217             Assert.IsNotNull(testingTarget, "should be not null");
218             Assert.IsInstanceOf<NUIWidgetCoreBackend>(testingTarget, "should be an instance of testing target class!");
219
220             try
221             {
222                 var result = testingTarget.WidgetApplicationHandle;
223             }
224             catch (Exception e)
225             {
226                 tlog.Debug(tag, e.Message.ToString());
227                 Assert.Fail("Caught Exception: Failed!");
228             }
229
230             testingTarget.Dispose();
231             tlog.Debug(tag, $"NUIWidgetCoreBackendWidgetApplicationHandle END (OK)");
232         }
233     }
234 }