[NUI] Add Componets.Devel project to implement Tizen.NUI.Components's line coverage.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / Program.cs
1 /*
2  *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16
17 using System;
18 using NUnitLite.TUnit;
19 using Tizen.NUI;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Components;
22 using System.Threading;
23 using System.Diagnostics;
24 using System.Threading.Tasks;
25
26 namespace Tizen.NUI.Devel.Tests
27 {
28     using tlog = Tizen.Log;
29     public class App : Tizen.NUI.NUIApplication
30     {
31         static string tag = "NUITEST";
32
33         public App() : base()
34         {
35             tlog.Debug(tag, "Call App()");
36         }
37
38         View root;
39         public static TextLabel mainTitle;
40         static string title = "NUI Auto TCT \n\n";
41         float textSize = 30.0f;
42         Window window;
43         Layer layer;
44         public static int mainPid;
45         public static int mainTid;
46
47         protected override void OnCreate()
48         {
49             base.OnCreate();
50
51             tlog.Debug(tag, "OnCreate() START!");
52
53             mainPid = Process.GetCurrentProcess().Id;
54             mainTid = Thread.CurrentThread.ManagedThreadId;
55
56             window = NUIApplication.GetDefaultWindow();
57             window.BackgroundColor = Color.Green;
58
59             root = new View()
60             {
61                 Size = new Size(100, 100),
62                 BackgroundColor = Color.White,
63                 PositionUsesPivotPoint = true,
64                 ParentOrigin = ParentOrigin.Center,
65                 PivotPoint = PivotPoint.Center,
66             };
67
68             layer = window.GetDefaultLayer();
69             layer.Add(root);
70
71             mainTitle = new TextLabel()
72             {
73                 MultiLine = true,
74                 Text = title + $"Process ID: {Process.GetCurrentProcess().Id} \nThread ID: {Thread.CurrentThread.ManagedThreadId}\n",
75                 PixelSize = textSize,
76                 BackgroundColor = Color.Cyan,
77                 Size = new Size(window.WindowSize.Width * 0.9f, window.WindowSize.Height * 0.9f, 0),
78                 PositionUsesPivotPoint = true,
79                 ParentOrigin = ParentOrigin.Center,
80                 PivotPoint = PivotPoint.Center,
81             };
82             root.Add(mainTitle);
83
84             tlog.Debug(tag, "OnCreate() END!");
85         }
86
87         static public async Task MainTitleChangeBackgroundColor(Color color)
88         {
89             if (color != null)
90             {
91                 mainTitle.BackgroundColor = color;
92                 await Task.Delay(900);
93             }
94         }
95
96         static public async Task MainTitleChangeText(string tcTitle)
97         {
98             if (tcTitle != null)
99             {
100                 var processId = Process.GetCurrentProcess().Id;
101                 var threadId = Thread.CurrentThread.ManagedThreadId;
102
103                 mainTitle.Text = $"{title}\nProcess ID: {processId}\nThread ID: {threadId}\n TC: {tcTitle}";
104                 await Task.Delay(20);
105
106                 tlog.Debug(tag, $"{title}\nProcess ID: {processId}\nThread ID: {threadId}\n TC: {tcTitle}");
107             }
108         }
109
110         protected override void OnResume()
111         {
112             base.OnResume();
113
114             tlog.Debug(tag, $"### OnResume() START!");
115
116             TRunner t = new TRunner();
117             t.LoadTestsuite();
118             t.Execute();
119
120             tlog.Debug(tag, $"OnResume() END!");
121         }
122
123         protected override void OnPause()
124         {
125             base.OnPause();
126         }
127
128         protected override void OnTerminate()
129         {
130             base.OnTerminate();
131             Exit();
132         }
133
134         static void Main(string[] args)
135         {
136             tlog.Debug(tag, "NUI RUN!");
137             App example = new App();
138             example.Run(args);
139         }
140     };
141 }