Fixed SVACE errors in Test Graphics
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-orientation.cpp
index 30dd65f..b959638 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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 "toolkit-orientation.h"
+#include <dali/devel-api/adaptor-framework/orientation.h>
 
-#include <dali/public-api/common/dali-common.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/signals/dali-signal.h>
 
-namespace Dali
-{
+using namespace Dali;
 
-namespace
+namespace Dali
 {
-ToolkitOrientation* gToolkitOrientation(NULL);
-} // unnamed namespace
+class Adaptor;
 
 namespace Internal
 {
-
 namespace Adaptor
 {
+class Window;
 
-/**
- * Stub for the Orientation
- */
-class Orientation : public BaseObject
-{
-public: // Creation & Destruction
 
-  Orientation();
-  Orientation(ToolkitOrientation *orientation);
-  ~Orientation();
+struct RotationEvent
+{
+  int angle;     ///< one of 0, 90, 180, 270
+  int winResize; ///< true if the window should be resized
+  int width;     ///< new window width
+  int height;    ///< new window height
+};
 
-public: // Setters & Getters
+class Orientation : public BaseObject
+{
+public:
+  typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
 
-  void SetDegrees( int degrees )
+  static Orientation* New(Window* window)
+  {
+    Orientation* orientation = new Orientation(window);
+    return orientation;
+  }
+  Orientation(Window* window)
   {
-    mOrientation = degrees;
   }
 
-  int GetDegrees() const;
-  float GetRadians() const;
-
-public: // Signals
-
-  Dali::Orientation::OrientationSignalType& ChangedSignal();
-
-  void EmitChangedSignal()
+protected:
+  virtual ~Orientation()
+  {
+  }
+public:
+  int GetDegrees() const
+  {
+    return 0;
+  }
+  float GetRadians() const
+  {
+    return 0.0f;
+  }
+  void OnOrientationChanged( const RotationEvent& rotation )
   {
-    mChangedSignal.Emit(Dali::Orientation(this));
+  }
+  OrientationSignalType& ChangedSignal()
+  {
+    return mChangedSignal;
   }
 
 private:
-
-  Dali::Orientation::OrientationSignalType mChangedSignal;
-
-  ToolkitOrientation* mToolkitOrientation;
-
-  int mOrientation;
+  Orientation(const Orientation&);
+  Orientation& operator=(Orientation&);
+  OrientationSignalType mChangedSignal;
 };
 
-Orientation::Orientation()
-: mToolkitOrientation(NULL),
-  mOrientation(0)
-{
-}
+} // Adaptor namespace
+} // Internal namespace
 
-Orientation::Orientation(ToolkitOrientation *orientation)
-: mToolkitOrientation(orientation),
-  mOrientation(0)
+inline Internal::Adaptor::Orientation& GetImplementation (Dali::Orientation& orientation)
 {
+  DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
+  BaseObject& handle = orientation.GetBaseObject();
+  return static_cast<Internal::Adaptor::Orientation&>(handle);
 }
-
-Orientation::~Orientation()
+inline const Internal::Adaptor::Orientation& GetImplementation(const Dali::Orientation& orientation)
 {
+  DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
+  const BaseObject& handle = orientation.GetBaseObject();
+  return static_cast<const Internal::Adaptor::Orientation&>(handle);
 }
 
-int Orientation::GetDegrees() const
+Orientation::Orientation()
 {
-  mToolkitOrientation->mFunctionsCalled.GetDegrees = true;
-  return mOrientation;
 }
-
-float Orientation::GetRadians() const
+Orientation::~Orientation()
 {
-  mToolkitOrientation->mFunctionsCalled.GetRadians = true;
-  return Math::PI * (float)mOrientation / 180.0f;
 }
-
-Dali::Orientation::OrientationSignalType& Orientation::ChangedSignal()
+Orientation::Orientation(const Orientation& handle)
+: BaseHandle(handle)
 {
-  mToolkitOrientation->mFunctionsCalled.ChangedSignal = true;
-  return mChangedSignal;
 }
 
-} // namespace Adaptor
-
-} // namespace Internal
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-ToolkitOrientation::ToolkitOrientation()
-: mOrientationStub(new Internal::Adaptor::Orientation(this)),
-  mOrientation( mOrientationStub )
+Orientation& Orientation::operator=(const Orientation& rhs)
 {
-  gToolkitOrientation = this;
+  BaseHandle::operator=(rhs);
+  return *this;
 }
 
-ToolkitOrientation::~ToolkitOrientation()
+int Orientation::GetDegrees() const
 {
-  gToolkitOrientation = NULL;
+  return GetImplementation(*this).GetDegrees();
 }
 
-Orientation ToolkitOrientation::GetHandle()
+float Orientation::GetRadians() const
 {
-  return mOrientation;
+  return GetImplementation(*this).GetRadians();
 }
 
-void ToolkitOrientation::SetDegrees( int degrees )
+Orientation::OrientationSignalType& Orientation::ChangedSignal()
 {
-  mOrientationStub->SetDegrees( degrees );
+  return GetImplementation(*this).ChangedSignal();
 }
 
-void ToolkitOrientation::EmitChangedSignal()
+Orientation::Orientation( Internal::Adaptor::Orientation* orientation )
+: BaseHandle(orientation)
 {
-  mOrientationStub->EmitChangedSignal();
 }
 
-} // namespace Dali
+} // Dali