[dali_2.3.33] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / dali-test-suite-utils / test-application.h
1 #ifndef DALI_TEST_APPLICATION_H
2 #define DALI_TEST_APPLICATION_H
3
4 /*
5  * Copyright (c) 2024 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
26 #include <dali/public-api/common/dali-common.h>
27 #include <test-platform-abstraction.h>
28
29 #include "test-graphics-controller.h"
30 #include "test-render-controller.h"
31 #include "test-render-surface.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 const Rect<int> DEFAULT_SURFACE_RECT;
43
44   static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
45   static constexpr uint32_t DEFAULT_VERTICAL_DPI   = 217;
46
47   static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
48
49   static const uint32_t RENDER_FRAME_INTERVAL = 16;
50
51   TestApplication(uint32_t surfaceWidth        = DEFAULT_SURFACE_WIDTH,
52                   uint32_t surfaceHeight       = DEFAULT_SURFACE_HEIGHT,
53                   uint32_t horizontalDpi       = DEFAULT_HORIZONTAL_DPI,
54                   uint32_t verticalDpi         = DEFAULT_VERTICAL_DPI,
55                   bool     initialize          = true,
56                   bool     enablePartialUpdate = false);
57
58   void Initialize();
59   void CreateCore();
60   void CreateScene();
61   void InitializeCore();
62   ~TestApplication() override;
63   static void              LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
64   static void              LogContext(bool start, const char* tag, const char* message);
65   Dali::Integration::Core& GetCore();
66   TestPlatformAbstraction& GetPlatform();
67   TestRenderController&    GetRenderController();
68   TestGraphicsController&  GetGraphicsController();
69
70   TestGlAbstraction&              GetGlAbstraction();
71   TestGraphicsSyncImplementation& GetGraphicsSyncImpl();
72
73   void        ProcessEvent(const Integration::Event& event);
74   void        SendNotification();
75   bool        Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL, bool uploadOnly = false);
76   bool        PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
77   bool        RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
78   bool        RenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location = NULL);
79   uint32_t    GetUpdateStatus();
80   bool        UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
81   bool        RenderOnly();
82   void        ResetContext();
83   bool        GetRenderNeedsUpdate();
84   bool        GetRenderNeedsPostRender();
85   uint32_t    Wait(uint32_t durationToWait);
86   static void EnableLogging(bool enabled)
87   {
88     mLoggingEnabled = enabled;
89   }
90
91   Integration::Scene GetScene() const
92   {
93     return mScene;
94   }
95
96   void AddScene(Integration::Scene scene);
97   void RemoveScene(Integration::Scene scene);
98
99 private:
100   void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL, bool uploadOnly = false);
101
102 protected:
103   TestPlatformAbstraction mPlatformAbstraction;
104   TestRenderController    mRenderController;
105   TestGraphicsController  mGraphicsController;
106   TestRenderSurface*      mRenderSurface;
107
108   Integration::UpdateStatus mStatus;
109   Integration::RenderStatus mRenderStatus;
110
111   Integration::Core*              mCore;
112   Dali::Integration::Scene        mScene;
113   std::vector<Integration::Scene> mScenes;
114
115   uint32_t mSurfaceWidth;
116   uint32_t mSurfaceHeight;
117   uint32_t mFrame;
118
119   Graphics::UniquePtr<Graphics::RenderTarget> mRenderTarget;
120
121   struct
122   {
123     uint32_t x;
124     uint32_t y;
125   } mDpi;
126   uint32_t    mLastVSyncTime;
127   bool        mPartialUpdateEnabled;
128   static bool mLoggingEnabled;
129 };
130
131 } // namespace Dali
132
133 #endif // DALI_TEST_APPLICATION_H