2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include "dali-toolkit-test-utils/toolkit-timer.h"
25 #include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-frame.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
34 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
35 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
36 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
37 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
38 #include <dali/integration-api/events/hover-event-integ.h>
39 #include <dali/integration-api/events/key-event-integ.h>
40 #include <dali/integration-api/events/touch-event-integ.h>
41 #include <dali/integration-api/events/wheel-event-integ.h>
42 #include <dali/public-api/images/pixel-data.h>
43 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
44 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
45 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
46 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
48 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
49 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
52 using namespace Toolkit;
57 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
58 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
60 static int gPageLoadStartedCallbackCalled = 0;
61 static int gPageLoadInProgressCallbackCalled = 0;
62 static int gPageLoadFinishedCallbackCalled = 0;
63 static int gPageLoadErrorCallbackCalled = 0;
64 static std::shared_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
65 static int gScrollEdgeReachedCallbackCalled = 0;
66 static int gUrlChangedCallbackCalled = 0;
67 static int gEvaluateJavaScriptCallbackCalled = 0;
68 static int gJavaScriptAlertCallbackCalled = 0;
69 static int gJavaScriptConfirmCallbackCalled = 0;
70 static int gJavaScriptPromptCallbackCalled = 0;
71 static int gScreenshotCapturedCallbackCalled = 0;
72 static int gVideoPlayingCallbackCalled = 0;
73 static int gGeolocationPermissionCallbackCalled = 0;
74 static bool gTouched = false;
75 static bool gHovered = false;
76 static bool gWheelEventHandled = false;
77 static int gFormRepostDecisionCallbackCalled = 0;
78 static std::shared_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecisionInstance = nullptr;
79 static int gFrameRenderedCallbackCalled = 0;
80 static int gRequestInterceptorCallbackCalled = 0;
81 static std::shared_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
82 static int gConsoleMessageCallbackCalled = 0;
83 static std::shared_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
84 static int 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 = nullptr;
101 static int gContextMenuItemSelectedCallbackCalled = 0;
102 static std::shared_ptr<Dali::WebEngineContextMenuItem> gContextMenuItemInstance = nullptr;
103 static int gHitTestCreatedCallbackCalled = 0;
105 struct CallbackFunctor
107 CallbackFunctor(bool* callbackFlag)
108 : mCallbackFlag( callbackFlag )
114 *mCallbackFlag = true;
119 static void OnPageLoadStarted( WebView view, const std::string& url )
121 gPageLoadStartedCallbackCalled++;
124 static void OnPageLoadInProgress( WebView view, const std::string& url )
126 gPageLoadInProgressCallbackCalled++;
129 static void OnPageLoadFinished( WebView view, const std::string& url )
131 gPageLoadFinishedCallbackCalled++;
134 static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
136 gScrollEdgeReachedCallbackCalled++;
139 static void OnPolicyDecisionRequest(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
141 gPolicyDecisionCallbackCalled++;
142 gPolicyDecisionInstance = std::move(decision);
145 static void OnUrlChanged( WebView view, const std::string& url )
147 gUrlChangedCallbackCalled++;
150 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
152 gHitTestCreatedCallbackCalled++;
156 static void OnPageLoadError(WebView view, std::shared_ptr<Dali::WebEngineLoadError> error)
158 gPageLoadErrorCallbackCalled++;
159 gPageLoadErrorInstance = std::move(error);
162 static void OnEvaluateJavaScript( const std::string& result )
164 gEvaluateJavaScriptCallbackCalled++;
167 static bool OnJavaScriptAlert( const std::string& result )
169 gJavaScriptAlertCallbackCalled++;
173 static bool OnJavaScriptConfirm( const std::string& result )
175 gJavaScriptConfirmCallbackCalled++;
179 static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string& message2 )
181 gJavaScriptPromptCallbackCalled++;
185 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
187 gScreenshotCapturedCallbackCalled++;
190 static void OnVideoPlaying(bool isPlaying)
192 gVideoPlayingCallbackCalled++;
195 static bool OnGeolocationPermission(const std::string&, const std::string&)
197 gGeolocationPermissionCallbackCalled++;
201 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
207 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
213 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheel )
215 gWheelEventHandled = true;
219 static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::WebEngineFormRepostDecision> decision)
221 gFormRepostDecisionCallbackCalled++;
222 gFormRepostDecisionInstance = std::move(decision);
225 static void OnFrameRendered(WebView)
227 gFrameRenderedCallbackCalled++;
230 static void OnRequestInterceptor(WebView view, std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
232 gRequestInterceptorCallbackCalled++;
233 gRequestInterceptorInstance = std::move(interceptor);
236 static void OnConsoleMessage(WebView view, std::shared_ptr<Dali::WebEngineConsoleMessage> message)
238 gConsoleMessageCallbackCalled++;
239 gConsoleMessageInstance = std::move(message);
242 static void OnCertificateConfirm(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
244 gCertificateConfirmCallbackCalled++;
245 gCertificateConfirmInstance = std::move(certificate);
248 static void OnSslCertificateChanged(WebView view, std::shared_ptr<Dali::WebEngineCertificate> certificate )
250 gSslCertificateChangedCallbackCalled++;
251 gSslCertificateInstance = std::move(certificate);
254 static void OnHttpAuthHandler( WebView view, std::shared_ptr<Dali::WebEngineHttpAuthHandler> hander )
256 gHttpAuthHandlerCallbackCalled++;
257 gHttpAuthInstance = std::move(hander);
260 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
262 gSecurityOriginsAcquiredCallbackCalled++;
263 gSecurityOriginList.clear();
264 gSecurityOriginList.swap(origins);
267 static void OnStorageUsageAcquired(uint64_t usage)
269 gStorageUsageAcquiredCallbackCalled++;
272 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
274 gFormPasswordsAcquiredCallbackCalled++;
275 gPasswordDataList.clear();
276 gPasswordDataList.swap(passwords);
279 static void OnDownloadStarted(const std::string& url)
281 gDownloadStartedCallbackCalled++;
284 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
286 gMimeOverriddenCallbackCalled++;
290 static void OnContextMenuCustomized(WebView view, std::shared_ptr<Dali::WebEngineContextMenu> menu)
292 gContextMenuCustomizedCallbackCalled++;
293 gContextMenuInstance = std::move(menu);
296 static void OnContextMenuItemSelected(WebView view, std::shared_ptr<Dali::WebEngineContextMenuItem> item)
298 gContextMenuItemSelectedCallbackCalled++;
299 gContextMenuItemInstance = std::move(item);
304 void web_view_startup(void)
306 test_return_value = TET_UNDEF;
309 void web_view_cleanup(void)
311 test_return_value = TET_PASS;
314 int UtcDaliWebViewBasics(void)
316 ToolkitTestApplication application;
318 // Copy and Assignment Test
319 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
320 WebView view = WebView::New();
321 DALI_TEST_CHECK( view );
323 WebView copy( view );
324 DALI_TEST_CHECK( view == copy );
327 DALI_TEST_CHECK( !assign );
330 DALI_TEST_CHECK( assign == view );
333 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
334 BaseHandle handle(view);
336 WebView view2 = WebView::DownCast( handle );
337 DALI_TEST_CHECK( view );
338 DALI_TEST_CHECK( view2 );
339 DALI_TEST_CHECK( view == view2 );
342 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
343 TypeRegistry typeRegistry = TypeRegistry::Get();
344 DALI_TEST_CHECK( typeRegistry );
346 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
347 DALI_TEST_CHECK( typeInfo );
349 BaseHandle handle2 = typeInfo.CreateInstance();
350 DALI_TEST_CHECK( handle2 );
352 WebView view3 = WebView::DownCast( handle2 );
353 DALI_TEST_CHECK( view3 );
358 int UtcDaliWebViewPageNavigation(void)
360 ToolkitTestApplication application;
362 WebView view = WebView::New();
363 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
364 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
365 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
366 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
367 application.GetScene().Add( view );
368 application.SendNotification();
369 application.Render();
370 DALI_TEST_CHECK( view );
372 ConnectionTracker* testTracker = new ConnectionTracker();
373 view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
374 view.PageLoadInProgressSignal().Connect( &OnPageLoadInProgress );
375 view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
376 view.UrlChangedSignal().Connect( &OnUrlChanged );
377 bool signal1 = false;
378 bool signal2 = false;
379 bool signal3 = false;
380 bool signal4 = false;
381 bool signal5 = false;
382 view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
383 view.ConnectSignal( testTracker, "pageLoadInProgress", CallbackFunctor(&signal2) );
384 view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal3) );
385 view.ConnectSignal( testTracker, "urlChanged", CallbackFunctor(&signal4) );
386 view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal5) );
387 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
388 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
389 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
390 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
392 view.LoadUrl( TEST_URL1 );
393 view.GetNaturalSize();
394 Test::EmitGlobalTimerSignal();
395 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
396 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
397 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
398 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
399 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
400 DALI_TEST_CHECK( signal1 & signal2 & signal3 & signal4 );
401 DALI_TEST_CHECK( !signal5 );
403 view.LoadUrl( TEST_URL2 );
405 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
406 application.SendNotification();
407 application.Render();
408 Test::EmitGlobalTimerSignal();
410 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
411 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
412 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
413 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
414 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
415 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
418 Test::EmitGlobalTimerSignal();
419 DALI_TEST_CHECK( !view.CanGoBack() );
420 DALI_TEST_CHECK( view.CanGoForward() );
423 Test::EmitGlobalTimerSignal();
424 DALI_TEST_CHECK( view.CanGoBack() );
425 DALI_TEST_CHECK( !view.CanGoForward() );
430 Test::EmitGlobalTimerSignal();
431 DALI_TEST_CHECK( !view.CanGoBack() );
432 DALI_TEST_CHECK( !view.CanGoForward() );
437 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
439 ToolkitTestApplication application;
441 WebView view = WebView::New();
442 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
443 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
444 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
445 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
446 application.GetScene().Add( view );
447 application.SendNotification();
448 application.Render();
449 DALI_TEST_CHECK( view );
451 ConnectionTracker* testTracker = new ConnectionTracker();
452 view.PageLoadErrorSignal().Connect( &OnPageLoadError );
453 view.ConsoleMessageSignal().Connect( &OnConsoleMessage );
454 bool signal1 = false;
455 bool signal2 = false;
456 view.ConnectSignal( testTracker, "pageLoadError", CallbackFunctor(&signal1) );
457 view.ConnectSignal( testTracker, "consoleMessage", CallbackFunctor(&signal2) );
458 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
459 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
461 view.LoadUrl( TEST_URL1 );
462 Test::EmitGlobalTimerSignal();
463 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
464 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
465 DALI_TEST_CHECK( signal1 & signal2);
468 DALI_TEST_CHECK(gPageLoadErrorInstance);
469 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
470 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
471 std::string testErrorDescription("This is an error.");
472 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
473 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
476 DALI_TEST_CHECK(gConsoleMessageInstance);
477 std::string testConsoleSource("source");
478 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
479 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
480 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
481 std::string testConsoleText("This is a text.");
482 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
485 gPageLoadErrorInstance = nullptr;
486 gConsoleMessageInstance = nullptr;
491 int UtcDaliWebViewTouchAndKeys(void)
493 ToolkitTestApplication application;
495 WebView view = WebView::New();
496 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
497 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
498 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
499 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
501 application.GetScene().Add( view );
502 application.SendNotification();
503 application.Render();
505 view.GetNaturalSize();
506 view.TouchedSignal().Connect( &OnTouched );
509 Dali::Integration::TouchEvent event;
510 Dali::Integration::Point pointDown, pointUp;
512 event = Dali::Integration::TouchEvent();
513 pointDown.SetState( PointState::DOWN );
514 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
515 event.AddPoint( pointDown );
516 application.ProcessEvent( event );
518 event = Dali::Integration::TouchEvent();
519 pointUp.SetState( PointState::UP );
520 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
521 event.AddPoint( pointUp );
522 application.ProcessEvent( event );
525 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
526 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
527 application.SendNotification();
529 DALI_TEST_CHECK( gTouched );
530 DALI_TEST_CHECK( view );
535 int UtcDaliWebViewFocusGainedAndLost(void)
537 ToolkitTestApplication application;
539 WebView view = WebView::New();
540 DALI_TEST_CHECK( view );
542 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
543 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
544 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
545 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
547 application.GetScene().Add( view );
548 application.SendNotification();
549 application.Render();
551 view.SetKeyInputFocus();
552 DALI_TEST_CHECK( view.HasKeyInputFocus() );
555 view.ClearKeyInputFocus();
556 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
561 int UtcDaliWebViewPropertyPageZoomFactor(void)
563 ToolkitTestApplication application;
565 WebView view = WebView::New();
566 DALI_TEST_CHECK( view );
568 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
569 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
570 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
571 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
573 application.GetScene().Add( view );
574 application.SendNotification();
575 application.Render();
577 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
578 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
579 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
581 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
582 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
583 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
588 int UtcDaliWebViewPropertyTextZoomFactor(void)
590 ToolkitTestApplication application;
592 WebView view = WebView::New();
593 DALI_TEST_CHECK( view );
595 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
596 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
597 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
598 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
600 application.GetScene().Add( view );
601 application.SendNotification();
602 application.Render();
604 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
605 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
606 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
608 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
609 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
610 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
615 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
617 ToolkitTestApplication application;
619 WebView view = WebView::New();
620 DALI_TEST_CHECK( view );
622 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
623 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
624 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
625 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
627 application.GetScene().Add( view );
628 application.SendNotification();
629 application.Render();
631 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
632 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
637 int UtcDaliWebViewMove(void)
639 ToolkitTestApplication application;
641 WebView view = WebView::New();
642 DALI_TEST_CHECK( view );
644 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
645 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
646 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
647 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
649 application.GetScene().Add( view );
650 application.SendNotification();
651 application.Render();
653 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
654 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
655 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
660 int UtcDaliWebViewPropertyVideoHoleEnabled(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::VIDEO_HOLE_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::VIDEO_HOLE_ENABLED, kTestValue );
678 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
679 DALI_TEST_CHECK( value.Get( output ) );
680 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
685 int UtcDaliWebViewPropertyMouseEventsEnabled(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::MOUSE_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::MOUSE_EVENTS_ENABLED, kTestValue );
703 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
704 DALI_TEST_CHECK( value.Get( output ) );
705 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
710 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
712 ToolkitTestApplication application;
714 WebView view = WebView::New();
715 DALI_TEST_CHECK( view );
717 const bool kDefaultValue = true;
718 const bool kTestValue = false;
720 // Check default value
722 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
723 DALI_TEST_CHECK( value.Get( output ) );
724 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
726 // Check Set/GetProperty
727 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
728 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
729 DALI_TEST_CHECK( value.Get( output ) );
730 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
735 int UtcDaliWebViewHoverAndWheel(void)
737 ToolkitTestApplication application;
739 WebView view = WebView::New();
740 DALI_TEST_CHECK( view );
741 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
742 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
743 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
744 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
746 application.GetScene().Add( view );
747 application.SendNotification();
748 application.Render();
750 view.GetNaturalSize();
751 view.HoveredSignal().Connect( &OnHovered );
752 view.WheelEventSignal().Connect( &OnWheelEvent );
755 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
756 Dali::Integration::Point pointDown;
757 pointDown.SetState( PointState::DOWN );
758 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
759 event.AddPoint( pointDown );
760 application.ProcessEvent( event );
762 event = Dali::Integration::HoverEvent();
763 Dali::Integration::Point pointUp;
764 pointUp.SetState( PointState::UP );
765 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
766 event.AddPoint( pointUp );
767 application.ProcessEvent( event );
769 event = Dali::Integration::HoverEvent();
770 Dali::Integration::Point pointMotion;
771 pointUp.SetState( PointState::MOTION );
772 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
773 event.AddPoint( pointMotion );
774 application.ProcessEvent( event );
777 Dali::Integration::WheelEvent wheelEvent;
778 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
779 wheelEvent.direction = 0;
780 wheelEvent.point = Vector2( 20, 20 );
781 wheelEvent.delta = 10;
782 application.ProcessEvent( wheelEvent );
783 application.SendNotification();
785 DALI_TEST_CHECK( gHovered );
786 DALI_TEST_CHECK( gWheelEventHandled );
791 int UtcDaliWebViewFormRepostDecisionFrameRendering(void)
793 ToolkitTestApplication application;
795 WebView view = WebView::New();
796 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
797 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
798 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
799 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
800 application.GetScene().Add( view );
801 application.SendNotification();
802 application.Render();
803 DALI_TEST_CHECK( view );
805 ConnectionTracker* testTracker = new ConnectionTracker();
806 view.FormRepostDecisionSignal().Connect(&OnFormRepostDecision);
807 view.FrameRenderedSignal().Connect(&OnFrameRendered);
808 bool signal1 = false;
809 bool signal2 = false;
810 view.ConnectSignal( testTracker, "formRepostDecision", CallbackFunctor(&signal1) );
811 view.ConnectSignal( testTracker, "frameRendered", CallbackFunctor(&signal2) );
812 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 0, TEST_LOCATION );
813 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
815 view.LoadUrl( TEST_URL1 );
816 Test::EmitGlobalTimerSignal();
817 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 1, TEST_LOCATION );
818 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
819 DALI_TEST_CHECK( signal1 & signal2);
821 // form repost decision.
822 DALI_TEST_CHECK(gFormRepostDecisionInstance);
823 gFormRepostDecisionInstance->Reply(true);
826 gFormRepostDecisionInstance = nullptr;
831 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
833 ToolkitTestApplication application;
835 WebView view = WebView::New();
836 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
837 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
838 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
839 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
840 application.GetScene().Add( view );
841 application.SendNotification();
842 application.Render();
843 DALI_TEST_CHECK( view );
845 ConnectionTracker* testTracker = new ConnectionTracker();
846 view.CertificateConfirmSignal().Connect(&OnCertificateConfirm);
847 view.SslCertificateChangedSignal().Connect(&OnSslCertificateChanged);
848 view.HttpAuthHandlerSignal().Connect(&OnHttpAuthHandler);
849 bool signal1 = false;
850 bool signal2 = false;
851 bool signal3 = false;
852 view.ConnectSignal( testTracker, "certificateConfirm", CallbackFunctor(&signal1) );
853 view.ConnectSignal( testTracker, "sslCertificateChanged", CallbackFunctor(&signal2) );
854 view.ConnectSignal( testTracker, "httpAuthRequest", CallbackFunctor(&signal3) );
855 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
856 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
857 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
859 view.LoadUrl( TEST_URL1 );
860 Test::EmitGlobalTimerSignal();
861 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
862 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
863 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
864 DALI_TEST_CHECK( signal1 & signal2 & signal3);
867 DALI_TEST_CHECK(gCertificateConfirmInstance);
868 gCertificateConfirmInstance->Allow(true);
869 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
871 DALI_TEST_CHECK(gSslCertificateInstance);
872 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
873 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
875 // http authentication.
876 DALI_TEST_CHECK(gHttpAuthInstance);
877 gHttpAuthInstance->Suspend();
878 gHttpAuthInstance->UseCredential("", "");
879 gHttpAuthInstance->CancelCredential();
880 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
883 gCertificateConfirmInstance = nullptr;
884 gSslCertificateInstance = nullptr;
885 gHttpAuthInstance = nullptr;
890 int UtcDaliWebViewGetWebBackForwardList(void)
892 ToolkitTestApplication application;
894 WebView view = WebView::New();
895 DALI_TEST_CHECK( view );
897 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
898 DALI_TEST_CHECK( bfList != 0 );
903 int UtcDaliWebViewGetWebContext(void)
905 ToolkitTestApplication application;
907 WebView view = WebView::New();
908 DALI_TEST_CHECK( view );
910 Dali::Toolkit::WebContext* context = view.GetContext();
911 DALI_TEST_CHECK( context != 0 );
916 int UtcDaliWebViewGetWebCookieManager(void)
918 ToolkitTestApplication application;
920 WebView view = WebView::New();
921 DALI_TEST_CHECK( view );
923 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
924 DALI_TEST_CHECK( cookieManager != 0 );
929 int UtcDaliWebViewGetWebSettings(void)
931 ToolkitTestApplication application;
933 WebView view = WebView::New();
934 DALI_TEST_CHECK( view );
936 Dali::Toolkit::WebSettings* settings = view.GetSettings();
937 DALI_TEST_CHECK( settings != 0 );
942 int UtcDaliWebViewProperty1(void)
945 ToolkitTestApplication application;
947 WebView view = WebView::New();
948 DALI_TEST_CHECK( view );
951 view.SetProperty( WebView::Property::URL, TEST_URL1 );
952 Property::Value val = view.GetProperty( WebView::Property::URL );
953 DALI_TEST_CHECK( val.Get( local ) );
954 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
959 int UtcDaliWebViewProperty4(void)
962 ToolkitTestApplication application;
964 WebView view = WebView::New();
965 DALI_TEST_CHECK( view );
967 const std::string kDefaultValue;
968 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";
970 // Check default value
972 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
973 DALI_TEST_CHECK( value.Get( output ) );
974 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
976 // Check Set/GetProperty
977 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
978 value = view.GetProperty( WebView::Property::USER_AGENT );
979 DALI_TEST_CHECK( value.Get( output ) );
980 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
985 int UtcDaliWebViewProperty9(void)
988 ToolkitTestApplication application;
990 WebView view = WebView::New();
991 DALI_TEST_CHECK( view );
993 // Check default value
994 Dali::Vector2 output = Dali::Vector2::ONE;
995 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
996 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
998 // Check Set/GetProperty
999 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1000 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1001 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1002 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1004 // Check default value of scroll size
1005 output = Dali::Vector2::ONE;
1006 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
1007 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1009 // Check default value of content size
1010 output = Dali::Vector2::ONE;
1011 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
1012 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
1017 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1019 ToolkitTestApplication application;
1021 WebView view = WebView::New();
1022 DALI_TEST_CHECK( view );
1024 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1025 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1026 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1027 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1028 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1030 // Check default value
1031 std::string testText("test");
1033 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1034 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1039 int UtcDaliWebViewPropertyTitleFavicon(void)
1041 ToolkitTestApplication application;
1043 char argv[] = "--test";
1044 WebView view = WebView::New( 1, (char**)&argv );
1045 DALI_TEST_CHECK( view );
1048 view.ClearAllTilesResources();
1050 // Check default value of title
1051 std::string testValue("title");
1053 view.GetProperty( WebView::Property::TITLE ).Get( output );
1054 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1056 // Check default value of favicon
1057 Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
1058 DALI_TEST_CHECK( favicon );
1059 Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1060 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1065 int UtcDaliWebViewContextMenuCustomizedAndItemSelected(void)
1067 ToolkitTestApplication application;
1069 WebView view = WebView::New();
1070 DALI_TEST_CHECK( view );
1073 ConnectionTracker* testTracker = new ConnectionTracker();
1074 view.ContextMenuCustomizedSignal().Connect( &OnContextMenuCustomized );
1075 view.ContextMenuItemSelectedSignal().Connect( &OnContextMenuItemSelected );
1076 bool signal1 = false;
1077 bool signal2 = false;
1078 view.ConnectSignal( testTracker, "contextMenuCustomized", CallbackFunctor(&signal1) );
1079 view.ConnectSignal( testTracker, "contextMenuItemSelected", CallbackFunctor(&signal2) );
1080 DALI_TEST_EQUALS( gContextMenuCustomizedCallbackCalled, 0, TEST_LOCATION );
1081 DALI_TEST_EQUALS( gContextMenuItemSelectedCallbackCalled, 0, TEST_LOCATION );
1082 DALI_TEST_CHECK(gContextMenuInstance == 0);
1083 DALI_TEST_CHECK(gContextMenuItemInstance == 0);
1085 view.LoadUrl( TEST_URL1 );
1086 Test::EmitGlobalTimerSignal();
1087 DALI_TEST_EQUALS( gContextMenuCustomizedCallbackCalled, 1, TEST_LOCATION );
1088 DALI_TEST_EQUALS( gContextMenuItemSelectedCallbackCalled, 1, TEST_LOCATION );
1089 DALI_TEST_CHECK( signal1 );
1090 DALI_TEST_CHECK( signal2 );
1092 // check context meun & its items.
1093 DALI_TEST_CHECK(gContextMenuInstance != 0);
1094 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuInstance->GetItemAt(0);
1095 DALI_TEST_CHECK(item.get() != 0);
1096 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuInstance->GetItemList();
1097 DALI_TEST_CHECK(itemList.size() == 1);
1098 Dali::Vector2 testPosition = Dali::Vector2(100, 100);
1099 DALI_TEST_EQUALS(gContextMenuInstance->GetPosition(), testPosition, TEST_LOCATION);
1100 DALI_TEST_CHECK(gContextMenuInstance->RemoveItem(*(item.get())));
1101 DALI_TEST_CHECK(gContextMenuInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1102 DALI_TEST_CHECK(gContextMenuInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1103 DALI_TEST_CHECK(gContextMenuInstance->SelectItem(*(item.get())));
1104 DALI_TEST_CHECK(gContextMenuInstance->Hide());
1106 DALI_TEST_CHECK(gContextMenuItemInstance != 0);
1107 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1108 DALI_TEST_EQUALS(gContextMenuItemInstance->GetTag(), testItemTag, TEST_LOCATION);
1109 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1110 DALI_TEST_EQUALS(gContextMenuItemInstance->GetType(), testItemType, TEST_LOCATION);
1111 DALI_TEST_CHECK(gContextMenuItemInstance->IsEnabled());
1112 std::string testLinkUrl("http://test.html");
1113 DALI_TEST_EQUALS(gContextMenuItemInstance->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1114 std::string testImageUrl("http://test.jpg");
1115 DALI_TEST_EQUALS(gContextMenuItemInstance->GetImageUrl(), testImageUrl, TEST_LOCATION);
1116 std::string testTitle("title");
1117 DALI_TEST_EQUALS(gContextMenuItemInstance->GetTitle(), testTitle, TEST_LOCATION);
1118 DALI_TEST_CHECK(gContextMenuItemInstance->GetParentMenu().get() == 0);
1120 gContextMenuInstance = nullptr;
1121 gContextMenuItemInstance = nullptr;
1126 int UtcDaliWebViewScrollBy(void)
1128 ToolkitTestApplication application;
1130 WebView view = WebView::New();
1131 DALI_TEST_CHECK( view );
1134 ConnectionTracker* testTracker = new ConnectionTracker();
1135 view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
1136 bool signal1 = false;
1137 view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
1138 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1140 view.LoadUrl( TEST_URL1 );
1141 Test::EmitGlobalTimerSignal();
1143 // set scroll position.
1144 Dali::Vector2 output = Dali::Vector2::ONE;
1145 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1146 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1147 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1148 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1150 // scroll by and trigger scrollEdgeReached event.
1151 view.ScrollBy( 50, 50 );
1152 Test::EmitGlobalTimerSignal();
1154 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1155 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1156 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1157 DALI_TEST_CHECK( signal1 );
1159 // scroll by and trigger scrollEdgeReached event.
1160 bool result = view.ScrollEdgeBy( 50, 50 );
1161 DALI_TEST_CHECK( result );
1162 Test::EmitGlobalTimerSignal();
1164 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1165 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1166 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1167 DALI_TEST_CHECK( signal1 );
1172 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1174 ToolkitTestApplication application;
1176 WebView view = WebView::New();
1177 DALI_TEST_CHECK( view );
1179 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1180 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1181 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1182 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1184 application.GetScene().Add( view );
1185 application.SendNotification();
1186 application.Render();
1188 view.ActivateAccessibility(true);
1189 view.AddDynamicCertificatePath("host", "test/to/path");
1190 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1191 DALI_TEST_CHECK( found );
1193 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1194 float result = view.GetScaleFactor();
1195 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1197 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1198 result = view.GetScaleFactor();
1199 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1204 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1207 ToolkitTestApplication application;
1209 char argv[] = "--test";
1210 WebView view = WebView::New( 1, (char**)&argv );
1211 DALI_TEST_CHECK( view );
1213 // Check GetScreenshot
1214 Dali::Rect<int> viewArea;
1217 viewArea.width = 10;
1218 viewArea.height = 10;
1219 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1220 DALI_TEST_CHECK( screenshot );
1221 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1222 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1224 // Check GetScreenshotAsynchronously
1227 viewArea.width = 100;
1228 viewArea.height = 100;
1229 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1230 DALI_TEST_CHECK( result );
1232 Test::EmitGlobalTimerSignal();
1234 Test::EmitGlobalTimerSignal();
1235 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1240 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1243 ToolkitTestApplication application;
1245 char argv[] = "--test";
1246 WebView view = WebView::New( 1, (char**)&argv );
1247 DALI_TEST_CHECK( view );
1249 // Check CheckVideoPlayingAsynchronously
1250 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1251 DALI_TEST_CHECK( result );
1252 Test::EmitGlobalTimerSignal();
1253 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1255 // Check RegisterGeolocationPermissionCallback
1256 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1257 Test::EmitGlobalTimerSignal();
1258 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1263 int UtcDaliWebViewHttpRequestInterceptor(void)
1265 ToolkitTestApplication application;
1267 WebView view = WebView::New();
1268 DALI_TEST_CHECK( view );
1271 ConnectionTracker* testTracker = new ConnectionTracker();
1272 view.RequestInterceptorSignal().Connect( &OnRequestInterceptor );
1273 bool signal1 = false;
1274 view.ConnectSignal( testTracker, "requestInterceptor", CallbackFunctor(&signal1) );
1275 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1276 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1278 view.LoadUrl( TEST_URL1 );
1279 Test::EmitGlobalTimerSignal();
1280 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1281 DALI_TEST_CHECK( signal1 );
1283 // check request interceptor.
1284 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1285 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1286 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1287 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1288 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1289 std::string testUrl("http://test.html");
1290 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1292 gRequestInterceptorInstance = nullptr;
1297 int UtcDaliWebViewPolicyDecisionRequest(void)
1299 ToolkitTestApplication application;
1301 WebView view = WebView::New();
1302 DALI_TEST_CHECK( view );
1305 ConnectionTracker* testTracker = new ConnectionTracker();
1306 view.PolicyDecisionSignal().Connect( &OnPolicyDecisionRequest );
1307 bool signal1 = false;
1308 view.ConnectSignal( testTracker, "policyDecision", CallbackFunctor(&signal1) );
1309 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 0, TEST_LOCATION );
1310 DALI_TEST_CHECK(gPolicyDecisionInstance == 0);
1312 view.LoadUrl( TEST_URL1 );
1313 Test::EmitGlobalTimerSignal();
1314 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 1, TEST_LOCATION );
1315 DALI_TEST_CHECK( signal1 );
1317 // check policy decision & its frame.
1318 DALI_TEST_CHECK(gPolicyDecisionInstance != 0);
1319 std::string testUrl("http://test.html");
1320 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1321 std::string testCookie("test:abc");
1322 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1323 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1324 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1325 std::string testResponseMime("txt/xml");
1326 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1327 int32_t ResponseStatusCode = 500;
1328 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1329 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1330 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1331 std::string testScheme("test");
1332 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1333 DALI_TEST_CHECK(gPolicyDecisionInstance->Use());
1334 DALI_TEST_CHECK(gPolicyDecisionInstance->Ignore());
1335 DALI_TEST_CHECK(gPolicyDecisionInstance->Suspend());
1337 Dali::WebEngineFrame* webFrame = &(gPolicyDecisionInstance->GetFrame());
1338 DALI_TEST_CHECK(webFrame);
1339 DALI_TEST_CHECK(webFrame->IsMainFrame());
1341 gPolicyDecisionInstance = nullptr;
1346 int UtcDaliWebViewHitTest(void)
1348 ToolkitTestApplication application;
1350 WebView view = WebView::New();
1351 DALI_TEST_CHECK( view );
1354 view.LoadUrl( TEST_URL1 );
1357 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1358 DALI_TEST_CHECK(hitTest != 0);
1359 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1360 std::string testLinkUri("http://test.html");
1361 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1362 std::string testLinkTitle("test");
1363 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1364 std::string testLinkLabel("label");
1365 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1366 std::string testImageUri("http://test.jpg");
1367 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1368 std::string testMediaUri("http://test.mp4");
1369 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1370 std::string testTagName("img");
1371 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1372 std::string testNodeValue("test");
1373 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1374 Dali::Property::Map* testMap = &hitTest->GetAttributes();
1375 DALI_TEST_CHECK(testMap);
1376 std::string testImageFileNameExtension("jpg");
1377 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1378 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1379 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1382 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1383 DALI_TEST_CHECK(result);
1384 Test::EmitGlobalTimerSignal();
1385 DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
1390 int UtcDaliWebViewEvaluteJavaScript(void)
1392 ToolkitTestApplication application;
1394 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1396 view.LoadHtmlString( "<body>Hello World!</body>" );
1397 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1398 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1399 Test::EmitGlobalTimerSignal();
1401 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1406 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1408 ToolkitTestApplication application;
1410 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1412 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1413 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1414 view.JavaScriptAlertReply();
1415 Test::EmitGlobalTimerSignal();
1416 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1418 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1419 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1420 view.JavaScriptConfirmReply( true );
1421 Test::EmitGlobalTimerSignal();
1422 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1424 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1425 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1426 view.JavaScriptPromptReply( "it is a prompt." );
1427 Test::EmitGlobalTimerSignal();
1428 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1433 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1435 ToolkitTestApplication application;
1437 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1438 DALI_TEST_CHECK( view );
1440 std::string html("<body>Hello World!</body>");
1441 std::string basicUri("http://basicurl");
1442 std::string unreachableUrl("http://unreachableurl");
1443 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1444 DALI_TEST_CHECK( result );
1446 application.SendNotification();
1447 application.Render();
1448 Test::EmitGlobalTimerSignal();
1450 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1451 DALI_TEST_CHECK( result );
1456 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1458 ToolkitTestApplication application;
1460 WebView view = WebView::New();
1461 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1462 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1463 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1464 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1466 application.GetScene().Add( view );
1467 application.SendNotification();
1468 application.Render();
1469 DALI_TEST_CHECK( view );
1471 view.LoadUrl( "http://test.html" );
1472 bool result = view.AddCustomHeader("key", "value");
1473 DALI_TEST_CHECK( result );
1475 result = view.ReloadWithoutCache();
1476 DALI_TEST_CHECK( result );
1478 uint32_t portNumber = view.StartInspectorServer(5000);
1479 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1481 application.SendNotification();
1482 application.Render();
1483 Test::EmitGlobalTimerSignal();
1485 result = view.StopInspectorServer();
1486 DALI_TEST_CHECK( result );
1488 view.SuspendNetworkLoading();
1490 result = view.RemoveCustomHeader("key");
1491 DALI_TEST_CHECK( result );
1493 view.ResumeNetworkLoading();
1498 int UtcDaliWebViewMethodsForCoverage(void)
1500 ToolkitTestApplication application;
1502 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1504 view.LoadHtmlString( "<body>Hello World!</body>" );
1505 view.AddJavaScriptMessageHandler( "jsObject",
1506 []( const std::string& arg ) {
1510 DALI_TEST_CHECK( view );
1515 // test cases for web backforward list.
1517 int UtcDaliWebBackForwardListCheckItem(void)
1519 ToolkitTestApplication application;
1521 WebView view = WebView::New();
1522 DALI_TEST_CHECK( view );
1524 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1525 DALI_TEST_CHECK( bfList != 0 )
1527 unsigned int itemCount = bfList->GetItemCount();
1528 DALI_TEST_CHECK( itemCount == 1 )
1530 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1531 DALI_TEST_CHECK( citem != 0 );
1533 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1534 DALI_TEST_CHECK( citemP != 0 );
1536 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1537 DALI_TEST_CHECK( citemN != 0 );
1539 const std::string kDefaultUrl( "http://url" );
1540 std::string testValue = citem->GetUrl();
1541 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1543 const std::string kDefaultTitle( "title" );
1544 testValue = citem->GetTitle();
1545 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1547 const std::string kDefaultOriginalUrl( "http://originalurl" );
1548 testValue = citem->GetOriginalUrl();
1549 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1551 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1552 DALI_TEST_CHECK( item != 0 );
1554 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1555 DALI_TEST_CHECK( vecBack.size() == 1 );
1557 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1558 DALI_TEST_CHECK( vecForward.size() == 1 );
1563 // test cases for web context.
1565 int UtcDaliWebContextGetSetCacheModel(void)
1567 ToolkitTestApplication application;
1569 WebView view = WebView::New();
1570 DALI_TEST_CHECK( view );
1572 Dali::Toolkit::WebContext* context = view.GetContext();
1573 DALI_TEST_CHECK( context != 0 )
1575 std::string kDefaultValue;
1578 context->SetProxyUri( kDefaultValue );
1579 context->SetCertificateFilePath( kDefaultValue );
1580 context->DisableCache( false );
1581 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1582 context->DeleteAllWebDatabase();
1583 context->DeleteAllWebStorage();
1584 context->DeleteLocalFileSystem();
1585 context->ClearCache();
1587 // Check default value
1588 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1589 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1591 // Check Set/GetProperty
1592 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1593 value = context->GetCacheModel();
1594 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1599 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1601 ToolkitTestApplication application;
1603 WebView view = WebView::New();
1604 DALI_TEST_CHECK( view );
1606 Dali::Toolkit::WebContext* context = view.GetContext();
1607 DALI_TEST_CHECK( context != 0 )
1609 std::string kDefaultValue;
1611 // get origins of web database
1612 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1613 DALI_TEST_CHECK( result );
1615 Test::EmitGlobalTimerSignal();
1616 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1617 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1619 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1620 DALI_TEST_CHECK( origin );
1622 result = context->DeleteWebDatabase(*origin);
1623 DALI_TEST_CHECK( result );
1625 // get origins of web storage
1626 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1627 DALI_TEST_CHECK( result );
1629 Test::EmitGlobalTimerSignal();
1630 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1631 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1633 origin = gSecurityOriginList[0].get();
1634 DALI_TEST_CHECK( origin );
1636 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1637 DALI_TEST_CHECK( result );
1638 Test::EmitGlobalTimerSignal();
1639 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1641 result = context->DeleteWebStorageOrigin(*origin);
1642 DALI_TEST_CHECK( result );
1644 result = context->DeleteApplicationCache(*origin);
1645 DALI_TEST_CHECK( result );
1647 // form passwords, download state, mime type.
1648 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1649 Test::EmitGlobalTimerSignal();
1650 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1651 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1652 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1653 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1655 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1656 Test::EmitGlobalTimerSignal();
1657 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1659 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1660 Test::EmitGlobalTimerSignal();
1661 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1663 gSecurityOriginList.clear();
1664 gPasswordDataList.clear();
1669 // test cases for web cookie manager.
1671 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1673 ToolkitTestApplication application;
1675 WebView view = WebView::New();
1676 DALI_TEST_CHECK( view );
1678 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1679 DALI_TEST_CHECK( cookieManager != 0 )
1681 const std::string kDefaultValue;
1684 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1685 cookieManager->ClearCookies();
1687 // Check default value
1688 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1689 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1691 // Check Set/GetProperty
1692 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1693 value = cookieManager->GetCookieAcceptPolicy();
1694 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1699 // test cases for web settings.
1701 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1703 ToolkitTestApplication application;
1705 WebView view = WebView::New();
1706 DALI_TEST_CHECK( view );
1708 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1709 DALI_TEST_CHECK( settings != 0 )
1712 settings->AllowMixedContents( false );
1713 settings->EnableSpatialNavigation( false );
1714 settings->EnableWebSecurity( false );
1715 settings->EnableCacheBuilder( false );
1716 settings->EnableDoNotTrack( false );
1717 settings->UseScrollbarThumbFocusNotifications( false );
1718 settings->AllowFileAccessFromExternalUrl( false );
1719 settings->AllowScriptsOpenWindows( false );
1721 // Check default value
1722 int value = settings->GetDefaultFontSize();
1723 DALI_TEST_CHECK( value == 16 );
1725 // Check Set/GetProperty
1726 settings->SetDefaultFontSize( 20 );
1727 value = settings->GetDefaultFontSize();
1728 DALI_TEST_CHECK( value == 20 );
1733 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1735 ToolkitTestApplication application;
1737 WebView view = WebView::New();
1738 DALI_TEST_CHECK( view );
1740 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1741 DALI_TEST_CHECK( settings != 0 )
1744 settings->AllowMixedContents( false );
1745 settings->EnableSpatialNavigation( false );
1746 settings->EnableWebSecurity( false );
1747 settings->EnableCacheBuilder( false );
1748 settings->EnableDoNotTrack( false );
1749 settings->UseScrollbarThumbFocusNotifications( false );
1750 settings->AllowFileAccessFromExternalUrl( false );
1751 settings->AllowScriptsOpenWindows( false );
1753 // Check default value is true or not
1754 bool value = settings->IsJavaScriptEnabled();
1755 DALI_TEST_CHECK( value );
1757 // Check Set/GetProperty
1758 settings->EnableJavaScript( false );
1759 value = settings->IsJavaScriptEnabled();
1760 DALI_TEST_CHECK( !value );
1765 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1767 ToolkitTestApplication application;
1769 WebView view = WebView::New();
1770 DALI_TEST_CHECK( view );
1772 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1773 DALI_TEST_CHECK( settings != 0 )
1776 settings->AllowMixedContents( false );
1777 settings->EnableSpatialNavigation( false );
1778 settings->EnableWebSecurity( false );
1779 settings->EnableCacheBuilder( false );
1780 settings->EnableDoNotTrack( false );
1781 settings->UseScrollbarThumbFocusNotifications( false );
1782 settings->AllowFileAccessFromExternalUrl( false );
1783 settings->AllowScriptsOpenWindows( false );
1785 // Check default value is true or not
1786 bool value = settings->IsAutoFittingEnabled();
1787 DALI_TEST_CHECK( value );
1789 // Check Set/GetProperty
1790 settings->EnableAutoFitting( false );
1791 value = settings->IsAutoFittingEnabled();
1792 DALI_TEST_CHECK( !value );
1797 int UtcDaliWebSettingsCheckEnablePlugins(void)
1799 ToolkitTestApplication application;
1801 WebView view = WebView::New();
1802 DALI_TEST_CHECK( view );
1804 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1805 DALI_TEST_CHECK( settings != 0 )
1808 settings->AllowMixedContents( false );
1809 settings->EnableSpatialNavigation( false );
1810 settings->EnableWebSecurity( false );
1811 settings->EnableCacheBuilder( false );
1812 settings->EnableDoNotTrack( false );
1813 settings->UseScrollbarThumbFocusNotifications( false );
1814 settings->AllowFileAccessFromExternalUrl( false );
1815 settings->AllowScriptsOpenWindows( false );
1817 // Check default value is true or not
1818 bool value = settings->ArePluginsEnabled();
1819 DALI_TEST_CHECK( value );
1821 // Check Set/GetProperty
1822 settings->EnablePlugins( false );
1823 value = settings->ArePluginsEnabled();
1824 DALI_TEST_CHECK( !value );
1829 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1831 ToolkitTestApplication application;
1833 WebView view = WebView::New();
1834 DALI_TEST_CHECK( view );
1836 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1837 DALI_TEST_CHECK( settings != 0 )
1840 settings->AllowMixedContents( false );
1841 settings->EnableSpatialNavigation( false );
1842 settings->EnableWebSecurity( false );
1843 settings->EnableCacheBuilder( false );
1844 settings->EnableDoNotTrack( false );
1845 settings->UseScrollbarThumbFocusNotifications( false );
1846 settings->AllowFileAccessFromExternalUrl( false );
1847 settings->AllowScriptsOpenWindows( false );
1849 // Check default value is true or not
1850 bool value = settings->IsPrivateBrowsingEnabled();
1851 DALI_TEST_CHECK( value );
1853 // Check Set/GetProperty
1854 settings->EnablePrivateBrowsing( false );
1855 value = settings->IsPrivateBrowsingEnabled();
1856 DALI_TEST_CHECK( !value );
1861 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1863 ToolkitTestApplication application;
1865 WebView view = WebView::New();
1866 DALI_TEST_CHECK( view );
1868 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1869 DALI_TEST_CHECK( settings != 0 )
1872 settings->AllowMixedContents( false );
1873 settings->EnableSpatialNavigation( false );
1874 settings->EnableWebSecurity( false );
1875 settings->EnableCacheBuilder( false );
1876 settings->EnableDoNotTrack( false );
1877 settings->UseScrollbarThumbFocusNotifications( false );
1878 settings->AllowFileAccessFromExternalUrl( false );
1879 settings->AllowScriptsOpenWindows( false );
1881 // Check default value is true or not
1882 bool value = settings->IsLinkMagnifierEnabled();
1883 DALI_TEST_CHECK( value );
1885 // Check Set/GetProperty
1886 settings->EnableLinkMagnifier( false );
1887 value = settings->IsLinkMagnifierEnabled();
1888 DALI_TEST_CHECK( !value );
1893 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1895 ToolkitTestApplication application;
1897 WebView view = WebView::New();
1898 DALI_TEST_CHECK( view );
1900 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1901 DALI_TEST_CHECK( settings != 0 )
1904 settings->AllowMixedContents( false );
1905 settings->EnableSpatialNavigation( false );
1906 settings->EnableWebSecurity( false );
1907 settings->EnableCacheBuilder( false );
1908 settings->EnableDoNotTrack( false );
1909 settings->UseScrollbarThumbFocusNotifications( false );
1910 settings->AllowFileAccessFromExternalUrl( false );
1911 settings->AllowScriptsOpenWindows( false );
1913 // Check default value is true or not
1914 bool value = settings->IsKeypadWithoutUserActionUsed();
1915 DALI_TEST_CHECK( value );
1917 // Check Set/GetProperty
1918 settings->UseKeypadWithoutUserAction( false );
1919 value = settings->IsKeypadWithoutUserActionUsed();
1920 DALI_TEST_CHECK( !value );
1925 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1927 ToolkitTestApplication application;
1929 WebView view = WebView::New();
1930 DALI_TEST_CHECK( view );
1932 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1933 DALI_TEST_CHECK( settings != 0 )
1936 settings->AllowMixedContents( false );
1937 settings->EnableSpatialNavigation( false );
1938 settings->EnableWebSecurity( false );
1939 settings->EnableCacheBuilder( false );
1940 settings->EnableDoNotTrack( false );
1941 settings->UseScrollbarThumbFocusNotifications( false );
1942 settings->AllowFileAccessFromExternalUrl( false );
1943 settings->AllowScriptsOpenWindows( false );
1945 // Check default value is true or not
1946 bool value = settings->IsAutofillPasswordFormEnabled();
1947 DALI_TEST_CHECK( value );
1948 settings->EnableAutofillPasswordForm( false );
1949 value = settings->IsAutofillPasswordFormEnabled();
1950 DALI_TEST_CHECK( !value );
1954 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1956 ToolkitTestApplication application;
1958 WebView view = WebView::New();
1959 DALI_TEST_CHECK( view );
1961 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1962 DALI_TEST_CHECK( settings != 0 );
1965 settings->AllowMixedContents( false );
1966 settings->EnableSpatialNavigation( false );
1967 settings->EnableWebSecurity( false );
1968 settings->EnableCacheBuilder( false );
1969 settings->EnableDoNotTrack( false );
1970 settings->UseScrollbarThumbFocusNotifications( false );
1971 settings->AllowFileAccessFromExternalUrl( false );
1972 settings->AllowScriptsOpenWindows( false );
1974 // Check default value is true or not
1975 bool value = settings->IsFormCandidateDataEnabled();
1976 DALI_TEST_CHECK( value );
1978 // Check Set/GetProperty
1979 settings->EnableFormCandidateData( false );
1980 value = settings->IsFormCandidateDataEnabled();
1981 DALI_TEST_CHECK( !value );
1986 int UtcDaliWebSettingsCheckEnableTextSelection(void)
1988 ToolkitTestApplication application;
1990 WebView view = WebView::New();
1991 DALI_TEST_CHECK( view );
1993 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1994 DALI_TEST_CHECK( settings != 0 );
1997 settings->AllowMixedContents( false );
1998 settings->EnableSpatialNavigation( false );
1999 settings->EnableWebSecurity( false );
2000 settings->EnableCacheBuilder( false );
2001 settings->EnableDoNotTrack( false );
2002 settings->UseScrollbarThumbFocusNotifications( false );
2003 settings->AllowFileAccessFromExternalUrl( false );
2004 settings->AllowScriptsOpenWindows( false );
2006 // Check default value is true or not
2007 bool value = settings->IsTextSelectionEnabled();
2008 DALI_TEST_CHECK( value );
2010 //Check Set/GetProperty
2011 settings->EnableTextSelection(false);
2012 value = settings->IsTextSelectionEnabled();
2013 DALI_TEST_CHECK( !value );
2018 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2020 ToolkitTestApplication application;
2022 WebView view = WebView::New();
2023 DALI_TEST_CHECK( view );
2025 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2026 DALI_TEST_CHECK( settings != 0 );
2029 settings->AllowMixedContents( false );
2030 settings->EnableSpatialNavigation( false );
2031 settings->EnableWebSecurity( false );
2032 settings->EnableCacheBuilder( false );
2033 settings->EnableDoNotTrack( false );
2034 settings->UseScrollbarThumbFocusNotifications( false );
2035 settings->AllowFileAccessFromExternalUrl( false );
2036 settings->AllowScriptsOpenWindows( false );
2038 // Check default value is true or not
2039 bool value = settings->IsTextAutosizingEnabled();
2040 DALI_TEST_CHECK( value );
2042 // Check Set/GetProperty
2043 settings->EnableTextAutosizing(false);
2044 value = settings->IsTextAutosizingEnabled();
2045 DALI_TEST_CHECK( !value );
2050 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2052 ToolkitTestApplication application;
2054 WebView view = WebView::New();
2055 DALI_TEST_CHECK( view );
2057 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2058 DALI_TEST_CHECK( settings != 0 );
2061 settings->AllowMixedContents( false );
2062 settings->EnableSpatialNavigation( false );
2063 settings->EnableWebSecurity( false );
2064 settings->EnableCacheBuilder( false );
2065 settings->EnableDoNotTrack( false );
2066 settings->UseScrollbarThumbFocusNotifications( false );
2067 settings->AllowFileAccessFromExternalUrl( false );
2068 settings->AllowScriptsOpenWindows( false );
2070 // Check default value is true or not
2071 bool value = settings->IsArrowScrollEnabled();
2072 DALI_TEST_CHECK( value );
2074 // Check Set/GetProperty
2075 settings->EnableArrowScroll(false);
2076 value = settings->IsArrowScrollEnabled();
2077 DALI_TEST_CHECK( !value );
2082 int UtcDaliWebSettingsCheckEnableClipboard(void)
2084 ToolkitTestApplication application;
2086 WebView view = WebView::New();
2087 DALI_TEST_CHECK( view );
2089 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2090 DALI_TEST_CHECK( settings != 0 );
2093 settings->AllowMixedContents( false );
2094 settings->EnableSpatialNavigation( false );
2095 settings->EnableWebSecurity( false );
2096 settings->EnableCacheBuilder( false );
2097 settings->EnableDoNotTrack( false );
2098 settings->UseScrollbarThumbFocusNotifications( false );
2099 settings->AllowFileAccessFromExternalUrl( false );
2100 settings->AllowScriptsOpenWindows( false );
2102 // Check default value is true or not
2103 bool value = settings->IsClipboardEnabled();
2104 DALI_TEST_CHECK( value );
2105 settings->EnableClipboard(false);
2106 value = settings->IsClipboardEnabled();
2107 DALI_TEST_CHECK( !value );
2111 int UtcDaliWebSettingsCheckEnableImePanel(void)
2113 ToolkitTestApplication application;
2115 WebView view = WebView::New();
2116 DALI_TEST_CHECK( view );
2118 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2119 DALI_TEST_CHECK( settings != 0 );
2122 settings->AllowMixedContents( false );
2123 settings->EnableSpatialNavigation( false );
2124 settings->EnableWebSecurity( false );
2125 settings->EnableCacheBuilder( false );
2126 settings->EnableDoNotTrack( false );
2127 settings->UseScrollbarThumbFocusNotifications( false );
2128 settings->AllowFileAccessFromExternalUrl( false );
2129 settings->AllowScriptsOpenWindows( false );
2131 // Check default value is true or not
2132 bool value = settings->IsImePanelEnabled();
2133 DALI_TEST_CHECK( value );
2135 // Check Set/GetProperty
2136 settings->EnableImePanel(false);
2137 value = settings->IsImePanelEnabled();
2138 DALI_TEST_CHECK( !value );
2143 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2145 ToolkitTestApplication application;
2147 WebView view = WebView::New();
2148 DALI_TEST_CHECK( view );
2150 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2151 DALI_TEST_CHECK( settings != 0 )
2154 settings->AllowMixedContents( false );
2155 settings->EnableSpatialNavigation( false );
2156 settings->EnableWebSecurity( false );
2157 settings->EnableCacheBuilder( false );
2158 settings->EnableDoNotTrack( false );
2159 settings->UseScrollbarThumbFocusNotifications( false );
2160 settings->AllowFileAccessFromExternalUrl( false );
2161 settings->AllowScriptsOpenWindows( false );
2163 // Check default value is true or not
2164 bool value = settings->AreImagesLoadedAutomatically();
2165 DALI_TEST_CHECK( value );
2167 // Check Set/GetProperty
2168 settings->AllowImagesLoadAutomatically( false );
2169 value = settings->AreImagesLoadedAutomatically();
2170 DALI_TEST_CHECK( !value );
2175 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2177 ToolkitTestApplication application;
2179 WebView view = WebView::New();
2180 DALI_TEST_CHECK( view );
2182 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2183 DALI_TEST_CHECK( settings != 0 )
2185 const std::string kDefaultValue;
2186 const std::string kTestValue = "UTF-8";
2189 settings->AllowMixedContents( false );
2190 settings->EnableSpatialNavigation( false );
2191 settings->EnableWebSecurity( false );
2192 settings->EnableCacheBuilder( false );
2193 settings->EnableDoNotTrack( false );
2194 settings->UseScrollbarThumbFocusNotifications( false );
2195 settings->AllowFileAccessFromExternalUrl( false );
2196 settings->AllowScriptsOpenWindows( false );
2198 // Check default value
2199 std::string value = settings->GetDefaultTextEncodingName();
2200 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2202 // Check Set/GetProperty
2203 settings->SetDefaultTextEncodingName( kTestValue );
2204 value = settings->GetDefaultTextEncodingName();
2205 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
2210 int UtcDaliWebSettingsSetViewportMetaTag(void)
2212 ToolkitTestApplication application;
2214 WebView view = WebView::New();
2215 DALI_TEST_CHECK( view );
2217 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2218 DALI_TEST_CHECK( settings != 0 )
2220 // Check the value is true or not
2221 bool value = settings->SetViewportMetaTag(true);
2222 DALI_TEST_CHECK( value );
2227 int UtcDaliWebSettingsSetForceZoom(void)
2229 ToolkitTestApplication application;
2231 WebView view = WebView::New();
2232 DALI_TEST_CHECK( view );
2234 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2235 DALI_TEST_CHECK( settings != 0 )
2237 // Check the value is true or not
2238 bool value = settings->SetForceZoom(true);
2239 DALI_TEST_CHECK( value );
2241 value = settings->IsZoomForced();
2242 DALI_TEST_CHECK( value );
2247 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2249 ToolkitTestApplication application;
2251 WebView view = WebView::New();
2252 DALI_TEST_CHECK( view );
2254 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2255 DALI_TEST_CHECK( settings != 0 )
2257 // Check the value is true or not
2258 bool value = settings->SetTextZoomEnabled(true);
2259 DALI_TEST_CHECK( value );
2261 value = settings->IsTextZoomEnabled();
2262 DALI_TEST_CHECK( value );
2267 int UtcDaliWebSettingsSetExtraFeature(void)
2269 ToolkitTestApplication application;
2271 WebView view = WebView::New();
2272 DALI_TEST_CHECK( view );
2274 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2275 DALI_TEST_CHECK( settings != 0 )
2277 // Check the value is true or not
2278 settings->SetExtraFeature("test", true);
2279 bool value = settings->IsExtraFeatureEnabled("test");
2280 DALI_TEST_CHECK( value );