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;
58 inline LoadFileResult()
65 Dali::Vector< unsigned char> buffer;
71 TestPlatformAbstraction();
76 virtual ~TestPlatformAbstraction();
79 * @copydoc PlatformAbstraction::GetTimeMicroseconds()
81 virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds);
84 * @copydoc PlatformAbstraction::Suspend()
86 virtual void Suspend();
89 * @copydoc PlatformAbstraction::Resume()
91 virtual void Resume();
94 * @copydoc PlatformAbstraction::GetClosestImageSize()
96 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
98 FittingMode::Type fittingMode,
99 SamplingMode::Type samplingMode,
100 bool orientationCorrection );
103 * @copydoc PlatformAbstraction::GetClosestImageSize()
105 virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
106 ImageDimensions size,
107 FittingMode::Type fittingMode,
108 SamplingMode::Type samplingMode,
109 bool orientationCorrection );
112 * @copydoc PlatformAbstraction::LoadResource()
114 virtual void LoadResource(const Integration::ResourceRequest& request);
117 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
119 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
122 * @copydoc PlatformAbstraction::CancelLoad()
124 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
127 * @copydoc PlatformAbstraction::GetResources()
129 virtual void GetResources(Integration::ResourceCache& cache);
132 * @copydoc PlatformAbstraction::IsLoading()
134 virtual bool IsLoading();
137 * @copydoc PlatformAbstraction::GetDefaultFontDescription()
139 virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
142 * @copydoc PlatformAbstraction::GetDefaultFontSize()
144 virtual int GetDefaultFontSize() const;
147 * @copydoc PlatformAbstraction::SetDpi()
149 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
152 * @copydoc PlatformAbstraction::LoadFile()
154 virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
157 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
159 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer
162 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
165 * @copydoc PlatformAbstraction::SaveFile()
167 virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes) const;
169 virtual void JoinLoaderThreads();
171 public: // TEST FUNCTIONS
173 // Enumeration of Platform Abstraction methods
176 GetTimeMicrosecondsFunc,
182 LoadShaderBinaryFileFunc,
183 SaveShaderBinaryFileFunc,
188 JoinLoaderThreadsFunc
191 /** Call this every test */
194 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
195 inline void ResetTrace() { mTrace.Reset(); }
196 inline TraceCallStack& GetTrace() { return mTrace; }
198 bool WasCalled(TestFuncEnum func);
200 void SetGetTimeMicrosecondsResult(size_t sec, size_t usec);
202 void IncrementGetTimeResult(size_t milliseconds);
204 void SetIsLoadingResult(bool result);
206 void SetGetDefaultFontFamilyResult(std::string result);
208 void SetGetDefaultFontSizeResult(float result);
210 void SetGetFontPathResult(std::string& result);
212 void ClearReadyResources();
214 void SetResourceLoaded(Integration::ResourceId loadedId,
215 Integration::ResourceTypeId loadedType,
216 Integration::ResourcePointer loadedResource);
218 void SetResourceLoadFailed(Integration::ResourceId id,
219 Integration::ResourceFailure failure);
221 Integration::ResourceRequest* GetRequest();
223 void DiscardRequest();
225 void SetClosestImageSize(const Vector2& size);
227 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
229 void SetSaveFileResult( bool result );
232 mutable TraceCallStack mTrace;
234 size_t mMicroSeconds;
235 bool mIsLoadingResult;
236 Resources mResources;
237 Integration::ResourceRequest* mRequest;
239 Vector2 mClosestSize;
241 LoadFileResult mLoadFileResult;
242 bool mSaveFileResult;
247 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */