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=8f3095fd877afd93d20d8f64c1c9b745446d486d;hp=63bacde7d60cc24da606067215dcf54860ea1bd3;hb=7018f61b640b6fcf9cb576b537bafcb6bb8240e8;hpb=b7a36db4c66c579601b9be7fa4af0f5215d3922c 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 63bacde..8f3095f 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) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -17,47 +17,23 @@ #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 #include -#include +#include namespace Dali { -namespace -{ - -/////////////////////////////////////////////////////////////////////////////// -// -// LogFactoryStub -// -/////////////////////////////////////////////////////////////////////////////// - -class LogFactory : public LogFactoryInterface -{ -public: - LogFactory() = default; - virtual ~LogFactory() = default; - -private: - void InstallLogFunction() const override - { - Dali::Integration::Log::InstallLogFunction( &TestApplication::LogMessage ); - } -}; -LogFactory* gLogFactory = NULL; // For some reason, destroying this when the Adaptor is destroyed causes a crash in some test cases when running all of them. -} //unnamed namespace - namespace Internal { namespace Adaptor @@ -95,11 +71,7 @@ Adaptor::~Adaptor() void Adaptor::Start( Dali::Window window ) { - if ( window ) - { - mWindows.push_back( window ); - mWindowCreatedSignal.Emit( window ); - } + AddWindow( &GetImplementation( window ) ); } Integration::Scene Adaptor::GetScene( Dali::Window window ) @@ -133,12 +105,88 @@ Dali::RenderSurfaceInterface& Adaptor::GetSurface() { DALI_ASSERT_ALWAYS( ! mWindows.empty() ); - return reinterpret_cast < Dali::RenderSurfaceInterface& >( mWindows.front().GetRenderSurface() ); + return reinterpret_cast < Dali::RenderSurfaceInterface& >( mWindows.front()->GetRenderSurface() ); } Dali::WindowContainer Adaptor::GetWindows() { - return mWindows; + 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, 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 ); +} + +void Adaptor::SetApplication( Dali::TestApplication& testApplication ) +{ + mTestApplication = &testApplication; } Dali::Adaptor::AdaptorSignalType& Adaptor::ResizedSignal() @@ -235,12 +283,22 @@ Dali::WindowContainer Adaptor::GetWindows() const return mImpl->GetWindows(); } +Dali::SceneHolderList Adaptor::GetSceneHolders() const +{ + return mImpl->GetSceneHolders(); +} + Any Adaptor::GetNativeWindowHandle() { Any window; return window; } +Any Adaptor::GetNativeWindowHandle( Actor actor ) +{ + return GetNativeWindowHandle(); +} + void Adaptor::ReleaseSurfaceLock() { } @@ -283,6 +341,24 @@ 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 ) @@ -292,4 +368,14 @@ const LogFactoryInterface& Adaptor::GetLogFactory() return *gLogFactory; } +void Adaptor::RegisterProcessor( Integration::Processor& processor, bool postProcessor) +{ + mImpl->RegisterProcessor( processor, postProcessor ); +} + +void Adaptor::UnregisterProcessor( Integration::Processor& processor, bool postProcessor) +{ + mImpl->UnregisterProcessor( processor, postProcessor ); +} + } // namespace Dali