X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-adaptor.cpp;h=5dbbe764d21b833fdcd2cbf7a1762bebe3d06f0f;hb=HEAD;hp=8f3095fd877afd93d20d8f64c1c9b745446d486d;hpb=55bef2b585b85c078894362584c00f29e6fef58e;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 8f3095f..3c9445a 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) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -24,21 +24,22 @@ #include #include -#include -#include #include #include #include +#include +#include +#include +#include #include +#include "dali-test-suite-utils.h" namespace Dali { - namespace Internal { namespace Adaptor { - /////////////////////////////////////////////////////////////////////////////// // // Dali::Internal::Adaptor::Adaptor Stub @@ -49,14 +50,14 @@ Dali::Adaptor* gAdaptor = nullptr; Dali::Adaptor& Adaptor::New() { - DALI_ASSERT_ALWAYS( ! gAdaptor ); + DALI_ASSERT_ALWAYS(!gAdaptor); gAdaptor = new Dali::Adaptor; return *gAdaptor; } Dali::Adaptor& Adaptor::Get() { - DALI_ASSERT_ALWAYS( gAdaptor ); + DALI_ASSERT_ALWAYS(gAdaptor); return *gAdaptor; } @@ -67,58 +68,108 @@ Adaptor::Adaptor() Adaptor::~Adaptor() { gAdaptor = nullptr; + + // Ensure all threads and not-excuted tasks are destroyed. + // TODO : we'd better make some singletone service for toolkit UTC in future. + Test::AsyncTaskManager::DestroyAsyncTaskManager(); +} + +void Adaptor::Start(Dali::Window window) +{ + AddWindow(&GetImplementation(window)); } -void Adaptor::Start( Dali::Window window ) +void Adaptor::Stop() { - AddWindow( &GetImplementation( window ) ); + if(mTestApplication) + { + Integration::Core& core = mTestApplication->GetCore(); + tet_printf("Adaptor::UnregisterProcessors\n"); + core.UnregisterProcessors(); + } + + mStopped = true; } -Integration::Scene Adaptor::GetScene( Dali::Window window ) +Integration::Scene Adaptor::GetScene(Dali::Window window) { return window.GetScene(); } -bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue ) +bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue) { - mCallbacks.PushBack( callback ); - return true; + if(ToolkitApplication::ADD_IDLE_SUCCESS) + { + if(hasReturnValue) + { + mReturnCallbacks.PushBack(callback); + } + else + { + mCallbacks.PushBack(callback); + } + } + return ToolkitApplication::ADD_IDLE_SUCCESS; } -void Adaptor::RemoveIdle( CallbackBase* callback ) +void Adaptor::RemoveIdle(CallbackBase* callback) { - mCallbacks.Erase( std::find_if( mCallbacks.Begin(), mCallbacks.End(), - [ &callback ] ( CallbackBase* current ) { return callback == current; } ) ); + 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()); } void Adaptor::RunIdles() { - for( auto& callback : mCallbacks ) + Dali::Vector reusedCallbacks; + for(auto& callback : mReturnCallbacks) + { + bool retValue = CallbackBase::ExecuteReturn(*callback); + if(retValue) + { + reusedCallbacks.PushBack(callback); + } + } + for(auto& callback : mCallbacks) { - CallbackBase::Execute( *callback ); + CallbackBase::Execute(*callback); } mCallbacks.Clear(); + mReturnCallbacks.Clear(); + mReturnCallbacks.Swap(reusedCallbacks); +} + +void Adaptor::RequestUpdateOnce() +{ + if(mTestApplication) + { + auto scene = mTestApplication->GetScene(); + if(scene) + { + tet_printf("Adaptor::RequestUpdateOnce()\n"); + scene.KeepRendering(0.0f); + } + } } Dali::RenderSurfaceInterface& Adaptor::GetSurface() { - DALI_ASSERT_ALWAYS( ! mWindows.empty() ); + DALI_ASSERT_ALWAYS(!mWindows.empty()); - return reinterpret_cast < Dali::RenderSurfaceInterface& >( mWindows.front()->GetRenderSurface() ); + return reinterpret_cast(mWindows.front()->GetRenderSurface()); } Dali::WindowContainer Adaptor::GetWindows() { Dali::WindowContainer windows; - for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter ) + for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter) { // Downcast to Dali::Window - Dali::Window window( dynamic_cast( *iter ) ); - if ( window ) + Dali::Window window(dynamic_cast(*iter)); + if(window) { - windows.push_back( window ); + windows.push_back(window); } } @@ -129,21 +180,21 @@ Dali::SceneHolderList Adaptor::GetSceneHolders() { Dali::SceneHolderList sceneHolderList; - for( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter ) + for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter) { - sceneHolderList.push_back( Dali::Integration::SceneHolder( *iter ) ); + sceneHolderList.push_back(Dali::Integration::SceneHolder(*iter)); } return sceneHolderList; } -Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor ) +Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow(Dali::Actor& actor) { - Dali::Integration::Scene scene = Dali::Integration::Scene::Get( actor ); + Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor); - for( auto window : mWindows ) + for(auto window : mWindows) { - if ( scene == window->GetScene() ) + if(scene == window->GetScene()) { return window; } @@ -152,39 +203,55 @@ Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor ) return nullptr; } -void Adaptor::AddWindow( Internal::Adaptor::SceneHolder* window ) +void Adaptor::AddWindow(Internal::Adaptor::SceneHolder* window) { - if ( window ) + if(window) { - mWindows.push_back( window ); + mWindows.push_back(window); - Dali::Integration::SceneHolder newWindow( window ); - mWindowCreatedSignal.Emit( newWindow ); + Dali::Integration::SceneHolder newWindow(window); + mWindowCreatedSignal.Emit(newWindow); } } -void Adaptor::RemoveWindow( Internal::Adaptor::SceneHolder* window ) +void Adaptor::RemoveWindow(Internal::Adaptor::SceneHolder* window) { - auto iter = std::find( mWindows.begin(), mWindows.end(), window ); - if( iter != mWindows.end() ) + auto iter = std::find(mWindows.begin(), mWindows.end(), window); + if(iter != mWindows.end()) { - mWindows.erase( iter ); + mWindows.erase(iter); } } -void Adaptor::RegisterProcessor( Integration::Processor& processor, bool postProcessor ) +void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor) { Integration::Core& core = mTestApplication->GetCore(); - core.RegisterProcessor( processor, postProcessor ); + tet_printf("Adaptor::RegisterProcessor : %s\n", processor.GetProcessorName().data()); + core.RegisterProcessor(processor, postProcessor); } -void Adaptor::UnregisterProcessor( Integration::Processor& processor, bool postProcessor ) +void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor) { Integration::Core& core = mTestApplication->GetCore(); - core.UnregisterProcessor( processor, postProcessor ); + tet_printf("Adaptor::UnregisterProcessor : %s\n", processor.GetProcessorName().data()); + core.UnregisterProcessor(processor, postProcessor); } -void Adaptor::SetApplication( Dali::TestApplication& testApplication ) +void Adaptor::RegisterProcessorOnce(Integration::Processor& processor, bool postProcessor) +{ + Integration::Core& core = mTestApplication->GetCore(); + tet_printf("Adaptor::RegisterProcessorOnce : %s\n", processor.GetProcessorName().data()); + core.RegisterProcessorOnce(processor, postProcessor); +} + +void Adaptor::UnregisterProcessorOnce(Integration::Processor& processor, bool postProcessor) +{ + Integration::Core& core = mTestApplication->GetCore(); + tet_printf("Adaptor::UnregisterProcessorOnce : %s\n", processor.GetProcessorName().data()); + core.UnregisterProcessorOnce(processor, postProcessor); +} + +void Adaptor::SetApplication(Dali::TestApplication& testApplication) { mTestApplication = &testApplication; } @@ -214,7 +281,7 @@ Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal() /////////////////////////////////////////////////////////////////////////////// Adaptor::Adaptor() -: mImpl( new Internal::Adaptor::Adaptor ) +: mImpl(new Internal::Adaptor::Adaptor) { } @@ -238,23 +305,24 @@ void Adaptor::Resume() void Adaptor::Stop() { + mImpl->Stop(); } -bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue ) +bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue) { - return mImpl->AddIdle( callback, hasReturnValue ); + return mImpl->AddIdle(callback, hasReturnValue); } -void Adaptor::RemoveIdle( CallbackBase* callback ) +void Adaptor::RemoveIdle(CallbackBase* callback) { - mImpl->RemoveIdle( callback ); + mImpl->RemoveIdle(callback); } -void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface ) +void Adaptor::ReplaceSurface(Window window, Dali::RenderSurfaceInterface& surface) { } -void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface ) +void Adaptor::ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface) { } @@ -294,7 +362,7 @@ Any Adaptor::GetNativeWindowHandle() return window; } -Any Adaptor::GetNativeWindowHandle( Actor actor ) +Any Adaptor::GetNativeWindowHandle(Actor actor) { return GetNativeWindowHandle(); } @@ -303,7 +371,7 @@ void Adaptor::ReleaseSurfaceLock() { } -void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) +void Adaptor::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender) { } @@ -314,7 +382,7 @@ Adaptor& Adaptor::Get() bool Adaptor::IsAvailable() { - return Internal::Adaptor::gAdaptor; + return Internal::Adaptor::gAdaptor && (!Internal::Adaptor::Adaptor::GetImpl(*Internal::Adaptor::gAdaptor).IsStopped()); } void Adaptor::NotifySceneCreated() @@ -325,15 +393,15 @@ void Adaptor::NotifyLanguageChanged() { } -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) { } @@ -358,24 +426,61 @@ public: } }; -LogFactory* gLogFactory = NULL; +LogFactory* gLogFactory = NULL; const LogFactoryInterface& Adaptor::GetLogFactory() { - if( gLogFactory == NULL ) + if(gLogFactory == NULL) { gLogFactory = new LogFactory; } return *gLogFactory; } -void Adaptor::RegisterProcessor( Integration::Processor& processor, bool postProcessor) +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::RegisterProcessor(Integration::Processor& processor, bool postProcessor) +{ + mImpl->RegisterProcessor(processor, postProcessor); +} + +void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor) +{ + mImpl->UnregisterProcessor(processor, postProcessor); +} + +void Adaptor::RegisterProcessorOnce(Integration::Processor& processor, bool postProcessor) { - mImpl->RegisterProcessor( processor, postProcessor ); + mImpl->RegisterProcessorOnce(processor, postProcessor); } -void Adaptor::UnregisterProcessor( Integration::Processor& processor, bool postProcessor) +void Adaptor::UnregisterProcessorOnce(Integration::Processor& processor, bool postProcessor) { - mImpl->UnregisterProcessor( processor, postProcessor ); + mImpl->UnregisterProcessorOnce(processor, postProcessor); } } // namespace Dali