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>
29 #include <dali/public-api/math/vector2.h>
31 #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 TestPlatformAbstraction();
52 virtual ~TestPlatformAbstraction();
55 * @copydoc PlatformAbstraction::GetClosestImageSize()
57 virtual ImageDimensions GetClosestImageSize( const std::string& filename,
59 FittingMode::Type fittingMode,
60 SamplingMode::Type samplingMode,
61 bool orientationCorrection );
64 * @copydoc PlatformAbstraction::GetClosestImageSize()
66 virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
68 FittingMode::Type fittingMode,
69 SamplingMode::Type samplingMode,
70 bool orientationCorrection );
73 * @copydoc PlatformAbstraction::LoadResourceSynchronously()
75 virtual Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resourceType, const std::string& resourcePath );
78 * @copydoc PlatformAbstraction::DecodeBuffer()
80 virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size );
83 * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
85 virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
88 * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
90 virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
93 public: // TEST FUNCTIONS
95 // Enumeration of Platform Abstraction methods
98 LoadResourceSynchronouslyFunc,
99 LoadShaderBinaryFileFunc,
100 SaveShaderBinaryFileFunc
103 /** Call this every test */
106 inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
107 inline void ResetTrace() { mTrace.Reset(); }
108 inline TraceCallStack& GetTrace() { return mTrace; }
111 * @brief Checks if a platform function was called
112 * @param[in] func The function to check
113 * @return true if the function was called
115 bool WasCalled(TestFuncEnum func);
118 * @brief Sets the result to return when IsLoading is called by Core.
119 * @param[in] result The result to set.
121 void SetIsLoadingResult(bool result);
124 * @brief Clears all resource queues
126 void ClearReadyResources();
129 * @brief Sets the value returned by GetClosestImageSize.
130 * @param[in] size The size that should be returned.
132 void SetClosestImageSize(const Vector2& size);
135 * @brief Sets the result return by LoadFile.
136 * @param[in] result The value that LoadFile should return.
137 * @param[in] buffer The buffer of the loaded file.
139 void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
142 * @brief Sets the SaveFile result
143 * @param[in] result The value that SaveFile should return
145 void SetSaveFileResult( bool result );
148 * @brief Sets the resource loaded by LoadResourceSynchronously
149 * @param[in] resource The loaded resource
151 void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource );
154 * @brief Sets the bitmap returned by DecodeBuffer()
155 * @param[in] bitmap The decoded bitmap
157 void SetDecodedBitmap( Integration::BitmapPtr bitmap );
161 TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined
162 TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined
166 struct LoadFileResult
168 inline LoadFileResult()
175 Dali::Vector< unsigned char> buffer;
178 mutable TraceCallStack mTrace;
179 bool mIsLoadingResult;
180 Vector2 mClosestSize;
182 LoadFileResult mLoadFileResult;
183 bool mSaveFileResult;
185 Integration::ResourcePointer mSynchronouslyLoadedResource;
186 Integration::BitmapPtr mDecodedBitmap;
191 #endif /* __DALI_TEST_PLATFORM_ABSTRACTION_H__ */