-#ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__
-#define __DALI_TEST_PLATFORM_ABSTRACTION_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+#ifndef DALI_TEST_PLATFORM_ABSTRACTION_H
+#define DALI_TEST_PLATFORM_ABSTRACTION_H
+
+/*
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// EXTERNAL INCLUDES
-#include <set>
#include <stdint.h>
#include <cstring>
+#include <string>
+#include <vector>
// INTERNAL INCLUDES
#include <dali/integration-api/platform-abstraction.h>
+#include <dali/public-api/math/vector2.h>
-#include <dali/integration-api/glyph-set.h>
#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
*/
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);
+ virtual Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resourceType, const std::string& resourcePath );
/**
- * @copydoc PlatformAbstraction::CancelLoad()
+ * @copydoc PlatformAbstraction::DecodeBuffer()
*/
- virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
+ virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size );
/**
- * @copydoc PlatformAbstraction::GetResources()
+ * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
*/
- virtual void GetResources(Integration::ResourceCache& cache);
+ virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
/**
- * @copydoc PlatformAbstraction::IsLoading()
+ * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
*/
- virtual bool IsLoading();
+ virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
+ * @copydoc PlatformAbstraction::StartTimer()
*/
- virtual std::string GetDefaultFontFamily() const;
+ virtual uint32_t StartTimer( uint32_t milliseconds, CallbackBase* callback );
- /**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
+ /*
+ * @copydoc PlatformAbstraction::CancelTimer()
*/
- virtual const float GetDefaultFontSize() const;
+ virtual void CancelTimer ( uint32_t timerId );
- virtual const Dali::PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) const;
+public: // TEST FUNCTIONS
- /**
- * @copydoc PlatformAbstraction::GetGlyphData()
- */
- virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily,
- bool getBitmap) const;
+ // Enumeration of Platform Abstraction methods
+ typedef enum
+ {
+ LoadResourceSynchronouslyFunc,
+ LoadShaderBinaryFileFunc,
+ SaveShaderBinaryFileFunc
+ } TestFuncEnum;
- /**
- * @copydoc PlatformAbstraction::GetCachedGlyphData()
- */
- virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily ) const;
+ /** 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::GetGlobalMetrics()
+ * @brief Checks if a platform function was called
+ * @param[in] func The function to check
+ * @return true if the function was called
*/
- virtual void GetGlobalMetrics( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics ) const;
+ bool WasCalled(TestFuncEnum func);
/**
- * @copydoc PlatformAbstraction::GetFontPath()
+ * @brief Sets the result to return when IsLoading is called by Core.
+ * @param[in] result The result to set.
*/
- virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const;
+ void SetIsLoadingResult(bool result);
/**
- * @copydoc PlatformAbstraction::SetDpi()
+ * @brief Clears all resource queues
*/
- virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
+ void ClearReadyResources();
/**
- * @copydoc PlatformAbstraction::GetFontFamilyForChars()
+ * @brief Sets the value returned by GetClosestImageSize.
+ * @param[in] size The size that should be returned.
*/
- virtual std::string GetFontFamilyForChars(const TextArray& charsRequested) const;
+ void SetClosestImageSize( const Vector2& size );
/**
- * @copydoc PlatformAbstraction::AllGlyphsSupported()
+ * @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 bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const;
+ void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
/**
- * @copydoc PlatformAbstraction::ValidateFontFamilyName()
+ * @brief Sets the SaveFile result
+ * @param[in] result The value that SaveFile should return
*/
- virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const;
+ void SetSaveFileResult( bool result );
/**
- * @copydoc PlatformAbstraction::GetFontList()
+ * @brief Sets the resource loaded by LoadResourceSynchronously
+ * @param[in] resource The loaded resource
*/
- virtual std::vector<std::string> GetFontList( PlatformAbstraction::FontListMode mode ) const;
+ void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource );
/**
- * @copydoc PlatformAbstraction::LoadFile()
+ * @brief Sets the bitmap returned by DecodeBuffer()
+ * @param[in] bitmap The decoded bitmap
*/
- virtual bool LoadFile( 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();
-
- virtual void UpdateDefaultsFromDevice();
-
- virtual Integration::DynamicsFactory* GetDynamicsFactory();
-
- virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics );
+ void TriggerTimer();
- virtual void WriteGlobalMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlobalMetrics& globalMetrics );
-
- virtual bool ReadMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
- virtual void WriteMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlyphSet& glyphSet );
-
-
- virtual void GetFileNamesFromDirectory( const std::string& directoryName,
- std::vector<std::string>& fileNames );
+private:
- virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const;
+ TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined
+ TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined
-public: // TEST FUNCTIONS
+private:
- // Enumeration of Platform Abstraction methods
- typedef enum
+ struct LoadFileResult
{
- GetTimeMicrosecondsFunc,
- SuspendFunc,
- ResumeFunc,
- LoadResourceFunc,
- SaveResourceFunc,
- SaveFileFunc,
- LoadFileFunc,
- CancelLoadFunc,
- GetResourcesFunc,
- IsLoadingFunc,
- GetDefaultFontFamilyFunc,
- GetDefaultFontSizeFunc,
- GetFontLineHeightFromCapsHeightFunc,
- GetGlyphDataFunc,
- GetCachedGlyphDataFunc,
- SetDpiFunc,
- GetFontPathFunc,
- JoinLoaderThreadsFunc,
- GetFontFamilyForCharsFunc,
- AllGlyphsSupportedFunc,
- ValidateFontFamilyNameFunc,
- UpdateDefaultsFromDeviceFunc,
- GetDynamicsFactoryFunc,
- ValidateGetFontListFunc,
- ReadGlobalMetricsFromCacheFileFunc,
- WriteGlobalMetricsToCacheFileFunc,
- ReadMetricsFromCacheFileFunc,
- WriteMetricsToCacheFileFunc,
- } 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();
-
- void DiscardRequest();
-
- void SetClosestImageSize(const Vector2& size);
-
- void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer );
-
- void SetSaveFileResult( bool result );
-
- PlatformAbstraction::FontListMode GetLastFontListMode( );
-
- void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics );
+ inline LoadFileResult()
+ : loadResult(false)
+ {
- void SetReadMetricsResult( bool success, std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
+ }
+ bool loadResult;
+ Dali::Vector< unsigned char> buffer;
+ };
-private:
mutable TraceCallStack mTrace;
- size_t mSeconds;
- size_t mMicroSeconds;
bool mIsLoadingResult;
- std::string mGetDefaultFontFamilyResult;
- float mGetDefaultFontSizeResult;
- std::string mGetFontPathResult;
- Resources mResources;
- Integration::ResourceRequest* mRequest;
- Vector2 mSize;
- Vector2 mClosestSize;
- bool mReadGlobalMetricsResult;
- bool mReadMetricsResult;
- Integration::GlobalMetrics mReadGlobalMetrics;
- std::vector<Integration::GlyphMetrics> mReadMetrics;
+ ImageDimensions mClosestSize;
LoadFileResult mLoadFileResult;
bool mSaveFileResult;
- mutable FontListMode mFontListMode;
+
+ Integration::ResourcePointer mSynchronouslyLoadedResource;
+ Integration::BitmapPtr mDecodedBitmap;
+
+ uint32_t mTimerId;
+ CallbackBase* mCallbackFunction;
};
} // Dali
-#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */
+#endif /* DALI_TEST_PLATFORM_ABSTRACTION_H */