Removed REQUIRES_STYLE_CHANGE_SIGNALS
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-gl-sync-abstraction.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "test-gl-sync-abstraction.h"
19
20 namespace Dali
21 {
22
23 TestSyncObject::TestSyncObject(TraceCallStack& trace)
24 : synced(false),
25   mTrace(trace)
26 {
27 }
28
29 TestSyncObject::~TestSyncObject()
30 {
31 }
32
33 bool TestSyncObject::IsSynced()
34 {
35   mTrace.PushCall("SyncObject::IsSynced", ""); // Trace the method
36   return synced;
37 }
38
39
40
41 TestGlSyncAbstraction::TestGlSyncAbstraction()
42 {
43   Initialize();
44 }
45
46 /**
47  * Destructor
48  */
49 TestGlSyncAbstraction::~TestGlSyncAbstraction()
50 {
51   for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter )
52   {
53     delete *iter;
54   }
55 }
56
57 /**
58  * Initialize the sync objects - clear down the map
59  */
60 void TestGlSyncAbstraction::Initialize()
61 {
62   mSyncObjects.clear();
63 }
64
65 /**
66  * Create a sync object
67  * @return the sync object
68  */
69 Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::CreateSyncObject( )
70 {
71   mTrace.PushCall("CreateSyncObject", ""); // Trace the method
72
73   TestSyncObject* syncObject = new TestSyncObject(mTrace);
74   mSyncObjects.push_back( syncObject );
75   return syncObject;
76 }
77
78 /**
79  * Destroy a sync object
80  * @param[in] syncObject The object to destroy
81  */
82 void TestGlSyncAbstraction::DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject )
83 {
84   std::stringstream out;
85   out << syncObject;
86   mTrace.PushCall("DestroySyncObject", out.str()); // Trace the method
87
88   for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter )
89   {
90     if( *iter == syncObject )
91     {
92       delete *iter;
93       mSyncObjects.erase(iter);
94       break;
95     }
96   }
97 }
98
99
100 Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::GetLastSyncObject( )
101 {
102   if( !mSyncObjects.empty() )
103   {
104     return mSyncObjects.back();
105   }
106   return NULL;
107 }
108
109 /**
110  * Test method to trigger the object sync behaviour.
111  * @param[in]
112  * @param[in] sync The sync value to set
113  */
114 void TestGlSyncAbstraction::SetObjectSynced( Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync )
115 {
116   TestSyncObject* testSyncObject = static_cast<TestSyncObject*>(syncObject);
117   testSyncObject->synced = sync;
118 }
119
120 /**
121  * Turn trace on
122  */
123 void TestGlSyncAbstraction::EnableTrace(bool enable) { mTrace.Enable(enable); }
124
125 /**
126  * Reset the trace callstack
127  */
128 void TestGlSyncAbstraction::ResetTrace() { mTrace.Reset(); }
129
130 /**
131  * Get the trace object (allows test case to find methods on it)
132  */
133 TraceCallStack& TestGlSyncAbstraction::GetTrace() { return mTrace; }
134
135 int32_t TestGlSyncAbstraction::GetNumberOfSyncObjects()
136 {
137   return static_cast<int32_t>( mSyncObjects.size() );
138 }
139
140
141 } // Dali