Merge "dali-toolkit: fix wrong TextChanged() signal" into devel/master
authorBowon Ryu <bowon.ryu@samsung.com>
Thu, 25 Feb 2021 05:21:03 +0000 (05:21 +0000)
committerGerrit Code Review <gerrit@review>
Thu, 25 Feb 2021 05:21:03 +0000 (05:21 +0000)
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/text/text-controller-event-handler.cpp

index 66f8db3..d5a243c 100644 (file)
@@ -975,6 +975,19 @@ int utcDaliTextEditorTextChangedP(void)
   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
   DALI_TEST_CHECK( gTextChangedCallBackCalled );
 
+  // Remove all text
+  editor.SetProperty( TextField::Property::TEXT, "" );
+
+  // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
+  gTextChangedCallBackCalled = false;
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  DALI_TEST_CHECK( !gTextChangedCallBackCalled );
+
+  // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
+  gTextChangedCallBackCalled = false;
+  application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  DALI_TEST_CHECK( !gTextChangedCallBackCalled );
+
   END_TEST;
 }
 
index 93d8f7d..b535059 100644 (file)
@@ -1045,6 +1045,19 @@ int utcDaliTextFieldTextChangedP(void)
   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
   DALI_TEST_CHECK( gTextChangedCallBackCalled );
 
+  // Remove all text
+  field.SetProperty( TextField::Property::TEXT, "" );
+
+  // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
+  gTextChangedCallBackCalled = false;
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  DALI_TEST_CHECK( !gTextChangedCallBackCalled );
+
+  // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
+  gTextChangedCallBackCalled = false;
+  application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  DALI_TEST_CHECK( !gTextChangedCallBackCalled );
+
   END_TEST;
 }
 
index c6fbe87..c6c4058 100644 (file)
@@ -599,7 +599,8 @@ bool Controller::EventHandler::DeleteEvent(Controller& controller, int keyCode)
                                     1,
                                     UPDATE_INPUT_STYLE);
   }
-  else if(keyCode == Dali::DevelKey::DALI_KEY_DELETE)
+  else if((controller.mImpl->mEventData->mPrimaryCursorPosition < controller.mImpl->mModel->mLogicalModel->mText.Count()) &&
+          (keyCode == Dali::DevelKey::DALI_KEY_DELETE))
   {
     // Remove the character after the current cursor position
     removed = controller.RemoveText(0,