[dali_2.3.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) 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 <dali/integration-api/resource-policies.h>
23 #include <dali/integration-api/scene.h>
24 #include <dali/integration-api/trace.h>
25 #include <dali/public-api/common/dali-common.h>
26 #include <test-platform-abstraction.h>
27
28 #include "test-gl-abstraction.h"
29 #include "test-gl-context-helper-abstraction.h"
30 #include "test-gl-sync-abstraction.h"
31 #include "test-render-controller.h"
32
33 namespace Dali
34 {
35 class DALI_CORE_API TestApplication : public ConnectionTracker
36 {
37 public:
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   static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
43   static constexpr uint32_t DEFAULT_VERTICAL_DPI   = 217;
44
45   static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
46
47   static const uint32_t RENDER_FRAME_INTERVAL = 16;
48
49   TestApplication(uint32_t surfaceWidth        = DEFAULT_SURFACE_WIDTH,
50                   uint32_t surfaceHeight       = DEFAULT_SURFACE_HEIGHT,
51                   uint32_t horizontalDpi       = DEFAULT_HORIZONTAL_DPI,
52                   uint32_t verticalDpi         = DEFAULT_VERTICAL_DPI,
53                   bool     initialize          = true,
54                   bool     enablePartialUpdate = false);
55
56   void Initialize();
57   void CreateCore();
58   void CreateScene();
59   void InitializeCore();
60   ~TestApplication() override;
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   bool                            PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
73   bool                            RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
74   uint32_t                        GetUpdateStatus();
75   bool                            UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
76   bool                            RenderOnly();
77   void                            ResetContext();
78   bool                            GetRenderNeedsUpdate();
79   bool                            GetRenderNeedsPostRender();
80   uint32_t                        Wait(uint32_t durationToWait);
81   static void                     EnableLogging(bool enabled)
82   {
83     mLoggingEnabled = enabled;
84   }
85
86   Integration::Scene GetScene() const
87   {
88     return mScene;
89   }
90
91 private:
92   void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL);
93
94 protected:
95   TestPlatformAbstraction        mPlatformAbstraction;
96   TestRenderController           mRenderController;
97   TestGlAbstraction              mGlAbstraction;
98   TestGlSyncAbstraction          mGlSyncAbstraction;
99   TestGlContextHelperAbstraction mGlContextHelperAbstraction;
100
101   Integration::UpdateStatus mStatus;
102   Integration::RenderStatus mRenderStatus;
103
104   Integration::Core*       mCore;
105   Dali::Integration::Scene mScene;
106
107   uint32_t mSurfaceWidth;
108   uint32_t mSurfaceHeight;
109   uint32_t mFrame;
110
111   struct
112   {
113     uint32_t x;
114     uint32_t y;
115   } mDpi;
116   uint32_t    mLastVSyncTime;
117   bool        mPartialUpdateEnabled;
118   static bool mLoggingEnabled;
119 };
120
121 } // namespace Dali
122
123 #endif // DALI_TEST_APPLICATION_H