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