From 8eb92d99dfc9cb3954f6802abdd9d438ef47eba5 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Fri, 16 May 2014 17:19:17 +0100 Subject: [PATCH] (Tests) Removed dependency on Ecore Change-Id: Ibd6314a3d377506b1723ff3804763986a00c4577 Signed-off-by: Adeel Kazmi --- .../tct-dali-toolkit-unmanaged-core.h | 2 + .../toolkit-imf-manager.cpp | 272 +-------------------- .../dali-toolkit-test-utils/toolkit-timer.cpp | 196 +++++++++++++-- .../dali-toolkit-test-utils/toolkit-timer.h | 14 +- 4 files changed, 189 insertions(+), 295 deletions(-) diff --git a/automated-tests/src/dali-toolkit-unmanaged/tct-dali-toolkit-unmanaged-core.h b/automated-tests/src/dali-toolkit-unmanaged/tct-dali-toolkit-unmanaged-core.h index aa3cb58..f3a27c4 100644 --- a/automated-tests/src/dali-toolkit-unmanaged/tct-dali-toolkit-unmanaged-core.h +++ b/automated-tests/src/dali-toolkit-unmanaged/tct-dali-toolkit-unmanaged-core.h @@ -193,6 +193,7 @@ extern int UtcDaliJsonParserMethod07(void); extern int UtcDaliJsonParserMethod08(void); extern int UtcDaliJsonParserMethod09(void); extern int UtcDaliJsonParserMethod10(void); +extern int UtcDaliJsonParserMethod11(void); extern int UtcDaliKeyInputFocusManagerGet(void); extern int UtcDaliKeyInputFocusManagerSetFocus(void); extern int UtcDaliKeyInputFocusManagerGetCurrentFocusControl(void); @@ -506,6 +507,7 @@ testcase tc_array[] = { {"UtcDaliJsonParserMethod08", UtcDaliJsonParserMethod08, utc_json_parser_startup, utc_json_parser_cleanup}, {"UtcDaliJsonParserMethod09", UtcDaliJsonParserMethod09, utc_json_parser_startup, utc_json_parser_cleanup}, {"UtcDaliJsonParserMethod10", UtcDaliJsonParserMethod10, utc_json_parser_startup, utc_json_parser_cleanup}, + {"UtcDaliJsonParserMethod11", UtcDaliJsonParserMethod11, utc_json_parser_startup, utc_json_parser_cleanup}, {"UtcDaliKeyInputFocusManagerGet", UtcDaliKeyInputFocusManagerGet, key_input_focus_manager_startup, key_input_focus_manager_cleanup}, {"UtcDaliKeyInputFocusManagerSetFocus", UtcDaliKeyInputFocusManagerSetFocus, key_input_focus_manager_startup, key_input_focus_manager_cleanup}, {"UtcDaliKeyInputFocusManagerGetCurrentFocusControl", UtcDaliKeyInputFocusManagerGetCurrentFocusControl, key_input_focus_manager_startup, key_input_focus_manager_cleanup}, diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp index ca25896..355b3ed 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp @@ -19,8 +19,6 @@ // EXTERNAL INCLUDES #include -#include -#include #include #include @@ -51,13 +49,8 @@ public: void Deactivate(); void Reset(); - Ecore_IMF_Context* GetContext(); bool RestoreAfterFocusLost() const; void SetRestoreAferFocusLost( bool toggle ); - void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info ); - void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info ); - Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition ); - void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info ); void NotifyCursorPosition(); int GetCursorPosition(); void SetCursorPosition( unsigned int cursorPosition ); @@ -81,7 +74,6 @@ private: ImfManager& operator=( ImfManager& ); private: - Ecore_IMF_Context* mIMFContext; int mIMFCursorPosition; std::string mSurroundingText; bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained. @@ -114,85 +106,8 @@ inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali }; - -namespace -{ - -// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead. -size_t Utf8SequenceLength(const unsigned char leadByte) -{ - size_t length = 0; - - if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero) - { - length = 1; - } - else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx - { - length = 2; - } - else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx - { - length = 3; - } - else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx - { - length = 4; - } - - return length; -} - -// Static function calls used by ecore 'c' style callback registration -void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info ) -{ - if ( data ) - { - ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data ); - imfManager->CommitReceived( data, imfContext, event_info ); - } -} - -void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info ) -{ - if ( data ) - { - ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data ); - imfManager->PreEditChanged( data, imfContext, event_info ); - } -} - -Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition ) -{ - if ( data ) - { - ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data ); - return imfManager->RetrieveSurrounding( data, imfContext, text, cursorPosition ); - } - else - { - return false; - } -} - -/** - * Called when an IMF delete surrounding event is received. - * Here we tell the application that it should delete a certain range. - */ -void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info ) -{ - if ( data ) - { - ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data ); - imfManager->DeleteSurrounding( data, imfContext, event_info ); - } -} - -} // unnamed namespace - Dali::ImfManager Dali::Internal::Adaptor::ImfManager::mToolkitImfManager; - Dali::ImfManager ImfManager::Get() { Dali::ImfManager manager; @@ -205,25 +120,20 @@ Dali::ImfManager ImfManager::Get() } ImfManager::ImfManager( /*Ecore_X_Window ecoreXwin*/ ) -: mIMFContext(), - mIMFCursorPosition( 0 ), +: mIMFCursorPosition( 0 ), mSurroundingText(""), mRestoreAfterFocusLost( false ), mIdleCallbackConnected( false ), mKeyEvents() { - //ecore_imf_init(); CreateContext( /*ecoreXwin*/ ); ConnectCallbacks(); - //VirtualKeyboard::ConnectCallbacks( mIMFContext ); } ImfManager::~ImfManager() { - //VirtualKeyboard::DisconnectCallbacks( mIMFContext ); DisconnectCallbacks(); DeleteContext(); - //ecore_imf_shutdown(); } void ImfManager::CreateContext( /*Ecore_X_Window ecoreXwin*/ ) @@ -237,60 +147,22 @@ void ImfManager::DeleteContext() // Callbacks for predicitive text support. void ImfManager::ConnectCallbacks() { - //if ( mIMFContext ) { - //ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this ); - //ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this ); - //ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this ); - //} } void ImfManager::DisconnectCallbacks() { - // if ( mIMFContext ) - // { - // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit ); - // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit ); - // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding ); - // } } void ImfManager::Activate() { - // // Reset mIdleCallbackConnected - // mIdleCallbackConnected = false; - - // if ( mIMFContext ) - // { - // ecore_imf_context_focus_in( mIMFContext ); - // // emit keyboard activated signal - // Dali::ImfManager handle( this ); - // mActivatedSignalV2.Emit( handle ); - // } } void ImfManager::Deactivate() { - // if( mIMFContext ) - // { - // Reset(); - // ecore_imf_context_focus_out( mIMFContext ); - // } - // // Reset mIdleCallbackConnected - // mIdleCallbackConnected = false; } void ImfManager::Reset() { - // if ( mIMFContext ) - // { - // ecore_imf_context_reset( mIMFContext ); - // } -} - -Ecore_IMF_Context* ImfManager::GetContext() -{ - //return mIMFContext; - return NULL; } bool ImfManager::RestoreAfterFocusLost() const @@ -303,148 +175,8 @@ void ImfManager::SetRestoreAferFocusLost( bool toggle ) mRestoreAfterFocusLost = toggle; } -void ImfManager::PreEditChanged( void *, Ecore_IMF_Context *imfContext, void *event_info ) -{ - // char *preEditString( NULL ); - // int cursorPosition( 0 ); - // Eina_List *attrs = NULL; - // Eina_List *l = NULL; - - // Ecore_IMF_Preedit_Attr *attr; - - // // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string. - // // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string. - // ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition ); - // if ( attrs ) - // { - // // iterate through the list of attributes getting the type, start and end position. - // for ( l = attrs, (attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ); l; l = eina_list_next(l), ( attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) )) - // { - // if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF) - // { - // // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages. - // size_t visualCharacterIndex = 0; - // size_t byteIndex = 0; - // // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). - // while ( preEditString[byteIndex] != '\0' ) - // { - // // attr->end_index is provided as a byte position not character and we need to know the character position. - // size_t currentSequenceLength = Utf8SequenceLength(preEditString[byteIndex]); // returns number of bytes used to represent character. - // if ( byteIndex == attr->end_index ) - // { - // cursorPosition = visualCharacterIndex; - // break; - // // end loop as found cursor position that matches byte position - // } - // else - // { - // byteIndex += currentSequenceLength; // jump to next character - // visualCharacterIndex++; // increment character count so we know our position for when we get a match - // } - // DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString )); - // } - // } - // } - // } - // if ( Dali::Adaptor::IsAvailable() ) - // { - // std::string keyString ( preEditString ); - // int numberOfChars( 0 ); - // Dali::ImfManager handle( this ); - // Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::PREEDIT, keyString, cursorPosition, numberOfChars ); - // Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData ); - // if ( callbackData.update ) - // { - // SetCursorPosition( callbackData.cursorPosition ); - // SetSurroundingText( callbackData.currentText ); - // NotifyCursorPosition(); - // } - // if ( callbackData.preeditResetRequired ) - // { - // Reset(); - // } - // } - // free( preEditString ); -} - -void ImfManager::CommitReceived( void *, Ecore_IMF_Context *imfContext, void *event_info ) -{ - // if ( Dali::Adaptor::IsAvailable() ) - // { - // const std::string keyString( (char *)event_info ); - // const int cursorOffset( 0 ); - // const int numberOfChars( 0 ); - - // Dali::ImfManager handle( this ); - // Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::COMMIT, keyString, cursorOffset, numberOfChars ); - // Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData ); - - // if ( callbackData.update ) - // { - // SetCursorPosition( callbackData.cursorPosition ); - // SetSurroundingText( callbackData.currentText ); - - // NotifyCursorPosition(); - // } - // } -} - -/** - * Called when an IMF retrieve surround event is received. - * Here the IMF module wishes to know the string we are working with and where within the string the cursor is - * We need to signal the application to tell us this information. - */ -Eina_Bool ImfManager::RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition ) -{ - // std::string keyString ( "" ); - // int cursorOffset( 0 ); - // int numberOfChars( 0 ); - // Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::GETSURROUNDING , keyString, cursorOffset, numberOfChars ); - // Dali::ImfManager handle( this ); - // mEventSignalV2.Emit( handle, imfData ); - // if ( text ) - // { - // std::string surroundingText( GetSurroundingText() ); - // if ( !surroundingText.empty() ) - // { - // *text = strdup( surroundingText.c_str() ); - // } - // else - // { - // *text = strdup( "" ); - // } - // } - // if ( cursorPosition ) - // { - // *cursorPosition = GetCursorPosition(); - // } - return EINA_TRUE; -} - -/** - * Called when an IMF delete surrounding event is received. - * Here we tell the application that it should delete a certain range. - */ -void ImfManager::DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info ) -{ - // if ( Dali::Adaptor::IsAvailable() ) - // { - // Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = (Ecore_IMF_Event_Delete_Surrounding*) event_info; - // const std::string keyString( "" ); - // const int cursorOffset( deleteSurroundingEvent->offset ); - // const int numberOfChars( deleteSurroundingEvent->n_chars ); - // Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::DELETESURROUNDING , keyString, cursorOffset, numberOfChars ); - // Dali::ImfManager handle( this ); - // mEventSignalV2.Emit( handle, imfData ); - // } -} - void ImfManager::NotifyCursorPosition() { - // if ( mIMFContext ) - // { - // ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition ); - // } } int ImfManager::GetCursorPosition() @@ -491,7 +223,7 @@ ImfManager ImfManager::Get() ImfContext ImfManager::GetContext() { - return reinterpret_cast( Internal::Adaptor::ImfManager::GetImplementation(*this).GetContext() ); + return NULL; } void ImfManager::Activate() 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 f2a3d58..c6facd5 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 @@ -16,40 +16,194 @@ #include "toolkit-timer.h" -#include - // INTERNAL INCLUDES #include #include #include +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ +class Timer; + +typedef IntrusivePtr TimerPtr; + +/** + * Implementation of the timer + */ +class Timer : public BaseObject +{ +public: + static TimerPtr New( unsigned int milliSec ); + Timer( unsigned int milliSec ); + virtual ~Timer(); + + void Start(); + void Stop(); + void SetInterval( unsigned int interval ); + unsigned int GetInterval() const; + bool IsRunning() const; + bool Tick(); + +public: // Signals + + Dali::Timer::TimerSignalV2& TickSignal(); + +private: // Implementation + + // not implemented + Timer( const Timer& ); + Timer& operator=( const Timer& ); + +private: // Data + + Dali::Timer::TimerSignalV2 mTickSignal; + unsigned int mInterval; +}; + +inline Timer& GetImplementation(Dali::Timer& timer) +{ + DALI_ASSERT_ALWAYS(timer && "Timer handle is empty"); + + BaseObject& handle = timer.GetBaseObject(); + + return static_cast(handle); +} + +inline const Timer& GetImplementation(const Dali::Timer& timer) +{ + DALI_ASSERT_ALWAYS(timer && "Timer handle is empty"); + + const BaseObject& handle = timer.GetBaseObject(); + + return static_cast(handle); +} + +TimerPtr Timer::New( unsigned int milliSec ) +{ + TimerPtr timerImpl = new Timer(10); + return timerImpl; +} + +Timer::Timer( unsigned int milliSec ) +: mInterval( milliSec ) +{ +} + +Timer::~Timer() +{ +} -namespace +void Timer::Start() { -bool ecore_timer_running = false; -Ecore_Task_Cb timer_callback_func=NULL; -const void* timer_callback_data=NULL; -int timerId = 0; -}// anon namespace +} -extern "C" +void Timer::Stop() { -Ecore_Timer* ecore_timer_add(double in, - Ecore_Task_Cb func, - const void *data) +} + +void Timer::SetInterval( unsigned int interval ) { - ecore_timer_running = true; - timer_callback_func = func; - timer_callback_data = data; - timerId += sizeof(Ecore_Timer*); - return (Ecore_Timer*)timerId; + mInterval = interval; } -void* ecore_timer_del(Ecore_Timer *timer) +unsigned int Timer::GetInterval() const { - ecore_timer_running = false; - timer_callback_func = NULL; - return NULL; + return mInterval; } +bool Timer::IsRunning() const +{ + return true; } + +bool Timer::Tick() +{ + return false; +} + +Dali::Timer::TimerSignalV2& Timer::TickSignal() +{ + return mTickSignal; +} + +} // namespace Adaptor + +} // namespace Internal + +/********************************************************************************/ +/********************************* PUBLIC CLASS *******************************/ +/********************************************************************************/ + +Timer::Timer() +{ + +} + +Timer Timer::New( unsigned int milliSec ) +{ + Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec ); + return Timer(internal.Get()); +} + +Timer::Timer( const Timer& timer ) +:BaseHandle( timer ) +{ +} + +Timer& Timer::operator=( const Timer& timer ) +{ + // check self assignment + if( *this != timer ) + { + BaseHandle::operator=(timer); + } + return *this; +} + +Timer::~Timer() +{ +} + +void Timer::Start() +{ + Internal::Adaptor::GetImplementation( *this ).Start(); +} + +void Timer::Stop() +{ + Internal::Adaptor::GetImplementation( *this ).Stop(); +} + +void Timer::SetInterval( unsigned int milliSec ) +{ + Internal::Adaptor::GetImplementation( *this ).SetInterval( milliSec ); +} + +unsigned int Timer::GetInterval() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetInterval(); +} + +bool Timer::IsRunning() const +{ + return true; +} + +Timer::TimerSignalV2& Timer::TickSignal() +{ + return Internal::Adaptor::GetImplementation( *this ).TickSignal(); +} + +Timer::Timer(Internal::Adaptor::Timer* timer) +: BaseHandle(timer) +{ +} + +} // namespace Dali + diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.h index 29abb84..908dbf0 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-timer.h @@ -28,12 +28,20 @@ namespace Dali { +namespace Internal +{ +namespace Adaptor +{ +class Timer; +} +} + class Timer : public BaseHandle { public: typedef SignalV2< bool () > TimerSignalV2; - static Timer New( unsigned int milliSec ); Timer(); + static Timer New( unsigned int milliSec ); Timer( const Timer& timer ); Timer& operator=( const Timer& timer ); virtual ~Timer(); @@ -46,9 +54,7 @@ public: bool IsRunning() const; TimerSignalV2& TickSignal(); private: - Dali::Timer::TimerSignalV2 mTickSignal; - unsigned int mInterval; - bool mIsRunning; + Timer(Internal::Adaptor::Timer* timer); }; } // namespace Dali -- 2.7.4