+}
+
+int UtcDaliTextControllerCheckBufferIndices(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckBufferIndices");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Set the text
+ const std::string text("A Quick Brown Fox Jumps Over The Lazy Dog");
+ controller->SetText(text);
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Tweak some parameters to make the indices to access the text buffer invalid
+ mImpl.mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl.mModel->mLogicalModel->mText.Count() * 10u;
+ mImpl.mTextUpdateInfo.mNumberOfCharactersToRemove = 0u;
+ mImpl.mTextUpdateInfo.mPreviousNumberOfCharacters = 0u;
+ mImpl.mOperationsPending = Controller::ALL_OPERATIONS;
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputColorChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputColorChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+
+ const Vector4 inputColor( 0.0f, 0.0f, 0.0f, 1.0f );
+ controller->SetInputColor( inputColor );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // change the input color
+ const Vector4 newInputColor( 1.0f, 0.0f, 0.0f, 1.0f );
+ controller->SetInputColor( newInputColor );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::COLOR, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::COLOR ), TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontFamilyChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontFamilyChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text and font family
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontFamily("SamsungOneUI_200");
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // change the input font family
+ controller->SetInputFontFamily("SamsungOneUI_300");
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontWeightChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontWeightChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontWeight( TextAbstraction::FontWeight::NORMAL );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // change the input font weight
+ controller->SetInputFontWeight( TextAbstraction::FontWeight::BOLD );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontWidthChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontWidthChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontWidth( TextAbstraction::FontWidth::NORMAL );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // change the input font width
+ controller->SetInputFontWidth( TextAbstraction::FontWidth::EXPANDED );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontSlantChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontSlantChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText(text);
+ controller->SetInputFontSlant( TextAbstraction::FontSlant::NORMAL );
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // change the input font slant
+ controller->SetInputFontSlant( TextAbstraction::FontSlant::ROMAN );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontPointSizeChanged(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontPointSizeChanged");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextLabel(controller);
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Enables the text input.
+ controller->EnableTextInput( decorator, inputMethodContext );
+
+ // 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() );
+
+ // Reset operation
+ mImpl.mOperationsPending = Controller::NO_OPERATION;
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // change the input font point size
+ controller->SetInputFontPointSize( 1.2f );
+
+ // Check if relayout is requested or not when event state is INACTIVE.
+ DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+ DALI_TEST_EQUALS( Controller::VALIDATE_FONTS, static_cast<Controller::OperationsMask>( mImpl.mOperationsPending & Controller::VALIDATE_FONTS ),
+ TEST_LOCATION );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerSelectEvent(void)
+{
+ tet_infoline(" UtcDaliTextControllerSelectEvent");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-field.
+ ConfigureTextField( controller );
+
+ // Set the text
+ const std::string text("Hello World!");
+ controller->SetText( text );
+
+ // Select the whole text.
+ controller->SelectEvent( 0.f, 0.f, SelectionType::INTERACTIVE );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ // Get the implementation of the text controller
+ Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+ // Check if the whole text is selected or not.
+ std::string retrieved_text;
+ mImpl.RetrieveSelection( retrieved_text, false );
+ DALI_TEST_EQUALS( "Hello", retrieved_text, TEST_LOCATION );
+
+ // Select the whole text.
+ controller->SelectEvent( 0.f, 0.f, SelectionType::ALL );
+
+ // Perform a relayout
+ controller->Relayout( size );
+
+ mImpl.RetrieveSelection( retrieved_text, false );
+ DALI_TEST_EQUALS( text, retrieved_text, 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( application.GetScene().GetSize() );
+ controller->Relayout( size );
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerCheckInputFontPointSizeUpdated(void)
+{
+ tet_infoline(" UtcDaliTextControllerCheckInputFontPointSizeUpdated");
+ 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 );
+ controller->KeyboardFocusGainEvent();
+
+ application.SendNotification();
+ application.Render();
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+ controller->Relayout(size);
+
+ // simulate a key event.
+ controller->KeyEvent( GenerateKey( "a", "a", 38, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // change the input font point size
+ controller->SetInputFontPointSize( 20.f );
+
+ application.SendNotification();
+ application.Render();
+
+ // Perform a relayout
+ controller->Relayout(size);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliTextControllerDeleteSurroundings(void)
+{
+ tet_infoline(" UtcDaliTextControllerDeleteSurroundings");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ ConfigureTextField( controller );
+
+ // 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 );
+
+ InputMethodContext inputMethodContext = InputMethodContext::New();
+ // Add some pre-edit text, such as Korean
+ InputMethodContext::EventData imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅂㅂㅂ", 0, 3 );
+ controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+ // Perform a relayout
+ const Size size( application.GetScene().GetSize() );
+
+ application.SendNotification();
+ application.Render();
+
+ controller->Relayout( size );
+
+ // Simulate a key event to delete one text
+ controller->KeyEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ // Send DELETE_SURROUNDING event (Delete All text)
+ imfEvent = InputMethodContext::EventData( InputMethodContext::DELETE_SURROUNDING, "", -2, 2 );
+ controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+ application.SendNotification();
+ application.Render();
+
+ controller->Relayout( size );
+
+ // simulate a key event to add text
+ controller->KeyEvent( GenerateKey( "ㅇ", "ㅇ", 238, 0, 0, Dali::KeyEvent::DOWN ) );
+ controller->KeyEvent( GenerateKey( "ㅇ", "ㅇ", 238, 0, 0, Dali::KeyEvent::DOWN ) );
+
+ DALI_TEST_EQUALS( EventData::EDITING, mImpl.mEventData->mState, TEST_LOCATION );
+
+ // Force to update the model.
+ controller->GetNaturalSize();
+
+ application.SendNotification();
+ application.Render();
+
+ controller->Relayout( size );
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}