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 );
111 * @copydoc PlatformAbstraction::LoadResource()
113 virtual void LoadResource(const Integration::ResourceRequest& request);
116 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
118 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
121 * @copydoc PlatformAbstraction::CancelLoad()
123 virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
126 * @copydoc PlatformAbstraction::GetResources()
128 virtual void GetResources(Integration::ResourceCache& cache);
131 * @copydoc PlatformAbstraction::IsLoading()
133 virtual bool IsLoading();
136 * @copydoc PlatformAbstraction::GetDefaultFontDescription()
138 virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
141 * @copydoc PlatformAbstraction::GetDefaultFontSize()
143 virtual int GetDefaultFontSize() const;
146 * @copydoc PlatformAbstraction::SetDpi()
148 virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
151 * @copydoc PlatformAbstraction::LoadFile()
153 virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
156 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
158 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer
161 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
164 * @copydoc PlatformAbstraction::SaveFile()
166 virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes) const;
168 virtual void JoinLoaderThreads();
170 public: // TEST FUNCTIONS
172 // Enumeration of Platform Abstraction methods
175 GetTimeMicrosecondsFunc,
181 LoadShaderBinaryFileFunc,
182 SaveShaderBinaryFileFunc,
187 JoinLoaderThreadsFunc,
190 /** Call this every test */
193 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
194 inline void ResetTrace() { mTrace.Reset(); }
195 inline TraceCallStack& GetTrace() { return mTrace; }
197 bool WasCalled(TestFuncEnum func);
199 void SetGetTimeMicrosecondsResult(size_t sec, size_t usec);
201 void IncrementGetTimeResult(size_t milliseconds);
203 void SetIsLoadingResult(bool result);
205 void SetGetDefaultFontFamilyResult(std::string result);
207 void SetGetDefaultFontSizeResult(float result);
209 void SetGetFontPathResult(std::string& result);
211 void ClearReadyResources();
213 void SetResourceLoaded(Integration::ResourceId loadedId,
214 Integration::ResourceTypeId loadedType,
215 Integration::ResourcePointer loadedResource);
217 void SetResourceLoadFailed(Integration::ResourceId id,
218 Integration::ResourceFailure failure);
220 Integration::ResourceRequest* GetRequest();
222 void DiscardRequest();
224 void SetClosestImageSize(const Vector2& size);
226 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
228 void SetSaveFileResult( bool result );
231 mutable TraceCallStack mTrace;
233 size_t mMicroSeconds;
234 bool mIsLoadingResult;
235 Resources mResources;
236 Integration::ResourceRequest* mRequest;
238 Vector2 mClosestSize;
240 LoadFileResult mLoadFileResult;
241 bool mSaveFileResult;
246 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */