[dali_1.2.19] 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) 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 // 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
30 namespace Dali
31 {
32
33 class DALI_IMPORT_API TestApplication : public ConnectionTracker
34 {
35 public:
36
37   // Default values derived from H2 device.
38   static const unsigned int DEFAULT_SURFACE_WIDTH = 480;
39   static const unsigned int DEFAULT_SURFACE_HEIGHT = 800;
40
41 #ifdef _CPP11
42   static constexpr float DEFAULT_HORIZONTAL_DPI = 220.0f;
43   static constexpr float DEFAULT_VERTICAL_DPI   = 217.0f;
44 #else
45   static const float DEFAULT_HORIZONTAL_DPI = 220.0f;
46   static const float DEFAULT_VERTICAL_DPI   = 217.0f;
47 #endif
48
49   static const unsigned int DEFAULT_RENDER_INTERVAL = 1;
50
51   static const unsigned int RENDER_FRAME_INTERVAL = 16;
52
53   TestApplication( size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
54                    size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
55                    float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
56                    float  verticalDpi   = DEFAULT_VERTICAL_DPI,
57                    ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA);
58
59   TestApplication( bool   initialize,
60                    size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
61                    size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
62                    float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
63                    float  verticalDpi   = DEFAULT_VERTICAL_DPI,
64                    ResourcePolicy::DataRetention policy = ResourcePolicy::DALI_DISCARDS_ALL_DATA);
65
66   void Initialize();
67   virtual ~TestApplication();
68   static void LogMessage( Dali::Integration::Log::DebugPriority level, std::string& message );
69   Dali::Integration::Core& GetCore();
70   TestPlatformAbstraction& GetPlatform();
71   TestRenderController& GetRenderController();
72   TestGlAbstraction& GetGlAbstraction();
73   TestGlSyncAbstraction& GetGlSyncAbstraction();
74   TestGestureManager& GetGestureManager();
75   void ProcessEvent(const Integration::Event& event);
76   void SendNotification();
77   void SetSurfaceWidth( unsigned int width, unsigned height );
78   void SetTopMargin( unsigned int margin );
79   bool Render( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
80   unsigned int GetUpdateStatus();
81   bool UpdateOnly( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
82   bool RenderOnly( );
83   void ResetContext();
84   bool GetRenderNeedsUpdate();
85   unsigned int Wait( unsigned int durationToWait );
86
87 private:
88   void DoUpdate( unsigned int intervalMilliseconds, const char* location=NULL );
89
90 protected:
91   TestPlatformAbstraction   mPlatformAbstraction;
92   TestRenderController      mRenderController;
93   TestGlAbstraction         mGlAbstraction;
94   TestGlSyncAbstraction     mGlSyncAbstraction;
95   TestGestureManager        mGestureManager;
96
97   Integration::UpdateStatus mStatus;
98   Integration::RenderStatus mRenderStatus;
99
100   Integration::Core* mCore;
101
102   unsigned int mSurfaceWidth;
103   unsigned int mSurfaceHeight;
104   unsigned int mFrame;
105
106   Vector2 mDpi;
107   unsigned int mLastVSyncTime;
108   ResourcePolicy::DataRetention mDataRetentionPolicy;
109 };
110
111 } // Dali
112
113 #endif