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