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-adaptor.cpp;h=522537c02f5f7460de42c824357ed6236de9ad96;hp=186fadd9671933d0d27ac4cb5a27424edf60cd7d;hb=8ae521ab64a3922f3419fbbfb83dde57e6135cf5;hpb=fca68202d695c569739819fb8d58b9808b8decb5;ds=sidebyside diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp index 186fadd..522537c 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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,250 +15,284 @@ * */ -#define __DALI_ADAPTOR_H__ -#define __DALI_ACCESSIBILITY_MANAGER_H__ -#define __DALI_TIMER_H__ -#define __DALI_CLIPBOARD_H__ -#define __DALI_IMF_MANAGER_H__ +#include -#include "toolkit-adaptor.h" -#include -#include -#include +// Don't want to include the actual window.h which otherwise will be indirectly included by adaptor.h. +#define DALI_WINDOW_H +#include -namespace Dali -{ - -//////////////////////////////////////////////////////////////////////////////////////////////////// +#include -class TestRenderSurface : public RenderSurface -{ -public: - TestRenderSurface(){} - virtual ~TestRenderSurface(){} - virtual SurfaceType GetType() { return RenderSurface::WINDOW; } - virtual Dali::Any GetSurface() { return Dali::Any(); } - virtual Dali::Any GetDisplay() { return Dali::Any(); } - virtual PositionSize GetPositionSize() const { return PositionSize(0, 0, 640, 480);} - virtual void SetRenderMode(RenderMode mode){} - virtual RenderMode GetRenderMode() const { return RenderSurface::RENDER_60FPS; } -}; +#include -typedef Dali::Rect PositionSize; +#include +#include +#include +#include -/** - * Stub for the Adaptor - */ -class Adaptor +namespace Dali { -public: - typedef SignalV2< void ( Adaptor& ) > AdaptorSignalV2; +namespace Internal +{ +namespace Adaptor +{ - typedef std::pair SingletonPair; - typedef std::map SingletonContainer; - typedef SingletonContainer::const_iterator SingletonConstIter; +bool Adaptor::mAvailable = false; +Vector Adaptor::mCallbacks = Vector(); +Dali::WindowContainer Adaptor::mWindows; +Dali::Adaptor::WindowCreatedSignalType* Adaptor::mWindowCreatedSignal = nullptr; -public: - - Adaptor(ToolkitAdaptor& toolkitAdaptor); - ~Adaptor(); +Dali::Adaptor& Adaptor::Get() +{ + Dali::Adaptor* adaptor = new Dali::Adaptor; + Adaptor::mAvailable = true; + return *adaptor; +} -public: +Dali::RenderSurfaceInterface& Adaptor::GetSurface() +{ + Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast ( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) ); + return *renderSurface; +} - void Start(); - void Pause(); - void Resume(); - void Stop(); - bool AddIdle(boost::function callBack); - void FeedEvent(TouchPoint& point, int timeStamp); - bool MoveResize(const PositionSize& positionSize); - void SurfaceResized(const PositionSize& positionSize); - void ReplaceSurface(RenderSurface& surface); - void RenderSync(); - RenderSurface& GetSurface(); +Dali::WindowContainer Adaptor::GetWindows() +{ + return Adaptor::mWindows; +} - void RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton); - Dali::BaseHandle GetSingleton(const std::type_info& info) const; +Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal() +{ + Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType; + return *signal; +} -public: // static methods - static Adaptor& Get(); - static bool IsAvailable(); +Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal() +{ + if ( !Adaptor::mWindowCreatedSignal ) + { + Adaptor::mWindowCreatedSignal = new Dali::Adaptor::WindowCreatedSignalType; + } -public: // Signals + return *Adaptor::mWindowCreatedSignal; +} - AdaptorSignalV2& SignalResize(); +} // namespace Adaptor +} // namespace Internal - void EmitSignalResize() - { - mResizeSignal.Emit( *this ); - } +Adaptor& Adaptor::New( Window window ) +{ + return Internal::Adaptor::Adaptor::Get(); +} -private: +Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration ) +{ + return Internal::Adaptor::Adaptor::Get(); +} - // Undefined - Adaptor(const Adaptor&); - Adaptor& operator=(Adaptor&); +Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface ) +{ + return Internal::Adaptor::Adaptor::Get(); +} - AdaptorSignalV2 mResizeSignal; - TestRenderSurface mRenderSurface; - ToolkitAdaptor& mToolkitAdaptor; +Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration ) +{ + return Internal::Adaptor::Adaptor::Get(); +} - SingletonContainer mSingletonContainer; -}; +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window ) +{ + return Internal::Adaptor::Adaptor::Get(); +} -namespace +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration ) { -Adaptor* gAdaptor = NULL; + return Internal::Adaptor::Adaptor::Get(); +} +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface ) +{ + return Internal::Adaptor::Adaptor::Get(); } -Adaptor::Adaptor(ToolkitAdaptor& toolkitAdaptor) -: mToolkitAdaptor(toolkitAdaptor) +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration ) { + return Internal::Adaptor::Adaptor::Get(); } Adaptor::~Adaptor() { - } void Adaptor::Start() { - mToolkitAdaptor.mFunctionsCalled.Start = true; } void Adaptor::Pause() { - mToolkitAdaptor.mFunctionsCalled.Pause = true; } void Adaptor::Resume() { - mToolkitAdaptor.mFunctionsCalled.Resume = true; } void Adaptor::Stop() { - mToolkitAdaptor.mFunctionsCalled.Stop = true; } -bool Adaptor::AddIdle(boost::function callBack) +bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue ) +{ + const bool isAvailable = IsAvailable(); + + if( isAvailable ) + { + Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback ); + } + + return isAvailable; +} + +void Adaptor::RemoveIdle( CallbackBase* callback ) { - mToolkitAdaptor.mFunctionsCalled.AddIdle = true; - mToolkitAdaptor.mLastIdleAdded = callBack; - return true; + const bool isAvailable = IsAvailable(); + + if( isAvailable ) + { + for( Vector::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::FeedEvent(TouchPoint& point, int timeStamp) +void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface ) { - mToolkitAdaptor.mFunctionsCalled.FeedEvent = true; - mToolkitAdaptor.mLastTouchPointFed = point; - mToolkitAdaptor.mLastTimeStampFed = timeStamp; } -bool Adaptor::MoveResize(const PositionSize& positionSize) +void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface ) { - mToolkitAdaptor.mFunctionsCalled.MoveResize = true; - mToolkitAdaptor.mLastSizeSet = positionSize; - return true; } -void Adaptor::SurfaceResized(const PositionSize& positionSize) +Adaptor::AdaptorSignalType& Adaptor::ResizedSignal() { - mToolkitAdaptor.mFunctionsCalled.SurfaceResized = true; - mToolkitAdaptor.mLastSizeSet = positionSize; + return Internal::Adaptor::Adaptor::AdaptorSignal(); } -void Adaptor::ReplaceSurface(RenderSurface& surface) +Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal() { - mToolkitAdaptor.mFunctionsCalled.ReplaceSurface = true; + return Internal::Adaptor::Adaptor::AdaptorSignal(); } -void Adaptor::RenderSync() +Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal() { - mToolkitAdaptor.mFunctionsCalled.RenderSync = true; + return Internal::Adaptor::Adaptor::WindowCreatedSignal(); } -RenderSurface& Adaptor::GetSurface() +Dali::RenderSurfaceInterface& Adaptor::GetSurface() { - mToolkitAdaptor.mFunctionsCalled.GetSurface = true; - return mRenderSurface; + return Internal::Adaptor::Adaptor::GetSurface(); } -Adaptor& Adaptor::Get() +Dali::WindowContainer Adaptor::GetWindows() const { - DALI_ASSERT_ALWAYS(gAdaptor); - gAdaptor->mToolkitAdaptor.mFunctionsCalled.Get = true; - return *gAdaptor; + return Internal::Adaptor::Adaptor::GetWindows(); } -bool Adaptor::IsAvailable() +Any Adaptor::GetNativeWindowHandle() { - bool available(false); + Any window; + return window; +} - if (gAdaptor) - { - gAdaptor->mToolkitAdaptor.mFunctionsCalled.IsAvailable = true; - available = true; - } +void Adaptor::ReleaseSurfaceLock() +{ +} - return available; +void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) +{ } -void Adaptor::RegisterSingleton(const std::type_info& info, Dali::BaseHandle singleton) +void Adaptor::SetUseHardwareVSync(bool useHardware) { - mToolkitAdaptor.mFunctionsCalled.RegisterSingleton = true; +} - if(singleton) - { - mSingletonContainer.insert(SingletonPair(info.name(), singleton)); - } +Adaptor& Adaptor::Get() +{ + return Internal::Adaptor::Adaptor::Get(); } -Dali::BaseHandle Adaptor::GetSingleton(const std::type_info& info) const +bool Adaptor::IsAvailable() { - mToolkitAdaptor.mFunctionsCalled.GetSingleton = true; + return Internal::Adaptor::Adaptor::mAvailable; +} - Dali::BaseHandle object = Dali::BaseHandle(); +void Adaptor::NotifySceneCreated() +{ +} - SingletonConstIter iter = mSingletonContainer.find(info.name()); - if(iter != mSingletonContainer.end()) - { - object = (*iter).second; - } +void Adaptor::NotifyLanguageChanged() +{ +} - return object; +void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp ) +{ } -Adaptor::AdaptorSignalV2& Adaptor::SignalResize() +void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent ) { - mToolkitAdaptor.mFunctionsCalled.SignalResize = true; - return mResizeSignal; } -//////////////////////////////////////////////////////////////////////////////////////////////////// +void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) +{ +} -ToolkitAdaptor::ToolkitAdaptor() -: mLastTouchPointFed(0, TouchPoint::Down, 0.0f, 0.0f), - mLastTimeStampFed(0), - mStyleMonitor(StyleMonitor::Get()), - mAccessibilityManager(AccessibilityManager::Get()), - mImfManager(ImfManager::Get()), - mAdaptorStub(new Adaptor(*this)) +void Adaptor::SceneCreated() { - gAdaptor = mAdaptorStub; } -ToolkitAdaptor::~ToolkitAdaptor() +class LogFactory : public LogFactoryInterface +{ +public: + virtual void InstallLogFunction() const + { + Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage); + Dali::Integration::Log::InstallLogFunction(logFunction); + } + + LogFactory() + { + } + virtual ~LogFactory() + { + } +}; + +LogFactory* gLogFactory = NULL; +const LogFactoryInterface& Adaptor::GetLogFactory() { - delete mAdaptorStub; - gAdaptor = NULL; + if( gLogFactory == NULL ) + { + gLogFactory = new LogFactory; + } + return *gLogFactory; } -void ToolkitAdaptor::EmitSignalResize() +Adaptor::Adaptor() +: mImpl( NULL ) { - mAdaptorStub->EmitSignalResize(); + Dali::PositionSize win_size; + win_size.width = 640; + win_size.height = 800; + + Dali::Window window = Dali::Window::New( win_size, "" ); + Internal::Adaptor::Adaptor::mWindows.push_back( window ); } } // namespace Dali