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 gRequestInterceptorCallbackCalled = 0;
81 static std::unique_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
82 static int gConsoleMessageCallbackCalled = 0;
83 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
84 static int gResponsePolicyDecidedCallbackCalled = 0;
85 static std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
86 static int gCertificateConfirmCallbackCalled = 0;
87 static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
88 static int gSslCertificateChangedCallbackCalled = 0;
89 static std::unique_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
90 static int gHttpAuthHandlerCallbackCalled = 0;
91 static std::unique_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::unique_ptr<Dali::WebEngineContextMenu> gContextMenuShownInstance = nullptr;
101 static int gContextMenuHiddenCallbackCalled = 0;
102 static std::unique_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(const std::string& url)
122 gPageLoadStartedCallbackCalled++;
125 static void OnPageLoadInProgress(const std::string& url)
127 gPageLoadInProgressCallbackCalled++;
130 static void OnPageLoadFinished(const std::string& url)
132 gPageLoadFinishedCallbackCalled++;
135 static void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
137 gScrollEdgeReachedCallbackCalled++;
140 static void OnResponsePolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
142 gResponsePolicyDecidedCallbackCalled++;
143 gResponsePolicyDecisionInstance = std::move(decision);
146 static void OnUrlChanged(const std::string& url)
148 gUrlChangedCallbackCalled++;
151 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
153 gHitTestCreatedCallbackCalled++;
157 static void OnPageLoadError(std::unique_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 OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
227 gFormRepostDecidedCallbackCalled++;
228 gFormRepostDecidedInstance = std::move(decision);
231 static void OnFrameRendered()
233 gFrameRenderedCallbackCalled++;
236 static void OnRequestInterceptor(std::unique_ptr<Dali::WebEngineRequestInterceptor> interceptor)
238 gRequestInterceptorCallbackCalled++;
239 gRequestInterceptorInstance = std::move(interceptor);
242 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
244 gConsoleMessageCallbackCalled++;
245 gConsoleMessageInstance = std::move(message);
248 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
250 gCertificateConfirmCallbackCalled++;
251 gCertificateConfirmInstance = std::move(certificate);
254 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
256 gSslCertificateChangedCallbackCalled++;
257 gSslCertificateInstance = std::move(certificate);
260 static void OnHttpAuthHandler(std::unique_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(std::unique_ptr<Dali::WebEngineContextMenu> menu)
298 gContextMenuShownCallbackCalled++;
299 gContextMenuShownInstance = std::move(menu);
302 static void OnContextMenuHidden(std::unique_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 view.RegisterPageLoadStartedCallback( &OnPageLoadStarted );
379 view.RegisterPageLoadInProgressCallback( &OnPageLoadInProgress );
380 view.RegisterPageLoadFinishedCallback( &OnPageLoadFinished );
381 view.RegisterUrlChangedCallback( &OnUrlChanged );
382 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
383 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
384 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
385 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
387 view.LoadUrl( TEST_URL1 );
388 view.GetNaturalSize();
389 Test::EmitGlobalTimerSignal();
390 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
391 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
392 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
393 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
394 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
396 view.LoadUrl( TEST_URL2 );
398 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
399 application.SendNotification();
400 application.Render();
401 Test::EmitGlobalTimerSignal();
403 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
404 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
405 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
406 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
407 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
408 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
411 Test::EmitGlobalTimerSignal();
412 DALI_TEST_CHECK( !view.CanGoBack() );
413 DALI_TEST_CHECK( view.CanGoForward() );
416 Test::EmitGlobalTimerSignal();
417 DALI_TEST_CHECK( view.CanGoBack() );
418 DALI_TEST_CHECK( !view.CanGoForward() );
423 Test::EmitGlobalTimerSignal();
424 DALI_TEST_CHECK( !view.CanGoBack() );
425 DALI_TEST_CHECK( !view.CanGoForward() );
430 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
432 ToolkitTestApplication application;
434 WebView view = WebView::New();
435 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
436 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
437 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
438 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
439 application.GetScene().Add( view );
440 application.SendNotification();
441 application.Render();
442 DALI_TEST_CHECK( view );
444 view.RegisterPageLoadErrorCallback( &OnPageLoadError );
445 view.RegisterConsoleMessageReceivedCallback( &OnConsoleMessage );
446 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
447 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
449 view.LoadUrl( TEST_URL1 );
450 Test::EmitGlobalTimerSignal();
451 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
452 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
455 DALI_TEST_CHECK(gPageLoadErrorInstance);
456 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
457 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
458 std::string testErrorDescription("This is an error.");
459 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
460 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
463 DALI_TEST_CHECK(gConsoleMessageInstance);
464 std::string testConsoleSource("source");
465 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
466 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
467 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
468 std::string testConsoleText("This is a text.");
469 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
472 gPageLoadErrorInstance = nullptr;
473 gConsoleMessageInstance = nullptr;
478 int UtcDaliWebViewTouchAndKeys(void)
480 ToolkitTestApplication application;
482 WebView view = WebView::New();
483 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
484 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
485 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
486 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
488 application.GetScene().Add( view );
489 application.SendNotification();
490 application.Render();
492 view.GetNaturalSize();
493 view.TouchedSignal().Connect( &OnTouched );
496 Dali::Integration::TouchEvent event;
497 Dali::Integration::Point pointDown, pointUp;
499 event = Dali::Integration::TouchEvent();
500 pointDown.SetState( PointState::DOWN );
501 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
502 event.AddPoint( pointDown );
503 application.ProcessEvent( event );
505 event = Dali::Integration::TouchEvent();
506 pointUp.SetState( PointState::UP );
507 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
508 event.AddPoint( pointUp );
509 application.ProcessEvent( event );
512 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
513 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
514 application.SendNotification();
516 DALI_TEST_CHECK( gTouched );
517 DALI_TEST_CHECK( view );
522 int UtcDaliWebViewFocusGainedAndLost(void)
524 ToolkitTestApplication application;
526 WebView view = WebView::New();
527 DALI_TEST_CHECK( view );
529 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
530 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
531 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
532 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
534 application.GetScene().Add( view );
535 application.SendNotification();
536 application.Render();
538 view.SetKeyInputFocus();
539 DALI_TEST_CHECK( view.HasKeyInputFocus() );
542 view.ClearKeyInputFocus();
543 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
548 int UtcDaliWebViewPropertyPageZoomFactor(void)
550 ToolkitTestApplication application;
552 WebView view = WebView::New();
553 DALI_TEST_CHECK( view );
555 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
556 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
557 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
558 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
560 application.GetScene().Add( view );
561 application.SendNotification();
562 application.Render();
564 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
565 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
566 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
568 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
569 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
570 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
575 int UtcDaliWebViewPropertyTextZoomFactor(void)
577 ToolkitTestApplication application;
579 WebView view = WebView::New();
580 DALI_TEST_CHECK( view );
582 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
583 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
584 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
585 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
587 application.GetScene().Add( view );
588 application.SendNotification();
589 application.Render();
591 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
592 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
593 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
595 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
596 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
597 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
602 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
604 ToolkitTestApplication application;
606 WebView view = WebView::New();
607 DALI_TEST_CHECK( view );
609 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
610 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
611 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
612 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
614 application.GetScene().Add( view );
615 application.SendNotification();
616 application.Render();
618 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
619 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
624 int UtcDaliWebViewMove(void)
626 ToolkitTestApplication application;
628 WebView view = WebView::New();
629 DALI_TEST_CHECK( view );
631 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
632 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
633 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
634 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
636 application.GetScene().Add( view );
637 application.SendNotification();
638 application.Render();
640 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
641 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
642 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
647 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
649 ToolkitTestApplication application;
651 WebView view = WebView::New();
652 DALI_TEST_CHECK( view );
654 const bool kDefaultValue = true;
655 const bool kTestValue = false;
657 // Check default value
659 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
660 DALI_TEST_CHECK( value.Get( output ) );
661 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
663 // Check Set/GetProperty
664 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
665 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
666 DALI_TEST_CHECK( value.Get( output ) );
667 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
672 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
674 ToolkitTestApplication application;
676 WebView view = WebView::New();
677 DALI_TEST_CHECK( view );
679 const bool kDefaultValue = true;
680 const bool kTestValue = false;
682 // Check default value
684 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
685 DALI_TEST_CHECK( value.Get( output ) );
686 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
688 // Check Set/GetProperty
689 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
690 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
691 DALI_TEST_CHECK( value.Get( output ) );
692 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
697 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
699 ToolkitTestApplication application;
701 WebView view = WebView::New();
702 DALI_TEST_CHECK( view );
704 const bool kDefaultValue = true;
705 const bool kTestValue = false;
707 // Check default value
709 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
710 DALI_TEST_CHECK( value.Get( output ) );
711 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
713 // Check Set/GetProperty
714 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
715 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
716 DALI_TEST_CHECK( value.Get( output ) );
717 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
722 int UtcDaliWebViewHoverAndWheel(void)
724 ToolkitTestApplication application;
726 WebView view = WebView::New();
727 DALI_TEST_CHECK( view );
728 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
729 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
730 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
731 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
733 application.GetScene().Add( view );
734 application.SendNotification();
735 application.Render();
737 view.GetNaturalSize();
738 view.HoveredSignal().Connect( &OnHovered );
739 view.WheelEventSignal().Connect( &OnWheelEvent );
742 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
743 Dali::Integration::Point pointDown;
744 pointDown.SetState( PointState::DOWN );
745 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
746 event.AddPoint( pointDown );
747 application.ProcessEvent( event );
749 event = Dali::Integration::HoverEvent();
750 Dali::Integration::Point pointUp;
751 pointUp.SetState( PointState::UP );
752 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
753 event.AddPoint( pointUp );
754 application.ProcessEvent( event );
756 event = Dali::Integration::HoverEvent();
757 Dali::Integration::Point pointMotion;
758 pointUp.SetState( PointState::MOTION );
759 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
760 event.AddPoint( pointMotion );
761 application.ProcessEvent( event );
764 Dali::Integration::WheelEvent wheelEvent;
765 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
766 wheelEvent.direction = 0;
767 wheelEvent.point = Vector2( 20, 20 );
768 wheelEvent.delta = 10;
769 application.ProcessEvent( wheelEvent );
770 application.SendNotification();
772 DALI_TEST_CHECK( gHovered );
773 DALI_TEST_CHECK( gWheelEventHandled );
778 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
780 ToolkitTestApplication application;
782 WebView view = WebView::New();
783 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
784 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
785 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
786 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
787 application.GetScene().Add( view );
788 application.SendNotification();
789 application.Render();
790 DALI_TEST_CHECK( view );
792 view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
793 view.RegisterFrameRenderedCallback(&OnFrameRendered);
794 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION );
795 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
797 view.LoadUrl( TEST_URL1 );
798 Test::EmitGlobalTimerSignal();
799 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION );
800 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
802 // form repost decision.
803 DALI_TEST_CHECK(gFormRepostDecidedInstance);
804 gFormRepostDecidedInstance->Reply(true);
807 gFormRepostDecidedInstance = nullptr;
812 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
814 ToolkitTestApplication application;
816 WebView view = WebView::New();
817 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
818 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
819 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
820 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
821 application.GetScene().Add( view );
822 application.SendNotification();
823 application.Render();
824 DALI_TEST_CHECK( view );
826 view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
827 view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
828 view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
829 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
830 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
831 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
833 view.LoadUrl( TEST_URL1 );
834 Test::EmitGlobalTimerSignal();
835 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
836 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
837 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
840 DALI_TEST_CHECK(gCertificateConfirmInstance);
841 gCertificateConfirmInstance->Allow(true);
842 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
844 DALI_TEST_CHECK(gSslCertificateInstance);
845 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
846 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
848 // http authentication.
849 DALI_TEST_CHECK(gHttpAuthInstance);
850 gHttpAuthInstance->Suspend();
851 gHttpAuthInstance->UseCredential("", "");
852 gHttpAuthInstance->CancelCredential();
853 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
856 gCertificateConfirmInstance = nullptr;
857 gSslCertificateInstance = nullptr;
858 gHttpAuthInstance = nullptr;
863 int UtcDaliWebViewGetWebBackForwardList(void)
865 ToolkitTestApplication application;
867 WebView view = WebView::New();
868 DALI_TEST_CHECK( view );
870 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
871 DALI_TEST_CHECK( bfList != 0 );
876 int UtcDaliWebViewGetWebContext(void)
878 ToolkitTestApplication application;
880 WebView view = WebView::New();
881 DALI_TEST_CHECK( view );
883 Dali::Toolkit::WebContext* context = view.GetContext();
884 DALI_TEST_CHECK( context != 0 );
889 int UtcDaliWebViewGetWebCookieManager(void)
891 ToolkitTestApplication application;
893 WebView view = WebView::New();
894 DALI_TEST_CHECK( view );
896 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
897 DALI_TEST_CHECK( cookieManager != 0 );
902 int UtcDaliWebViewGetWebSettings(void)
904 ToolkitTestApplication application;
906 WebView view = WebView::New();
907 DALI_TEST_CHECK( view );
909 Dali::Toolkit::WebSettings* settings = view.GetSettings();
910 DALI_TEST_CHECK( settings != 0 );
915 int UtcDaliWebViewProperty1(void)
918 ToolkitTestApplication application;
920 WebView view = WebView::New();
921 DALI_TEST_CHECK( view );
924 view.SetProperty( WebView::Property::URL, TEST_URL1 );
925 Property::Value val = view.GetProperty( WebView::Property::URL );
926 DALI_TEST_CHECK( val.Get( local ) );
927 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
932 int UtcDaliWebViewProperty4(void)
935 ToolkitTestApplication application;
937 WebView view = WebView::New();
938 DALI_TEST_CHECK( view );
940 const std::string kDefaultValue;
941 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";
943 // Check default value
945 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
946 DALI_TEST_CHECK( value.Get( output ) );
947 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
949 // Check Set/GetProperty
950 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
951 value = view.GetProperty( WebView::Property::USER_AGENT );
952 DALI_TEST_CHECK( value.Get( output ) );
953 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
958 int UtcDaliWebViewProperty9(void)
961 ToolkitTestApplication application;
963 WebView view = WebView::New();
964 DALI_TEST_CHECK( view );
966 // Check default value
967 Dali::Vector2 output = Dali::Vector2::ONE;
968 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
969 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
971 // Check Set/GetProperty
972 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
973 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
974 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
975 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
977 // Check default value of scroll size
978 output = Dali::Vector2::ONE;
979 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
980 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
982 // Check default value of content size
983 output = Dali::Vector2::ONE;
984 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
985 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
990 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
992 ToolkitTestApplication application;
994 WebView view = WebView::New();
995 DALI_TEST_CHECK( view );
997 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
998 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
999 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1000 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1001 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1003 // Check default value
1004 std::string testText("test");
1006 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1007 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1012 int UtcDaliWebViewPropertyTitleFavicon(void)
1014 ToolkitTestApplication application;
1016 char argv[] = "--test";
1017 WebView view = WebView::New( 1, (char**)&argv );
1018 DALI_TEST_CHECK( view );
1021 view.ClearAllTilesResources();
1023 // Check default value of title
1024 std::string testValue("title");
1026 view.GetProperty( WebView::Property::TITLE ).Get( output );
1027 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1029 // Check the case that favicon is not null.
1030 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1031 DALI_TEST_CHECK( favicon );
1032 Dali::Vector3 iconsize = favicon.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1033 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1035 // Check the case that favicon is null.
1036 favicon = view.GetFavicon();
1037 DALI_TEST_CHECK( !favicon );
1042 int UtcDaliWebViewContextMenuShownAndHidden(void)
1044 ToolkitTestApplication application;
1046 WebView view = WebView::New();
1047 DALI_TEST_CHECK( view );
1050 view.RegisterContextMenuShownCallback( &OnContextMenuShown );
1051 view.RegisterContextMenuHiddenCallback( &OnContextMenuHidden );
1052 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 0, TEST_LOCATION );
1053 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION );
1054 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1055 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1057 view.LoadUrl( TEST_URL1 );
1058 Test::EmitGlobalTimerSignal();
1059 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 1, TEST_LOCATION );
1060 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION );
1062 // check context meun & its items.
1063 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1064 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1065 DALI_TEST_CHECK(item.get() != 0);
1066 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1067 DALI_TEST_CHECK(itemList.size() == 1);
1068 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1069 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1070 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1071 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1072 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1074 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1075 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1076 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1077 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1078 DALI_TEST_CHECK(item->IsEnabled());
1079 std::string testLinkUrl("http://test.html");
1080 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1081 std::string testImageUrl("http://test.jpg");
1082 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1083 std::string testTitle("title");
1084 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1085 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1087 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1089 gContextMenuShownInstance = nullptr;
1090 gContextMenuHiddenInstance = nullptr;
1095 int UtcDaliWebViewScrollBy(void)
1097 ToolkitTestApplication application;
1099 WebView view = WebView::New();
1100 DALI_TEST_CHECK( view );
1103 view.RegisterScrollEdgeReachedCallback( &OnScrollEdgeReached );
1104 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1106 view.LoadUrl( TEST_URL1 );
1107 Test::EmitGlobalTimerSignal();
1109 // set scroll position.
1110 Dali::Vector2 output = Dali::Vector2::ONE;
1111 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1112 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1113 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1114 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1116 // scroll by and trigger scrollEdgeReached event.
1117 view.ScrollBy( 50, 50 );
1118 Test::EmitGlobalTimerSignal();
1120 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1121 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1122 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1124 // scroll by and trigger scrollEdgeReached event.
1125 bool result = view.ScrollEdgeBy( 50, 50 );
1126 DALI_TEST_CHECK( result );
1127 Test::EmitGlobalTimerSignal();
1129 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1130 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1131 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1136 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1138 ToolkitTestApplication application;
1140 WebView view = WebView::New();
1141 DALI_TEST_CHECK( view );
1143 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1144 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1145 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1146 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1148 application.GetScene().Add( view );
1149 application.SendNotification();
1150 application.Render();
1152 view.ActivateAccessibility(true);
1153 view.AddDynamicCertificatePath("host", "test/to/path");
1154 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1155 DALI_TEST_CHECK( found );
1157 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1158 float result = view.GetScaleFactor();
1159 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1161 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1162 result = view.GetScaleFactor();
1163 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1168 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1171 ToolkitTestApplication application;
1173 char argv[] = "--test";
1174 WebView view = WebView::New( 1, (char**)&argv );
1175 DALI_TEST_CHECK( view );
1177 // Check GetScreenshot
1178 Dali::Rect<int> viewArea;
1181 viewArea.width = 10;
1182 viewArea.height = 10;
1183 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1184 DALI_TEST_CHECK( screenshot );
1185 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1186 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1188 // Check GetScreenshotAsynchronously
1191 viewArea.width = 100;
1192 viewArea.height = 100;
1193 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1194 DALI_TEST_CHECK( result );
1196 Test::EmitGlobalTimerSignal();
1198 Test::EmitGlobalTimerSignal();
1199 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1204 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1207 ToolkitTestApplication application;
1209 char argv[] = "--test";
1210 WebView view = WebView::New( 1, (char**)&argv );
1211 DALI_TEST_CHECK( view );
1213 // Check CheckVideoPlayingAsynchronously
1214 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1215 DALI_TEST_CHECK( result );
1216 Test::EmitGlobalTimerSignal();
1217 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1219 // Check RegisterGeolocationPermissionCallback
1220 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1221 Test::EmitGlobalTimerSignal();
1222 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1227 int UtcDaliWebViewHttpRequestInterceptor(void)
1229 ToolkitTestApplication application;
1231 WebView view = WebView::New();
1232 DALI_TEST_CHECK( view );
1235 view.RegisterRequestInterceptorCallback( &OnRequestInterceptor );
1236 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1237 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1239 view.LoadUrl( TEST_URL1 );
1240 Test::EmitGlobalTimerSignal();
1241 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1243 // check request interceptor.
1244 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1245 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1246 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1247 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1248 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1249 std::string testUrl("http://test.html");
1250 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1252 gRequestInterceptorInstance = nullptr;
1257 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1259 ToolkitTestApplication application;
1261 WebView view = WebView::New();
1262 DALI_TEST_CHECK( view );
1265 view.RegisterResponsePolicyDecidedCallback( &OnResponsePolicyDecided );
1266 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION );
1267 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1269 view.LoadUrl( TEST_URL1 );
1270 Test::EmitGlobalTimerSignal();
1271 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION );
1273 // check response policy decision & its frame.
1274 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1275 std::string testUrl("http://test.html");
1276 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1277 std::string testCookie("test:abc");
1278 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1279 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1280 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1281 std::string testResponseMime("txt/xml");
1282 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1283 int32_t ResponseStatusCode = 500;
1284 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1285 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1286 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1287 std::string testScheme("test");
1288 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1289 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1290 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1291 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1293 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1294 DALI_TEST_CHECK(webFrame);
1295 DALI_TEST_CHECK(webFrame->IsMainFrame());
1297 gResponsePolicyDecisionInstance = nullptr;
1302 int UtcDaliWebViewHitTest(void)
1304 ToolkitTestApplication application;
1306 WebView view = WebView::New();
1307 DALI_TEST_CHECK( view );
1310 view.LoadUrl( TEST_URL1 );
1313 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1314 DALI_TEST_CHECK(hitTest != 0);
1315 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1316 std::string testLinkUri("http://test.html");
1317 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1318 std::string testLinkTitle("test");
1319 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1320 std::string testLinkLabel("label");
1321 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1322 std::string testImageUri("http://test.jpg");
1323 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1324 std::string testMediaUri("http://test.mp4");
1325 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1326 std::string testTagName("img");
1327 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1328 std::string testNodeValue("test");
1329 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1330 Dali::Property::Map* testMap = &hitTest->GetAttributes();
1331 DALI_TEST_CHECK(testMap);
1332 std::string testImageFileNameExtension("jpg");
1333 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1334 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1335 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1338 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1339 DALI_TEST_CHECK(result);
1340 Test::EmitGlobalTimerSignal();
1341 DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
1346 int UtcDaliWebViewEvaluteJavaScript(void)
1348 ToolkitTestApplication application;
1350 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1352 view.LoadHtmlString( "<body>Hello World!</body>" );
1353 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1354 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1355 Test::EmitGlobalTimerSignal();
1357 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1362 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1364 ToolkitTestApplication application;
1366 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1368 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1369 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1370 view.JavaScriptAlertReply();
1371 Test::EmitGlobalTimerSignal();
1372 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1374 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1375 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1376 view.JavaScriptConfirmReply( true );
1377 Test::EmitGlobalTimerSignal();
1378 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1380 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1381 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1382 view.JavaScriptPromptReply( "it is a prompt." );
1383 Test::EmitGlobalTimerSignal();
1384 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1389 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1391 ToolkitTestApplication application;
1393 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1394 DALI_TEST_CHECK( view );
1396 std::string html("<body>Hello World!</body>");
1397 std::string basicUri("http://basicurl");
1398 std::string unreachableUrl("http://unreachableurl");
1399 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1400 DALI_TEST_CHECK( result );
1402 application.SendNotification();
1403 application.Render();
1404 Test::EmitGlobalTimerSignal();
1406 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1407 DALI_TEST_CHECK( result );
1412 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1414 ToolkitTestApplication application;
1416 WebView view = WebView::New();
1417 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1418 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1419 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1420 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1422 application.GetScene().Add( view );
1423 application.SendNotification();
1424 application.Render();
1425 DALI_TEST_CHECK( view );
1427 view.LoadUrl( "http://test.html" );
1428 bool result = view.AddCustomHeader("key", "value");
1429 DALI_TEST_CHECK( result );
1431 result = view.ReloadWithoutCache();
1432 DALI_TEST_CHECK( result );
1434 uint32_t portNumber = view.StartInspectorServer(5000);
1435 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1437 application.SendNotification();
1438 application.Render();
1439 Test::EmitGlobalTimerSignal();
1441 result = view.StopInspectorServer();
1442 DALI_TEST_CHECK( result );
1444 view.SuspendNetworkLoading();
1446 result = view.RemoveCustomHeader("key");
1447 DALI_TEST_CHECK( result );
1449 view.ResumeNetworkLoading();
1454 int UtcDaliWebViewMethodsForCoverage(void)
1456 ToolkitTestApplication application;
1458 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1460 view.LoadHtmlString( "<body>Hello World!</body>" );
1461 view.AddJavaScriptMessageHandler( "jsObject",
1462 []( const std::string& arg ) {
1465 view.SetTtsFocus(true);
1467 DALI_TEST_CHECK( view );
1472 // test cases for web backforward list.
1474 int UtcDaliWebBackForwardListCheckItem(void)
1476 ToolkitTestApplication application;
1478 WebView view = WebView::New();
1479 DALI_TEST_CHECK( view );
1481 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1482 DALI_TEST_CHECK( bfList != 0 )
1484 unsigned int itemCount = bfList->GetItemCount();
1485 DALI_TEST_CHECK( itemCount == 1 )
1487 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1488 DALI_TEST_CHECK( citem != 0 );
1490 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1491 DALI_TEST_CHECK( citemP != 0 );
1493 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1494 DALI_TEST_CHECK( citemN != 0 );
1496 const std::string kDefaultUrl( "http://url" );
1497 std::string testValue = citem->GetUrl();
1498 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1500 const std::string kDefaultTitle( "title" );
1501 testValue = citem->GetTitle();
1502 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1504 const std::string kDefaultOriginalUrl( "http://originalurl" );
1505 testValue = citem->GetOriginalUrl();
1506 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1508 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1509 DALI_TEST_CHECK( item != 0 );
1511 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1512 DALI_TEST_CHECK( vecBack.size() == 1 );
1514 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1515 DALI_TEST_CHECK( vecForward.size() == 1 );
1520 // test cases for web context.
1522 int UtcDaliWebContextGetSetCacheModel(void)
1524 ToolkitTestApplication application;
1526 WebView view = WebView::New();
1527 DALI_TEST_CHECK( view );
1529 Dali::Toolkit::WebContext* context = view.GetContext();
1530 DALI_TEST_CHECK( context != 0 )
1532 std::string kDefaultValue;
1535 context->SetAppId( "id" );
1536 context->SetApplicationType( Dali::WebEngineContext::ApplicationType::OTHER );
1537 context->SetTimeOffset( 0 );
1538 context->SetTimeZoneOffset( 0, 0 );
1539 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1540 context->DeleteAllWebDatabase();
1541 context->DeleteAllWebStorage();
1542 context->DeleteLocalFileSystem();
1543 context->ClearCache();
1544 context->DeleteAllFormPasswordData();
1545 context->DeleteAllFormCandidateData();
1547 // Check default value
1548 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1549 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1551 // Check Set/GetProperty
1552 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1553 value = context->GetCacheModel();
1554 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1556 // Get cache enabled
1557 context->EnableCache( true );
1558 DALI_TEST_CHECK( context->IsCacheEnabled() );
1561 context->SetCertificateFilePath( "test" );
1562 std::string str = context->GetCertificateFilePath();
1563 DALI_TEST_EQUALS( str, "test", TEST_LOCATION );
1566 DALI_TEST_CHECK( context->SetAppVersion( "test" ) );
1569 std::vector<std::string> temp;
1570 context->RegisterUrlSchemesAsCorsEnabled( temp );
1571 context->RegisterJsPluginMimeTypes( temp );
1572 context->DeleteFormPasswordDataList( temp );
1575 context->SetDefaultZoomFactor( 1.0f );
1576 DALI_TEST_EQUALS( context->GetDefaultZoomFactor(), float( 1.0f ), TEST_LOCATION );
1578 // Delete cache and database
1579 DALI_TEST_CHECK( context->DeleteAllApplicationCache() );
1580 DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() );
1583 context->SetProxyUri( "test" );
1584 DALI_TEST_EQUALS( context->GetProxyUri(), "test", TEST_LOCATION );
1585 context->SetProxyBypassRule("", "test");
1586 DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION );
1589 DALI_TEST_CHECK( context->FreeUnusedMemory() );
1594 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1596 ToolkitTestApplication application;
1598 WebView view = WebView::New();
1599 DALI_TEST_CHECK( view );
1601 Dali::Toolkit::WebContext* context = view.GetContext();
1602 DALI_TEST_CHECK( context != 0 )
1604 std::string kDefaultValue;
1606 // get origins of web database
1607 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1608 DALI_TEST_CHECK( result );
1610 Test::EmitGlobalTimerSignal();
1611 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1612 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1614 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1615 DALI_TEST_CHECK( origin );
1617 result = context->DeleteWebDatabase(*origin);
1618 DALI_TEST_CHECK( result );
1620 // get origins of web storage
1621 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1622 DALI_TEST_CHECK( result );
1624 Test::EmitGlobalTimerSignal();
1625 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1626 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1628 origin = gSecurityOriginList[0].get();
1629 DALI_TEST_CHECK( origin );
1631 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1632 DALI_TEST_CHECK( result );
1633 Test::EmitGlobalTimerSignal();
1634 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1636 result = context->DeleteWebStorage(*origin);
1637 DALI_TEST_CHECK( result );
1639 result = context->DeleteApplicationCache(*origin);
1640 DALI_TEST_CHECK( result );
1642 // form passwords, download state, mime type.
1643 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1644 Test::EmitGlobalTimerSignal();
1645 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1646 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1647 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1648 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1650 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1651 Test::EmitGlobalTimerSignal();
1652 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1654 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1655 Test::EmitGlobalTimerSignal();
1656 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1658 gSecurityOriginList.clear();
1659 gPasswordDataList.clear();
1664 // test cases for web cookie manager.
1666 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1668 ToolkitTestApplication application;
1670 WebView view = WebView::New();
1671 DALI_TEST_CHECK( view );
1673 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1674 DALI_TEST_CHECK( cookieManager != 0 )
1676 const std::string kDefaultValue;
1679 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1680 cookieManager->ClearCookies();
1682 // Check default value
1683 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1684 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1686 // Check Set/GetProperty
1687 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1688 value = cookieManager->GetCookieAcceptPolicy();
1689 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1694 int UtcDaliWebCookieManagerChangesWatch(void)
1696 ToolkitTestApplication application;
1698 WebView view = WebView::New();
1699 DALI_TEST_CHECK( view );
1701 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1702 DALI_TEST_CHECK( cookieManager != 0 )
1704 cookieManager->ChangesWatch(&OnChangesWatch);
1705 Test::EmitGlobalTimerSignal();
1706 DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
1711 // test cases for web settings.
1713 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1715 ToolkitTestApplication application;
1717 WebView view = WebView::New();
1718 DALI_TEST_CHECK( view );
1720 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1721 DALI_TEST_CHECK( settings != 0 )
1724 settings->AllowMixedContents( false );
1725 settings->EnableSpatialNavigation( false );
1726 settings->EnableWebSecurity( false );
1727 settings->EnableCacheBuilder( false );
1728 settings->EnableDoNotTrack( false );
1729 settings->UseScrollbarThumbFocusNotifications( false );
1730 settings->AllowFileAccessFromExternalUrl( false );
1731 settings->AllowScriptsOpenWindows( false );
1733 // Check default value
1734 int value = settings->GetDefaultFontSize();
1735 DALI_TEST_CHECK( value == 16 );
1737 // Check Set/GetProperty
1738 settings->SetDefaultFontSize( 20 );
1739 value = settings->GetDefaultFontSize();
1740 DALI_TEST_CHECK( value == 20 );
1745 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1747 ToolkitTestApplication application;
1749 WebView view = WebView::New();
1750 DALI_TEST_CHECK( view );
1752 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1753 DALI_TEST_CHECK( settings != 0 )
1756 settings->AllowMixedContents( false );
1757 settings->EnableSpatialNavigation( false );
1758 settings->EnableWebSecurity( false );
1759 settings->EnableCacheBuilder( false );
1760 settings->EnableDoNotTrack( false );
1761 settings->UseScrollbarThumbFocusNotifications( false );
1762 settings->AllowFileAccessFromExternalUrl( false );
1763 settings->AllowScriptsOpenWindows( false );
1765 // Check default value is true or not
1766 bool value = settings->IsJavaScriptEnabled();
1767 DALI_TEST_CHECK( value );
1769 // Check Set/GetProperty
1770 settings->EnableJavaScript( false );
1771 value = settings->IsJavaScriptEnabled();
1772 DALI_TEST_CHECK( !value );
1777 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1779 ToolkitTestApplication application;
1781 WebView view = WebView::New();
1782 DALI_TEST_CHECK( view );
1784 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1785 DALI_TEST_CHECK( settings != 0 )
1788 settings->AllowMixedContents( false );
1789 settings->EnableSpatialNavigation( false );
1790 settings->EnableWebSecurity( false );
1791 settings->EnableCacheBuilder( false );
1792 settings->EnableDoNotTrack( false );
1793 settings->UseScrollbarThumbFocusNotifications( false );
1794 settings->AllowFileAccessFromExternalUrl( false );
1795 settings->AllowScriptsOpenWindows( false );
1797 // Check default value is true or not
1798 bool value = settings->IsAutoFittingEnabled();
1799 DALI_TEST_CHECK( value );
1801 // Check Set/GetProperty
1802 settings->EnableAutoFitting( false );
1803 value = settings->IsAutoFittingEnabled();
1804 DALI_TEST_CHECK( !value );
1809 int UtcDaliWebSettingsCheckEnablePlugins(void)
1811 ToolkitTestApplication application;
1813 WebView view = WebView::New();
1814 DALI_TEST_CHECK( view );
1816 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1817 DALI_TEST_CHECK( settings != 0 )
1820 settings->AllowMixedContents( false );
1821 settings->EnableSpatialNavigation( false );
1822 settings->EnableWebSecurity( false );
1823 settings->EnableCacheBuilder( false );
1824 settings->EnableDoNotTrack( false );
1825 settings->UseScrollbarThumbFocusNotifications( false );
1826 settings->AllowFileAccessFromExternalUrl( false );
1827 settings->AllowScriptsOpenWindows( false );
1829 // Check default value is true or not
1830 bool value = settings->ArePluginsEnabled();
1831 DALI_TEST_CHECK( value );
1833 // Check Set/GetProperty
1834 settings->EnablePlugins( false );
1835 value = settings->ArePluginsEnabled();
1836 DALI_TEST_CHECK( !value );
1841 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1843 ToolkitTestApplication application;
1845 WebView view = WebView::New();
1846 DALI_TEST_CHECK( view );
1848 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1849 DALI_TEST_CHECK( settings != 0 )
1852 settings->AllowMixedContents( false );
1853 settings->EnableSpatialNavigation( false );
1854 settings->EnableWebSecurity( false );
1855 settings->EnableCacheBuilder( false );
1856 settings->EnableDoNotTrack( false );
1857 settings->UseScrollbarThumbFocusNotifications( false );
1858 settings->AllowFileAccessFromExternalUrl( false );
1859 settings->AllowScriptsOpenWindows( false );
1861 // Check default value is true or not
1862 bool value = settings->IsPrivateBrowsingEnabled();
1863 DALI_TEST_CHECK( value );
1865 // Check Set/GetProperty
1866 settings->EnablePrivateBrowsing( false );
1867 value = settings->IsPrivateBrowsingEnabled();
1868 DALI_TEST_CHECK( !value );
1873 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1875 ToolkitTestApplication application;
1877 WebView view = WebView::New();
1878 DALI_TEST_CHECK( view );
1880 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1881 DALI_TEST_CHECK( settings != 0 )
1884 settings->AllowMixedContents( false );
1885 settings->EnableSpatialNavigation( false );
1886 settings->EnableWebSecurity( false );
1887 settings->EnableCacheBuilder( false );
1888 settings->EnableDoNotTrack( false );
1889 settings->UseScrollbarThumbFocusNotifications( false );
1890 settings->AllowFileAccessFromExternalUrl( false );
1891 settings->AllowScriptsOpenWindows( false );
1893 // Check default value is true or not
1894 bool value = settings->IsLinkMagnifierEnabled();
1895 DALI_TEST_CHECK( value );
1897 // Check Set/GetProperty
1898 settings->EnableLinkMagnifier( false );
1899 value = settings->IsLinkMagnifierEnabled();
1900 DALI_TEST_CHECK( !value );
1905 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1907 ToolkitTestApplication application;
1909 WebView view = WebView::New();
1910 DALI_TEST_CHECK( view );
1912 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1913 DALI_TEST_CHECK( settings != 0 )
1916 settings->AllowMixedContents( false );
1917 settings->EnableSpatialNavigation( false );
1918 settings->EnableWebSecurity( false );
1919 settings->EnableCacheBuilder( false );
1920 settings->EnableDoNotTrack( false );
1921 settings->UseScrollbarThumbFocusNotifications( false );
1922 settings->AllowFileAccessFromExternalUrl( false );
1923 settings->AllowScriptsOpenWindows( false );
1925 // Check default value is true or not
1926 bool value = settings->IsKeypadWithoutUserActionUsed();
1927 DALI_TEST_CHECK( value );
1929 // Check Set/GetProperty
1930 settings->UseKeypadWithoutUserAction( false );
1931 value = settings->IsKeypadWithoutUserActionUsed();
1932 DALI_TEST_CHECK( !value );
1937 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1939 ToolkitTestApplication application;
1941 WebView view = WebView::New();
1942 DALI_TEST_CHECK( view );
1944 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1945 DALI_TEST_CHECK( settings != 0 )
1948 settings->AllowMixedContents( false );
1949 settings->EnableSpatialNavigation( false );
1950 settings->EnableWebSecurity( false );
1951 settings->EnableCacheBuilder( false );
1952 settings->EnableDoNotTrack( false );
1953 settings->UseScrollbarThumbFocusNotifications( false );
1954 settings->AllowFileAccessFromExternalUrl( false );
1955 settings->AllowScriptsOpenWindows( false );
1957 // Check default value is true or not
1958 bool value = settings->IsAutofillPasswordFormEnabled();
1959 DALI_TEST_CHECK( value );
1960 settings->EnableAutofillPasswordForm( false );
1961 value = settings->IsAutofillPasswordFormEnabled();
1962 DALI_TEST_CHECK( !value );
1966 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1968 ToolkitTestApplication application;
1970 WebView view = WebView::New();
1971 DALI_TEST_CHECK( view );
1973 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1974 DALI_TEST_CHECK( settings != 0 );
1977 settings->AllowMixedContents( false );
1978 settings->EnableSpatialNavigation( false );
1979 settings->EnableWebSecurity( false );
1980 settings->EnableCacheBuilder( false );
1981 settings->EnableDoNotTrack( false );
1982 settings->UseScrollbarThumbFocusNotifications( false );
1983 settings->AllowFileAccessFromExternalUrl( false );
1984 settings->AllowScriptsOpenWindows( false );
1986 // Check default value is true or not
1987 bool value = settings->IsFormCandidateDataEnabled();
1988 DALI_TEST_CHECK( value );
1990 // Check Set/GetProperty
1991 settings->EnableFormCandidateData( false );
1992 value = settings->IsFormCandidateDataEnabled();
1993 DALI_TEST_CHECK( !value );
1998 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2000 ToolkitTestApplication application;
2002 WebView view = WebView::New();
2003 DALI_TEST_CHECK( view );
2005 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2006 DALI_TEST_CHECK( settings != 0 );
2009 settings->AllowMixedContents( false );
2010 settings->EnableSpatialNavigation( false );
2011 settings->EnableWebSecurity( false );
2012 settings->EnableCacheBuilder( false );
2013 settings->EnableDoNotTrack( false );
2014 settings->UseScrollbarThumbFocusNotifications( false );
2015 settings->AllowFileAccessFromExternalUrl( false );
2016 settings->AllowScriptsOpenWindows( false );
2018 // Check default value is true or not
2019 bool value = settings->IsTextSelectionEnabled();
2020 DALI_TEST_CHECK( value );
2022 //Check Set/GetProperty
2023 settings->EnableTextSelection(false);
2024 value = settings->IsTextSelectionEnabled();
2025 DALI_TEST_CHECK( !value );
2030 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2032 ToolkitTestApplication application;
2034 WebView view = WebView::New();
2035 DALI_TEST_CHECK( view );
2037 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2038 DALI_TEST_CHECK( settings != 0 );
2041 settings->AllowMixedContents( false );
2042 settings->EnableSpatialNavigation( false );
2043 settings->EnableWebSecurity( false );
2044 settings->EnableCacheBuilder( false );
2045 settings->EnableDoNotTrack( false );
2046 settings->UseScrollbarThumbFocusNotifications( false );
2047 settings->AllowFileAccessFromExternalUrl( false );
2048 settings->AllowScriptsOpenWindows( false );
2050 // Check default value is true or not
2051 bool value = settings->IsTextAutosizingEnabled();
2052 DALI_TEST_CHECK( value );
2054 // Check Set/GetProperty
2055 settings->EnableTextAutosizing(false);
2056 value = settings->IsTextAutosizingEnabled();
2057 DALI_TEST_CHECK( !value );
2062 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2064 ToolkitTestApplication application;
2066 WebView view = WebView::New();
2067 DALI_TEST_CHECK( view );
2069 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2070 DALI_TEST_CHECK( settings != 0 );
2073 settings->AllowMixedContents( false );
2074 settings->EnableSpatialNavigation( false );
2075 settings->EnableWebSecurity( false );
2076 settings->EnableCacheBuilder( false );
2077 settings->EnableDoNotTrack( false );
2078 settings->UseScrollbarThumbFocusNotifications( false );
2079 settings->AllowFileAccessFromExternalUrl( false );
2080 settings->AllowScriptsOpenWindows( false );
2082 // Check default value is true or not
2083 bool value = settings->IsArrowScrollEnabled();
2084 DALI_TEST_CHECK( value );
2086 // Check Set/GetProperty
2087 settings->EnableArrowScroll(false);
2088 value = settings->IsArrowScrollEnabled();
2089 DALI_TEST_CHECK( !value );
2094 int UtcDaliWebSettingsCheckEnableClipboard(void)
2096 ToolkitTestApplication application;
2098 WebView view = WebView::New();
2099 DALI_TEST_CHECK( view );
2101 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2102 DALI_TEST_CHECK( settings != 0 );
2105 settings->AllowMixedContents( false );
2106 settings->EnableSpatialNavigation( false );
2107 settings->EnableWebSecurity( false );
2108 settings->EnableCacheBuilder( false );
2109 settings->EnableDoNotTrack( false );
2110 settings->UseScrollbarThumbFocusNotifications( false );
2111 settings->AllowFileAccessFromExternalUrl( false );
2112 settings->AllowScriptsOpenWindows( false );
2114 // Check default value is true or not
2115 bool value = settings->IsClipboardEnabled();
2116 DALI_TEST_CHECK( value );
2117 settings->EnableClipboard(false);
2118 value = settings->IsClipboardEnabled();
2119 DALI_TEST_CHECK( !value );
2123 int UtcDaliWebSettingsCheckEnableImePanel(void)
2125 ToolkitTestApplication application;
2127 WebView view = WebView::New();
2128 DALI_TEST_CHECK( view );
2130 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2131 DALI_TEST_CHECK( settings != 0 );
2134 settings->AllowMixedContents( false );
2135 settings->EnableSpatialNavigation( false );
2136 settings->EnableWebSecurity( false );
2137 settings->EnableCacheBuilder( false );
2138 settings->EnableDoNotTrack( false );
2139 settings->UseScrollbarThumbFocusNotifications( false );
2140 settings->AllowFileAccessFromExternalUrl( false );
2141 settings->AllowScriptsOpenWindows( false );
2143 // Check default value is true or not
2144 bool value = settings->IsImePanelEnabled();
2145 DALI_TEST_CHECK( value );
2147 // Check Set/GetProperty
2148 settings->EnableImePanel(false);
2149 value = settings->IsImePanelEnabled();
2150 DALI_TEST_CHECK( !value );
2155 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2157 ToolkitTestApplication application;
2159 WebView view = WebView::New();
2160 DALI_TEST_CHECK( view );
2162 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2163 DALI_TEST_CHECK( settings != 0 )
2166 settings->AllowMixedContents( false );
2167 settings->EnableSpatialNavigation( false );
2168 settings->EnableWebSecurity( false );
2169 settings->EnableCacheBuilder( false );
2170 settings->EnableDoNotTrack( false );
2171 settings->UseScrollbarThumbFocusNotifications( false );
2172 settings->AllowFileAccessFromExternalUrl( false );
2173 settings->AllowScriptsOpenWindows( false );
2175 // Check default value is true or not
2176 bool value = settings->AreImagesLoadedAutomatically();
2177 DALI_TEST_CHECK( value );
2179 // Check Set/GetProperty
2180 settings->AllowImagesLoadAutomatically( false );
2181 value = settings->AreImagesLoadedAutomatically();
2182 DALI_TEST_CHECK( !value );
2187 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2189 ToolkitTestApplication application;
2191 WebView view = WebView::New();
2192 DALI_TEST_CHECK( view );
2194 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2195 DALI_TEST_CHECK( settings != 0 )
2197 const std::string kDefaultValue;
2198 const std::string kTestValue = "UTF-8";
2201 settings->AllowMixedContents( false );
2202 settings->EnableSpatialNavigation( false );
2203 settings->EnableWebSecurity( false );
2204 settings->EnableCacheBuilder( false );
2205 settings->EnableDoNotTrack( false );
2206 settings->UseScrollbarThumbFocusNotifications( false );
2207 settings->AllowFileAccessFromExternalUrl( false );
2208 settings->AllowScriptsOpenWindows( false );
2210 // Check default value
2211 std::string value = settings->GetDefaultTextEncodingName();
2212 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2214 // Check Set/GetProperty
2215 settings->SetDefaultTextEncodingName( kTestValue );
2216 value = settings->GetDefaultTextEncodingName();
2217 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
2222 int UtcDaliWebSettingsSetViewportMetaTag(void)
2224 ToolkitTestApplication application;
2226 WebView view = WebView::New();
2227 DALI_TEST_CHECK( view );
2229 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2230 DALI_TEST_CHECK( settings != 0 )
2232 // Check the value is true or not
2233 bool value = settings->SetViewportMetaTag(true);
2234 DALI_TEST_CHECK( value );
2239 int UtcDaliWebSettingsSetForceZoom(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 // Check the value is true or not
2250 bool value = settings->SetForceZoom(true);
2251 DALI_TEST_CHECK( value );
2253 value = settings->IsZoomForced();
2254 DALI_TEST_CHECK( value );
2259 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2261 ToolkitTestApplication application;
2263 WebView view = WebView::New();
2264 DALI_TEST_CHECK( view );
2266 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2267 DALI_TEST_CHECK( settings != 0 )
2269 // Check the value is true or not
2270 bool value = settings->SetTextZoomEnabled(true);
2271 DALI_TEST_CHECK( value );
2273 value = settings->IsTextZoomEnabled();
2274 DALI_TEST_CHECK( value );
2279 int UtcDaliWebSettingsSetExtraFeature(void)
2281 ToolkitTestApplication application;
2283 WebView view = WebView::New();
2284 DALI_TEST_CHECK( view );
2286 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2287 DALI_TEST_CHECK( settings != 0 )
2289 // Check the value is true or not
2290 settings->SetExtraFeature("test", true);
2291 bool value = settings->IsExtraFeatureEnabled("test");
2292 DALI_TEST_CHECK( value );