1 #ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__
2 #define __DALI_TEST_PLATFORM_ABSTRACTION_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
24 #include <dali/public-api/images/image-operations.h>
27 #include <dali/devel-api/common/set-wrapper.h>
28 #include <dali/integration-api/platform-abstraction.h>
30 #include "test-trace-call-stack.h"
37 * Concrete implementation of the platform abstraction class.
39 class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction
47 Integration::ResourceId loadedId;
48 Integration::ResourceTypeId loadedType;
49 Integration::ResourcePointer loadedResource;
52 Integration::ResourceId loadFailedId;
53 Integration::ResourceFailure loadFailure;
56 Integration::ResourceId savedId;
57 Integration::ResourceTypeId savedType;
60 Integration::ResourceId saveFailedId;
61 Integration::ResourceFailure saveFailure;
66 inline LoadFileResult()
73 std::vector< unsigned char> buffer;
79 TestPlatformAbstraction();
84 virtual ~TestPlatformAbstraction();
87 * @copydoc PlatformAbstraction::GetTimeMicroseconds()
89 virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds);
92 * @copydoc PlatformAbstraction::Suspend()
94 virtual void Suspend();
97 * @copydoc PlatformAbstraction::Resume()
99 virtual void Resume();
102 * @copydoc PlatformAbstraction::GetClosestImageSize()
104 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
105 ImageDimensions size,
106 FittingMode::Type fittingMode,
107 SamplingMode::Type samplingMode,
108 bool orientationCorrection );
111 * @copydoc PlatformAbstraction::GetClosestImageSize()
113 virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
114 ImageDimensions size,
115 FittingMode::Type fittingMode,
116 SamplingMode::Type samplingMode,
117 bool orientationCorrection );
119 * @copydoc PlatformAbstraction::LoadResource()
121 virtual void LoadResource(const Integration::ResourceRequest& request);
124 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
126 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
129 * @copydoc PlatformAbstraction::SaveResource()
131 virtual void SaveResource(const Integration::ResourceRequest& request);
134 * @copydoc PlatformAbstraction::CancelLoad()
136 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
139 * @copydoc PlatformAbstraction::GetResources()
141 virtual void GetResources(Integration::ResourceCache& cache);
144 * @copydoc PlatformAbstraction::IsLoading()
146 virtual bool IsLoading();
149 * @copydoc PlatformAbstraction::GetDefaultFontDescription()
151 virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
154 * @copydoc PlatformAbstraction::GetDefaultFontSize()
156 virtual int GetDefaultFontSize() const;
159 * @copydoc PlatformAbstraction::SetDpi()
161 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
164 * @copydoc PlatformAbstraction::LoadFile()
166 virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
169 * @copydoc PlatformAbstraction::LoadShaderBinFile()
171 virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer
175 * @copydoc PlatformAbstraction::SaveFile()
177 virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const;
179 virtual void JoinLoaderThreads();
181 virtual Integration::DynamicsFactory* GetDynamicsFactory();
183 public: // TEST FUNCTIONS
185 // Enumeration of Platform Abstraction methods
188 GetTimeMicrosecondsFunc,
195 LoadShaderBinFileFunc,
200 JoinLoaderThreadsFunc,
201 GetDynamicsFactoryFunc
204 /** Call this every test */
207 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
208 inline void ResetTrace() { mTrace.Reset(); }
209 inline TraceCallStack& GetTrace() { return mTrace; }
211 bool WasCalled(TestFuncEnum func);
213 void SetGetTimeMicrosecondsResult(size_t sec, size_t usec);
215 void IncrementGetTimeResult(size_t milliseconds);
217 void SetIsLoadingResult(bool result);
219 void SetGetDefaultFontFamilyResult(std::string result);
221 void SetGetDefaultFontSizeResult(float result);
223 void SetGetFontPathResult(std::string& result);
225 void ClearReadyResources();
227 void SetResourceLoaded(Integration::ResourceId loadedId,
228 Integration::ResourceTypeId loadedType,
229 Integration::ResourcePointer loadedResource);
231 void SetResourceLoadFailed(Integration::ResourceId id,
232 Integration::ResourceFailure failure);
234 void SetResourceSaved(Integration::ResourceId savedId,
235 Integration::ResourceTypeId savedType);
237 void SetResourceSaveFailed(Integration::ResourceId id,
238 Integration::ResourceFailure failure);
240 Integration::ResourceRequest* GetRequest();
242 void DiscardRequest();
244 void SetClosestImageSize(const Vector2& size);
246 void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer );
248 void SetSaveFileResult( bool result );
251 mutable TraceCallStack mTrace;
253 size_t mMicroSeconds;
254 bool mIsLoadingResult;
255 Resources mResources;
256 Integration::ResourceRequest* mRequest;
258 Vector2 mClosestSize;
260 LoadFileResult mLoadFileResult;
261 bool mSaveFileResult;
266 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */