Dali 3D User Interface Engine
utc-Dali-Lifecycle-Controller.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 <lifecycle-controller.h>
24 
26 
27 using namespace Dali;
28 
30 {
32 }
33 
35 {
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_OnResizeCalled = false;
49 
50 void OnInit()
51 {
52  g_OnInitCalled = true;
53 }
54 
56 {
57  g_OnTerminateCalled = true;
58 }
59 
60 void OnPause()
61 {
62  g_OnPauseCalled = true;
63 }
64 
65 void OnResume()
66 {
67  g_OnResumeCalled = true;
68 }
69 
70 void OnReset()
71 {
72  g_OnResetCalled = true;
73 }
74 
75 void OnResize()
76 {
77  g_OnResizeCalled = true;
78 }
79 
81 {
82  g_OnLanguageChangedCalled = true;
83 }
84 
85 } // anonymous namespace
86 
88 {
89  // Attempt to retrieve LifecycleController before creating application
90  LifecycleController lifecycleController;
91  lifecycleController = LifecycleController::Get();
92  DALI_TEST_CHECK( !lifecycleController );
93 
94  Application application = Application::New();
95 
96  lifecycleController = LifecycleController::Get();
97  DALI_TEST_CHECK( lifecycleController );
98 
99  END_TEST;
100 }
101 
103 {
104  Application application = Application::New();
105 
107 
108  LifecycleController lifecycleController = LifecycleController::Get();
109 
110  lifecycleController.InitSignal().Connect( &OnInit );
111 
112  GetImplementation( lifecycleController ).OnInit( application );
113 
115 
116  END_TEST;
117 }
118 
120 {
121  Application application = Application::New();
122 
124 
125  LifecycleController lifecycleController = LifecycleController::Get();
126 
127  lifecycleController.TerminateSignal().Connect( &OnTerminate );
128 
129  GetImplementation( lifecycleController ).OnTerminate( application );
130 
132 
133  END_TEST;
134 }
135 
137 {
138  Application application = Application::New();
139 
141 
142  LifecycleController lifecycleController = LifecycleController::Get();
143 
144  lifecycleController.PauseSignal().Connect( &OnPause );
145 
146  GetImplementation( lifecycleController ).OnPause( application );
147 
149 
150  END_TEST;
151 }
152 
154 {
155  Application application = Application::New();
156 
158 
159  LifecycleController lifecycleController = LifecycleController::Get();
160 
161  lifecycleController.ResumeSignal().Connect( &OnResume );
162 
163  GetImplementation( lifecycleController ).OnResume( application );
164 
166 
167  END_TEST;
168 }
169 
171 {
172  Application application = Application::New();
173 
175 
176  LifecycleController lifecycleController = LifecycleController::Get();
177 
178  lifecycleController.ResetSignal().Connect( &OnReset );
179 
180  GetImplementation( lifecycleController ).OnReset( application );
181 
183 
184  END_TEST;
185 }
186 
188 {
189  Application application = Application::New();
190 
192 
193  LifecycleController lifecycleController = LifecycleController::Get();
194 
195  lifecycleController.ResizeSignal().Connect( &OnResize );
196 
197  GetImplementation( lifecycleController ).OnResize( application );
198 
200 
201  END_TEST;
202 }
203 
205 {
206  Application application = Application::New();
207 
209 
210  LifecycleController lifecycleController = LifecycleController::Get();
211 
212  lifecycleController.LanguageChangedSignal().Connect( &OnLanguageChanged );
213 
214  GetImplementation( lifecycleController ).OnLanguageChanged( application );
215 
217 
218  END_TEST;
219 }
Dali Docs Home
Read more about Dali