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.
27 #include <dali/integration-api/platform-abstraction.h>
29 #include "test-trace-call-stack.h"
35 * Concrete implementation of the platform abstraction class.
37 class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction
45 Integration::ResourceId loadedId;
46 Integration::ResourceTypeId loadedType;
47 Integration::ResourcePointer loadedResource;
50 Integration::ResourceId loadFailedId;
51 Integration::ResourceFailure loadFailure;
56 inline LoadFileResult()
63 Dali::Vector< unsigned char> buffer;
69 TestPlatformAbstraction();
74 virtual ~TestPlatformAbstraction();
77 * @copydoc PlatformAbstraction::GetTimeNanoseconds()
79 virtual void GetTimeNanoseconds( uint64_t& seconds, uint64_t& nanoseconds );
82 * @copydoc PlatformAbstraction::Suspend()
84 virtual void Suspend();
87 * @copydoc PlatformAbstraction::Resume()
89 virtual void Resume();
92 * @copydoc PlatformAbstraction::GetClosestImageSize()
94 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
96 FittingMode::Type fittingMode,
97 SamplingMode::Type samplingMode,
98 bool orientationCorrection );
101 * @copydoc PlatformAbstraction::GetClosestImageSize()
103 virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
104 ImageDimensions size,
105 FittingMode::Type fittingMode,
106 SamplingMode::Type samplingMode,
107 bool orientationCorrection );
110 * @copydoc PlatformAbstraction::LoadResource()
112 virtual void LoadResource(const Integration::ResourceRequest& request);
115 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
117 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
120 * @copydoc PlatformAbstraction::DecodeBuffer()
122 virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
125 * @copydoc PlatformAbstraction::CancelLoad()
127 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
130 * @copydoc PlatformAbstraction::GetResources()
132 virtual void GetResources(Integration::ResourceCache& cache);
135 * @copydoc PlatformAbstraction::IsLoading()
137 virtual bool IsLoading();
140 * @copydoc PlatformAbstraction::GetDefaultFontSize()
142 virtual int GetDefaultFontSize() const;
145 * @copydoc PlatformAbstraction::SetDpi()
147 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
150 * @copydoc PlatformAbstraction::LoadFile()
152 virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
155 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
157 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
160 * @copydoc PlatformAbstraction::SaveFile()
162 virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
165 * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
167 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
169 virtual void JoinLoaderThreads();
171 public: // TEST FUNCTIONS
173 // Enumeration of Platform Abstraction methods
176 GetTimeNanosecondsFunc,
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 SetGetTimeNanosecondsResult(size_t sec, size_t nsec);
202 void IncrementGetTimeResult(size_t milliseconds);
204 void SetIsLoadingResult(bool result);
206 void SetGetDefaultFontSizeResult(float result);
208 void ClearReadyResources();
210 void SetResourceLoaded(Integration::ResourceId loadedId,
211 Integration::ResourceTypeId loadedType,
212 Integration::ResourcePointer loadedResource);
214 void SetResourceLoadFailed(Integration::ResourceId id,
215 Integration::ResourceFailure failure);
217 Integration::ResourceRequest* GetRequest();
219 void DiscardRequest();
221 void SetClosestImageSize(const Vector2& size);
223 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
225 void SetSaveFileResult( bool result );
228 mutable TraceCallStack mTrace;
230 uint64_t mNanoSeconds;
231 bool mIsLoadingResult;
232 int mGetDefaultFontSizeResult;
233 Resources mResources;
234 Integration::ResourceRequest* mRequest;
236 Vector2 mClosestSize;
238 LoadFileResult mLoadFileResult;
239 bool mSaveFileResult;
244 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */