Adding 'override', removing 'virtual' from overriding functions' declarations in...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-platform-abstraction.h
index b1fb01b..1adedd4 100644 (file)
@@ -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) 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.
 #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 "test-trace-call-stack.h"
 
@@ -34,35 +36,11 @@ 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
    */
@@ -71,121 +49,64 @@ public:
   /**
    * Destructor
    */
-  virtual ~TestPlatformAbstraction();
-
-  /**
-   * @copydoc PlatformAbstraction::GetTimeNanoseconds()
-   */
-  virtual void GetTimeNanoseconds( uint64_t& seconds, uint64_t& nanoseconds );
-
-  /**
-   * @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 GetClosestImageSize( const std::string& filename,
                                                  ImageDimensions size,
                                                  FittingMode::Type fittingMode,
                                                  SamplingMode::Type samplingMode,
-                                                 bool orientationCorrection );
+                                                 bool orientationCorrection ) override;
 
   /**
    * @copydoc PlatformAbstraction::GetClosestImageSize()
    */
-  virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
+  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);
+                                               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);
+  Integration::BitmapPtr DecodeBuffer( const Dali::Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size ) override;
 
   /**
-   * @copydoc PlatformAbstraction::IsLoading()
-   */
-  virtual bool IsLoading();
-
-  /**
-   * @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< unsigned char >& 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
   {
-    GetTimeNanosecondsFunc,
-    SuspendFunc,
-    ResumeFunc,
-    LoadResourceFunc,
-    SaveFileFunc,
-    LoadFileFunc,
+    LoadResourceSynchronouslyFunc,
     LoadShaderBinaryFileFunc,
-    SaveShaderBinaryFileFunc,
-    CancelLoadFunc,
-    GetResourcesFunc,
-    IsLoadingFunc,
-    SetDpiFunc,
-    JoinLoaderThreadsFunc,
+    SaveShaderBinaryFileFunc
   } TestFuncEnum;
 
   /** Call this every test */
@@ -195,50 +116,93 @@ 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 SetGetTimeNanosecondsResult(size_t sec, size_t nsec);
-
-  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 SetGetDefaultFontSizeResult(float result);
-
+  /**
+   * @brief Clears all resource queues
+   */
   void ClearReadyResources();
 
-  void SetResourceLoaded(Integration::ResourceId  loadedId,
-                         Integration::ResourceTypeId  loadedType,
-                         Integration::ResourcePointer loadedResource);
+  /**
+   * @brief Sets the value returned by GetClosestImageSize.
+   * @param[in] size The size that should be returned.
+   */
+  void SetClosestImageSize( const Vector2& size );
 
-  void SetResourceLoadFailed(Integration::ResourceId  id,
-                             Integration::ResourceFailure failure);
+  /**
+   * @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 );
 
-  Integration::ResourceRequest* GetRequest();
+  /**
+   * @brief Sets the SaveFile result
+   * @param[in] result The value that SaveFile should return
+   */
+  void SetSaveFileResult( bool result );
 
-  void DiscardRequest();
+  /**
+   * @brief Sets the resource loaded by LoadResourceSynchronously
+   * @param[in] resource The loaded resource
+   */
+  void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource );
 
-  void SetClosestImageSize(const Vector2& size);
+  /**
+   * @brief Sets the bitmap returned by DecodeBuffer()
+   * @param[in] bitmap The decoded bitmap
+   */
+  void SetDecodedBitmap( Integration::BitmapPtr bitmap );
 
-  void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
+  /**
+   * @brief Triggers the previously stored callback function
+   */
+  void TriggerTimer();
 
-  void SetSaveFileResult( bool result );
+private:
+
+  TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined
+  TestPlatformAbstraction& operator=( const TestPlatformAbstraction& ); ///< Undefined
 
 private:
+
+  struct LoadFileResult
+  {
+    inline LoadFileResult()
+    : loadResult(false)
+    {
+
+    }
+
+    bool loadResult;
+    Dali::Vector< unsigned char> buffer;
+  };
+
   mutable TraceCallStack        mTrace;
-  uint64_t                      mSeconds;
-  uint64_t                      mNanoSeconds;
   bool                          mIsLoadingResult;
-  int                           mGetDefaultFontSizeResult;
-  Resources                     mResources;
-  Integration::ResourceRequest* mRequest;
-  Vector2                       mSize;
-  Vector2                       mClosestSize;
+  ImageDimensions               mClosestSize;
 
   LoadFileResult                mLoadFileResult;
   bool                          mSaveFileResult;
+
+  Integration::ResourcePointer  mSynchronouslyLoadedResource;
+  Integration::BitmapPtr        mDecodedBitmap;
+
+  uint32_t                      mTimerId;
+  CallbackBase*                 mCallbackFunction;
 };
 
 } // Dali
 
-#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */
+#endif /* DALI_TEST_PLATFORM_ABSTRACTION_H */