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=2fce6a2a12937ef96b9541d6c5a730e08e007485;hb=HEAD;hpb=074b05f53f89491982b2d5380cab7f05b1932a76 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 2fce6a2..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,59 +20,25 @@ // 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; - - 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 */ @@ -81,185 +47,168 @@ public: /** * Destructor */ - virtual ~TestPlatformAbstraction(); + ~TestPlatformAbstraction() override; /** - * @copydoc PlatformAbstraction::GetTimeMicroseconds() + * @copydoc PlatformAbstraction::GetClosestImageSize() */ - virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds); + ImageDimensions GetClosestImageSize(const std::string& filename, + ImageDimensions size, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection) override; /** - * @copydoc PlatformAbstraction::Suspend() + * @copydoc PlatformAbstraction::GetClosestImageSize() */ - virtual void Suspend(); + ImageDimensions GetClosestImageSize(Integration::ResourcePointer resourceBuffer, + ImageDimensions size, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection) override; /** - * @copydoc PlatformAbstraction::Resume() + * @copydoc PlatformAbstraction::LoadResourceSynchronously() */ - virtual void Resume(); + Integration::ResourcePointer LoadImageSynchronously(const Integration::BitmapResourceType& resourceType, const std::string& resourcePath) override; /** - * @copydoc PlatformAbstraction::GetClosestImageSize() + * @copydoc PlatformAbstraction::DecodeBuffer() */ - virtual ImageDimensions GetClosestImageSize( const std::string& filename, - ImageDimensions size, - FittingMode::Type scalingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection ); + Integration::BitmapPtr DecodeBuffer(const Dali::Integration::BitmapResourceType& resourceType, uint8_t* buffer, size_t size) override; /** - * @copydoc PlatformAbstraction::GetClosestImageSize() + * @copydoc PlatformAbstraction::LoadShaderBinaryFile() */ - virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer, - ImageDimensions size, - FittingMode::Type scalingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection ); + bool LoadShaderBinaryFile(const std::string& filename, Dali::Vector& buffer) const override; /** - * @copydoc PlatformAbstraction::LoadResource() + * @copydoc PlatformAbstraction::SaveShaderBinaryFile() */ - virtual void LoadResource(const Integration::ResourceRequest& request); + virtual bool SaveShaderBinaryFile(const std::string& filename, const unsigned char* buffer, unsigned int numBytes) const override + { + return true; + } /** - * @copydoc PlatformAbstraction::LoadResourceSynchronously() + * @copydoc PlatformAbstraction::StartTimer() */ - virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ); + uint32_t StartTimer(uint32_t milliseconds, CallbackBase* callback) override; - /** - * @copydoc PlatformAbstraction::SaveResource() + /* + * @copydoc PlatformAbstraction::CancelTimer() */ - virtual void SaveResource(const Integration::ResourceRequest& request); + void CancelTimer(uint32_t timerId) override; + +public: // TEST FUNCTIONS + // Enumeration of Platform Abstraction methods + typedef enum + { + LoadResourceSynchronouslyFunc, + LoadShaderBinaryFileFunc, + 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; + } /** - * @copydoc PlatformAbstraction::CancelLoad() + * @brief Checks if a platform function was called + * @param[in] func The function to check + * @return true if the function was called */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); + bool WasCalled(TestFuncEnum func); /** - * @copydoc PlatformAbstraction::GetResources() + * @brief Sets the result to return when IsLoading is called by Core. + * @param[in] result The result to set. */ - virtual void GetResources(Integration::ResourceCache& cache); + void SetIsLoadingResult(bool result); /** - * @copydoc PlatformAbstraction::IsLoading() + * @brief Clears all resource queues */ - virtual bool IsLoading(); + void ClearReadyResources(); /** - * @copydoc PlatformAbstraction::GetDefaultFontDescription() + * @brief Sets the value returned by GetClosestImageSize. + * @param[in] size The size that should be returned. */ - virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const; + void SetClosestImageSize(const Vector2& size); /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() + * @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. */ - virtual int GetDefaultFontSize() const; + void SetLoadFileResult(bool result, Dali::Vector& buffer); /** - * @copydoc PlatformAbstraction::SetDpi() + * @brief Sets the SaveFile result + * @param[in] result The value that SaveFile should return */ - virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); + void SetSaveFileResult(bool result); + /** - * @copydoc PlatformAbstraction::LoadFile() + * @brief Sets the resource loaded by LoadResourceSynchronously + * @param[in] resource The loaded resource */ - virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; + void SetSynchronouslyLoadedResource(Integration::ResourcePointer resource); /** - * @copydoc PlatformAbstraction::LoadShaderBinFile() + * @brief Sets the bitmap returned by DecodeBuffer() + * @param[in] bitmap The decoded bitmap */ - virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; + void SetDecodedBitmap(Integration::BitmapPtr bitmap); /** - * @copydoc PlatformAbstraction::SaveFile() + * @brief Triggers the previously stored callback function */ - virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const; - - virtual void JoinLoaderThreads(); + void TriggerTimer(); - virtual Integration::DynamicsFactory* GetDynamicsFactory(); - -public: // TEST FUNCTIONS +private: + TestPlatformAbstraction(const TestPlatformAbstraction&); ///< Undefined + TestPlatformAbstraction& operator=(const TestPlatformAbstraction&); ///< Undefined - // Enumeration of Platform Abstraction methods - typedef enum +private: + struct LoadFileResult { - GetTimeMicrosecondsFunc, - SuspendFunc, - ResumeFunc, - LoadResourceFunc, - SaveResourceFunc, - SaveFileFunc, - LoadFileFunc, - LoadShaderBinFileFunc, - CancelLoadFunc, - GetResourcesFunc, - IsLoadingFunc, - SetDpiFunc, - JoinLoaderThreadsFunc, - GetDynamicsFactoryFunc, - } 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; } - - bool WasCalled(TestFuncEnum func); - - void SetGetTimeMicrosecondsResult(size_t sec, size_t usec); - - void IncrementGetTimeResult(size_t milliseconds); - - void SetIsLoadingResult(bool result); - - void SetGetDefaultFontFamilyResult(std::string result); - - void SetGetDefaultFontSizeResult(float result); - - void SetGetFontPathResult(std::string& result); - - void ClearReadyResources(); - - void SetResourceLoaded(Integration::ResourceId loadedId, - Integration::ResourceTypeId loadedType, - Integration::ResourcePointer loadedResource); - - void SetResourceLoadFailed(Integration::ResourceId id, - Integration::ResourceFailure failure); - - void SetResourceSaved(Integration::ResourceId savedId, - Integration::ResourceTypeId savedType); - - void SetResourceSaveFailed(Integration::ResourceId id, - Integration::ResourceFailure failure); - - Integration::ResourceRequest* GetRequest(); + inline LoadFileResult() + : loadResult(false) + { + } - void DiscardRequest(); + bool loadResult; + Dali::Vector buffer; + }; - void SetClosestImageSize(const Vector2& size); + mutable TraceCallStack mTrace{true, "PlatformAbstraction::"}; + bool mIsLoadingResult; + ImageDimensions mClosestSize; - void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer ); + LoadFileResult mLoadFileResult; + bool mSaveFileResult; - void SetSaveFileResult( bool result ); + Integration::ResourcePointer mSynchronouslyLoadedResource; + Integration::BitmapPtr mDecodedBitmap; -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; + uint32_t mTimerId; + CallbackBase* mCallbackFunction; }; -} // Dali +} // namespace Dali -#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */ +#endif /* DALI_TEST_PLATFORM_ABSTRACTION_H */