X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Futc-Dali-Text-Controller.cpp;h=a76ccb9ea56f3633dbc744d326a3bb284a7dc938;hp=95f769739c91d0eefbd5320c9a925d659ff975ec;hb=590ede8c5f4771821ff5ac3f3acef0d189525008;hpb=b03acd78e2289973171be301c1e04fbb5b778d29 diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index 95f7697..a76ccb9 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -258,6 +258,9 @@ int UtcDaliTextControllerImfEvent(void) controller->GetText( text ); DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION ); + // for coverage + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::UNDERLINE ); + // Send PRE_EDIT event imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "wo", 6, 2 ); controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); @@ -286,6 +289,107 @@ int UtcDaliTextControllerImfEvent(void) END_TEST; } +int UtcDaliTextControllerImfPreeditStyle(void) +{ + tet_infoline(" UtcDaliTextControllerImfPreeditStyle"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + std::string text; + InputMethodContext::EventData imfEvent; + + DALI_TEST_CHECK( controller ); + + // Configures the text controller similarly to the text-field. + ConfigureTextField( controller ); + + InputMethodContext inputMethodContext = InputMethodContext::New(); + + // Send COMMIT event. + imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "Hello ", 0, 6 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Force to update the model. + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION ); + + // Send PRE_EDIT event + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::NONE ); + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Set the preedit style as REVERSE + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::REVERSE ); + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Set the preedit style as HIGHLIGHT + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::HIGHLIGHT ); + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Set the preedit style as CUSTOM_PLATFORM_STYLE_1 + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1 ); + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Set the preedit style as CUSTOM_PLATFORM_STYLE_2 + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2 ); + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Set the preedit style as CUSTOM_PLATFORM_STYLE_3 + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3 ); + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION ); + + imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 ); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Set the preedit style as CUSTOM_PLATFORM_STYLE_4 + inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4 ); + controller->GetNaturalSize(); + + controller->GetText( text ); + DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION ); + + tet_result(TET_PASS); + END_TEST; +} + int UtcDaliTextControllerTextPopupButtonTouched(void) { tet_infoline(" UtcDaliTextControllerTextPopupButtonTouched"); @@ -1045,3 +1149,83 @@ int UtcDaliTextControllerSelectEvent(void) END_TEST; } + + +int UtcDaliTextControllerMaxLengthSetText(void) +{ + tet_infoline(" UtcDaliTextControllerMaxLengthSetText"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + ConfigureTextLabel(controller); + + const Length MAX_TEXT_LENGTH = 1024u * 32u; + + // make over length world + int maxLength = (1024u * 32u) + 10u; + char world[maxLength]; + for( int i = 0; i < maxLength; i++ ) + { + world[i] = 'a'; + } + + // Set the text + std::string text(world); + controller->SetText( text ); + + // Perform a relayout + const Size size( Dali::Stage::GetCurrent().GetSize() ); + controller->Relayout(size); + + // check text length + controller->GetText( text ); + Length textSize = text.size(); + + DALI_TEST_EQUALS( MAX_TEXT_LENGTH, textSize, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTextControllerRemoveTextChangeEventData(void) +{ + tet_infoline(" UtcDaliTextControllerRemoveTextChangeEventData"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + ConfigureTextField( controller ); + + // Set the text + const std::string text( "Hello World!" ); + controller->SetText( text ); + controller->SetInputFontPointSize( 1.0f ); + + // Get the implementation of the text controller + Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() ); + + DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION ); + + // Send DELETE_SURROUNDING event + InputMethodContext::EventData imfEvent = InputMethodContext::EventData( InputMethodContext::DELETE_SURROUNDING, "", -1, 1 ); + InputMethodContext inputMethodContext = InputMethodContext::New(); + controller->OnInputMethodContextEvent( inputMethodContext, imfEvent ); + + // Force to update the model. + controller->GetNaturalSize(); + + // Simulate a key event to delete text + controller->KeyEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Dali::KeyEvent::Down ) ); + + DALI_TEST_EQUALS( EventData::EDITING, mImpl.mEventData->mState, TEST_LOCATION ); + + // Perform a relayout + const Size size( Dali::Stage::GetCurrent().GetSize() ); + controller->Relayout( size ); + + tet_result(TET_PASS); + + END_TEST; +}