License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / dali-test-suite-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) 2014 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 <sstream>
23 #include <string>
24 #include <map>
25
26 // INTERNAL INCLUDES
27 #include <dali/dali.h>
28 #include <dali/integration-api/core.h>
29 #include <dali/integration-api/gl-sync-abstraction.h>
30 #include "test-trace-call-stack.h"
31
32 namespace Dali
33 {
34
35 class DALI_IMPORT_API TestSyncObject : public Integration::GlSyncAbstraction::SyncObject
36 {
37 public:
38   TestSyncObject(TraceCallStack& trace);
39   ~TestSyncObject();
40   bool IsSynced();
41   bool synced;
42   TraceCallStack& mTrace;
43 };
44
45 /**
46  * Class to emulate the GL sync functions with tracing
47  */
48 class DALI_IMPORT_API TestGlSyncAbstraction: public Integration::GlSyncAbstraction
49 {
50 public:
51   /**
52    * Constructor
53    */
54   TestGlSyncAbstraction();
55
56   /**
57    * Destructor
58    */
59   ~TestGlSyncAbstraction();
60
61   /**
62    * Initialize the sync objects - clear down the map
63    */
64   void Initialize();
65
66   /**
67    * Create a sync object
68    * @return the sync object
69    */
70   virtual Integration::GlSyncAbstraction::SyncObject* CreateSyncObject( );
71
72   /**
73    * Destroy a sync object
74    * @param[in] syncObject The object to destroy
75    */
76   virtual void DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject );
77
78
79 public: // TEST FUNCTIONS
80   Integration::GlSyncAbstraction::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( Integration::GlSyncAbstraction::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 private:
105   typedef std::vector<TestSyncObject*>   SyncContainer;
106   typedef SyncContainer::iterator SyncIter;
107   SyncContainer mSyncObjects;  ///< The sync objects
108   TraceCallStack mTrace; ///< the trace call stack for testing
109 };
110
111 } // Dali
112
113 #endif // __TEST_GL_SYNC_ABSTRACTION_H__