a922e23240e680f13fb419b7c0ba6d57a8ce9c3b
[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) 2020 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-gl-sync-abstraction.h"
24 #include "test-gl-abstraction.h"
25 #include "test-gl-context-helper-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 #include <dali/integration-api/scene.h>
31
32 namespace Dali
33 {
34
35 class DALI_CORE_API TestApplication : public ConnectionTracker
36 {
37 public:
38
39   // Default values derived from H2 device.
40   static const uint32_t DEFAULT_SURFACE_WIDTH = 480;
41   static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
42
43   static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
44   static constexpr uint32_t DEFAULT_VERTICAL_DPI   = 217;
45
46   static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
47
48   static const uint32_t RENDER_FRAME_INTERVAL = 16;
49
50   TestApplication( uint32_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
51                    uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
52                    uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI,
53                    uint32_t verticalDpi   = DEFAULT_VERTICAL_DPI,
54                    bool initialize = true );
55
56   void Initialize();
57   void CreateCore();
58   void CreateScene();
59   void InitializeCore();
60   virtual ~TestApplication();
61   static void LogMessage( Dali::Integration::Log::DebugPriority level, std::string& message );
62   static void LogContext( bool start, const char* tag );
63   Dali::Integration::Core& GetCore();
64   TestPlatformAbstraction& GetPlatform();
65   TestRenderController& GetRenderController();
66   TestGlAbstraction& GetGlAbstraction();
67   TestGlSyncAbstraction& GetGlSyncAbstraction();
68   TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
69   void ProcessEvent(const Integration::Event& event);
70   void SendNotification();
71   bool Render( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL );
72   uint32_t GetUpdateStatus();
73   bool UpdateOnly( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
74   bool RenderOnly( );
75   void ResetContext();
76   bool GetRenderNeedsUpdate();
77   uint32_t Wait( uint32_t durationToWait );
78   static void EnableLogging( bool enabled )
79   {
80     mLoggingEnabled = enabled;
81   }
82
83   Integration::Scene GetScene() const
84   {
85     return mScene;
86   }
87
88 private:
89   void DoUpdate( uint32_t intervalMilliseconds, const char* location=NULL );
90
91 protected:
92   TestPlatformAbstraction   mPlatformAbstraction;
93   TestRenderController      mRenderController;
94   TestGlAbstraction         mGlAbstraction;
95   TestGlSyncAbstraction     mGlSyncAbstraction;
96   TestGlContextHelperAbstraction mGlContextHelperAbstraction;
97
98   Integration::UpdateStatus mStatus;
99   Integration::RenderStatus mRenderStatus;
100
101   Integration::Core* mCore;
102   Dali::Integration::Scene mScene;
103
104   uint32_t mSurfaceWidth;
105   uint32_t mSurfaceHeight;
106   uint32_t mFrame;
107
108   struct { uint32_t x; uint32_t y; } mDpi;
109   uint32_t mLastVSyncTime;
110   static bool mLoggingEnabled;
111 };
112
113 } // Dali
114
115 #endif // DALI_TEST_APPLICATION_H