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 Dali::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 );
120 * @copydoc PlatformAbstraction::LoadResource()
122 virtual void LoadResource(const Integration::ResourceRequest& request);
125 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
127 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
130 * @copydoc PlatformAbstraction::SaveResource()
132 virtual void SaveResource(const Integration::ResourceRequest& request);
135 * @copydoc PlatformAbstraction::CancelLoad()
137 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
140 * @copydoc PlatformAbstraction::GetResources()
142 virtual void GetResources(Integration::ResourceCache& cache);
145 * @copydoc PlatformAbstraction::IsLoading()
147 virtual bool IsLoading();
150 * @copydoc PlatformAbstraction::GetDefaultFontDescription()
152 virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
155 * @copydoc PlatformAbstraction::GetDefaultFontSize()
157 virtual int GetDefaultFontSize() const;
160 * @copydoc PlatformAbstraction::SetDpi()
162 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
165 * @copydoc PlatformAbstraction::LoadFile()
167 virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
170 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
172 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer
175 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
178 * @copydoc PlatformAbstraction::SaveFile()
180 virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes) const;
182 virtual void JoinLoaderThreads();
184 public: // TEST FUNCTIONS
186 // Enumeration of Platform Abstraction methods
189 GetTimeMicrosecondsFunc,
196 LoadShaderBinaryFileFunc,
197 SaveShaderBinaryFileFunc,
202 JoinLoaderThreadsFunc
205 /** Call this every test */
208 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
209 inline void ResetTrace() { mTrace.Reset(); }
210 inline TraceCallStack& GetTrace() { return mTrace; }
212 bool WasCalled(TestFuncEnum func);
214 void SetGetTimeMicrosecondsResult(size_t sec, size_t usec);
216 void IncrementGetTimeResult(size_t milliseconds);
218 void SetIsLoadingResult(bool result);
220 void SetGetDefaultFontFamilyResult(std::string result);
222 void SetGetDefaultFontSizeResult(float result);
224 void SetGetFontPathResult(std::string& result);
226 void ClearReadyResources();
228 void SetResourceLoaded(Integration::ResourceId loadedId,
229 Integration::ResourceTypeId loadedType,
230 Integration::ResourcePointer loadedResource);
232 void SetResourceLoadFailed(Integration::ResourceId id,
233 Integration::ResourceFailure failure);
235 void SetResourceSaved(Integration::ResourceId savedId,
236 Integration::ResourceTypeId savedType);
238 void SetResourceSaveFailed(Integration::ResourceId id,
239 Integration::ResourceFailure failure);
241 Integration::ResourceRequest* GetRequest();
243 void DiscardRequest();
245 void SetClosestImageSize(const Vector2& size);
247 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
249 void SetSaveFileResult( bool result );
252 mutable TraceCallStack mTrace;
254 size_t mMicroSeconds;
255 bool mIsLoadingResult;
256 Resources mResources;
257 Integration::ResourceRequest* mRequest;
259 Vector2 mClosestSize;
261 LoadFileResult mLoadFileResult;
262 bool mSaveFileResult;
267 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */