X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-platform-abstraction.h;h=201e29d4e33c9cd891e34591d02eddddf1d7d34e;hp=a4ec8d3f1a61dd2fa00b2c0b91893cd725a78775;hb=d07dc4c4a6067ba3080184d862bca40a90d1789c;hpb=cd7d41bc8e0a0816da28401207091344fbbe0b2c diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h index a4ec8d3..201e29d 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h @@ -2,7 +2,7 @@ #define __DALI_TEST_PLATFORM_ABSTRACTION_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,15 @@ // EXTERNAL INCLUDES #include #include +#include +#include // INTERNAL INCLUDES -#include #include +#include #include "test-trace-call-stack.h" - namespace Dali { @@ -40,38 +41,6 @@ class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::Platfo public: - struct Resources - { - bool loaded; - Integration::ResourceId loadedId; - Integration::ResourceTypeId loadedType; - Integration::ResourcePointer loadedResource; - - bool loadFailed; - Integration::ResourceId loadFailedId; - Integration::ResourceFailure loadFailure; - - bool saved; - Integration::ResourceId savedId; - Integration::ResourceTypeId savedType; - - bool saveFailed; - Integration::ResourceId saveFailedId; - Integration::ResourceFailure saveFailure; - }; - - struct LoadFileResult - { - inline LoadFileResult() - : loadResult(false) - { - - } - - bool loadResult; - std::vector< unsigned char> buffer; - }; - /** * Constructor */ @@ -83,110 +52,52 @@ public: virtual ~TestPlatformAbstraction(); /** - * @copydoc PlatformAbstraction::GetTimeMicroseconds() - */ - virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds); - - /** - * @copydoc PlatformAbstraction::Suspend() + * @copydoc PlatformAbstraction::GetClosestImageSize() */ - virtual void Suspend(); + virtual ImageDimensions GetClosestImageSize( const std::string& filename, + ImageDimensions size, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection ); /** - * @copydoc PlatformAbstraction::Resume() + * @copydoc PlatformAbstraction::GetClosestImageSize() */ - virtual void Resume(); - - virtual void GetClosestImageSize( const std::string& filename, - const ImageAttributes& attributes, - Vector2& closestSize); - - virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer, - const ImageAttributes& attributes, - Vector2& closestSize); - - /** - * @copydoc PlatformAbstraction::LoadResource() - */ - virtual void LoadResource(const Integration::ResourceRequest& request); + virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer, + ImageDimensions size, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection ); /** * @copydoc PlatformAbstraction::LoadResourceSynchronously() */ - virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ); - - /** - * @copydoc PlatformAbstraction::SaveResource() - */ - virtual void SaveResource(const Integration::ResourceRequest& request); - - /** - * @copydoc PlatformAbstraction::CancelLoad() - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); - - /** - * @copydoc PlatformAbstraction::GetResources() - */ - virtual void GetResources(Integration::ResourceCache& cache); + virtual Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resourceType, const std::string& resourcePath ); /** - * @copydoc PlatformAbstraction::IsLoading() + * @copydoc PlatformAbstraction::DecodeBuffer() */ - virtual bool IsLoading(); + virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size ); /** - * @copydoc PlatformAbstraction::GetDefaultFontDescription() + * @copydoc PlatformAbstraction::LoadShaderBinaryFile() */ - virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const; + virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - virtual int GetDefaultFontSize() const; - - /** - * @copydoc PlatformAbstraction::SetDpi() - */ - virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); - /** - * @copydoc PlatformAbstraction::LoadFile() + * @copydoc PlatformAbstraction::SaveShaderBinaryFile() */ - virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; + virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; } - /** - * @copydoc PlatformAbstraction::LoadShaderBinFile() - */ - virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; - - /** - * @copydoc PlatformAbstraction::SaveFile() - */ - virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const; - - virtual void JoinLoaderThreads(); - - virtual Integration::DynamicsFactory* GetDynamicsFactory(); public: // TEST FUNCTIONS // Enumeration of Platform Abstraction methods typedef enum { - GetTimeMicrosecondsFunc, - SuspendFunc, - ResumeFunc, - LoadResourceFunc, - SaveResourceFunc, - SaveFileFunc, - LoadFileFunc, - LoadShaderBinFileFunc, - CancelLoadFunc, - GetResourcesFunc, - IsLoadingFunc, - SetDpiFunc, - JoinLoaderThreadsFunc, - GetDynamicsFactoryFunc, + LoadResourceSynchronouslyFunc, + LoadShaderBinaryFileFunc, + SaveShaderBinaryFileFunc } TestFuncEnum; /** Call this every test */ @@ -196,59 +107,85 @@ public: // TEST FUNCTIONS inline void ResetTrace() { mTrace.Reset(); } inline TraceCallStack& GetTrace() { return mTrace; } + /** + * @brief Checks if a platform function was called + * @param[in] func The function to check + * @return true if the function was called + */ bool WasCalled(TestFuncEnum func); - void SetGetTimeMicrosecondsResult(size_t sec, size_t usec); - - void IncrementGetTimeResult(size_t milliseconds); - + /** + * @brief Sets the result to return when IsLoading is called by Core. + * @param[in] result The result to set. + */ void SetIsLoadingResult(bool result); - void SetGetDefaultFontFamilyResult(std::string result); - - void SetGetDefaultFontSizeResult(float result); + /** + * @brief Clears all resource queues + */ + void ClearReadyResources(); - void SetGetFontPathResult(std::string& result); + /** + * @brief Sets the value returned by GetClosestImageSize. + * @param[in] size The size that should be returned. + */ + void SetClosestImageSize(const Vector2& size); - void ClearReadyResources(); + /** + * @brief Sets the result return by LoadFile. + * @param[in] result The value that LoadFile should return. + * @param[in] buffer The buffer of the loaded file. + */ + void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer ); - void SetResourceLoaded(Integration::ResourceId loadedId, - Integration::ResourceTypeId loadedType, - Integration::ResourcePointer loadedResource); + /** + * @brief Sets the SaveFile result + * @param[in] result The value that SaveFile should return + */ + void SetSaveFileResult( bool result ); - void SetResourceLoadFailed(Integration::ResourceId id, - Integration::ResourceFailure failure); + /** + * @brief Sets the resource loaded by LoadResourceSynchronously + * @param[in] resource The loaded resource + */ + void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource ); - void SetResourceSaved(Integration::ResourceId savedId, - Integration::ResourceTypeId savedType); + /** + * @brief Sets the bitmap returned by DecodeBuffer() + * @param[in] bitmap The decoded bitmap + */ + void SetDecodedBitmap( Integration::BitmapPtr bitmap ); - void SetResourceSaveFailed(Integration::ResourceId id, - Integration::ResourceFailure failure); +private: - Integration::ResourceRequest* GetRequest(); + TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined + TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined - void DiscardRequest(); +private: - void SetClosestImageSize(const Vector2& size); + struct LoadFileResult + { + inline LoadFileResult() + : loadResult(false) + { - void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer ); + } - void SetSaveFileResult( bool result ); + bool loadResult; + Dali::Vector< unsigned char> buffer; + }; -private: mutable TraceCallStack mTrace; - size_t mSeconds; - size_t mMicroSeconds; bool mIsLoadingResult; - Resources mResources; - Integration::ResourceRequest* mRequest; - Vector2 mSize; Vector2 mClosestSize; LoadFileResult mLoadFileResult; bool mSaveFileResult; + + Integration::ResourcePointer mSynchronouslyLoadedResource; + Integration::BitmapPtr mDecodedBitmap; }; } // Dali -#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */ +#endif /* __DALI_TEST_PLATFORM_ABSTRACTION_H__ */