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-back-forward-list-item.h>
45 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
46 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
48 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
49 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
52 using namespace Toolkit;
57 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
58 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
60 static int gPageLoadStartedCallbackCalled = 0;
61 static int gPageLoadInProgressCallbackCalled = 0;
62 static int gPageLoadFinishedCallbackCalled = 0;
63 static int gPageLoadErrorCallbackCalled = 0;
64 static std::shared_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
65 static int gScrollEdgeReachedCallbackCalled = 0;
66 static int gUrlChangedCallbackCalled = 0;
67 static int gEvaluateJavaScriptCallbackCalled = 0;
68 static int gJavaScriptAlertCallbackCalled = 0;
69 static int gJavaScriptConfirmCallbackCalled = 0;
70 static int gJavaScriptPromptCallbackCalled = 0;
71 static int gScreenshotCapturedCallbackCalled = 0;
72 static int gVideoPlayingCallbackCalled = 0;
73 static int gGeolocationPermissionCallbackCalled = 0;
74 static bool gTouched = false;
75 static bool gHovered = false;
76 static bool gWheelEventHandled = false;
77 static int gFormRepostDecisionCallbackCalled = 0;
78 static std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> gFormRepostDecisionInstance = nullptr;
79 static int gFrameRenderedCallbackCalled = 0;
80 static int gRequestInterceptorCallbackCalled = 0;
81 static std::shared_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
82 static int gConsoleMessageCallbackCalled = 0;
83 static std::shared_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
84 static int gPolicyDecisionCallbackCalled = 0;
85 static std::shared_ptr<Dali::WebEnginePolicyDecision> gPolicyDecisionInstance = nullptr;
86 static int gCertificateConfirmCallbackCalled = 0;
87 static std::shared_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
88 static int gSslCertificateChangedCallbackCalled = 0;
89 static std::shared_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
90 static int gHttpAuthHandlerCallbackCalled = 0;
91 static std::shared_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
92 static int gSecurityOriginsAcquiredCallbackCalled = 0;
93 static int gStorageUsageAcquiredCallbackCalled = 0;
94 static int gFormPasswordsAcquiredCallbackCalled = 0;
95 static int gDownloadStartedCallbackCalled = 0;
96 static int gMimeOverriddenCallbackCalled = 0;
97 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
98 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
99 static int gContextMenuCustomizedCallbackCalled = 0;
100 static std::shared_ptr<Dali::WebEngineContextMenu> gContextMenuInstance = 0;
101 static int gContextMenuItemSelectedCallbackCalled = 0;
102 static std::shared_ptr<Dali::WebEngineContextMenuItem> gContextMenuItemInstance = 0;
104 struct CallbackFunctor
106 CallbackFunctor(bool* callbackFlag)
107 : mCallbackFlag( callbackFlag )
113 *mCallbackFlag = true;
118 static void OnPageLoadStarted( WebView view, const std::string& url )
120 gPageLoadStartedCallbackCalled++;
123 static void OnPageLoadInProgress( WebView view, const std::string& url )
125 gPageLoadInProgressCallbackCalled++;
128 static void OnPageLoadFinished( WebView view, const std::string& url )
130 gPageLoadFinishedCallbackCalled++;
133 static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
135 gScrollEdgeReachedCallbackCalled++;
138 static void OnPolicyDecisionRequest(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
140 gPolicyDecisionCallbackCalled++;
141 gPolicyDecisionInstance = std::move(decision);
144 static void OnUrlChanged( WebView view, const std::string& url )
146 gUrlChangedCallbackCalled++;
149 static void OnPageLoadError(WebView view, std::shared_ptr<Dali::WebEngineLoadError> error)
151 gPageLoadErrorCallbackCalled++;
152 gPageLoadErrorInstance = std::move(error);
155 static void OnEvaluateJavaScript( const std::string& result )
157 gEvaluateJavaScriptCallbackCalled++;
160 static bool OnJavaScriptAlert( const std::string& result )
162 gJavaScriptAlertCallbackCalled++;
166 static bool OnJavaScriptConfirm( const std::string& result )
168 gJavaScriptConfirmCallbackCalled++;
172 static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string& message2 )
174 gJavaScriptPromptCallbackCalled++;
178 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
180 gScreenshotCapturedCallbackCalled++;
183 static void OnVideoPlaying(bool isPlaying)
185 gVideoPlayingCallbackCalled++;
188 static bool OnGeolocationPermission(const std::string&, const std::string&)
190 gGeolocationPermissionCallbackCalled++;
194 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
200 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
206 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheel )
208 gWheelEventHandled = true;
212 static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> decision)
214 gFormRepostDecisionCallbackCalled++;
215 gFormRepostDecisionInstance = std::move(decision);
218 static void OnFrameRendered(WebView)
220 gFrameRenderedCallbackCalled++;
223 static void OnRequestInterceptor(WebView view, std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
225 gRequestInterceptorCallbackCalled++;
226 gRequestInterceptorInstance = std::move(interceptor);
229 static void OnConsoleMessage(WebView view, std::shared_ptr<Dali::WebEngineConsoleMessage> message)
231 gConsoleMessageCallbackCalled++;
232 gConsoleMessageInstance = std::move(message);
235 static void OnCertificateConfirm(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
237 gCertificateConfirmCallbackCalled++;
238 gCertificateConfirmInstance = std::move(certificate);
241 static void OnSslCertificateChanged(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
243 gSslCertificateChangedCallbackCalled++;
244 gSslCertificateInstance = std::move(certificate);
247 static void OnHttpAuthHandler( WebView view, std::shared_ptr<Dali::WebEngineHttpAuthHandler> hander )
249 gHttpAuthHandlerCallbackCalled++;
250 gHttpAuthInstance = std::move(hander);
253 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
255 gSecurityOriginsAcquiredCallbackCalled++;
256 gSecurityOriginList.clear();
257 gSecurityOriginList.swap(origins);
260 static void OnStorageUsageAcquired(uint64_t usage)
262 gStorageUsageAcquiredCallbackCalled++;
265 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
267 gFormPasswordsAcquiredCallbackCalled++;
268 gPasswordDataList.clear();
269 gPasswordDataList.swap(passwords);
272 static void OnDownloadStarted(const std::string& url)
274 gDownloadStartedCallbackCalled++;
277 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
279 gMimeOverriddenCallbackCalled++;
283 static void OnContextMenuCustomized(WebView view, std::shared_ptr<Dali::WebEngineContextMenu> menu)
285 gContextMenuCustomizedCallbackCalled++;
286 gContextMenuInstance = std::move(menu);
289 static void OnContextMenuItemSelected(WebView view, std::shared_ptr<Dali::WebEngineContextMenuItem> item)
291 gContextMenuItemSelectedCallbackCalled++;
292 gContextMenuItemInstance = std::move(item);
297 void web_view_startup(void)
299 test_return_value = TET_UNDEF;
302 void web_view_cleanup(void)
304 test_return_value = TET_PASS;
307 int UtcDaliWebViewBasics(void)
309 ToolkitTestApplication application;
311 // Copy and Assignment Test
312 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
313 WebView view = WebView::New();
314 DALI_TEST_CHECK( view );
316 WebView copy( view );
317 DALI_TEST_CHECK( view == copy );
320 DALI_TEST_CHECK( !assign );
323 DALI_TEST_CHECK( assign == view );
326 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
327 BaseHandle handle(view);
329 WebView view2 = WebView::DownCast( handle );
330 DALI_TEST_CHECK( view );
331 DALI_TEST_CHECK( view2 );
332 DALI_TEST_CHECK( view == view2 );
335 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
336 TypeRegistry typeRegistry = TypeRegistry::Get();
337 DALI_TEST_CHECK( typeRegistry );
339 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
340 DALI_TEST_CHECK( typeInfo );
342 BaseHandle handle2 = typeInfo.CreateInstance();
343 DALI_TEST_CHECK( handle2 );
345 WebView view3 = WebView::DownCast( handle2 );
346 DALI_TEST_CHECK( view3 );
351 int UtcDaliWebViewPageNavigation(void)
353 ToolkitTestApplication application;
355 WebView view = WebView::New();
356 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
357 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
358 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
359 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
360 application.GetScene().Add( view );
361 application.SendNotification();
362 application.Render();
363 DALI_TEST_CHECK( view );
365 ConnectionTracker* testTracker = new ConnectionTracker();
366 view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
367 view.PageLoadInProgressSignal().Connect( &OnPageLoadInProgress );
368 view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
369 view.UrlChangedSignal().Connect( &OnUrlChanged );
370 bool signal1 = false;
371 bool signal2 = false;
372 bool signal3 = false;
373 bool signal4 = false;
374 bool signal5 = false;
375 view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
376 view.ConnectSignal( testTracker, "pageLoadInProgress", CallbackFunctor(&signal2) );
377 view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal3) );
378 view.ConnectSignal( testTracker, "urlChanged", CallbackFunctor(&signal4) );
379 view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal5) );
380 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
381 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
382 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
383 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
385 view.LoadUrl( TEST_URL1 );
386 view.GetNaturalSize();
387 Test::EmitGlobalTimerSignal();
388 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
389 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
390 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
391 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
392 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
393 DALI_TEST_CHECK( signal1 & signal2 & signal3 & signal4 );
394 DALI_TEST_CHECK( !signal5 );
396 view.LoadUrl( TEST_URL2 );
398 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
399 application.SendNotification();
400 application.Render();
401 Test::EmitGlobalTimerSignal();
403 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
404 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
405 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
406 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
407 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
408 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
411 Test::EmitGlobalTimerSignal();
412 DALI_TEST_CHECK( !view.CanGoBack() );
413 DALI_TEST_CHECK( view.CanGoForward() );
416 Test::EmitGlobalTimerSignal();
417 DALI_TEST_CHECK( view.CanGoBack() );
418 DALI_TEST_CHECK( !view.CanGoForward() );
423 Test::EmitGlobalTimerSignal();
424 DALI_TEST_CHECK( !view.CanGoBack() );
425 DALI_TEST_CHECK( !view.CanGoForward() );
430 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
432 ToolkitTestApplication application;
434 WebView view = WebView::New();
435 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
436 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
437 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
438 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
439 application.GetScene().Add( view );
440 application.SendNotification();
441 application.Render();
442 DALI_TEST_CHECK( view );
444 ConnectionTracker* testTracker = new ConnectionTracker();
445 view.PageLoadErrorSignal().Connect( &OnPageLoadError );
446 view.ConsoleMessageSignal().Connect( &OnConsoleMessage );
447 bool signal1 = false;
448 bool signal2 = false;
449 view.ConnectSignal( testTracker, "pageLoadError", CallbackFunctor(&signal1) );
450 view.ConnectSignal( testTracker, "consoleMessage", CallbackFunctor(&signal2) );
451 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
452 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
454 view.LoadUrl( TEST_URL1 );
455 Test::EmitGlobalTimerSignal();
456 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
457 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
458 DALI_TEST_CHECK( signal1 & signal2);
461 DALI_TEST_CHECK(gPageLoadErrorInstance);
462 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
463 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
464 std::string testErrorDescription("This is an error.");
465 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
466 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
469 DALI_TEST_CHECK(gConsoleMessageInstance);
470 std::string testConsoleSource("source");
471 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
472 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
473 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
474 std::string testConsoleText("This is a text.");
475 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
478 gPageLoadErrorInstance = nullptr;
479 gConsoleMessageInstance = nullptr;
484 int UtcDaliWebViewTouchAndKeys(void)
486 ToolkitTestApplication application;
488 WebView view = WebView::New();
489 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
490 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
491 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
492 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
494 application.GetScene().Add( view );
495 application.SendNotification();
496 application.Render();
498 view.GetNaturalSize();
499 view.TouchedSignal().Connect( &OnTouched );
502 Dali::Integration::TouchEvent event;
503 Dali::Integration::Point pointDown, pointUp;
505 event = Dali::Integration::TouchEvent();
506 pointDown.SetState( PointState::DOWN );
507 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
508 event.AddPoint( pointDown );
509 application.ProcessEvent( event );
511 event = Dali::Integration::TouchEvent();
512 pointUp.SetState( PointState::UP );
513 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
514 event.AddPoint( pointUp );
515 application.ProcessEvent( event );
518 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
519 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
520 application.SendNotification();
522 DALI_TEST_CHECK( gTouched );
523 DALI_TEST_CHECK( view );
528 int UtcDaliWebViewFocusGainedAndLost(void)
530 ToolkitTestApplication application;
532 WebView view = WebView::New();
533 DALI_TEST_CHECK( view );
535 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
536 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
537 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
538 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
540 application.GetScene().Add( view );
541 application.SendNotification();
542 application.Render();
544 view.SetKeyInputFocus();
545 DALI_TEST_CHECK( view.HasKeyInputFocus() );
548 view.ClearKeyInputFocus();
549 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
554 int UtcDaliWebViewPropertyPageZoomFactor(void)
556 ToolkitTestApplication application;
558 WebView view = WebView::New();
559 DALI_TEST_CHECK( view );
561 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
562 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
563 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
564 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
566 application.GetScene().Add( view );
567 application.SendNotification();
568 application.Render();
570 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
571 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
572 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
574 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
575 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
576 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
581 int UtcDaliWebViewPropertyTextZoomFactor(void)
583 ToolkitTestApplication application;
585 WebView view = WebView::New();
586 DALI_TEST_CHECK( view );
588 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
589 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
590 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
591 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
593 application.GetScene().Add( view );
594 application.SendNotification();
595 application.Render();
597 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
598 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
599 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
601 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
602 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
603 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
608 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
610 ToolkitTestApplication application;
612 WebView view = WebView::New();
613 DALI_TEST_CHECK( view );
615 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
616 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
617 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
618 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
620 application.GetScene().Add( view );
621 application.SendNotification();
622 application.Render();
624 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
625 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
630 int UtcDaliWebViewMove(void)
632 ToolkitTestApplication application;
634 WebView view = WebView::New();
635 DALI_TEST_CHECK( view );
637 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
638 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
639 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
640 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
642 application.GetScene().Add( view );
643 application.SendNotification();
644 application.Render();
646 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
647 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
648 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
653 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
655 ToolkitTestApplication application;
657 WebView view = WebView::New();
658 DALI_TEST_CHECK( view );
660 const bool kDefaultValue = true;
661 const bool kTestValue = false;
663 // Check default value
665 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
666 DALI_TEST_CHECK( value.Get( output ) );
667 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
669 // Check Set/GetProperty
670 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
671 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
672 DALI_TEST_CHECK( value.Get( output ) );
673 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
678 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
680 ToolkitTestApplication application;
682 WebView view = WebView::New();
683 DALI_TEST_CHECK( view );
685 const bool kDefaultValue = true;
686 const bool kTestValue = false;
688 // Check default value
690 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
691 DALI_TEST_CHECK( value.Get( output ) );
692 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
694 // Check Set/GetProperty
695 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
696 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
697 DALI_TEST_CHECK( value.Get( output ) );
698 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
703 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
705 ToolkitTestApplication application;
707 WebView view = WebView::New();
708 DALI_TEST_CHECK( view );
710 const bool kDefaultValue = true;
711 const bool kTestValue = false;
713 // Check default value
715 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
716 DALI_TEST_CHECK( value.Get( output ) );
717 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
719 // Check Set/GetProperty
720 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
721 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
722 DALI_TEST_CHECK( value.Get( output ) );
723 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
728 int UtcDaliWebViewHoverAndWheel(void)
730 ToolkitTestApplication application;
732 WebView view = WebView::New();
733 DALI_TEST_CHECK( view );
734 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
735 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
736 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
737 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
739 application.GetScene().Add( view );
740 application.SendNotification();
741 application.Render();
743 view.GetNaturalSize();
744 view.HoveredSignal().Connect( &OnHovered );
745 view.WheelEventSignal().Connect( &OnWheelEvent );
748 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
749 Dali::Integration::Point pointDown;
750 pointDown.SetState( PointState::DOWN );
751 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
752 event.AddPoint( pointDown );
753 application.ProcessEvent( event );
755 event = Dali::Integration::HoverEvent();
756 Dali::Integration::Point pointUp;
757 pointUp.SetState( PointState::UP );
758 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
759 event.AddPoint( pointUp );
760 application.ProcessEvent( event );
762 event = Dali::Integration::HoverEvent();
763 Dali::Integration::Point pointMotion;
764 pointUp.SetState( PointState::MOTION );
765 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
766 event.AddPoint( pointMotion );
767 application.ProcessEvent( event );
770 Dali::Integration::WheelEvent wheelEvent;
771 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
772 wheelEvent.direction = 0;
773 wheelEvent.point = Vector2( 20, 20 );
774 wheelEvent.delta = 10;
775 application.ProcessEvent( wheelEvent );
776 application.SendNotification();
778 DALI_TEST_CHECK( gHovered );
779 DALI_TEST_CHECK( gWheelEventHandled );
784 int UtcDaliWebViewFormRepostDecisionFrameRendering(void)
786 ToolkitTestApplication application;
788 WebView view = WebView::New();
789 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
790 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
791 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
792 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
793 application.GetScene().Add( view );
794 application.SendNotification();
795 application.Render();
796 DALI_TEST_CHECK( view );
798 ConnectionTracker* testTracker = new ConnectionTracker();
799 view.FormRepostDecisionSignal().Connect(&OnFormRepostDecision);
800 view.FrameRenderedSignal().Connect(&OnFrameRendered);
801 bool signal1 = false;
802 bool signal2 = false;
803 view.ConnectSignal( testTracker, "formRepostDecision", CallbackFunctor(&signal1) );
804 view.ConnectSignal( testTracker, "frameRendered", CallbackFunctor(&signal2) );
805 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 0, TEST_LOCATION );
806 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
808 view.LoadUrl( TEST_URL1 );
809 Test::EmitGlobalTimerSignal();
810 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 1, TEST_LOCATION );
811 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
812 DALI_TEST_CHECK( signal1 & signal2);
814 // form repost decision.
815 DALI_TEST_CHECK(gFormRepostDecisionInstance);
816 gFormRepostDecisionInstance->Reply(true);
819 gFormRepostDecisionInstance = nullptr;
824 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
826 ToolkitTestApplication application;
828 WebView view = WebView::New();
829 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
830 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
831 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
832 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
833 application.GetScene().Add( view );
834 application.SendNotification();
835 application.Render();
836 DALI_TEST_CHECK( view );
838 ConnectionTracker* testTracker = new ConnectionTracker();
839 view.CertificateConfirmSignal().Connect(&OnCertificateConfirm);
840 view.SslCertificateChangedSignal().Connect(&OnSslCertificateChanged);
841 view.HttpAuthHandlerSignal().Connect(&OnHttpAuthHandler);
842 bool signal1 = false;
843 bool signal2 = false;
844 bool signal3 = false;
845 view.ConnectSignal( testTracker, "certificateConfirm", CallbackFunctor(&signal1) );
846 view.ConnectSignal( testTracker, "sslCertificateChanged", CallbackFunctor(&signal2) );
847 view.ConnectSignal( testTracker, "httpAuthRequest", CallbackFunctor(&signal3) );
848 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
849 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
850 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
852 view.LoadUrl( TEST_URL1 );
853 Test::EmitGlobalTimerSignal();
854 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
855 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
856 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
857 DALI_TEST_CHECK( signal1 & signal2 & signal3);
860 DALI_TEST_CHECK(gCertificateConfirmInstance);
861 gCertificateConfirmInstance->Allow(true);
862 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
864 DALI_TEST_CHECK(gSslCertificateInstance);
865 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
866 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
868 // http authentication.
869 DALI_TEST_CHECK(gHttpAuthInstance);
870 gHttpAuthInstance->Suspend();
871 gHttpAuthInstance->UseCredential("", "");
872 gHttpAuthInstance->CancelCredential();
873 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
876 gCertificateConfirmInstance = nullptr;
877 gSslCertificateInstance = nullptr;
878 gHttpAuthInstance = nullptr;
883 int UtcDaliWebViewGetWebBackForwardList(void)
885 ToolkitTestApplication application;
887 WebView view = WebView::New();
888 DALI_TEST_CHECK( view );
890 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
891 DALI_TEST_CHECK( bfList != 0 );
896 int UtcDaliWebViewGetWebContext(void)
898 ToolkitTestApplication application;
900 WebView view = WebView::New();
901 DALI_TEST_CHECK( view );
903 Dali::Toolkit::WebContext* context = view.GetContext();
904 DALI_TEST_CHECK( context != 0 );
909 int UtcDaliWebViewGetWebCookieManager(void)
911 ToolkitTestApplication application;
913 WebView view = WebView::New();
914 DALI_TEST_CHECK( view );
916 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
917 DALI_TEST_CHECK( cookieManager != 0 );
922 int UtcDaliWebViewGetWebSettings(void)
924 ToolkitTestApplication application;
926 WebView view = WebView::New();
927 DALI_TEST_CHECK( view );
929 Dali::Toolkit::WebSettings* settings = view.GetSettings();
930 DALI_TEST_CHECK( settings != 0 );
935 int UtcDaliWebViewProperty1(void)
938 ToolkitTestApplication application;
940 WebView view = WebView::New();
941 DALI_TEST_CHECK( view );
944 view.SetProperty( WebView::Property::URL, TEST_URL1 );
945 Property::Value val = view.GetProperty( WebView::Property::URL );
946 DALI_TEST_CHECK( val.Get( local ) );
947 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
952 int UtcDaliWebViewProperty4(void)
955 ToolkitTestApplication application;
957 WebView view = WebView::New();
958 DALI_TEST_CHECK( view );
960 const std::string kDefaultValue;
961 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";
963 // Check default value
965 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
966 DALI_TEST_CHECK( value.Get( output ) );
967 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
969 // Check Set/GetProperty
970 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
971 value = view.GetProperty( WebView::Property::USER_AGENT );
972 DALI_TEST_CHECK( value.Get( output ) );
973 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
978 int UtcDaliWebViewProperty9(void)
981 ToolkitTestApplication application;
983 WebView view = WebView::New();
984 DALI_TEST_CHECK( view );
986 // Check default value
987 Dali::Vector2 output = Dali::Vector2::ONE;
988 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
989 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
991 // Check Set/GetProperty
992 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
993 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
994 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
995 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
997 // Check default value of scroll size
998 output = Dali::Vector2::ONE;
999 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
1000 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1002 // Check default value of content size
1003 output = Dali::Vector2::ONE;
1004 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
1005 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1010 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1012 ToolkitTestApplication application;
1014 WebView view = WebView::New();
1015 DALI_TEST_CHECK( view );
1017 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1018 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1019 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1020 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1021 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1023 // Check default value
1024 std::string testText("test");
1026 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1027 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1032 int UtcDaliWebViewPropertyTitleFavicon(void)
1034 ToolkitTestApplication application;
1036 char argv[] = "--test";
1037 WebView view = WebView::New( 1, (char**)&argv );
1038 DALI_TEST_CHECK( view );
1041 view.ClearAllTilesResources();
1043 // Check default value of title
1044 std::string testValue("title");
1046 view.GetProperty( WebView::Property::TITLE ).Get( output );
1047 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1049 // Check default value of favicon
1050 Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
1051 DALI_TEST_CHECK( favicon );
1052 Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1053 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1058 int UtcDaliWebViewContextMenuCustomizedAndItemSelected(void)
1060 ToolkitTestApplication application;
1062 WebView view = WebView::New();
1063 DALI_TEST_CHECK( view );
1066 ConnectionTracker* testTracker = new ConnectionTracker();
1067 view.ContextMenuCustomizedSignal().Connect( &OnContextMenuCustomized );
1068 view.ContextMenuItemSelectedSignal().Connect( &OnContextMenuItemSelected );
1069 bool signal1 = false;
1070 bool signal2 = false;
1071 view.ConnectSignal( testTracker, "contextMenuCustomized", CallbackFunctor(&signal1) );
1072 view.ConnectSignal( testTracker, "contextMenuItemSelected", CallbackFunctor(&signal2) );
1073 DALI_TEST_EQUALS( gContextMenuCustomizedCallbackCalled, 0, TEST_LOCATION );
1074 DALI_TEST_EQUALS( gContextMenuItemSelectedCallbackCalled, 0, TEST_LOCATION );
1075 DALI_TEST_CHECK(gContextMenuInstance == 0);
1076 DALI_TEST_CHECK(gContextMenuItemInstance == 0);
1078 view.LoadUrl( TEST_URL1 );
1079 Test::EmitGlobalTimerSignal();
1080 DALI_TEST_EQUALS( gContextMenuCustomizedCallbackCalled, 1, TEST_LOCATION );
1081 DALI_TEST_EQUALS( gContextMenuItemSelectedCallbackCalled, 1, TEST_LOCATION );
1082 DALI_TEST_CHECK( signal1 );
1083 DALI_TEST_CHECK( signal2 );
1085 // check context meun & its items.
1086 DALI_TEST_CHECK(gContextMenuInstance != 0);
1087 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuInstance->GetItemAt(0);
1088 DALI_TEST_CHECK(item.get() != 0);
1089 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuInstance->GetItemList();
1090 DALI_TEST_CHECK(itemList.size() == 1);
1091 Dali::Vector2 testPosition = Dali::Vector2(100, 100);
1092 DALI_TEST_EQUALS(gContextMenuInstance->GetPosition(), testPosition, TEST_LOCATION);
1093 DALI_TEST_CHECK(gContextMenuInstance->RemoveItem(*(item.get())));
1094 DALI_TEST_CHECK(gContextMenuInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1095 DALI_TEST_CHECK(gContextMenuInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1096 DALI_TEST_CHECK(gContextMenuInstance->SelectItem(*(item.get())));
1097 DALI_TEST_CHECK(gContextMenuInstance->Hide());
1099 DALI_TEST_CHECK(gContextMenuItemInstance != 0);
1100 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1101 DALI_TEST_EQUALS(gContextMenuItemInstance->GetTag(), testItemTag, TEST_LOCATION);
1102 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1103 DALI_TEST_EQUALS(gContextMenuItemInstance->GetType(), testItemType, TEST_LOCATION);
1104 DALI_TEST_CHECK(gContextMenuItemInstance->IsEnabled());
1105 std::string testLinkUrl("http://test.html");
1106 DALI_TEST_EQUALS(gContextMenuItemInstance->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1107 std::string testImageUrl("http://test.jpg");
1108 DALI_TEST_EQUALS(gContextMenuItemInstance->GetImageUrl(), testImageUrl, TEST_LOCATION);
1109 std::string testTitle("title");
1110 DALI_TEST_EQUALS(gContextMenuItemInstance->GetTitle(), testTitle, TEST_LOCATION);
1111 DALI_TEST_CHECK(gContextMenuItemInstance->GetParentMenu().get() == 0);
1113 gContextMenuInstance = nullptr;
1114 gContextMenuItemInstance = nullptr;
1119 int UtcDaliWebViewScrollBy(void)
1121 ToolkitTestApplication application;
1123 WebView view = WebView::New();
1124 DALI_TEST_CHECK( view );
1127 ConnectionTracker* testTracker = new ConnectionTracker();
1128 view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
1129 bool signal1 = false;
1130 view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
1131 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1133 view.LoadUrl( TEST_URL1 );
1134 Test::EmitGlobalTimerSignal();
1136 // set scroll position.
1137 Dali::Vector2 output = Dali::Vector2::ONE;
1138 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1139 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1140 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1141 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1143 // scroll by and trigger scrollEdgeReached event.
1144 view.ScrollBy( 50, 50 );
1145 Test::EmitGlobalTimerSignal();
1147 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1148 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1149 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1150 DALI_TEST_CHECK( signal1 );
1152 // scroll by and trigger scrollEdgeReached event.
1153 bool result = view.ScrollEdgeBy( 50, 50 );
1154 DALI_TEST_CHECK( result );
1155 Test::EmitGlobalTimerSignal();
1157 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1158 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1159 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1160 DALI_TEST_CHECK( signal1 );
1165 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1167 ToolkitTestApplication application;
1169 WebView view = WebView::New();
1170 DALI_TEST_CHECK( view );
1172 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1173 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1174 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1175 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1177 application.GetScene().Add( view );
1178 application.SendNotification();
1179 application.Render();
1181 view.ActivateAccessibility(true);
1182 view.AddDynamicCertificatePath("host", "test/to/path");
1183 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1184 DALI_TEST_CHECK( found );
1186 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1187 float result = view.GetScaleFactor();
1188 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1190 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1191 result = view.GetScaleFactor();
1192 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1197 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1200 ToolkitTestApplication application;
1202 char argv[] = "--test";
1203 WebView view = WebView::New( 1, (char**)&argv );
1204 DALI_TEST_CHECK( view );
1206 // Check GetScreenshot
1207 Dali::Rect<int> viewArea;
1210 viewArea.width = 10;
1211 viewArea.height = 10;
1212 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1213 DALI_TEST_CHECK( screenshot );
1214 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1215 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1217 // Check GetScreenshotAsynchronously
1220 viewArea.width = 100;
1221 viewArea.height = 100;
1222 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1223 DALI_TEST_CHECK( result );
1225 Test::EmitGlobalTimerSignal();
1227 Test::EmitGlobalTimerSignal();
1228 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1233 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1236 ToolkitTestApplication application;
1238 char argv[] = "--test";
1239 WebView view = WebView::New( 1, (char**)&argv );
1240 DALI_TEST_CHECK( view );
1242 // Check CheckVideoPlayingAsynchronously
1243 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1244 DALI_TEST_CHECK( result );
1245 Test::EmitGlobalTimerSignal();
1246 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1248 // Check RegisterGeolocationPermissionCallback
1249 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1250 Test::EmitGlobalTimerSignal();
1251 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1256 int UtcDaliWebViewHttpRequestInterceptor(void)
1258 ToolkitTestApplication application;
1260 WebView view = WebView::New();
1261 DALI_TEST_CHECK( view );
1264 ConnectionTracker* testTracker = new ConnectionTracker();
1265 view.RequestInterceptorSignal().Connect( &OnRequestInterceptor );
1266 bool signal1 = false;
1267 view.ConnectSignal( testTracker, "requestInterceptor", CallbackFunctor(&signal1) );
1268 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1269 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1271 view.LoadUrl( TEST_URL1 );
1272 Test::EmitGlobalTimerSignal();
1273 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1274 DALI_TEST_CHECK( signal1 );
1276 // check request interceptor.
1277 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1278 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1279 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1280 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1281 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1282 std::string testUrl("http://test.html");
1283 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1285 gRequestInterceptorInstance = nullptr;
1290 int UtcDaliWebViewPolicyDecisionRequest(void)
1292 ToolkitTestApplication application;
1294 WebView view = WebView::New();
1295 DALI_TEST_CHECK( view );
1298 ConnectionTracker* testTracker = new ConnectionTracker();
1299 view.PolicyDecisionSignal().Connect( &OnPolicyDecisionRequest );
1300 bool signal1 = false;
1301 view.ConnectSignal( testTracker, "policyDecision", CallbackFunctor(&signal1) );
1302 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 0, TEST_LOCATION );
1303 DALI_TEST_CHECK(gPolicyDecisionInstance == 0);
1305 view.LoadUrl( TEST_URL1 );
1306 Test::EmitGlobalTimerSignal();
1307 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 1, TEST_LOCATION );
1308 DALI_TEST_CHECK( signal1 );
1310 // check policy decision & its frame.
1311 DALI_TEST_CHECK(gPolicyDecisionInstance != 0);
1312 std::string testUrl("http://test.html");
1313 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1314 std::string testCookie("test:abc");
1315 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1316 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1317 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1318 std::string testResponseMime("txt/xml");
1319 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1320 int32_t ResponseStatusCode = 500;
1321 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1322 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1323 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1324 std::string testScheme("test");
1325 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1326 DALI_TEST_CHECK(gPolicyDecisionInstance->Use());
1327 DALI_TEST_CHECK(gPolicyDecisionInstance->Ignore());
1328 DALI_TEST_CHECK(gPolicyDecisionInstance->Suspend());
1330 Dali::WebEngineFrame* webFrame = &(gPolicyDecisionInstance->GetFrame());
1331 DALI_TEST_CHECK(webFrame);
1332 DALI_TEST_CHECK(webFrame->IsMainFrame());
1334 gPolicyDecisionInstance = nullptr;
1339 int UtcDaliWebViewEvaluteJavaScript(void)
1341 ToolkitTestApplication application;
1343 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1345 view.LoadHtmlString( "<body>Hello World!</body>" );
1346 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1347 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1348 Test::EmitGlobalTimerSignal();
1350 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1355 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1357 ToolkitTestApplication application;
1359 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1361 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1362 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1363 view.JavaScriptAlertReply();
1364 Test::EmitGlobalTimerSignal();
1365 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1367 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1368 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1369 view.JavaScriptConfirmReply( true );
1370 Test::EmitGlobalTimerSignal();
1371 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1373 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1374 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1375 view.JavaScriptPromptReply( "it is a prompt." );
1376 Test::EmitGlobalTimerSignal();
1377 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1382 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1384 ToolkitTestApplication application;
1386 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1387 DALI_TEST_CHECK( view );
1389 std::string html("<body>Hello World!</body>");
1390 std::string basicUri("http://basicurl");
1391 std::string unreachableUrl("http://unreachableurl");
1392 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1393 DALI_TEST_CHECK( result );
1395 application.SendNotification();
1396 application.Render();
1397 Test::EmitGlobalTimerSignal();
1399 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1400 DALI_TEST_CHECK( result );
1405 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1407 ToolkitTestApplication application;
1409 WebView view = WebView::New();
1410 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1411 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1412 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1413 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1415 application.GetScene().Add( view );
1416 application.SendNotification();
1417 application.Render();
1418 DALI_TEST_CHECK( view );
1420 view.LoadUrl( "http://test.html" );
1421 bool result = view.AddCustomHeader("key", "value");
1422 DALI_TEST_CHECK( result );
1424 result = view.ReloadWithoutCache();
1425 DALI_TEST_CHECK( result );
1427 uint32_t portNumber = view.StartInspectorServer(5000);
1428 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1430 application.SendNotification();
1431 application.Render();
1432 Test::EmitGlobalTimerSignal();
1434 result = view.StopInspectorServer();
1435 DALI_TEST_CHECK( result );
1437 view.SuspendNetworkLoading();
1439 result = view.RemoveCustomHeader("key");
1440 DALI_TEST_CHECK( result );
1442 view.ResumeNetworkLoading();
1447 int UtcDaliWebViewMethodsForCoverage(void)
1449 ToolkitTestApplication application;
1451 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1453 view.LoadHtmlString( "<body>Hello World!</body>" );
1454 view.AddJavaScriptMessageHandler( "jsObject",
1455 []( const std::string& arg ) {
1459 DALI_TEST_CHECK( view );
1464 // test cases for web backforward list.
1466 int UtcDaliWebBackForwardListCheckItem(void)
1468 ToolkitTestApplication application;
1470 WebView view = WebView::New();
1471 DALI_TEST_CHECK( view );
1473 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1474 DALI_TEST_CHECK( bfList != 0 )
1476 unsigned int itemCount = bfList->GetItemCount();
1477 DALI_TEST_CHECK( itemCount == 1 )
1479 Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
1480 DALI_TEST_CHECK( citem != 0 );
1482 const std::string kDefaultUrl( "http://url" );
1483 std::string testValue = citem->GetUrl();
1484 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1486 const std::string kDefaultTitle( "title" );
1487 testValue = citem->GetTitle();
1488 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1490 const std::string kDefaultOriginalUrl( "http://originalurl" );
1491 testValue = citem->GetOriginalUrl();
1492 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1494 Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
1495 DALI_TEST_CHECK( item != 0 );
1500 // test cases for web context.
1502 int UtcDaliWebContextGetSetCacheModel(void)
1504 ToolkitTestApplication application;
1506 WebView view = WebView::New();
1507 DALI_TEST_CHECK( view );
1509 Dali::Toolkit::WebContext* context = view.GetContext();
1510 DALI_TEST_CHECK( context != 0 )
1512 std::string kDefaultValue;
1515 context->SetProxyUri( kDefaultValue );
1516 context->SetCertificateFilePath( kDefaultValue );
1517 context->DisableCache( false );
1518 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1519 context->DeleteAllWebDatabase();
1520 context->DeleteAllWebStorage();
1521 context->DeleteLocalFileSystem();
1522 context->ClearCache();
1524 // Check default value
1525 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1526 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1528 // Check Set/GetProperty
1529 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1530 value = context->GetCacheModel();
1531 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1536 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1538 ToolkitTestApplication application;
1540 WebView view = WebView::New();
1541 DALI_TEST_CHECK( view );
1543 Dali::Toolkit::WebContext* context = view.GetContext();
1544 DALI_TEST_CHECK( context != 0 )
1546 std::string kDefaultValue;
1548 // get origins of web database
1549 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1550 DALI_TEST_CHECK( result );
1552 Test::EmitGlobalTimerSignal();
1553 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1554 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1556 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1557 DALI_TEST_CHECK( origin );
1559 result = context->DeleteWebDatabase(*origin);
1560 DALI_TEST_CHECK( result );
1562 // get origins of web storage
1563 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1564 DALI_TEST_CHECK( result );
1566 Test::EmitGlobalTimerSignal();
1567 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1568 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1570 origin = gSecurityOriginList[0].get();
1571 DALI_TEST_CHECK( origin );
1573 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1574 DALI_TEST_CHECK( result );
1575 Test::EmitGlobalTimerSignal();
1576 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1578 result = context->DeleteWebStorageOrigin(*origin);
1579 DALI_TEST_CHECK( result );
1581 result = context->DeleteApplicationCache(*origin);
1582 DALI_TEST_CHECK( result );
1584 // form passwords, download state, mime type.
1585 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1586 Test::EmitGlobalTimerSignal();
1587 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1588 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1589 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1590 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1592 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1593 Test::EmitGlobalTimerSignal();
1594 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1596 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1597 Test::EmitGlobalTimerSignal();
1598 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1600 gSecurityOriginList.clear();
1601 gPasswordDataList.clear();
1606 // test cases for web cookie manager.
1608 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1610 ToolkitTestApplication application;
1612 WebView view = WebView::New();
1613 DALI_TEST_CHECK( view );
1615 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1616 DALI_TEST_CHECK( cookieManager != 0 )
1618 const std::string kDefaultValue;
1621 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1622 cookieManager->ClearCookies();
1624 // Check default value
1625 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1626 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1628 // Check Set/GetProperty
1629 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1630 value = cookieManager->GetCookieAcceptPolicy();
1631 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1636 // test cases for web settings.
1638 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1640 ToolkitTestApplication application;
1642 WebView view = WebView::New();
1643 DALI_TEST_CHECK( view );
1645 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1646 DALI_TEST_CHECK( settings != 0 )
1649 settings->AllowMixedContents( false );
1650 settings->EnableSpatialNavigation( false );
1651 settings->EnableWebSecurity( false );
1652 settings->EnableCacheBuilder( false );
1653 settings->EnableDoNotTrack( false );
1654 settings->UseScrollbarThumbFocusNotifications( false );
1655 settings->AllowFileAccessFromExternalUrl( false );
1656 settings->AllowScriptsOpenWindows( false );
1658 // Check default value
1659 int value = settings->GetDefaultFontSize();
1660 DALI_TEST_CHECK( value == 16 );
1662 // Check Set/GetProperty
1663 settings->SetDefaultFontSize( 20 );
1664 value = settings->GetDefaultFontSize();
1665 DALI_TEST_CHECK( value == 20 );
1670 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1672 ToolkitTestApplication application;
1674 WebView view = WebView::New();
1675 DALI_TEST_CHECK( view );
1677 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1678 DALI_TEST_CHECK( settings != 0 )
1681 settings->AllowMixedContents( false );
1682 settings->EnableSpatialNavigation( false );
1683 settings->EnableWebSecurity( false );
1684 settings->EnableCacheBuilder( false );
1685 settings->EnableDoNotTrack( false );
1686 settings->UseScrollbarThumbFocusNotifications( false );
1687 settings->AllowFileAccessFromExternalUrl( false );
1688 settings->AllowScriptsOpenWindows( false );
1690 // Check default value is true or not
1691 bool value = settings->IsJavaScriptEnabled();
1692 DALI_TEST_CHECK( value );
1694 // Check Set/GetProperty
1695 settings->EnableJavaScript( false );
1696 value = settings->IsJavaScriptEnabled();
1697 DALI_TEST_CHECK( !value );
1702 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1704 ToolkitTestApplication application;
1706 WebView view = WebView::New();
1707 DALI_TEST_CHECK( view );
1709 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1710 DALI_TEST_CHECK( settings != 0 )
1713 settings->AllowMixedContents( false );
1714 settings->EnableSpatialNavigation( false );
1715 settings->EnableWebSecurity( false );
1716 settings->EnableCacheBuilder( false );
1717 settings->EnableDoNotTrack( false );
1718 settings->UseScrollbarThumbFocusNotifications( false );
1719 settings->AllowFileAccessFromExternalUrl( false );
1720 settings->AllowScriptsOpenWindows( false );
1722 // Check default value is true or not
1723 bool value = settings->IsAutoFittingEnabled();
1724 DALI_TEST_CHECK( value );
1726 // Check Set/GetProperty
1727 settings->EnableAutoFitting( false );
1728 value = settings->IsAutoFittingEnabled();
1729 DALI_TEST_CHECK( !value );
1734 int UtcDaliWebSettingsCheckEnablePlugins(void)
1736 ToolkitTestApplication application;
1738 WebView view = WebView::New();
1739 DALI_TEST_CHECK( view );
1741 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1742 DALI_TEST_CHECK( settings != 0 )
1745 settings->AllowMixedContents( false );
1746 settings->EnableSpatialNavigation( false );
1747 settings->EnableWebSecurity( false );
1748 settings->EnableCacheBuilder( false );
1749 settings->EnableDoNotTrack( false );
1750 settings->UseScrollbarThumbFocusNotifications( false );
1751 settings->AllowFileAccessFromExternalUrl( false );
1752 settings->AllowScriptsOpenWindows( false );
1754 // Check default value is true or not
1755 bool value = settings->ArePluginsEnabled();
1756 DALI_TEST_CHECK( value );
1758 // Check Set/GetProperty
1759 settings->EnablePlugins( false );
1760 value = settings->ArePluginsEnabled();
1761 DALI_TEST_CHECK( !value );
1766 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1768 ToolkitTestApplication application;
1770 WebView view = WebView::New();
1771 DALI_TEST_CHECK( view );
1773 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1774 DALI_TEST_CHECK( settings != 0 )
1777 settings->AllowMixedContents( false );
1778 settings->EnableSpatialNavigation( false );
1779 settings->EnableWebSecurity( false );
1780 settings->EnableCacheBuilder( false );
1781 settings->EnableDoNotTrack( false );
1782 settings->UseScrollbarThumbFocusNotifications( false );
1783 settings->AllowFileAccessFromExternalUrl( false );
1784 settings->AllowScriptsOpenWindows( false );
1786 // Check default value is true or not
1787 bool value = settings->IsPrivateBrowsingEnabled();
1788 DALI_TEST_CHECK( value );
1790 // Check Set/GetProperty
1791 settings->EnablePrivateBrowsing( false );
1792 value = settings->IsPrivateBrowsingEnabled();
1793 DALI_TEST_CHECK( !value );
1798 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1800 ToolkitTestApplication application;
1802 WebView view = WebView::New();
1803 DALI_TEST_CHECK( view );
1805 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1806 DALI_TEST_CHECK( settings != 0 )
1809 settings->AllowMixedContents( false );
1810 settings->EnableSpatialNavigation( false );
1811 settings->EnableWebSecurity( false );
1812 settings->EnableCacheBuilder( false );
1813 settings->EnableDoNotTrack( false );
1814 settings->UseScrollbarThumbFocusNotifications( false );
1815 settings->AllowFileAccessFromExternalUrl( false );
1816 settings->AllowScriptsOpenWindows( false );
1818 // Check default value is true or not
1819 bool value = settings->IsLinkMagnifierEnabled();
1820 DALI_TEST_CHECK( value );
1822 // Check Set/GetProperty
1823 settings->EnableLinkMagnifier( false );
1824 value = settings->IsLinkMagnifierEnabled();
1825 DALI_TEST_CHECK( !value );
1830 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1832 ToolkitTestApplication application;
1834 WebView view = WebView::New();
1835 DALI_TEST_CHECK( view );
1837 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1838 DALI_TEST_CHECK( settings != 0 )
1841 settings->AllowMixedContents( false );
1842 settings->EnableSpatialNavigation( false );
1843 settings->EnableWebSecurity( false );
1844 settings->EnableCacheBuilder( false );
1845 settings->EnableDoNotTrack( false );
1846 settings->UseScrollbarThumbFocusNotifications( false );
1847 settings->AllowFileAccessFromExternalUrl( false );
1848 settings->AllowScriptsOpenWindows( false );
1850 // Check default value is true or not
1851 bool value = settings->IsKeypadWithoutUserActionUsed();
1852 DALI_TEST_CHECK( value );
1854 // Check Set/GetProperty
1855 settings->UseKeypadWithoutUserAction( false );
1856 value = settings->IsKeypadWithoutUserActionUsed();
1857 DALI_TEST_CHECK( !value );
1862 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1864 ToolkitTestApplication application;
1866 WebView view = WebView::New();
1867 DALI_TEST_CHECK( view );
1869 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1870 DALI_TEST_CHECK( settings != 0 )
1873 settings->AllowMixedContents( false );
1874 settings->EnableSpatialNavigation( false );
1875 settings->EnableWebSecurity( false );
1876 settings->EnableCacheBuilder( false );
1877 settings->EnableDoNotTrack( false );
1878 settings->UseScrollbarThumbFocusNotifications( false );
1879 settings->AllowFileAccessFromExternalUrl( false );
1880 settings->AllowScriptsOpenWindows( false );
1882 // Check default value is true or not
1883 bool value = settings->IsAutofillPasswordFormEnabled();
1884 DALI_TEST_CHECK( value );
1885 settings->EnableAutofillPasswordForm( false );
1886 value = settings->IsAutofillPasswordFormEnabled();
1887 DALI_TEST_CHECK( !value );
1891 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1893 ToolkitTestApplication application;
1895 WebView view = WebView::New();
1896 DALI_TEST_CHECK( view );
1898 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1899 DALI_TEST_CHECK( settings != 0 );
1902 settings->AllowMixedContents( false );
1903 settings->EnableSpatialNavigation( false );
1904 settings->EnableWebSecurity( false );
1905 settings->EnableCacheBuilder( false );
1906 settings->EnableDoNotTrack( false );
1907 settings->UseScrollbarThumbFocusNotifications( false );
1908 settings->AllowFileAccessFromExternalUrl( false );
1909 settings->AllowScriptsOpenWindows( false );
1911 // Check default value is true or not
1912 bool value = settings->IsFormCandidateDataEnabled();
1913 DALI_TEST_CHECK( value );
1915 // Check Set/GetProperty
1916 settings->EnableFormCandidateData( false );
1917 value = settings->IsFormCandidateDataEnabled();
1918 DALI_TEST_CHECK( !value );
1923 int UtcDaliWebSettingsCheckEnableTextSelection(void)
1925 ToolkitTestApplication application;
1927 WebView view = WebView::New();
1928 DALI_TEST_CHECK( view );
1930 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1931 DALI_TEST_CHECK( settings != 0 );
1934 settings->AllowMixedContents( false );
1935 settings->EnableSpatialNavigation( false );
1936 settings->EnableWebSecurity( false );
1937 settings->EnableCacheBuilder( false );
1938 settings->EnableDoNotTrack( false );
1939 settings->UseScrollbarThumbFocusNotifications( false );
1940 settings->AllowFileAccessFromExternalUrl( false );
1941 settings->AllowScriptsOpenWindows( false );
1943 // Check default value is true or not
1944 bool value = settings->IsTextSelectionEnabled();
1945 DALI_TEST_CHECK( value );
1947 //Check Set/GetProperty
1948 settings->EnableTextSelection(false);
1949 value = settings->IsTextSelectionEnabled();
1950 DALI_TEST_CHECK( !value );
1955 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
1957 ToolkitTestApplication application;
1959 WebView view = WebView::New();
1960 DALI_TEST_CHECK( view );
1962 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1963 DALI_TEST_CHECK( settings != 0 );
1966 settings->AllowMixedContents( false );
1967 settings->EnableSpatialNavigation( false );
1968 settings->EnableWebSecurity( false );
1969 settings->EnableCacheBuilder( false );
1970 settings->EnableDoNotTrack( false );
1971 settings->UseScrollbarThumbFocusNotifications( false );
1972 settings->AllowFileAccessFromExternalUrl( false );
1973 settings->AllowScriptsOpenWindows( false );
1975 // Check default value is true or not
1976 bool value = settings->IsTextAutosizingEnabled();
1977 DALI_TEST_CHECK( value );
1979 // Check Set/GetProperty
1980 settings->EnableTextAutosizing(false);
1981 value = settings->IsTextAutosizingEnabled();
1982 DALI_TEST_CHECK( !value );
1987 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
1989 ToolkitTestApplication application;
1991 WebView view = WebView::New();
1992 DALI_TEST_CHECK( view );
1994 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1995 DALI_TEST_CHECK( settings != 0 );
1998 settings->AllowMixedContents( false );
1999 settings->EnableSpatialNavigation( false );
2000 settings->EnableWebSecurity( false );
2001 settings->EnableCacheBuilder( false );
2002 settings->EnableDoNotTrack( false );
2003 settings->UseScrollbarThumbFocusNotifications( false );
2004 settings->AllowFileAccessFromExternalUrl( false );
2005 settings->AllowScriptsOpenWindows( false );
2007 // Check default value is true or not
2008 bool value = settings->IsArrowScrollEnabled();
2009 DALI_TEST_CHECK( value );
2011 // Check Set/GetProperty
2012 settings->EnableArrowScroll(false);
2013 value = settings->IsArrowScrollEnabled();
2014 DALI_TEST_CHECK( !value );
2019 int UtcDaliWebSettingsCheckEnableClipboard(void)
2021 ToolkitTestApplication application;
2023 WebView view = WebView::New();
2024 DALI_TEST_CHECK( view );
2026 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2027 DALI_TEST_CHECK( settings != 0 );
2030 settings->AllowMixedContents( false );
2031 settings->EnableSpatialNavigation( false );
2032 settings->EnableWebSecurity( false );
2033 settings->EnableCacheBuilder( false );
2034 settings->EnableDoNotTrack( false );
2035 settings->UseScrollbarThumbFocusNotifications( false );
2036 settings->AllowFileAccessFromExternalUrl( false );
2037 settings->AllowScriptsOpenWindows( false );
2039 // Check default value is true or not
2040 bool value = settings->IsClipboardEnabled();
2041 DALI_TEST_CHECK( value );
2042 settings->EnableClipboard(false);
2043 value = settings->IsClipboardEnabled();
2044 DALI_TEST_CHECK( !value );
2048 int UtcDaliWebSettingsCheckEnableImePanel(void)
2050 ToolkitTestApplication application;
2052 WebView view = WebView::New();
2053 DALI_TEST_CHECK( view );
2055 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2056 DALI_TEST_CHECK( settings != 0 );
2059 settings->AllowMixedContents( false );
2060 settings->EnableSpatialNavigation( false );
2061 settings->EnableWebSecurity( false );
2062 settings->EnableCacheBuilder( false );
2063 settings->EnableDoNotTrack( false );
2064 settings->UseScrollbarThumbFocusNotifications( false );
2065 settings->AllowFileAccessFromExternalUrl( false );
2066 settings->AllowScriptsOpenWindows( false );
2068 // Check default value is true or not
2069 bool value = settings->IsImePanelEnabled();
2070 DALI_TEST_CHECK( value );
2072 // Check Set/GetProperty
2073 settings->EnableImePanel(false);
2074 value = settings->IsImePanelEnabled();
2075 DALI_TEST_CHECK( !value );
2080 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2082 ToolkitTestApplication application;
2084 WebView view = WebView::New();
2085 DALI_TEST_CHECK( view );
2087 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2088 DALI_TEST_CHECK( settings != 0 )
2091 settings->AllowMixedContents( false );
2092 settings->EnableSpatialNavigation( false );
2093 settings->EnableWebSecurity( false );
2094 settings->EnableCacheBuilder( false );
2095 settings->EnableDoNotTrack( false );
2096 settings->UseScrollbarThumbFocusNotifications( false );
2097 settings->AllowFileAccessFromExternalUrl( false );
2098 settings->AllowScriptsOpenWindows( false );
2100 // Check default value is true or not
2101 bool value = settings->AreImagesLoadedAutomatically();
2102 DALI_TEST_CHECK( value );
2104 // Check Set/GetProperty
2105 settings->AllowImagesLoadAutomatically( false );
2106 value = settings->AreImagesLoadedAutomatically();
2107 DALI_TEST_CHECK( !value );
2112 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2114 ToolkitTestApplication application;
2116 WebView view = WebView::New();
2117 DALI_TEST_CHECK( view );
2119 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2120 DALI_TEST_CHECK( settings != 0 )
2122 const std::string kDefaultValue;
2123 const std::string kTestValue = "UTF-8";
2126 settings->AllowMixedContents( false );
2127 settings->EnableSpatialNavigation( false );
2128 settings->EnableWebSecurity( false );
2129 settings->EnableCacheBuilder( false );
2130 settings->EnableDoNotTrack( false );
2131 settings->UseScrollbarThumbFocusNotifications( false );
2132 settings->AllowFileAccessFromExternalUrl( false );
2133 settings->AllowScriptsOpenWindows( false );
2135 // Check default value
2136 std::string value = settings->GetDefaultTextEncodingName();
2137 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2139 // Check Set/GetProperty
2140 settings->SetDefaultTextEncodingName( kTestValue );
2141 value = settings->GetDefaultTextEncodingName();
2142 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );