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::GetTimeMicroseconds()
79 virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds);
82 * @copydoc PlatformAbstraction::Suspend()
84 virtual void Suspend();
87 * @copydoc PlatformAbstraction::Resume()
89 virtual void Resume();
91 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
93 FittingMode::Type fittingMode,
94 SamplingMode::Type samplingMode,
95 bool orientationCorrection );
97 virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
99 FittingMode::Type fittingMode,
100 SamplingMode::Type samplingMode,
101 bool orientationCorrection );
104 * @copydoc PlatformAbstraction::LoadResource()
106 virtual void LoadResource(const Integration::ResourceRequest& request);
109 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
111 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
114 * @copydoc PlatformAbstraction::DecodeBuffer()
116 virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
119 * @copydoc PlatformAbstraction::CancelLoad()
121 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
124 * @copydoc PlatformAbstraction::GetResources()
126 virtual void GetResources(Integration::ResourceCache& cache);
129 * @copydoc PlatformAbstraction::IsLoading()
131 virtual bool IsLoading();
134 * @copydoc PlatformAbstraction::GetDefaultFontSize()
136 virtual int GetDefaultFontSize() const;
139 * @copydoc PlatformAbstraction::SetDpi()
141 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
144 * @copydoc PlatformAbstraction::LoadFile()
146 virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
149 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
151 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
154 * @copydoc PlatformAbstraction::SaveFile()
156 virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
159 * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
161 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return false; }
163 virtual void JoinLoaderThreads();
165 public: // TEST FUNCTIONS
167 // Enumeration of Platform Abstraction methods
170 GetTimeMicrosecondsFunc,
180 JoinLoaderThreadsFunc,
183 /** Call this every test */
186 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
187 inline void ResetTrace() { mTrace.Reset(); }
188 inline TraceCallStack& GetTrace() { return mTrace; }
190 bool WasCalled(TestFuncEnum func);
192 void SetGetTimeMicrosecondsResult(size_t sec, size_t usec);
194 void IncrementGetTimeResult(size_t milliseconds);
196 void SetIsLoadingResult(bool result);
198 void ClearReadyResources();
200 void SetResourceLoaded(Integration::ResourceId loadedId,
201 Integration::ResourceTypeId loadedType,
202 Integration::ResourcePointer loadedResource);
204 void SetResourceLoadFailed(Integration::ResourceId id,
205 Integration::ResourceFailure failure);
207 Integration::ResourceRequest* GetRequest();
209 void DiscardRequest();
211 void SetClosestImageSize(const Vector2& size);
213 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
215 void SetSaveFileResult( bool result );
218 mutable TraceCallStack mTrace;
220 size_t mMicroSeconds;
221 bool mIsLoadingResult;
222 std::string mGetDefaultFontFamilyResult;
223 std::string mGetDefaultFontStyleResult;
224 int mGetDefaultFontSizeResult;
225 Resources mResources;
226 Integration::ResourceRequest* mRequest;
228 Vector2 mClosestSize;
230 LoadFileResult mLoadFileResult;
231 bool mSaveFileResult;
236 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */