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-frame.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
34 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
35 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
36 #include <dali/integration-api/events/hover-event-integ.h>
37 #include <dali/integration-api/events/key-event-integ.h>
38 #include <dali/integration-api/events/touch-event-integ.h>
39 #include <dali/integration-api/events/wheel-event-integ.h>
40 #include <dali/public-api/images/pixel-data.h>
41 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
42 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
43 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
44 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
45 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
46 #include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
48 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
51 using namespace Toolkit;
56 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
57 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
59 static int gPageLoadStartedCallbackCalled = 0;
60 static int gPageLoadInProgressCallbackCalled = 0;
61 static int gPageLoadFinishedCallbackCalled = 0;
62 static int gPageLoadErrorCallbackCalled = 0;
63 static std::shared_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
64 static int gScrollEdgeReachedCallbackCalled = 0;
65 static int gUrlChangedCallbackCalled = 0;
66 static int gEvaluateJavaScriptCallbackCalled = 0;
67 static int gJavaScriptAlertCallbackCalled = 0;
68 static int gJavaScriptConfirmCallbackCalled = 0;
69 static int gJavaScriptPromptCallbackCalled = 0;
70 static int gScreenshotCapturedCallbackCalled = 0;
71 static int gVideoPlayingCallbackCalled = 0;
72 static int gGeolocationPermissionCallbackCalled = 0;
73 static bool gTouched = false;
74 static bool gHovered = false;
75 static bool gWheelEventHandled = false;
76 static int gFormRepostDecisionCallbackCalled = 0;
77 static std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> gFormRepostDecisionInstance = nullptr;
78 static int gFrameRenderedCallbackCalled = 0;
79 static int gRequestInterceptorCallbackCalled = 0;
80 static std::shared_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
81 static int gConsoleMessageCallbackCalled = 0;
82 static std::shared_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
83 static int gPolicyDecisionCallbackCalled = 0;
84 static std::shared_ptr<Dali::WebEnginePolicyDecision> gPolicyDecisionInstance = nullptr;
85 static int gCertificateConfirmCallbackCalled = 0;
86 static std::shared_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
87 static int gSslCertificateChangedCallbackCalled = 0;
88 static std::shared_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
89 static int gHttpAuthHandlerCallbackCalled = 0;
90 static std::shared_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
91 static int gSecurityOriginsAcquiredCallbackCalled = 0;
92 static int gStorageUsageAcquiredCallbackCalled = 0;
93 static int gFormPasswordsAcquiredCallbackCalled = 0;
94 static int gDownloadStartedCallbackCalled = 0;
95 static int gMimeOverriddenCallbackCalled = 0;
96 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
97 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
98 static int gContextMenuCustomizedCallbackCalled = 0;
99 static std::shared_ptr<Dali::WebEngineContextMenu> gContextMenuInstance = 0;
100 static int gContextMenuItemSelectedCallbackCalled = 0;
101 static std::shared_ptr<Dali::WebEngineContextMenuItem> gContextMenuItemInstance = 0;
103 struct CallbackFunctor
105 CallbackFunctor(bool* callbackFlag)
106 : mCallbackFlag( callbackFlag )
112 *mCallbackFlag = true;
117 static void OnPageLoadStarted( WebView view, const std::string& url )
119 gPageLoadStartedCallbackCalled++;
122 static void OnPageLoadInProgress( WebView view, const std::string& url )
124 gPageLoadInProgressCallbackCalled++;
127 static void OnPageLoadFinished( WebView view, const std::string& url )
129 gPageLoadFinishedCallbackCalled++;
132 static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
134 gScrollEdgeReachedCallbackCalled++;
137 static void OnPolicyDecisionRequest(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
139 gPolicyDecisionCallbackCalled++;
140 gPolicyDecisionInstance = std::move(decision);
143 static void OnUrlChanged( WebView view, const std::string& url )
145 gUrlChangedCallbackCalled++;
148 static void OnPageLoadError(WebView view, std::shared_ptr<Dali::WebEngineLoadError> error)
150 gPageLoadErrorCallbackCalled++;
151 gPageLoadErrorInstance = std::move(error);
154 static void OnEvaluateJavaScript( const std::string& result )
156 gEvaluateJavaScriptCallbackCalled++;
159 static bool OnJavaScriptAlert( const std::string& result )
161 gJavaScriptAlertCallbackCalled++;
165 static bool OnJavaScriptConfirm( const std::string& result )
167 gJavaScriptConfirmCallbackCalled++;
171 static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string& message2 )
173 gJavaScriptPromptCallbackCalled++;
177 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
179 gScreenshotCapturedCallbackCalled++;
182 static void OnVideoPlaying(bool isPlaying)
184 gVideoPlayingCallbackCalled++;
187 static bool OnGeolocationPermission(const std::string&, const std::string&)
189 gGeolocationPermissionCallbackCalled++;
193 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
199 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
205 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheel )
207 gWheelEventHandled = true;
211 static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> decision)
213 gFormRepostDecisionCallbackCalled++;
214 gFormRepostDecisionInstance = std::move(decision);
217 static void OnFrameRendered(WebView)
219 gFrameRenderedCallbackCalled++;
222 static void OnRequestInterceptor(WebView view, std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
224 gRequestInterceptorCallbackCalled++;
225 gRequestInterceptorInstance = std::move(interceptor);
228 static void OnConsoleMessage(WebView view, std::shared_ptr<Dali::WebEngineConsoleMessage> message)
230 gConsoleMessageCallbackCalled++;
231 gConsoleMessageInstance = std::move(message);
234 static void OnCertificateConfirm(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
236 gCertificateConfirmCallbackCalled++;
237 gCertificateConfirmInstance = std::move(certificate);
240 static void OnSslCertificateChanged(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
242 gSslCertificateChangedCallbackCalled++;
243 gSslCertificateInstance = std::move(certificate);
246 static void OnHttpAuthHandler( WebView view, std::shared_ptr<Dali::WebEngineHttpAuthHandler> hander )
248 gHttpAuthHandlerCallbackCalled++;
249 gHttpAuthInstance = std::move(hander);
252 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
254 gSecurityOriginsAcquiredCallbackCalled++;
255 gSecurityOriginList.clear();
256 gSecurityOriginList.swap(origins);
259 static void OnStorageUsageAcquired(uint64_t usage)
261 gStorageUsageAcquiredCallbackCalled++;
264 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
266 gFormPasswordsAcquiredCallbackCalled++;
267 gPasswordDataList.clear();
268 gPasswordDataList.swap(passwords);
271 static void OnDownloadStarted(const std::string& url)
273 gDownloadStartedCallbackCalled++;
276 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
278 gMimeOverriddenCallbackCalled++;
282 static void OnContextMenuCustomized(WebView view, std::shared_ptr<Dali::WebEngineContextMenu> menu)
284 gContextMenuCustomizedCallbackCalled++;
285 gContextMenuInstance = std::move(menu);
288 static void OnContextMenuItemSelected(WebView view, std::shared_ptr<Dali::WebEngineContextMenuItem> item)
290 gContextMenuItemSelectedCallbackCalled++;
291 gContextMenuItemInstance = std::move(item);
296 void web_view_startup(void)
298 test_return_value = TET_UNDEF;
301 void web_view_cleanup(void)
303 test_return_value = TET_PASS;
306 int UtcDaliWebViewBasics(void)
308 ToolkitTestApplication application;
310 // Copy and Assignment Test
311 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
312 WebView view = WebView::New();
313 DALI_TEST_CHECK( view );
315 WebView copy( view );
316 DALI_TEST_CHECK( view == copy );
319 DALI_TEST_CHECK( !assign );
322 DALI_TEST_CHECK( assign == view );
325 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
326 BaseHandle handle(view);
328 WebView view2 = WebView::DownCast( handle );
329 DALI_TEST_CHECK( view );
330 DALI_TEST_CHECK( view2 );
331 DALI_TEST_CHECK( view == view2 );
334 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
335 TypeRegistry typeRegistry = TypeRegistry::Get();
336 DALI_TEST_CHECK( typeRegistry );
338 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
339 DALI_TEST_CHECK( typeInfo );
341 BaseHandle handle2 = typeInfo.CreateInstance();
342 DALI_TEST_CHECK( handle2 );
344 WebView view3 = WebView::DownCast( handle2 );
345 DALI_TEST_CHECK( view3 );
350 int UtcDaliWebViewPageNavigation(void)
352 ToolkitTestApplication application;
354 WebView view = WebView::New();
355 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
356 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
357 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
358 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
359 application.GetScene().Add( view );
360 application.SendNotification();
361 application.Render();
362 DALI_TEST_CHECK( view );
364 ConnectionTracker* testTracker = new ConnectionTracker();
365 view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
366 view.PageLoadInProgressSignal().Connect( &OnPageLoadInProgress );
367 view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
368 view.UrlChangedSignal().Connect( &OnUrlChanged );
369 bool signal1 = false;
370 bool signal2 = false;
371 bool signal3 = false;
372 bool signal4 = false;
373 bool signal5 = false;
374 view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
375 view.ConnectSignal( testTracker, "pageLoadInProgress", CallbackFunctor(&signal2) );
376 view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal3) );
377 view.ConnectSignal( testTracker, "urlChanged", CallbackFunctor(&signal4) );
378 view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal5) );
379 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
380 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
381 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
382 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
384 view.LoadUrl( TEST_URL1 );
385 view.GetNaturalSize();
386 Test::EmitGlobalTimerSignal();
387 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
388 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
389 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
390 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
391 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
392 DALI_TEST_CHECK( signal1 & signal2 & signal3 & signal4 );
393 DALI_TEST_CHECK( !signal5 );
395 view.LoadUrl( TEST_URL2 );
397 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
398 application.SendNotification();
399 application.Render();
400 Test::EmitGlobalTimerSignal();
402 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
403 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
404 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
405 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
406 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
407 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
410 Test::EmitGlobalTimerSignal();
411 DALI_TEST_CHECK( !view.CanGoBack() );
412 DALI_TEST_CHECK( view.CanGoForward() );
415 Test::EmitGlobalTimerSignal();
416 DALI_TEST_CHECK( view.CanGoBack() );
417 DALI_TEST_CHECK( !view.CanGoForward() );
422 Test::EmitGlobalTimerSignal();
423 DALI_TEST_CHECK( !view.CanGoBack() );
424 DALI_TEST_CHECK( !view.CanGoForward() );
429 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
431 ToolkitTestApplication application;
433 WebView view = WebView::New();
434 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
435 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
436 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
437 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
438 application.GetScene().Add( view );
439 application.SendNotification();
440 application.Render();
441 DALI_TEST_CHECK( view );
443 ConnectionTracker* testTracker = new ConnectionTracker();
444 view.PageLoadErrorSignal().Connect( &OnPageLoadError );
445 view.ConsoleMessageSignal().Connect( &OnConsoleMessage );
446 bool signal1 = false;
447 bool signal2 = false;
448 view.ConnectSignal( testTracker, "pageLoadError", CallbackFunctor(&signal1) );
449 view.ConnectSignal( testTracker, "consoleMessage", CallbackFunctor(&signal2) );
450 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
451 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
453 view.LoadUrl( TEST_URL1 );
454 Test::EmitGlobalTimerSignal();
455 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
456 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
457 DALI_TEST_CHECK( signal1 & signal2);
460 DALI_TEST_CHECK(gPageLoadErrorInstance);
461 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
462 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
463 std::string testErrorDescription("This is an error.");
464 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
465 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
468 DALI_TEST_CHECK(gConsoleMessageInstance);
469 std::string testConsoleSource("source");
470 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
471 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
472 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
473 std::string testConsoleText("This is a text.");
474 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
477 gPageLoadErrorInstance = nullptr;
478 gConsoleMessageInstance = nullptr;
483 int UtcDaliWebViewTouchAndKeys(void)
485 ToolkitTestApplication application;
487 WebView view = WebView::New();
488 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
489 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
490 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
491 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
493 application.GetScene().Add( view );
494 application.SendNotification();
495 application.Render();
497 view.GetNaturalSize();
498 view.TouchedSignal().Connect( &OnTouched );
501 Dali::Integration::TouchEvent event;
502 Dali::Integration::Point pointDown, pointUp;
504 event = Dali::Integration::TouchEvent();
505 pointDown.SetState( PointState::DOWN );
506 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
507 event.AddPoint( pointDown );
508 application.ProcessEvent( event );
510 event = Dali::Integration::TouchEvent();
511 pointUp.SetState( PointState::UP );
512 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
513 event.AddPoint( pointUp );
514 application.ProcessEvent( event );
517 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
518 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
519 application.SendNotification();
521 DALI_TEST_CHECK( gTouched );
522 DALI_TEST_CHECK( view );
527 int UtcDaliWebViewFocusGainedAndLost(void)
529 ToolkitTestApplication application;
531 WebView view = WebView::New();
532 DALI_TEST_CHECK( view );
534 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
535 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
536 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
537 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
539 application.GetScene().Add( view );
540 application.SendNotification();
541 application.Render();
543 view.SetKeyInputFocus();
544 DALI_TEST_CHECK( view.HasKeyInputFocus() );
547 view.ClearKeyInputFocus();
548 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
553 int UtcDaliWebViewPropertyPageZoomFactor(void)
555 ToolkitTestApplication application;
557 WebView view = WebView::New();
558 DALI_TEST_CHECK( view );
560 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
561 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
562 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
563 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
565 application.GetScene().Add( view );
566 application.SendNotification();
567 application.Render();
569 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
570 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
571 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
573 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
574 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
575 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
580 int UtcDaliWebViewPropertyTextZoomFactor(void)
582 ToolkitTestApplication application;
584 WebView view = WebView::New();
585 DALI_TEST_CHECK( view );
587 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
588 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
589 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
590 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
592 application.GetScene().Add( view );
593 application.SendNotification();
594 application.Render();
596 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
597 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
598 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
600 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
601 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
602 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
607 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
609 ToolkitTestApplication application;
611 WebView view = WebView::New();
612 DALI_TEST_CHECK( view );
614 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
615 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
616 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
617 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
619 application.GetScene().Add( view );
620 application.SendNotification();
621 application.Render();
623 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
624 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
629 int UtcDaliWebViewMove(void)
631 ToolkitTestApplication application;
633 WebView view = WebView::New();
634 DALI_TEST_CHECK( view );
636 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
637 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
638 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
639 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
641 application.GetScene().Add( view );
642 application.SendNotification();
643 application.Render();
645 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
646 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
647 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
652 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
654 ToolkitTestApplication application;
656 WebView view = WebView::New();
657 DALI_TEST_CHECK( view );
659 const bool kDefaultValue = true;
660 const bool kTestValue = false;
662 // Check default value
664 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
665 DALI_TEST_CHECK( value.Get( output ) );
666 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
668 // Check Set/GetProperty
669 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
670 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
671 DALI_TEST_CHECK( value.Get( output ) );
672 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
677 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
679 ToolkitTestApplication application;
681 WebView view = WebView::New();
682 DALI_TEST_CHECK( view );
684 const bool kDefaultValue = true;
685 const bool kTestValue = false;
687 // Check default value
689 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
690 DALI_TEST_CHECK( value.Get( output ) );
691 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
693 // Check Set/GetProperty
694 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
695 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
696 DALI_TEST_CHECK( value.Get( output ) );
697 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
702 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
704 ToolkitTestApplication application;
706 WebView view = WebView::New();
707 DALI_TEST_CHECK( view );
709 const bool kDefaultValue = true;
710 const bool kTestValue = false;
712 // Check default value
714 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
715 DALI_TEST_CHECK( value.Get( output ) );
716 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
718 // Check Set/GetProperty
719 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
720 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
721 DALI_TEST_CHECK( value.Get( output ) );
722 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
727 int UtcDaliWebViewHoverAndWheel(void)
729 ToolkitTestApplication application;
731 WebView view = WebView::New();
732 DALI_TEST_CHECK( view );
733 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
734 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
735 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
736 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
738 application.GetScene().Add( view );
739 application.SendNotification();
740 application.Render();
742 view.GetNaturalSize();
743 view.HoveredSignal().Connect( &OnHovered );
744 view.WheelEventSignal().Connect( &OnWheelEvent );
747 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
748 Dali::Integration::Point pointDown;
749 pointDown.SetState( PointState::DOWN );
750 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
751 event.AddPoint( pointDown );
752 application.ProcessEvent( event );
754 event = Dali::Integration::HoverEvent();
755 Dali::Integration::Point pointUp;
756 pointUp.SetState( PointState::UP );
757 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
758 event.AddPoint( pointUp );
759 application.ProcessEvent( event );
761 event = Dali::Integration::HoverEvent();
762 Dali::Integration::Point pointMotion;
763 pointUp.SetState( PointState::MOTION );
764 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
765 event.AddPoint( pointMotion );
766 application.ProcessEvent( event );
769 Dali::Integration::WheelEvent wheelEvent;
770 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
771 wheelEvent.direction = 0;
772 wheelEvent.point = Vector2( 20, 20 );
773 wheelEvent.delta = 10;
774 application.ProcessEvent( wheelEvent );
775 application.SendNotification();
777 DALI_TEST_CHECK( gHovered );
778 DALI_TEST_CHECK( gWheelEventHandled );
783 int UtcDaliWebViewFormRepostDecisionFrameRendering(void)
785 ToolkitTestApplication application;
787 WebView view = WebView::New();
788 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
789 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
790 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
791 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
792 application.GetScene().Add( view );
793 application.SendNotification();
794 application.Render();
795 DALI_TEST_CHECK( view );
797 ConnectionTracker* testTracker = new ConnectionTracker();
798 view.FormRepostDecisionSignal().Connect(&OnFormRepostDecision);
799 view.FrameRenderedSignal().Connect(&OnFrameRendered);
800 bool signal1 = false;
801 bool signal2 = false;
802 view.ConnectSignal( testTracker, "formRepostDecision", CallbackFunctor(&signal1) );
803 view.ConnectSignal( testTracker, "frameRendered", CallbackFunctor(&signal2) );
804 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 0, TEST_LOCATION );
805 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
807 view.LoadUrl( TEST_URL1 );
808 Test::EmitGlobalTimerSignal();
809 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 1, TEST_LOCATION );
810 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
811 DALI_TEST_CHECK( signal1 & signal2);
813 // form repost decision.
814 DALI_TEST_CHECK(gFormRepostDecisionInstance);
815 gFormRepostDecisionInstance->Reply(true);
818 gFormRepostDecisionInstance = nullptr;
823 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
825 ToolkitTestApplication application;
827 WebView view = WebView::New();
828 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
829 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
830 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
831 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
832 application.GetScene().Add( view );
833 application.SendNotification();
834 application.Render();
835 DALI_TEST_CHECK( view );
837 ConnectionTracker* testTracker = new ConnectionTracker();
838 view.CertificateConfirmSignal().Connect(&OnCertificateConfirm);
839 view.SslCertificateChangedSignal().Connect(&OnSslCertificateChanged);
840 view.HttpAuthHandlerSignal().Connect(&OnHttpAuthHandler);
841 bool signal1 = false;
842 bool signal2 = false;
843 bool signal3 = false;
844 view.ConnectSignal( testTracker, "certificateConfirm", CallbackFunctor(&signal1) );
845 view.ConnectSignal( testTracker, "sslCertificateChanged", CallbackFunctor(&signal2) );
846 view.ConnectSignal( testTracker, "httpAuthRequest", CallbackFunctor(&signal3) );
847 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
848 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
849 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
851 view.LoadUrl( TEST_URL1 );
852 Test::EmitGlobalTimerSignal();
853 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
854 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
855 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
856 DALI_TEST_CHECK( signal1 & signal2 & signal3);
859 DALI_TEST_CHECK(gCertificateConfirmInstance);
860 gCertificateConfirmInstance->Allow(true);
861 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
863 DALI_TEST_CHECK(gSslCertificateInstance);
864 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
865 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
867 // http authentication.
868 DALI_TEST_CHECK(gHttpAuthInstance);
869 gHttpAuthInstance->Suspend();
870 gHttpAuthInstance->UseCredential("", "");
871 gHttpAuthInstance->CancelCredential();
872 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
875 gCertificateConfirmInstance = nullptr;
876 gSslCertificateInstance = nullptr;
877 gHttpAuthInstance = nullptr;
882 int UtcDaliWebViewGetWebBackForwardList(void)
884 ToolkitTestApplication application;
886 WebView view = WebView::New();
887 DALI_TEST_CHECK( view );
889 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
890 DALI_TEST_CHECK( bfList != 0 );
895 int UtcDaliWebViewGetWebContext(void)
897 ToolkitTestApplication application;
899 WebView view = WebView::New();
900 DALI_TEST_CHECK( view );
902 Dali::Toolkit::WebContext* context = view.GetContext();
903 DALI_TEST_CHECK( context != 0 );
908 int UtcDaliWebViewGetWebCookieManager(void)
910 ToolkitTestApplication application;
912 WebView view = WebView::New();
913 DALI_TEST_CHECK( view );
915 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
916 DALI_TEST_CHECK( cookieManager != 0 );
921 int UtcDaliWebViewGetWebSettings(void)
923 ToolkitTestApplication application;
925 WebView view = WebView::New();
926 DALI_TEST_CHECK( view );
928 Dali::Toolkit::WebSettings* settings = view.GetSettings();
929 DALI_TEST_CHECK( settings != 0 );
934 int UtcDaliWebViewProperty1(void)
937 ToolkitTestApplication application;
939 WebView view = WebView::New();
940 DALI_TEST_CHECK( view );
943 view.SetProperty( WebView::Property::URL, TEST_URL1 );
944 Property::Value val = view.GetProperty( WebView::Property::URL );
945 DALI_TEST_CHECK( val.Get( local ) );
946 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
951 int UtcDaliWebViewProperty4(void)
954 ToolkitTestApplication application;
956 WebView view = WebView::New();
957 DALI_TEST_CHECK( view );
959 const std::string kDefaultValue;
960 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";
962 // Check default value
964 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
965 DALI_TEST_CHECK( value.Get( output ) );
966 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
968 // Check Set/GetProperty
969 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
970 value = view.GetProperty( WebView::Property::USER_AGENT );
971 DALI_TEST_CHECK( value.Get( output ) );
972 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
977 int UtcDaliWebViewProperty9(void)
980 ToolkitTestApplication application;
982 WebView view = WebView::New();
983 DALI_TEST_CHECK( view );
985 // Check default value
986 Dali::Vector2 output = Dali::Vector2::ONE;
987 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
988 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
990 // Check Set/GetProperty
991 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
992 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
993 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
994 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
996 // Check default value of scroll size
997 output = Dali::Vector2::ONE;
998 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
999 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1001 // Check default value of content size
1002 output = Dali::Vector2::ONE;
1003 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
1004 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1009 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1011 ToolkitTestApplication application;
1013 WebView view = WebView::New();
1014 DALI_TEST_CHECK( view );
1016 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1017 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1018 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1019 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1020 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1022 // Check default value
1023 std::string testText("test");
1025 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1026 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1031 int UtcDaliWebViewPropertyTitleFavicon(void)
1033 ToolkitTestApplication application;
1035 char argv[] = "--test";
1036 WebView view = WebView::New( 1, (char**)&argv );
1037 DALI_TEST_CHECK( view );
1040 view.ClearAllTilesResources();
1042 // Check default value of title
1043 std::string testValue("title");
1045 view.GetProperty( WebView::Property::TITLE ).Get( output );
1046 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1048 // Check default value of favicon
1049 Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
1050 DALI_TEST_CHECK( favicon );
1051 Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1052 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1057 int UtcDaliWebViewContextMenuCustomizedAndItemSelected(void)
1059 ToolkitTestApplication application;
1061 WebView view = WebView::New();
1062 DALI_TEST_CHECK( view );
1065 ConnectionTracker* testTracker = new ConnectionTracker();
1066 view.ContextMenuCustomizedSignal().Connect( &OnContextMenuCustomized );
1067 view.ContextMenuItemSelectedSignal().Connect( &OnContextMenuItemSelected );
1068 bool signal1 = false;
1069 bool signal2 = false;
1070 view.ConnectSignal( testTracker, "contextMenuCustomized", CallbackFunctor(&signal1) );
1071 view.ConnectSignal( testTracker, "contextMenuItemSelected", CallbackFunctor(&signal2) );
1072 DALI_TEST_EQUALS( gContextMenuCustomizedCallbackCalled, 0, TEST_LOCATION );
1073 DALI_TEST_EQUALS( gContextMenuItemSelectedCallbackCalled, 0, TEST_LOCATION );
1074 DALI_TEST_CHECK(gContextMenuInstance == 0);
1075 DALI_TEST_CHECK(gContextMenuItemInstance == 0);
1077 view.LoadUrl( TEST_URL1 );
1078 Test::EmitGlobalTimerSignal();
1079 DALI_TEST_EQUALS( gContextMenuCustomizedCallbackCalled, 1, TEST_LOCATION );
1080 DALI_TEST_EQUALS( gContextMenuItemSelectedCallbackCalled, 1, TEST_LOCATION );
1081 DALI_TEST_CHECK( signal1 );
1082 DALI_TEST_CHECK( signal2 );
1084 // check context meun & its items.
1085 DALI_TEST_CHECK(gContextMenuInstance != 0);
1086 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuInstance->GetItemAt(0);
1087 DALI_TEST_CHECK(item.get() != 0);
1088 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuInstance->GetItemList();
1089 DALI_TEST_CHECK(itemList.size() == 1);
1090 Dali::Vector2 testPosition = Dali::Vector2(100, 100);
1091 DALI_TEST_EQUALS(gContextMenuInstance->GetPosition(), testPosition, TEST_LOCATION);
1092 DALI_TEST_CHECK(gContextMenuInstance->RemoveItem(*(item.get())));
1093 DALI_TEST_CHECK(gContextMenuInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1094 DALI_TEST_CHECK(gContextMenuInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1095 DALI_TEST_CHECK(gContextMenuInstance->SelectItem(*(item.get())));
1096 DALI_TEST_CHECK(gContextMenuInstance->Hide());
1098 DALI_TEST_CHECK(gContextMenuItemInstance != 0);
1099 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1100 DALI_TEST_EQUALS(gContextMenuItemInstance->GetTag(), testItemTag, TEST_LOCATION);
1101 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1102 DALI_TEST_EQUALS(gContextMenuItemInstance->GetType(), testItemType, TEST_LOCATION);
1103 DALI_TEST_CHECK(gContextMenuItemInstance->IsEnabled());
1104 std::string testLinkUrl("http://test.html");
1105 DALI_TEST_EQUALS(gContextMenuItemInstance->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1106 std::string testImageUrl("http://test.jpg");
1107 DALI_TEST_EQUALS(gContextMenuItemInstance->GetImageUrl(), testImageUrl, TEST_LOCATION);
1108 std::string testTitle("title");
1109 DALI_TEST_EQUALS(gContextMenuItemInstance->GetTitle(), testTitle, TEST_LOCATION);
1110 DALI_TEST_CHECK(gContextMenuItemInstance->GetParentMenu().get() == 0);
1112 gContextMenuInstance = nullptr;
1113 gContextMenuItemInstance = nullptr;
1118 int UtcDaliWebViewScrollBy(void)
1120 ToolkitTestApplication application;
1122 WebView view = WebView::New();
1123 DALI_TEST_CHECK( view );
1126 ConnectionTracker* testTracker = new ConnectionTracker();
1127 view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
1128 bool signal1 = false;
1129 view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
1130 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1132 view.LoadUrl( TEST_URL1 );
1133 Test::EmitGlobalTimerSignal();
1135 // set scroll position.
1136 Dali::Vector2 output = Dali::Vector2::ONE;
1137 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1138 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1139 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1140 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1142 // scroll by and trigger scrollEdgeReached event.
1143 view.ScrollBy( 50, 50 );
1144 Test::EmitGlobalTimerSignal();
1146 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1147 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1148 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1149 DALI_TEST_CHECK( signal1 );
1151 // scroll by and trigger scrollEdgeReached event.
1152 bool result = view.ScrollEdgeBy( 50, 50 );
1153 DALI_TEST_CHECK( result );
1154 Test::EmitGlobalTimerSignal();
1156 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1157 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1158 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1159 DALI_TEST_CHECK( signal1 );
1164 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1166 ToolkitTestApplication application;
1168 WebView view = WebView::New();
1169 DALI_TEST_CHECK( view );
1171 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1172 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1173 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1174 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1176 application.GetScene().Add( view );
1177 application.SendNotification();
1178 application.Render();
1180 view.ActivateAccessibility(true);
1181 view.AddDynamicCertificatePath("host", "test/to/path");
1182 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1183 DALI_TEST_CHECK( found );
1185 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1186 float result = view.GetScaleFactor();
1187 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1189 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1190 result = view.GetScaleFactor();
1191 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1196 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1199 ToolkitTestApplication application;
1201 char argv[] = "--test";
1202 WebView view = WebView::New( 1, (char**)&argv );
1203 DALI_TEST_CHECK( view );
1205 // Check GetScreenshot
1206 Dali::Rect<int> viewArea;
1209 viewArea.width = 10;
1210 viewArea.height = 10;
1211 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1212 DALI_TEST_CHECK( screenshot );
1213 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1214 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1216 // Check GetScreenshotAsynchronously
1219 viewArea.width = 100;
1220 viewArea.height = 100;
1221 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1222 DALI_TEST_CHECK( result );
1224 Test::EmitGlobalTimerSignal();
1226 Test::EmitGlobalTimerSignal();
1227 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1232 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1235 ToolkitTestApplication application;
1237 char argv[] = "--test";
1238 WebView view = WebView::New( 1, (char**)&argv );
1239 DALI_TEST_CHECK( view );
1241 // Check CheckVideoPlayingAsynchronously
1242 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1243 DALI_TEST_CHECK( result );
1244 Test::EmitGlobalTimerSignal();
1245 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1247 // Check RegisterGeolocationPermissionCallback
1248 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1249 Test::EmitGlobalTimerSignal();
1250 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1255 int UtcDaliWebViewHttpRequestInterceptor(void)
1257 ToolkitTestApplication application;
1259 WebView view = WebView::New();
1260 DALI_TEST_CHECK( view );
1263 ConnectionTracker* testTracker = new ConnectionTracker();
1264 view.RequestInterceptorSignal().Connect( &OnRequestInterceptor );
1265 bool signal1 = false;
1266 view.ConnectSignal( testTracker, "requestInterceptor", CallbackFunctor(&signal1) );
1267 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1268 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1270 view.LoadUrl( TEST_URL1 );
1271 Test::EmitGlobalTimerSignal();
1272 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1273 DALI_TEST_CHECK( signal1 );
1275 // check request interceptor.
1276 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1277 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1278 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1279 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1280 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1281 std::string testUrl("http://test.html");
1282 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1284 gRequestInterceptorInstance = nullptr;
1289 int UtcDaliWebViewPolicyDecisionRequest(void)
1291 ToolkitTestApplication application;
1293 WebView view = WebView::New();
1294 DALI_TEST_CHECK( view );
1297 ConnectionTracker* testTracker = new ConnectionTracker();
1298 view.PolicyDecisionSignal().Connect( &OnPolicyDecisionRequest );
1299 bool signal1 = false;
1300 view.ConnectSignal( testTracker, "policyDecision", CallbackFunctor(&signal1) );
1301 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 0, TEST_LOCATION );
1302 DALI_TEST_CHECK(gPolicyDecisionInstance == 0);
1304 view.LoadUrl( TEST_URL1 );
1305 Test::EmitGlobalTimerSignal();
1306 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 1, TEST_LOCATION );
1307 DALI_TEST_CHECK( signal1 );
1309 // check policy decision & its frame.
1310 DALI_TEST_CHECK(gPolicyDecisionInstance != 0);
1311 std::string testUrl("http://test.html");
1312 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1313 std::string testCookie("test:abc");
1314 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1315 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1316 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1317 std::string testResponseMime("txt/xml");
1318 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1319 int32_t ResponseStatusCode = 500;
1320 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1321 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1322 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1323 std::string testScheme("test");
1324 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1325 DALI_TEST_CHECK(gPolicyDecisionInstance->Use());
1326 DALI_TEST_CHECK(gPolicyDecisionInstance->Ignore());
1327 DALI_TEST_CHECK(gPolicyDecisionInstance->Suspend());
1329 Dali::WebEngineFrame* webFrame = &(gPolicyDecisionInstance->GetFrame());
1330 DALI_TEST_CHECK(webFrame);
1331 DALI_TEST_CHECK(webFrame->IsMainFrame());
1333 gPolicyDecisionInstance = nullptr;
1338 int UtcDaliWebViewEvaluteJavaScript(void)
1340 ToolkitTestApplication application;
1342 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1344 view.LoadHtmlString( "<body>Hello World!</body>" );
1345 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1346 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1347 Test::EmitGlobalTimerSignal();
1349 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1354 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1356 ToolkitTestApplication application;
1358 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1360 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1361 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1362 view.JavaScriptAlertReply();
1363 Test::EmitGlobalTimerSignal();
1364 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1366 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1367 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1368 view.JavaScriptConfirmReply( true );
1369 Test::EmitGlobalTimerSignal();
1370 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1372 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1373 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1374 view.JavaScriptPromptReply( "it is a prompt." );
1375 Test::EmitGlobalTimerSignal();
1376 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1381 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1383 ToolkitTestApplication application;
1385 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1386 DALI_TEST_CHECK( view );
1388 std::string html("<body>Hello World!</body>");
1389 std::string basicUri("http://basicurl");
1390 std::string unreachableUrl("http://unreachableurl");
1391 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1392 DALI_TEST_CHECK( result );
1394 application.SendNotification();
1395 application.Render();
1396 Test::EmitGlobalTimerSignal();
1398 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1399 DALI_TEST_CHECK( result );
1404 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1406 ToolkitTestApplication application;
1408 WebView view = WebView::New();
1409 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1410 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1411 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1412 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1414 application.GetScene().Add( view );
1415 application.SendNotification();
1416 application.Render();
1417 DALI_TEST_CHECK( view );
1419 view.LoadUrl( "http://test.html" );
1420 bool result = view.AddCustomHeader("key", "value");
1421 DALI_TEST_CHECK( result );
1423 result = view.ReloadWithoutCache();
1424 DALI_TEST_CHECK( result );
1426 uint32_t portNumber = view.StartInspectorServer(5000);
1427 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1429 application.SendNotification();
1430 application.Render();
1431 Test::EmitGlobalTimerSignal();
1433 result = view.StopInspectorServer();
1434 DALI_TEST_CHECK( result );
1436 view.SuspendNetworkLoading();
1438 result = view.RemoveCustomHeader("key");
1439 DALI_TEST_CHECK( result );
1441 view.ResumeNetworkLoading();
1446 int UtcDaliWebViewMethodsForCoverage(void)
1448 ToolkitTestApplication application;
1450 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1452 view.LoadHtmlString( "<body>Hello World!</body>" );
1453 view.AddJavaScriptMessageHandler( "jsObject",
1454 []( const std::string& arg ) {
1458 DALI_TEST_CHECK( view );
1463 // test cases for web backforward list.
1465 int UtcDaliWebBackForwardListCheckItem(void)
1467 ToolkitTestApplication application;
1469 WebView view = WebView::New();
1470 DALI_TEST_CHECK( view );
1472 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1473 DALI_TEST_CHECK( bfList != 0 )
1475 unsigned int itemCount = bfList->GetItemCount();
1476 DALI_TEST_CHECK( itemCount == 1 )
1478 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1479 DALI_TEST_CHECK( citem != 0 );
1481 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1482 DALI_TEST_CHECK( citemP != 0 );
1484 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1485 DALI_TEST_CHECK( citemN != 0 );
1487 const std::string kDefaultUrl( "http://url" );
1488 std::string testValue = citem->GetUrl();
1489 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1491 const std::string kDefaultTitle( "title" );
1492 testValue = citem->GetTitle();
1493 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1495 const std::string kDefaultOriginalUrl( "http://originalurl" );
1496 testValue = citem->GetOriginalUrl();
1497 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1499 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1500 DALI_TEST_CHECK( item != 0 );
1502 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1503 DALI_TEST_CHECK( vecBack.size() == 1 );
1505 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1506 DALI_TEST_CHECK( vecForward.size() == 1 );
1511 // test cases for web context.
1513 int UtcDaliWebContextGetSetCacheModel(void)
1515 ToolkitTestApplication application;
1517 WebView view = WebView::New();
1518 DALI_TEST_CHECK( view );
1520 Dali::Toolkit::WebContext* context = view.GetContext();
1521 DALI_TEST_CHECK( context != 0 )
1523 std::string kDefaultValue;
1526 context->SetProxyUri( kDefaultValue );
1527 context->SetCertificateFilePath( kDefaultValue );
1528 context->DisableCache( false );
1529 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1530 context->DeleteAllWebDatabase();
1531 context->DeleteAllWebStorage();
1532 context->DeleteLocalFileSystem();
1533 context->ClearCache();
1535 // Check default value
1536 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1537 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1539 // Check Set/GetProperty
1540 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1541 value = context->GetCacheModel();
1542 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1547 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1549 ToolkitTestApplication application;
1551 WebView view = WebView::New();
1552 DALI_TEST_CHECK( view );
1554 Dali::Toolkit::WebContext* context = view.GetContext();
1555 DALI_TEST_CHECK( context != 0 )
1557 std::string kDefaultValue;
1559 // get origins of web database
1560 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1561 DALI_TEST_CHECK( result );
1563 Test::EmitGlobalTimerSignal();
1564 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1565 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1567 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1568 DALI_TEST_CHECK( origin );
1570 result = context->DeleteWebDatabase(*origin);
1571 DALI_TEST_CHECK( result );
1573 // get origins of web storage
1574 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1575 DALI_TEST_CHECK( result );
1577 Test::EmitGlobalTimerSignal();
1578 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1579 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1581 origin = gSecurityOriginList[0].get();
1582 DALI_TEST_CHECK( origin );
1584 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1585 DALI_TEST_CHECK( result );
1586 Test::EmitGlobalTimerSignal();
1587 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1589 result = context->DeleteWebStorageOrigin(*origin);
1590 DALI_TEST_CHECK( result );
1592 result = context->DeleteApplicationCache(*origin);
1593 DALI_TEST_CHECK( result );
1595 // form passwords, download state, mime type.
1596 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1597 Test::EmitGlobalTimerSignal();
1598 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1599 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1600 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1601 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1603 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1604 Test::EmitGlobalTimerSignal();
1605 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1607 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1608 Test::EmitGlobalTimerSignal();
1609 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1611 gSecurityOriginList.clear();
1612 gPasswordDataList.clear();
1617 // test cases for web cookie manager.
1619 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1621 ToolkitTestApplication application;
1623 WebView view = WebView::New();
1624 DALI_TEST_CHECK( view );
1626 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1627 DALI_TEST_CHECK( cookieManager != 0 )
1629 const std::string kDefaultValue;
1632 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1633 cookieManager->ClearCookies();
1635 // Check default value
1636 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1637 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1639 // Check Set/GetProperty
1640 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1641 value = cookieManager->GetCookieAcceptPolicy();
1642 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1647 // test cases for web settings.
1649 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1651 ToolkitTestApplication application;
1653 WebView view = WebView::New();
1654 DALI_TEST_CHECK( view );
1656 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1657 DALI_TEST_CHECK( settings != 0 )
1660 settings->AllowMixedContents( false );
1661 settings->EnableSpatialNavigation( false );
1662 settings->EnableWebSecurity( false );
1663 settings->EnableCacheBuilder( false );
1664 settings->EnableDoNotTrack( false );
1665 settings->UseScrollbarThumbFocusNotifications( false );
1666 settings->AllowFileAccessFromExternalUrl( false );
1667 settings->AllowScriptsOpenWindows( false );
1669 // Check default value
1670 int value = settings->GetDefaultFontSize();
1671 DALI_TEST_CHECK( value == 16 );
1673 // Check Set/GetProperty
1674 settings->SetDefaultFontSize( 20 );
1675 value = settings->GetDefaultFontSize();
1676 DALI_TEST_CHECK( value == 20 );
1681 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1683 ToolkitTestApplication application;
1685 WebView view = WebView::New();
1686 DALI_TEST_CHECK( view );
1688 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1689 DALI_TEST_CHECK( settings != 0 )
1692 settings->AllowMixedContents( false );
1693 settings->EnableSpatialNavigation( false );
1694 settings->EnableWebSecurity( false );
1695 settings->EnableCacheBuilder( false );
1696 settings->EnableDoNotTrack( false );
1697 settings->UseScrollbarThumbFocusNotifications( false );
1698 settings->AllowFileAccessFromExternalUrl( false );
1699 settings->AllowScriptsOpenWindows( false );
1701 // Check default value is true or not
1702 bool value = settings->IsJavaScriptEnabled();
1703 DALI_TEST_CHECK( value );
1705 // Check Set/GetProperty
1706 settings->EnableJavaScript( false );
1707 value = settings->IsJavaScriptEnabled();
1708 DALI_TEST_CHECK( !value );
1713 int UtcDaliWebSettingsCheckEnableAutoFitting(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 is true or not
1734 bool value = settings->IsAutoFittingEnabled();
1735 DALI_TEST_CHECK( value );
1737 // Check Set/GetProperty
1738 settings->EnableAutoFitting( false );
1739 value = settings->IsAutoFittingEnabled();
1740 DALI_TEST_CHECK( !value );
1745 int UtcDaliWebSettingsCheckEnablePlugins(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->ArePluginsEnabled();
1767 DALI_TEST_CHECK( value );
1769 // Check Set/GetProperty
1770 settings->EnablePlugins( false );
1771 value = settings->ArePluginsEnabled();
1772 DALI_TEST_CHECK( !value );
1777 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(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->IsPrivateBrowsingEnabled();
1799 DALI_TEST_CHECK( value );
1801 // Check Set/GetProperty
1802 settings->EnablePrivateBrowsing( false );
1803 value = settings->IsPrivateBrowsingEnabled();
1804 DALI_TEST_CHECK( !value );
1809 int UtcDaliWebSettingsCheckEnableLinkMagnifier(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->IsLinkMagnifierEnabled();
1831 DALI_TEST_CHECK( value );
1833 // Check Set/GetProperty
1834 settings->EnableLinkMagnifier( false );
1835 value = settings->IsLinkMagnifierEnabled();
1836 DALI_TEST_CHECK( !value );
1841 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(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->IsKeypadWithoutUserActionUsed();
1863 DALI_TEST_CHECK( value );
1865 // Check Set/GetProperty
1866 settings->UseKeypadWithoutUserAction( false );
1867 value = settings->IsKeypadWithoutUserActionUsed();
1868 DALI_TEST_CHECK( !value );
1873 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(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->IsAutofillPasswordFormEnabled();
1895 DALI_TEST_CHECK( value );
1896 settings->EnableAutofillPasswordForm( false );
1897 value = settings->IsAutofillPasswordFormEnabled();
1898 DALI_TEST_CHECK( !value );
1902 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1904 ToolkitTestApplication application;
1906 WebView view = WebView::New();
1907 DALI_TEST_CHECK( view );
1909 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1910 DALI_TEST_CHECK( settings != 0 );
1913 settings->AllowMixedContents( false );
1914 settings->EnableSpatialNavigation( false );
1915 settings->EnableWebSecurity( false );
1916 settings->EnableCacheBuilder( false );
1917 settings->EnableDoNotTrack( false );
1918 settings->UseScrollbarThumbFocusNotifications( false );
1919 settings->AllowFileAccessFromExternalUrl( false );
1920 settings->AllowScriptsOpenWindows( false );
1922 // Check default value is true or not
1923 bool value = settings->IsFormCandidateDataEnabled();
1924 DALI_TEST_CHECK( value );
1926 // Check Set/GetProperty
1927 settings->EnableFormCandidateData( false );
1928 value = settings->IsFormCandidateDataEnabled();
1929 DALI_TEST_CHECK( !value );
1934 int UtcDaliWebSettingsCheckEnableTextSelection(void)
1936 ToolkitTestApplication application;
1938 WebView view = WebView::New();
1939 DALI_TEST_CHECK( view );
1941 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1942 DALI_TEST_CHECK( settings != 0 );
1945 settings->AllowMixedContents( false );
1946 settings->EnableSpatialNavigation( false );
1947 settings->EnableWebSecurity( false );
1948 settings->EnableCacheBuilder( false );
1949 settings->EnableDoNotTrack( false );
1950 settings->UseScrollbarThumbFocusNotifications( false );
1951 settings->AllowFileAccessFromExternalUrl( false );
1952 settings->AllowScriptsOpenWindows( false );
1954 // Check default value is true or not
1955 bool value = settings->IsTextSelectionEnabled();
1956 DALI_TEST_CHECK( value );
1958 //Check Set/GetProperty
1959 settings->EnableTextSelection(false);
1960 value = settings->IsTextSelectionEnabled();
1961 DALI_TEST_CHECK( !value );
1966 int UtcDaliWebSettingsCheckEnableTextAutosizing(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->IsTextAutosizingEnabled();
1988 DALI_TEST_CHECK( value );
1990 // Check Set/GetProperty
1991 settings->EnableTextAutosizing(false);
1992 value = settings->IsTextAutosizingEnabled();
1993 DALI_TEST_CHECK( !value );
1998 int UtcDaliWebSettingsCheckEnableArrowScroll(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->IsArrowScrollEnabled();
2020 DALI_TEST_CHECK( value );
2022 // Check Set/GetProperty
2023 settings->EnableArrowScroll(false);
2024 value = settings->IsArrowScrollEnabled();
2025 DALI_TEST_CHECK( !value );
2030 int UtcDaliWebSettingsCheckEnableClipboard(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->IsClipboardEnabled();
2052 DALI_TEST_CHECK( value );
2053 settings->EnableClipboard(false);
2054 value = settings->IsClipboardEnabled();
2055 DALI_TEST_CHECK( !value );
2059 int UtcDaliWebSettingsCheckEnableImePanel(void)
2061 ToolkitTestApplication application;
2063 WebView view = WebView::New();
2064 DALI_TEST_CHECK( view );
2066 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2067 DALI_TEST_CHECK( settings != 0 );
2070 settings->AllowMixedContents( false );
2071 settings->EnableSpatialNavigation( false );
2072 settings->EnableWebSecurity( false );
2073 settings->EnableCacheBuilder( false );
2074 settings->EnableDoNotTrack( false );
2075 settings->UseScrollbarThumbFocusNotifications( false );
2076 settings->AllowFileAccessFromExternalUrl( false );
2077 settings->AllowScriptsOpenWindows( false );
2079 // Check default value is true or not
2080 bool value = settings->IsImePanelEnabled();
2081 DALI_TEST_CHECK( value );
2083 // Check Set/GetProperty
2084 settings->EnableImePanel(false);
2085 value = settings->IsImePanelEnabled();
2086 DALI_TEST_CHECK( !value );
2091 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2093 ToolkitTestApplication application;
2095 WebView view = WebView::New();
2096 DALI_TEST_CHECK( view );
2098 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2099 DALI_TEST_CHECK( settings != 0 )
2102 settings->AllowMixedContents( false );
2103 settings->EnableSpatialNavigation( false );
2104 settings->EnableWebSecurity( false );
2105 settings->EnableCacheBuilder( false );
2106 settings->EnableDoNotTrack( false );
2107 settings->UseScrollbarThumbFocusNotifications( false );
2108 settings->AllowFileAccessFromExternalUrl( false );
2109 settings->AllowScriptsOpenWindows( false );
2111 // Check default value is true or not
2112 bool value = settings->AreImagesLoadedAutomatically();
2113 DALI_TEST_CHECK( value );
2115 // Check Set/GetProperty
2116 settings->AllowImagesLoadAutomatically( false );
2117 value = settings->AreImagesLoadedAutomatically();
2118 DALI_TEST_CHECK( !value );
2123 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(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 )
2133 const std::string kDefaultValue;
2134 const std::string kTestValue = "UTF-8";
2137 settings->AllowMixedContents( false );
2138 settings->EnableSpatialNavigation( false );
2139 settings->EnableWebSecurity( false );
2140 settings->EnableCacheBuilder( false );
2141 settings->EnableDoNotTrack( false );
2142 settings->UseScrollbarThumbFocusNotifications( false );
2143 settings->AllowFileAccessFromExternalUrl( false );
2144 settings->AllowScriptsOpenWindows( false );
2146 // Check default value
2147 std::string value = settings->GetDefaultTextEncodingName();
2148 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2150 // Check Set/GetProperty
2151 settings->SetDefaultTextEncodingName( kTestValue );
2152 value = settings->GetDefaultTextEncodingName();
2153 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );