Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Application / TSNUIComponentApplication.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
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("public/Application/NUIComponentApplication")]
14     class PublicNUIComponentApplicationTest
15     {
16         private const string tag = "NUITEST";
17
18         internal class MyNUIComponentApplication : NUIComponentApplication
19         {
20             public MyNUIComponentApplication(IDictionary<Type, string> typeInfo) : base(typeInfo)
21             { }
22
23             public void MyOnCreate() {   base.OnCreate();    }
24
25             public void MyOnTerminate() {   base.OnTerminate();    }
26
27             public void MyExit() { base.Exit(); }
28         }
29
30         [SetUp]
31         public void Init()
32         {
33             tlog.Info(tag, "Init() is called!");
34         }
35
36         [TearDown]
37         public void Destroy()
38         {
39             tlog.Info(tag, "Destroy() is called!");
40         }
41
42         [Test]
43         [Category("P1")]
44         [Description("NUIComponentApplication constructor.")]
45         [Property("SPEC", "Tizen.NUI.NUIComponentApplication.NUIComponentApplication M")]
46         [Property("SPEC_URL", "-")]
47         [Property("CRITERIA", "MR")]
48         [Property("AUTHOR", "guowei.wang@samsung.com")]
49         public void NUIComponentApplicationConstructor()
50         {
51             tlog.Debug(tag, $"NUIComponentApplicationConstructor START");
52
53             IDictionary<Type, string> typeInfo = new Dictionary<Type, string>();
54             typeInfo.Add(typeof(Applications.ComponentBased.Common.FrameComponent), "FrameComponent");
55             typeInfo.Add(typeof(Applications.ComponentBased.Common.ServiceComponent), "ServiceComponent");
56             var testingTarget = new NUIComponentApplication(typeInfo);
57             Assert.IsNotNull(testingTarget, "Should be not null.");
58             Assert.IsInstanceOf<NUIComponentApplication>(testingTarget, "Should be an instance of NUIComponentApplication type.");
59
60             testingTarget.Dispose();
61             tlog.Debug(tag, $"NUIComponentApplicationConstructor END (OK)");
62         }
63
64         [Test]
65         [Category("P2")]
66         [Description("NUIComponentApplication constructor. With illegal type.")]
67         [Property("SPEC", "Tizen.NUI.NUIComponentApplication.NUIComponentApplication M")]
68         [Property("SPEC_URL", "-")]
69         [Property("CRITERIA", "MR")]
70         [Property("AUTHOR", "guowei.wang@samsung.com")]
71         public void NUIComponentApplicationConstructorWithIllegalType()
72         {
73             tlog.Debug(tag, $"NUIComponentApplicationConstructorWithIllegalType START");
74
75             IDictionary<Type, string> typeInfo = new Dictionary<Type, string>();
76             typeInfo.Add(typeof(Widget), "Widget");
77
78             try
79             {
80                 new NUIComponentApplication(typeInfo);
81             }
82             catch (ArgumentException e)
83             {
84                 tlog.Debug(tag, e.Message.ToString());
85                 tlog.Debug(tag, $"NUIComponentApplicationConstructorWithIllegalType END (OK)");
86                 Assert.Pass("Caught ArgumentException: Passed!");
87             }
88         }
89
90         [Test]
91         [Category("P2")]
92         [Description("NUIComponentApplication constructor. With null parameter.")]
93         [Property("SPEC", "Tizen.NUI.NUIComponentApplication.NUIComponentApplication M")]
94         [Property("SPEC_URL", "-")]
95         [Property("CRITERIA", "MR")]
96         [Property("AUTHOR", "guowei.wang@samsung.com")]
97         public void NUIComponentApplicationConstructorWithNull()
98         {
99             tlog.Debug(tag, $"NUIComponentApplicationConstructorWithNull START");
100
101             var testingTarget = new NUIComponentApplication(null);
102             Assert.IsNotNull(testingTarget, "Should be not null.");
103             Assert.IsInstanceOf<NUIComponentApplication>(testingTarget, "Should be an instance of NUIComponentApplication type.");
104
105             testingTarget.Dispose();
106             tlog.Debug(tag, $"NUIComponentApplicationConstructorWithNull END (OK)");
107         }
108
109         [Test]
110         [Category("P1")]
111         [Description("NUIComponentApplication OnCreate.")]
112         [Property("SPEC", "Tizen.NUI.NUIComponentApplication.OnCreate M")]
113         [Property("SPEC_URL", "-")]
114         [Property("CRITERIA", "MR")]
115         [Property("AUTHOR", "guowei.wang@samsung.com")]
116         public void NUIComponentApplicationOnCreate()
117         {
118             tlog.Debug(tag, $"NUIComponentApplicationOnCreate START");
119
120             IDictionary<Type, string> typeInfo = new Dictionary<Type, string>();
121             typeInfo.Add(typeof(Applications.ComponentBased.Common.FrameComponent), "FrameComponent");
122             var testingTarget = new MyNUIComponentApplication(typeInfo);
123             Assert.IsNotNull(testingTarget, "Should be not null.");
124             Assert.IsInstanceOf<NUIComponentApplication>(testingTarget, "Should be an instance of NUIComponentApplication type.");
125
126             try
127             {
128                 testingTarget.MyOnCreate();
129             }
130             catch (Exception e)
131             {
132                 tlog.Debug(tag, e.Message.ToString());
133                 Assert.Fail("Caught Exception: Failed!");
134             }
135
136             testingTarget.Dispose();
137             tlog.Debug(tag, $"NUIComponentApplicationOnCreate END (OK)");
138         }
139
140         [Test]
141         [Category("P1")]
142         [Description("NUIComponentApplication OnTerminate.")]
143         [Property("SPEC", "Tizen.NUI.NUIComponentApplication.OnTerminate M")]
144         [Property("SPEC_URL", "-")]
145         [Property("CRITERIA", "MR")]
146         [Property("AUTHOR", "guowei.wang@samsung.com")]
147         public void NUIComponentApplicationOnTerminate()
148         {
149             tlog.Debug(tag, $"NUIComponentApplicationOnCreate START");
150
151             IDictionary<Type, string> typeInfo = new Dictionary<Type, string>();
152             typeInfo.Add(typeof(Applications.ComponentBased.Common.FrameComponent), "FrameComponent");
153             var testingTarget = new MyNUIComponentApplication(typeInfo);
154             Assert.IsNotNull(testingTarget, "Should be not null.");
155             Assert.IsInstanceOf<NUIComponentApplication>(testingTarget, "Should be an instance of NUIComponentApplication type.");
156
157             try
158             {
159                 testingTarget.MyOnTerminate();
160             }
161             catch (Exception e)
162             {
163                 tlog.Debug(tag, e.Message.ToString());
164                 Assert.Fail("Caught Exception: Failed!");
165             }
166
167             testingTarget.Dispose();
168             tlog.Debug(tag, $"NUIComponentApplicationOnCreate END (OK)");
169         }
170
171         [Test]
172         [Category("P1")]
173         [Description("NUIComponentApplication Exit.")]
174         [Property("SPEC", "Tizen.NUI.NUIComponentApplication.Exit M")]
175         [Property("SPEC_URL", "-")]
176         [Property("CRITERIA", "MR")]
177         [Property("AUTHOR", "guowei.wang@samsung.com")]
178         public void NUIComponentApplicationExit()
179         {
180             tlog.Debug(tag, $"NUIComponentApplicationExit START");
181
182             IDictionary<Type, string> typeInfo = new Dictionary<Type, string>();
183             typeInfo.Add(typeof(Applications.ComponentBased.Common.FrameComponent), "FrameComponent");
184             var testingTarget = new MyNUIComponentApplication(typeInfo);
185             Assert.IsNotNull(testingTarget, "Should be not null.");
186             Assert.IsInstanceOf<NUIComponentApplication>(testingTarget, "Should be an instance of NUIComponentApplication type.");
187
188             try
189             {
190                 testingTarget.MyExit();
191             }
192             catch (Exception e)
193             {
194                 tlog.Debug(tag, e.Message.ToString());
195                 Assert.Fail("Caught Exception: Failed!");
196             }
197
198             testingTarget.Dispose();
199             tlog.Debug(tag, $"NUIComponentApplicationExit END (OK)");
200         }
201
202     }
203 }