[NUI] Add Application(Internal & Public) TCs.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.TCT / testcase / internal / Application / TSNUICoreBackend.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 namespace Tizen.NUI.Devel.Tests
7 {
8     using tlog = Tizen.Log;
9
10     [TestFixture]
11     [Description("internal/Application/NUICoreBackend")]
12     public class InternalNUICoreBackendTest
13     {
14         private const string tag = "NUITEST";
15         private event EventHandler Created;
16         protected virtual void OnCreate()
17         {
18             Created?.Invoke(this, EventArgs.Empty);
19         }
20
21         [SetUp]
22         public void Init()
23         {
24             tlog.Info(tag, "Init() is called!");
25         }
26
27         [TearDown]
28         public void Destroy()
29         {
30             tlog.Info(tag, "Destroy() is called!");
31         }
32
33         [Test]
34         [Description("NUICoreBackend constructor")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void NUICoreBackendConstructor()
37         {
38             tlog.Debug(tag, $"NUICoreBackendConstructor START");
39
40             var testingTarget = new NUICoreBackend();
41             Assert.IsNotNull(testingTarget, "should be not null");
42             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
43
44             testingTarget.Dispose();
45             tlog.Debug(tag, $"NUICoreBackendConstructor END (OK)");
46         }
47
48         [Test]
49         [Description("NUICoreBackend constructor with stylesheet")]
50         [Property("AUTHOR", "guowei.wang@samsung.com")]
51         public void NUICoreBackendConstructorWithStylesheet()
52         {
53             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheet START");
54
55             var dummy = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/style/Test_Style_Manager.json";
56             var testingTarget = new NUICoreBackend(dummy);
57             Assert.IsNotNull(testingTarget, "should be not null");
58             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
59
60             testingTarget.Dispose();
61             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheet END (OK)");
62         }
63
64         [Test]
65         [Description("NUICoreBackend constructor with stylesheet and windowMode")]
66         [Property("AUTHOR", "guowei.wang@samsung.com")]
67         public void NUICoreBackendConstructorWithStylesheetAndWindowmode()
68         {
69             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheetAndWindowmode START");
70
71             var dummy = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/style/Test_Style_Manager.json";
72             var testingTarget = new NUICoreBackend(dummy, NUIApplication.WindowMode.Opaque);
73             Assert.IsNotNull(testingTarget, "should be not null");
74             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
75
76             testingTarget.Dispose();
77             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheetAndWindowmode END (OK)");
78         }
79
80         [Test]
81         [Description("NUICoreBackend constructor with stylesheet, window mode, window size and window position")]
82         [Property("AUTHOR", "guowei.wang@samsung.com")]
83         public void NUICoreBackendConstructorWithMoreArgs()
84         {
85             tlog.Debug(tag, $"NUICoreBackendConstructorWithMoreArgs START");
86
87             var dummy = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/style/Test_Style_Manager.json";
88             var testingTarget = new NUICoreBackend(dummy, NUIApplication.WindowMode.Opaque, new Size(400, 400), new Position(200, 300));
89             Assert.IsNotNull(testingTarget, "should be not null");
90             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
91
92             testingTarget.Dispose();
93             tlog.Debug(tag, $"NUICoreBackendConstructorWithMoreArgs END (OK)");
94         }
95
96         [Test]
97         [Description("NUICoreBackend AddEventHandler")]
98         [Property("AUTHOR", "guowei.wang@samsung.com")]
99         public void NUICoreBackendAddEventHandler()
100         {
101             tlog.Debug(tag, $"NUICoreBackendAddEventHandler START");
102
103             var testingTarget = new NUICoreBackend();
104             Assert.IsNotNull(testingTarget, "should be not null");
105             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
106
107             testingTarget.AddEventHandler(Tizen.Applications.CoreBackend.EventType.Created, OnCreate);
108
109             testingTarget.Dispose();
110             tlog.Debug(tag, $"NUICoreBackendAddEventHandler END (OK)");
111         }
112
113         [Test]
114         [Description("NUICoreBackend dispose")]
115         [Property("AUTHOR", "guowei.wang@samsung.com")]
116         public void NUICoreBackendDispose()
117         {
118             tlog.Debug(tag, $"NUICoreBackendDispose START");
119
120             var testingTarget = new NUICoreBackend();
121             Assert.IsNotNull(testingTarget, "should be not null");
122             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
123
124             try
125             {
126                 testingTarget.Dispose();
127             }
128             catch (Exception e)
129             {
130                 tlog.Error(tag, "Caught Exception" + e.ToString());
131                 Assert.Fail("Caught Exception" + e.ToString());
132             }
133
134             tlog.Debug(tag, $"NUICoreBackendDispose END (OK)");
135         }
136
137         [Test]
138         [Description("NUICoreBackend exit")]
139         [Property("AUTHOR", "guowei.wang@samsung.com")]
140         public void NUICoreBackendExit()
141         {
142             tlog.Debug(tag, $"NUICoreBackendExit START");
143
144             var testingTarget = new NUICoreBackend();
145             Assert.IsNotNull(testingTarget, "should be not null");
146             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
147
148             try
149             {
150                 testingTarget.Exit();
151             }
152             catch (Exception e)
153             {
154                 tlog.Error(tag, "Caught Exception" + e.ToString());
155                 Assert.Fail("Caught Exception" + e.ToString());
156             }
157
158             testingTarget.Dispose();
159             tlog.Debug(tag, $"NUICoreBackendExit END (OK)");
160         }
161     }
162 }