Remove unnecessary timeDelta parameter from PostRender
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / dali-test-suite-utils / test-platform-abstraction.h
1 #ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__
2 #define __DALI_TEST_PLATFORM_ABSTRACTION_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <stdint.h>
23 #include <cstring>
24 #include <string>
25
26 // INTERNAL INCLUDES
27 #include <dali/integration-api/platform-abstraction.h>
28
29 #include "test-trace-call-stack.h"
30
31 namespace Dali
32 {
33
34 /**
35  * Concrete implementation of the platform abstraction class.
36  */
37 class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction
38 {
39
40 public:
41
42   struct Resources
43   {
44     bool                         loaded;
45     Integration::ResourceId      loadedId;
46     Integration::ResourceTypeId  loadedType;
47     Integration::ResourcePointer loadedResource;
48
49     bool                         loadFailed;
50     Integration::ResourceId      loadFailedId;
51     Integration::ResourceFailure loadFailure;
52   };
53
54   struct LoadFileResult
55   {
56     inline LoadFileResult()
57     : loadResult(false)
58     {
59
60     }
61
62     bool loadResult;
63     Dali::Vector< unsigned char> buffer;
64   };
65
66   /**
67    * Constructor
68    */
69   TestPlatformAbstraction();
70
71   /**
72    * Destructor
73    */
74   virtual ~TestPlatformAbstraction();
75
76   /**
77    * @copydoc PlatformAbstraction::GetTimeMicroseconds()
78    */
79   virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int &microSeconds);
80
81   /**
82    * @copydoc PlatformAbstraction::Suspend()
83    */
84   virtual void Suspend();
85
86   /**
87    * @copydoc PlatformAbstraction::Resume()
88    */
89   virtual void Resume();
90
91   virtual ImageDimensions GetClosestImageSize( const std::string& filename,
92                                                  ImageDimensions size,
93                                                  FittingMode::Type fittingMode,
94                                                  SamplingMode::Type samplingMode,
95                                                  bool orientationCorrection );
96
97   virtual ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
98                                                ImageDimensions size,
99                                                FittingMode::Type fittingMode,
100                                                SamplingMode::Type samplingMode,
101                                                bool orientationCorrection );
102
103   /**
104    * @copydoc PlatformAbstraction::LoadResource()
105    */
106   virtual void LoadResource(const Integration::ResourceRequest& request);
107
108   virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
109
110   /**
111    * @copydoc PlatformAbstraction::CancelLoad()
112    */
113   virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
114
115   /**
116    * @copydoc PlatformAbstraction::GetResources()
117    */
118   virtual void GetResources(Integration::ResourceCache& cache);
119
120   /**
121    * @copydoc PlatformAbstraction::IsLoading()
122    */
123   virtual bool IsLoading();
124
125   /**
126    * @copydoc PlatformAbstraction::GetDefaultFontFamily()
127    */
128   virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
129
130   /**
131    * @copydoc PlatformAbstraction::GetDefaultFontSize()
132    */
133   virtual int GetDefaultFontSize() const;
134
135   /**
136    * @copydoc PlatformAbstraction::SetDpi()
137    */
138   virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
139
140   /**
141    * @copydoc PlatformAbstraction::LoadFile()
142    */
143   virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
144
145   /**
146    * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
147    */
148   virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
149
150   /**
151    * @copydoc PlatformAbstraction::SaveFile()
152    */
153   virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
154
155  /**
156   * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
157   */
158   virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return false; }
159
160   virtual void JoinLoaderThreads();
161
162 public: // TEST FUNCTIONS
163
164   // Enumeration of Platform Abstraction methods
165   typedef enum
166   {
167     GetTimeMicrosecondsFunc,
168     SuspendFunc,
169     ResumeFunc,
170     LoadResourceFunc,
171     SaveFileFunc,
172     LoadFileFunc,
173     CancelLoadFunc,
174     GetResourcesFunc,
175     IsLoadingFunc,
176     SetDpiFunc,
177     JoinLoaderThreadsFunc,
178   } TestFuncEnum;
179
180   /** Call this every test */
181   void Initialize();
182
183   inline void EnableTrace(bool enable) { mTrace.Enable(enable); }
184   inline void ResetTrace() { mTrace.Reset(); }
185   inline TraceCallStack& GetTrace() { return mTrace; }
186
187   bool WasCalled(TestFuncEnum func);
188
189   void SetGetTimeMicrosecondsResult(size_t sec, size_t usec);
190
191   void IncrementGetTimeResult(size_t milliseconds);
192
193   void SetIsLoadingResult(bool result);
194
195   void ClearReadyResources();
196
197   void SetResourceLoaded(Integration::ResourceId  loadedId,
198                          Integration::ResourceTypeId  loadedType,
199                          Integration::ResourcePointer loadedResource);
200
201   void SetResourceLoadFailed(Integration::ResourceId  id,
202                              Integration::ResourceFailure failure);
203
204   Integration::ResourceRequest* GetRequest();
205
206   void DiscardRequest();
207
208   void SetClosestImageSize(const Vector2& size);
209
210   void SetLoadFileResult( bool result, Dali::Vector< unsigned char >& buffer );
211
212   void SetSaveFileResult( bool result );
213
214 private:
215   mutable TraceCallStack        mTrace;
216   size_t                        mSeconds;
217   size_t                        mMicroSeconds;
218   bool                          mIsLoadingResult;
219   std::string                   mGetDefaultFontFamilyResult;
220   std::string                   mGetDefaultFontStyleResult;
221   int                           mGetDefaultFontSizeResult;
222   Resources                     mResources;
223   Integration::ResourceRequest* mRequest;
224   Vector2                       mSize;
225   Vector2                       mClosestSize;
226
227   LoadFileResult                mLoadFileResult;
228   bool                          mSaveFileResult;
229 };
230
231 } // Dali
232
233 #endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */