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