X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-orientation.cpp;h=b959638ae1bf6c7efdd56e142e1ea768f9ff957e;hp=e7e2568431d60b1860f839cd07db9938f4dec1e3;hb=32d9c82fd183da60e3c54584d888388e73b92d34;hpb=998d982768c7f211d948cfd7921ec27ff739ce49 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp index e7e2568..b959638 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp @@ -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. @@ -15,130 +15,125 @@ * */ -#include "toolkit-orientation.h" +#include -#include +#include #include -#include +#include -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::OrientationSignalV2& 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::OrientationSignalV2 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(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(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::OrientationSignalV2& 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