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::DecodeBuffer()
124 virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
127 * @copydoc PlatformAbstraction::CancelLoad()
129 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
132 * @copydoc PlatformAbstraction::GetResources()
134 virtual void GetResources(Integration::ResourceCache& cache);
137 * @copydoc PlatformAbstraction::IsLoading()
139 virtual bool IsLoading();
142 * @copydoc PlatformAbstraction::GetDefaultFontDescription()
144 virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
147 * @copydoc PlatformAbstraction::GetDefaultFontSize()
149 virtual int GetDefaultFontSize() const;
152 * @copydoc PlatformAbstraction::SetDpi()
154 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
157 * @copydoc PlatformAbstraction::LoadFile()
159 virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
162 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
164 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer
167 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
170 * @copydoc PlatformAbstraction::SaveFile()
172 virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes) const;
174 virtual void JoinLoaderThreads();
176 public: // TEST FUNCTIONS
178 // Enumeration of Platform Abstraction methods
181 GetTimeMicrosecondsFunc,
187 LoadShaderBinaryFileFunc,
188 SaveShaderBinaryFileFunc,
193 JoinLoaderThreadsFunc
196 /** Call this every test */
199 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
200 inline void ResetTrace() { mTrace.Reset(); }
201 inline TraceCallStack& GetTrace() { return mTrace; }
203 bool WasCalled(TestFuncEnum func);
205 void SetGetTimeMicrosecondsResult(size_t sec, size_t usec);
207 void IncrementGetTimeResult(size_t milliseconds);
209 void SetIsLoadingResult(bool result);
211 void SetGetDefaultFontFamilyResult(std::string result);
213 void SetGetDefaultFontSizeResult(float result);
215 void SetGetFontPathResult(std::string& result);
217 void ClearReadyResources();
219 void SetResourceLoaded(Integration::ResourceId loadedId,
220 Integration::ResourceTypeId loadedType,
221 Integration::ResourcePointer loadedResource);
223 void SetResourceLoadFailed(Integration::ResourceId id,
224 Integration::ResourceFailure failure);
226 Integration::ResourceRequest* GetRequest();
228 void DiscardRequest();
230 void SetClosestImageSize(const Vector2& size);
232 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
234 void SetSaveFileResult( bool result );
237 mutable TraceCallStack mTrace;
239 size_t mMicroSeconds;
240 bool mIsLoadingResult;
241 Resources mResources;
242 Integration::ResourceRequest* mRequest;
244 Vector2 mClosestSize;
246 LoadFileResult mLoadFileResult;
247 bool mSaveFileResult;
252 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */