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-timer.cpp;h=f9c89dad59fc6e6603c60a6928e21675efd9e47e;hp=2f1ce14ab3032c492b1529101ae577d550a6af0f;hb=6154e1e69b7cd3afb49213c4f6f5730dd3df074e;hpb=8ad943a28e16767f5fe2fc92d18b38f8808bdc99 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp index 2f1ce14..f9c89da 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -18,7 +18,7 @@ #include "toolkit-timer.h" // INTERNAL INCLUDES -#include +#include #include #include @@ -35,6 +35,8 @@ class Timer; typedef IntrusivePtr TimerPtr; Dali::Timer::TimerSignalType gTickSignal; +int gTimerCount = 0; +bool gKeepTimersRunning = false; /** * Implementation of the timer @@ -69,6 +71,7 @@ private: // Implementation private: // Data unsigned int mInterval; + bool mRunning; }; inline Timer& GetImplementation(Dali::Timer& timer) @@ -96,20 +99,25 @@ TimerPtr Timer::New( unsigned int milliSec ) } Timer::Timer( unsigned int milliSec ) -: mInterval( milliSec ) +: mInterval( milliSec ), + mRunning( false ) { + ++gTimerCount; } Timer::~Timer() { + --gTimerCount; } void Timer::Start() { + mRunning = true; } void Timer::Stop() { + mRunning = false; } void Timer::SetInterval( unsigned int interval ) @@ -124,7 +132,7 @@ unsigned int Timer::GetInterval() const bool Timer::IsRunning() const { - return true; + return mRunning; } bool Timer::Tick() @@ -141,10 +149,13 @@ Dali::Timer::TimerSignalType& Timer::TickSignal() void Timer::MockEmitSignal() { - gTickSignal.Emit(); + if( gTimerCount > 1 ) + { + // Only emit the signal if we have more than just the timer created in the test function + gTickSignal.Emit(); + } } - } // namespace Adaptor } // namespace Internal @@ -186,6 +197,7 @@ Timer::~Timer() void Timer::Start() { Internal::Adaptor::GetImplementation( *this ).Start(); + Dali::Internal::Adaptor::gKeepTimersRunning = true; } void Timer::Stop() @@ -227,3 +239,24 @@ void Timer::MockEmitSignal() } // namespace Dali + +namespace Test +{ + +int GetTimerCount() +{ + return Dali::Internal::Adaptor::gTimerCount; +} + +void EmitGlobalTimerSignal() +{ + // @todo Multiplex timers properly. + Dali::Internal::Adaptor::gKeepTimersRunning = Dali::Internal::Adaptor::gTickSignal.Emit(); +} + +bool AreTimersRunning() +{ + return Dali::Internal::Adaptor::gKeepTimersRunning; +} + +}