[dali_1.3.47] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-application.h
1 #ifndef __DALI_TEST_APPLICATION_H__
2 #define __DALI_TEST_APPLICATION_H__
3
4 /*
5  * Copyright (c) 2018 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 // INTERNAL INCLUDES
22 #include <test-platform-abstraction.h>
23 #include "test-gesture-manager.h"
24 #include "test-gl-sync-abstraction.h"
25 #include "test-gl-abstraction.h"
26 #include "test-render-controller.h"
27 #include <dali/public-api/common/dali-common.h>
28 #include <dali/integration-api/resource-policies.h>
29 #include <dali/integration-api/trace.h>
30
31 namespace Dali
32 {
33
34 class DALI_CORE_API TestApplication : public ConnectionTracker
35 {
36 public:
37
38   // Default values derived from H2 device.
39   static const uint32_t DEFAULT_SURFACE_WIDTH = 480;
40   static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
41
42 #ifdef _CPP11
43   static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
44   static constexpr uint32_t DEFAULT_VERTICAL_DPI   = 217;
45 #else
46   static const uint32_t DEFAULT_HORIZONTAL_DPI = 220;
47   static const uint32_t DEFAULT_VERTICAL_DPI   = 217;
48 #endif
49
50   static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
51
52   static const uint32_t RENDER_FRAME_INTERVAL = 16;
53
54   TestApplication( uint32_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
55                    uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
56                    uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI,
57                    uint32_t verticalDpi   = DEFAULT_VERTICAL_DPI,
58                    ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA);
59
60   void Initialize();
61   virtual ~TestApplication();
62   static void LogMessage( Dali::Integration::Log::DebugPriority level, std::string& message );
63   static void LogContext( bool start, const char* tag );
64   Dali::Integration::Core& GetCore();
65   TestPlatformAbstraction& GetPlatform();
66   TestRenderController& GetRenderController();
67   TestGlAbstraction& GetGlAbstraction();
68   TestGlSyncAbstraction& GetGlSyncAbstraction();
69   TestGestureManager& GetGestureManager();
70   void ProcessEvent(const Integration::Event& event);
71   void SendNotification();
72   void SetSurfaceWidth( uint32_t width, unsigned height );
73   void SetTopMargin( uint32_t margin );
74   bool Render( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
75   uint32_t GetUpdateStatus();
76   bool UpdateOnly( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
77   bool RenderOnly( );
78   void ResetContext();
79   bool GetRenderNeedsUpdate();
80   uint32_t Wait( uint32_t durationToWait );
81
82 private:
83   void DoUpdate( uint32_t intervalMilliseconds, const char* location=NULL );
84
85 protected:
86   TestPlatformAbstraction   mPlatformAbstraction;
87   TestRenderController      mRenderController;
88   TestGlAbstraction         mGlAbstraction;
89   TestGlSyncAbstraction     mGlSyncAbstraction;
90   TestGestureManager        mGestureManager;
91
92   Integration::UpdateStatus mStatus;
93   Integration::RenderStatus mRenderStatus;
94
95   Integration::Core* mCore;
96
97   uint32_t mSurfaceWidth;
98   uint32_t mSurfaceHeight;
99   uint32_t mFrame;
100
101   struct { uint32_t x; uint32_t y; } mDpi;
102   uint32_t mLastVSyncTime;
103   ResourcePolicy::DataRetention mDataRetentionPolicy;
104 };
105
106 } // Dali
107
108 #endif