X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-adaptor.cpp;h=c675fef5f3c25e33698c3da9563070ec5a768ef9;hb=55b24ec2b71ef5819be7887e465a6b48d3bf65ee;hp=ebab526f12bcc6b474f5f78fedfd6c562a94a166;hpb=0849361c6c77097551c9c7a320125dbe275be871;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 ebab526..c675fef 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) 2023 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,121 +15,229 @@ * */ -// CLASS HEADER -#include +#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 { +namespace Internal +{ +namespace Adaptor +{ +/////////////////////////////////////////////////////////////////////////////// +// +// Dali::Internal::Adaptor::Adaptor Stub +// +/////////////////////////////////////////////////////////////////////////////// -class EglInterface; -class DisplayConnection; -class ThreadSynchronizationInterface; +Dali::Adaptor* gAdaptor = nullptr; -namespace Integration +Dali::Adaptor& Adaptor::New() { + DALI_ASSERT_ALWAYS(!gAdaptor); + gAdaptor = new Dali::Adaptor; + return *gAdaptor; +} -class GlAbstraction; +Dali::Adaptor& Adaptor::Get() +{ + DALI_ASSERT_ALWAYS(gAdaptor); + return *gAdaptor; +} -} // namespace Integration +Adaptor::Adaptor() +{ +} -class TestRenderSurface : public RenderSurface +Adaptor::~Adaptor() { -public: - virtual PositionSize GetPositionSize() const { PositionSize size; return size; } + gAdaptor = nullptr; +} - virtual void InitializeEgl( EglInterface& egl ) {} +void Adaptor::Start(Dali::Window window) +{ + AddWindow(&GetImplementation(window)); +} - virtual void CreateEglSurface( EglInterface& egl ) {} +Integration::Scene Adaptor::GetScene(Dali::Window window) +{ + return window.GetScene(); +} - virtual void DestroyEglSurface( EglInterface& egl ) {} +bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue) +{ + if(hasReturnValue) + { + mReturnCallbacks.PushBack(callback); + } + else + { + mCallbacks.PushBack(callback); + } + return true; +} - virtual bool ReplaceEGLSurface( EglInterface& egl ) { return false; } +void Adaptor::RemoveIdle(CallbackBase* callback) +{ + mCallbacks.Erase(std::remove_if(mCallbacks.Begin(), mCallbacks.End(), [&callback](CallbackBase* current) { return callback == current; }), mCallbacks.End()); + mReturnCallbacks.Erase(std::remove_if(mReturnCallbacks.Begin(), mReturnCallbacks.End(), [&callback](CallbackBase* current) { return callback == current; }), mReturnCallbacks.End()); +} - virtual void MoveResize( Dali::PositionSize positionSize ) {} +void Adaptor::RunIdles() +{ + Dali::Vector reusedCallbacks; + for(auto& callback : mReturnCallbacks) + { + bool retValue = CallbackBase::ExecuteReturn(*callback); + if(retValue) + { + reusedCallbacks.PushBack(callback); + } + } + for(auto& callback : mCallbacks) + { + CallbackBase::Execute(*callback); + } - virtual void SetViewMode( ViewMode viewMode ) {} + mCallbacks.Clear(); + mReturnCallbacks.Clear(); + mReturnCallbacks.Swap(reusedCallbacks); +} - virtual void StartRender() {} +Dali::RenderSurfaceInterface& Adaptor::GetSurface() +{ + DALI_ASSERT_ALWAYS(!mWindows.empty()); - virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) { return false; } + return reinterpret_cast(mWindows.front()->GetRenderSurface()); +} - virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface ) {} +Dali::WindowContainer Adaptor::GetWindows() +{ + Dali::WindowContainer windows; - virtual void StopRender() {} + 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); + } + } - virtual void ReleaseLock() {} + return windows; +} - virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) {} +Dali::SceneHolderList Adaptor::GetSceneHolders() +{ + Dali::SceneHolderList sceneHolderList; -}; + for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter) + { + sceneHolderList.push_back(Dali::Integration::SceneHolder(*iter)); + } -namespace Internal -{ -namespace Adaptor -{ + return sceneHolderList; +} -class Adaptor: public BaseObject +Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow(Dali::Actor& actor) { -public: - static Dali::Adaptor& Get(); - Adaptor(); - ~Adaptor(); + Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor); -public: - static Dali::RenderSurface& GetSurface(); - static Dali::Adaptor::AdaptorSignalType& AdaptorSignal(); -}; + for(auto window : mWindows) + { + if(scene == window->GetScene()) + { + return window; + } + } -Dali::Adaptor& Adaptor::Get() -{ - Dali::Adaptor* adaptor = new Dali::Adaptor; - return *adaptor; + return nullptr; } -Dali::RenderSurface& Adaptor::GetSurface() +void Adaptor::AddWindow(Internal::Adaptor::SceneHolder* window) { - Dali::RenderSurface *renderSurface = new Dali::TestRenderSurface; - return *renderSurface; + if(window) + { + mWindows.push_back(window); + + Dali::Integration::SceneHolder newWindow(window); + mWindowCreatedSignal.Emit(newWindow); + } } -Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal() +void Adaptor::RemoveWindow(Internal::Adaptor::SceneHolder* window) { - Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType; - return *signal; + auto iter = std::find(mWindows.begin(), mWindows.end(), window); + if(iter != mWindows.end()) + { + mWindows.erase(iter); + } } +void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor) +{ + Integration::Core& core = mTestApplication->GetCore(); + core.RegisterProcessor(processor, postProcessor); } -} + +void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor) +{ + Integration::Core& core = mTestApplication->GetCore(); + core.UnregisterProcessor(processor, postProcessor); } -namespace Dali +void Adaptor::SetApplication(Dali::TestApplication& testApplication) { + mTestApplication = &testApplication; +} -Adaptor& Adaptor::New( Window window ) +Dali::Adaptor::AdaptorSignalType& Adaptor::ResizedSignal() { - return Internal::Adaptor::Adaptor::Get(); + return mResizedSignal; } -Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration ) +Dali::Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal() { - return Internal::Adaptor::Adaptor::Get(); + return mLanguageChangedSignal; } -Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface ) +Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal() { - return Internal::Adaptor::Adaptor::Get(); + return mWindowCreatedSignal; } -Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface, Configuration::ContextLoss configuration ) +} // 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() @@ -148,28 +256,52 @@ void Adaptor::Stop() { } -bool Adaptor::AddIdle( CallbackBase* callback ) +bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue) +{ + return mImpl->AddIdle(callback, hasReturnValue); +} + +void Adaptor::RemoveIdle(CallbackBase* callback) { - return false; + mImpl->RemoveIdle(callback); } -void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurface& surface ) +void Adaptor::ReplaceSurface(Window window, Dali::RenderSurfaceInterface& 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() @@ -178,15 +310,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) { } @@ -197,7 +330,7 @@ Adaptor& Adaptor::Get() bool Adaptor::IsAvailable() { - return false; + return Internal::Adaptor::gAdaptor; } void Adaptor::NotifySceneCreated() @@ -208,37 +341,84 @@ void Adaptor::NotifyLanguageChanged() { } -void Adaptor::SetMinimumPinchDistance(float distance) +void Adaptor::FeedTouchPoint(TouchPoint& point, int timeStamp) { } -void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp ) +void Adaptor::FeedWheelEvent(WheelEvent& wheelEvent) { } -void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent ) +void Adaptor::FeedKeyEvent(KeyEvent& keyEvent) { } -void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) +void Adaptor::SceneCreated() { } -void Adaptor::SceneCreated() +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::SetViewMode( ViewMode mode ) +class TraceFactory : public TraceFactoryInterface { +public: + virtual void InstallTraceFunction() const + { + Dali::Integration::Trace::LogContextFunction logContextFunction(&TestApplication::LogContext); + Dali::Integration::Trace::InstallLogContextFunction(logContextFunction); + } + + TraceFactory() + { + } + virtual ~TraceFactory() + { + } +}; + +TraceFactory* gTraceFactory = NULL; +const TraceFactoryInterface& Adaptor::GetTraceFactory() +{ + if(gTraceFactory == NULL) + { + gTraceFactory = new TraceFactory; + } + return *gTraceFactory; } -void Adaptor::SetStereoBase( float stereoBase ) +void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor) { + mImpl->RegisterProcessor(processor, postProcessor); } -Adaptor::Adaptor() -: mImpl( NULL ) +void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor) { + mImpl->UnregisterProcessor(processor, postProcessor); } } // namespace Dali