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=1fe86c3711bd3f86f8ecac1bf334872b0e3c077e;hp=4b25c5da0f4e9ea71e35a349ab532c92b7009921;hb=8a647e87a01c5c78451653c1264a9eea81ac9b20;hpb=260c832bfaa0294e74a4f96d321f149adf09a3ce 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 4b25c5d..1fe86c3 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) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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,12 +15,21 @@ * */ -// CLASS HEADER -#include +#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 +#include + +#include #include +#include +#include +#include +#include namespace Dali { @@ -30,53 +39,189 @@ namespace Internal namespace Adaptor { -bool Adaptor::mAvailable = false; -Vector Adaptor::mCallbacks = Vector(); +/////////////////////////////////////////////////////////////////////////////// +// +// Dali::Internal::Adaptor::Adaptor Stub +// +/////////////////////////////////////////////////////////////////////////////// + +Dali::Adaptor* gAdaptor = nullptr; + +Dali::Adaptor& Adaptor::New() +{ + DALI_ASSERT_ALWAYS( ! gAdaptor ); + gAdaptor = new Dali::Adaptor; + return *gAdaptor; +} Dali::Adaptor& Adaptor::Get() { - Dali::Adaptor* adaptor = new Dali::Adaptor; - Adaptor::mAvailable = true; - return *adaptor; + DALI_ASSERT_ALWAYS( gAdaptor ); + return *gAdaptor; } -Dali::RenderSurface& Adaptor::GetSurface() +Adaptor::Adaptor() { - Dali::RenderSurface *renderSurface = new Dali::TestRenderSurface; - return *renderSurface; } -Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal() +Adaptor::~Adaptor() { - Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType; - return *signal; + gAdaptor = nullptr; } -} // namespace Adaptor -} // namespace Internal +void Adaptor::Start( Dali::Window window ) +{ + AddWindow( &GetImplementation( window ) ); +} -Adaptor& Adaptor::New( Window window ) +Integration::Scene Adaptor::GetScene( Dali::Window window ) { - return Internal::Adaptor::Adaptor::Get(); + return window.GetScene(); } -Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration ) +bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue ) { - return Internal::Adaptor::Adaptor::Get(); + mCallbacks.PushBack( callback ); + return true; } -Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface ) +void Adaptor::RemoveIdle( CallbackBase* callback ) { - return Internal::Adaptor::Adaptor::Get(); + mCallbacks.Erase( std::find_if( mCallbacks.Begin(), mCallbacks.End(), + [ &callback ] ( CallbackBase* current ) { return callback == current; } ) ); } -Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface, Configuration::ContextLoss configuration ) +void Adaptor::RunIdles() +{ + for( auto& callback : mCallbacks ) + { + CallbackBase::Execute( *callback ); + } + + mCallbacks.Clear(); +} + +Dali::RenderSurfaceInterface& Adaptor::GetSurface() +{ + DALI_ASSERT_ALWAYS( ! mWindows.empty() ); + + return reinterpret_cast < Dali::RenderSurfaceInterface& >( mWindows.front()->GetRenderSurface() ); +} + +Dali::WindowContainer Adaptor::GetWindows() +{ + Dali::WindowContainer windows; + + for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter ) + { + // Downcast to Dali::Window + Dali::Window window( dynamic_cast( *iter ) ); + if ( window ) + { + windows.push_back( window ); + } + } + + return windows; +} + +Dali::SceneHolderList Adaptor::GetSceneHolders() +{ + Dali::SceneHolderList sceneHolderList; + + for( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter ) + { + sceneHolderList.push_back( Dali::Integration::SceneHolder( *iter ) ); + } + + return sceneHolderList; +} + +Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor ) +{ + Dali::Integration::Scene scene = Dali::Integration::Scene::Get( actor ); + + for( auto window : mWindows ) + { + if ( scene == window->GetScene() ) + { + return window; + } + } + + return nullptr; +} + +void Adaptor::AddWindow( Internal::Adaptor::SceneHolder* window ) +{ + if ( window ) + { + mWindows.push_back( window ); + + Dali::Integration::SceneHolder newWindow( window ); + mWindowCreatedSignal.Emit( newWindow ); + } +} + +void Adaptor::RemoveWindow( Internal::Adaptor::SceneHolder* window ) +{ + auto iter = std::find( mWindows.begin(), mWindows.end(), window ); + if( iter != mWindows.end() ) + { + mWindows.erase( iter ); + } +} + +void Adaptor::RegisterProcessor( Integration::Processor& processor ) +{ + Integration::Core& core = mTestApplication->GetCore(); + core.RegisterProcessor( processor ); +} + +void Adaptor::UnregisterProcessor( Integration::Processor& processor ) +{ + Integration::Core& core = mTestApplication->GetCore(); + core.UnregisterProcessor( processor ); +} + +void Adaptor::SetApplication( Dali::TestApplication& testApplication ) +{ + mTestApplication = &testApplication; +} + +Dali::Adaptor::AdaptorSignalType& Adaptor::ResizedSignal() +{ + return mResizedSignal; +} + +Dali::Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal() +{ + return mLanguageChangedSignal; +} + +Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal() +{ + return mWindowCreatedSignal; +} + +} // namespace Adaptor +} // namespace Internal + +/////////////////////////////////////////////////////////////////////////////// +// +// Dali::Adaptor Stub +// +/////////////////////////////////////////////////////////////////////////////// + +Adaptor::Adaptor() +: mImpl( new Internal::Adaptor::Adaptor ) { - return Internal::Adaptor::Adaptor::Get(); } Adaptor::~Adaptor() { + Internal::Adaptor::gAdaptor = nullptr; + delete mImpl; } void Adaptor::Start() @@ -95,55 +240,52 @@ void Adaptor::Stop() { } -bool Adaptor::AddIdle( CallbackBase* callback ) +bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue ) { - const bool isAvailable = IsAvailable(); - - if( isAvailable ) - { - Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback ); - } - - return isAvailable; + return mImpl->AddIdle( callback, hasReturnValue ); } void Adaptor::RemoveIdle( CallbackBase* callback ) { - const bool isAvailable = IsAvailable(); + mImpl->RemoveIdle( callback ); +} - 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::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface ) +{ } -void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurface& surface ) +void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface ) { } Adaptor::AdaptorSignalType& Adaptor::ResizedSignal() { - return Internal::Adaptor::Adaptor::AdaptorSignal(); + return mImpl->ResizedSignal(); } Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal() { - return Internal::Adaptor::Adaptor::AdaptorSignal(); + return mImpl->LanguageChangedSignal(); +} + +Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal() +{ + return mImpl->WindowCreatedSignal(); +} + +Dali::RenderSurfaceInterface& Adaptor::GetSurface() +{ + return mImpl->GetSurface(); } -RenderSurface& Adaptor::GetSurface() +Dali::WindowContainer Adaptor::GetWindows() const { - return Internal::Adaptor::Adaptor::GetSurface(); + return mImpl->GetWindows(); +} + +Dali::SceneHolderList Adaptor::GetSceneHolders() const +{ + return mImpl->GetSceneHolders(); } Any Adaptor::GetNativeWindowHandle() @@ -152,15 +294,16 @@ Any Adaptor::GetNativeWindowHandle() return window; } -void Adaptor::ReleaseSurfaceLock() +Any Adaptor::GetNativeWindowHandle( Actor actor ) { + return GetNativeWindowHandle(); } -void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) +void Adaptor::ReleaseSurfaceLock() { } -void Adaptor::SetUseHardwareVSync(bool useHardware) +void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) { } @@ -171,7 +314,7 @@ Adaptor& Adaptor::Get() bool Adaptor::IsAvailable() { - return Internal::Adaptor::Adaptor::mAvailable; + return Internal::Adaptor::gAdaptor; } void Adaptor::NotifySceneCreated() @@ -182,10 +325,6 @@ void Adaptor::NotifyLanguageChanged() { } -void Adaptor::SetMinimumPinchDistance(float distance) -{ -} - void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp ) { } @@ -202,17 +341,41 @@ void Adaptor::SceneCreated() { } -void Adaptor::SetViewMode( ViewMode mode ) +class LogFactory : public LogFactoryInterface { +public: + virtual void InstallLogFunction() const + { + Dali::Integration::Log::LogFunction logFunction(&ToolkitTestApplication::LogMessage); + Dali::Integration::Log::InstallLogFunction(logFunction); + } + + LogFactory() + { + } + virtual ~LogFactory() + { + } +}; + +LogFactory* gLogFactory = NULL; +const LogFactoryInterface& Adaptor::GetLogFactory() +{ + if( gLogFactory == NULL ) + { + gLogFactory = new LogFactory; + } + return *gLogFactory; } -void Adaptor::SetStereoBase( float stereoBase ) +void Adaptor::RegisterProcessor( Integration::Processor& processor ) { + mImpl->RegisterProcessor( processor ); } -Adaptor::Adaptor() -: mImpl( NULL ) +void Adaptor::UnregisterProcessor( Integration::Processor& processor ) { + mImpl->UnregisterProcessor( processor ); } } // namespace Dali