/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
*
*/
-#include <iostream>
-#include <stdlib.h>
-#include <stdint.h>
-#include <dali/dali.h>
-#include <Ecore.h>
-#include <dali-test-suite-utils.h>
#include <adaptor-test-application.h>
+#include <dali-test-suite-utils.h>
+#include <dali/dali.h>
+#include <dali/internal/system/linux/dali-ecore.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <iostream>
using namespace Dali;
namespace
{
-bool ecore_timer_running = false;
-Ecore_Task_Cb timer_callback_func=NULL;
-const void* timer_callback_data=NULL;
-bool main_loop_can_run = false;
-intptr_t timerId = 0; // intptr_t has the same size as a pointer and is platform independent so this can be returned as a pointer in ecore_timer_add below without compilation warnings
-}// anon namespace
+bool ecore_timer_running = false;
+Ecore_Task_Cb timer_callback_func = NULL;
+const void* timer_callback_data = NULL;
+bool main_loop_can_run = false;
+intptr_t timerId = 0; // intptr_t has the same size as a pointer and is platform independent so this can be returned as a pointer in ecore_timer_add below without compilation warnings
+} // namespace
extern "C"
{
-Ecore_Timer* ecore_timer_add(double in,
- Ecore_Task_Cb func,
- const void *data)
-{
- ecore_timer_running = true;
- timer_callback_func = func;
- timer_callback_data = data;
- timerId+=8;
- return (Ecore_Timer*)timerId;
-}
-
-void* ecore_timer_del(Ecore_Timer *timer)
-{
- ecore_timer_running = false;
- timer_callback_func = NULL;
- return NULL;
-}
+ Ecore_Timer* ecore_timer_add(double in,
+ Ecore_Task_Cb func,
+ const void* data)
+ {
+ ecore_timer_running = true;
+ timer_callback_func = func;
+ timer_callback_data = data;
+ timerId += 8;
+ return (Ecore_Timer*)timerId;
+ }
+ void* ecore_timer_del(Ecore_Timer* timer)
+ {
+ ecore_timer_running = false;
+ timer_callback_func = NULL;
+ return NULL;
+ }
}
namespace
{
-
void test_ecore_main_loop_begin()
{
if(timer_callback_func != NULL)
{
main_loop_can_run = true;
- while( main_loop_can_run )
+ while(main_loop_can_run)
{
- if( ! timer_callback_func(const_cast<void*>(timer_callback_data)) )
+ if(!timer_callback_func(const_cast<void*>(timer_callback_data)))
break;
}
}
void test_ecore_main_loop_quit()
{
timer_callback_func = NULL;
- main_loop_can_run = false;
+ main_loop_can_run = false;
}
-
/**
* small class to test timer signal
*/
class TimerTestClass : public ConnectionTracker
{
public:
-
- TimerTestClass(bool repeat):mTimerCalled(false),mReturnContiune(repeat) {}
+ TimerTestClass(bool repeat)
+ : mTimerCalled(false),
+ mReturnContiune(repeat)
+ {
+ }
bool Tick()
{
}
bool mTimerCalled; // whether tick has been called or not
bool mReturnContiune; // whether to return true / false to continue
-
};
-} // anon namespace
-
+} // namespace
// Positive test case for a method
int UtcDaliTimerCreation(void)
tet_printf("timer creation \n");
Timer timer = Timer::New(300);
- DALI_TEST_CHECK( timer );
+ DALI_TEST_CHECK(timer);
- DALI_TEST_CHECK( timer.GetInterval() == 300);
+ DALI_TEST_CHECK(timer.GetInterval() == 300);
END_TEST;
}
tet_printf("unintialized timer start \n");
- Timer *timer = new Timer;
+ Timer* timer = new Timer;
DALI_TEST_CHECK(timer != NULL);
try
tet_printf("unintialized timer stop \n");
- Timer *timer = new Timer;
+ Timer* timer = new Timer;
DALI_TEST_CHECK(timer != NULL);
try
tet_printf("unintialized get interval \n");
- Timer *timer = new Timer;
+ Timer* timer = new Timer;
DALI_TEST_CHECK(timer != NULL);
try
tet_printf("unintialized set interval \n");
- Timer *timer = new Timer;
+ Timer* timer = new Timer;
DALI_TEST_CHECK(timer != NULL);
try
tet_printf("unintialized is running \n");
- Timer *timer = new Timer;
+ Timer* timer = new Timer;
DALI_TEST_CHECK(timer != NULL);
try
END_TEST;
}
-
int UtcDaliTimerUnitializedSignalTick(void)
{
AdaptorTestApplication application;
tet_printf("unintialized SignalTick \n");
- Timer *timer = new Timer;
+ Timer* timer = new Timer;
DALI_TEST_CHECK(timer != NULL);
try
{
- TimerTestClass testClass(true);// = new TimerTestClass(true);
+ TimerTestClass testClass(true); // = new TimerTestClass(true);
timer->TickSignal().Connect(&testClass, &TimerTestClass::Tick);
}
tet_printf("timer set interval \n");
Timer timer = Timer::New(10);
- DALI_TEST_CHECK( timer.GetInterval() == 10);
+ DALI_TEST_CHECK(timer.GetInterval() == 10);
timer.SetInterval(5000);
- DALI_TEST_CHECK( timer.GetInterval() == 5000);
+ DALI_TEST_CHECK(timer.GetInterval() == 5000);
+
+ 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;
}
tet_printf("timer copy constructor \n");
Timer timer = Timer::New(10);
- Timer anotherTimer( timer );
+ Timer anotherTimer(timer);
- DALI_TEST_CHECK( anotherTimer.GetInterval() == 10);
+ DALI_TEST_CHECK(anotherTimer.GetInterval() == 10);
END_TEST;
}
Timer timer = Timer::New(10);
- DALI_TEST_CHECK( timer );
+ DALI_TEST_CHECK(timer);
Timer anotherTimer = Timer::New(40);
DALI_TEST_CHECK(anotherTimer.GetInterval() == 40);
- tet_printf("timer 1 interval %d, \n",anotherTimer.GetInterval());
- tet_printf("timer 2 interval %d, \n",timer.GetInterval());
+ tet_printf("timer 1 interval %d, \n", anotherTimer.GetInterval());
+ tet_printf("timer 2 interval %d, \n", timer.GetInterval());
DALI_TEST_CHECK(timer != anotherTimer);
DALI_TEST_CHECK(timer == anotherTimer);
- tet_printf("timer 1 interval %d, \n",timer.GetInterval());
- tet_printf("timer 2 interval %d, \n",anotherTimer.GetInterval());
+ tet_printf("timer 1 interval %d, \n", timer.GetInterval());
+ tet_printf("timer 2 interval %d, \n", anotherTimer.GetInterval());
+
+ DALI_TEST_CHECK(timer.GetInterval() == 40);
+
+ END_TEST;
+}
+
+int UtcDaliTimerMoveConstructor(void)
+{
+ AdaptorTestApplication application;
+ Timer timer = Timer::New(40);
+ DALI_TEST_CHECK(timer);
+ DALI_TEST_EQUALS(1, timer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
DALI_TEST_CHECK(timer.GetInterval() == 40);
+ Timer moved = std::move(timer);
+ DALI_TEST_CHECK(moved);
+ DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ DALI_TEST_CHECK(moved.GetInterval() == 40);
+ DALI_TEST_CHECK(!timer);
+
+ END_TEST;
+}
+
+int UtcDaliTimerMoveAssignmentr(void)
+{
+ AdaptorTestApplication application;
+
+ Timer timer = Timer::New(40);
+ DALI_TEST_CHECK(timer);
+ DALI_TEST_EQUALS(1, timer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ DALI_TEST_CHECK(timer.GetInterval() == 40);
+
+ Timer moved;
+ moved = std::move(timer);
+ DALI_TEST_CHECK(moved);
+ DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+ DALI_TEST_CHECK(moved.GetInterval() == 40);
+ DALI_TEST_CHECK(!timer);
+
END_TEST;
}
timer.Start();
- DALI_TEST_CHECK( timer.IsRunning() );
+ DALI_TEST_CHECK(timer.IsRunning());
timer.Stop();
- DALI_TEST_CHECK( timer.IsRunning() == false );
+ DALI_TEST_CHECK(timer.IsRunning() == false);
END_TEST;
}
tet_printf("timer call back\n");
- Timer timer = Timer::New(100);
+ Timer timer = Timer::New(100);
TimerTestClass testClass(true);
timer.TickSignal().Connect(&testClass, &TimerTestClass::Tick);
test_ecore_main_loop_begin();
- DALI_TEST_CHECK( testClass.mTimerCalled );
+ DALI_TEST_CHECK(testClass.mTimerCalled);
END_TEST;
}
{
AdaptorTestApplication application;
- Timer timer = Timer::New(100);
+ Timer timer = Timer::New(100);
TimerTestClass testClass(false);
timer.TickSignal().Connect(&testClass, &TimerTestClass::Tick);
test_ecore_main_loop_begin();
- DALI_TEST_CHECK( testClass.mTimerCalled );
+ DALI_TEST_CHECK(testClass.mTimerCalled);
END_TEST;
}
AdaptorTestApplication application;
Timer timer = Timer::New(100);
- Timer cast = Timer::DownCast( timer );
+ Timer cast = Timer::DownCast(timer);
- DALI_TEST_CHECK( cast );
+ DALI_TEST_CHECK(cast);
END_TEST;
}
AdaptorTestApplication application;
Timer timer;
- Timer cast = Timer::DownCast( timer );
+ Timer cast = Timer::DownCast(timer);
- DALI_TEST_CHECK( ! cast );
+ DALI_TEST_CHECK(!cast);
END_TEST;
}