2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include "dali-toolkit-test-utils/toolkit-timer.h"
25 #include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-frame.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
34 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
35 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
36 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
37 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
38 #include <dali/integration-api/events/hover-event-integ.h>
39 #include <dali/integration-api/events/key-event-integ.h>
40 #include <dali/integration-api/events/touch-event-integ.h>
41 #include <dali/integration-api/events/wheel-event-integ.h>
42 #include <dali/public-api/images/pixel-data.h>
43 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
44 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
45 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
46 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
48 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
49 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
52 using namespace Toolkit;
57 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
58 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
60 static int gPageLoadStartedCallbackCalled = 0;
61 static int gPageLoadInProgressCallbackCalled = 0;
62 static int gPageLoadFinishedCallbackCalled = 0;
63 static int gPageLoadErrorCallbackCalled = 0;
64 static std::unique_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
65 static int gScrollEdgeReachedCallbackCalled = 0;
66 static int gUrlChangedCallbackCalled = 0;
67 static int gEvaluateJavaScriptCallbackCalled = 0;
68 static int gJavaScriptAlertCallbackCalled = 0;
69 static int gJavaScriptConfirmCallbackCalled = 0;
70 static int gJavaScriptPromptCallbackCalled = 0;
71 static int gScreenshotCapturedCallbackCalled = 0;
72 static int gVideoPlayingCallbackCalled = 0;
73 static int gGeolocationPermissionCallbackCalled = 0;
74 static bool gTouched = false;
75 static bool gHovered = false;
76 static bool gWheelEventHandled = false;
77 static int gFormRepostDecidedCallbackCalled = 0;
78 static std::unique_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecidedInstance = nullptr;
79 static int gFrameRenderedCallbackCalled = 0;
80 static int gConsoleMessageCallbackCalled = 0;
81 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
82 static int gResponsePolicyDecidedCallbackCalled = 0;
83 static int gNavigationPolicyDecidedCallbackCalled = 0;
84 static std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
85 static int gCertificateConfirmCallbackCalled = 0;
86 static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
87 static int gSslCertificateChangedCallbackCalled = 0;
88 static std::unique_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
89 static int gHttpAuthHandlerCallbackCalled = 0;
90 static std::unique_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
91 static int gSecurityOriginsAcquiredCallbackCalled = 0;
92 static int gStorageUsageAcquiredCallbackCalled = 0;
93 static int gFormPasswordsAcquiredCallbackCalled = 0;
94 static int gDownloadStartedCallbackCalled = 0;
95 static int gMimeOverriddenCallbackCalled = 0;
96 static int gRequestInterceptedCallbackCalled = 0;
97 static Dali::WebEngineRequestInterceptorPtr gRequestInterceptorInstance = nullptr;
98 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
99 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
100 static int gContextMenuShownCallbackCalled = 0;
101 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuShownInstance = nullptr;
102 static int gContextMenuHiddenCallbackCalled = 0;
103 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuHiddenInstance = nullptr;
104 static int gHitTestCreatedCallbackCalled = 0;
105 static int gCookieManagerChangsWatchCallbackCalled = 0;
106 static int gPlainTextReceivedCallbackCalled = 0;
108 struct CallbackFunctor
110 CallbackFunctor(bool* callbackFlag)
111 : mCallbackFlag( callbackFlag )
117 *mCallbackFlag = true;
122 static void OnPageLoadStarted(const std::string& url)
124 gPageLoadStartedCallbackCalled++;
127 static void OnPageLoadInProgress(const std::string& url)
129 gPageLoadInProgressCallbackCalled++;
132 static void OnPageLoadFinished(const std::string& url)
134 gPageLoadFinishedCallbackCalled++;
137 static void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
139 gScrollEdgeReachedCallbackCalled++;
142 static void OnResponsePolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
144 gResponsePolicyDecidedCallbackCalled++;
145 gResponsePolicyDecisionInstance = std::move(decision);
148 static void OnNavigationPolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
150 gNavigationPolicyDecidedCallbackCalled++;
153 static void OnUrlChanged(const std::string& url)
155 gUrlChangedCallbackCalled++;
158 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
160 gHitTestCreatedCallbackCalled++;
164 static bool OnPlainTextReceived(const std::string& plainText)
166 gPlainTextReceivedCallbackCalled++;
170 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
172 gPageLoadErrorCallbackCalled++;
173 gPageLoadErrorInstance = std::move(error);
176 static void OnEvaluateJavaScript(const std::string& result)
178 gEvaluateJavaScriptCallbackCalled++;
181 static bool OnJavaScriptAlert(const std::string& result)
183 gJavaScriptAlertCallbackCalled++;
187 static bool OnJavaScriptConfirm(const std::string& result)
189 gJavaScriptConfirmCallbackCalled++;
193 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
195 gJavaScriptPromptCallbackCalled++;
199 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
201 gScreenshotCapturedCallbackCalled++;
204 static void OnVideoPlaying(bool isPlaying)
206 gVideoPlayingCallbackCalled++;
209 static bool OnGeolocationPermission(const std::string&, const std::string&)
211 gGeolocationPermissionCallbackCalled++;
215 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
221 static void OnChangesWatch()
223 gCookieManagerChangsWatchCallbackCalled++;
226 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
232 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
234 gWheelEventHandled = true;
238 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
240 gFormRepostDecidedCallbackCalled++;
241 gFormRepostDecidedInstance = std::move(decision);
244 static void OnFrameRendered()
246 gFrameRenderedCallbackCalled++;
249 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
251 gConsoleMessageCallbackCalled++;
252 gConsoleMessageInstance = std::move(message);
255 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
257 gCertificateConfirmCallbackCalled++;
258 gCertificateConfirmInstance = std::move(certificate);
261 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
263 gSslCertificateChangedCallbackCalled++;
264 gSslCertificateInstance = std::move(certificate);
267 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
269 gHttpAuthHandlerCallbackCalled++;
270 gHttpAuthInstance = std::move(hander);
273 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
275 gSecurityOriginsAcquiredCallbackCalled++;
276 gSecurityOriginList.clear();
277 gSecurityOriginList.swap(origins);
280 static void OnStorageUsageAcquired(uint64_t usage)
282 gStorageUsageAcquiredCallbackCalled++;
285 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
287 gFormPasswordsAcquiredCallbackCalled++;
288 gPasswordDataList.clear();
289 gPasswordDataList.swap(passwords);
292 static void OnDownloadStarted(const std::string& url)
294 gDownloadStartedCallbackCalled++;
297 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
299 gMimeOverriddenCallbackCalled++;
303 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
305 gRequestInterceptedCallbackCalled++;
306 gRequestInterceptorInstance = interceptor;
310 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
312 gContextMenuShownCallbackCalled++;
313 gContextMenuShownInstance = std::move(menu);
316 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
318 gContextMenuHiddenCallbackCalled++;
319 gContextMenuHiddenInstance = std::move(menu);
324 void web_view_startup(void)
326 test_return_value = TET_UNDEF;
329 void web_view_cleanup(void)
331 test_return_value = TET_PASS;
334 int UtcDaliWebViewBasics(void)
336 ToolkitTestApplication application;
338 // Copy and Assignment Test
339 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
340 WebView view = WebView::New();
341 DALI_TEST_CHECK( view );
343 WebView copy( view );
344 DALI_TEST_CHECK( view == copy );
347 DALI_TEST_CHECK( !assign );
350 DALI_TEST_CHECK( assign == view );
353 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
354 BaseHandle handle(view);
356 WebView view2 = WebView::DownCast( handle );
357 DALI_TEST_CHECK( view );
358 DALI_TEST_CHECK( view2 );
359 DALI_TEST_CHECK( view == view2 );
362 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
363 TypeRegistry typeRegistry = TypeRegistry::Get();
364 DALI_TEST_CHECK( typeRegistry );
366 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
367 DALI_TEST_CHECK( typeInfo );
369 BaseHandle handle2 = typeInfo.CreateInstance();
370 DALI_TEST_CHECK( handle2 );
372 WebView view3 = WebView::DownCast( handle2 );
373 DALI_TEST_CHECK( view3 );
378 int UtcDaliWebViewPageNavigation(void)
380 ToolkitTestApplication application;
382 WebView view = WebView::New();
383 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
384 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
385 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
386 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
387 application.GetScene().Add( view );
388 application.SendNotification();
389 application.Render();
390 DALI_TEST_CHECK( view );
392 view.RegisterPageLoadStartedCallback( &OnPageLoadStarted );
393 view.RegisterPageLoadInProgressCallback( &OnPageLoadInProgress );
394 view.RegisterPageLoadFinishedCallback( &OnPageLoadFinished );
395 view.RegisterUrlChangedCallback( &OnUrlChanged );
396 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
397 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
398 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
399 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
401 view.LoadUrl( TEST_URL1 );
402 view.GetNaturalSize();
403 Test::EmitGlobalTimerSignal();
404 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
405 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
406 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
407 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
408 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
410 view.LoadUrl( TEST_URL2 );
412 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
413 application.SendNotification();
414 application.Render();
415 Test::EmitGlobalTimerSignal();
417 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
418 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
419 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
420 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
421 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
422 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
425 Test::EmitGlobalTimerSignal();
426 DALI_TEST_CHECK( !view.CanGoBack() );
427 DALI_TEST_CHECK( view.CanGoForward() );
430 Test::EmitGlobalTimerSignal();
431 DALI_TEST_CHECK( view.CanGoBack() );
432 DALI_TEST_CHECK( !view.CanGoForward() );
437 Test::EmitGlobalTimerSignal();
438 DALI_TEST_CHECK( !view.CanGoBack() );
439 DALI_TEST_CHECK( !view.CanGoForward() );
444 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
446 ToolkitTestApplication application;
448 WebView view = WebView::New();
449 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
450 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
451 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
452 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
453 application.GetScene().Add( view );
454 application.SendNotification();
455 application.Render();
456 DALI_TEST_CHECK( view );
458 view.RegisterPageLoadErrorCallback( &OnPageLoadError );
459 view.RegisterConsoleMessageReceivedCallback( &OnConsoleMessage );
460 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
461 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
463 view.LoadUrl( TEST_URL1 );
464 Test::EmitGlobalTimerSignal();
465 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
466 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
469 DALI_TEST_CHECK(gPageLoadErrorInstance);
470 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
471 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
472 std::string testErrorDescription("This is an error.");
473 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
474 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
477 DALI_TEST_CHECK(gConsoleMessageInstance);
478 std::string testConsoleSource("source");
479 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
480 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
481 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
482 std::string testConsoleText("This is a text.");
483 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
486 gPageLoadErrorInstance = nullptr;
487 gConsoleMessageInstance = nullptr;
492 int UtcDaliWebViewTouchAndKeys(void)
494 ToolkitTestApplication application;
496 WebView view = WebView::New();
497 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
498 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
499 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
500 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
502 application.GetScene().Add( view );
503 application.SendNotification();
504 application.Render();
506 view.GetNaturalSize();
507 view.TouchedSignal().Connect( &OnTouched );
510 Dali::Integration::TouchEvent event;
511 Dali::Integration::Point pointDown, pointUp;
513 event = Dali::Integration::TouchEvent();
514 pointDown.SetState( PointState::DOWN );
515 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
516 event.AddPoint( pointDown );
517 application.ProcessEvent( event );
519 event = Dali::Integration::TouchEvent();
520 pointUp.SetState( PointState::UP );
521 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
522 event.AddPoint( pointUp );
523 application.ProcessEvent( event );
526 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
527 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
528 application.SendNotification();
530 DALI_TEST_CHECK( gTouched );
531 DALI_TEST_CHECK( view );
536 int UtcDaliWebViewFocusGainedAndLost(void)
538 ToolkitTestApplication application;
540 WebView view = WebView::New();
541 DALI_TEST_CHECK( view );
543 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
544 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
545 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
546 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
548 application.GetScene().Add( view );
549 application.SendNotification();
550 application.Render();
552 view.SetKeyInputFocus();
553 DALI_TEST_CHECK( view.HasKeyInputFocus() );
556 view.ClearKeyInputFocus();
557 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
562 int UtcDaliWebViewPropertyPageZoomFactor(void)
564 ToolkitTestApplication application;
566 WebView view = WebView::New();
567 DALI_TEST_CHECK( view );
569 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
570 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
571 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
572 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
574 application.GetScene().Add( view );
575 application.SendNotification();
576 application.Render();
578 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
579 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
580 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
582 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
583 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
584 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
589 int UtcDaliWebViewPropertyTextZoomFactor(void)
591 ToolkitTestApplication application;
593 WebView view = WebView::New();
594 DALI_TEST_CHECK( view );
596 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
597 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
598 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
599 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
601 application.GetScene().Add( view );
602 application.SendNotification();
603 application.Render();
605 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
606 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
607 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
609 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
610 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
611 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
616 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
618 ToolkitTestApplication application;
620 WebView view = WebView::New();
621 DALI_TEST_CHECK( view );
623 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
624 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
625 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
626 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
628 application.GetScene().Add( view );
629 application.SendNotification();
630 application.Render();
632 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
633 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
638 int UtcDaliWebViewMove(void)
640 ToolkitTestApplication application;
642 WebView view = WebView::New();
643 DALI_TEST_CHECK( view );
645 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
646 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
647 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
648 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
650 application.GetScene().Add( view );
651 application.SendNotification();
652 application.Render();
654 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
655 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
656 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
661 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
663 ToolkitTestApplication application;
665 WebView view = WebView::New();
666 DALI_TEST_CHECK( view );
668 const bool kDefaultValue = false;
669 const bool kTestValue = true;
671 // Check default value
673 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
674 DALI_TEST_CHECK( value.Get( output ) );
675 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
677 // Check Set/GetProperty
678 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
679 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
680 DALI_TEST_CHECK( value.Get( output ) );
681 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
686 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
688 ToolkitTestApplication application;
690 WebView view = WebView::New();
691 DALI_TEST_CHECK( view );
693 const bool kDefaultValue = true;
694 const bool kTestValue = false;
696 // Check default value
698 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
699 DALI_TEST_CHECK( value.Get( output ) );
700 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
702 // Check Set/GetProperty
703 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
704 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
705 DALI_TEST_CHECK( value.Get( output ) );
706 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
711 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
713 ToolkitTestApplication application;
715 WebView view = WebView::New();
716 DALI_TEST_CHECK( view );
718 const bool kDefaultValue = true;
719 const bool kTestValue = false;
721 // Check default value
723 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
724 DALI_TEST_CHECK( value.Get( output ) );
725 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
727 // Check Set/GetProperty
728 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
729 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
730 DALI_TEST_CHECK( value.Get( output ) );
731 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
736 int UtcDaliWebViewHoverAndWheel(void)
738 ToolkitTestApplication application;
740 WebView view = WebView::New();
741 DALI_TEST_CHECK( view );
742 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
743 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
744 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
745 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
747 application.GetScene().Add( view );
748 application.SendNotification();
749 application.Render();
751 view.GetNaturalSize();
752 view.HoveredSignal().Connect( &OnHovered );
753 view.WheelEventSignal().Connect( &OnWheelEvent );
756 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
757 Dali::Integration::Point pointDown;
758 pointDown.SetState( PointState::DOWN );
759 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
760 event.AddPoint( pointDown );
761 application.ProcessEvent( event );
763 event = Dali::Integration::HoverEvent();
764 Dali::Integration::Point pointUp;
765 pointUp.SetState( PointState::UP );
766 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
767 event.AddPoint( pointUp );
768 application.ProcessEvent( event );
770 event = Dali::Integration::HoverEvent();
771 Dali::Integration::Point pointMotion;
772 pointUp.SetState( PointState::MOTION );
773 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
774 event.AddPoint( pointMotion );
775 application.ProcessEvent( event );
778 Dali::Integration::WheelEvent wheelEvent;
779 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
780 wheelEvent.direction = 0;
781 wheelEvent.point = Vector2( 20, 20 );
782 wheelEvent.delta = 10;
783 application.ProcessEvent( wheelEvent );
784 application.SendNotification();
786 DALI_TEST_CHECK( gHovered );
787 DALI_TEST_CHECK( gWheelEventHandled );
792 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
794 ToolkitTestApplication application;
796 WebView view = WebView::New();
797 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
798 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
799 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
800 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
801 application.GetScene().Add( view );
802 application.SendNotification();
803 application.Render();
804 DALI_TEST_CHECK( view );
806 view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
807 view.RegisterFrameRenderedCallback(&OnFrameRendered);
808 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION );
809 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
811 view.LoadUrl( TEST_URL1 );
812 Test::EmitGlobalTimerSignal();
813 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION );
814 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
816 // form repost decision.
817 DALI_TEST_CHECK(gFormRepostDecidedInstance);
818 gFormRepostDecidedInstance->Reply(true);
821 gFormRepostDecidedInstance = nullptr;
826 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
828 ToolkitTestApplication application;
830 WebView view = WebView::New();
831 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
832 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
833 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
834 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
835 application.GetScene().Add( view );
836 application.SendNotification();
837 application.Render();
838 DALI_TEST_CHECK( view );
840 view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
841 view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
842 view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
843 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
844 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
845 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
847 view.LoadUrl( TEST_URL1 );
848 Test::EmitGlobalTimerSignal();
849 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
850 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
851 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
854 DALI_TEST_CHECK(gCertificateConfirmInstance);
855 gCertificateConfirmInstance->Allow(true);
856 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
858 DALI_TEST_CHECK(gSslCertificateInstance);
859 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
860 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
862 // http authentication.
863 DALI_TEST_CHECK(gHttpAuthInstance);
864 gHttpAuthInstance->Suspend();
865 gHttpAuthInstance->UseCredential("", "");
866 gHttpAuthInstance->CancelCredential();
867 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
870 gCertificateConfirmInstance = nullptr;
871 gSslCertificateInstance = nullptr;
872 gHttpAuthInstance = nullptr;
877 int UtcDaliWebViewGetWebBackForwardList(void)
879 ToolkitTestApplication application;
881 WebView view = WebView::New();
882 DALI_TEST_CHECK( view );
884 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
885 DALI_TEST_CHECK( bfList != 0 );
890 int UtcDaliWebViewGetWebContext(void)
892 ToolkitTestApplication application;
894 WebView view = WebView::New();
895 DALI_TEST_CHECK( view );
897 Dali::Toolkit::WebContext* context = view.GetContext();
898 DALI_TEST_CHECK( context != 0 );
903 int UtcDaliWebViewGetWebCookieManager(void)
905 ToolkitTestApplication application;
907 WebView view = WebView::New();
908 DALI_TEST_CHECK( view );
910 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
911 DALI_TEST_CHECK( cookieManager != 0 );
916 int UtcDaliWebViewGetWebSettings(void)
918 ToolkitTestApplication application;
920 WebView view = WebView::New();
921 DALI_TEST_CHECK( view );
923 Dali::Toolkit::WebSettings* settings = view.GetSettings();
924 DALI_TEST_CHECK( settings != 0 );
929 int UtcDaliWebViewProperty1(void)
932 ToolkitTestApplication application;
934 WebView view = WebView::New();
935 DALI_TEST_CHECK( view );
938 view.SetProperty( WebView::Property::URL, TEST_URL1 );
939 Property::Value val = view.GetProperty( WebView::Property::URL );
940 DALI_TEST_CHECK( val.Get( local ) );
941 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
946 int UtcDaliWebViewProperty4(void)
949 ToolkitTestApplication application;
951 WebView view = WebView::New();
952 DALI_TEST_CHECK( view );
954 const std::string kDefaultValue;
955 const std::string kTestValue = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
957 // Check default value
959 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
960 DALI_TEST_CHECK( value.Get( output ) );
961 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
963 // Check Set/GetProperty
964 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
965 value = view.GetProperty( WebView::Property::USER_AGENT );
966 DALI_TEST_CHECK( value.Get( output ) );
967 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
972 int UtcDaliWebViewProperty9(void)
975 ToolkitTestApplication application;
977 WebView view = WebView::New();
978 DALI_TEST_CHECK( view );
980 // Check default value
981 Dali::Vector2 output = Dali::Vector2::ONE;
982 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
983 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
985 // Check Set/GetProperty
986 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
987 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
988 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
989 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
991 // Check default value of scroll size
992 output = Dali::Vector2::ONE;
993 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
994 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
996 // Check default value of content size
997 output = Dali::Vector2::ONE;
998 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
999 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1004 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1006 ToolkitTestApplication application;
1008 WebView view = WebView::New();
1009 DALI_TEST_CHECK( view );
1011 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1012 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1013 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1014 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1015 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1017 // Check default value
1018 std::string testText("test");
1020 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1021 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1026 int UtcDaliWebViewPropertyTitleFavicon(void)
1028 ToolkitTestApplication application;
1030 char argv[] = "--test";
1031 WebView view = WebView::New( 1, (char**)&argv );
1032 DALI_TEST_CHECK( view );
1035 view.ClearAllTilesResources();
1037 // Check default value of title
1038 std::string testValue("title");
1040 view.GetProperty( WebView::Property::TITLE ).Get( output );
1041 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1043 // Check the case that favicon is not null.
1044 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1045 DALI_TEST_CHECK( favicon );
1046 Dali::Vector3 iconsize = favicon.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1047 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1049 // Check the case that favicon is null.
1050 favicon = view.GetFavicon();
1051 DALI_TEST_CHECK( !favicon );
1056 int UtcDaliWebViewContextMenuShownAndHidden(void)
1058 ToolkitTestApplication application;
1060 WebView view = WebView::New();
1061 DALI_TEST_CHECK( view );
1064 view.RegisterContextMenuShownCallback( &OnContextMenuShown );
1065 view.RegisterContextMenuHiddenCallback( &OnContextMenuHidden );
1066 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 0, TEST_LOCATION );
1067 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION );
1068 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1069 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1071 view.LoadUrl( TEST_URL1 );
1072 Test::EmitGlobalTimerSignal();
1073 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 1, TEST_LOCATION );
1074 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION );
1076 // check context meun & its items.
1077 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1078 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1079 DALI_TEST_CHECK(item.get() != 0);
1080 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1081 DALI_TEST_CHECK(itemList.size() == 1);
1082 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1083 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1084 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1085 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1086 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1088 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1089 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1090 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1091 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1092 DALI_TEST_CHECK(item->IsEnabled());
1093 std::string testLinkUrl("http://test.html");
1094 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1095 std::string testImageUrl("http://test.jpg");
1096 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1097 std::string testTitle("title");
1098 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1099 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1101 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1103 gContextMenuShownInstance = nullptr;
1104 gContextMenuHiddenInstance = nullptr;
1109 int UtcDaliWebViewScrollBy(void)
1111 ToolkitTestApplication application;
1113 WebView view = WebView::New();
1114 DALI_TEST_CHECK( view );
1117 view.RegisterScrollEdgeReachedCallback( &OnScrollEdgeReached );
1118 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1120 view.LoadUrl( TEST_URL1 );
1121 Test::EmitGlobalTimerSignal();
1123 // set scroll position.
1124 Dali::Vector2 output = Dali::Vector2::ONE;
1125 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1126 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1127 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1128 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1130 // scroll by and trigger scrollEdgeReached event.
1131 view.ScrollBy( 50, 50 );
1132 Test::EmitGlobalTimerSignal();
1134 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1135 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1136 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1138 // scroll by and trigger scrollEdgeReached event.
1139 bool result = view.ScrollEdgeBy( 50, 50 );
1140 DALI_TEST_CHECK( result );
1141 Test::EmitGlobalTimerSignal();
1143 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1144 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1145 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1150 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1152 ToolkitTestApplication application;
1154 WebView view = WebView::New();
1155 DALI_TEST_CHECK( view );
1157 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1158 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1159 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1160 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1162 application.GetScene().Add( view );
1163 application.SendNotification();
1164 application.Render();
1166 view.ActivateAccessibility(true);
1167 view.AddDynamicCertificatePath("host", "test/to/path");
1168 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1169 DALI_TEST_CHECK( found );
1171 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1172 float result = view.GetScaleFactor();
1173 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1175 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1176 result = view.GetScaleFactor();
1177 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1182 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1185 ToolkitTestApplication application;
1187 char argv[] = "--test";
1188 WebView view = WebView::New( 1, (char**)&argv );
1189 DALI_TEST_CHECK( view );
1191 // Check GetScreenshot
1192 Dali::Rect<int> viewArea;
1195 viewArea.width = 10;
1196 viewArea.height = 10;
1197 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1198 DALI_TEST_CHECK( screenshot );
1199 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1200 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1202 // Check GetScreenshotAsynchronously
1205 viewArea.width = 100;
1206 viewArea.height = 100;
1207 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1208 DALI_TEST_CHECK( result );
1210 Test::EmitGlobalTimerSignal();
1212 Test::EmitGlobalTimerSignal();
1213 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1218 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1221 ToolkitTestApplication application;
1223 char argv[] = "--test";
1224 WebView view = WebView::New( 1, (char**)&argv );
1225 DALI_TEST_CHECK( view );
1227 // Check CheckVideoPlayingAsynchronously
1228 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1229 DALI_TEST_CHECK( result );
1230 Test::EmitGlobalTimerSignal();
1231 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1233 // Check RegisterGeolocationPermissionCallback
1234 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1235 Test::EmitGlobalTimerSignal();
1236 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1241 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1243 ToolkitTestApplication application;
1245 WebView view = WebView::New();
1246 DALI_TEST_CHECK( view );
1249 view.RegisterResponsePolicyDecidedCallback( &OnResponsePolicyDecided );
1250 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION );
1251 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1253 view.LoadUrl( TEST_URL1 );
1254 Test::EmitGlobalTimerSignal();
1255 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION );
1257 // check response policy decision & its frame.
1258 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1259 std::string testUrl("http://test.html");
1260 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1261 std::string testCookie("test:abc");
1262 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1263 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1264 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1265 std::string testResponseMime("txt/xml");
1266 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1267 int32_t ResponseStatusCode = 500;
1268 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1269 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1270 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1271 std::string testScheme("test");
1272 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1273 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1274 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1275 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1277 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1278 DALI_TEST_CHECK(webFrame);
1279 DALI_TEST_CHECK(webFrame->IsMainFrame());
1281 gResponsePolicyDecisionInstance = nullptr;
1286 int UtcDaliWebViewNavigationPolicyDecisionRequest(void)
1288 ToolkitTestApplication application;
1290 WebView view = WebView::New();
1291 DALI_TEST_CHECK(view);
1294 view.RegisterNavigationPolicyDecidedCallback(&OnNavigationPolicyDecided);
1295 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1297 view.LoadUrl(TEST_URL1);
1298 Test::EmitGlobalTimerSignal();
1299 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1304 int UtcDaliWebViewHitTest(void)
1306 ToolkitTestApplication application;
1308 WebView view = WebView::New();
1309 DALI_TEST_CHECK( view );
1312 view.LoadUrl( TEST_URL1 );
1315 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1316 DALI_TEST_CHECK(hitTest != 0);
1317 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1318 std::string testLinkUri("http://test.html");
1319 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1320 std::string testLinkTitle("test");
1321 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1322 std::string testLinkLabel("label");
1323 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1324 std::string testImageUri("http://test.jpg");
1325 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1326 std::string testMediaUri("http://test.mp4");
1327 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1328 std::string testTagName("img");
1329 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1330 std::string testNodeValue("test");
1331 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1332 Dali::Property::Map testMap = hitTest->GetAttributes();
1333 DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
1334 std::string testImageFileNameExtension("jpg");
1335 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1336 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1337 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1340 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1341 DALI_TEST_CHECK(result);
1342 Test::EmitGlobalTimerSignal();
1343 DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
1348 int UtcDaliWebViewEvaluteJavaScript(void)
1350 ToolkitTestApplication application;
1352 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1354 view.LoadHtmlString( "<body>Hello World!</body>" );
1355 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1356 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1357 Test::EmitGlobalTimerSignal();
1359 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1364 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1366 ToolkitTestApplication application;
1368 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1370 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1371 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1372 view.JavaScriptAlertReply();
1373 Test::EmitGlobalTimerSignal();
1374 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1376 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1377 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1378 view.JavaScriptConfirmReply( true );
1379 Test::EmitGlobalTimerSignal();
1380 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1382 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1383 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1384 view.JavaScriptPromptReply( "it is a prompt." );
1385 Test::EmitGlobalTimerSignal();
1386 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1391 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1393 ToolkitTestApplication application;
1395 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1396 DALI_TEST_CHECK( view );
1398 std::string html("<body>Hello World!</body>");
1399 std::string basicUri("http://basicurl");
1400 std::string unreachableUrl("http://unreachableurl");
1401 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1402 DALI_TEST_CHECK( result );
1404 application.SendNotification();
1405 application.Render();
1406 Test::EmitGlobalTimerSignal();
1408 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1409 DALI_TEST_CHECK( result );
1414 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1416 ToolkitTestApplication application;
1418 WebView view = WebView::New();
1419 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1420 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1421 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1422 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1424 application.GetScene().Add( view );
1425 application.SendNotification();
1426 application.Render();
1427 DALI_TEST_CHECK( view );
1429 view.LoadUrl( "http://test.html" );
1430 bool result = view.AddCustomHeader("key", "value");
1431 DALI_TEST_CHECK( result );
1433 result = view.ReloadWithoutCache();
1434 DALI_TEST_CHECK( result );
1436 uint32_t portNumber = view.StartInspectorServer(5000);
1437 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1439 application.SendNotification();
1440 application.Render();
1441 Test::EmitGlobalTimerSignal();
1443 result = view.StopInspectorServer();
1444 DALI_TEST_CHECK( result );
1446 view.SuspendNetworkLoading();
1448 result = view.RemoveCustomHeader("key");
1449 DALI_TEST_CHECK( result );
1451 view.ResumeNetworkLoading();
1456 int UtcDaliWebViewMethodsForCoverage(void)
1458 ToolkitTestApplication application;
1460 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1462 view.LoadHtmlString( "<body>Hello World!</body>" );
1463 view.AddJavaScriptMessageHandler( "jsObject",
1464 []( const std::string& arg ) {
1467 view.SetTtsFocus(true);
1469 DALI_TEST_CHECK( view );
1474 // test cases for web backforward list.
1476 int UtcDaliWebBackForwardListCheckItem(void)
1478 ToolkitTestApplication application;
1480 WebView view = WebView::New();
1481 DALI_TEST_CHECK( view );
1483 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1484 DALI_TEST_CHECK( bfList != 0 )
1486 unsigned int itemCount = bfList->GetItemCount();
1487 DALI_TEST_CHECK( itemCount == 1 )
1489 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1490 DALI_TEST_CHECK( citem != 0 );
1492 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1493 DALI_TEST_CHECK( citemP != 0 );
1495 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1496 DALI_TEST_CHECK( citemN != 0 );
1498 const std::string kDefaultUrl( "http://url" );
1499 std::string testValue = citem->GetUrl();
1500 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1502 const std::string kDefaultTitle( "title" );
1503 testValue = citem->GetTitle();
1504 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1506 const std::string kDefaultOriginalUrl( "http://originalurl" );
1507 testValue = citem->GetOriginalUrl();
1508 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1510 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1511 DALI_TEST_CHECK( item != 0 );
1513 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1514 DALI_TEST_CHECK( vecBack.size() == 1 );
1516 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1517 DALI_TEST_CHECK( vecForward.size() == 1 );
1522 // test cases for web context.
1524 int UtcDaliWebContextGetSetCacheModel(void)
1526 ToolkitTestApplication application;
1528 WebView view = WebView::New();
1529 DALI_TEST_CHECK( view );
1531 Dali::Toolkit::WebContext* context = view.GetContext();
1532 DALI_TEST_CHECK( context != 0 )
1534 std::string kDefaultValue;
1537 context->SetAppId( "id" );
1538 context->SetApplicationType( Dali::WebEngineContext::ApplicationType::OTHER );
1539 context->SetTimeOffset( 0 );
1540 context->SetTimeZoneOffset( 0, 0 );
1541 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1542 context->DeleteAllWebDatabase();
1543 context->DeleteAllWebStorage();
1544 context->DeleteLocalFileSystem();
1545 context->ClearCache();
1546 context->DeleteAllFormPasswordData();
1547 context->DeleteAllFormCandidateData();
1549 // Check default value
1550 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1551 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1553 // Check Set/GetProperty
1554 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1555 value = context->GetCacheModel();
1556 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1558 // Get cache enabled
1559 context->EnableCache( true );
1560 DALI_TEST_CHECK( context->IsCacheEnabled() );
1563 context->SetCertificateFilePath( "test" );
1564 std::string str = context->GetCertificateFilePath();
1565 DALI_TEST_EQUALS( str, "test", TEST_LOCATION );
1568 DALI_TEST_CHECK( context->SetAppVersion( "test" ) );
1571 std::vector<std::string> temp;
1572 context->RegisterUrlSchemesAsCorsEnabled( temp );
1573 context->RegisterJsPluginMimeTypes( temp );
1574 context->DeleteFormPasswordDataList( temp );
1577 context->SetDefaultZoomFactor( 1.0f );
1578 DALI_TEST_EQUALS( context->GetDefaultZoomFactor(), float( 1.0f ), TEST_LOCATION );
1580 // Delete cache and database
1581 DALI_TEST_CHECK( context->DeleteAllApplicationCache() );
1582 DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() );
1585 context->SetProxyUri( "test" );
1586 DALI_TEST_EQUALS( context->GetProxyUri(), "test", TEST_LOCATION );
1587 context->SetProxyBypassRule("", "test");
1588 DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION );
1591 DALI_TEST_CHECK( context->FreeUnusedMemory() );
1596 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1598 ToolkitTestApplication application;
1600 WebView view = WebView::New();
1601 DALI_TEST_CHECK( view );
1603 Dali::Toolkit::WebContext* context = view.GetContext();
1604 DALI_TEST_CHECK( context != 0 )
1606 std::string kDefaultValue;
1608 // get origins of web database
1609 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1610 DALI_TEST_CHECK( result );
1612 Test::EmitGlobalTimerSignal();
1613 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1614 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1616 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1617 DALI_TEST_CHECK( origin );
1619 result = context->DeleteWebDatabase(*origin);
1620 DALI_TEST_CHECK( result );
1622 // get origins of web storage
1623 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1624 DALI_TEST_CHECK( result );
1626 Test::EmitGlobalTimerSignal();
1627 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1628 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1630 origin = gSecurityOriginList[0].get();
1631 DALI_TEST_CHECK( origin );
1633 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1634 DALI_TEST_CHECK( result );
1635 Test::EmitGlobalTimerSignal();
1636 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1638 result = context->DeleteWebStorage(*origin);
1639 DALI_TEST_CHECK( result );
1641 result = context->DeleteApplicationCache(*origin);
1642 DALI_TEST_CHECK( result );
1644 // form passwords, download state, mime type.
1645 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1646 Test::EmitGlobalTimerSignal();
1647 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1648 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1649 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1650 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1652 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1653 Test::EmitGlobalTimerSignal();
1654 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1656 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1657 Test::EmitGlobalTimerSignal();
1658 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1660 gSecurityOriginList.clear();
1661 gPasswordDataList.clear();
1666 int UtcDaliWebContextHttpRequestInterceptor(void)
1668 ToolkitTestApplication application;
1670 WebView view = WebView::New();
1671 DALI_TEST_CHECK( view );
1673 Dali::Toolkit::WebContext* context = view.GetContext();
1674 DALI_TEST_CHECK( context != 0 )
1677 context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1678 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1679 DALI_TEST_CHECK(!gRequestInterceptorInstance);
1681 Test::EmitGlobalTimerSignal();
1682 DALI_TEST_EQUALS( gRequestInterceptedCallbackCalled, 1, TEST_LOCATION );
1684 // check request interceptor.
1685 DALI_TEST_CHECK(gRequestInterceptorInstance);
1686 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1687 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1688 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
1689 Dali::Property::Map testHeaders;
1690 testHeaders.Insert("key2", "value2");
1691 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
1692 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1693 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", "test", 4));
1694 DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk("test", 4));
1695 std::string testUrl("http://test.html");
1696 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1697 std::string testMethod("GET");
1698 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
1699 Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
1700 DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
1702 gRequestInterceptorInstance = nullptr;
1707 // test cases for web cookie manager.
1709 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1711 ToolkitTestApplication application;
1713 WebView view = WebView::New();
1714 DALI_TEST_CHECK( view );
1716 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1717 DALI_TEST_CHECK( cookieManager != 0 )
1719 const std::string kDefaultValue;
1722 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1723 cookieManager->ClearCookies();
1725 // Check default value
1726 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1727 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1729 // Check Set/GetProperty
1730 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1731 value = cookieManager->GetCookieAcceptPolicy();
1732 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1737 int UtcDaliWebCookieManagerChangesWatch(void)
1739 ToolkitTestApplication application;
1741 WebView view = WebView::New();
1742 DALI_TEST_CHECK( view );
1744 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1745 DALI_TEST_CHECK( cookieManager != 0 )
1747 cookieManager->ChangesWatch(&OnChangesWatch);
1748 Test::EmitGlobalTimerSignal();
1749 DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
1754 // test cases for web settings.
1756 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1758 ToolkitTestApplication application;
1760 WebView view = WebView::New();
1761 DALI_TEST_CHECK( view );
1763 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1764 DALI_TEST_CHECK( settings != 0 )
1767 settings->AllowMixedContents( false );
1768 settings->EnableSpatialNavigation( false );
1769 settings->EnableWebSecurity( false );
1770 settings->EnableCacheBuilder( false );
1771 settings->EnableDoNotTrack( false );
1772 settings->UseScrollbarThumbFocusNotifications( false );
1773 settings->AllowFileAccessFromExternalUrl( false );
1774 settings->AllowScriptsOpenWindows( false );
1776 // Check default value
1777 int value = settings->GetDefaultFontSize();
1778 DALI_TEST_CHECK( value == 16 );
1780 // Check Set/GetProperty
1781 settings->SetDefaultFontSize( 20 );
1782 value = settings->GetDefaultFontSize();
1783 DALI_TEST_CHECK( value == 20 );
1788 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1790 ToolkitTestApplication application;
1792 WebView view = WebView::New();
1793 DALI_TEST_CHECK( view );
1795 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1796 DALI_TEST_CHECK( settings != 0 )
1799 settings->AllowMixedContents( false );
1800 settings->EnableSpatialNavigation( false );
1801 settings->EnableWebSecurity( false );
1802 settings->EnableCacheBuilder( false );
1803 settings->EnableDoNotTrack( false );
1804 settings->UseScrollbarThumbFocusNotifications( false );
1805 settings->AllowFileAccessFromExternalUrl( false );
1806 settings->AllowScriptsOpenWindows( false );
1808 // Check default value is true or not
1809 bool value = settings->IsJavaScriptEnabled();
1810 DALI_TEST_CHECK( value );
1812 // Check Set/GetProperty
1813 settings->EnableJavaScript( false );
1814 value = settings->IsJavaScriptEnabled();
1815 DALI_TEST_CHECK( !value );
1820 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1822 ToolkitTestApplication application;
1824 WebView view = WebView::New();
1825 DALI_TEST_CHECK( view );
1827 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1828 DALI_TEST_CHECK( settings != 0 )
1831 settings->AllowMixedContents( false );
1832 settings->EnableSpatialNavigation( false );
1833 settings->EnableWebSecurity( false );
1834 settings->EnableCacheBuilder( false );
1835 settings->EnableDoNotTrack( false );
1836 settings->UseScrollbarThumbFocusNotifications( false );
1837 settings->AllowFileAccessFromExternalUrl( false );
1838 settings->AllowScriptsOpenWindows( false );
1840 // Check default value is true or not
1841 bool value = settings->IsAutoFittingEnabled();
1842 DALI_TEST_CHECK( value );
1844 // Check Set/GetProperty
1845 settings->EnableAutoFitting( false );
1846 value = settings->IsAutoFittingEnabled();
1847 DALI_TEST_CHECK( !value );
1852 int UtcDaliWebSettingsCheckEnablePlugins(void)
1854 ToolkitTestApplication application;
1856 WebView view = WebView::New();
1857 DALI_TEST_CHECK( view );
1859 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1860 DALI_TEST_CHECK( settings != 0 )
1863 settings->AllowMixedContents( false );
1864 settings->EnableSpatialNavigation( false );
1865 settings->EnableWebSecurity( false );
1866 settings->EnableCacheBuilder( false );
1867 settings->EnableDoNotTrack( false );
1868 settings->UseScrollbarThumbFocusNotifications( false );
1869 settings->AllowFileAccessFromExternalUrl( false );
1870 settings->AllowScriptsOpenWindows( false );
1872 // Check default value is true or not
1873 bool value = settings->ArePluginsEnabled();
1874 DALI_TEST_CHECK( value );
1876 // Check Set/GetProperty
1877 settings->EnablePlugins( false );
1878 value = settings->ArePluginsEnabled();
1879 DALI_TEST_CHECK( !value );
1884 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1886 ToolkitTestApplication application;
1888 WebView view = WebView::New();
1889 DALI_TEST_CHECK( view );
1891 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1892 DALI_TEST_CHECK( settings != 0 )
1895 settings->AllowMixedContents( false );
1896 settings->EnableSpatialNavigation( false );
1897 settings->EnableWebSecurity( false );
1898 settings->EnableCacheBuilder( false );
1899 settings->EnableDoNotTrack( false );
1900 settings->UseScrollbarThumbFocusNotifications( false );
1901 settings->AllowFileAccessFromExternalUrl( false );
1902 settings->AllowScriptsOpenWindows( false );
1904 // Check default value is true or not
1905 bool value = settings->IsPrivateBrowsingEnabled();
1906 DALI_TEST_CHECK( value );
1908 // Check Set/GetProperty
1909 settings->EnablePrivateBrowsing( false );
1910 value = settings->IsPrivateBrowsingEnabled();
1911 DALI_TEST_CHECK( !value );
1916 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1918 ToolkitTestApplication application;
1920 WebView view = WebView::New();
1921 DALI_TEST_CHECK( view );
1923 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1924 DALI_TEST_CHECK( settings != 0 )
1927 settings->AllowMixedContents( false );
1928 settings->EnableSpatialNavigation( false );
1929 settings->EnableWebSecurity( false );
1930 settings->EnableCacheBuilder( false );
1931 settings->EnableDoNotTrack( false );
1932 settings->UseScrollbarThumbFocusNotifications( false );
1933 settings->AllowFileAccessFromExternalUrl( false );
1934 settings->AllowScriptsOpenWindows( false );
1936 // Check default value is true or not
1937 bool value = settings->IsLinkMagnifierEnabled();
1938 DALI_TEST_CHECK( value );
1940 // Check Set/GetProperty
1941 settings->EnableLinkMagnifier( false );
1942 value = settings->IsLinkMagnifierEnabled();
1943 DALI_TEST_CHECK( !value );
1948 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1950 ToolkitTestApplication application;
1952 WebView view = WebView::New();
1953 DALI_TEST_CHECK( view );
1955 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1956 DALI_TEST_CHECK( settings != 0 )
1959 settings->AllowMixedContents( false );
1960 settings->EnableSpatialNavigation( false );
1961 settings->EnableWebSecurity( false );
1962 settings->EnableCacheBuilder( false );
1963 settings->EnableDoNotTrack( false );
1964 settings->UseScrollbarThumbFocusNotifications( false );
1965 settings->AllowFileAccessFromExternalUrl( false );
1966 settings->AllowScriptsOpenWindows( false );
1968 // Check default value is true or not
1969 bool value = settings->IsKeypadWithoutUserActionUsed();
1970 DALI_TEST_CHECK( value );
1972 // Check Set/GetProperty
1973 settings->UseKeypadWithoutUserAction( false );
1974 value = settings->IsKeypadWithoutUserActionUsed();
1975 DALI_TEST_CHECK( !value );
1980 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1982 ToolkitTestApplication application;
1984 WebView view = WebView::New();
1985 DALI_TEST_CHECK( view );
1987 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1988 DALI_TEST_CHECK( settings != 0 )
1991 settings->AllowMixedContents( false );
1992 settings->EnableSpatialNavigation( false );
1993 settings->EnableWebSecurity( false );
1994 settings->EnableCacheBuilder( false );
1995 settings->EnableDoNotTrack( false );
1996 settings->UseScrollbarThumbFocusNotifications( false );
1997 settings->AllowFileAccessFromExternalUrl( false );
1998 settings->AllowScriptsOpenWindows( false );
2000 // Check default value is true or not
2001 bool value = settings->IsAutofillPasswordFormEnabled();
2002 DALI_TEST_CHECK( value );
2003 settings->EnableAutofillPasswordForm( false );
2004 value = settings->IsAutofillPasswordFormEnabled();
2005 DALI_TEST_CHECK( !value );
2009 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
2011 ToolkitTestApplication application;
2013 WebView view = WebView::New();
2014 DALI_TEST_CHECK( view );
2016 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2017 DALI_TEST_CHECK( settings != 0 );
2020 settings->AllowMixedContents( false );
2021 settings->EnableSpatialNavigation( false );
2022 settings->EnableWebSecurity( false );
2023 settings->EnableCacheBuilder( false );
2024 settings->EnableDoNotTrack( false );
2025 settings->UseScrollbarThumbFocusNotifications( false );
2026 settings->AllowFileAccessFromExternalUrl( false );
2027 settings->AllowScriptsOpenWindows( false );
2029 // Check default value is true or not
2030 bool value = settings->IsFormCandidateDataEnabled();
2031 DALI_TEST_CHECK( value );
2033 // Check Set/GetProperty
2034 settings->EnableFormCandidateData( false );
2035 value = settings->IsFormCandidateDataEnabled();
2036 DALI_TEST_CHECK( !value );
2041 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2043 ToolkitTestApplication application;
2045 WebView view = WebView::New();
2046 DALI_TEST_CHECK( view );
2048 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2049 DALI_TEST_CHECK( settings != 0 );
2052 settings->AllowMixedContents( false );
2053 settings->EnableSpatialNavigation( false );
2054 settings->EnableWebSecurity( false );
2055 settings->EnableCacheBuilder( false );
2056 settings->EnableDoNotTrack( false );
2057 settings->UseScrollbarThumbFocusNotifications( false );
2058 settings->AllowFileAccessFromExternalUrl( false );
2059 settings->AllowScriptsOpenWindows( false );
2061 // Check default value is true or not
2062 bool value = settings->IsTextSelectionEnabled();
2063 DALI_TEST_CHECK( value );
2065 //Check Set/GetProperty
2066 settings->EnableTextSelection(false);
2067 value = settings->IsTextSelectionEnabled();
2068 DALI_TEST_CHECK( !value );
2073 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2075 ToolkitTestApplication application;
2077 WebView view = WebView::New();
2078 DALI_TEST_CHECK( view );
2080 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2081 DALI_TEST_CHECK( settings != 0 );
2084 settings->AllowMixedContents( false );
2085 settings->EnableSpatialNavigation( false );
2086 settings->EnableWebSecurity( false );
2087 settings->EnableCacheBuilder( false );
2088 settings->EnableDoNotTrack( false );
2089 settings->UseScrollbarThumbFocusNotifications( false );
2090 settings->AllowFileAccessFromExternalUrl( false );
2091 settings->AllowScriptsOpenWindows( false );
2093 // Check default value is true or not
2094 bool value = settings->IsTextAutosizingEnabled();
2095 DALI_TEST_CHECK( value );
2097 // Check Set/GetProperty
2098 settings->EnableTextAutosizing(false);
2099 value = settings->IsTextAutosizingEnabled();
2100 DALI_TEST_CHECK( !value );
2105 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2107 ToolkitTestApplication application;
2109 WebView view = WebView::New();
2110 DALI_TEST_CHECK( view );
2112 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2113 DALI_TEST_CHECK( settings != 0 );
2116 settings->AllowMixedContents( false );
2117 settings->EnableSpatialNavigation( false );
2118 settings->EnableWebSecurity( false );
2119 settings->EnableCacheBuilder( false );
2120 settings->EnableDoNotTrack( false );
2121 settings->UseScrollbarThumbFocusNotifications( false );
2122 settings->AllowFileAccessFromExternalUrl( false );
2123 settings->AllowScriptsOpenWindows( false );
2125 // Check default value is true or not
2126 bool value = settings->IsArrowScrollEnabled();
2127 DALI_TEST_CHECK( value );
2129 // Check Set/GetProperty
2130 settings->EnableArrowScroll(false);
2131 value = settings->IsArrowScrollEnabled();
2132 DALI_TEST_CHECK( !value );
2137 int UtcDaliWebSettingsCheckEnableClipboard(void)
2139 ToolkitTestApplication application;
2141 WebView view = WebView::New();
2142 DALI_TEST_CHECK( view );
2144 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2145 DALI_TEST_CHECK( settings != 0 );
2148 settings->AllowMixedContents( false );
2149 settings->EnableSpatialNavigation( false );
2150 settings->EnableWebSecurity( false );
2151 settings->EnableCacheBuilder( false );
2152 settings->EnableDoNotTrack( false );
2153 settings->UseScrollbarThumbFocusNotifications( false );
2154 settings->AllowFileAccessFromExternalUrl( false );
2155 settings->AllowScriptsOpenWindows( false );
2157 // Check default value is true or not
2158 bool value = settings->IsClipboardEnabled();
2159 DALI_TEST_CHECK( value );
2160 settings->EnableClipboard(false);
2161 value = settings->IsClipboardEnabled();
2162 DALI_TEST_CHECK( !value );
2166 int UtcDaliWebSettingsCheckEnableImePanel(void)
2168 ToolkitTestApplication application;
2170 WebView view = WebView::New();
2171 DALI_TEST_CHECK( view );
2173 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2174 DALI_TEST_CHECK( settings != 0 );
2177 settings->AllowMixedContents( false );
2178 settings->EnableSpatialNavigation( false );
2179 settings->EnableWebSecurity( false );
2180 settings->EnableCacheBuilder( false );
2181 settings->EnableDoNotTrack( false );
2182 settings->UseScrollbarThumbFocusNotifications( false );
2183 settings->AllowFileAccessFromExternalUrl( false );
2184 settings->AllowScriptsOpenWindows( false );
2186 // Check default value is true or not
2187 bool value = settings->IsImePanelEnabled();
2188 DALI_TEST_CHECK( value );
2190 // Check Set/GetProperty
2191 settings->EnableImePanel(false);
2192 value = settings->IsImePanelEnabled();
2193 DALI_TEST_CHECK( !value );
2198 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2200 ToolkitTestApplication application;
2202 WebView view = WebView::New();
2203 DALI_TEST_CHECK( view );
2205 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2206 DALI_TEST_CHECK( settings != 0 )
2209 settings->AllowMixedContents( false );
2210 settings->EnableSpatialNavigation( false );
2211 settings->EnableWebSecurity( false );
2212 settings->EnableCacheBuilder( false );
2213 settings->EnableDoNotTrack( false );
2214 settings->UseScrollbarThumbFocusNotifications( false );
2215 settings->AllowFileAccessFromExternalUrl( false );
2216 settings->AllowScriptsOpenWindows( false );
2218 // Check default value is true or not
2219 bool value = settings->AreImagesLoadedAutomatically();
2220 DALI_TEST_CHECK( value );
2222 // Check Set/GetProperty
2223 settings->AllowImagesLoadAutomatically( false );
2224 value = settings->AreImagesLoadedAutomatically();
2225 DALI_TEST_CHECK( !value );
2230 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2232 ToolkitTestApplication application;
2234 WebView view = WebView::New();
2235 DALI_TEST_CHECK( view );
2237 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2238 DALI_TEST_CHECK( settings != 0 )
2240 const std::string kDefaultValue;
2241 const std::string kTestValue = "UTF-8";
2244 settings->AllowMixedContents( false );
2245 settings->EnableSpatialNavigation( false );
2246 settings->EnableWebSecurity( false );
2247 settings->EnableCacheBuilder( false );
2248 settings->EnableDoNotTrack( false );
2249 settings->UseScrollbarThumbFocusNotifications( false );
2250 settings->AllowFileAccessFromExternalUrl( false );
2251 settings->AllowScriptsOpenWindows( false );
2253 // Check default value
2254 std::string value = settings->GetDefaultTextEncodingName();
2255 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2257 // Check Set/GetProperty
2258 settings->SetDefaultTextEncodingName( kTestValue );
2259 value = settings->GetDefaultTextEncodingName();
2260 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
2265 int UtcDaliWebSettingsSetViewportMetaTag(void)
2267 ToolkitTestApplication application;
2269 WebView view = WebView::New();
2270 DALI_TEST_CHECK( view );
2272 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2273 DALI_TEST_CHECK( settings != 0 )
2275 // Check the value is true or not
2276 bool value = settings->SetViewportMetaTag(true);
2277 DALI_TEST_CHECK( value );
2282 int UtcDaliWebSettingsSetForceZoom(void)
2284 ToolkitTestApplication application;
2286 WebView view = WebView::New();
2287 DALI_TEST_CHECK( view );
2289 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2290 DALI_TEST_CHECK( settings != 0 )
2292 // Check the value is true or not
2293 bool value = settings->SetForceZoom(true);
2294 DALI_TEST_CHECK( value );
2296 value = settings->IsZoomForced();
2297 DALI_TEST_CHECK( value );
2302 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2304 ToolkitTestApplication application;
2306 WebView view = WebView::New();
2307 DALI_TEST_CHECK( view );
2309 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2310 DALI_TEST_CHECK( settings != 0 )
2312 // Check the value is true or not
2313 bool value = settings->SetTextZoomEnabled(true);
2314 DALI_TEST_CHECK( value );
2316 value = settings->IsTextZoomEnabled();
2317 DALI_TEST_CHECK( value );
2322 int UtcDaliWebSettingsSetExtraFeature(void)
2324 ToolkitTestApplication application;
2326 WebView view = WebView::New();
2327 DALI_TEST_CHECK( view );
2329 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2330 DALI_TEST_CHECK( settings != 0 )
2332 // Check the value is true or not
2333 settings->SetExtraFeature("test", true);
2334 bool value = settings->IsExtraFeatureEnabled("test");
2335 DALI_TEST_CHECK( value );
2340 int UtcDaliWebViewGetPlainText(void)
2342 ToolkitTestApplication application;
2344 WebView view = WebView::New();
2345 DALI_TEST_CHECK(view);
2347 view.LoadUrl(TEST_URL1);
2349 view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2350 Test::EmitGlobalTimerSignal();
2351 DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);