Fixed SVACE errors in Test Graphics
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-sync-impl.h
1 #ifndef TEST_SYNC_IMPLEMENTATION_H
2 #define TEST_SYNC_IMPLEMENTATION_H
3
4 /*
5  * Copyright (c) 2021 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 // EXTERNAL INCLUDES
22 #include <map>
23 #include <sstream>
24 #include <string>
25
26 // INTERNAL INCLUDES
27 #include <dali/graphics-api/graphics-sync-object-create-info.h>
28 #include <dali/graphics-api/graphics-sync-object.h>
29 #include <dali/integration-api/core.h>
30 #include <dali/integration-api/graphics-sync-abstraction.h>
31
32 #include "test-trace-call-stack.h"
33
34 namespace Dali
35 {
36 class TestGraphicsSyncImplementation;
37
38 class TestSyncObject : public Integration::GraphicsSyncAbstraction::SyncObject
39 {
40 public:
41   TestSyncObject(TraceCallStack& trace);
42   ~TestSyncObject() override;
43   bool            IsSynced() override;
44   bool            synced;
45   TraceCallStack& mTrace;
46 };
47
48 /**
49  * Class to emulate the gpu sync functions with tracing
50  */
51 class TestGraphicsSyncImplementation : public Integration::GraphicsSyncAbstraction
52 {
53 public:
54   /**
55    * Constructor
56    */
57   TestGraphicsSyncImplementation();
58
59   /**
60    * Destructor
61    */
62   virtual ~TestGraphicsSyncImplementation();
63
64   /**
65    * Initialize the sync objects
66    */
67   void Initialize();
68
69   /**
70    * Create a sync object that can be polled
71    */
72   GraphicsSyncAbstraction::SyncObject* CreateSyncObject() override;
73
74   /**
75    * Destroy a sync object
76    */
77   void DestroySyncObject(GraphicsSyncAbstraction::SyncObject* syncObject) override;
78
79 public: // TEST FUNCTIONS
80   GraphicsSyncAbstraction::SyncObject* GetLastSyncObject();
81
82   /**
83    * Test method to trigger the object sync behaviour.
84    * @param[in]
85    * @param[in] sync The sync value to set
86    */
87   void SetObjectSynced(GraphicsSyncAbstraction::SyncObject* syncObject, bool sync);
88
89   /**
90    * Turn trace on
91    */
92   void EnableTrace(bool enable);
93
94   /**
95    * Reset the trace callstack
96    */
97   void ResetTrace();
98
99   /**
100    * Get the trace object (allows test case to find methods on it)
101    */
102   TraceCallStack& GetTrace();
103
104   /**
105    * Get the number of sync objects
106    *
107    * @return the number of sync objects
108    */
109   int32_t GetNumberOfSyncObjects();
110
111   TestGraphicsSyncImplementation(const TestGraphicsSyncImplementation&) = delete;
112   TestGraphicsSyncImplementation& operator=(const TestGraphicsSyncImplementation&) = delete;
113
114 private:
115   typedef std::vector<TestSyncObject*> SyncContainer;
116   typedef SyncContainer::iterator      SyncIter;
117   SyncContainer                        mSyncObjects;       ///< The sync objects
118   TraceCallStack                       mTrace{true, "gl"}; ///< the trace call stack for testing
119 };
120
121 } // namespace Dali
122
123 #endif // TEST_GL_SYNC_ABSTRACTION_H