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-frame.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
34 #include <dali/integration-api/events/hover-event-integ.h>
35 #include <dali/integration-api/events/key-event-integ.h>
36 #include <dali/integration-api/events/touch-event-integ.h>
37 #include <dali/integration-api/events/wheel-event-integ.h>
38 #include <dali/public-api/images/pixel-data.h>
39 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
40 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
41 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
42 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
43 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
44 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
45 #include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
46 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
50 using namespace Toolkit;
55 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
56 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
58 static int gPageLoadStartedCallbackCalled = 0;
59 static int gPageLoadInProgressCallbackCalled = 0;
60 static int gPageLoadFinishedCallbackCalled = 0;
61 static int gPageLoadErrorCallbackCalled = 0;
62 static std::shared_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
63 static int gScrollEdgeReachedCallbackCalled = 0;
64 static int gUrlChangedCallbackCalled = 0;
65 static int gEvaluateJavaScriptCallbackCalled = 0;
66 static int gJavaScriptAlertCallbackCalled = 0;
67 static int gJavaScriptConfirmCallbackCalled = 0;
68 static int gJavaScriptPromptCallbackCalled = 0;
69 static int gScreenshotCapturedCallbackCalled = 0;
70 static int gVideoPlayingCallbackCalled = 0;
71 static int gGeolocationPermissionCallbackCalled = 0;
72 static bool gTouched = false;
73 static bool gHovered = false;
74 static bool gWheelEventHandled = false;
75 static int gFormRepostDecisionCallbackCalled = 0;
76 static std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> gFormRepostDecisionInstance = nullptr;
77 static int gFrameRenderedCallbackCalled = 0;
78 static int gRequestInterceptorCallbackCalled = 0;
79 static std::shared_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
80 static int gConsoleMessageCallbackCalled = 0;
81 static std::shared_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
82 static int gPolicyDecisionCallbackCalled = 0;
83 static std::shared_ptr<Dali::WebEnginePolicyDecision> gPolicyDecisionInstance = nullptr;
84 static int gCertificateConfirmCallbackCalled = 0;
85 static std::shared_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
86 static int gSslCertificateChangedCallbackCalled = 0;
87 static std::shared_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
88 static int gHttpAuthHandlerCallbackCalled = 0;
89 static std::shared_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
90 static int gSecurityOriginsAcquiredCallbackCalled = 0;
91 static int gStorageUsageAcquiredCallbackCalled = 0;
92 static int gFormPasswordsAcquiredCallbackCalled = 0;
93 static int gDownloadStartedCallbackCalled = 0;
94 static int gMimeOverriddenCallbackCalled = 0;
95 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
96 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
98 struct CallbackFunctor
100 CallbackFunctor(bool* callbackFlag)
101 : mCallbackFlag( callbackFlag )
107 *mCallbackFlag = true;
112 static void OnPageLoadStarted( WebView view, const std::string& url )
114 gPageLoadStartedCallbackCalled++;
117 static void OnPageLoadInProgress( WebView view, const std::string& url )
119 gPageLoadInProgressCallbackCalled++;
122 static void OnPageLoadFinished( WebView view, const std::string& url )
124 gPageLoadFinishedCallbackCalled++;
127 static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
129 gScrollEdgeReachedCallbackCalled++;
132 static void OnPolicyDecisionRequest(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
134 gPolicyDecisionCallbackCalled++;
135 gPolicyDecisionInstance = std::move(decision);
138 static void OnUrlChanged( WebView view, const std::string& url )
140 gUrlChangedCallbackCalled++;
143 static void OnPageLoadError(WebView view, std::shared_ptr<Dali::WebEngineLoadError> error)
145 gPageLoadErrorCallbackCalled++;
146 gPageLoadErrorInstance = std::move(error);
149 static void OnEvaluateJavaScript( const std::string& result )
151 gEvaluateJavaScriptCallbackCalled++;
154 static bool OnJavaScriptAlert( const std::string& result )
156 gJavaScriptAlertCallbackCalled++;
160 static bool OnJavaScriptConfirm( const std::string& result )
162 gJavaScriptConfirmCallbackCalled++;
166 static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string& message2 )
168 gJavaScriptPromptCallbackCalled++;
172 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
174 gScreenshotCapturedCallbackCalled++;
177 static void OnVideoPlaying(bool isPlaying)
179 gVideoPlayingCallbackCalled++;
182 static bool OnGeolocationPermission(const std::string&, const std::string&)
184 gGeolocationPermissionCallbackCalled++;
188 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
194 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
200 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheel )
202 gWheelEventHandled = true;
206 static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> decision)
208 gFormRepostDecisionCallbackCalled++;
209 gFormRepostDecisionInstance = std::move(decision);
212 static void OnFrameRendered(WebView)
214 gFrameRenderedCallbackCalled++;
217 static void OnRequestInterceptor(WebView view, std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
219 gRequestInterceptorCallbackCalled++;
220 gRequestInterceptorInstance = std::move(interceptor);
223 static void OnConsoleMessage(WebView view, std::shared_ptr<Dali::WebEngineConsoleMessage> message)
225 gConsoleMessageCallbackCalled++;
226 gConsoleMessageInstance = std::move(message);
229 static void OnCertificateConfirm(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
231 gCertificateConfirmCallbackCalled++;
232 gCertificateConfirmInstance = std::move(certificate);
235 static void OnSslCertificateChanged(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
237 gSslCertificateChangedCallbackCalled++;
238 gSslCertificateInstance = std::move(certificate);
241 static void OnHttpAuthHandler( WebView view, std::shared_ptr<Dali::WebEngineHttpAuthHandler> hander )
243 gHttpAuthHandlerCallbackCalled++;
244 gHttpAuthInstance = std::move(hander);
247 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
249 gSecurityOriginsAcquiredCallbackCalled++;
250 gSecurityOriginList.clear();
251 gSecurityOriginList.swap(origins);
254 static void OnStorageUsageAcquired(uint64_t usage)
256 gStorageUsageAcquiredCallbackCalled++;
259 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
261 gFormPasswordsAcquiredCallbackCalled++;
262 gPasswordDataList.clear();
263 gPasswordDataList.swap(passwords);
266 static void OnDownloadStarted(const std::string& url)
268 gDownloadStartedCallbackCalled++;
271 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
273 gMimeOverriddenCallbackCalled++;
279 void web_view_startup(void)
281 test_return_value = TET_UNDEF;
284 void web_view_cleanup(void)
286 test_return_value = TET_PASS;
289 int UtcDaliWebViewBasics(void)
291 ToolkitTestApplication application;
293 // Copy and Assignment Test
294 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
295 WebView view = WebView::New();
296 DALI_TEST_CHECK( view );
298 WebView copy( view );
299 DALI_TEST_CHECK( view == copy );
302 DALI_TEST_CHECK( !assign );
305 DALI_TEST_CHECK( assign == view );
308 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
309 BaseHandle handle(view);
311 WebView view2 = WebView::DownCast( handle );
312 DALI_TEST_CHECK( view );
313 DALI_TEST_CHECK( view2 );
314 DALI_TEST_CHECK( view == view2 );
317 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
318 TypeRegistry typeRegistry = TypeRegistry::Get();
319 DALI_TEST_CHECK( typeRegistry );
321 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
322 DALI_TEST_CHECK( typeInfo );
324 BaseHandle handle2 = typeInfo.CreateInstance();
325 DALI_TEST_CHECK( handle2 );
327 WebView view3 = WebView::DownCast( handle2 );
328 DALI_TEST_CHECK( view3 );
333 int UtcDaliWebViewPageNavigation(void)
335 ToolkitTestApplication application;
337 WebView view = WebView::New();
338 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
339 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
340 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
341 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
342 application.GetScene().Add( view );
343 application.SendNotification();
344 application.Render();
345 DALI_TEST_CHECK( view );
347 ConnectionTracker* testTracker = new ConnectionTracker();
348 view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
349 view.PageLoadInProgressSignal().Connect( &OnPageLoadInProgress );
350 view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
351 view.UrlChangedSignal().Connect( &OnUrlChanged );
352 bool signal1 = false;
353 bool signal2 = false;
354 bool signal3 = false;
355 bool signal4 = false;
356 bool signal5 = false;
357 view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
358 view.ConnectSignal( testTracker, "pageLoadInProgress", CallbackFunctor(&signal2) );
359 view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal3) );
360 view.ConnectSignal( testTracker, "urlChanged", CallbackFunctor(&signal4) );
361 view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal5) );
362 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
363 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
364 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
365 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
367 view.LoadUrl( TEST_URL1 );
368 view.GetNaturalSize();
369 Test::EmitGlobalTimerSignal();
370 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
371 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
372 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
373 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
374 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
375 DALI_TEST_CHECK( signal1 & signal2 & signal3 & signal4 );
376 DALI_TEST_CHECK( !signal5 );
378 view.LoadUrl( TEST_URL2 );
380 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
381 application.SendNotification();
382 application.Render();
383 Test::EmitGlobalTimerSignal();
385 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
386 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
387 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
388 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
389 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
390 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
393 Test::EmitGlobalTimerSignal();
394 DALI_TEST_CHECK( !view.CanGoBack() );
395 DALI_TEST_CHECK( view.CanGoForward() );
398 Test::EmitGlobalTimerSignal();
399 DALI_TEST_CHECK( view.CanGoBack() );
400 DALI_TEST_CHECK( !view.CanGoForward() );
405 Test::EmitGlobalTimerSignal();
406 DALI_TEST_CHECK( !view.CanGoBack() );
407 DALI_TEST_CHECK( !view.CanGoForward() );
412 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
414 ToolkitTestApplication application;
416 WebView view = WebView::New();
417 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
418 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
419 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
420 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
421 application.GetScene().Add( view );
422 application.SendNotification();
423 application.Render();
424 DALI_TEST_CHECK( view );
426 ConnectionTracker* testTracker = new ConnectionTracker();
427 view.PageLoadErrorSignal().Connect( &OnPageLoadError );
428 view.ConsoleMessageSignal().Connect( &OnConsoleMessage );
429 bool signal1 = false;
430 bool signal2 = false;
431 view.ConnectSignal( testTracker, "pageLoadError", CallbackFunctor(&signal1) );
432 view.ConnectSignal( testTracker, "consoleMessage", CallbackFunctor(&signal2) );
433 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
434 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
436 view.LoadUrl( TEST_URL1 );
437 Test::EmitGlobalTimerSignal();
438 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
439 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
440 DALI_TEST_CHECK( signal1 & signal2);
443 DALI_TEST_CHECK(gPageLoadErrorInstance);
444 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
445 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
446 std::string testErrorDescription("This is an error.");
447 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
448 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
451 DALI_TEST_CHECK(gConsoleMessageInstance);
452 std::string testConsoleSource("source");
453 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
454 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
455 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
456 std::string testConsoleText("This is a text.");
457 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
460 gPageLoadErrorInstance = nullptr;
461 gConsoleMessageInstance = nullptr;
466 int UtcDaliWebViewTouchAndKeys(void)
468 ToolkitTestApplication application;
470 WebView view = WebView::New();
471 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
472 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
473 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
474 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
476 application.GetScene().Add( view );
477 application.SendNotification();
478 application.Render();
480 view.GetNaturalSize();
481 view.TouchedSignal().Connect( &OnTouched );
484 Dali::Integration::TouchEvent event;
485 Dali::Integration::Point pointDown, pointUp;
487 event = Dali::Integration::TouchEvent();
488 pointDown.SetState( PointState::DOWN );
489 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
490 event.AddPoint( pointDown );
491 application.ProcessEvent( event );
493 event = Dali::Integration::TouchEvent();
494 pointUp.SetState( PointState::UP );
495 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
496 event.AddPoint( pointUp );
497 application.ProcessEvent( event );
500 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
501 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
502 application.SendNotification();
504 DALI_TEST_CHECK( gTouched );
505 DALI_TEST_CHECK( view );
510 int UtcDaliWebViewFocusGainedAndLost(void)
512 ToolkitTestApplication application;
514 WebView view = WebView::New();
515 DALI_TEST_CHECK( view );
517 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
518 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
519 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
520 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
522 application.GetScene().Add( view );
523 application.SendNotification();
524 application.Render();
526 view.SetKeyInputFocus();
527 DALI_TEST_CHECK( view.HasKeyInputFocus() );
530 view.ClearKeyInputFocus();
531 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
536 int UtcDaliWebViewPropertyPageZoomFactor(void)
538 ToolkitTestApplication application;
540 WebView view = WebView::New();
541 DALI_TEST_CHECK( view );
543 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
544 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
545 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
546 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
548 application.GetScene().Add( view );
549 application.SendNotification();
550 application.Render();
552 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
553 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
554 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
556 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
557 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
558 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
563 int UtcDaliWebViewPropertyTextZoomFactor(void)
565 ToolkitTestApplication application;
567 WebView view = WebView::New();
568 DALI_TEST_CHECK( view );
570 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
571 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
572 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
573 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
575 application.GetScene().Add( view );
576 application.SendNotification();
577 application.Render();
579 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
580 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
581 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
583 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
584 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
585 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
590 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
592 ToolkitTestApplication application;
594 WebView view = WebView::New();
595 DALI_TEST_CHECK( view );
597 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
598 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
599 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
600 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
602 application.GetScene().Add( view );
603 application.SendNotification();
604 application.Render();
606 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
607 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
612 int UtcDaliWebViewMove(void)
614 ToolkitTestApplication application;
616 WebView view = WebView::New();
617 DALI_TEST_CHECK( view );
619 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
620 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
621 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
622 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
624 application.GetScene().Add( view );
625 application.SendNotification();
626 application.Render();
628 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
629 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
630 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
635 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
637 ToolkitTestApplication application;
639 WebView view = WebView::New();
640 DALI_TEST_CHECK( view );
642 const bool kDefaultValue = true;
643 const bool kTestValue = false;
645 // Check default value
647 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
648 DALI_TEST_CHECK( value.Get( output ) );
649 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
651 // Check Set/GetProperty
652 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
653 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
654 DALI_TEST_CHECK( value.Get( output ) );
655 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
660 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
662 ToolkitTestApplication application;
664 WebView view = WebView::New();
665 DALI_TEST_CHECK( view );
667 const bool kDefaultValue = true;
668 const bool kTestValue = false;
670 // Check default value
672 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
673 DALI_TEST_CHECK( value.Get( output ) );
674 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
676 // Check Set/GetProperty
677 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
678 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
679 DALI_TEST_CHECK( value.Get( output ) );
680 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
685 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
687 ToolkitTestApplication application;
689 WebView view = WebView::New();
690 DALI_TEST_CHECK( view );
692 const bool kDefaultValue = true;
693 const bool kTestValue = false;
695 // Check default value
697 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
698 DALI_TEST_CHECK( value.Get( output ) );
699 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
701 // Check Set/GetProperty
702 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
703 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
704 DALI_TEST_CHECK( value.Get( output ) );
705 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
710 int UtcDaliWebViewHoverAndWheel(void)
712 ToolkitTestApplication application;
714 WebView view = WebView::New();
715 DALI_TEST_CHECK( view );
716 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
717 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
718 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
719 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
721 application.GetScene().Add( view );
722 application.SendNotification();
723 application.Render();
725 view.GetNaturalSize();
726 view.HoveredSignal().Connect( &OnHovered );
727 view.WheelEventSignal().Connect( &OnWheelEvent );
730 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
731 Dali::Integration::Point pointDown;
732 pointDown.SetState( PointState::DOWN );
733 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
734 event.AddPoint( pointDown );
735 application.ProcessEvent( event );
737 event = Dali::Integration::HoverEvent();
738 Dali::Integration::Point pointUp;
739 pointUp.SetState( PointState::UP );
740 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
741 event.AddPoint( pointUp );
742 application.ProcessEvent( event );
744 event = Dali::Integration::HoverEvent();
745 Dali::Integration::Point pointMotion;
746 pointUp.SetState( PointState::MOTION );
747 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
748 event.AddPoint( pointMotion );
749 application.ProcessEvent( event );
752 Dali::Integration::WheelEvent wheelEvent;
753 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
754 wheelEvent.direction = 0;
755 wheelEvent.point = Vector2( 20, 20 );
756 wheelEvent.delta = 10;
757 application.ProcessEvent( wheelEvent );
758 application.SendNotification();
760 DALI_TEST_CHECK( gHovered );
761 DALI_TEST_CHECK( gWheelEventHandled );
766 int UtcDaliWebViewFormRepostDecisionFrameRendering(void)
768 ToolkitTestApplication application;
770 WebView view = WebView::New();
771 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
772 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
773 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
774 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
775 application.GetScene().Add( view );
776 application.SendNotification();
777 application.Render();
778 DALI_TEST_CHECK( view );
780 ConnectionTracker* testTracker = new ConnectionTracker();
781 view.FormRepostDecisionSignal().Connect(&OnFormRepostDecision);
782 view.FrameRenderedSignal().Connect(&OnFrameRendered);
783 bool signal1 = false;
784 bool signal2 = false;
785 view.ConnectSignal( testTracker, "formRepostDecision", CallbackFunctor(&signal1) );
786 view.ConnectSignal( testTracker, "frameRendered", CallbackFunctor(&signal2) );
787 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 0, TEST_LOCATION );
788 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
790 view.LoadUrl( TEST_URL1 );
791 Test::EmitGlobalTimerSignal();
792 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 1, TEST_LOCATION );
793 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
794 DALI_TEST_CHECK( signal1 & signal2);
796 // form repost decision.
797 DALI_TEST_CHECK(gFormRepostDecisionInstance);
798 gFormRepostDecisionInstance->Reply(true);
801 gFormRepostDecisionInstance = nullptr;
806 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
808 ToolkitTestApplication application;
810 WebView view = WebView::New();
811 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
812 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
813 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
814 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
815 application.GetScene().Add( view );
816 application.SendNotification();
817 application.Render();
818 DALI_TEST_CHECK( view );
820 ConnectionTracker* testTracker = new ConnectionTracker();
821 view.CertificateConfirmSignal().Connect(&OnCertificateConfirm);
822 view.SslCertificateChangedSignal().Connect(&OnSslCertificateChanged);
823 view.HttpAuthHandlerSignal().Connect(&OnHttpAuthHandler);
824 bool signal1 = false;
825 bool signal2 = false;
826 bool signal3 = false;
827 view.ConnectSignal( testTracker, "certificateConfirm", CallbackFunctor(&signal1) );
828 view.ConnectSignal( testTracker, "sslCertificateChanged", CallbackFunctor(&signal2) );
829 view.ConnectSignal( testTracker, "httpAuthRequest", CallbackFunctor(&signal3) );
830 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
831 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
832 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
834 view.LoadUrl( TEST_URL1 );
835 Test::EmitGlobalTimerSignal();
836 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
837 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
838 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
839 DALI_TEST_CHECK( signal1 & signal2 & signal3);
842 DALI_TEST_CHECK(gCertificateConfirmInstance);
843 gCertificateConfirmInstance->Allow(true);
844 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
846 DALI_TEST_CHECK(gSslCertificateInstance);
847 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
848 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
850 // http authentication.
851 DALI_TEST_CHECK(gHttpAuthInstance);
852 gHttpAuthInstance->Suspend();
853 gHttpAuthInstance->UseCredential("", "");
854 gHttpAuthInstance->CancelCredential();
855 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
858 gCertificateConfirmInstance = nullptr;
859 gSslCertificateInstance = nullptr;
860 gHttpAuthInstance = nullptr;
865 int UtcDaliWebViewGetWebBackForwardList(void)
867 ToolkitTestApplication application;
869 WebView view = WebView::New();
870 DALI_TEST_CHECK( view );
872 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
873 DALI_TEST_CHECK( bfList != 0 );
878 int UtcDaliWebViewGetWebContext(void)
880 ToolkitTestApplication application;
882 WebView view = WebView::New();
883 DALI_TEST_CHECK( view );
885 Dali::Toolkit::WebContext* context = view.GetContext();
886 DALI_TEST_CHECK( context != 0 );
891 int UtcDaliWebViewGetWebCookieManager(void)
893 ToolkitTestApplication application;
895 WebView view = WebView::New();
896 DALI_TEST_CHECK( view );
898 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
899 DALI_TEST_CHECK( cookieManager != 0 );
904 int UtcDaliWebViewGetWebSettings(void)
906 ToolkitTestApplication application;
908 WebView view = WebView::New();
909 DALI_TEST_CHECK( view );
911 Dali::Toolkit::WebSettings* settings = view.GetSettings();
912 DALI_TEST_CHECK( settings != 0 );
917 int UtcDaliWebViewProperty1(void)
920 ToolkitTestApplication application;
922 WebView view = WebView::New();
923 DALI_TEST_CHECK( view );
926 view.SetProperty( WebView::Property::URL, TEST_URL1 );
927 Property::Value val = view.GetProperty( WebView::Property::URL );
928 DALI_TEST_CHECK( val.Get( local ) );
929 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
934 int UtcDaliWebViewProperty4(void)
937 ToolkitTestApplication application;
939 WebView view = WebView::New();
940 DALI_TEST_CHECK( view );
942 const std::string kDefaultValue;
943 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";
945 // Check default value
947 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
948 DALI_TEST_CHECK( value.Get( output ) );
949 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
951 // Check Set/GetProperty
952 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
953 value = view.GetProperty( WebView::Property::USER_AGENT );
954 DALI_TEST_CHECK( value.Get( output ) );
955 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
960 int UtcDaliWebViewProperty9(void)
963 ToolkitTestApplication application;
965 WebView view = WebView::New();
966 DALI_TEST_CHECK( view );
968 // Check default value
969 Dali::Vector2 output = Dali::Vector2::ONE;
970 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
971 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
973 // Check Set/GetProperty
974 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
975 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
976 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
977 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
979 // Check default value of scroll size
980 output = Dali::Vector2::ONE;
981 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
982 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
984 // Check default value of content size
985 output = Dali::Vector2::ONE;
986 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
987 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
992 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
994 ToolkitTestApplication application;
996 WebView view = WebView::New();
997 DALI_TEST_CHECK( view );
999 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1000 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1001 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1002 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1003 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1005 // Check default value
1006 std::string testText("test");
1008 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1009 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1014 int UtcDaliWebViewPropertyTitleFavicon(void)
1016 ToolkitTestApplication application;
1018 char argv[] = "--test";
1019 WebView view = WebView::New( 1, (char**)&argv );
1020 DALI_TEST_CHECK( view );
1023 view.ClearAllTilesResources();
1025 // Check default value of title
1026 std::string testValue("title");
1028 view.GetProperty( WebView::Property::TITLE ).Get( output );
1029 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1031 // Check default value of favicon
1032 Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
1033 DALI_TEST_CHECK( favicon );
1034 Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1035 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1040 int UtcDaliWebViewScrollBy(void)
1042 ToolkitTestApplication application;
1044 WebView view = WebView::New();
1045 DALI_TEST_CHECK( view );
1048 ConnectionTracker* testTracker = new ConnectionTracker();
1049 view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
1050 bool signal1 = false;
1051 view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
1052 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1054 view.LoadUrl( TEST_URL1 );
1055 Test::EmitGlobalTimerSignal();
1057 // set scroll position.
1058 Dali::Vector2 output = Dali::Vector2::ONE;
1059 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1060 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1061 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1062 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1064 // scroll by and trigger scrollEdgeReached event.
1065 view.ScrollBy( 50, 50 );
1066 Test::EmitGlobalTimerSignal();
1068 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1069 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1070 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1071 DALI_TEST_CHECK( signal1 );
1073 // scroll by and trigger scrollEdgeReached event.
1074 bool result = view.ScrollEdgeBy( 50, 50 );
1075 DALI_TEST_CHECK( result );
1076 Test::EmitGlobalTimerSignal();
1078 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1079 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1080 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1081 DALI_TEST_CHECK( signal1 );
1086 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1088 ToolkitTestApplication application;
1090 WebView view = WebView::New();
1091 DALI_TEST_CHECK( view );
1093 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1094 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1095 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1096 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1098 application.GetScene().Add( view );
1099 application.SendNotification();
1100 application.Render();
1102 view.ActivateAccessibility(true);
1103 view.AddDynamicCertificatePath("host", "test/to/path");
1104 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1105 DALI_TEST_CHECK( found );
1107 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1108 float result = view.GetScaleFactor();
1109 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1111 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1112 result = view.GetScaleFactor();
1113 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1118 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1121 ToolkitTestApplication application;
1123 char argv[] = "--test";
1124 WebView view = WebView::New( 1, (char**)&argv );
1125 DALI_TEST_CHECK( view );
1127 // Check GetScreenshot
1128 Dali::Rect<int> viewArea;
1131 viewArea.width = 10;
1132 viewArea.height = 10;
1133 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1134 DALI_TEST_CHECK( screenshot );
1135 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1136 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1138 // Check GetScreenshotAsynchronously
1141 viewArea.width = 100;
1142 viewArea.height = 100;
1143 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1144 DALI_TEST_CHECK( result );
1146 Test::EmitGlobalTimerSignal();
1148 Test::EmitGlobalTimerSignal();
1149 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1154 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1157 ToolkitTestApplication application;
1159 char argv[] = "--test";
1160 WebView view = WebView::New( 1, (char**)&argv );
1161 DALI_TEST_CHECK( view );
1163 // Check CheckVideoPlayingAsynchronously
1164 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1165 DALI_TEST_CHECK( result );
1166 Test::EmitGlobalTimerSignal();
1167 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1169 // Check RegisterGeolocationPermissionCallback
1170 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1171 Test::EmitGlobalTimerSignal();
1172 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1177 int UtcDaliWebViewHttpRequestInterceptor(void)
1179 ToolkitTestApplication application;
1181 WebView view = WebView::New();
1182 DALI_TEST_CHECK( view );
1185 ConnectionTracker* testTracker = new ConnectionTracker();
1186 view.RequestInterceptorSignal().Connect( &OnRequestInterceptor );
1187 bool signal1 = false;
1188 view.ConnectSignal( testTracker, "requestInterceptor", CallbackFunctor(&signal1) );
1189 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1190 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1192 view.LoadUrl( TEST_URL1 );
1193 Test::EmitGlobalTimerSignal();
1194 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1195 DALI_TEST_CHECK( signal1 );
1197 // check request interceptor.
1198 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1199 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1200 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1201 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1202 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1203 std::string testUrl("http://test.html");
1204 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1206 gRequestInterceptorInstance = nullptr;
1211 int UtcDaliWebViewPolicyDecisionRequest(void)
1213 ToolkitTestApplication application;
1215 WebView view = WebView::New();
1216 DALI_TEST_CHECK( view );
1219 ConnectionTracker* testTracker = new ConnectionTracker();
1220 view.PolicyDecisionSignal().Connect( &OnPolicyDecisionRequest );
1221 bool signal1 = false;
1222 view.ConnectSignal( testTracker, "policyDecision", CallbackFunctor(&signal1) );
1223 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 0, TEST_LOCATION );
1224 DALI_TEST_CHECK(gPolicyDecisionInstance == 0);
1226 view.LoadUrl( TEST_URL1 );
1227 Test::EmitGlobalTimerSignal();
1228 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 1, TEST_LOCATION );
1229 DALI_TEST_CHECK( signal1 );
1231 // check policy decision & its frame.
1232 DALI_TEST_CHECK(gPolicyDecisionInstance != 0);
1233 std::string testUrl("http://test.html");
1234 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1235 std::string testCookie("test:abc");
1236 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1237 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1238 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1239 std::string testResponseMime("txt/xml");
1240 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1241 int32_t ResponseStatusCode = 500;
1242 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1243 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1244 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1245 std::string testScheme("test");
1246 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1247 DALI_TEST_CHECK(gPolicyDecisionInstance->Use());
1248 DALI_TEST_CHECK(gPolicyDecisionInstance->Ignore());
1249 DALI_TEST_CHECK(gPolicyDecisionInstance->Suspend());
1251 Dali::WebEngineFrame* webFrame = &(gPolicyDecisionInstance->GetFrame());
1252 DALI_TEST_CHECK(webFrame);
1253 DALI_TEST_CHECK(webFrame->IsMainFrame());
1255 gPolicyDecisionInstance = nullptr;
1260 int UtcDaliWebViewEvaluteJavaScript(void)
1262 ToolkitTestApplication application;
1264 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1266 view.LoadHtmlString( "<body>Hello World!</body>" );
1267 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1268 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1269 Test::EmitGlobalTimerSignal();
1271 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1276 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1278 ToolkitTestApplication application;
1280 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1282 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1283 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1284 view.JavaScriptAlertReply();
1285 Test::EmitGlobalTimerSignal();
1286 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1288 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1289 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1290 view.JavaScriptConfirmReply( true );
1291 Test::EmitGlobalTimerSignal();
1292 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1294 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1295 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1296 view.JavaScriptPromptReply( "it is a prompt." );
1297 Test::EmitGlobalTimerSignal();
1298 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1303 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1305 ToolkitTestApplication application;
1307 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1308 DALI_TEST_CHECK( view );
1310 std::string html("<body>Hello World!</body>");
1311 std::string basicUri("http://basicurl");
1312 std::string unreachableUrl("http://unreachableurl");
1313 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1314 DALI_TEST_CHECK( result );
1316 application.SendNotification();
1317 application.Render();
1318 Test::EmitGlobalTimerSignal();
1320 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1321 DALI_TEST_CHECK( result );
1326 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1328 ToolkitTestApplication application;
1330 WebView view = WebView::New();
1331 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1332 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1333 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1334 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1336 application.GetScene().Add( view );
1337 application.SendNotification();
1338 application.Render();
1339 DALI_TEST_CHECK( view );
1341 view.LoadUrl( "http://test.html" );
1342 bool result = view.AddCustomHeader("key", "value");
1343 DALI_TEST_CHECK( result );
1345 result = view.ReloadWithoutCache();
1346 DALI_TEST_CHECK( result );
1348 uint32_t portNumber = view.StartInspectorServer(5000);
1349 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1351 application.SendNotification();
1352 application.Render();
1353 Test::EmitGlobalTimerSignal();
1355 result = view.StopInspectorServer();
1356 DALI_TEST_CHECK( result );
1358 view.SuspendNetworkLoading();
1360 result = view.RemoveCustomHeader("key");
1361 DALI_TEST_CHECK( result );
1363 view.ResumeNetworkLoading();
1368 int UtcDaliWebViewMethodsForCoverage(void)
1370 ToolkitTestApplication application;
1372 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1374 view.LoadHtmlString( "<body>Hello World!</body>" );
1375 view.AddJavaScriptMessageHandler( "jsObject",
1376 []( const std::string& arg ) {
1380 DALI_TEST_CHECK( view );
1385 // test cases for web backforward list.
1387 int UtcDaliWebBackForwardListCheckItem(void)
1389 ToolkitTestApplication application;
1391 WebView view = WebView::New();
1392 DALI_TEST_CHECK( view );
1394 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1395 DALI_TEST_CHECK( bfList != 0 )
1397 unsigned int itemCount = bfList->GetItemCount();
1398 DALI_TEST_CHECK( itemCount == 1 )
1400 Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
1401 DALI_TEST_CHECK( citem != 0 );
1403 const std::string kDefaultUrl( "http://url" );
1404 std::string testValue = citem->GetUrl();
1405 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1407 const std::string kDefaultTitle( "title" );
1408 testValue = citem->GetTitle();
1409 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1411 const std::string kDefaultOriginalUrl( "http://originalurl" );
1412 testValue = citem->GetOriginalUrl();
1413 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1415 Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
1416 DALI_TEST_CHECK( item != 0 );
1421 // test cases for web context.
1423 int UtcDaliWebContextGetSetCacheModel(void)
1425 ToolkitTestApplication application;
1427 WebView view = WebView::New();
1428 DALI_TEST_CHECK( view );
1430 Dali::Toolkit::WebContext* context = view.GetContext();
1431 DALI_TEST_CHECK( context != 0 )
1433 std::string kDefaultValue;
1436 context->SetProxyUri( kDefaultValue );
1437 context->SetCertificateFilePath( kDefaultValue );
1438 context->DisableCache( false );
1439 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1440 context->DeleteAllWebDatabase();
1441 context->DeleteAllWebStorage();
1442 context->DeleteLocalFileSystem();
1443 context->ClearCache();
1445 // Check default value
1446 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1447 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1449 // Check Set/GetProperty
1450 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1451 value = context->GetCacheModel();
1452 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1457 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1459 ToolkitTestApplication application;
1461 WebView view = WebView::New();
1462 DALI_TEST_CHECK( view );
1464 Dali::Toolkit::WebContext* context = view.GetContext();
1465 DALI_TEST_CHECK( context != 0 )
1467 std::string kDefaultValue;
1469 // get origins of web database
1470 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1471 DALI_TEST_CHECK( result );
1473 Test::EmitGlobalTimerSignal();
1474 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1475 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1477 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1478 DALI_TEST_CHECK( origin );
1480 result = context->DeleteWebDatabase(*origin);
1481 DALI_TEST_CHECK( result );
1483 // get origins of web storage
1484 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1485 DALI_TEST_CHECK( result );
1487 Test::EmitGlobalTimerSignal();
1488 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1489 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1491 origin = gSecurityOriginList[0].get();
1492 DALI_TEST_CHECK( origin );
1494 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1495 DALI_TEST_CHECK( result );
1496 Test::EmitGlobalTimerSignal();
1497 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1499 result = context->DeleteWebStorageOrigin(*origin);
1500 DALI_TEST_CHECK( result );
1502 result = context->DeleteApplicationCache(*origin);
1503 DALI_TEST_CHECK( result );
1505 // form passwords, download state, mime type.
1506 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1507 Test::EmitGlobalTimerSignal();
1508 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1509 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1510 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1511 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1513 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1514 Test::EmitGlobalTimerSignal();
1515 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1517 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1518 Test::EmitGlobalTimerSignal();
1519 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1521 gSecurityOriginList.clear();
1522 gPasswordDataList.clear();
1527 // test cases for web cookie manager.
1529 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1531 ToolkitTestApplication application;
1533 WebView view = WebView::New();
1534 DALI_TEST_CHECK( view );
1536 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1537 DALI_TEST_CHECK( cookieManager != 0 )
1539 const std::string kDefaultValue;
1542 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1543 cookieManager->ClearCookies();
1545 // Check default value
1546 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1547 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1549 // Check Set/GetProperty
1550 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1551 value = cookieManager->GetCookieAcceptPolicy();
1552 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1557 // test cases for web settings.
1559 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1561 ToolkitTestApplication application;
1563 WebView view = WebView::New();
1564 DALI_TEST_CHECK( view );
1566 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1567 DALI_TEST_CHECK( settings != 0 )
1570 settings->AllowMixedContents( false );
1571 settings->EnableSpatialNavigation( false );
1572 settings->EnableWebSecurity( false );
1573 settings->EnableCacheBuilder( false );
1574 settings->EnableDoNotTrack( false );
1575 settings->UseScrollbarThumbFocusNotifications( false );
1576 settings->AllowFileAccessFromExternalUrl( false );
1577 settings->AllowScriptsOpenWindows( false );
1579 // Check default value
1580 int value = settings->GetDefaultFontSize();
1581 DALI_TEST_CHECK( value == 16 );
1583 // Check Set/GetProperty
1584 settings->SetDefaultFontSize( 20 );
1585 value = settings->GetDefaultFontSize();
1586 DALI_TEST_CHECK( value == 20 );
1591 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1593 ToolkitTestApplication application;
1595 WebView view = WebView::New();
1596 DALI_TEST_CHECK( view );
1598 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1599 DALI_TEST_CHECK( settings != 0 )
1602 settings->AllowMixedContents( false );
1603 settings->EnableSpatialNavigation( false );
1604 settings->EnableWebSecurity( false );
1605 settings->EnableCacheBuilder( false );
1606 settings->EnableDoNotTrack( false );
1607 settings->UseScrollbarThumbFocusNotifications( false );
1608 settings->AllowFileAccessFromExternalUrl( false );
1609 settings->AllowScriptsOpenWindows( false );
1611 // Check default value is true or not
1612 bool value = settings->IsJavaScriptEnabled();
1613 DALI_TEST_CHECK( value );
1615 // Check Set/GetProperty
1616 settings->EnableJavaScript( false );
1617 value = settings->IsJavaScriptEnabled();
1618 DALI_TEST_CHECK( !value );
1623 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1625 ToolkitTestApplication application;
1627 WebView view = WebView::New();
1628 DALI_TEST_CHECK( view );
1630 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1631 DALI_TEST_CHECK( settings != 0 )
1634 settings->AllowMixedContents( false );
1635 settings->EnableSpatialNavigation( false );
1636 settings->EnableWebSecurity( false );
1637 settings->EnableCacheBuilder( false );
1638 settings->EnableDoNotTrack( false );
1639 settings->UseScrollbarThumbFocusNotifications( false );
1640 settings->AllowFileAccessFromExternalUrl( false );
1641 settings->AllowScriptsOpenWindows( false );
1643 // Check default value is true or not
1644 bool value = settings->IsAutoFittingEnabled();
1645 DALI_TEST_CHECK( value );
1647 // Check Set/GetProperty
1648 settings->EnableAutoFitting( false );
1649 value = settings->IsAutoFittingEnabled();
1650 DALI_TEST_CHECK( !value );
1655 int UtcDaliWebSettingsCheckEnablePlugins(void)
1657 ToolkitTestApplication application;
1659 WebView view = WebView::New();
1660 DALI_TEST_CHECK( view );
1662 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1663 DALI_TEST_CHECK( settings != 0 )
1666 settings->AllowMixedContents( false );
1667 settings->EnableSpatialNavigation( false );
1668 settings->EnableWebSecurity( false );
1669 settings->EnableCacheBuilder( false );
1670 settings->EnableDoNotTrack( false );
1671 settings->UseScrollbarThumbFocusNotifications( false );
1672 settings->AllowFileAccessFromExternalUrl( false );
1673 settings->AllowScriptsOpenWindows( false );
1675 // Check default value is true or not
1676 bool value = settings->ArePluginsEnabled();
1677 DALI_TEST_CHECK( value );
1679 // Check Set/GetProperty
1680 settings->EnablePlugins( false );
1681 value = settings->ArePluginsEnabled();
1682 DALI_TEST_CHECK( !value );
1687 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1689 ToolkitTestApplication application;
1691 WebView view = WebView::New();
1692 DALI_TEST_CHECK( view );
1694 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1695 DALI_TEST_CHECK( settings != 0 )
1698 settings->AllowMixedContents( false );
1699 settings->EnableSpatialNavigation( false );
1700 settings->EnableWebSecurity( false );
1701 settings->EnableCacheBuilder( false );
1702 settings->EnableDoNotTrack( false );
1703 settings->UseScrollbarThumbFocusNotifications( false );
1704 settings->AllowFileAccessFromExternalUrl( false );
1705 settings->AllowScriptsOpenWindows( false );
1707 // Check default value is true or not
1708 bool value = settings->IsPrivateBrowsingEnabled();
1709 DALI_TEST_CHECK( value );
1711 // Check Set/GetProperty
1712 settings->EnablePrivateBrowsing( false );
1713 value = settings->IsPrivateBrowsingEnabled();
1714 DALI_TEST_CHECK( !value );
1719 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1721 ToolkitTestApplication application;
1723 WebView view = WebView::New();
1724 DALI_TEST_CHECK( view );
1726 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1727 DALI_TEST_CHECK( settings != 0 )
1730 settings->AllowMixedContents( false );
1731 settings->EnableSpatialNavigation( false );
1732 settings->EnableWebSecurity( false );
1733 settings->EnableCacheBuilder( false );
1734 settings->EnableDoNotTrack( false );
1735 settings->UseScrollbarThumbFocusNotifications( false );
1736 settings->AllowFileAccessFromExternalUrl( false );
1737 settings->AllowScriptsOpenWindows( false );
1739 // Check default value is true or not
1740 bool value = settings->IsLinkMagnifierEnabled();
1741 DALI_TEST_CHECK( value );
1743 // Check Set/GetProperty
1744 settings->EnableLinkMagnifier( false );
1745 value = settings->IsLinkMagnifierEnabled();
1746 DALI_TEST_CHECK( !value );
1751 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1753 ToolkitTestApplication application;
1755 WebView view = WebView::New();
1756 DALI_TEST_CHECK( view );
1758 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1759 DALI_TEST_CHECK( settings != 0 )
1762 settings->AllowMixedContents( false );
1763 settings->EnableSpatialNavigation( false );
1764 settings->EnableWebSecurity( false );
1765 settings->EnableCacheBuilder( false );
1766 settings->EnableDoNotTrack( false );
1767 settings->UseScrollbarThumbFocusNotifications( false );
1768 settings->AllowFileAccessFromExternalUrl( false );
1769 settings->AllowScriptsOpenWindows( false );
1771 // Check default value is true or not
1772 bool value = settings->IsKeypadWithoutUserActionUsed();
1773 DALI_TEST_CHECK( value );
1775 // Check Set/GetProperty
1776 settings->UseKeypadWithoutUserAction( false );
1777 value = settings->IsKeypadWithoutUserActionUsed();
1778 DALI_TEST_CHECK( !value );
1783 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1785 ToolkitTestApplication application;
1787 WebView view = WebView::New();
1788 DALI_TEST_CHECK( view );
1790 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1791 DALI_TEST_CHECK( settings != 0 )
1794 settings->AllowMixedContents( false );
1795 settings->EnableSpatialNavigation( false );
1796 settings->EnableWebSecurity( false );
1797 settings->EnableCacheBuilder( false );
1798 settings->EnableDoNotTrack( false );
1799 settings->UseScrollbarThumbFocusNotifications( false );
1800 settings->AllowFileAccessFromExternalUrl( false );
1801 settings->AllowScriptsOpenWindows( false );
1803 // Check default value is true or not
1804 bool value = settings->IsAutofillPasswordFormEnabled();
1805 DALI_TEST_CHECK( value );
1806 settings->EnableAutofillPasswordForm( false );
1807 value = settings->IsAutofillPasswordFormEnabled();
1808 DALI_TEST_CHECK( !value );
1812 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1814 ToolkitTestApplication application;
1816 WebView view = WebView::New();
1817 DALI_TEST_CHECK( view );
1819 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1820 DALI_TEST_CHECK( settings != 0 );
1823 settings->AllowMixedContents( false );
1824 settings->EnableSpatialNavigation( false );
1825 settings->EnableWebSecurity( false );
1826 settings->EnableCacheBuilder( false );
1827 settings->EnableDoNotTrack( false );
1828 settings->UseScrollbarThumbFocusNotifications( false );
1829 settings->AllowFileAccessFromExternalUrl( false );
1830 settings->AllowScriptsOpenWindows( false );
1832 // Check default value is true or not
1833 bool value = settings->IsFormCandidateDataEnabled();
1834 DALI_TEST_CHECK( value );
1836 // Check Set/GetProperty
1837 settings->EnableFormCandidateData( false );
1838 value = settings->IsFormCandidateDataEnabled();
1839 DALI_TEST_CHECK( !value );
1844 int UtcDaliWebSettingsCheckEnableTextSelection(void)
1846 ToolkitTestApplication application;
1848 WebView view = WebView::New();
1849 DALI_TEST_CHECK( view );
1851 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1852 DALI_TEST_CHECK( settings != 0 );
1855 settings->AllowMixedContents( false );
1856 settings->EnableSpatialNavigation( false );
1857 settings->EnableWebSecurity( false );
1858 settings->EnableCacheBuilder( false );
1859 settings->EnableDoNotTrack( false );
1860 settings->UseScrollbarThumbFocusNotifications( false );
1861 settings->AllowFileAccessFromExternalUrl( false );
1862 settings->AllowScriptsOpenWindows( false );
1864 // Check default value is true or not
1865 bool value = settings->IsTextSelectionEnabled();
1866 DALI_TEST_CHECK( value );
1868 //Check Set/GetProperty
1869 settings->EnableTextSelection(false);
1870 value = settings->IsTextSelectionEnabled();
1871 DALI_TEST_CHECK( !value );
1876 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
1878 ToolkitTestApplication application;
1880 WebView view = WebView::New();
1881 DALI_TEST_CHECK( view );
1883 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1884 DALI_TEST_CHECK( settings != 0 );
1887 settings->AllowMixedContents( false );
1888 settings->EnableSpatialNavigation( false );
1889 settings->EnableWebSecurity( false );
1890 settings->EnableCacheBuilder( false );
1891 settings->EnableDoNotTrack( false );
1892 settings->UseScrollbarThumbFocusNotifications( false );
1893 settings->AllowFileAccessFromExternalUrl( false );
1894 settings->AllowScriptsOpenWindows( false );
1896 // Check default value is true or not
1897 bool value = settings->IsTextAutosizingEnabled();
1898 DALI_TEST_CHECK( value );
1900 // Check Set/GetProperty
1901 settings->EnableTextAutosizing(false);
1902 value = settings->IsTextAutosizingEnabled();
1903 DALI_TEST_CHECK( !value );
1908 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
1910 ToolkitTestApplication application;
1912 WebView view = WebView::New();
1913 DALI_TEST_CHECK( view );
1915 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1916 DALI_TEST_CHECK( settings != 0 );
1919 settings->AllowMixedContents( false );
1920 settings->EnableSpatialNavigation( false );
1921 settings->EnableWebSecurity( false );
1922 settings->EnableCacheBuilder( false );
1923 settings->EnableDoNotTrack( false );
1924 settings->UseScrollbarThumbFocusNotifications( false );
1925 settings->AllowFileAccessFromExternalUrl( false );
1926 settings->AllowScriptsOpenWindows( false );
1928 // Check default value is true or not
1929 bool value = settings->IsArrowScrollEnabled();
1930 DALI_TEST_CHECK( value );
1932 // Check Set/GetProperty
1933 settings->EnableArrowScroll(false);
1934 value = settings->IsArrowScrollEnabled();
1935 DALI_TEST_CHECK( !value );
1940 int UtcDaliWebSettingsCheckEnableClipboard(void)
1942 ToolkitTestApplication application;
1944 WebView view = WebView::New();
1945 DALI_TEST_CHECK( view );
1947 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1948 DALI_TEST_CHECK( settings != 0 );
1951 settings->AllowMixedContents( false );
1952 settings->EnableSpatialNavigation( false );
1953 settings->EnableWebSecurity( false );
1954 settings->EnableCacheBuilder( false );
1955 settings->EnableDoNotTrack( false );
1956 settings->UseScrollbarThumbFocusNotifications( false );
1957 settings->AllowFileAccessFromExternalUrl( false );
1958 settings->AllowScriptsOpenWindows( false );
1960 // Check default value is true or not
1961 bool value = settings->IsClipboardEnabled();
1962 DALI_TEST_CHECK( value );
1963 settings->EnableClipboard(false);
1964 value = settings->IsClipboardEnabled();
1965 DALI_TEST_CHECK( !value );
1969 int UtcDaliWebSettingsCheckEnableImePanel(void)
1971 ToolkitTestApplication application;
1973 WebView view = WebView::New();
1974 DALI_TEST_CHECK( view );
1976 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1977 DALI_TEST_CHECK( settings != 0 );
1980 settings->AllowMixedContents( false );
1981 settings->EnableSpatialNavigation( false );
1982 settings->EnableWebSecurity( false );
1983 settings->EnableCacheBuilder( false );
1984 settings->EnableDoNotTrack( false );
1985 settings->UseScrollbarThumbFocusNotifications( false );
1986 settings->AllowFileAccessFromExternalUrl( false );
1987 settings->AllowScriptsOpenWindows( false );
1989 // Check default value is true or not
1990 bool value = settings->IsImePanelEnabled();
1991 DALI_TEST_CHECK( value );
1993 // Check Set/GetProperty
1994 settings->EnableImePanel(false);
1995 value = settings->IsImePanelEnabled();
1996 DALI_TEST_CHECK( !value );
2001 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2003 ToolkitTestApplication application;
2005 WebView view = WebView::New();
2006 DALI_TEST_CHECK( view );
2008 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2009 DALI_TEST_CHECK( settings != 0 )
2012 settings->AllowMixedContents( false );
2013 settings->EnableSpatialNavigation( false );
2014 settings->EnableWebSecurity( false );
2015 settings->EnableCacheBuilder( false );
2016 settings->EnableDoNotTrack( false );
2017 settings->UseScrollbarThumbFocusNotifications( false );
2018 settings->AllowFileAccessFromExternalUrl( false );
2019 settings->AllowScriptsOpenWindows( false );
2021 // Check default value is true or not
2022 bool value = settings->AreImagesLoadedAutomatically();
2023 DALI_TEST_CHECK( value );
2025 // Check Set/GetProperty
2026 settings->AllowImagesLoadAutomatically( false );
2027 value = settings->AreImagesLoadedAutomatically();
2028 DALI_TEST_CHECK( !value );
2033 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2035 ToolkitTestApplication application;
2037 WebView view = WebView::New();
2038 DALI_TEST_CHECK( view );
2040 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2041 DALI_TEST_CHECK( settings != 0 )
2043 const std::string kDefaultValue;
2044 const std::string kTestValue = "UTF-8";
2047 settings->AllowMixedContents( false );
2048 settings->EnableSpatialNavigation( false );
2049 settings->EnableWebSecurity( false );
2050 settings->EnableCacheBuilder( false );
2051 settings->EnableDoNotTrack( false );
2052 settings->UseScrollbarThumbFocusNotifications( false );
2053 settings->AllowFileAccessFromExternalUrl( false );
2054 settings->AllowScriptsOpenWindows( false );
2056 // Check default value
2057 std::string value = settings->GetDefaultTextEncodingName();
2058 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2060 // Check Set/GetProperty
2061 settings->SetDefaultTextEncodingName( kTestValue );
2062 value = settings->GetDefaultTextEncodingName();
2063 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );