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=63bacde7d60cc24da606067215dcf54860ea1bd3;hp=7acde34af015c7344fdf900f1808fa0d9fdfc015;hb=0e8dfa9c961af84b18edf2e3307840b0d94fb430;hpb=c35f47a46398a7d71180285e6e52a64243af0a6d 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 7acde34..63bacde 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 @@ -15,71 +15,165 @@ * */ -// CLASS HEADER +#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 +{ + +/////////////////////////////////////////////////////////////////////////////// +// +// 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 { -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::RenderSurfaceInterface& Adaptor::GetSurface() +Adaptor::Adaptor() { - Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast ( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) ); - 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 ) +{ + if ( window ) + { + mWindows.push_back( window ); + mWindowCreatedSignal.Emit( 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( Window window, const Dali::RenderSurfaceInterface& 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( Window window, const Dali::RenderSurfaceInterface& 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() +{ + return mWindows; +} + +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() @@ -100,53 +194,45 @@ void Adaptor::Stop() 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(); - - 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; - } - } - } + mImpl->RemoveIdle( callback ); } 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 Internal::Adaptor::Adaptor::GetSurface(); + return mImpl->GetSurface(); +} + +Dali::WindowContainer Adaptor::GetWindows() const +{ + return mImpl->GetWindows(); } Any Adaptor::GetNativeWindowHandle() @@ -163,10 +249,6 @@ void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) { } -void Adaptor::SetUseHardwareVSync(bool useHardware) -{ -} - Adaptor& Adaptor::Get() { return Internal::Adaptor::Adaptor::Get(); @@ -174,7 +256,7 @@ Adaptor& Adaptor::Get() bool Adaptor::IsAvailable() { - return Internal::Adaptor::Adaptor::mAvailable; + return Internal::Adaptor::gAdaptor; } void Adaptor::NotifySceneCreated() @@ -201,24 +283,6 @@ void Adaptor::SceneCreated() { } -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() { if( gLogFactory == NULL ) @@ -228,9 +292,4 @@ const LogFactoryInterface& Adaptor::GetLogFactory() return *gLogFactory; } -Adaptor::Adaptor() -: mImpl( NULL ) -{ -} - } // namespace Dali