Adding new test harness
[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) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
21 #include <sstream>
22 #include <string>
23 #include <map>
24
25 // INTERNAL INCLUDES
26 #include <dali/integration-api/core.h>
27 #include <dali/integration-api/gl-sync-abstraction.h>
28 #include "test-trace-call-stack.h"
29
30 namespace Dali
31 {
32
33 class DALI_IMPORT_API TestSyncObject : public Integration::GlSyncAbstraction::SyncObject
34 {
35 public:
36   TestSyncObject(TraceCallStack& trace);
37   ~TestSyncObject();
38   bool IsSynced();
39   bool synced;
40   TraceCallStack& mTrace;
41 };
42
43 /**
44  * Class to emulate the GL sync functions with tracing
45  */
46 class DALI_IMPORT_API TestGlSyncAbstraction: public Integration::GlSyncAbstraction
47 {
48 public:
49   /**
50    * Constructor
51    */
52   TestGlSyncAbstraction();
53
54   /**
55    * Destructor
56    */
57   ~TestGlSyncAbstraction();
58
59   /**
60    * Initialize the sync objects - clear down the map
61    */
62   void Initialize();
63
64   /**
65    * Create a sync object
66    * @return the sync object
67    */
68   virtual Integration::GlSyncAbstraction::SyncObject* CreateSyncObject( );
69
70   /**
71    * Destroy a sync object
72    * @param[in] syncObject The object to destroy
73    */
74   virtual void DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject );
75
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 private:
103   typedef std::vector<TestSyncObject*>   SyncContainer;
104   typedef SyncContainer::iterator SyncIter;
105   SyncContainer mSyncObjects;  ///< The sync objects
106   TraceCallStack mTrace; ///< the trace call stack for testing
107 };
108
109 } // Dali
110
111 #endif // __TEST_GL_SYNC_ABSTRACTION_H__