X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-WebView.cpp;h=39ebd29581fb9dc5498b50b10d96c9ee6ba2ee7f;hb=dc96b027c0d06fae091bde3f877b32a379ca2894;hp=6cacfbf2341cfc675cdeb9aba9962028dd3f44e8;hpb=64b92adb4035ab57f5ad265e0676a8ca8a23c64b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index 6cacfbf..39ebd29 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,10 @@ 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; struct CallbackFunctor { @@ -145,6 +147,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++; @@ -208,7 +216,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 +1343,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; @@ -2155,3 +2207,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; +} +