--- /dev/null
+#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
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", "");
// 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;
return 0;
}
-const char* NativeImageSource::GetCustomFragmentPrefix() const
-{
- return "";
-}
-
bool NativeImageSource::ApplyNativeFragmentShader(std::string& shader)
{
+ shader = Dali::NativeImageSourceTest::GetCustomFragmentPrefix() + shader;
return true;
}
bool OnFormPasswordAcquired();
bool OnDownloadStarted();
bool OnMimeOverridden();
+bool OnRequestIntercepted();
bool OnChangesWatch();
bool OnPlainTextReceived();
{
}
- bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback)
+ bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback) override
{
if (callback)
{
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)
{
return true;
}
- bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback)
+ bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback) override
{
if (callback)
{
{
}
- bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin)
+ bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin) override
{
return true;
}
{
}
- 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)
{
}
}
- void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback)
+ void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback) override
{
if (callback)
{
}
}
- void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback)
+ void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback) override
{
if (callback)
{
}
}
+ void RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback) override
+ {
+ if (callback)
+ {
+ ConnectToGlobalSignal(&OnRequestIntercepted);
+ mRequestInterceptedCallback = callback;
+ }
+ }
+
void EnableCache( bool cacheEnabled ) override
{
mockCacheEnabled = cacheEnabled;
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;
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::string& body, 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
return "test";
}
- Dali::Property::Map& GetAttributes() const override
+ Dali::Property::Map GetAttributes() const override
{
return mockAttributesMap;
}
mFormRepostDecidedCallback = callback;
}
- void RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
- {
- mRequestInterceptorCallback = callback;
- }
-
void RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
{
mConsoleMessageCallback = callback;
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;
{
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());
return false;
}
+bool OnRequestIntercepted()
+{
+ DisconnectFromGlobalSignal(&OnRequestIntercepted);
+ if (gWebEngineContextInstance)
+ {
+ Dali::WebEngineRequestInterceptorPtr interceptor = new MockWebEngineRequestInterceptor();
+ gWebEngineContextInstance->mRequestInterceptedCallback(interceptor);
+ }
+ return false;
+}
+
bool OnChangesWatch()
{
DisconnectFromGlobalSignal( &OnChangesWatch );
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);
#include <test-encoded-image-buffer.h>
#include "dummy-control.h"
+#include "test-native-image-source.h"
using namespace Dali;
using namespace Dali::Toolkit;
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 );
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;
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");
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;
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;
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;
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++;
return false;
}
+static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
+{
+ gRequestInterceptedCallbackCalled++;
+ gRequestInterceptorInstance = interceptor;
+ return false;
+}
+
static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
{
gContextMenuShownCallbackCalled++;
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;
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();
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)
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
*/
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
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
*/
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
mWebEngineContext.RegisterMimeOverriddenCallback(callback);
}
+void WebContext::RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback)
+{
+ mWebEngineContext.RegisterRequestInterceptedCallback(callback);
+}
+
void WebContext::EnableCache(bool cacheEnabled)
{
mWebEngineContext.EnableCache(cacheEnabled);
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
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);
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
}
}
+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())
*/
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
/**
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;
*/
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
/**
#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>
mFrameRenderedCallback = callback;
}
-void WebView::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback)
-{
- if(mWebEngine)
- {
- mWebEngine.RegisterRequestInterceptorCallback(callback);
- }
-}
-
void WebView::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
{
if(mWebEngine)
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);
{
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:
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);
}
}
}
- 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);
}
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);
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();
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);
* @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