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=dfa4d6c035ad77c9a01721906ed9682510b8b391;hp=cd6bf85140ed2e5c97de55ab1c9e6243ac030f00;hb=908670e8d7b3447b5201a7f9118cca881cf0a41e;hpb=ec4cd25a0466c6580d4a8f3fbba07340dfa2de1d 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 cd6bf85..dfa4d6c 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) 2018 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,50 +21,26 @@ // EXTERNAL INCLUDES #include #include -#include +#include +#include // INTERNAL INCLUDES -#include #include +#include #include "test-trace-call-stack.h" - namespace Dali { /** * Concrete implementation of the platform abstraction class. */ -class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction +class DALI_CORE_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction { public: - struct Resources - { - bool loaded; - Integration::ResourceId loadedId; - Integration::ResourceTypeId loadedType; - Integration::ResourcePointer loadedResource; - - bool loadFailed; - Integration::ResourceId loadFailedId; - Integration::ResourceFailure loadFailure; - }; - - struct LoadFileResult - { - inline LoadFileResult() - : loadResult(false) - { - - } - - bool loadResult; - Dali::Vector< unsigned char> buffer; - }; - /** * Constructor */ @@ -76,21 +52,6 @@ public: virtual ~TestPlatformAbstraction(); /** - * @copydoc PlatformAbstraction::GetTimeMicroseconds() - */ - virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds); - - /** - * @copydoc PlatformAbstraction::Suspend() - */ - virtual void Suspend(); - - /** - * @copydoc PlatformAbstraction::Resume() - */ - virtual void Resume(); - - /** * @copydoc PlatformAbstraction::GetClosestImageSize() */ virtual ImageDimensions GetClosestImageSize( const std::string& filename, @@ -109,83 +70,34 @@ public: bool orientationCorrection ); /** - * @copydoc PlatformAbstraction::LoadResource() - */ - virtual void LoadResource(const Integration::ResourceRequest& request); - - /** * @copydoc PlatformAbstraction::LoadResourceSynchronously() */ - virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ); - - /** - * @copydoc PlatformAbstraction::CancelLoad() - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); - - /** - * @copydoc PlatformAbstraction::GetResources() - */ - virtual void GetResources(Integration::ResourceCache& cache); - - /** - * @copydoc PlatformAbstraction::IsLoading() - */ - virtual bool IsLoading(); + virtual Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resourceType, const std::string& resourcePath ); /** - * @copydoc PlatformAbstraction::GetDefaultFontDescription() + * @copydoc PlatformAbstraction::DecodeBuffer() */ - virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const; - - /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - virtual int GetDefaultFontSize() const; - - /** - * @copydoc PlatformAbstraction::SetDpi() - */ - virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); - - /** - * @copydoc PlatformAbstraction::LoadFile() - */ - virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; + virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size ); /** * @copydoc PlatformAbstraction::LoadShaderBinaryFile() */ - virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer -) const; - - virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; } + virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; /** - * @copydoc PlatformAbstraction::SaveFile() + * @copydoc PlatformAbstraction::SaveShaderBinaryFile() */ - virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes) const; + virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; } - virtual void JoinLoaderThreads(); public: // TEST FUNCTIONS // Enumeration of Platform Abstraction methods typedef enum { - GetTimeMicrosecondsFunc, - SuspendFunc, - ResumeFunc, - LoadResourceFunc, - SaveFileFunc, - LoadFileFunc, + LoadResourceSynchronouslyFunc, LoadShaderBinaryFileFunc, - SaveShaderBinaryFileFunc, - CancelLoadFunc, - GetResourcesFunc, - IsLoadingFunc, - SetDpiFunc, - JoinLoaderThreadsFunc + SaveShaderBinaryFileFunc } TestFuncEnum; /** Call this every test */ @@ -195,53 +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); + /** + * @brief Clears all resource queues + */ + void ClearReadyResources(); - void SetGetDefaultFontSizeResult(float result); + /** + * @brief Sets the value returned by GetClosestImageSize. + * @param[in] size The size that should be returned. + */ + void SetClosestImageSize( const Vector2& size ); - void SetGetFontPathResult(std::string& result); + /** + * @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 ClearReadyResources(); + /** + * @brief Sets the SaveFile result + * @param[in] result The value that SaveFile should return + */ + void SetSaveFileResult( bool result ); - void SetResourceLoaded(Integration::ResourceId loadedId, - Integration::ResourceTypeId loadedType, - Integration::ResourcePointer loadedResource); + /** + * @brief Sets the resource loaded by LoadResourceSynchronously + * @param[in] resource The loaded resource + */ + void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource ); - void SetResourceLoadFailed(Integration::ResourceId id, - Integration::ResourceFailure failure); + /** + * @brief Sets the bitmap returned by DecodeBuffer() + * @param[in] bitmap The decoded bitmap + */ + void SetDecodedBitmap( Integration::BitmapPtr bitmap ); - Integration::ResourceRequest* GetRequest(); +private: - void DiscardRequest(); + TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined + TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined - void SetClosestImageSize(const Vector2& size); +private: - void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer ); + struct LoadFileResult + { + inline LoadFileResult() + : loadResult(false) + { - 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; + ImageDimensions mClosestSize; LoadFileResult mLoadFileResult; bool mSaveFileResult; + + Integration::ResourcePointer mSynchronouslyLoadedResource; + Integration::BitmapPtr mDecodedBitmap; }; } // Dali -#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */ +#endif /* __DALI_TEST_PLATFORM_ABSTRACTION_H__ */