Merge "Add SelectionCleared signal" into devel/master
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 27 Aug 2021 01:56:48 +0000 (01:56 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 27 Aug 2021 01:56:48 +0000 (01:56 +0000)
27 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-native-image-source.h [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-native-image.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-native-image-source.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/devel-api/controls/text-controls/text-editor-devel.cpp
dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h
dali-toolkit/devel-api/controls/text-controls/text-field-devel.cpp
dali-toolkit/devel-api/controls/text-controls/text-field-devel.h
dali-toolkit/devel-api/controls/web-view/web-context.cpp
dali-toolkit/devel-api/controls/web-view/web-context.h
dali-toolkit/devel-api/controls/web-view/web-view.cpp
dali-toolkit/devel-api/controls/web-view/web-view.h
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/controls/web-view/web-view-impl.cpp [changed mode: 0644->0755]
dali-toolkit/internal/controls/web-view/web-view-impl.h
dali-toolkit/internal/text/text-controller-event-handler.cpp
dali-toolkit/internal/text/text-controller-impl-event-handler.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-editable-control-interface.h

diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-native-image-source.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-native-image-source.h
new file mode 100644 (file)
index 0000000..c459e07
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef TEST_NATIVE_IMAGE_SOURCE_H
+#define TEST_NATIVE_IMAGE_SOURCE_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace NativeImageSourceTest
+{
+
+const char* GetCustomFragmentPrefix();
+
+}
+} // namespace Dali
+
+#endif // TEST_NATIVE_IMAGE_SOURCE_H
index fb9451c..bd1bfcc 100644 (file)
@@ -78,11 +78,6 @@ public:
     mCallStack.PushCall("GetTextureTarget", "");
     return GL_TEXTURE_EXTERNAL_OES;
   };
-  inline virtual const char* GetCustomFragmentPrefix() const
-  {
-    mCallStack.PushCall("GetCustomFragmentPrefix", "");
-    return "#extension GL_OES_EGL_image_external:require\n";
-  };
   inline virtual bool ApplyNativeFragmentShader(std::string& shader)
   {
     mCallStack.PushCall("ApplyNativeFragmentShader", "");
index 29ea5d5..d2be2d7 100755 (executable)
 // CLASS HEADER
 #include <dali/public-api/adaptor-framework/native-image-source.h>
 
+// INTERNAL INCLUDES
+#include "test-native-image-source.h"
+
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/any.h>
 
 namespace Dali
 {
 
+const char* NativeImageSourceTest::GetCustomFragmentPrefix()
+{
+  return "#extension GL_OES_EGL_image_external:require\n";
+}
+
 NativeImageSourcePtr NativeImageSource::New( unsigned int width, unsigned int height, ColorDepth depth )
 {
   Any empty;
@@ -100,13 +108,9 @@ int NativeImageSource::GetTextureTarget() const
   return 0;
 }
 
-const char* NativeImageSource::GetCustomFragmentPrefix() const
-{
-  return "";
-}
-
 bool NativeImageSource::ApplyNativeFragmentShader(std::string& shader)
 {
+  shader = Dali::NativeImageSourceTest::GetCustomFragmentPrefix() + shader;
   return true;
 }
 
index c1d8700..8f8853c 100755 (executable)
@@ -83,6 +83,7 @@ bool OnStorageUsageAcquired();
 bool OnFormPasswordAcquired();
 bool OnDownloadStarted();
 bool OnMimeOverridden();
+bool OnRequestIntercepted();
 bool OnChangesWatch();
 bool OnPlainTextReceived();
 
@@ -155,7 +156,7 @@ public:
   {
   }
 
-  bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback)
+  bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback) override
   {
     if (callback)
     {
@@ -165,12 +166,12 @@ public:
     return true;
   }
 
-  bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin)
+  bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin) override
   {
     return true;
   }
 
-  bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback)
+  bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback) override
   {
     if (callback)
     {
@@ -180,7 +181,7 @@ public:
     return true;
   }
 
-  bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback) 
+  bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback) override
   {
     if (callback)
     {
@@ -194,7 +195,7 @@ public:
   {
   }
 
-  bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin)
+  bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin) override
   {
     return true;
   }
@@ -207,12 +208,12 @@ public:
   {
   }
 
-  bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin)
+  bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin) override
   {
     return true;
   }
 
-  void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback)
+  void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback) override
   {
     if (callback)
     {
@@ -221,7 +222,7 @@ public:
     }
   }
 
-  void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback)
+  void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback) override
   {
     if (callback)
     {
@@ -230,7 +231,7 @@ public:
     }
   }
 
-  void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback)
+  void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback) override
   {
     if (callback)
     {
@@ -239,6 +240,15 @@ public:
     }
   }
 
+  void RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback) override
+  {
+    if (callback)
+    {
+      ConnectToGlobalSignal(&OnRequestIntercepted);
+      mRequestInterceptedCallback = callback;
+    }
+  }
+
   void EnableCache( bool cacheEnabled ) override
   {
     mockCacheEnabled = cacheEnabled;
@@ -317,10 +327,11 @@ public:
 
 public:
   Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback mSecurityOriginAcquiredCallback;
-  Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback mStorageUsageAcquiredCallback;
-  Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback mFormPasswordAcquiredCallback;
-  Dali::WebEngineContext::WebEngineDownloadStartedCallback mDownloadStartedCallback;
-  Dali::WebEngineContext::WebEngineMimeOverriddenCallback mMimeOverriddenCallback;
+  Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback   mStorageUsageAcquiredCallback;
+  Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback   mFormPasswordAcquiredCallback;
+  Dali::WebEngineContext::WebEngineDownloadStartedCallback        mDownloadStartedCallback;
+  Dali::WebEngineContext::WebEngineMimeOverriddenCallback         mMimeOverriddenCallback;
+  Dali::WebEngineContext::WebEngineRequestInterceptedCallback     mRequestInterceptedCallback;
 
 private:
   Dali::WebEngineContext::CacheModel mockModel;
@@ -611,25 +622,55 @@ public:
     return "http://test.html";
   }
 
+  Dali::Property::Map GetHeaders() const override
+  {
+    return mockHeadersMap;
+  }
+
+  std::string GetMethod() const override
+  {
+    return "GET";
+  }
+
   bool Ignore() override
   {
     return true;
   }
 
-  bool SetResponseStatus(int statusCode, const std::string &customedStatusText) override
+  bool SetResponseStatus(int statusCode, const std::string& customedStatusText) override
+  {
+    return true;
+  }
+
+  bool AddResponseHeader(const std::string& fieldName, const std::string& fieldValue) override
   {
+    mockHeadersMap.Add(fieldName, fieldValue);
     return true;
   }
 
-  bool AddResponseHeader(const std::string &fieldName, const std::string &fieldValue) override
+  bool AddResponseHeaders(const Dali::Property::Map& headers) override
   {
+    mockHeadersMap.Merge(headers);
     return true;
   }
 
-  bool AddResponseBody(const std::string &body, uint32_t length) override
+  bool AddResponseBody(const std::stringbody, uint32_t length) override
   {
     return true;
   }
+
+  bool AddResponse(const std::string& headers, const std::string& body, uint32_t length) override
+  {
+    return true;
+  }
+
+  bool WriteResponseChunk(const std::string& chunk, uint32_t length) override
+  {
+    return true;
+  }
+
+private:
+  Dali::Property::Map mockHeadersMap;
 };
 
 class MockWebEngineConsoleMessage : public Dali::WebEngineConsoleMessage
@@ -835,7 +876,7 @@ public:
     return "test";
   }
 
-  Dali::Property::Map& GetAttributes() const override
+  Dali::Property::Map GetAttributes() const override
   {
     return mockAttributesMap;
   }
@@ -1493,11 +1534,6 @@ public:
     mFormRepostDecidedCallback = callback;
   }
 
-  void RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
-  {
-    mRequestInterceptorCallback = callback;
-  }
-
   void RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
   {
     mConsoleMessageCallback = callback;
@@ -1572,7 +1608,6 @@ public:
   Dali::WebEnginePlugin::WebEngineUrlChangedCallback             mUrlChangedCallback;
   Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback      mFormRepostDecidedCallback;
   Dali::WebEnginePlugin::WebEngineFrameRenderedCallback          mFrameRenderedCallback;
-  Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback     mRequestInterceptorCallback;
   Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback mConsoleMessageCallback;
   Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback  mResponsePolicyDecisionCallback;
   Dali::WebEnginePlugin::WebEngineCertificateCallback            mCertificateConfirmCallback;
@@ -1659,11 +1694,6 @@ bool OnLoadUrl()
     {
       gInstance->mFrameRenderedCallback();
     }
-    if (gInstance->mRequestInterceptorCallback)
-    {
-      std::unique_ptr<Dali::WebEngineRequestInterceptor> interceptor(new MockWebEngineRequestInterceptor());
-      gInstance->mRequestInterceptorCallback(std::move(interceptor));
-    }
     if (gInstance->mConsoleMessageCallback)
     {
       std::unique_ptr<Dali::WebEngineConsoleMessage> message(new MockWebEngineConsoleMessage());
@@ -1879,6 +1909,17 @@ bool OnMimeOverridden()
   return false;
 }
 
+bool OnRequestIntercepted()
+{
+  DisconnectFromGlobalSignal(&OnRequestIntercepted);
+  if (gWebEngineContextInstance)
+  {
+    Dali::WebEngineRequestInterceptorPtr interceptor = new MockWebEngineRequestInterceptor();
+    gWebEngineContextInstance->mRequestInterceptedCallback(interceptor);
+  }
+  return false;
+}
+
 bool OnChangesWatch()
 {
   DisconnectFromGlobalSignal( &OnChangesWatch );
@@ -2373,11 +2414,6 @@ void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngi
   Internal::Adaptor::GetImplementation( *this ).RegisterFormRepostDecidedCallback(callback);
 }
 
-void WebEngine::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
-{
-  Internal::Adaptor::GetImplementation( *this ).RegisterRequestInterceptorCallback(callback);
-}
-
 void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
 {
   Internal::Adaptor::GetImplementation( *this ).RegisterConsoleMessageReceivedCallback(callback);
index 1dbb737..cd834df 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <test-encoded-image-buffer.h>
 #include "dummy-control.h"
+#include "test-native-image-source.h"
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -459,7 +460,7 @@ int UtcDaliImageVisualWithNativeImage(void)
   const Property::Map* outMap = value.GetMap();
   std::string fragmentShader = (*outMap)["fragment"].Get<std::string>();
 
-  const char* fragmentPrefix = nativeImageSource->GetCustomFragmentPrefix();
+  const char* fragmentPrefix = Dali::NativeImageSourceTest::GetCustomFragmentPrefix();
   size_t pos = fragmentShader.find(fragmentPrefix);
 
   DALI_TEST_EQUALS( pos != std::string::npos, true, TEST_LOCATION );
index 7d19f70..02dff2e 100644 (file)
@@ -4012,6 +4012,297 @@ int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
   END_TEST;
 }
 
+int UtcDaliTextEditorCopyText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextEditorCopyText ");
+
+  TextEditor textEditor = TextEditor::New();
+
+  std::string selectedText = "";
+  std::string copiedText = "";
+
+  application.GetScene().Add( textEditor );
+
+  textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  application.SendNotification();
+  application.Render();
+
+  textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
+
+  application.SendNotification();
+  application.Render();
+
+  // Hello is selected
+  DevelTextEditor::SelectText( textEditor, 0, 5 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+  // Hello is copied
+  copiedText = DevelTextEditor::CopyText( textEditor );
+  DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
+
+  // world is selected
+  DevelTextEditor::SelectText( textEditor, 6, 11 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
+
+  // world is copied
+  copiedText = DevelTextEditor::CopyText( textEditor );
+  DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
+
+  // "lo wo" is selected
+  DevelTextEditor::SelectText( textEditor, 3, 8 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
+
+  // "lo wo" is copied
+  copiedText = DevelTextEditor::CopyText( textEditor );
+  DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTextEditorCutText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextEditorCutText ");
+
+  TextEditor textEditor = TextEditor::New();
+
+  std::string selectedText = "";
+
+  application.GetScene().Add( textEditor );
+
+  textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  application.SendNotification();
+  application.Render();
+
+  textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
+
+  application.SendNotification();
+  application.Render();
+
+  // Hello is selected
+  DevelTextEditor::SelectText( textEditor, 0, 5 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+  // Hello is cut
+  DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
+
+  // " w" is selected
+  DevelTextEditor::SelectText( textEditor, 0, 2 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
+
+  // " w" is cut
+  DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
+
+  // Test Cut from the middle
+
+  // "rl" is selected
+  DevelTextEditor::SelectText( textEditor, 1, 3 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
+
+  // "rl" is cut
+  DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
+
+  // Test Cut from the end
+
+  // "d" is selected
+  DevelTextEditor::SelectText( textEditor, 1, 2 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
+  DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
+
+  // "d" is cut
+  DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTextEditorPasteText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextEditorPasteText ");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+
+  application.GetScene().Add( editor );
+
+  std::string cutText = "";
+  std::string copiedText = "";
+
+  editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
+  editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
+  editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Tap on the text editor
+  TestGenerateTap( application, 3.0f, 25.0f );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Move to second line of the text.
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Select some text in the right of the current cursor position
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Cut the selected text
+  cutText = DevelTextEditor::CutText(editor);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
+  DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+  // Select some text in the left of the current cursor position
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN,  "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Copy the selected text
+  copiedText = DevelTextEditor::CopyText(editor);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
+  DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+
+  // Move the cursor to the third line
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Paste the selected text at the current cursor position
+  DevelTextEditor::PasteText(editor);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+  END_TEST;
+}
 int UtcDaliTextEditorLineSpacing(void)
 {
   ToolkitTestApplication application;
index 6cfdf90..e8bf4b6 100644 (file)
@@ -120,7 +120,6 @@ const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
 const int KEY_RETURN_CODE = 36;
 const int KEY_A_CODE = 38;
 const int KEY_D_CODE = 40;
-
 const int KEY_SHIFT_MODIFIER = 257;
 
 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
@@ -4010,6 +4009,286 @@ int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
   END_TEST;
 }
 
+int UtcDaliTextFieldCopyText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextFieldCopyText ");
+
+  TextField textField = TextField::New();
+
+  std::string selectedText = "";
+  std::string copiedText = "";
+
+  application.GetScene().Add( textField );
+
+  textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  application.SendNotification();
+  application.Render();
+
+  textField.SetProperty( TextField::Property::TEXT, "Hello world" );
+
+  application.SendNotification();
+  application.Render();
+
+  // Hello is selected
+  DevelTextField::SelectText( textField, 0, 5 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+  // Hello is copied
+  copiedText = DevelTextField::CopyText( textField );
+  DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
+
+  // world is selected
+  DevelTextField::SelectText( textField, 6, 11 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
+
+  // world is copied
+  copiedText = DevelTextField::CopyText( textField );
+  DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
+
+  // "lo wo" is selected
+  DevelTextField::SelectText( textField, 3, 8 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
+
+  // "lo wo" is copied
+  copiedText = DevelTextField::CopyText( textField );
+  DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTextFieldCutText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextFieldCutText ");
+
+  TextField textField = TextField::New();
+
+  std::string selectedText = "";
+
+  application.GetScene().Add( textField );
+
+  textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  application.SendNotification();
+  application.Render();
+
+  textField.SetProperty( TextField::Property::TEXT, "Hello world" );
+
+  application.SendNotification();
+  application.Render();
+
+  // Hello is selected
+  DevelTextField::SelectText( textField, 0, 5 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+  // Hello is cut
+  DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
+
+  // " w" is selected
+  DevelTextField::SelectText( textField, 0, 2 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
+
+  // " w" is cut
+  DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
+
+  // Test Cut from the middle
+
+  // "rl" is selected
+  DevelTextField::SelectText( textField, 1, 3 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
+
+  // "rl" is cut
+  DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
+
+  // Test Cut from the end
+
+  // "d" is selected
+  DevelTextField::SelectText( textField, 1, 2 );
+
+  application.SendNotification();
+  application.Render();
+
+  selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+  DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
+
+  // "d" is cut
+  DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTextFieldPasteText(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextFieldPasteText ");
+
+  TextField textField = TextField::New();
+
+  application.GetScene().Add( textField );
+
+  std::string cutText = "";
+  std::string copiedText = "";
+
+  textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+  textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  application.SendNotification();
+  application.Render();
+
+  textField.SetProperty( TextField::Property::TEXT, "Hello World" );
+
+  application.SendNotification();
+  application.Render();
+
+  // Tap on the text editor
+  TestGenerateTap( application, 3.0f, 25.0f );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Select some text in the right of the current cursor position
+  DevelTextField::SelectText( textField, 0, 3 );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Cut the selected text
+  cutText = DevelTextField::CutText(textField);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
+  DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
+
+  DevelTextField::SelectText( textField, 0, 3 );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Copy the selected text
+  copiedText = DevelTextField::CopyText(textField);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
+  DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
+
+  // Move the cursor to the end of the line
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Paste the selected text at the current cursor position
+  DevelTextField::PasteText(textField);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
+
+  END_TEST;
+}
 int utcDaliTextFieldCursorPositionChangedSignal(void)
 {
   ToolkitTestApplication application;
index 16518da..4e553e8 100755 (executable)
@@ -77,8 +77,6 @@ static bool gWheelEventHandled = false;
 static int gFormRepostDecidedCallbackCalled = 0;
 static std::unique_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecidedInstance = nullptr;
 static int gFrameRenderedCallbackCalled = 0;
-static int gRequestInterceptorCallbackCalled = 0;
-static std::unique_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
 static int gConsoleMessageCallbackCalled = 0;
 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
 static int gResponsePolicyDecidedCallbackCalled = 0;
@@ -94,6 +92,8 @@ static int gStorageUsageAcquiredCallbackCalled = 0;
 static int gFormPasswordsAcquiredCallbackCalled = 0;
 static int gDownloadStartedCallbackCalled = 0;
 static int gMimeOverriddenCallbackCalled = 0;
+static int gRequestInterceptedCallbackCalled = 0;
+static Dali::WebEngineRequestInterceptorPtr gRequestInterceptorInstance = nullptr;
 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
 static int gContextMenuShownCallbackCalled = 0;
@@ -240,12 +240,6 @@ static void OnFrameRendered()
   gFrameRenderedCallbackCalled++;
 }
 
-static void OnRequestInterceptor(std::unique_ptr<Dali::WebEngineRequestInterceptor> interceptor)
-{
-  gRequestInterceptorCallbackCalled++;
-  gRequestInterceptorInstance = std::move(interceptor);
-}
-
 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
 {
   gConsoleMessageCallbackCalled++;
@@ -300,6 +294,13 @@ static bool OnMimeOverridden(const std::string&, const std::string&, std::string
   return false;
 }
 
+static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
+{
+  gRequestInterceptedCallbackCalled++;
+  gRequestInterceptorInstance = interceptor;
+  return false;
+}
+
 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
 {
   gContextMenuShownCallbackCalled++;
@@ -1231,36 +1232,6 @@ int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
   END_TEST;
 }
 
-int UtcDaliWebViewHttpRequestInterceptor(void)
-{
-  ToolkitTestApplication application;
-
-  WebView view = WebView::New();
-  DALI_TEST_CHECK( view );
-
-  // load url.
-  view.RegisterRequestInterceptorCallback( &OnRequestInterceptor );
-  DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
-  DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
-
-  view.LoadUrl( TEST_URL1 );
-  Test::EmitGlobalTimerSignal();
-  DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
-
-  // check request interceptor.
-  DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
-  DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
-  DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
-  DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
-  DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
-  std::string testUrl("http://test.html");
-  DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
-
-  gRequestInterceptorInstance = nullptr;
-
-  END_TEST;
-}
-
 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
 {
   ToolkitTestApplication application;
@@ -1334,8 +1305,8 @@ int UtcDaliWebViewHitTest(void)
   DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
   std::string testNodeValue("test");
   DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
-  Dali::Property::Map* testMap = &hitTest->GetAttributes();
-  DALI_TEST_CHECK(testMap);
+  Dali::Property::Map testMap = hitTest->GetAttributes();
+  DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
   std::string testImageFileNameExtension("jpg");
   DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
   Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
@@ -1668,6 +1639,47 @@ int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
   END_TEST;
 }
 
+int UtcDaliWebContextHttpRequestInterceptor(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebContext* context = view.GetContext();
+  DALI_TEST_CHECK( context != 0 )
+
+  // load url.
+  context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
+  DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
+  DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
+
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS( gRequestInterceptedCallbackCalled, 1, TEST_LOCATION );
+
+  // check request interceptor.
+  DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
+  DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
+  DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
+  DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
+  Dali::Property::Map testHeaders;
+  testHeaders.Insert("key2", "value2");
+  DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
+  DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
+  DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", "test", 4));
+  DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk("test", 4));
+  std::string testUrl("http://test.html");
+  DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
+  std::string testMethod("GET");
+  DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
+  Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
+  DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
+
+  gRequestInterceptorInstance = nullptr;
+
+  END_TEST;
+}
+
 // test cases for web cookie manager.
 
 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
index fdd6e77..f3f073b 100644 (file)
@@ -80,6 +80,21 @@ void ScrollBy(TextEditor textEditor, Vector2 scroll)
   GetImpl(textEditor).ScrollBy(scroll);
 }
 
+string CopyText(TextEditor textEditor)
+{
+  return GetImpl(textEditor).CopyText();
+}
+
+string CutText(TextEditor textEditor)
+{
+  return GetImpl(textEditor).CutText();
+}
+
+void PasteText(TextEditor textEditor)
+{
+  GetImpl(textEditor).PasteText();
+}
+
 } // namespace DevelTextEditor
 
 } // namespace Toolkit
index 19abc12..177be64 100644 (file)
@@ -450,6 +450,29 @@ DALI_TOOLKIT_API void SelectText(TextEditor textEditor, const uint32_t start, co
  */
 DALI_TOOLKIT_API void ScrollBy(TextEditor textEditor, Vector2 scroll);
 
+/**
+ * @brief Copy and return the selected text of TextEditor.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ * @return The copied text.
+ */
+DALI_TOOLKIT_API std::string CopyText(TextEditor textEditor);
+
+/**
+ * @brief Cut and return the selected text of TextEditor.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ * @return The cut text.
+ */
+DALI_TOOLKIT_API std::string CutText(TextEditor textEditor);
+
+/**
+ * @brief Paste the most recent clipboard text item into the TextEditor.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ */
+DALI_TOOLKIT_API void PasteText(TextEditor textEditor);
+
 } // namespace DevelTextEditor
 
 } // namespace Toolkit
index 98e6aa3..e5abdfa 100644 (file)
@@ -70,6 +70,21 @@ void SelectText(TextField textField, const uint32_t start, const uint32_t end)
   GetImpl(textField).SelectText(start, end);
 }
 
+string CopyText(TextField textField)
+{
+  return GetImpl(textField).CopyText();
+}
+
+string CutText(TextField textField)
+{
+  return GetImpl(textField).CutText();
+}
+
+void PasteText(TextField textField)
+{
+  GetImpl(textField).PasteText();
+}
+
 } // namespace DevelTextField
 
 } // namespace Toolkit
index 2471cc4..10d79e8 100644 (file)
@@ -364,6 +364,29 @@ DALI_TOOLKIT_API void SelectNone(TextField textField);
  */
 DALI_TOOLKIT_API void SelectText(TextField textField, const uint32_t start, const uint32_t end);
 
+/**
+ * @brief Copy and return the selected text of TextField.
+ *
+ * @param[in] textField The instance of TextField.
+ * @return The copied text.
+ */
+DALI_TOOLKIT_API std::string CopyText(TextField textField);
+
+/**
+ * @brief Cut and return the selected text of TextField.
+ *
+ * @param[in] textField The instance of TextField.
+ * @return The cut text.
+ */
+DALI_TOOLKIT_API std::string CutText(TextField textField);
+
+/**
+ * @brief Paste the most recent clipboard text item into the TextField.
+ *
+ * @param[in] textField The instance of TextField.
+ */
+DALI_TOOLKIT_API void PasteText(TextField textField);
+
 } // namespace DevelTextField
 
 } // namespace Toolkit
index 12218f7..bba91c6 100755 (executable)
@@ -144,6 +144,11 @@ void WebContext::RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngin
   mWebEngineContext.RegisterMimeOverriddenCallback(callback);
 }
 
+void WebContext::RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback)
+{
+  mWebEngineContext.RegisterRequestInterceptedCallback(callback);
+}
+
 void WebContext::EnableCache(bool cacheEnabled)
 {
   mWebEngineContext.EnableCache(cacheEnabled);
index 56bf2d8..69e723b 100755 (executable)
@@ -229,6 +229,13 @@ public:
   void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback);
 
   /**
+   * @brief Callback to be called when http request need be intercepted.
+   *
+   * @param[in] callback
+   */
+  void RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback);
+
+  /**
    * @brief Toggle the cache to be enabled or disabled
    *
    * @param[in] cacheEnabled enable or disable cache
index 7fff902..8412273 100755 (executable)
@@ -354,11 +354,6 @@ void WebView::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFram
   Dali::Toolkit::GetImpl(*this).RegisterFrameRenderedCallback(callback);
 }
 
-void WebView::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
-{
-  Dali::Toolkit::GetImpl(*this).RegisterRequestInterceptorCallback(callback);
-}
-
 void WebView::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
 {
   Dali::Toolkit::GetImpl(*this).RegisterConsoleMessageReceivedCallback(callback);
index fa8cee3..6b373df 100755 (executable)
@@ -678,13 +678,6 @@ public:
   void RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback);
 
   /**
-   * @brief Callback to be called when http request need be intercepted.
-   *
-   * @param[in] callback
-   */
-  void RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback);
-
-  /**
    * @brief Callback to be called when console message will be logged.
    *
    * @param[in] callback
index 77cd93d..47e4c0a 100644 (file)
@@ -1264,6 +1264,35 @@ void TextEditor::SelectText(const uint32_t start, const uint32_t end)
   }
 }
 
+string TextEditor::CopyText()
+{
+  string copiedText = "";
+  if(mController && mController->IsShowingRealText())
+  {
+    copiedText = mController->CopyText();
+  }
+  return copiedText;
+}
+
+string TextEditor::CutText()
+{
+  string cutText = "";
+  if(mController && mController->IsShowingRealText())
+  {
+    cutText = mController->CutText();
+  }
+  return cutText;
+}
+
+void TextEditor::PasteText()
+{
+  if(mController)
+  {
+    SetKeyInputFocus(); //Giving focus to the editor that was passed to the PasteText in case the passed editor (current editor) doesn't have focus.
+    mController->PasteText();
+  }
+}
+
 void TextEditor::ScrollBy(Vector2 scroll)
 {
   if(mController && mController->IsShowingRealText())
index d20e8ea..bc28781 100644 (file)
@@ -331,6 +331,21 @@ public:
    */
   void SetEditable(bool editable) override;
 
+  /**
+   * @copydoc Text::EditableControlInterface::CopyText()
+   */
+  string CopyText() override;
+
+  /**
+   * @copydoc Text::EditableControlInterface::CutText()
+   */
+  string CutText() override;
+
+  /**
+   * @copydoc Text::EditableControlInterface::PasteText()
+   */
+  void PasteText() override;
+
   // From AnchorControlInterface
 
   /**
index 5e6d740..6e08da1 100644 (file)
@@ -1217,6 +1217,35 @@ Uint32Pair TextField::GetTextSelectionRange() const
   return range;
 }
 
+string TextField::CopyText()
+{
+  string copiedText = "";
+  if(mController && mController->IsShowingRealText())
+  {
+    copiedText = mController->CopyText();
+  }
+  return copiedText;
+}
+
+string TextField::CutText()
+{
+  string cutText = "";
+  if(mController && mController->IsShowingRealText())
+  {
+    cutText = mController->CutText();
+  }
+  return cutText;
+}
+
+void TextField::PasteText()
+{
+  if(mController)
+  {
+    SetKeyInputFocus(); //Giving focus to the field that was passed to the PasteText in case the passed field (current field) doesn't have focus.
+    mController->PasteText();
+  }
+}
+
 InputMethodContext TextField::GetInputMethodContext()
 {
   return mInputMethodContext;
index 4711036..0472aa8 100644 (file)
@@ -303,6 +303,21 @@ public:
    */
   void SetEditable(bool editable) override;
 
+  /**
+   * @copydoc Dali::EditableControlInterface::CopyText()
+   */
+  string CopyText() override;
+
+  /**
+   * @copydoc Dali::EditableControlInterface::CutText()
+   */
+  string CutText() override;
+
+  /**
+   * @copydoc Text::EditableControlInterface::PasteText()
+   */
+  void PasteText() override;
+
   // From AnchorControlInterface
 
   /**
old mode 100644 (file)
new mode 100755 (executable)
index e336f2c..77b29ca
@@ -31,7 +31,6 @@
 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
-#include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/scripting/enum-helper.h>
@@ -702,14 +701,6 @@ void WebView::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFram
   mFrameRenderedCallback = callback;
 }
 
-void WebView::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
-{
-  if(mWebEngine)
-  {
-    mWebEngine.RegisterRequestInterceptorCallback(callback);
-  }
-}
-
 void WebView::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
 {
   if(mWebEngine)
index 15f3ce3..ca1ec27 100755 (executable)
@@ -353,11 +353,6 @@ public:
   void RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback);
 
   /**
-   * @copydoc Dali::Toolkit::WebView::RegisterRequestInterceptorCallback()
-   */
-  void RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback);
-
-  /**
    * @copydoc Dali::Toolkit::WebView::RegisterConsoleMessageReceivedCallback()
    */
   void RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback);
index bf677e5..5d78405 100644 (file)
@@ -952,43 +952,17 @@ void Controller::EventHandler::TextPopupButtonTouched(Controller& controller, Da
   {
     case Toolkit::TextSelectionPopup::CUT:
     {
-      if(!controller.IsEditable()) return;
-      controller.mImpl->SendSelectionToClipboard(true); // Synchronous call to modify text
-      controller.mImpl->mOperationsPending = ALL_OPERATIONS;
-
-      if((0u != controller.mImpl->mModel->mLogicalModel->mText.Count()) ||
-         !controller.mImpl->IsPlaceholderAvailable())
-      {
-        controller.mImpl->QueueModifyEvent(ModifyEvent::TEXT_DELETED);
-      }
-      else
-      {
-        controller.ShowPlaceholderText();
-      }
-
-      controller.mImpl->mEventData->mUpdateCursorPosition = true;
-      controller.mImpl->mEventData->mScrollAfterDelete    = true;
-
-      controller.mImpl->RequestRelayout();
-
-      if(NULL != controller.mImpl->mEditableControlInterface)
-      {
-        controller.mImpl->mEditableControlInterface->TextChanged(true);
-      }
+      controller.CutText();
       break;
     }
     case Toolkit::TextSelectionPopup::COPY:
     {
-      controller.mImpl->SendSelectionToClipboard(false); // Text not modified
-
-      controller.mImpl->mEventData->mUpdateCursorPosition = true;
-
-      controller.mImpl->RequestRelayout(); // Cursor, Handles, Selection Highlight, Popup
+      controller.CopyText();
       break;
     }
     case Toolkit::TextSelectionPopup::PASTE:
     {
-      controller.mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
+      controller.PasteText();
       break;
     }
     case Toolkit::TextSelectionPopup::SELECT:
index 60c4c54..416f937 100644 (file)
@@ -850,7 +850,7 @@ void ControllerImplEventHandler::OnHandlePressed(Controller::Impl& impl, const E
     eventData.mIsRightHandleSelected = true;
   }
 
-  if((impl.mSelectableControlInterface != nullptr) || eventData.mUpdateRightSelectionPosition || eventData.mUpdateLeftSelectionPosition)
+  if((impl.mSelectableControlInterface != nullptr) && ((oldStart != eventData.mLeftSelectionPosition) || (oldEnd != eventData.mRightSelectionPosition)))
   {
     impl.mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, eventData.mLeftSelectionPosition, eventData.mRightSelectionPosition);
   }
@@ -937,7 +937,7 @@ void ControllerImplEventHandler::OnHandleReleased(Controller::Impl& impl, const
     }
   }
 
-  if((impl.mSelectableControlInterface != nullptr) || eventData.mUpdateRightSelectionPosition || eventData.mUpdateLeftSelectionPosition)
+  if((impl.mSelectableControlInterface != nullptr) && ((oldStart != eventData.mLeftSelectionPosition) || (oldEnd != eventData.mRightSelectionPosition)))
   {
     impl.mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, eventData.mLeftSelectionPosition, eventData.mRightSelectionPosition);
   }
index b058e26..30c6e04 100644 (file)
@@ -1913,6 +1913,59 @@ string Controller::GetSelectedText() const
   return text;
 }
 
+string Controller::CopyText()
+{
+  string text;
+  mImpl->RetrieveSelection(text, false);
+  mImpl->SendSelectionToClipboard(false); // Text not modified
+
+  mImpl->mEventData->mUpdateCursorPosition = true;
+
+  mImpl->RequestRelayout(); // Cursor, Handles, Selection Highlight, Popup
+
+  return text;
+}
+
+string Controller::CutText()
+{
+  string text;
+  mImpl->RetrieveSelection(text, false);
+
+  if(!IsEditable())
+  {
+    return "";
+  }
+
+  mImpl->SendSelectionToClipboard(true); // Synchronous call to modify text
+  mImpl->mOperationsPending = ALL_OPERATIONS;
+
+  if((0u != mImpl->mModel->mLogicalModel->mText.Count()) ||
+     !mImpl->IsPlaceholderAvailable())
+  {
+    mImpl->QueueModifyEvent(ModifyEvent::TEXT_DELETED);
+  }
+  else
+  {
+    ShowPlaceholderText();
+  }
+
+  mImpl->mEventData->mUpdateCursorPosition = true;
+  mImpl->mEventData->mScrollAfterDelete    = true;
+
+  mImpl->RequestRelayout();
+
+  if(nullptr != mImpl->mEditableControlInterface)
+  {
+    mImpl->mEditableControlInterface->TextChanged(true);
+  }
+  return text;
+}
+
+void Controller::PasteText()
+{
+  mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
+}
+
 InputMethodContext::CallbackData Controller::OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent)
 {
   return EventHandler::OnInputMethodContextEvent(*this, inputMethodContext, inputMethodContextEvent);
index 109be1a..9302cf5 100644 (file)
@@ -1633,6 +1633,21 @@ public: // Text-input Event Queuing.
   void SelectWholeText();
 
   /**
+   * @copydoc Text::EditableControlInterface::CopyText()
+   */
+  string CopyText();
+
+  /**
+   * @copydoc Text::EditableControlInterface::CutText()
+   */
+  string CutText();
+
+  /**
+   * @copydoc Text::EditableControlInterface::PasteText()
+   */
+  void PasteText();
+
+  /**
    * @copydoc Text::SelectableControlInterface::SelectNone()
    */
   void SelectNone();
@@ -1751,8 +1766,7 @@ private: // Update.
   void InsertText(const std::string& text, InsertType type);
 
   /**
-   * @brief Paste given string into Text model
-   * @param[in] stringToPaste this string will be inserted into the text model
+   * @copydoc Text::EditableControlInterface::PasteText()
    */
   void PasteText(const std::string& stringToPaste);
 
index cd071f2..12d4256 100644 (file)
@@ -112,6 +112,23 @@ public:
    * @param[in] editable The editable status.
    */
   virtual void SetEditable(bool editable) = 0;
+
+  /**
+   * @brief Called to copy the selected text.
+   * @return The copied text.
+   */
+  virtual string CopyText() = 0;
+
+  /**
+   * @brief Called to cut the selected text.
+   * @return The cut text.
+   */
+  virtual string CutText() = 0;
+
+  /**
+   * @brief Called to paste the most recent clipboard text item into the control.
+   */
+  virtual void PasteText() = 0;
 };
 
 } // namespace Text