Revert "[Tizen] Add DALi Autofill implementation"
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor-internal / utc-Dali-Lifecycle-Controller.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
18 // EXTERNAL INCLUDES
19 #include <stdlib.h>
20 #include <iostream>
21 #include <dali.h>
22 #include <dali-test-suite-utils.h>
23 #include <dali/devel-api/adaptor-framework/lifecycle-controller.h>
24
25 #include <dali/internal/adaptor/common/lifecycle-controller-impl.h>
26
27 using namespace Dali;
28
29 void utc_dali_lifecycle_controller_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_lifecycle_controller_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 namespace
40 {
41
42 bool g_OnInitCalled = false;
43 bool g_OnTerminateCalled = false;
44 bool g_OnPauseCalled = false;
45 bool g_OnResumeCalled = false;
46 bool g_OnResetCalled = false;
47 bool g_OnLanguageChangedCalled = false;
48
49 void OnInit()
50 {
51   g_OnInitCalled = true;
52 }
53
54 void OnTerminate()
55 {
56   g_OnTerminateCalled = true;
57 }
58
59 void OnPause()
60 {
61   g_OnPauseCalled = true;
62 }
63
64 void OnResume()
65 {
66   g_OnResumeCalled = true;
67 }
68
69 void OnReset()
70 {
71   g_OnResetCalled = true;
72 }
73
74 void OnLanguageChanged()
75 {
76   g_OnLanguageChangedCalled = true;
77 }
78
79 } // anonymous namespace
80
81 int UtcDaliLifecycleControllerGet(void)
82 {
83   // Attempt to retrieve LifecycleController before creating application
84   LifecycleController lifecycleController;
85   lifecycleController = LifecycleController::Get();
86   DALI_TEST_CHECK( !lifecycleController );
87
88   TestApplication app;
89   Application application = Application::New();
90
91   lifecycleController = LifecycleController::Get();
92   DALI_TEST_CHECK( lifecycleController );
93
94   END_TEST;
95 }
96
97 int UtcDaliLifecycleControllerSignalInit(void)
98 {
99   TestApplication app;
100   Application application = Application::New();
101
102   DALI_TEST_CHECK( !g_OnInitCalled );
103
104   LifecycleController lifecycleController = LifecycleController::Get();
105
106   lifecycleController.InitSignal().Connect( &OnInit );
107
108   GetImplementation( lifecycleController ).OnInit( application );
109
110   DALI_TEST_CHECK( g_OnInitCalled );
111
112   END_TEST;
113 }
114
115 int UtcDaliLifecycleControllerSignalTerminate(void)
116 {
117   TestApplication app;
118   Application application = Application::New();
119
120   DALI_TEST_CHECK( !g_OnTerminateCalled );
121
122   LifecycleController lifecycleController = LifecycleController::Get();
123
124   lifecycleController.TerminateSignal().Connect( &OnTerminate );
125
126   GetImplementation( lifecycleController ).OnTerminate( application );
127
128   DALI_TEST_CHECK( g_OnTerminateCalled );
129
130   END_TEST;
131 }
132
133 int UtcDaliLifecycleControllerSignalPause(void)
134 {
135   TestApplication app;
136   Application application = Application::New();
137
138   DALI_TEST_CHECK( !g_OnPauseCalled );
139
140   LifecycleController lifecycleController = LifecycleController::Get();
141
142   lifecycleController.PauseSignal().Connect( &OnPause );
143
144   GetImplementation( lifecycleController ).OnPause( application );
145
146   DALI_TEST_CHECK( g_OnPauseCalled );
147
148   END_TEST;
149 }
150
151 int UtcDaliLifecycleControllerSignalResume(void)
152 {
153   TestApplication app;
154   Application application = Application::New();
155
156   DALI_TEST_CHECK( !g_OnResumeCalled );
157
158   LifecycleController lifecycleController = LifecycleController::Get();
159
160   lifecycleController.ResumeSignal().Connect( &OnResume );
161
162   GetImplementation( lifecycleController ).OnResume( application );
163
164   DALI_TEST_CHECK( g_OnResumeCalled );
165
166   END_TEST;
167 }
168
169 int UtcDaliLifecycleControllerSignalReset(void)
170 {
171   TestApplication app;
172   Application application = Application::New();
173
174   DALI_TEST_CHECK( !g_OnResetCalled );
175
176   LifecycleController lifecycleController = LifecycleController::Get();
177
178   lifecycleController.ResetSignal().Connect( &OnReset );
179
180   GetImplementation( lifecycleController ).OnReset( application );
181
182   DALI_TEST_CHECK( g_OnResetCalled );
183
184   END_TEST;
185 }
186
187 int UtcDaliLifecycleControllerSignalLanguageChanged(void)
188 {
189   TestApplication app;
190   Application application = Application::New();
191
192   DALI_TEST_CHECK( !g_OnLanguageChangedCalled );
193
194   LifecycleController lifecycleController = LifecycleController::Get();
195
196   lifecycleController.LanguageChangedSignal().Connect( &OnLanguageChanged );
197
198   GetImplementation( lifecycleController ).OnLanguageChanged( application );
199
200   DALI_TEST_CHECK( g_OnLanguageChangedCalled );
201
202   END_TEST;
203 }