#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/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
-#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.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 int gConsoleMessageCallbackCalled = 0;
static std::shared_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
-static int gPolicyDecisionCallbackCalled = 0;
-static std::shared_ptr<Dali::WebEnginePolicyDecision> gPolicyDecisionInstance = nullptr;
+static int gResponsePolicyDecidedCallbackCalled = 0;
+static std::shared_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
static int gCertificateConfirmCallbackCalled = 0;
static std::shared_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
static int gSslCertificateChangedCallbackCalled = 0;
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
{
gScrollEdgeReachedCallbackCalled++;
}
-static void OnPolicyDecisionRequest(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
+static void OnResponsePolicyDecided(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
{
- gPolicyDecisionCallbackCalled++;
- gPolicyDecisionInstance = std::move(decision);
+ gResponsePolicyDecidedCallbackCalled++;
+ gResponsePolicyDecisionInstance = std::move(decision);
}
static void OnUrlChanged( WebView view, const std::string& url )
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 UtcDaliWebViewPolicyDecisionRequest(void)
+int UtcDaliWebViewResponsePolicyDecisionRequest(void)
{
ToolkitTestApplication application;
// load url.
ConnectionTracker* testTracker = new ConnectionTracker();
- view.PolicyDecisionSignal().Connect( &OnPolicyDecisionRequest );
+ view.ResponsePolicyDecisionSignal().Connect( &OnResponsePolicyDecided );
bool signal1 = false;
- view.ConnectSignal( testTracker, "policyDecision", CallbackFunctor(&signal1) );
- DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 0, TEST_LOCATION );
- DALI_TEST_CHECK(gPolicyDecisionInstance == 0);
+ view.ConnectSignal( testTracker, "responsePolicyDecided", CallbackFunctor(&signal1) );
+ DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION );
+ DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
view.LoadUrl( TEST_URL1 );
Test::EmitGlobalTimerSignal();
- DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION );
DALI_TEST_CHECK( signal1 );
- // check policy decision & its frame.
- DALI_TEST_CHECK(gPolicyDecisionInstance != 0);
+ // check response policy decision & its frame.
+ DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
std::string testUrl("http://test.html");
- DALI_TEST_EQUALS(gPolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
std::string testCookie("test:abc");
- DALI_TEST_EQUALS(gPolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
- DALI_TEST_EQUALS(gPolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
std::string testResponseMime("txt/xml");
- DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
int32_t ResponseStatusCode = 500;
- DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
- DALI_TEST_EQUALS(gPolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
std::string testScheme("test");
- DALI_TEST_EQUALS(gPolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
- DALI_TEST_CHECK(gPolicyDecisionInstance->Use());
- DALI_TEST_CHECK(gPolicyDecisionInstance->Ignore());
- DALI_TEST_CHECK(gPolicyDecisionInstance->Suspend());
+ DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
+ DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
+ DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
+ DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
- Dali::WebEngineFrame* webFrame = &(gPolicyDecisionInstance->GetFrame());
+ Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
DALI_TEST_CHECK(webFrame);
DALI_TEST_CHECK(webFrame->IsMainFrame());
- gPolicyDecisionInstance = nullptr;
+ gResponsePolicyDecisionInstance = nullptr;
+
+ 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;
}
unsigned int itemCount = bfList->GetItemCount();
DALI_TEST_CHECK( itemCount == 1 )
- Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
+ std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
DALI_TEST_CHECK( citem != 0 );
+ std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
+ DALI_TEST_CHECK( citemP != 0 );
+
+ std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
+ DALI_TEST_CHECK( citemN != 0 );
+
const std::string kDefaultUrl( "http://url" );
std::string testValue = citem->GetUrl();
DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
testValue = citem->GetOriginalUrl();
DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
- Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
+ std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
DALI_TEST_CHECK( item != 0 );
+ std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
+ DALI_TEST_CHECK( vecBack.size() == 1 );
+
+ std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
+ DALI_TEST_CHECK( vecForward.size() == 1 );
+
END_TEST;
}
// 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;
+}
+