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