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=7c1b0108bc27171141e8da732f0fd1e5d6cd60c3;hp=d9d3247f85d3032764a7ae43e0ab44bbcd5458c0;hb=HEAD;hpb=6734ced9c8c84f8f0e637043087fedaa5f79dd9d 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 d9d3247..3146e2d 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 @@ -1,8 +1,8 @@ -#ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__ -#define __DALI_TEST_PLATFORM_ABSTRACTION_H__ +#ifndef DALI_TEST_PLATFORM_ABSTRACTION_H +#define DALI_TEST_PLATFORM_ABSTRACTION_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -20,28 +20,25 @@ // EXTERNAL INCLUDES #include + #include #include #include // INTERNAL INCLUDES #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: - - typedef Vector< Integration::ResourceRequest* > ResourceRequestContainer; - /** * Constructor */ @@ -50,124 +47,83 @@ public: /** * Destructor */ - virtual ~TestPlatformAbstraction(); - - /** - * @copydoc PlatformAbstraction::Suspend() - */ - virtual void Suspend(); - - /** - * @copydoc PlatformAbstraction::Resume() - */ - virtual void Resume(); + ~TestPlatformAbstraction() override; /** * @copydoc PlatformAbstraction::GetClosestImageSize() */ - virtual ImageDimensions GetClosestImageSize( const std::string& filename, - ImageDimensions size, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection ); + ImageDimensions GetClosestImageSize(const std::string& filename, + ImageDimensions size, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection) override; /** * @copydoc PlatformAbstraction::GetClosestImageSize() */ - virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer, - ImageDimensions size, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection ); - - /** - * @copydoc PlatformAbstraction::LoadResource() - */ - virtual void LoadResource(const Integration::ResourceRequest& request); + ImageDimensions GetClosestImageSize(Integration::ResourcePointer resourceBuffer, + ImageDimensions size, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection) override; /** * @copydoc PlatformAbstraction::LoadResourceSynchronously() */ - virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ); + Integration::ResourcePointer LoadImageSynchronously(const Integration::BitmapResourceType& resourceType, const std::string& resourcePath) override; /** * @copydoc PlatformAbstraction::DecodeBuffer() */ - virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size ); - - /** - * @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(); + Integration::BitmapPtr DecodeBuffer(const Dali::Integration::BitmapResourceType& resourceType, uint8_t* buffer, size_t size) override; /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - virtual int GetDefaultFontSize() const; - - /** - * @copydoc PlatformAbstraction::SetDpi() + * @copydoc PlatformAbstraction::LoadShaderBinaryFile() */ - virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); + bool LoadShaderBinaryFile(const std::string& filename, Dali::Vector& buffer) const override; /** - * @copydoc PlatformAbstraction::LoadFile() + * @copydoc PlatformAbstraction::SaveShaderBinaryFile() */ - virtual bool LoadFile( 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 override + { + return true; + } /** - * @copydoc PlatformAbstraction::LoadShaderBinaryFile() + * @copydoc PlatformAbstraction::StartTimer() */ - virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const; + uint32_t StartTimer(uint32_t milliseconds, CallbackBase* callback) override; - /** - * @copydoc PlatformAbstraction::SaveFile() + /* + * @copydoc PlatformAbstraction::CancelTimer() */ - virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const; - - /** - * @copydoc PlatformAbstraction::SaveShaderBinaryFile() - */ - virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; } - - virtual void JoinLoaderThreads(); + void CancelTimer(uint32_t timerId) override; public: // TEST FUNCTIONS - // Enumeration of Platform Abstraction methods typedef enum { - SuspendFunc, - ResumeFunc, - LoadResourceFunc, LoadResourceSynchronouslyFunc, - SaveFileFunc, - LoadFileFunc, LoadShaderBinaryFileFunc, - SaveShaderBinaryFileFunc, - CancelLoadFunc, - GetResourcesFunc, - IsLoadingFunc, - SetDpiFunc, - JoinLoaderThreadsFunc, + SaveShaderBinaryFileFunc } TestFuncEnum; /** Call this every test */ void Initialize(); - inline void EnableTrace(bool enable) { mTrace.Enable(enable); } - inline void ResetTrace() { mTrace.Reset(); } - inline TraceCallStack& GetTrace() { return mTrace; } + inline void EnableTrace(bool enable) + { + mTrace.Enable(enable); + } + inline void ResetTrace() + { + mTrace.Reset(); + } + inline TraceCallStack& GetTrace() + { + return mTrace; + } /** * @brief Checks if a platform function was called @@ -183,63 +139,11 @@ public: // TEST FUNCTIONS void SetIsLoadingResult(bool result); /** - * @brief Sets the value returned by GetDefaultFontSize - * @param[in] result The value to return - */ - void SetGetDefaultFontSizeResult(float result); - - /** * @brief Clears all resource queues */ void ClearReadyResources(); /** - * @brief Sets a particular resource request as loaded. - * @param[in] loadedId The ResourceID of the resource that has been loaded. - * @param[in] loadedType The type of resource that has been loaded. - * @param[in] loadedResource A pointer to the resource that has been loaded. - */ - void SetResourceLoaded(Integration::ResourceId loadedId, - Integration::ResourceTypeId loadedType, - Integration::ResourcePointer loadedResource); - - /** - * @brief Sets a particular resource request as load failure. - * @param[in] id The ID of the failed resource request. - * @param[in] failure The type of failure. - */ - void SetResourceLoadFailed(Integration::ResourceId id, - Integration::ResourceFailure failure); - - /** - * @brief Retrieves the latest resource request - * @return A pointer to the latest resource request. - */ - Integration::ResourceRequest* GetRequest(); - - /** - * @brief Retrieves a reference to a container of all the resource requests. - * @return A reference to a container of all the resource requests. - */ - const ResourceRequestContainer& GetAllRequests() const; - - /** - * @brief Sets all resource requests as loaded. - */ - void SetAllResourceRequestsAsLoaded(); - - /** - * @brief Sets all resource requests as loaded. - * @param[in] failure The failure type - */ - void SetAllResourceRequestsAsFailed( Integration::ResourceFailure failure ); - - /** - * @brief Discards all current resource requests. - */ - void DiscardRequest(); - - /** * @brief Sets the value returned by GetClosestImageSize. * @param[in] size The size that should be returned. */ @@ -250,65 +154,61 @@ public: // TEST FUNCTIONS * @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 SetLoadFileResult(bool result, Dali::Vector& buffer); /** * @brief Sets the SaveFile result * @param[in] result The value that SaveFile should return */ - void SetSaveFileResult( bool result ); + void SetSaveFileResult(bool result); /** * @brief Sets the resource loaded by LoadResourceSynchronously * @param[in] resource The loaded resource */ - void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource ); + void SetSynchronouslyLoadedResource(Integration::ResourcePointer resource); -private: + /** + * @brief Sets the bitmap returned by DecodeBuffer() + * @param[in] bitmap The decoded bitmap + */ + void SetDecodedBitmap(Integration::BitmapPtr bitmap); - struct LoadedResource - { - Integration::ResourceId id; - Integration::ResourceTypeId type; - Integration::ResourcePointer resource; - }; + /** + * @brief Triggers the previously stored callback function + */ + void TriggerTimer(); - struct FailedLoad - { - Integration::ResourceId id; - Integration::ResourceFailure failure; - }; +private: + TestPlatformAbstraction(const TestPlatformAbstraction&); ///< Undefined + TestPlatformAbstraction& operator=(const TestPlatformAbstraction&); ///< Undefined +private: struct LoadFileResult { inline LoadFileResult() : loadResult(false) { - } - bool loadResult; - Dali::Vector< unsigned char> buffer; + bool loadResult; + Dali::Vector buffer; }; - typedef std::vector< LoadedResource > LoadedResourceContainer; - typedef std::vector< FailedLoad > FailedLoadContainer; + mutable TraceCallStack mTrace{true, "PlatformAbstraction::"}; + bool mIsLoadingResult; + ImageDimensions mClosestSize; - mutable TraceCallStack mTrace; - bool mIsLoadingResult; - int mGetDefaultFontSizeResult; - LoadedResourceContainer mLoadedResourcesQueue; - FailedLoadContainer mFailedLoadQueue; - ResourceRequestContainer mResourceRequests; - Vector2 mSize; - Vector2 mClosestSize; + LoadFileResult mLoadFileResult; + bool mSaveFileResult; - LoadFileResult mLoadFileResult; - bool mSaveFileResult; + Integration::ResourcePointer mSynchronouslyLoadedResource; + Integration::BitmapPtr mDecodedBitmap; - Integration::ResourcePointer mSynchronouslyLoadedResource; + uint32_t mTimerId; + CallbackBase* mCallbackFunction; }; -} // Dali +} // namespace Dali -#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */ +#endif /* DALI_TEST_PLATFORM_ABSTRACTION_H */