[dali_1.4.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-adaptor.cpp
1 /*
2  * Copyright (c) 2019 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 // CLASS HEADER
19 #include <dali/integration-api/adaptors/adaptor.h>
20 #include <dali/integration-api/adaptors/scene-holder.h>
21
22 #include <dali/public-api/object/base-object.h>
23
24 #include <toolkit-adaptor-impl.h>
25 #include <dali/integration-api/debug.h>
26 #include <test-application.h>
27 #include <test-render-surface.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34 namespace Adaptor
35 {
36
37 bool Adaptor::mAvailable = false;
38 Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
39
40 Dali::Adaptor& Adaptor::Get()
41 {
42   Dali::Adaptor* adaptor = new Dali::Adaptor;
43   Adaptor::mAvailable = true;
44   return *adaptor;
45 }
46
47 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
48 {
49   Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast <Dali::RenderSurfaceInterface*>( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) );
50   return *renderSurface;
51 }
52
53 Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
54 {
55   Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
56   return *signal;
57 }
58
59 } // namespace Adaptor
60 } // namespace Internal
61
62 Adaptor& Adaptor::New( Window window )
63 {
64   return Internal::Adaptor::Adaptor::Get();
65 }
66
67 Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
68 {
69   return Internal::Adaptor::Adaptor::Get();
70 }
71
72 Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface )
73 {
74   return Internal::Adaptor::Adaptor::Get();
75 }
76
77 Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
78 {
79   return Internal::Adaptor::Adaptor::Get();
80 }
81
82 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window )
83 {
84   return Internal::Adaptor::Adaptor::Get();
85 }
86
87 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration )
88 {
89   return Internal::Adaptor::Adaptor::Get();
90 }
91
92 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface )
93 {
94   return Internal::Adaptor::Adaptor::Get();
95 }
96
97 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
98 {
99   return Internal::Adaptor::Adaptor::Get();
100 }
101
102 Adaptor::~Adaptor()
103 {
104 }
105
106 void Adaptor::Start()
107 {
108 }
109
110 void Adaptor::Pause()
111 {
112 }
113
114 void Adaptor::Resume()
115 {
116 }
117
118 void Adaptor::Stop()
119 {
120 }
121
122 bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
123 {
124   const bool isAvailable = IsAvailable();
125
126   if( isAvailable )
127   {
128     Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback );
129   }
130
131   return isAvailable;
132 }
133
134 void Adaptor::RemoveIdle( CallbackBase* callback )
135 {
136   const bool isAvailable = IsAvailable();
137
138   if( isAvailable )
139   {
140     for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
141            endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
142          it != endIt;
143          ++it )
144     {
145       if( callback == *it )
146       {
147         Internal::Adaptor::Adaptor::mCallbacks.Remove( it );
148         return;
149       }
150     }
151   }
152 }
153
154 void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
155 {
156 }
157
158 void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
159 {
160 }
161
162 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
163 {
164   return Internal::Adaptor::Adaptor::AdaptorSignal();
165 }
166
167 Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
168 {
169   return Internal::Adaptor::Adaptor::AdaptorSignal();
170 }
171
172 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
173 {
174   return Internal::Adaptor::Adaptor::GetSurface();
175 }
176
177 Any Adaptor::GetNativeWindowHandle()
178 {
179   Any window;
180   return window;
181 }
182
183 void Adaptor::ReleaseSurfaceLock()
184 {
185 }
186
187 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
188 {
189 }
190
191 void Adaptor::SetUseHardwareVSync(bool useHardware)
192 {
193 }
194
195 Adaptor& Adaptor::Get()
196 {
197   return Internal::Adaptor::Adaptor::Get();
198 }
199
200 bool Adaptor::IsAvailable()
201 {
202   return Internal::Adaptor::Adaptor::mAvailable;
203 }
204
205 void Adaptor::NotifySceneCreated()
206 {
207 }
208
209 void Adaptor::NotifyLanguageChanged()
210 {
211 }
212
213 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
214 {
215 }
216
217 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
218 {
219 }
220
221 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
222 {
223 }
224
225 void Adaptor::SceneCreated()
226 {
227 }
228
229 class LogFactory : public LogFactoryInterface
230 {
231 public:
232   virtual void InstallLogFunction() const
233   {
234     Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
235     Dali::Integration::Log::InstallLogFunction(logFunction);
236   }
237
238   LogFactory()
239   {
240   }
241   virtual ~LogFactory()
242   {
243   }
244 };
245
246 LogFactory* gLogFactory = NULL;
247 const LogFactoryInterface& Adaptor::GetLogFactory()
248 {
249   if( gLogFactory == NULL )
250   {
251     gLogFactory = new LogFactory;
252   }
253   return *gLogFactory;
254 }
255
256 Adaptor::Adaptor()
257 : mImpl( NULL )
258 {
259 }
260
261 } // namespace Dali