Add SetInterval, Pause, and Resume APIs in Timer 95/183595/5
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 9 Jul 2018 02:03:35 +0000 (11:03 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 11 Sep 2018 10:18:16 +0000 (19:18 +0900)
- Added enabled to restart the timer to SetInterval
- Added to pause and resume the timer

Change-Id: Ie9334dc9f03fd8b660138c1bc4297e6cd87d06ea
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali-adaptor/utc-Dali-Timer.cpp
dali/internal/system/common/timer-impl-ecore.cpp
dali/internal/system/common/timer-impl.h
dali/internal/system/common/timer-interface.h
dali/public-api/adaptor-framework/timer.cpp
dali/public-api/adaptor-framework/timer.h

index bbd8555..6b2b283 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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.
@@ -268,6 +268,44 @@ int UtcDaliTimerSetInterval(void)
   END_TEST;
 }
 
+int UtcDaliTimerSetInterval02(void)
+{
+  AdaptorTestApplication application;
+
+  tet_printf("timer set interval 02 \n");
+  Timer timer = Timer::New(10);
+  timer.SetInterval(20);
+
+  DALI_TEST_CHECK( timer.GetInterval() == 20 );
+  DALI_TEST_CHECK( timer.IsRunning() == true );
+
+  timer.SetInterval(5000, false);
+
+  DALI_TEST_CHECK( timer.GetInterval() == 5000 );
+  DALI_TEST_CHECK( timer.IsRunning() == false );
+
+  END_TEST;
+}
+
+int UtcDaliTimerSetInterval03(void)
+{
+  AdaptorTestApplication application;
+
+  tet_printf("UtcDaliTimerSetInterval03 SetInterval and ensure timer restarts \n");
+  Timer timer = Timer::New(10);
+  timer.SetInterval(20);
+
+  DALI_TEST_CHECK( timer.GetInterval() == 20 );
+  DALI_TEST_CHECK( timer.IsRunning() == true );
+
+  timer.SetInterval(5000, true);
+
+  DALI_TEST_CHECK( timer.GetInterval() == 5000 );
+  DALI_TEST_CHECK( timer.IsRunning() == true );
+
+  END_TEST;
+}
+
 int UtcDaliTimerCopyConstructor(void)
 {
   AdaptorTestApplication application;
index 1c3e541..46ef603 100644 (file)
@@ -101,13 +101,39 @@ void Timer::Stop()
   ResetTimerData();
 }
 
-void Timer::SetInterval( unsigned int interval )
+void Timer::Pause()
+{
+  // Timer should be used in the event thread
+  DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+
+  if( mImpl->mId != NULL )
+  {
+    ecore_timer_freeze( mImpl->mId );
+  }
+}
+
+void Timer::Resume()
+{
+  // Timer should be used in the event thread
+  DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+
+  if( mImpl->mId != NULL )
+  {
+    ecore_timer_thaw( mImpl->mId );
+  }
+}
+
+void Timer::SetInterval( unsigned int interval, bool restart )
 {
   // stop existing timer
   Stop();
   mImpl->mInterval = interval;
-  // start new tick
-  Start();
+
+  if( restart )
+  {
+    // start new tick
+    Start();
+  }
 }
 
 unsigned int Timer::GetInterval() const
index a382d8f..17d8ca4 100644 (file)
@@ -70,9 +70,19 @@ public:
   virtual void Stop();
 
   /**
+   * @copydoc Dali::Timer::Pause()
+   */
+  virtual void Pause();
+
+  /**
+   * @copydoc Dali::Timer::Resume()
+   */
+  virtual void Resume();
+
+  /**
    * @copydoc Dali::Timer::SetInterval()
    */
-  virtual void SetInterval( unsigned int interval );
+  virtual void SetInterval( unsigned int interval, bool restart );
 
   /**
    * @copydoc Dali::Timer::GetInterval()
index f2b1462..a648b5a 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ADAPTOR_BASE_TIMER_INTERFACE_H__
 
 /*
- * Copyright (c) 2014 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.
@@ -42,9 +42,19 @@ public:
   virtual void Stop() = 0;
 
   /**
+   * @copydoc Dali::Timer::Pause()
+   */
+  virtual void Pause() = 0;
+
+  /**
+   * @copydoc Dali::Timer::Resume()
+   */
+  virtual void Resume() = 0;
+
+  /**
    * @copydoc Dali::Timer::SetInterval()
    */
-  virtual void SetInterval( unsigned int intervalInMilliseconds ) = 0;
+  virtual void SetInterval( unsigned int intervalInMilliseconds, bool restart ) = 0;
 
   /**
    * @copydoc Dali::Timer::GetInterval()
index 244aa26..ba98792 100644 (file)
@@ -69,9 +69,24 @@ void Timer::Stop()
   Internal::Adaptor::GetImplementation(*this).Stop();
 }
 
+void Timer::Pause()
+{
+  Internal::Adaptor::GetImplementation(*this).Pause();
+}
+
+void Timer::Resume()
+{
+  Internal::Adaptor::GetImplementation(*this).Resume();
+}
+
 void Timer::SetInterval( unsigned int interval )
 {
-  Internal::Adaptor::GetImplementation(*this).SetInterval( interval );
+  Internal::Adaptor::GetImplementation(*this).SetInterval( interval, true );
+}
+
+void Timer::SetInterval( unsigned int interval, bool restart )
+{
+  Internal::Adaptor::GetImplementation(*this).SetInterval( interval, restart );
 }
 
 unsigned int Timer::GetInterval() const
index 9e9beac..28481ba 100755 (executable)
@@ -132,6 +132,18 @@ public: // API
   void Stop();
 
   /**
+   * @brief Pauses timer.
+   * @SINCE_1_3.41
+   */
+  void Pause();
+
+  /**
+   * @brief Resumes timer.
+   * @SINCE_1_3.41
+   */
+  void Resume();
+
+  /**
    * @brief Sets a new interval on the timer and starts the timer.
    *
    * Cancels the previous timer.
@@ -141,6 +153,16 @@ public: // API
   void SetInterval( unsigned int milliSec );
 
   /**
+   * @brief Sets a new interval on the timer with option to restart the timer.
+   *
+   * Cancels the previous timer.
+   * @SINCE_1_3.41
+   * @param[in] milliSec Interval in milliseconds
+   * @param[in] restart Flag to set enabled to restart or not.
+   */
+  void SetInterval( unsigned int milliSec, bool restart );
+
+  /**
    * @brief Gets the interval of timer.
    *
    * @SINCE_1_0.0