1 #ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__
2 #define __DALI_TEST_PLATFORM_ABSTRACTION_H__
5 * Copyright (c) 2017 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.
28 #include <dali/integration-api/platform-abstraction.h>
30 #include "test-trace-call-stack.h"
36 * Concrete implementation of the platform abstraction class.
38 class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction
46 TestPlatformAbstraction();
51 virtual ~TestPlatformAbstraction();
54 * @copydoc PlatformAbstraction::GetClosestImageSize()
56 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
58 FittingMode::Type fittingMode,
59 SamplingMode::Type samplingMode,
60 bool orientationCorrection );
63 * @copydoc PlatformAbstraction::GetClosestImageSize()
65 virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
67 FittingMode::Type fittingMode,
68 SamplingMode::Type samplingMode,
69 bool orientationCorrection );
72 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
74 virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
77 * @copydoc PlatformAbstraction::DecodeBuffer()
79 virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
82 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
84 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
87 * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
89 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
92 public: // TEST FUNCTIONS
94 // Enumeration of Platform Abstraction methods
97 LoadResourceSynchronouslyFunc,
98 LoadShaderBinaryFileFunc,
99 SaveShaderBinaryFileFunc
102 /** Call this every test */
105 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
106 inline void ResetTrace() { mTrace.Reset(); }
107 inline TraceCallStack& GetTrace() { return mTrace; }
110 * @brief Checks if a platform function was called
111 * @param[in] func The function to check
112 * @return true if the function was called
114 bool WasCalled(TestFuncEnum func);
117 * @brief Sets the result to return when IsLoading is called by Core.
118 * @param[in] result The result to set.
120 void SetIsLoadingResult(bool result);
123 * @brief Clears all resource queues
125 void ClearReadyResources();
128 * @brief Sets the value returned by GetClosestImageSize.
129 * @param[in] size The size that should be returned.
131 void SetClosestImageSize(const Vector2& size);
134 * @brief Sets the result return by LoadFile.
135 * @param[in] result The value that LoadFile should return.
136 * @param[in] buffer The buffer of the loaded file.
138 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
141 * @brief Sets the SaveFile result
142 * @param[in] result The value that SaveFile should return
144 void SetSaveFileResult( bool result );
147 * @brief Sets the resource loaded by LoadResourceSynchronously
148 * @param[in] resource The loaded resource
150 void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource );
153 * @brief Sets the bitmap returned by DecodeBuffer()
154 * @param[in] bitmap The decoded bitmap
156 void SetDecodedBitmap( Integration::BitmapPtr bitmap );
160 TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined
161 TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined
165 struct LoadFileResult
167 inline LoadFileResult()
174 Dali::Vector< unsigned char> buffer;
177 mutable TraceCallStack mTrace;
178 bool mIsLoadingResult;
180 Vector2 mClosestSize;
182 LoadFileResult mLoadFileResult;
183 bool mSaveFileResult;
185 Integration::ResourcePointer mSynchronouslyLoadedResource;
186 Integration::BitmapPtr mDecodedBitmap;
191 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */