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::shared_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 gFormRepostDecisionCallbackCalled = 0;
78 static std::shared_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecisionInstance = nullptr;
79 static int gFrameRenderedCallbackCalled = 0;
80 static int gRequestInterceptorCallbackCalled = 0;
81 static std::shared_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
82 static int gConsoleMessageCallbackCalled = 0;
83 static std::shared_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
84 static int gResponsePolicyDecidedCallbackCalled = 0;
85 static std::shared_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
86 static int gCertificateConfirmCallbackCalled = 0;
87 static std::shared_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
88 static int gSslCertificateChangedCallbackCalled = 0;
89 static std::shared_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
90 static int gHttpAuthHandlerCallbackCalled = 0;
91 static std::shared_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
92 static int gSecurityOriginsAcquiredCallbackCalled = 0;
93 static int gStorageUsageAcquiredCallbackCalled = 0;
94 static int gFormPasswordsAcquiredCallbackCalled = 0;
95 static int gDownloadStartedCallbackCalled = 0;
96 static int gMimeOverriddenCallbackCalled = 0;
97 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
98 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
99 static int gContextMenuShownCallbackCalled = 0;
100 static std::shared_ptr<Dali::WebEngineContextMenu> gContextMenuShownInstance = nullptr;
101 static int gContextMenuHiddenCallbackCalled = 0;
102 static std::shared_ptr<Dali::WebEngineContextMenu> gContextMenuHiddenInstance = nullptr;
103 static int gHitTestCreatedCallbackCalled = 0;
104 static int gCookieManagerChangsWatchCallbackCalled = 0;
106 struct CallbackFunctor
108 CallbackFunctor(bool* callbackFlag)
109 : mCallbackFlag( callbackFlag )
115 *mCallbackFlag = true;
120 static void OnPageLoadStarted( WebView view, const std::string& url )
122 gPageLoadStartedCallbackCalled++;
125 static void OnPageLoadInProgress( WebView view, const std::string& url )
127 gPageLoadInProgressCallbackCalled++;
130 static void OnPageLoadFinished( WebView view, const std::string& url )
132 gPageLoadFinishedCallbackCalled++;
135 static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
137 gScrollEdgeReachedCallbackCalled++;
140 static void OnResponsePolicyDecided(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
142 gResponsePolicyDecidedCallbackCalled++;
143 gResponsePolicyDecisionInstance = std::move(decision);
146 static void OnUrlChanged( WebView view, const std::string& url )
148 gUrlChangedCallbackCalled++;
151 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
153 gHitTestCreatedCallbackCalled++;
157 static void OnPageLoadError(WebView view, std::shared_ptr<Dali::WebEngineLoadError> error)
159 gPageLoadErrorCallbackCalled++;
160 gPageLoadErrorInstance = std::move(error);
163 static void OnEvaluateJavaScript( const std::string& result )
165 gEvaluateJavaScriptCallbackCalled++;
168 static bool OnJavaScriptAlert( const std::string& result )
170 gJavaScriptAlertCallbackCalled++;
174 static bool OnJavaScriptConfirm( const std::string& result )
176 gJavaScriptConfirmCallbackCalled++;
180 static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string& message2 )
182 gJavaScriptPromptCallbackCalled++;
186 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
188 gScreenshotCapturedCallbackCalled++;
191 static void OnVideoPlaying(bool isPlaying)
193 gVideoPlayingCallbackCalled++;
196 static bool OnGeolocationPermission(const std::string&, const std::string&)
198 gGeolocationPermissionCallbackCalled++;
202 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
208 static void OnChangesWatch()
210 gCookieManagerChangsWatchCallbackCalled++;
213 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
219 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheel )
221 gWheelEventHandled = true;
225 static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::WebEngineFormRepostDecision> decision)
227 gFormRepostDecisionCallbackCalled++;
228 gFormRepostDecisionInstance = std::move(decision);
231 static void OnFrameRendered(WebView)
233 gFrameRenderedCallbackCalled++;
236 static void OnRequestInterceptor(WebView view, std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
238 gRequestInterceptorCallbackCalled++;
239 gRequestInterceptorInstance = std::move(interceptor);
242 static void OnConsoleMessage(WebView view, std::shared_ptr<Dali::WebEngineConsoleMessage> message)
244 gConsoleMessageCallbackCalled++;
245 gConsoleMessageInstance = std::move(message);
248 static void OnCertificateConfirm(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
250 gCertificateConfirmCallbackCalled++;
251 gCertificateConfirmInstance = std::move(certificate);
254 static void OnSslCertificateChanged(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
256 gSslCertificateChangedCallbackCalled++;
257 gSslCertificateInstance = std::move(certificate);
260 static void OnHttpAuthHandler( WebView view, std::shared_ptr<Dali::WebEngineHttpAuthHandler> hander )
262 gHttpAuthHandlerCallbackCalled++;
263 gHttpAuthInstance = std::move(hander);
266 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
268 gSecurityOriginsAcquiredCallbackCalled++;
269 gSecurityOriginList.clear();
270 gSecurityOriginList.swap(origins);
273 static void OnStorageUsageAcquired(uint64_t usage)
275 gStorageUsageAcquiredCallbackCalled++;
278 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
280 gFormPasswordsAcquiredCallbackCalled++;
281 gPasswordDataList.clear();
282 gPasswordDataList.swap(passwords);
285 static void OnDownloadStarted(const std::string& url)
287 gDownloadStartedCallbackCalled++;
290 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
292 gMimeOverriddenCallbackCalled++;
296 static void OnContextMenuShown(WebView view, std::shared_ptr<Dali::WebEngineContextMenu> menu)
298 gContextMenuShownCallbackCalled++;
299 gContextMenuShownInstance = std::move(menu);
302 static void OnContextMenuHidden(WebView view, std::shared_ptr<Dali::WebEngineContextMenu> menu)
304 gContextMenuHiddenCallbackCalled++;
305 gContextMenuHiddenInstance = std::move(menu);
310 void web_view_startup(void)
312 test_return_value = TET_UNDEF;
315 void web_view_cleanup(void)
317 test_return_value = TET_PASS;
320 int UtcDaliWebViewBasics(void)
322 ToolkitTestApplication application;
324 // Copy and Assignment Test
325 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
326 WebView view = WebView::New();
327 DALI_TEST_CHECK( view );
329 WebView copy( view );
330 DALI_TEST_CHECK( view == copy );
333 DALI_TEST_CHECK( !assign );
336 DALI_TEST_CHECK( assign == view );
339 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
340 BaseHandle handle(view);
342 WebView view2 = WebView::DownCast( handle );
343 DALI_TEST_CHECK( view );
344 DALI_TEST_CHECK( view2 );
345 DALI_TEST_CHECK( view == view2 );
348 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
349 TypeRegistry typeRegistry = TypeRegistry::Get();
350 DALI_TEST_CHECK( typeRegistry );
352 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
353 DALI_TEST_CHECK( typeInfo );
355 BaseHandle handle2 = typeInfo.CreateInstance();
356 DALI_TEST_CHECK( handle2 );
358 WebView view3 = WebView::DownCast( handle2 );
359 DALI_TEST_CHECK( view3 );
364 int UtcDaliWebViewPageNavigation(void)
366 ToolkitTestApplication application;
368 WebView view = WebView::New();
369 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
370 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
371 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
372 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
373 application.GetScene().Add( view );
374 application.SendNotification();
375 application.Render();
376 DALI_TEST_CHECK( view );
378 ConnectionTracker* testTracker = new ConnectionTracker();
379 view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
380 view.PageLoadInProgressSignal().Connect( &OnPageLoadInProgress );
381 view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
382 view.UrlChangedSignal().Connect( &OnUrlChanged );
383 bool signal1 = false;
384 bool signal2 = false;
385 bool signal3 = false;
386 bool signal4 = false;
387 bool signal5 = false;
388 view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
389 view.ConnectSignal( testTracker, "pageLoadInProgress", CallbackFunctor(&signal2) );
390 view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal3) );
391 view.ConnectSignal( testTracker, "urlChanged", CallbackFunctor(&signal4) );
392 view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal5) );
393 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
394 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
395 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
396 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
398 view.LoadUrl( TEST_URL1 );
399 view.GetNaturalSize();
400 Test::EmitGlobalTimerSignal();
401 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
402 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
403 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
404 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
405 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
406 DALI_TEST_CHECK( signal1 & signal2 & signal3 & signal4 );
407 DALI_TEST_CHECK( !signal5 );
409 view.LoadUrl( TEST_URL2 );
411 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
412 application.SendNotification();
413 application.Render();
414 Test::EmitGlobalTimerSignal();
416 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
417 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
418 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
419 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
420 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
421 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
424 Test::EmitGlobalTimerSignal();
425 DALI_TEST_CHECK( !view.CanGoBack() );
426 DALI_TEST_CHECK( view.CanGoForward() );
429 Test::EmitGlobalTimerSignal();
430 DALI_TEST_CHECK( view.CanGoBack() );
431 DALI_TEST_CHECK( !view.CanGoForward() );
436 Test::EmitGlobalTimerSignal();
437 DALI_TEST_CHECK( !view.CanGoBack() );
438 DALI_TEST_CHECK( !view.CanGoForward() );
443 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
445 ToolkitTestApplication application;
447 WebView view = WebView::New();
448 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
449 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
450 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
451 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
452 application.GetScene().Add( view );
453 application.SendNotification();
454 application.Render();
455 DALI_TEST_CHECK( view );
457 ConnectionTracker* testTracker = new ConnectionTracker();
458 view.PageLoadErrorSignal().Connect( &OnPageLoadError );
459 view.ConsoleMessageSignal().Connect( &OnConsoleMessage );
460 bool signal1 = false;
461 bool signal2 = false;
462 view.ConnectSignal( testTracker, "pageLoadError", CallbackFunctor(&signal1) );
463 view.ConnectSignal( testTracker, "consoleMessage", CallbackFunctor(&signal2) );
464 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
465 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
467 view.LoadUrl( TEST_URL1 );
468 Test::EmitGlobalTimerSignal();
469 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
470 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
471 DALI_TEST_CHECK( signal1 & signal2);
474 DALI_TEST_CHECK(gPageLoadErrorInstance);
475 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
476 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
477 std::string testErrorDescription("This is an error.");
478 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
479 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
482 DALI_TEST_CHECK(gConsoleMessageInstance);
483 std::string testConsoleSource("source");
484 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
485 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
486 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
487 std::string testConsoleText("This is a text.");
488 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
491 gPageLoadErrorInstance = nullptr;
492 gConsoleMessageInstance = nullptr;
497 int UtcDaliWebViewTouchAndKeys(void)
499 ToolkitTestApplication application;
501 WebView view = WebView::New();
502 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
503 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
504 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
505 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
507 application.GetScene().Add( view );
508 application.SendNotification();
509 application.Render();
511 view.GetNaturalSize();
512 view.TouchedSignal().Connect( &OnTouched );
515 Dali::Integration::TouchEvent event;
516 Dali::Integration::Point pointDown, pointUp;
518 event = Dali::Integration::TouchEvent();
519 pointDown.SetState( PointState::DOWN );
520 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
521 event.AddPoint( pointDown );
522 application.ProcessEvent( event );
524 event = Dali::Integration::TouchEvent();
525 pointUp.SetState( PointState::UP );
526 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
527 event.AddPoint( pointUp );
528 application.ProcessEvent( event );
531 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
532 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
533 application.SendNotification();
535 DALI_TEST_CHECK( gTouched );
536 DALI_TEST_CHECK( view );
541 int UtcDaliWebViewFocusGainedAndLost(void)
543 ToolkitTestApplication application;
545 WebView view = WebView::New();
546 DALI_TEST_CHECK( view );
548 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
549 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
550 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
551 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
553 application.GetScene().Add( view );
554 application.SendNotification();
555 application.Render();
557 view.SetKeyInputFocus();
558 DALI_TEST_CHECK( view.HasKeyInputFocus() );
561 view.ClearKeyInputFocus();
562 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
567 int UtcDaliWebViewPropertyPageZoomFactor(void)
569 ToolkitTestApplication application;
571 WebView view = WebView::New();
572 DALI_TEST_CHECK( view );
574 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
575 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
576 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
577 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
579 application.GetScene().Add( view );
580 application.SendNotification();
581 application.Render();
583 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
584 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
585 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
587 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
588 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
589 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
594 int UtcDaliWebViewPropertyTextZoomFactor(void)
596 ToolkitTestApplication application;
598 WebView view = WebView::New();
599 DALI_TEST_CHECK( view );
601 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
602 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
603 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
604 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
606 application.GetScene().Add( view );
607 application.SendNotification();
608 application.Render();
610 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
611 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
612 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
614 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
615 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
616 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
621 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
623 ToolkitTestApplication application;
625 WebView view = WebView::New();
626 DALI_TEST_CHECK( view );
628 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
629 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
630 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
631 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
633 application.GetScene().Add( view );
634 application.SendNotification();
635 application.Render();
637 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
638 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
643 int UtcDaliWebViewMove(void)
645 ToolkitTestApplication application;
647 WebView view = WebView::New();
648 DALI_TEST_CHECK( view );
650 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
651 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
652 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
653 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
655 application.GetScene().Add( view );
656 application.SendNotification();
657 application.Render();
659 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
660 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
661 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
666 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
668 ToolkitTestApplication application;
670 WebView view = WebView::New();
671 DALI_TEST_CHECK( view );
673 const bool kDefaultValue = true;
674 const bool kTestValue = false;
676 // Check default value
678 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
679 DALI_TEST_CHECK( value.Get( output ) );
680 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
682 // Check Set/GetProperty
683 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
684 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
685 DALI_TEST_CHECK( value.Get( output ) );
686 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
691 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
693 ToolkitTestApplication application;
695 WebView view = WebView::New();
696 DALI_TEST_CHECK( view );
698 const bool kDefaultValue = true;
699 const bool kTestValue = false;
701 // Check default value
703 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
704 DALI_TEST_CHECK( value.Get( output ) );
705 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
707 // Check Set/GetProperty
708 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
709 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
710 DALI_TEST_CHECK( value.Get( output ) );
711 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
716 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
718 ToolkitTestApplication application;
720 WebView view = WebView::New();
721 DALI_TEST_CHECK( view );
723 const bool kDefaultValue = true;
724 const bool kTestValue = false;
726 // Check default value
728 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
729 DALI_TEST_CHECK( value.Get( output ) );
730 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
732 // Check Set/GetProperty
733 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
734 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
735 DALI_TEST_CHECK( value.Get( output ) );
736 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
741 int UtcDaliWebViewHoverAndWheel(void)
743 ToolkitTestApplication application;
745 WebView view = WebView::New();
746 DALI_TEST_CHECK( view );
747 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
748 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
749 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
750 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
752 application.GetScene().Add( view );
753 application.SendNotification();
754 application.Render();
756 view.GetNaturalSize();
757 view.HoveredSignal().Connect( &OnHovered );
758 view.WheelEventSignal().Connect( &OnWheelEvent );
761 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
762 Dali::Integration::Point pointDown;
763 pointDown.SetState( PointState::DOWN );
764 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
765 event.AddPoint( pointDown );
766 application.ProcessEvent( event );
768 event = Dali::Integration::HoverEvent();
769 Dali::Integration::Point pointUp;
770 pointUp.SetState( PointState::UP );
771 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
772 event.AddPoint( pointUp );
773 application.ProcessEvent( event );
775 event = Dali::Integration::HoverEvent();
776 Dali::Integration::Point pointMotion;
777 pointUp.SetState( PointState::MOTION );
778 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
779 event.AddPoint( pointMotion );
780 application.ProcessEvent( event );
783 Dali::Integration::WheelEvent wheelEvent;
784 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
785 wheelEvent.direction = 0;
786 wheelEvent.point = Vector2( 20, 20 );
787 wheelEvent.delta = 10;
788 application.ProcessEvent( wheelEvent );
789 application.SendNotification();
791 DALI_TEST_CHECK( gHovered );
792 DALI_TEST_CHECK( gWheelEventHandled );
797 int UtcDaliWebViewFormRepostDecisionFrameRendering(void)
799 ToolkitTestApplication application;
801 WebView view = WebView::New();
802 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
803 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
804 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
805 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
806 application.GetScene().Add( view );
807 application.SendNotification();
808 application.Render();
809 DALI_TEST_CHECK( view );
811 ConnectionTracker* testTracker = new ConnectionTracker();
812 view.FormRepostDecisionSignal().Connect(&OnFormRepostDecision);
813 view.FrameRenderedSignal().Connect(&OnFrameRendered);
814 bool signal1 = false;
815 bool signal2 = false;
816 view.ConnectSignal( testTracker, "formRepostDecision", CallbackFunctor(&signal1) );
817 view.ConnectSignal( testTracker, "frameRendered", CallbackFunctor(&signal2) );
818 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 0, TEST_LOCATION );
819 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
821 view.LoadUrl( TEST_URL1 );
822 Test::EmitGlobalTimerSignal();
823 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 1, TEST_LOCATION );
824 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
825 DALI_TEST_CHECK( signal1 & signal2);
827 // form repost decision.
828 DALI_TEST_CHECK(gFormRepostDecisionInstance);
829 gFormRepostDecisionInstance->Reply(true);
832 gFormRepostDecisionInstance = nullptr;
837 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
839 ToolkitTestApplication application;
841 WebView view = WebView::New();
842 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
843 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
844 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
845 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
846 application.GetScene().Add( view );
847 application.SendNotification();
848 application.Render();
849 DALI_TEST_CHECK( view );
851 ConnectionTracker* testTracker = new ConnectionTracker();
852 view.CertificateConfirmSignal().Connect(&OnCertificateConfirm);
853 view.SslCertificateChangedSignal().Connect(&OnSslCertificateChanged);
854 view.HttpAuthHandlerSignal().Connect(&OnHttpAuthHandler);
855 bool signal1 = false;
856 bool signal2 = false;
857 bool signal3 = false;
858 view.ConnectSignal( testTracker, "certificateConfirm", CallbackFunctor(&signal1) );
859 view.ConnectSignal( testTracker, "sslCertificateChanged", CallbackFunctor(&signal2) );
860 view.ConnectSignal( testTracker, "httpAuthRequest", CallbackFunctor(&signal3) );
861 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
862 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
863 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
865 view.LoadUrl( TEST_URL1 );
866 Test::EmitGlobalTimerSignal();
867 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
868 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
869 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
870 DALI_TEST_CHECK( signal1 & signal2 & signal3);
873 DALI_TEST_CHECK(gCertificateConfirmInstance);
874 gCertificateConfirmInstance->Allow(true);
875 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
877 DALI_TEST_CHECK(gSslCertificateInstance);
878 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
879 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
881 // http authentication.
882 DALI_TEST_CHECK(gHttpAuthInstance);
883 gHttpAuthInstance->Suspend();
884 gHttpAuthInstance->UseCredential("", "");
885 gHttpAuthInstance->CancelCredential();
886 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
889 gCertificateConfirmInstance = nullptr;
890 gSslCertificateInstance = nullptr;
891 gHttpAuthInstance = nullptr;
896 int UtcDaliWebViewGetWebBackForwardList(void)
898 ToolkitTestApplication application;
900 WebView view = WebView::New();
901 DALI_TEST_CHECK( view );
903 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
904 DALI_TEST_CHECK( bfList != 0 );
909 int UtcDaliWebViewGetWebContext(void)
911 ToolkitTestApplication application;
913 WebView view = WebView::New();
914 DALI_TEST_CHECK( view );
916 Dali::Toolkit::WebContext* context = view.GetContext();
917 DALI_TEST_CHECK( context != 0 );
922 int UtcDaliWebViewGetWebCookieManager(void)
924 ToolkitTestApplication application;
926 WebView view = WebView::New();
927 DALI_TEST_CHECK( view );
929 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
930 DALI_TEST_CHECK( cookieManager != 0 );
935 int UtcDaliWebViewGetWebSettings(void)
937 ToolkitTestApplication application;
939 WebView view = WebView::New();
940 DALI_TEST_CHECK( view );
942 Dali::Toolkit::WebSettings* settings = view.GetSettings();
943 DALI_TEST_CHECK( settings != 0 );
948 int UtcDaliWebViewProperty1(void)
951 ToolkitTestApplication application;
953 WebView view = WebView::New();
954 DALI_TEST_CHECK( view );
957 view.SetProperty( WebView::Property::URL, TEST_URL1 );
958 Property::Value val = view.GetProperty( WebView::Property::URL );
959 DALI_TEST_CHECK( val.Get( local ) );
960 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
965 int UtcDaliWebViewProperty4(void)
968 ToolkitTestApplication application;
970 WebView view = WebView::New();
971 DALI_TEST_CHECK( view );
973 const std::string kDefaultValue;
974 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";
976 // Check default value
978 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
979 DALI_TEST_CHECK( value.Get( output ) );
980 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
982 // Check Set/GetProperty
983 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
984 value = view.GetProperty( WebView::Property::USER_AGENT );
985 DALI_TEST_CHECK( value.Get( output ) );
986 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
991 int UtcDaliWebViewProperty9(void)
994 ToolkitTestApplication application;
996 WebView view = WebView::New();
997 DALI_TEST_CHECK( view );
999 // Check default value
1000 Dali::Vector2 output = Dali::Vector2::ONE;
1001 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1002 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
1004 // Check Set/GetProperty
1005 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1006 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1007 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1008 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1010 // Check default value of scroll size
1011 output = Dali::Vector2::ONE;
1012 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
1013 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1015 // Check default value of content size
1016 output = Dali::Vector2::ONE;
1017 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
1018 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1023 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1025 ToolkitTestApplication application;
1027 WebView view = WebView::New();
1028 DALI_TEST_CHECK( view );
1030 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1031 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1032 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1033 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1034 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1036 // Check default value
1037 std::string testText("test");
1039 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1040 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1045 int UtcDaliWebViewPropertyTitleFavicon(void)
1047 ToolkitTestApplication application;
1049 char argv[] = "--test";
1050 WebView view = WebView::New( 1, (char**)&argv );
1051 DALI_TEST_CHECK( view );
1054 view.ClearAllTilesResources();
1056 // Check default value of title
1057 std::string testValue("title");
1059 view.GetProperty( WebView::Property::TITLE ).Get( output );
1060 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1062 // Check the case that favicon is not null.
1063 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1064 DALI_TEST_CHECK( favicon );
1065 Dali::Vector3 iconsize = favicon.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1066 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1068 // Check the case that favicon is null.
1069 favicon = view.GetFavicon();
1070 DALI_TEST_CHECK( !favicon );
1075 int UtcDaliWebViewContextMenuShownAndHidden(void)
1077 ToolkitTestApplication application;
1079 WebView view = WebView::New();
1080 DALI_TEST_CHECK( view );
1083 ConnectionTracker* testTracker = new ConnectionTracker();
1084 view.ContextMenuShownSignal().Connect( &OnContextMenuShown );
1085 view.ContextMenuHiddenSignal().Connect( &OnContextMenuHidden );
1086 bool signal1 = false;
1087 bool signal2 = false;
1088 view.ConnectSignal( testTracker, "contextMenuShown", CallbackFunctor(&signal1) );
1089 view.ConnectSignal( testTracker, "contextMenuHidden", CallbackFunctor(&signal2) );
1090 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 0, TEST_LOCATION );
1091 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION );
1092 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1093 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1095 view.LoadUrl( TEST_URL1 );
1096 Test::EmitGlobalTimerSignal();
1097 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 1, TEST_LOCATION );
1098 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION );
1099 DALI_TEST_CHECK( signal1 );
1100 DALI_TEST_CHECK( signal2 );
1102 // check context meun & its items.
1103 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1104 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1105 DALI_TEST_CHECK(item.get() != 0);
1106 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1107 DALI_TEST_CHECK(itemList.size() == 1);
1108 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1109 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1110 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1111 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1112 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1114 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1115 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1116 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1117 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1118 DALI_TEST_CHECK(item->IsEnabled());
1119 std::string testLinkUrl("http://test.html");
1120 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1121 std::string testImageUrl("http://test.jpg");
1122 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1123 std::string testTitle("title");
1124 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1125 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1127 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1129 gContextMenuShownInstance = nullptr;
1130 gContextMenuHiddenInstance = nullptr;
1135 int UtcDaliWebViewScrollBy(void)
1137 ToolkitTestApplication application;
1139 WebView view = WebView::New();
1140 DALI_TEST_CHECK( view );
1143 ConnectionTracker* testTracker = new ConnectionTracker();
1144 view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
1145 bool signal1 = false;
1146 view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
1147 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1149 view.LoadUrl( TEST_URL1 );
1150 Test::EmitGlobalTimerSignal();
1152 // set scroll position.
1153 Dali::Vector2 output = Dali::Vector2::ONE;
1154 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1155 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1156 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1157 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1159 // scroll by and trigger scrollEdgeReached event.
1160 view.ScrollBy( 50, 50 );
1161 Test::EmitGlobalTimerSignal();
1163 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1164 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1165 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1166 DALI_TEST_CHECK( signal1 );
1168 // scroll by and trigger scrollEdgeReached event.
1169 bool result = view.ScrollEdgeBy( 50, 50 );
1170 DALI_TEST_CHECK( result );
1171 Test::EmitGlobalTimerSignal();
1173 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1174 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1175 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1176 DALI_TEST_CHECK( signal1 );
1181 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1183 ToolkitTestApplication application;
1185 WebView view = WebView::New();
1186 DALI_TEST_CHECK( view );
1188 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1189 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1190 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1191 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1193 application.GetScene().Add( view );
1194 application.SendNotification();
1195 application.Render();
1197 view.ActivateAccessibility(true);
1198 view.AddDynamicCertificatePath("host", "test/to/path");
1199 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1200 DALI_TEST_CHECK( found );
1202 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1203 float result = view.GetScaleFactor();
1204 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1206 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1207 result = view.GetScaleFactor();
1208 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1213 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1216 ToolkitTestApplication application;
1218 char argv[] = "--test";
1219 WebView view = WebView::New( 1, (char**)&argv );
1220 DALI_TEST_CHECK( view );
1222 // Check GetScreenshot
1223 Dali::Rect<int> viewArea;
1226 viewArea.width = 10;
1227 viewArea.height = 10;
1228 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1229 DALI_TEST_CHECK( screenshot );
1230 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1231 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1233 // Check GetScreenshotAsynchronously
1236 viewArea.width = 100;
1237 viewArea.height = 100;
1238 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1239 DALI_TEST_CHECK( result );
1241 Test::EmitGlobalTimerSignal();
1243 Test::EmitGlobalTimerSignal();
1244 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1249 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1252 ToolkitTestApplication application;
1254 char argv[] = "--test";
1255 WebView view = WebView::New( 1, (char**)&argv );
1256 DALI_TEST_CHECK( view );
1258 // Check CheckVideoPlayingAsynchronously
1259 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1260 DALI_TEST_CHECK( result );
1261 Test::EmitGlobalTimerSignal();
1262 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1264 // Check RegisterGeolocationPermissionCallback
1265 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1266 Test::EmitGlobalTimerSignal();
1267 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1272 int UtcDaliWebViewHttpRequestInterceptor(void)
1274 ToolkitTestApplication application;
1276 WebView view = WebView::New();
1277 DALI_TEST_CHECK( view );
1280 ConnectionTracker* testTracker = new ConnectionTracker();
1281 view.RequestInterceptorSignal().Connect( &OnRequestInterceptor );
1282 bool signal1 = false;
1283 view.ConnectSignal( testTracker, "requestInterceptor", CallbackFunctor(&signal1) );
1284 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1285 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1287 view.LoadUrl( TEST_URL1 );
1288 Test::EmitGlobalTimerSignal();
1289 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1290 DALI_TEST_CHECK( signal1 );
1292 // check request interceptor.
1293 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1294 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1295 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1296 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1297 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1298 std::string testUrl("http://test.html");
1299 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1301 gRequestInterceptorInstance = nullptr;
1306 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1308 ToolkitTestApplication application;
1310 WebView view = WebView::New();
1311 DALI_TEST_CHECK( view );
1314 ConnectionTracker* testTracker = new ConnectionTracker();
1315 view.ResponsePolicyDecisionSignal().Connect( &OnResponsePolicyDecided );
1316 bool signal1 = false;
1317 view.ConnectSignal( testTracker, "responsePolicyDecided", CallbackFunctor(&signal1) );
1318 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION );
1319 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1321 view.LoadUrl( TEST_URL1 );
1322 Test::EmitGlobalTimerSignal();
1323 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION );
1324 DALI_TEST_CHECK( signal1 );
1326 // check response policy decision & its frame.
1327 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1328 std::string testUrl("http://test.html");
1329 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1330 std::string testCookie("test:abc");
1331 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1332 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1333 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1334 std::string testResponseMime("txt/xml");
1335 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1336 int32_t ResponseStatusCode = 500;
1337 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1338 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1339 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1340 std::string testScheme("test");
1341 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1342 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1343 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1344 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1346 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1347 DALI_TEST_CHECK(webFrame);
1348 DALI_TEST_CHECK(webFrame->IsMainFrame());
1350 gResponsePolicyDecisionInstance = nullptr;
1355 int UtcDaliWebViewHitTest(void)
1357 ToolkitTestApplication application;
1359 WebView view = WebView::New();
1360 DALI_TEST_CHECK( view );
1363 view.LoadUrl( TEST_URL1 );
1366 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1367 DALI_TEST_CHECK(hitTest != 0);
1368 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1369 std::string testLinkUri("http://test.html");
1370 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1371 std::string testLinkTitle("test");
1372 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1373 std::string testLinkLabel("label");
1374 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1375 std::string testImageUri("http://test.jpg");
1376 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1377 std::string testMediaUri("http://test.mp4");
1378 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1379 std::string testTagName("img");
1380 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1381 std::string testNodeValue("test");
1382 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1383 Dali::Property::Map* testMap = &hitTest->GetAttributes();
1384 DALI_TEST_CHECK(testMap);
1385 std::string testImageFileNameExtension("jpg");
1386 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1387 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1388 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1391 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1392 DALI_TEST_CHECK(result);
1393 Test::EmitGlobalTimerSignal();
1394 DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
1399 int UtcDaliWebViewEvaluteJavaScript(void)
1401 ToolkitTestApplication application;
1403 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1405 view.LoadHtmlString( "<body>Hello World!</body>" );
1406 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1407 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1408 Test::EmitGlobalTimerSignal();
1410 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1415 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1417 ToolkitTestApplication application;
1419 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1421 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1422 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1423 view.JavaScriptAlertReply();
1424 Test::EmitGlobalTimerSignal();
1425 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1427 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1428 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1429 view.JavaScriptConfirmReply( true );
1430 Test::EmitGlobalTimerSignal();
1431 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1433 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1434 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1435 view.JavaScriptPromptReply( "it is a prompt." );
1436 Test::EmitGlobalTimerSignal();
1437 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1442 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1444 ToolkitTestApplication application;
1446 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1447 DALI_TEST_CHECK( view );
1449 std::string html("<body>Hello World!</body>");
1450 std::string basicUri("http://basicurl");
1451 std::string unreachableUrl("http://unreachableurl");
1452 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1453 DALI_TEST_CHECK( result );
1455 application.SendNotification();
1456 application.Render();
1457 Test::EmitGlobalTimerSignal();
1459 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1460 DALI_TEST_CHECK( result );
1465 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1467 ToolkitTestApplication application;
1469 WebView view = WebView::New();
1470 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1471 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1472 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1473 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1475 application.GetScene().Add( view );
1476 application.SendNotification();
1477 application.Render();
1478 DALI_TEST_CHECK( view );
1480 view.LoadUrl( "http://test.html" );
1481 bool result = view.AddCustomHeader("key", "value");
1482 DALI_TEST_CHECK( result );
1484 result = view.ReloadWithoutCache();
1485 DALI_TEST_CHECK( result );
1487 uint32_t portNumber = view.StartInspectorServer(5000);
1488 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1490 application.SendNotification();
1491 application.Render();
1492 Test::EmitGlobalTimerSignal();
1494 result = view.StopInspectorServer();
1495 DALI_TEST_CHECK( result );
1497 view.SuspendNetworkLoading();
1499 result = view.RemoveCustomHeader("key");
1500 DALI_TEST_CHECK( result );
1502 view.ResumeNetworkLoading();
1507 int UtcDaliWebViewMethodsForCoverage(void)
1509 ToolkitTestApplication application;
1511 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1513 view.LoadHtmlString( "<body>Hello World!</body>" );
1514 view.AddJavaScriptMessageHandler( "jsObject",
1515 []( const std::string& arg ) {
1519 DALI_TEST_CHECK( view );
1524 // test cases for web backforward list.
1526 int UtcDaliWebBackForwardListCheckItem(void)
1528 ToolkitTestApplication application;
1530 WebView view = WebView::New();
1531 DALI_TEST_CHECK( view );
1533 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1534 DALI_TEST_CHECK( bfList != 0 )
1536 unsigned int itemCount = bfList->GetItemCount();
1537 DALI_TEST_CHECK( itemCount == 1 )
1539 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1540 DALI_TEST_CHECK( citem != 0 );
1542 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1543 DALI_TEST_CHECK( citemP != 0 );
1545 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1546 DALI_TEST_CHECK( citemN != 0 );
1548 const std::string kDefaultUrl( "http://url" );
1549 std::string testValue = citem->GetUrl();
1550 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1552 const std::string kDefaultTitle( "title" );
1553 testValue = citem->GetTitle();
1554 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1556 const std::string kDefaultOriginalUrl( "http://originalurl" );
1557 testValue = citem->GetOriginalUrl();
1558 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1560 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1561 DALI_TEST_CHECK( item != 0 );
1563 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1564 DALI_TEST_CHECK( vecBack.size() == 1 );
1566 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1567 DALI_TEST_CHECK( vecForward.size() == 1 );
1572 // test cases for web context.
1574 int UtcDaliWebContextGetSetCacheModel(void)
1576 ToolkitTestApplication application;
1578 WebView view = WebView::New();
1579 DALI_TEST_CHECK( view );
1581 Dali::Toolkit::WebContext* context = view.GetContext();
1582 DALI_TEST_CHECK( context != 0 )
1584 std::string kDefaultValue;
1587 context->SetAppId( "id" );
1588 context->SetApplicationType( Dali::WebEngineContext::ApplicationType::OTHER );
1589 context->SetTimeOffset( 0 );
1590 context->SetTimeZoneOffset( 0, 0 );
1591 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1592 context->DeleteAllWebDatabase();
1593 context->DeleteAllWebStorage();
1594 context->DeleteLocalFileSystem();
1595 context->ClearCache();
1596 context->DeleteAllFormPasswordData();
1597 context->DeleteAllFormCandidateData();
1599 // Check default value
1600 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1601 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1603 // Check Set/GetProperty
1604 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1605 value = context->GetCacheModel();
1606 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1608 // Get cache enabled
1609 context->EnableCache( true );
1610 DALI_TEST_CHECK( context->IsCacheEnabled() );
1613 context->SetCertificateFilePath( "test" );
1614 std::string str = context->GetCertificateFilePath();
1615 DALI_TEST_EQUALS( str, "test", TEST_LOCATION );
1618 DALI_TEST_CHECK( context->SetAppVersion( "test" ) );
1621 std::vector<std::string> temp;
1622 context->RegisterUrlSchemesAsCorsEnabled( temp );
1623 context->RegisterJsPluginMimeTypes( temp );
1624 context->DeleteFormPasswordDataList( temp );
1627 context->SetDefaultZoomFactor( 1.0f );
1628 DALI_TEST_EQUALS( context->GetDefaultZoomFactor(), float( 1.0f ), TEST_LOCATION );
1630 // Delete cache and database
1631 DALI_TEST_CHECK( context->DeleteAllApplicationCache() );
1632 DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() );
1635 context->SetProxyUri( "test" );
1636 DALI_TEST_EQUALS( context->GetProxyUri(), "test", TEST_LOCATION );
1637 context->SetProxyBypassRule("", "test");
1638 DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION );
1641 DALI_TEST_CHECK( context->FreeUnusedMemory() );
1646 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1648 ToolkitTestApplication application;
1650 WebView view = WebView::New();
1651 DALI_TEST_CHECK( view );
1653 Dali::Toolkit::WebContext* context = view.GetContext();
1654 DALI_TEST_CHECK( context != 0 )
1656 std::string kDefaultValue;
1658 // get origins of web database
1659 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1660 DALI_TEST_CHECK( result );
1662 Test::EmitGlobalTimerSignal();
1663 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1664 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1666 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1667 DALI_TEST_CHECK( origin );
1669 result = context->DeleteWebDatabase(*origin);
1670 DALI_TEST_CHECK( result );
1672 // get origins of web storage
1673 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1674 DALI_TEST_CHECK( result );
1676 Test::EmitGlobalTimerSignal();
1677 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1678 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1680 origin = gSecurityOriginList[0].get();
1681 DALI_TEST_CHECK( origin );
1683 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1684 DALI_TEST_CHECK( result );
1685 Test::EmitGlobalTimerSignal();
1686 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1688 result = context->DeleteWebStorage(*origin);
1689 DALI_TEST_CHECK( result );
1691 result = context->DeleteApplicationCache(*origin);
1692 DALI_TEST_CHECK( result );
1694 // form passwords, download state, mime type.
1695 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1696 Test::EmitGlobalTimerSignal();
1697 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1698 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1699 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1700 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1702 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1703 Test::EmitGlobalTimerSignal();
1704 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1706 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1707 Test::EmitGlobalTimerSignal();
1708 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1710 gSecurityOriginList.clear();
1711 gPasswordDataList.clear();
1716 // test cases for web cookie manager.
1718 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1720 ToolkitTestApplication application;
1722 WebView view = WebView::New();
1723 DALI_TEST_CHECK( view );
1725 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1726 DALI_TEST_CHECK( cookieManager != 0 )
1728 const std::string kDefaultValue;
1731 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1732 cookieManager->ClearCookies();
1734 // Check default value
1735 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1736 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1738 // Check Set/GetProperty
1739 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1740 value = cookieManager->GetCookieAcceptPolicy();
1741 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1746 int UtcDaliWebCookieManagerChangesWatch(void)
1748 ToolkitTestApplication application;
1750 WebView view = WebView::New();
1751 DALI_TEST_CHECK( view );
1753 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1754 DALI_TEST_CHECK( cookieManager != 0 )
1756 cookieManager->ChangesWatch(&OnChangesWatch);
1757 Test::EmitGlobalTimerSignal();
1758 DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
1763 // test cases for web settings.
1765 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1767 ToolkitTestApplication application;
1769 WebView view = WebView::New();
1770 DALI_TEST_CHECK( view );
1772 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1773 DALI_TEST_CHECK( settings != 0 )
1776 settings->AllowMixedContents( false );
1777 settings->EnableSpatialNavigation( false );
1778 settings->EnableWebSecurity( false );
1779 settings->EnableCacheBuilder( false );
1780 settings->EnableDoNotTrack( false );
1781 settings->UseScrollbarThumbFocusNotifications( false );
1782 settings->AllowFileAccessFromExternalUrl( false );
1783 settings->AllowScriptsOpenWindows( false );
1785 // Check default value
1786 int value = settings->GetDefaultFontSize();
1787 DALI_TEST_CHECK( value == 16 );
1789 // Check Set/GetProperty
1790 settings->SetDefaultFontSize( 20 );
1791 value = settings->GetDefaultFontSize();
1792 DALI_TEST_CHECK( value == 20 );
1797 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1799 ToolkitTestApplication application;
1801 WebView view = WebView::New();
1802 DALI_TEST_CHECK( view );
1804 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1805 DALI_TEST_CHECK( settings != 0 )
1808 settings->AllowMixedContents( false );
1809 settings->EnableSpatialNavigation( false );
1810 settings->EnableWebSecurity( false );
1811 settings->EnableCacheBuilder( false );
1812 settings->EnableDoNotTrack( false );
1813 settings->UseScrollbarThumbFocusNotifications( false );
1814 settings->AllowFileAccessFromExternalUrl( false );
1815 settings->AllowScriptsOpenWindows( false );
1817 // Check default value is true or not
1818 bool value = settings->IsJavaScriptEnabled();
1819 DALI_TEST_CHECK( value );
1821 // Check Set/GetProperty
1822 settings->EnableJavaScript( false );
1823 value = settings->IsJavaScriptEnabled();
1824 DALI_TEST_CHECK( !value );
1829 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1831 ToolkitTestApplication application;
1833 WebView view = WebView::New();
1834 DALI_TEST_CHECK( view );
1836 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1837 DALI_TEST_CHECK( settings != 0 )
1840 settings->AllowMixedContents( false );
1841 settings->EnableSpatialNavigation( false );
1842 settings->EnableWebSecurity( false );
1843 settings->EnableCacheBuilder( false );
1844 settings->EnableDoNotTrack( false );
1845 settings->UseScrollbarThumbFocusNotifications( false );
1846 settings->AllowFileAccessFromExternalUrl( false );
1847 settings->AllowScriptsOpenWindows( false );
1849 // Check default value is true or not
1850 bool value = settings->IsAutoFittingEnabled();
1851 DALI_TEST_CHECK( value );
1853 // Check Set/GetProperty
1854 settings->EnableAutoFitting( false );
1855 value = settings->IsAutoFittingEnabled();
1856 DALI_TEST_CHECK( !value );
1861 int UtcDaliWebSettingsCheckEnablePlugins(void)
1863 ToolkitTestApplication application;
1865 WebView view = WebView::New();
1866 DALI_TEST_CHECK( view );
1868 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1869 DALI_TEST_CHECK( settings != 0 )
1872 settings->AllowMixedContents( false );
1873 settings->EnableSpatialNavigation( false );
1874 settings->EnableWebSecurity( false );
1875 settings->EnableCacheBuilder( false );
1876 settings->EnableDoNotTrack( false );
1877 settings->UseScrollbarThumbFocusNotifications( false );
1878 settings->AllowFileAccessFromExternalUrl( false );
1879 settings->AllowScriptsOpenWindows( false );
1881 // Check default value is true or not
1882 bool value = settings->ArePluginsEnabled();
1883 DALI_TEST_CHECK( value );
1885 // Check Set/GetProperty
1886 settings->EnablePlugins( false );
1887 value = settings->ArePluginsEnabled();
1888 DALI_TEST_CHECK( !value );
1893 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1895 ToolkitTestApplication application;
1897 WebView view = WebView::New();
1898 DALI_TEST_CHECK( view );
1900 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1901 DALI_TEST_CHECK( settings != 0 )
1904 settings->AllowMixedContents( false );
1905 settings->EnableSpatialNavigation( false );
1906 settings->EnableWebSecurity( false );
1907 settings->EnableCacheBuilder( false );
1908 settings->EnableDoNotTrack( false );
1909 settings->UseScrollbarThumbFocusNotifications( false );
1910 settings->AllowFileAccessFromExternalUrl( false );
1911 settings->AllowScriptsOpenWindows( false );
1913 // Check default value is true or not
1914 bool value = settings->IsPrivateBrowsingEnabled();
1915 DALI_TEST_CHECK( value );
1917 // Check Set/GetProperty
1918 settings->EnablePrivateBrowsing( false );
1919 value = settings->IsPrivateBrowsingEnabled();
1920 DALI_TEST_CHECK( !value );
1925 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1927 ToolkitTestApplication application;
1929 WebView view = WebView::New();
1930 DALI_TEST_CHECK( view );
1932 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1933 DALI_TEST_CHECK( settings != 0 )
1936 settings->AllowMixedContents( false );
1937 settings->EnableSpatialNavigation( false );
1938 settings->EnableWebSecurity( false );
1939 settings->EnableCacheBuilder( false );
1940 settings->EnableDoNotTrack( false );
1941 settings->UseScrollbarThumbFocusNotifications( false );
1942 settings->AllowFileAccessFromExternalUrl( false );
1943 settings->AllowScriptsOpenWindows( false );
1945 // Check default value is true or not
1946 bool value = settings->IsLinkMagnifierEnabled();
1947 DALI_TEST_CHECK( value );
1949 // Check Set/GetProperty
1950 settings->EnableLinkMagnifier( false );
1951 value = settings->IsLinkMagnifierEnabled();
1952 DALI_TEST_CHECK( !value );
1957 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1959 ToolkitTestApplication application;
1961 WebView view = WebView::New();
1962 DALI_TEST_CHECK( view );
1964 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1965 DALI_TEST_CHECK( settings != 0 )
1968 settings->AllowMixedContents( false );
1969 settings->EnableSpatialNavigation( false );
1970 settings->EnableWebSecurity( false );
1971 settings->EnableCacheBuilder( false );
1972 settings->EnableDoNotTrack( false );
1973 settings->UseScrollbarThumbFocusNotifications( false );
1974 settings->AllowFileAccessFromExternalUrl( false );
1975 settings->AllowScriptsOpenWindows( false );
1977 // Check default value is true or not
1978 bool value = settings->IsKeypadWithoutUserActionUsed();
1979 DALI_TEST_CHECK( value );
1981 // Check Set/GetProperty
1982 settings->UseKeypadWithoutUserAction( false );
1983 value = settings->IsKeypadWithoutUserActionUsed();
1984 DALI_TEST_CHECK( !value );
1989 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1991 ToolkitTestApplication application;
1993 WebView view = WebView::New();
1994 DALI_TEST_CHECK( view );
1996 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1997 DALI_TEST_CHECK( settings != 0 )
2000 settings->AllowMixedContents( false );
2001 settings->EnableSpatialNavigation( false );
2002 settings->EnableWebSecurity( false );
2003 settings->EnableCacheBuilder( false );
2004 settings->EnableDoNotTrack( false );
2005 settings->UseScrollbarThumbFocusNotifications( false );
2006 settings->AllowFileAccessFromExternalUrl( false );
2007 settings->AllowScriptsOpenWindows( false );
2009 // Check default value is true or not
2010 bool value = settings->IsAutofillPasswordFormEnabled();
2011 DALI_TEST_CHECK( value );
2012 settings->EnableAutofillPasswordForm( false );
2013 value = settings->IsAutofillPasswordFormEnabled();
2014 DALI_TEST_CHECK( !value );
2018 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
2020 ToolkitTestApplication application;
2022 WebView view = WebView::New();
2023 DALI_TEST_CHECK( view );
2025 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2026 DALI_TEST_CHECK( settings != 0 );
2029 settings->AllowMixedContents( false );
2030 settings->EnableSpatialNavigation( false );
2031 settings->EnableWebSecurity( false );
2032 settings->EnableCacheBuilder( false );
2033 settings->EnableDoNotTrack( false );
2034 settings->UseScrollbarThumbFocusNotifications( false );
2035 settings->AllowFileAccessFromExternalUrl( false );
2036 settings->AllowScriptsOpenWindows( false );
2038 // Check default value is true or not
2039 bool value = settings->IsFormCandidateDataEnabled();
2040 DALI_TEST_CHECK( value );
2042 // Check Set/GetProperty
2043 settings->EnableFormCandidateData( false );
2044 value = settings->IsFormCandidateDataEnabled();
2045 DALI_TEST_CHECK( !value );
2050 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2052 ToolkitTestApplication application;
2054 WebView view = WebView::New();
2055 DALI_TEST_CHECK( view );
2057 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2058 DALI_TEST_CHECK( settings != 0 );
2061 settings->AllowMixedContents( false );
2062 settings->EnableSpatialNavigation( false );
2063 settings->EnableWebSecurity( false );
2064 settings->EnableCacheBuilder( false );
2065 settings->EnableDoNotTrack( false );
2066 settings->UseScrollbarThumbFocusNotifications( false );
2067 settings->AllowFileAccessFromExternalUrl( false );
2068 settings->AllowScriptsOpenWindows( false );
2070 // Check default value is true or not
2071 bool value = settings->IsTextSelectionEnabled();
2072 DALI_TEST_CHECK( value );
2074 //Check Set/GetProperty
2075 settings->EnableTextSelection(false);
2076 value = settings->IsTextSelectionEnabled();
2077 DALI_TEST_CHECK( !value );
2082 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2084 ToolkitTestApplication application;
2086 WebView view = WebView::New();
2087 DALI_TEST_CHECK( view );
2089 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2090 DALI_TEST_CHECK( settings != 0 );
2093 settings->AllowMixedContents( false );
2094 settings->EnableSpatialNavigation( false );
2095 settings->EnableWebSecurity( false );
2096 settings->EnableCacheBuilder( false );
2097 settings->EnableDoNotTrack( false );
2098 settings->UseScrollbarThumbFocusNotifications( false );
2099 settings->AllowFileAccessFromExternalUrl( false );
2100 settings->AllowScriptsOpenWindows( false );
2102 // Check default value is true or not
2103 bool value = settings->IsTextAutosizingEnabled();
2104 DALI_TEST_CHECK( value );
2106 // Check Set/GetProperty
2107 settings->EnableTextAutosizing(false);
2108 value = settings->IsTextAutosizingEnabled();
2109 DALI_TEST_CHECK( !value );
2114 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2116 ToolkitTestApplication application;
2118 WebView view = WebView::New();
2119 DALI_TEST_CHECK( view );
2121 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2122 DALI_TEST_CHECK( settings != 0 );
2125 settings->AllowMixedContents( false );
2126 settings->EnableSpatialNavigation( false );
2127 settings->EnableWebSecurity( false );
2128 settings->EnableCacheBuilder( false );
2129 settings->EnableDoNotTrack( false );
2130 settings->UseScrollbarThumbFocusNotifications( false );
2131 settings->AllowFileAccessFromExternalUrl( false );
2132 settings->AllowScriptsOpenWindows( false );
2134 // Check default value is true or not
2135 bool value = settings->IsArrowScrollEnabled();
2136 DALI_TEST_CHECK( value );
2138 // Check Set/GetProperty
2139 settings->EnableArrowScroll(false);
2140 value = settings->IsArrowScrollEnabled();
2141 DALI_TEST_CHECK( !value );
2146 int UtcDaliWebSettingsCheckEnableClipboard(void)
2148 ToolkitTestApplication application;
2150 WebView view = WebView::New();
2151 DALI_TEST_CHECK( view );
2153 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2154 DALI_TEST_CHECK( settings != 0 );
2157 settings->AllowMixedContents( false );
2158 settings->EnableSpatialNavigation( false );
2159 settings->EnableWebSecurity( false );
2160 settings->EnableCacheBuilder( false );
2161 settings->EnableDoNotTrack( false );
2162 settings->UseScrollbarThumbFocusNotifications( false );
2163 settings->AllowFileAccessFromExternalUrl( false );
2164 settings->AllowScriptsOpenWindows( false );
2166 // Check default value is true or not
2167 bool value = settings->IsClipboardEnabled();
2168 DALI_TEST_CHECK( value );
2169 settings->EnableClipboard(false);
2170 value = settings->IsClipboardEnabled();
2171 DALI_TEST_CHECK( !value );
2175 int UtcDaliWebSettingsCheckEnableImePanel(void)
2177 ToolkitTestApplication application;
2179 WebView view = WebView::New();
2180 DALI_TEST_CHECK( view );
2182 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2183 DALI_TEST_CHECK( settings != 0 );
2186 settings->AllowMixedContents( false );
2187 settings->EnableSpatialNavigation( false );
2188 settings->EnableWebSecurity( false );
2189 settings->EnableCacheBuilder( false );
2190 settings->EnableDoNotTrack( false );
2191 settings->UseScrollbarThumbFocusNotifications( false );
2192 settings->AllowFileAccessFromExternalUrl( false );
2193 settings->AllowScriptsOpenWindows( false );
2195 // Check default value is true or not
2196 bool value = settings->IsImePanelEnabled();
2197 DALI_TEST_CHECK( value );
2199 // Check Set/GetProperty
2200 settings->EnableImePanel(false);
2201 value = settings->IsImePanelEnabled();
2202 DALI_TEST_CHECK( !value );
2207 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2209 ToolkitTestApplication application;
2211 WebView view = WebView::New();
2212 DALI_TEST_CHECK( view );
2214 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2215 DALI_TEST_CHECK( settings != 0 )
2218 settings->AllowMixedContents( false );
2219 settings->EnableSpatialNavigation( false );
2220 settings->EnableWebSecurity( false );
2221 settings->EnableCacheBuilder( false );
2222 settings->EnableDoNotTrack( false );
2223 settings->UseScrollbarThumbFocusNotifications( false );
2224 settings->AllowFileAccessFromExternalUrl( false );
2225 settings->AllowScriptsOpenWindows( false );
2227 // Check default value is true or not
2228 bool value = settings->AreImagesLoadedAutomatically();
2229 DALI_TEST_CHECK( value );
2231 // Check Set/GetProperty
2232 settings->AllowImagesLoadAutomatically( false );
2233 value = settings->AreImagesLoadedAutomatically();
2234 DALI_TEST_CHECK( !value );
2239 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2241 ToolkitTestApplication application;
2243 WebView view = WebView::New();
2244 DALI_TEST_CHECK( view );
2246 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2247 DALI_TEST_CHECK( settings != 0 )
2249 const std::string kDefaultValue;
2250 const std::string kTestValue = "UTF-8";
2253 settings->AllowMixedContents( false );
2254 settings->EnableSpatialNavigation( false );
2255 settings->EnableWebSecurity( false );
2256 settings->EnableCacheBuilder( false );
2257 settings->EnableDoNotTrack( false );
2258 settings->UseScrollbarThumbFocusNotifications( false );
2259 settings->AllowFileAccessFromExternalUrl( false );
2260 settings->AllowScriptsOpenWindows( false );
2262 // Check default value
2263 std::string value = settings->GetDefaultTextEncodingName();
2264 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2266 // Check Set/GetProperty
2267 settings->SetDefaultTextEncodingName( kTestValue );
2268 value = settings->GetDefaultTextEncodingName();
2269 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
2274 int UtcDaliWebSettingsSetViewportMetaTag(void)
2276 ToolkitTestApplication application;
2278 WebView view = WebView::New();
2279 DALI_TEST_CHECK( view );
2281 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2282 DALI_TEST_CHECK( settings != 0 )
2284 // Check the value is true or not
2285 bool value = settings->SetViewportMetaTag(true);
2286 DALI_TEST_CHECK( value );
2291 int UtcDaliWebSettingsSetForceZoom(void)
2293 ToolkitTestApplication application;
2295 WebView view = WebView::New();
2296 DALI_TEST_CHECK( view );
2298 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2299 DALI_TEST_CHECK( settings != 0 )
2301 // Check the value is true or not
2302 bool value = settings->SetForceZoom(true);
2303 DALI_TEST_CHECK( value );
2305 value = settings->IsZoomForced();
2306 DALI_TEST_CHECK( value );
2311 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2313 ToolkitTestApplication application;
2315 WebView view = WebView::New();
2316 DALI_TEST_CHECK( view );
2318 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2319 DALI_TEST_CHECK( settings != 0 )
2321 // Check the value is true or not
2322 bool value = settings->SetTextZoomEnabled(true);
2323 DALI_TEST_CHECK( value );
2325 value = settings->IsTextZoomEnabled();
2326 DALI_TEST_CHECK( value );
2331 int UtcDaliWebSettingsSetExtraFeature(void)
2333 ToolkitTestApplication application;
2335 WebView view = WebView::New();
2336 DALI_TEST_CHECK( view );
2338 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2339 DALI_TEST_CHECK( settings != 0 )
2341 // Check the value is true or not
2342 settings->SetExtraFeature("test", true);
2343 bool value = settings->IsExtraFeatureEnabled("test");
2344 DALI_TEST_CHECK( value );