Add an assertion for thread-satfy check to Timer 87/148187/5
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 7 Sep 2017 04:55:34 +0000 (13:55 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 13 Sep 2017 06:22:13 +0000 (15:22 +0900)
Change-Id: Ib42bd9f3312b2140d379491a66b29a47182a5f90

adaptors/common/event-loop/ecore/ecore-timer-impl.cpp
automated-tests/src/dali-adaptor-internal/CMakeLists.txt
automated-tests/src/dali-adaptor-internal/utc-Dali-TiltSensor.cpp
automated-tests/src/dali-adaptor/CMakeLists.txt
automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp [new file with mode: 0644]
automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.h [new file with mode: 0644]
automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-application.h [new file with mode: 0644]
automated-tests/src/dali-adaptor/utc-Dali-Timer.cpp
automated-tests/src/dali-platform-abstraction/CMakeLists.txt

index 681ca16beda08cd00cbf6cbaaa938e75b1322198..d392001775f7529ca08330eb065b4b166fa57a0e 100644 (file)
 // CLASS HEADER
 #include "timer-impl.h"
 
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+
 // EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
 // Ecore is littered with C style cast
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wold-style-cast"
@@ -82,6 +87,9 @@ Timer::~Timer()
 
 void Timer::Start()
 {
+  // Timer should be used in the event thread
+  DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+
   if(mImpl->mId != NULL)
   {
     Stop();
@@ -91,6 +99,9 @@ void Timer::Start()
 
 void Timer::Stop()
 {
+  // Timer should be used in the event thread
+  DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+
   if (mImpl->mId != NULL)
   {
     ecore_timer_del(mImpl->mId);
index 2292b644254d9750a13cc3bb8c7dd9d660d305f8..4d137b8ca659a80f5194c9d1b059b6e93c7f490c 100644 (file)
@@ -31,6 +31,7 @@ LIST(APPEND TC_SOURCES
     ../dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
     ../dali-adaptor/dali-test-suite-utils/test-render-controller.cpp
     ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
+    ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
 )
 
 PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
index 8f66578bf395722e79c49f1392f689888dd8be8e..81ee574bfb8a38757a9fc9414ff7a75d46d2552b 100644 (file)
@@ -22,6 +22,7 @@
 #include <Ecore.h>
 #include <dali/dali.h>
 #include <dali-test-suite-utils.h>
+#include <adaptor-test-application.h>
 #include <tilt-sensor-impl.h>
 
 using namespace Dali;
@@ -112,7 +113,7 @@ void tilt_sensor_cleanup(void)
 
 int UtcDaliTiltSensorStart(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorStart");
 
@@ -127,7 +128,7 @@ int UtcDaliTiltSensorStart(void)
 
 int UtcDaliTiltSensorStop(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorStop");
 
@@ -144,7 +145,7 @@ int UtcDaliTiltSensorStop(void)
 
 int UtcDaliTiltSensorIsStarted(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorIsStarted");
 
@@ -158,7 +159,7 @@ int UtcDaliTiltSensorIsStarted(void)
 
 int UtcDaliTiltSensorGetRoll(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorGetRoll");
 
@@ -172,7 +173,7 @@ int UtcDaliTiltSensorGetRoll(void)
 
 int UtcDaliTiltSensorGetPitch(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorGetPitch");
 
@@ -186,7 +187,7 @@ int UtcDaliTiltSensorGetPitch(void)
 
 int UtcDaliTiltSensorGetRotation(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorGetRotation");
 
@@ -208,7 +209,7 @@ int UtcDaliTiltSensorGetRotation(void)
 
 int UtcDaliTiltSensorSignalTilted(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorSignalTilted");
 
@@ -225,7 +226,7 @@ int UtcDaliTiltSensorSignalTilted(void)
 
 int UtcDaliTiltSensorSetUpdateFrequency(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorSetUpdateFrequency");
 
@@ -243,7 +244,7 @@ int UtcDaliTiltSensorSetUpdateFrequency(void)
 
 int UtcDaliTiltSensorSetRotationThreshold01(void)
 {
-  TestApplication application;
+  AdaptorTestApplication application;
 
   tet_infoline("UtcDaliTiltSensorSetRotationThreshold01");
 
index ee64cb232e719d1d012125722f4e9b6bce60ccec..41cc8862bf43110002ac18032bcc5f13573c276f 100644 (file)
@@ -34,6 +34,7 @@ LIST(APPEND TC_SOURCES
     dali-test-suite-utils/test-platform-abstraction.cpp
     dali-test-suite-utils/test-render-controller.cpp
     dali-test-suite-utils/test-trace-call-stack.cpp
+    dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
 )
 
 PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
new file mode 100644 (file)
index 0000000..5b3847a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "adaptor-test-adaptor-impl.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+bool Adaptor::mAvailable = false;
+
+bool Adaptor::IsAvailable()
+{
+  return mAvailable;
+}
+
+void Adaptor::SetAvailable()
+{
+  mAvailable = true;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.h
new file mode 100644 (file)
index 0000000..38a8e77
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef __DALI_ADAPTOR_TEST_ADAPTOR_IMPL_H__
+#define __DALI_ADAPTOR_TEST_ADAPTOR_IMPL_H__
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class Adaptor
+{
+public:
+  static bool IsAvailable();
+  static void SetAvailable();
+
+  Adaptor() {}
+  ~Adaptor() {}
+
+public:
+  static bool mAvailable;
+};
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
+
+#endif  // __DALI_ADAPTOR_TEST_ADAPTOR_IMPL_H__
diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-application.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/adaptor-test-application.h
new file mode 100644 (file)
index 0000000..270ab57
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __DALI_ADAPTOR_TEST_APPLICATION_H__
+#define __DALI_ADAPTOR_TEST_APPLICATION_H__
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include "test-application.h"
+#include "adaptor-test-adaptor-impl.h"
+
+namespace Dali
+{
+
+/**
+ * Adds some functionality on top of TestApplication that is required by the Adaptor.
+ */
+class AdaptorTestApplication : public TestApplication
+{
+public:
+
+  AdaptorTestApplication( size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
+                          size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
+                          float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
+                          float  verticalDpi   = DEFAULT_VERTICAL_DPI )
+  : TestApplication( false, surfaceWidth, surfaceHeight, horizontalDpi, verticalDpi )
+  {
+    Initialize();
+
+    Internal::Adaptor::Adaptor::SetAvailable();
+  }
+
+  ~AdaptorTestApplication()
+  {
+  }
+};
+
+} // namespace Dali
+
+#endif // __DALI_ADAPTOR_TEST_APPLICATION_H__
index ecd4638f2025a62c53d2cd7ceef07316669ba4f6..bbd85553c953b10ee70ea9f69152a00cdec0f632 100644 (file)
@@ -21,6 +21,7 @@
 #include <dali/dali.h>
 #include <Ecore.h>
 #include <dali-test-suite-utils.h>
+#include <adaptor-test-application.h>
 
 using namespace Dali;
 
@@ -116,7 +117,8 @@ public:
 // Positive test case for a method
 int UtcDaliTimerCreation(void)
 {
- // TestApplication application;
+  AdaptorTestApplication application;
+
   tet_printf("timer creation \n");
   Timer timer = Timer::New(300);
 
@@ -129,6 +131,8 @@ int UtcDaliTimerCreation(void)
 
 int UtcDaliTimerUnitializedStart(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("unintialized timer start \n");
 
   Timer *timer = new Timer;
@@ -147,6 +151,8 @@ int UtcDaliTimerUnitializedStart(void)
 
 int UtcDaliTimerUnitializedStop(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("unintialized timer stop \n");
 
   Timer *timer = new Timer;
@@ -165,6 +171,8 @@ int UtcDaliTimerUnitializedStop(void)
 
 int UtcDaliTimerUnitializedGetInterval(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("unintialized get interval \n");
 
   Timer *timer = new Timer;
@@ -183,6 +191,8 @@ int UtcDaliTimerUnitializedGetInterval(void)
 
 int UtcDaliTimerUnitializedSetInterval(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("unintialized set interval \n");
 
   Timer *timer = new Timer;
@@ -201,6 +211,8 @@ int UtcDaliTimerUnitializedSetInterval(void)
 
 int UtcDaliTimerUnitializedIsRunning(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("unintialized is running \n");
 
   Timer *timer = new Timer;
@@ -220,6 +232,8 @@ int UtcDaliTimerUnitializedIsRunning(void)
 
 int UtcDaliTimerUnitializedSignalTick(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("unintialized SignalTick \n");
 
   Timer *timer = new Timer;
@@ -240,6 +254,8 @@ int UtcDaliTimerUnitializedSignalTick(void)
 
 int UtcDaliTimerSetInterval(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("timer set interval \n");
   Timer timer = Timer::New(10);
 
@@ -254,6 +270,8 @@ int UtcDaliTimerSetInterval(void)
 
 int UtcDaliTimerCopyConstructor(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("timer copy constructor \n");
   Timer timer = Timer::New(10);
 
@@ -265,6 +283,8 @@ int UtcDaliTimerCopyConstructor(void)
 
 int UtcDaliTimerAssignmentOperator(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("assignmnet constructor \n");
 
   Timer timer = Timer::New(10);
@@ -294,6 +314,8 @@ int UtcDaliTimerAssignmentOperator(void)
 
 int UtcDaliTimerIsRunning(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("timer is running \n");
 
   Timer timer = Timer::New(100);
@@ -311,6 +333,8 @@ int UtcDaliTimerIsRunning(void)
 
 int UtcDaliTimerSignalTickContinue(void)
 {
+  AdaptorTestApplication application;
+
   tet_printf("timer call back\n");
 
   Timer timer = Timer::New(100);
@@ -329,6 +353,8 @@ int UtcDaliTimerSignalTickContinue(void)
 
 int UtcDaliTimerSignalTickStop(void)
 {
+  AdaptorTestApplication application;
+
   Timer timer = Timer::New(100);
   TimerTestClass testClass(false);
 
@@ -345,6 +371,8 @@ int UtcDaliTimerSignalTickStop(void)
 
 int UtcDaliTimerReset(void)
 {
+  AdaptorTestApplication application;
+
   Timer timer = Timer::New(100);
 
   DALI_TEST_CHECK(timer);
@@ -358,6 +386,8 @@ int UtcDaliTimerReset(void)
 
 int UtcDaliTimerDownCastP(void)
 {
+  AdaptorTestApplication application;
+
   Timer timer = Timer::New(100);
   Timer cast = Timer::DownCast( timer );
 
@@ -368,6 +398,8 @@ int UtcDaliTimerDownCastP(void)
 
 int UtcDaliTimerDownCastN(void)
 {
+  AdaptorTestApplication application;
+
   Timer timer;
   Timer cast = Timer::DownCast( timer );
 
index 3705a125a914f3d347901c62a0e7383ebda280a8..0467e1e1966bcc2539806c907554beecee3ffda7 100644 (file)
@@ -22,6 +22,7 @@ LIST(APPEND TC_SOURCES
     ../dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
     ../dali-adaptor/dali-test-suite-utils/test-render-controller.cpp
     ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
+    ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
     tct-dali-platform-abstraction-core.cpp
     utc-image-loading-common.cpp
 )