Reset the number of characters to add in deleting all texts 97/239297/4
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Thu, 23 Jul 2020 10:57:10 +0000 (19:57 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 27 Jul 2020 09:00:09 +0000 (18:00 +0900)
Change-Id: Icc5681a75eb9ed93afb2741b08861cb2974000cf
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
dali-toolkit/internal/text/text-controller.cpp

index b1afd347fc2801bed3ce082f6b3bbdd6ea4c663a..e87c900096c8548e8d9d0cac00a47826e84043b6 100755 (executable)
@@ -1232,3 +1232,62 @@ int UtcDaliTextControllerCheckInputFontPointSizeUpdated(void)
 
   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;
+}
index 95f54bca9651d33140682493cb2ecae4b51a75d0..19cae29c9ebeefe7a797c76041ff742418dec2f9 100755 (executable)
@@ -3833,6 +3833,7 @@ bool Controller::RemoveText( int cursorOffset,
       if( ( currentText.Count() - numberOfCharacters == 0 ) && ( cursorIndex == 0 ) )
       {
         mImpl->ClearPreEditFlag();
+        mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0;
       }
 
       // Updates the text style runs by removing characters. Runs with no characters are removed.