Protecting test cases from memory scribbling
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-gl-sync-abstraction.cpp
index 8ea52be..f404f32 100644 (file)
@@ -1,24 +1,24 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 #include "test-gl-sync-abstraction.h"
 
 namespace Dali
 {
-
 TestSyncObject::TestSyncObject(TraceCallStack& trace)
 : synced(false),
   mTrace(trace)
@@ -35,8 +35,6 @@ bool TestSyncObject::IsSynced()
   return synced;
 }
 
-
-
 TestGlSyncAbstraction::TestGlSyncAbstraction()
 {
   Initialize();
@@ -47,7 +45,7 @@ TestGlSyncAbstraction::TestGlSyncAbstraction()
  */
 TestGlSyncAbstraction::~TestGlSyncAbstraction()
 {
-  for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter )
+  for(SyncIter iter = mSyncObjects.begin(), end = mSyncObjects.end(); iter != end; ++iter)
   {
     delete *iter;
   }
@@ -65,12 +63,12 @@ void TestGlSyncAbstraction::Initialize()
  * Create a sync object
  * @return the sync object
  */
-Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::CreateSyncObject( )
+Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::CreateSyncObject()
 {
   mTrace.PushCall("CreateSyncObject", ""); // Trace the method
 
   TestSyncObject* syncObject = new TestSyncObject(mTrace);
-  mSyncObjects.push_back( syncObject );
+  mSyncObjects.push_back(syncObject);
   return syncObject;
 }
 
@@ -78,15 +76,15 @@ Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::CreateSyncObj
  * Destroy a sync object
  * @param[in] syncObject The object to destroy
  */
-void TestGlSyncAbstraction::DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject )
+void TestGlSyncAbstraction::DestroySyncObject(Integration::GlSyncAbstraction::SyncObject* syncObject)
 {
   std::stringstream out;
   out << syncObject;
   mTrace.PushCall("DestroySyncObject", out.str()); // Trace the method
 
-  for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter )
+  for(SyncIter iter = mSyncObjects.begin(), end = mSyncObjects.end(); iter != end; ++iter)
   {
-    if( *iter == syncObject )
+    if(*iter == syncObject)
     {
       delete *iter;
       mSyncObjects.erase(iter);
@@ -95,10 +93,9 @@ void TestGlSyncAbstraction::DestroySyncObject( Integration::GlSyncAbstraction::S
   }
 }
 
-
-Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::GetLastSyncObject( )
+Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::GetLastSyncObject()
 {
-  if( !mSyncObjects.empty() )
+  if(!mSyncObjects.empty())
   {
     return mSyncObjects.back();
   }
@@ -110,26 +107,39 @@ Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::GetLastSyncOb
  * @param[in]
  * @param[in] sync The sync value to set
  */
-void TestGlSyncAbstraction::SetObjectSynced( Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync )
+void TestGlSyncAbstraction::SetObjectSynced(Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync)
 {
   TestSyncObject* testSyncObject = static_cast<TestSyncObject*>(syncObject);
-  testSyncObject->synced = sync;
+  testSyncObject->synced         = sync;
 }
 
 /**
  * Turn trace on
  */
-void TestGlSyncAbstraction::EnableTrace(bool enable) { mTrace.Enable(enable); }
+void TestGlSyncAbstraction::EnableTrace(bool enable)
+{
+  mTrace.Enable(enable);
+}
 
 /**
  * Reset the trace callstack
  */
-void TestGlSyncAbstraction::ResetTrace() { mTrace.Reset(); }
+void TestGlSyncAbstraction::ResetTrace()
+{
+  mTrace.Reset();
+}
 
 /**
  * Get the trace object (allows test case to find methods on it)
  */
-TraceCallStack& TestGlSyncAbstraction::GetTrace() { return mTrace; }
+TraceCallStack& TestGlSyncAbstraction::GetTrace()
+{
+  return mTrace;
+}
 
+int32_t TestGlSyncAbstraction::GetNumberOfSyncObjects()
+{
+  return static_cast<int32_t>(mSyncObjects.size());
+}
 
-} // Dali
+} // namespace Dali