X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-WebView.cpp;h=86776ff6c211511b6609a80595d6f9862aec6904;hp=6cacfbf2341cfc675cdeb9aba9962028dd3f44e8;hb=0c8875977f6f8e8a026eacb7a9ef57d14ce8deac;hpb=64b92adb4035ab57f5ad265e0676a8ca8a23c64b diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index 6cacfbf..86776ff 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -43,7 +45,6 @@ #include #include #include -#include #include #include @@ -74,7 +75,7 @@ static bool gTouched = false; static bool gHovered = false; static bool gWheelEventHandled = false; static int gFormRepostDecisionCallbackCalled = 0; -static std::shared_ptr gFormRepostDecisionInstance = nullptr; +static std::shared_ptr gFormRepostDecisionInstance = nullptr; static int gFrameRenderedCallbackCalled = 0; static int gRequestInterceptorCallbackCalled = 0; static std::shared_ptr gRequestInterceptorInstance = nullptr; @@ -96,9 +97,11 @@ static int gMimeOverriddenCallbackCalled = 0; static std::vector> gSecurityOriginList; static std::vector> gPasswordDataList; static int gContextMenuCustomizedCallbackCalled = 0; -static std::shared_ptr gContextMenuInstance = 0; +static std::shared_ptr gContextMenuInstance = nullptr; static int gContextMenuItemSelectedCallbackCalled = 0; -static std::shared_ptr gContextMenuItemInstance = 0; +static std::shared_ptr gContextMenuItemInstance = nullptr; +static int gHitTestCreatedCallbackCalled = 0; +static int gCookieManagerChangsWatchCallbackCalled = 0; struct CallbackFunctor { @@ -145,6 +148,12 @@ static void OnUrlChanged( WebView view, const std::string& url ) gUrlChangedCallbackCalled++; } +static bool OnHitTestCreated(std::unique_ptr test) +{ + gHitTestCreatedCallbackCalled++; + return true; +} + static void OnPageLoadError(WebView view, std::shared_ptr error) { gPageLoadErrorCallbackCalled++; @@ -196,6 +205,11 @@ static bool OnTouched( Actor actor, const Dali::TouchEvent& touch ) return true; } +static void OnChangesWatch() +{ + gCookieManagerChangsWatchCallbackCalled++; +} + static bool OnHovered( Actor actor, const Dali::HoverEvent& hover ) { gHovered = true; @@ -208,7 +222,7 @@ static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheel ) return true; } -static void OnFormRepostDecision(WebView, std::shared_ptr decision) +static void OnFormRepostDecision(WebView, std::shared_ptr decision) { gFormRepostDecisionCallbackCalled++; gFormRepostDecisionInstance = std::move(decision); @@ -1335,6 +1349,50 @@ int UtcDaliWebViewPolicyDecisionRequest(void) 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 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; @@ -1525,12 +1583,19 @@ int UtcDaliWebContextGetSetCacheModel(void) // 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(); @@ -1541,6 +1606,37 @@ int UtcDaliWebContextGetSetCacheModel(void) 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 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; } @@ -1586,7 +1682,7 @@ int UtcDaliWebContextGetWebDatabaseStorageOrigins(void) 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); @@ -1644,6 +1740,23 @@ int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void) 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) @@ -2155,3 +2268,78 @@ int UtcDaliWebSettingsGetSetDefaultTextEncodingName(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; +} +