#include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
#include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
#include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
+#include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
#include <dali/devel-api/adaptor-framework/web-engine-frame.h>
+#include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
#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-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
-#include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
static bool gHovered = false;
static bool gWheelEventHandled = false;
static int gFormRepostDecisionCallbackCalled = 0;
-static std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> gFormRepostDecisionInstance = nullptr;
+static std::shared_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecisionInstance = nullptr;
static int gFrameRenderedCallbackCalled = 0;
static int gRequestInterceptorCallbackCalled = 0;
static std::shared_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
static int gContextMenuCustomizedCallbackCalled = 0;
-static std::shared_ptr<Dali::WebEngineContextMenu> gContextMenuInstance = 0;
+static std::shared_ptr<Dali::WebEngineContextMenu> gContextMenuInstance = nullptr;
static int gContextMenuItemSelectedCallbackCalled = 0;
-static std::shared_ptr<Dali::WebEngineContextMenuItem> gContextMenuItemInstance = 0;
+static std::shared_ptr<Dali::WebEngineContextMenuItem> gContextMenuItemInstance = nullptr;
+static int gHitTestCreatedCallbackCalled = 0;
+static int gCookieManagerChangsWatchCallbackCalled = 0;
struct CallbackFunctor
{
gUrlChangedCallbackCalled++;
}
+static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
+{
+ gHitTestCreatedCallbackCalled++;
+ return true;
+}
+
static void OnPageLoadError(WebView view, std::shared_ptr<Dali::WebEngineLoadError> error)
{
gPageLoadErrorCallbackCalled++;
return true;
}
+static void OnChangesWatch()
+{
+ gCookieManagerChangsWatchCallbackCalled++;
+}
+
static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
{
gHovered = true;
return true;
}
-static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> decision)
+static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::WebEngineFormRepostDecision> decision)
{
gFormRepostDecisionCallbackCalled++;
gFormRepostDecisionInstance = std::move(decision);
END_TEST;
}
+int UtcDaliWebViewHitTest(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ // load url.
+ view.LoadUrl( TEST_URL1 );
+
+ // sync hit test.
+ std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
+ DALI_TEST_CHECK(hitTest != 0);
+ DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
+ std::string testLinkUri("http://test.html");
+ DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
+ std::string testLinkTitle("test");
+ DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
+ std::string testLinkLabel("label");
+ DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
+ std::string testImageUri("http://test.jpg");
+ DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
+ std::string testMediaUri("http://test.mp4");
+ DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
+ std::string testTagName("img");
+ 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);
+ std::string testImageFileNameExtension("jpg");
+ DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
+ Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
+ DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
+
+ // async...
+ bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
+ DALI_TEST_CHECK(result);
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliWebViewEvaluteJavaScript(void)
{
ToolkitTestApplication application;
// Reset something
context->SetProxyUri( kDefaultValue );
context->SetCertificateFilePath( kDefaultValue );
- context->DisableCache( false );
+ context->EnableCache( true );
context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
context->DeleteAllWebDatabase();
context->DeleteAllWebStorage();
context->DeleteLocalFileSystem();
context->ClearCache();
+ context->SetContextAppId( "id" );
+ context->SetContextApplicationType( Dali::WebEngineContext::ApplicationType::OTHER );
+ context->SetContextTimeOffset( 0 );
+ context->SetContextTimeZoneOffset( 0, 0 );
+ context->SetDefaultZoomFactor( 0 );
+ context->DeleteAllFormPasswordData();
+ context->DeleteAllFormCandidateData();
// Check default value
Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
value = context->GetCacheModel();
DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
+ // Get cache enabled
+ DALI_TEST_CHECK( context->IsCacheEnabled() );
+
+ // Get certificate
+ std::string str = context->GetContextCertificateFile();
+ DALI_TEST_EQUALS( str, "test", TEST_LOCATION );
+
+ // Set version
+ DALI_TEST_CHECK( context->SetContextAppVersion( "test" ) );
+
+ // Register
+ std::vector<std::string> temp;
+ context->RegisterUrlSchemesAsCorsEnabled( temp );
+ context->RegisterJsPluginMimeTypes( temp );
+ context->DeleteFormPasswordDataList( temp );
+
+ // Get zoom
+ DALI_TEST_EQUALS( context->GetContextDefaultZoomFactor(), float( 0 ), TEST_LOCATION );
+
+ // Delete cache and database
+ DALI_TEST_CHECK( context->DeleteAllApplicationCache() );
+ DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() );
+
+ // Get contextProxy
+ context->SetContextProxy("", "");
+ DALI_TEST_EQUALS( context->GetContextProxy(), "test", TEST_LOCATION );
+ DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION );
+
+ //Notify low memory
+ DALI_TEST_CHECK( context->FreeUnusedMemory() );
+
END_TEST;
}
Test::EmitGlobalTimerSignal();
DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
- result = context->DeleteWebStorageOrigin(*origin);
+ result = context->DeleteWebStorage(*origin);
DALI_TEST_CHECK( result );
result = context->DeleteApplicationCache(*origin);
END_TEST;
}
+int UtcDaliWebCookieManagerChangesWatch(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+ DALI_TEST_CHECK( cookieManager != 0 )
+
+ cookieManager->ChangesWatch(&OnChangesWatch);
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
// test cases for web settings.
int UtcDaliWebSettingsGetSetDefaultFontSize(void)
END_TEST;
}
+int UtcDaliWebSettingsSetViewportMetaTag(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Check the value is true or not
+ bool value = settings->SetViewportMetaTag(true);
+ DALI_TEST_CHECK( value );
+
+ END_TEST;
+}
+
+int UtcDaliWebSettingsSetForceZoom(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Check the value is true or not
+ bool value = settings->SetForceZoom(true);
+ DALI_TEST_CHECK( value );
+
+ value = settings->IsZoomForced();
+ DALI_TEST_CHECK( value );
+
+ END_TEST;
+}
+
+int UtcDaliWebSettingsSetTextZoomEnabled(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Check the value is true or not
+ bool value = settings->SetTextZoomEnabled(true);
+ DALI_TEST_CHECK( value );
+
+ value = settings->IsTextZoomEnabled();
+ DALI_TEST_CHECK( value );
+
+ END_TEST;
+}
+
+int UtcDaliWebSettingsSetExtraFeature(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Check the value is true or not
+ settings->SetExtraFeature("test", true);
+ bool value = settings->IsExtraFeatureEnabled("test");
+ DALI_TEST_CHECK( value );
+
+ END_TEST;
+}
+