Update common test util
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-adaptor.cpp
index ebab526..4b25c5d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
 #include <dali/integration-api/adaptors/adaptor.h>
 
 #include <dali/public-api/object/base-object.h>
-#include <dali/devel-api/adaptor-framework/render-surface.h>
 
-namespace Dali
-{
-
-class EglInterface;
-class DisplayConnection;
-class ThreadSynchronizationInterface;
-
-namespace Integration
-{
+#include <toolkit-adaptor-impl.h>
 
-class GlAbstraction;
-
-} // namespace Integration
-
-class TestRenderSurface : public RenderSurface
+namespace Dali
 {
-public:
-  virtual PositionSize GetPositionSize() const { PositionSize size; return size; }
-
-  virtual void InitializeEgl( EglInterface& egl ) {}
-
-  virtual void CreateEglSurface( EglInterface& egl ) {}
-
-  virtual void DestroyEglSurface( EglInterface& egl ) {}
-
-  virtual bool ReplaceEGLSurface( EglInterface& egl ) { return false; }
-
-  virtual void MoveResize( Dali::PositionSize positionSize ) {}
-
-  virtual void SetViewMode( ViewMode viewMode ) {}
-
-  virtual void StartRender() {}
-
-  virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) { return false; }
-
-  virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface ) {}
-
-  virtual void StopRender() {}
-
-  virtual void ReleaseLock() {}
-
-  virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) {}
-
-};
 
 namespace Internal
 {
 namespace Adaptor
 {
 
-class Adaptor: public BaseObject
-{
-public:
-  static Dali::Adaptor& Get();
-  Adaptor();
-  ~Adaptor();
-
-public:
-  static Dali::RenderSurface& GetSurface();
-  static Dali::Adaptor::AdaptorSignalType& AdaptorSignal();
-};
+bool Adaptor::mAvailable = false;
+Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
 
 Dali::Adaptor& Adaptor::Get()
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor;
+  Adaptor::mAvailable = true;
   return *adaptor;
 }
 
@@ -101,12 +52,8 @@ Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
   return *signal;
 }
 
-}
-}
-}
-
-namespace Dali
-{
+} // namespace Adaptor
+} // namespace Internal
 
 Adaptor& Adaptor::New( Window window )
 {
@@ -150,7 +97,34 @@ void Adaptor::Stop()
 
 bool Adaptor::AddIdle( CallbackBase* callback )
 {
-  return false;
+  const bool isAvailable = IsAvailable();
+
+  if( isAvailable )
+  {
+    Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback );
+  }
+
+  return isAvailable;
+}
+
+void Adaptor::RemoveIdle( CallbackBase* callback )
+{
+  const bool isAvailable = IsAvailable();
+
+  if( isAvailable )
+  {
+    for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
+           endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
+         it != endIt;
+         ++it )
+    {
+      if( callback == *it )
+      {
+        Internal::Adaptor::Adaptor::mCallbacks.Remove( it );
+        return;
+      }
+    }
+  }
 }
 
 void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurface& surface )
@@ -197,7 +171,7 @@ Adaptor& Adaptor::Get()
 
 bool Adaptor::IsAvailable()
 {
-  return false;
+  return Internal::Adaptor::Adaptor::mAvailable;
 }
 
 void Adaptor::NotifySceneCreated()