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::Suspend()
79 virtual void Suspend();
82 * @copydoc PlatformAbstraction::Resume()
84 virtual void Resume();
87 * @copydoc PlatformAbstraction::GetClosestImageSize()
89 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
91 FittingMode::Type fittingMode,
92 SamplingMode::Type samplingMode,
93 bool orientationCorrection );
96 * @copydoc PlatformAbstraction::GetClosestImageSize()
98 virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
100 FittingMode::Type fittingMode,
101 SamplingMode::Type samplingMode,
102 bool orientationCorrection );
105 * @copydoc PlatformAbstraction::LoadResource()
107 virtual void LoadResource(const Integration::ResourceRequest& request);
110 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
112 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
115 * @copydoc PlatformAbstraction::DecodeBuffer()
117 virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
120 * @copydoc PlatformAbstraction::CancelLoad()
122 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
125 * @copydoc PlatformAbstraction::GetResources()
127 virtual void GetResources(Integration::ResourceCache& cache);
130 * @copydoc PlatformAbstraction::IsLoading()
132 virtual bool IsLoading();
135 * @copydoc PlatformAbstraction::GetDefaultFontSize()
137 virtual int GetDefaultFontSize() const;
140 * @copydoc PlatformAbstraction::SetDpi()
142 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
145 * @copydoc PlatformAbstraction::LoadFile()
147 virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
150 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
152 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
155 * @copydoc PlatformAbstraction::SaveFile()
157 virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
160 * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
162 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
164 virtual void JoinLoaderThreads();
166 public: // TEST FUNCTIONS
168 // Enumeration of Platform Abstraction methods
176 LoadShaderBinaryFileFunc,
177 SaveShaderBinaryFileFunc,
182 JoinLoaderThreadsFunc,
185 /** Call this every test */
188 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
189 inline void ResetTrace() { mTrace.Reset(); }
190 inline TraceCallStack& GetTrace() { return mTrace; }
192 bool WasCalled(TestFuncEnum func);
194 void SetIsLoadingResult(bool result);
196 void SetGetDefaultFontSizeResult(float 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;
219 bool mIsLoadingResult;
220 int mGetDefaultFontSizeResult;
221 Resources mResources;
222 Integration::ResourceRequest* mRequest;
224 Vector2 mClosestSize;
226 LoadFileResult mLoadFileResult;
227 bool mSaveFileResult;
232 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */