From fce4aea5af5427774774b07822dad714a3c8db86 Mon Sep 17 00:00:00 2001 From: suhyung Eom Date: Tue, 5 Jul 2016 14:32:07 +0900 Subject: [PATCH] [UTC][DALi-Adaptor][ACR-685]Added test cases for WatchApplication class Signed-off-by: suhyung Eom Change-Id: I2719142ff3cf23f216625654b43a8bfb15fbbe39 --- packaging/utc/core-dali-adaptor-tests.spec | 4 + src/utc/dali-adaptor/CMakeLists.txt | 27 +- .../dali-adaptor/application/utc-dali-watch.cpp | 336 +++++++++++++++++++++ .../dali-adaptor/tct-dali-adaptor-core_wearable.h | 23 ++ 4 files changed, 387 insertions(+), 3 deletions(-) mode change 100755 => 100644 packaging/utc/core-dali-adaptor-tests.spec mode change 100755 => 100644 src/utc/dali-adaptor/CMakeLists.txt create mode 100644 src/utc/dali-adaptor/application/utc-dali-watch.cpp mode change 100755 => 100644 src/utc/dali-adaptor/tct-dali-adaptor-core_wearable.h diff --git a/packaging/utc/core-dali-adaptor-tests.spec b/packaging/utc/core-dali-adaptor-tests.spec old mode 100755 new mode 100644 index 20b6d1e..d65ec61 --- a/packaging/utc/core-dali-adaptor-tests.spec +++ b/packaging/utc/core-dali-adaptor-tests.spec @@ -24,6 +24,10 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(storage) +%if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 +BuildRequires: pkgconfig(capi-appfw-watch-application) +BuildRequires: pkgconfig(appcore-watch) +%endif %description Core API unit TC (%{name}) diff --git a/src/utc/dali-adaptor/CMakeLists.txt b/src/utc/dali-adaptor/CMakeLists.txt old mode 100755 new mode 100644 index e640a71..b626664 --- a/src/utc/dali-adaptor/CMakeLists.txt +++ b/src/utc/dali-adaptor/CMakeLists.txt @@ -19,10 +19,10 @@ SET(TC_SOURCES application/utc-dali-application-common.cpp ) -LIST(APPEND TC_SOURCES - ../../common/dali-common.cpp +IF(DEFINED WEARABLE) +SET(TC_SOURCES ${TC_SOURCES} + application/utc-dali-watch.cpp ) - PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED ${CAPI_LIB} glib-2.0 @@ -35,6 +35,27 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED bundle dlog elementary + capi-appfw-watch-application + appcore-watch +) +ELSE() +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + ${CAPI_LIB} + glib-2.0 + capi-appfw-application + capi-system-info + dali-core + dali-adaptor + dali-toolkit + storage + bundle + dlog + elementary +) +ENDIF() + +LIST(APPEND TC_SOURCES + ../../common/dali-common.cpp ) INCLUDE_DIRECTORIES( diff --git a/src/utc/dali-adaptor/application/utc-dali-watch.cpp b/src/utc/dali-adaptor/application/utc-dali-watch.cpp new file mode 100644 index 0000000..4cf83f8 --- /dev/null +++ b/src/utc/dali-adaptor/application/utc-dali-watch.cpp @@ -0,0 +1,336 @@ +#include "utc-dali-application-common.h" +#include "public-api/dali-wearable.h" + +extern int gArgc; +extern char ** gArgv; +extern int test_return_value; + +/** + * @function utc_dali_watchapplication_startup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_dali_watchapplication_startup(void) +{ + test_return_value=0; +} + +/** + * @function utc_dali_watchapplication_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_dali_watchapplication_cleanup(void) +{ +} + +void WatchApplicationNew01(WatchApplication& application); +void WatchApplicationNew02(WatchApplication& application); +void WatchApplicationNew03(WatchApplication& application); +void WatchApplicationCopyAndAssignment(WatchApplication& application); +void WatchApplicationTimeTickSignalP(WatchApplication& application); +void WatchApplicationTimeTickSignalN(void); +void WatchApplicationAmbientTickSignalP(WatchApplication& application); +void WatchApplicationAmbientTickSignalN(void); +void WatchApplicationAmbientChangedSignalP(WatchApplication& application); +void WatchApplicationAmbientChangedSignalN(void); + + +namespace +{ + enum TEST_CASES_LIST_WATCH + { + WATCH_NEW_2, + WATCH_NEW_3, + WATCH_COPY_AND_ASSIGNMENT, + WATCH_TIMETICK_SIGNAL_P, + WATCH_TIMETICK_SIGNAL_N, + WATCH_AMBIENT_TIMETICK_SIGNAL_P, + WATCH_AMBIENT_TIMETICK_SIGNAL_N, + WATCH_AMBIENT_CHANGED_SIGNAL_P, + WATCH_AMBIENT_CHANGED_SIGNAL_N + }; + + class Watch_TestApp : public ConnectionTracker + { + public: + Watch_TestApp( WatchApplication& app, int test_case = WATCH_NEW_2 ) + : initCalled( false ), + mApplication( app ), + mTestCase( test_case ) + { + mApplication.InitSignal().Connect( this, &Watch_TestApp::Create ); + } + + private: + void Create(Application& app) + { + initCalled = true; + + mTimer = Timer::New( 1000 ); + mTimer.TickSignal().Connect( this, &Watch_TestApp::Tick ); + mTimer.Start(); + + ExcuteTest(); + Quit(); + } + + void ExcuteTest() + { + switch (mTestCase) + { + case WATCH_NEW_2: + WatchApplicationNew02(mApplication); + break; + case WATCH_NEW_3: + WatchApplicationNew03(mApplication); + break; + case WATCH_COPY_AND_ASSIGNMENT: + WatchApplicationCopyAndAssignment(mApplication); + break; + case WATCH_TIMETICK_SIGNAL_P: + WatchApplicationTimeTickSignalP(mApplication); + break; + case WATCH_TIMETICK_SIGNAL_N: + WatchApplicationTimeTickSignalN(); + break; + case WATCH_AMBIENT_TIMETICK_SIGNAL_P: + WatchApplicationAmbientTickSignalP(mApplication); + break; + case WATCH_AMBIENT_TIMETICK_SIGNAL_N: + WatchApplicationAmbientTickSignalN(); + break; + case WATCH_AMBIENT_CHANGED_SIGNAL_P: + WatchApplicationAmbientChangedSignalP(mApplication); + break; + case WATCH_AMBIENT_CHANGED_SIGNAL_N: + WatchApplicationAmbientChangedSignalN(); + break; + } + } + + void Quit() + { + mApplication.Quit(); + } + + bool Tick() + { + mTimer.Stop(); + mApplication.Quit(); + return true; + } + + // Data + bool initCalled; + WatchApplication& mApplication; + int mTestCase; + + Timer mTimer; + }; + +} // unnamed namespace + + +void WatchTimeSignalCallback( Application& app, const WatchTime& time) +{ +} + +void WatchChangedSignalCallback( Application& app, bool ambient) +{ +} + +void WatchApplicationNew01(WatchApplication& application) +{ + DALI_CHECK_FAIL(!application, "Application::New() has failed." ); + + DaliLog::PrintPass(); +} + +void WatchApplicationNew02(WatchApplication& application) +{ + DALI_CHECK_FAIL(!application, "Application::New() has failed." ); + + DaliLog::PrintPass(); +} + +void WatchApplicationNew03(WatchApplication& application) +{ + DALI_CHECK_FAIL(!application, "Application::New() has failed." ); + + DaliLog::PrintPass(); +} + +void WatchApplicationCopyAndAssignment(WatchApplication& application) +{ + WatchApplication copy( application ); + + DALI_CHECK_FAIL( copy != application,"WatchApplication::CopyAndAssignment is failing"); + + WatchApplication assigned; + DALI_CHECK_FAIL( assigned,"WatchApplication::CopyAndAssignment is failing"); + + assigned = application; + DALI_CHECK_FAIL( copy != assigned,"WatchApplication::CopyAndAssignment is failing"); + + DaliLog::PrintPass(); +} + +void WatchApplicationTimeTickSignalP(WatchApplication& application) +{ + application.TimeTickSignal().Connect( &WatchTimeSignalCallback ); + + DALI_CHECK_FAIL(!application,"WatchApplication::TimeTickSignalP is failing"); + + DaliLog::PrintPass(); +} + +void WatchApplicationTimeTickSignalN() +{ + WatchApplication application; + + try + { + application.TimeTickSignal().Connect( &WatchTimeSignalCallback ); + DALI_CHECK_FAIL(true,"WatchApplication::TimeTickSignalN is failing"); + } + catch( ... ) + { + DALI_CHECK_FAIL(false,"WatchApplication::TimeTickSignalN is failing"); + } + + DaliLog::PrintPass(); +} + +void WatchApplicationAmbientTickSignalP(WatchApplication& application) +{ + application.AmbientTickSignal().Connect( &WatchTimeSignalCallback ); + DALI_CHECK_FAIL(!application,"WatchApplication::AmbientTimeTickSignalP is failing"); + + DaliLog::PrintPass(); +} + +void WatchApplicationAmbientTickSignalN() +{ + WatchApplication application; + + try + { + application.AmbientTickSignal().Connect( &WatchTimeSignalCallback ); + DALI_CHECK_FAIL(true,"WatchApplication::AmbientTimeTickSignalN is failing"); + } + catch( ... ) + { + DALI_CHECK_FAIL(false,"WatchApplication::AmbientTimeTickSignalN is failing"); + } + + DaliLog::PrintPass(); +} + +void WatchApplicationAmbientChangedSignalP(WatchApplication& application) +{ + application.AmbientChangedSignal().Connect( &WatchChangedSignalCallback ); + DALI_CHECK_FAIL(!application,"WatchApplication::AmbientChangedSignalP is failing"); + + DaliLog::PrintPass(); +} + +void WatchApplicationAmbientChangedSignalN() +{ + WatchApplication application; + + try + { + application.AmbientChangedSignal().Connect( &WatchChangedSignalCallback ); + DALI_CHECK_FAIL(true,"WatchApplication::AmbientChangedSignalN is failing"); + } + catch( ... ) + { + DALI_CHECK_FAIL(false,"WatchApplication::AmbientChangedSignalN is failing"); + } + + DaliLog::PrintPass(); +} + +int UtcDaliWatchApplicationTest(int testMode) +{ + DaliLog::PrintExecStarted(SUITE_NAME, __FUNCTION__); + + WatchApplication application = WatchApplication::New( &gArgc, &gArgv ); + CHECK_GL; + Watch_TestApp testApp( application, testMode); + application.MainLoop(); + return test_return_value; +} + +int UtcDaliWatchApplicationNew01(void) +{ + DaliLog::PrintExecStarted(SUITE_NAME, __FUNCTION__); + + WatchApplication application = WatchApplication::New(); + CHECK_GL; + Watch_TestApp testApp( application ); + + WatchApplicationNew01( application ); + return test_return_value; +} + +int UtcDaliWatchApplicationNew02(void) +{ + DaliLog::PrintExecStarted(SUITE_NAME, __FUNCTION__); + + WatchApplication application = WatchApplication::New( &gArgc, &gArgv ); + CHECK_GL; + Watch_TestApp testApp( application, WATCH_NEW_2); + application.MainLoop(); + return test_return_value; +} + +int UtcDaliWatchApplicationNew03(void) +{ + DaliLog::PrintExecStarted(SUITE_NAME, __FUNCTION__); + + WatchApplication application = WatchApplication::New( &gArgc, &gArgv, "stylesheet" ); + CHECK_GL; + Watch_TestApp testApp( application, WATCH_NEW_3); + application.MainLoop(); + return test_return_value; +} + +int UtcDaliWatchApplicationCopyAndAssignment(void) +{ + return UtcDaliWatchApplicationTest(WATCH_COPY_AND_ASSIGNMENT); +} + +int UtcDaliWatchApplicationTimeTickSignalP(void) +{ + return UtcDaliWatchApplicationTest(WATCH_TIMETICK_SIGNAL_P); +} + +int UtcDaliWatchApplicationTimeTickSignalN(void) +{ + return UtcDaliWatchApplicationTest(WATCH_TIMETICK_SIGNAL_N); +} + +int UtcDaliWatchApplicationAmbientTickSignalP(void) +{ + return UtcDaliWatchApplicationTest(WATCH_AMBIENT_TIMETICK_SIGNAL_P); +} + +int UtcDaliWatchApplicationAmbientTickSignalN(void) +{ + return UtcDaliWatchApplicationTest(WATCH_AMBIENT_TIMETICK_SIGNAL_N); +} + +int UtcDaliWatchApplicationAmbientChangedSignalP(void) +{ + return UtcDaliWatchApplicationTest(WATCH_AMBIENT_CHANGED_SIGNAL_P); +} + +int UtcDaliWatchApplicationAmbientChangedSignalN(void) +{ + return UtcDaliWatchApplicationTest(WATCH_AMBIENT_CHANGED_SIGNAL_N); +} + diff --git a/src/utc/dali-adaptor/tct-dali-adaptor-core_wearable.h b/src/utc/dali-adaptor/tct-dali-adaptor-core_wearable.h old mode 100755 new mode 100644 index 7f28d5a..2d076ce --- a/src/utc/dali-adaptor/tct-dali-adaptor-core_wearable.h +++ b/src/utc/dali-adaptor/tct-dali-adaptor-core_wearable.h @@ -31,6 +31,8 @@ extern void utc_Dali_TtsPlayer_startup(void); extern void utc_Dali_TtsPlayer_cleanup(void); extern void utc_Dali_Application_startup(void); extern void utc_Dali_Application_cleanup(void); +extern void utc_dali_watchapplication_startup(void); +extern void utc_dali_watchapplication_cleanup(void); extern int UtcDaliTimerConstructorP(void); extern int UtcDaliTimerDowncastP(void); @@ -134,6 +136,17 @@ extern int UtcDaliApplicationMainLoopN(void); extern int UtcDaliApplicationConstructorP(void); extern int UtcDaliApplicationCopyConstructorP(void); +extern int UtcDaliWatchApplicationNew01(void); +extern int UtcDaliWatchApplicationNew02(void); +extern int UtcDaliWatchApplicationNew03(void); +extern int UtcDaliWatchApplicationCopyAndAssignment(void); +extern int UtcDaliWatchApplicationTimeTickSignalP(void); +extern int UtcDaliWatchApplicationTimeTickSignalN(void); +extern int UtcDaliWatchApplicationAmbientTickSignalP(void); +extern int UtcDaliWatchApplicationAmbientTickSignalN(void); +extern int UtcDaliWatchApplicationAmbientChangedSignalP(void); +extern int UtcDaliWatchApplicationAmbientChangedSignalN(void); + testcase tc_array[] = { {"UtcDaliApplicationCopyConstructorP", UtcDaliApplicationCopyConstructorP, utc_Dali_Application_startup, utc_Dali_Application_cleanup}, @@ -232,6 +245,16 @@ testcase tc_array[] = { {"UtcDaliTtsPlayerConstructorP", UtcDaliTtsPlayerConstructorP, utc_Dali_TtsPlayer_startup, utc_Dali_TtsPlayer_cleanup}, {"UtcDaliTtsPlayerCopyConstructorP", UtcDaliTtsPlayerCopyConstructorP, utc_Dali_TtsPlayer_startup, utc_Dali_TtsPlayer_cleanup}, {"UtcDaliTtsPlayerAssignmentOperatorP", UtcDaliTtsPlayerAssignmentOperatorP, utc_Dali_TtsPlayer_startup, utc_Dali_TtsPlayer_cleanup}, + {"UtcDaliWatchApplicationNew01", UtcDaliWatchApplicationNew01, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationNew02", UtcDaliWatchApplicationNew02, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationNew03", UtcDaliWatchApplicationNew03, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationCopyAndAssignment", UtcDaliWatchApplicationCopyAndAssignment, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationTimeTickSignalP", UtcDaliWatchApplicationTimeTickSignalP, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationTimeTickSignalN", UtcDaliWatchApplicationTimeTickSignalN, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationAmbientTickSignalP", UtcDaliWatchApplicationAmbientTickSignalP, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationAmbientTickSignalN", UtcDaliWatchApplicationAmbientTickSignalN, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationAmbientChangedSignalP", UtcDaliWatchApplicationAmbientChangedSignalP, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, + {"UtcDaliWatchApplicationAmbientChangedSignalN", UtcDaliWatchApplicationAmbientChangedSignalN, utc_dali_watchapplication_startup, utc_dali_watchapplication_cleanup}, {NULL, NULL} }; -- 2.7.4