2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include "dali-toolkit-test-utils/toolkit-timer.h"
25 #include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-frame.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
34 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
35 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
36 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
37 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
38 #include <dali/integration-api/events/hover-event-integ.h>
39 #include <dali/integration-api/events/key-event-integ.h>
40 #include <dali/integration-api/events/touch-event-integ.h>
41 #include <dali/integration-api/events/wheel-event-integ.h>
42 #include <dali/public-api/images/pixel-data.h>
43 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
44 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
45 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
46 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
48 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
49 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
52 using namespace Toolkit;
57 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
58 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
60 static int gPageLoadStartedCallbackCalled = 0;
61 static int gPageLoadInProgressCallbackCalled = 0;
62 static int gPageLoadFinishedCallbackCalled = 0;
63 static int gPageLoadErrorCallbackCalled = 0;
64 static std::unique_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
65 static int gScrollEdgeReachedCallbackCalled = 0;
66 static int gUrlChangedCallbackCalled = 0;
67 static int gEvaluateJavaScriptCallbackCalled = 0;
68 static int gJavaScriptAlertCallbackCalled = 0;
69 static int gJavaScriptConfirmCallbackCalled = 0;
70 static int gJavaScriptPromptCallbackCalled = 0;
71 static int gScreenshotCapturedCallbackCalled = 0;
72 static int gVideoPlayingCallbackCalled = 0;
73 static int gGeolocationPermissionCallbackCalled = 0;
74 static bool gTouched = false;
75 static bool gHovered = false;
76 static bool gWheelEventHandled = false;
77 static int gFormRepostDecidedCallbackCalled = 0;
78 static std::unique_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecidedInstance = nullptr;
79 static int gFrameRenderedCallbackCalled = 0;
80 static int gRequestInterceptorCallbackCalled = 0;
81 static std::unique_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
82 static int gConsoleMessageCallbackCalled = 0;
83 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
84 static int gResponsePolicyDecidedCallbackCalled = 0;
85 static std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
86 static int gCertificateConfirmCallbackCalled = 0;
87 static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
88 static int gSslCertificateChangedCallbackCalled = 0;
89 static std::unique_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
90 static int gHttpAuthHandlerCallbackCalled = 0;
91 static std::unique_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
92 static int gSecurityOriginsAcquiredCallbackCalled = 0;
93 static int gStorageUsageAcquiredCallbackCalled = 0;
94 static int gFormPasswordsAcquiredCallbackCalled = 0;
95 static int gDownloadStartedCallbackCalled = 0;
96 static int gMimeOverriddenCallbackCalled = 0;
97 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
98 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
99 static int gContextMenuShownCallbackCalled = 0;
100 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuShownInstance = nullptr;
101 static int gContextMenuHiddenCallbackCalled = 0;
102 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuHiddenInstance = nullptr;
103 static int gHitTestCreatedCallbackCalled = 0;
104 static int gCookieManagerChangsWatchCallbackCalled = 0;
105 static int gPlainTextReceivedCallbackCalled = 0;
107 struct CallbackFunctor
109 CallbackFunctor(bool* callbackFlag)
110 : mCallbackFlag( callbackFlag )
116 *mCallbackFlag = true;
121 static void OnPageLoadStarted(const std::string& url)
123 gPageLoadStartedCallbackCalled++;
126 static void OnPageLoadInProgress(const std::string& url)
128 gPageLoadInProgressCallbackCalled++;
131 static void OnPageLoadFinished(const std::string& url)
133 gPageLoadFinishedCallbackCalled++;
136 static void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
138 gScrollEdgeReachedCallbackCalled++;
141 static void OnResponsePolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
143 gResponsePolicyDecidedCallbackCalled++;
144 gResponsePolicyDecisionInstance = std::move(decision);
147 static void OnUrlChanged(const std::string& url)
149 gUrlChangedCallbackCalled++;
152 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
154 gHitTestCreatedCallbackCalled++;
158 static bool OnPlainTextReceived(const std::string& plainText)
160 gPlainTextReceivedCallbackCalled++;
164 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
166 gPageLoadErrorCallbackCalled++;
167 gPageLoadErrorInstance = std::move(error);
170 static void OnEvaluateJavaScript(const std::string& result)
172 gEvaluateJavaScriptCallbackCalled++;
175 static bool OnJavaScriptAlert(const std::string& result)
177 gJavaScriptAlertCallbackCalled++;
181 static bool OnJavaScriptConfirm(const std::string& result)
183 gJavaScriptConfirmCallbackCalled++;
187 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
189 gJavaScriptPromptCallbackCalled++;
193 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
195 gScreenshotCapturedCallbackCalled++;
198 static void OnVideoPlaying(bool isPlaying)
200 gVideoPlayingCallbackCalled++;
203 static bool OnGeolocationPermission(const std::string&, const std::string&)
205 gGeolocationPermissionCallbackCalled++;
209 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
215 static void OnChangesWatch()
217 gCookieManagerChangsWatchCallbackCalled++;
220 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
226 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
228 gWheelEventHandled = true;
232 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
234 gFormRepostDecidedCallbackCalled++;
235 gFormRepostDecidedInstance = std::move(decision);
238 static void OnFrameRendered()
240 gFrameRenderedCallbackCalled++;
243 static void OnRequestInterceptor(std::unique_ptr<Dali::WebEngineRequestInterceptor> interceptor)
245 gRequestInterceptorCallbackCalled++;
246 gRequestInterceptorInstance = std::move(interceptor);
249 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
251 gConsoleMessageCallbackCalled++;
252 gConsoleMessageInstance = std::move(message);
255 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
257 gCertificateConfirmCallbackCalled++;
258 gCertificateConfirmInstance = std::move(certificate);
261 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
263 gSslCertificateChangedCallbackCalled++;
264 gSslCertificateInstance = std::move(certificate);
267 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
269 gHttpAuthHandlerCallbackCalled++;
270 gHttpAuthInstance = std::move(hander);
273 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
275 gSecurityOriginsAcquiredCallbackCalled++;
276 gSecurityOriginList.clear();
277 gSecurityOriginList.swap(origins);
280 static void OnStorageUsageAcquired(uint64_t usage)
282 gStorageUsageAcquiredCallbackCalled++;
285 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
287 gFormPasswordsAcquiredCallbackCalled++;
288 gPasswordDataList.clear();
289 gPasswordDataList.swap(passwords);
292 static void OnDownloadStarted(const std::string& url)
294 gDownloadStartedCallbackCalled++;
297 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
299 gMimeOverriddenCallbackCalled++;
303 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
305 gContextMenuShownCallbackCalled++;
306 gContextMenuShownInstance = std::move(menu);
309 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
311 gContextMenuHiddenCallbackCalled++;
312 gContextMenuHiddenInstance = std::move(menu);
317 void web_view_startup(void)
319 test_return_value = TET_UNDEF;
322 void web_view_cleanup(void)
324 test_return_value = TET_PASS;
327 int UtcDaliWebViewBasics(void)
329 ToolkitTestApplication application;
331 // Copy and Assignment Test
332 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
333 WebView view = WebView::New();
334 DALI_TEST_CHECK( view );
336 WebView copy( view );
337 DALI_TEST_CHECK( view == copy );
340 DALI_TEST_CHECK( !assign );
343 DALI_TEST_CHECK( assign == view );
346 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
347 BaseHandle handle(view);
349 WebView view2 = WebView::DownCast( handle );
350 DALI_TEST_CHECK( view );
351 DALI_TEST_CHECK( view2 );
352 DALI_TEST_CHECK( view == view2 );
355 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
356 TypeRegistry typeRegistry = TypeRegistry::Get();
357 DALI_TEST_CHECK( typeRegistry );
359 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
360 DALI_TEST_CHECK( typeInfo );
362 BaseHandle handle2 = typeInfo.CreateInstance();
363 DALI_TEST_CHECK( handle2 );
365 WebView view3 = WebView::DownCast( handle2 );
366 DALI_TEST_CHECK( view3 );
371 int UtcDaliWebViewPageNavigation(void)
373 ToolkitTestApplication application;
375 WebView view = WebView::New();
376 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
377 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
378 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
379 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
380 application.GetScene().Add( view );
381 application.SendNotification();
382 application.Render();
383 DALI_TEST_CHECK( view );
385 view.RegisterPageLoadStartedCallback( &OnPageLoadStarted );
386 view.RegisterPageLoadInProgressCallback( &OnPageLoadInProgress );
387 view.RegisterPageLoadFinishedCallback( &OnPageLoadFinished );
388 view.RegisterUrlChangedCallback( &OnUrlChanged );
389 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
390 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
391 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
392 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
394 view.LoadUrl( TEST_URL1 );
395 view.GetNaturalSize();
396 Test::EmitGlobalTimerSignal();
397 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
398 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
399 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
400 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
401 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
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 view.RegisterPageLoadErrorCallback( &OnPageLoadError );
452 view.RegisterConsoleMessageReceivedCallback( &OnConsoleMessage );
453 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
454 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
456 view.LoadUrl( TEST_URL1 );
457 Test::EmitGlobalTimerSignal();
458 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
459 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
462 DALI_TEST_CHECK(gPageLoadErrorInstance);
463 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
464 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
465 std::string testErrorDescription("This is an error.");
466 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
467 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
470 DALI_TEST_CHECK(gConsoleMessageInstance);
471 std::string testConsoleSource("source");
472 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
473 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
474 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
475 std::string testConsoleText("This is a text.");
476 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
479 gPageLoadErrorInstance = nullptr;
480 gConsoleMessageInstance = nullptr;
485 int UtcDaliWebViewTouchAndKeys(void)
487 ToolkitTestApplication application;
489 WebView view = WebView::New();
490 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
491 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
492 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
493 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
495 application.GetScene().Add( view );
496 application.SendNotification();
497 application.Render();
499 view.GetNaturalSize();
500 view.TouchedSignal().Connect( &OnTouched );
503 Dali::Integration::TouchEvent event;
504 Dali::Integration::Point pointDown, pointUp;
506 event = Dali::Integration::TouchEvent();
507 pointDown.SetState( PointState::DOWN );
508 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
509 event.AddPoint( pointDown );
510 application.ProcessEvent( event );
512 event = Dali::Integration::TouchEvent();
513 pointUp.SetState( PointState::UP );
514 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
515 event.AddPoint( pointUp );
516 application.ProcessEvent( event );
519 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
520 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
521 application.SendNotification();
523 DALI_TEST_CHECK( gTouched );
524 DALI_TEST_CHECK( view );
529 int UtcDaliWebViewFocusGainedAndLost(void)
531 ToolkitTestApplication application;
533 WebView view = WebView::New();
534 DALI_TEST_CHECK( view );
536 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
537 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
538 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
539 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
541 application.GetScene().Add( view );
542 application.SendNotification();
543 application.Render();
545 view.SetKeyInputFocus();
546 DALI_TEST_CHECK( view.HasKeyInputFocus() );
549 view.ClearKeyInputFocus();
550 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
555 int UtcDaliWebViewPropertyPageZoomFactor(void)
557 ToolkitTestApplication application;
559 WebView view = WebView::New();
560 DALI_TEST_CHECK( view );
562 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
563 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
564 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
565 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
567 application.GetScene().Add( view );
568 application.SendNotification();
569 application.Render();
571 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
572 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
573 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
575 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
576 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
577 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
582 int UtcDaliWebViewPropertyTextZoomFactor(void)
584 ToolkitTestApplication application;
586 WebView view = WebView::New();
587 DALI_TEST_CHECK( view );
589 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
590 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
591 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
592 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
594 application.GetScene().Add( view );
595 application.SendNotification();
596 application.Render();
598 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
599 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
600 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
602 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
603 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
604 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
609 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
611 ToolkitTestApplication application;
613 WebView view = WebView::New();
614 DALI_TEST_CHECK( view );
616 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
617 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
618 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
619 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
621 application.GetScene().Add( view );
622 application.SendNotification();
623 application.Render();
625 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
626 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
631 int UtcDaliWebViewMove(void)
633 ToolkitTestApplication application;
635 WebView view = WebView::New();
636 DALI_TEST_CHECK( view );
638 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
639 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
640 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
641 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
643 application.GetScene().Add( view );
644 application.SendNotification();
645 application.Render();
647 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
648 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
649 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
654 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
656 ToolkitTestApplication application;
658 WebView view = WebView::New();
659 DALI_TEST_CHECK( view );
661 const bool kDefaultValue = false;
662 const bool kTestValue = true;
664 // Check default value
666 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
667 DALI_TEST_CHECK( value.Get( output ) );
668 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
670 // Check Set/GetProperty
671 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
672 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
673 DALI_TEST_CHECK( value.Get( output ) );
674 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
679 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
681 ToolkitTestApplication application;
683 WebView view = WebView::New();
684 DALI_TEST_CHECK( view );
686 const bool kDefaultValue = true;
687 const bool kTestValue = false;
689 // Check default value
691 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
692 DALI_TEST_CHECK( value.Get( output ) );
693 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
695 // Check Set/GetProperty
696 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
697 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
698 DALI_TEST_CHECK( value.Get( output ) );
699 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
704 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
706 ToolkitTestApplication application;
708 WebView view = WebView::New();
709 DALI_TEST_CHECK( view );
711 const bool kDefaultValue = true;
712 const bool kTestValue = false;
714 // Check default value
716 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
717 DALI_TEST_CHECK( value.Get( output ) );
718 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
720 // Check Set/GetProperty
721 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
722 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
723 DALI_TEST_CHECK( value.Get( output ) );
724 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
729 int UtcDaliWebViewHoverAndWheel(void)
731 ToolkitTestApplication application;
733 WebView view = WebView::New();
734 DALI_TEST_CHECK( view );
735 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
736 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
737 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
738 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
740 application.GetScene().Add( view );
741 application.SendNotification();
742 application.Render();
744 view.GetNaturalSize();
745 view.HoveredSignal().Connect( &OnHovered );
746 view.WheelEventSignal().Connect( &OnWheelEvent );
749 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
750 Dali::Integration::Point pointDown;
751 pointDown.SetState( PointState::DOWN );
752 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
753 event.AddPoint( pointDown );
754 application.ProcessEvent( event );
756 event = Dali::Integration::HoverEvent();
757 Dali::Integration::Point pointUp;
758 pointUp.SetState( PointState::UP );
759 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
760 event.AddPoint( pointUp );
761 application.ProcessEvent( event );
763 event = Dali::Integration::HoverEvent();
764 Dali::Integration::Point pointMotion;
765 pointUp.SetState( PointState::MOTION );
766 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
767 event.AddPoint( pointMotion );
768 application.ProcessEvent( event );
771 Dali::Integration::WheelEvent wheelEvent;
772 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
773 wheelEvent.direction = 0;
774 wheelEvent.point = Vector2( 20, 20 );
775 wheelEvent.delta = 10;
776 application.ProcessEvent( wheelEvent );
777 application.SendNotification();
779 DALI_TEST_CHECK( gHovered );
780 DALI_TEST_CHECK( gWheelEventHandled );
785 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
787 ToolkitTestApplication application;
789 WebView view = WebView::New();
790 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
791 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
792 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
793 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
794 application.GetScene().Add( view );
795 application.SendNotification();
796 application.Render();
797 DALI_TEST_CHECK( view );
799 view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
800 view.RegisterFrameRenderedCallback(&OnFrameRendered);
801 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION );
802 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
804 view.LoadUrl( TEST_URL1 );
805 Test::EmitGlobalTimerSignal();
806 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION );
807 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
809 // form repost decision.
810 DALI_TEST_CHECK(gFormRepostDecidedInstance);
811 gFormRepostDecidedInstance->Reply(true);
814 gFormRepostDecidedInstance = nullptr;
819 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
821 ToolkitTestApplication application;
823 WebView view = WebView::New();
824 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
825 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
826 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
827 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
828 application.GetScene().Add( view );
829 application.SendNotification();
830 application.Render();
831 DALI_TEST_CHECK( view );
833 view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
834 view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
835 view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
836 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
837 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
838 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
840 view.LoadUrl( TEST_URL1 );
841 Test::EmitGlobalTimerSignal();
842 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
843 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
844 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
847 DALI_TEST_CHECK(gCertificateConfirmInstance);
848 gCertificateConfirmInstance->Allow(true);
849 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
851 DALI_TEST_CHECK(gSslCertificateInstance);
852 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
853 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
855 // http authentication.
856 DALI_TEST_CHECK(gHttpAuthInstance);
857 gHttpAuthInstance->Suspend();
858 gHttpAuthInstance->UseCredential("", "");
859 gHttpAuthInstance->CancelCredential();
860 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
863 gCertificateConfirmInstance = nullptr;
864 gSslCertificateInstance = nullptr;
865 gHttpAuthInstance = nullptr;
870 int UtcDaliWebViewGetWebBackForwardList(void)
872 ToolkitTestApplication application;
874 WebView view = WebView::New();
875 DALI_TEST_CHECK( view );
877 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
878 DALI_TEST_CHECK( bfList != 0 );
883 int UtcDaliWebViewGetWebContext(void)
885 ToolkitTestApplication application;
887 WebView view = WebView::New();
888 DALI_TEST_CHECK( view );
890 Dali::Toolkit::WebContext* context = view.GetContext();
891 DALI_TEST_CHECK( context != 0 );
896 int UtcDaliWebViewGetWebCookieManager(void)
898 ToolkitTestApplication application;
900 WebView view = WebView::New();
901 DALI_TEST_CHECK( view );
903 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
904 DALI_TEST_CHECK( cookieManager != 0 );
909 int UtcDaliWebViewGetWebSettings(void)
911 ToolkitTestApplication application;
913 WebView view = WebView::New();
914 DALI_TEST_CHECK( view );
916 Dali::Toolkit::WebSettings* settings = view.GetSettings();
917 DALI_TEST_CHECK( settings != 0 );
922 int UtcDaliWebViewProperty1(void)
925 ToolkitTestApplication application;
927 WebView view = WebView::New();
928 DALI_TEST_CHECK( view );
931 view.SetProperty( WebView::Property::URL, TEST_URL1 );
932 Property::Value val = view.GetProperty( WebView::Property::URL );
933 DALI_TEST_CHECK( val.Get( local ) );
934 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
939 int UtcDaliWebViewProperty4(void)
942 ToolkitTestApplication application;
944 WebView view = WebView::New();
945 DALI_TEST_CHECK( view );
947 const std::string kDefaultValue;
948 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";
950 // Check default value
952 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
953 DALI_TEST_CHECK( value.Get( output ) );
954 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
956 // Check Set/GetProperty
957 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
958 value = view.GetProperty( WebView::Property::USER_AGENT );
959 DALI_TEST_CHECK( value.Get( output ) );
960 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
965 int UtcDaliWebViewProperty9(void)
968 ToolkitTestApplication application;
970 WebView view = WebView::New();
971 DALI_TEST_CHECK( view );
973 // Check default value
974 Dali::Vector2 output = Dali::Vector2::ONE;
975 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
976 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
978 // Check Set/GetProperty
979 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
980 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
981 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
982 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
984 // Check default value of scroll size
985 output = Dali::Vector2::ONE;
986 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
987 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
989 // Check default value of content size
990 output = Dali::Vector2::ONE;
991 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
992 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
997 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
999 ToolkitTestApplication application;
1001 WebView view = WebView::New();
1002 DALI_TEST_CHECK( view );
1004 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1005 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1006 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1007 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1008 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1010 // Check default value
1011 std::string testText("test");
1013 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1014 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1019 int UtcDaliWebViewPropertyTitleFavicon(void)
1021 ToolkitTestApplication application;
1023 char argv[] = "--test";
1024 WebView view = WebView::New( 1, (char**)&argv );
1025 DALI_TEST_CHECK( view );
1028 view.ClearAllTilesResources();
1030 // Check default value of title
1031 std::string testValue("title");
1033 view.GetProperty( WebView::Property::TITLE ).Get( output );
1034 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1036 // Check the case that favicon is not null.
1037 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1038 DALI_TEST_CHECK( favicon );
1039 Dali::Vector3 iconsize = favicon.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1040 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1042 // Check the case that favicon is null.
1043 favicon = view.GetFavicon();
1044 DALI_TEST_CHECK( !favicon );
1049 int UtcDaliWebViewContextMenuShownAndHidden(void)
1051 ToolkitTestApplication application;
1053 WebView view = WebView::New();
1054 DALI_TEST_CHECK( view );
1057 view.RegisterContextMenuShownCallback( &OnContextMenuShown );
1058 view.RegisterContextMenuHiddenCallback( &OnContextMenuHidden );
1059 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 0, TEST_LOCATION );
1060 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION );
1061 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1062 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1064 view.LoadUrl( TEST_URL1 );
1065 Test::EmitGlobalTimerSignal();
1066 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 1, TEST_LOCATION );
1067 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION );
1069 // check context meun & its items.
1070 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1071 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1072 DALI_TEST_CHECK(item.get() != 0);
1073 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1074 DALI_TEST_CHECK(itemList.size() == 1);
1075 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1076 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1077 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1078 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1079 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1081 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1082 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1083 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1084 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1085 DALI_TEST_CHECK(item->IsEnabled());
1086 std::string testLinkUrl("http://test.html");
1087 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1088 std::string testImageUrl("http://test.jpg");
1089 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1090 std::string testTitle("title");
1091 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1092 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1094 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1096 gContextMenuShownInstance = nullptr;
1097 gContextMenuHiddenInstance = nullptr;
1102 int UtcDaliWebViewScrollBy(void)
1104 ToolkitTestApplication application;
1106 WebView view = WebView::New();
1107 DALI_TEST_CHECK( view );
1110 view.RegisterScrollEdgeReachedCallback( &OnScrollEdgeReached );
1111 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1113 view.LoadUrl( TEST_URL1 );
1114 Test::EmitGlobalTimerSignal();
1116 // set scroll position.
1117 Dali::Vector2 output = Dali::Vector2::ONE;
1118 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1119 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1120 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1121 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1123 // scroll by and trigger scrollEdgeReached event.
1124 view.ScrollBy( 50, 50 );
1125 Test::EmitGlobalTimerSignal();
1127 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1128 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1129 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1131 // scroll by and trigger scrollEdgeReached event.
1132 bool result = view.ScrollEdgeBy( 50, 50 );
1133 DALI_TEST_CHECK( result );
1134 Test::EmitGlobalTimerSignal();
1136 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1137 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1138 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1143 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1145 ToolkitTestApplication application;
1147 WebView view = WebView::New();
1148 DALI_TEST_CHECK( view );
1150 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1151 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1152 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1153 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1155 application.GetScene().Add( view );
1156 application.SendNotification();
1157 application.Render();
1159 view.ActivateAccessibility(true);
1160 view.AddDynamicCertificatePath("host", "test/to/path");
1161 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1162 DALI_TEST_CHECK( found );
1164 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1165 float result = view.GetScaleFactor();
1166 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1168 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1169 result = view.GetScaleFactor();
1170 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1175 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1178 ToolkitTestApplication application;
1180 char argv[] = "--test";
1181 WebView view = WebView::New( 1, (char**)&argv );
1182 DALI_TEST_CHECK( view );
1184 // Check GetScreenshot
1185 Dali::Rect<int> viewArea;
1188 viewArea.width = 10;
1189 viewArea.height = 10;
1190 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1191 DALI_TEST_CHECK( screenshot );
1192 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1193 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1195 // Check GetScreenshotAsynchronously
1198 viewArea.width = 100;
1199 viewArea.height = 100;
1200 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1201 DALI_TEST_CHECK( result );
1203 Test::EmitGlobalTimerSignal();
1205 Test::EmitGlobalTimerSignal();
1206 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1211 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1214 ToolkitTestApplication application;
1216 char argv[] = "--test";
1217 WebView view = WebView::New( 1, (char**)&argv );
1218 DALI_TEST_CHECK( view );
1220 // Check CheckVideoPlayingAsynchronously
1221 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1222 DALI_TEST_CHECK( result );
1223 Test::EmitGlobalTimerSignal();
1224 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1226 // Check RegisterGeolocationPermissionCallback
1227 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1228 Test::EmitGlobalTimerSignal();
1229 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1234 int UtcDaliWebViewHttpRequestInterceptor(void)
1236 ToolkitTestApplication application;
1238 WebView view = WebView::New();
1239 DALI_TEST_CHECK( view );
1242 view.RegisterRequestInterceptorCallback( &OnRequestInterceptor );
1243 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1244 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1246 view.LoadUrl( TEST_URL1 );
1247 Test::EmitGlobalTimerSignal();
1248 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1250 // check request interceptor.
1251 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1252 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1253 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1254 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1255 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1256 std::string testUrl("http://test.html");
1257 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1259 gRequestInterceptorInstance = nullptr;
1264 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1266 ToolkitTestApplication application;
1268 WebView view = WebView::New();
1269 DALI_TEST_CHECK( view );
1272 view.RegisterResponsePolicyDecidedCallback( &OnResponsePolicyDecided );
1273 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION );
1274 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1276 view.LoadUrl( TEST_URL1 );
1277 Test::EmitGlobalTimerSignal();
1278 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION );
1280 // check response policy decision & its frame.
1281 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1282 std::string testUrl("http://test.html");
1283 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1284 std::string testCookie("test:abc");
1285 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1286 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1287 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1288 std::string testResponseMime("txt/xml");
1289 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1290 int32_t ResponseStatusCode = 500;
1291 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1292 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1293 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1294 std::string testScheme("test");
1295 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1296 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1297 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1298 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1300 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1301 DALI_TEST_CHECK(webFrame);
1302 DALI_TEST_CHECK(webFrame->IsMainFrame());
1304 gResponsePolicyDecisionInstance = nullptr;
1309 int UtcDaliWebViewHitTest(void)
1311 ToolkitTestApplication application;
1313 WebView view = WebView::New();
1314 DALI_TEST_CHECK( view );
1317 view.LoadUrl( TEST_URL1 );
1320 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1321 DALI_TEST_CHECK(hitTest != 0);
1322 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1323 std::string testLinkUri("http://test.html");
1324 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1325 std::string testLinkTitle("test");
1326 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1327 std::string testLinkLabel("label");
1328 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1329 std::string testImageUri("http://test.jpg");
1330 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1331 std::string testMediaUri("http://test.mp4");
1332 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1333 std::string testTagName("img");
1334 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1335 std::string testNodeValue("test");
1336 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1337 Dali::Property::Map* testMap = &hitTest->GetAttributes();
1338 DALI_TEST_CHECK(testMap);
1339 std::string testImageFileNameExtension("jpg");
1340 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1341 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1342 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1345 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1346 DALI_TEST_CHECK(result);
1347 Test::EmitGlobalTimerSignal();
1348 DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
1353 int UtcDaliWebViewEvaluteJavaScript(void)
1355 ToolkitTestApplication application;
1357 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1359 view.LoadHtmlString( "<body>Hello World!</body>" );
1360 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1361 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1362 Test::EmitGlobalTimerSignal();
1364 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1369 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1371 ToolkitTestApplication application;
1373 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1375 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1376 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1377 view.JavaScriptAlertReply();
1378 Test::EmitGlobalTimerSignal();
1379 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1381 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1382 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1383 view.JavaScriptConfirmReply( true );
1384 Test::EmitGlobalTimerSignal();
1385 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1387 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1388 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1389 view.JavaScriptPromptReply( "it is a prompt." );
1390 Test::EmitGlobalTimerSignal();
1391 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1396 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1398 ToolkitTestApplication application;
1400 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1401 DALI_TEST_CHECK( view );
1403 std::string html("<body>Hello World!</body>");
1404 std::string basicUri("http://basicurl");
1405 std::string unreachableUrl("http://unreachableurl");
1406 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1407 DALI_TEST_CHECK( result );
1409 application.SendNotification();
1410 application.Render();
1411 Test::EmitGlobalTimerSignal();
1413 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1414 DALI_TEST_CHECK( result );
1419 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1421 ToolkitTestApplication application;
1423 WebView view = WebView::New();
1424 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1425 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1426 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1427 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1429 application.GetScene().Add( view );
1430 application.SendNotification();
1431 application.Render();
1432 DALI_TEST_CHECK( view );
1434 view.LoadUrl( "http://test.html" );
1435 bool result = view.AddCustomHeader("key", "value");
1436 DALI_TEST_CHECK( result );
1438 result = view.ReloadWithoutCache();
1439 DALI_TEST_CHECK( result );
1441 uint32_t portNumber = view.StartInspectorServer(5000);
1442 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1444 application.SendNotification();
1445 application.Render();
1446 Test::EmitGlobalTimerSignal();
1448 result = view.StopInspectorServer();
1449 DALI_TEST_CHECK( result );
1451 view.SuspendNetworkLoading();
1453 result = view.RemoveCustomHeader("key");
1454 DALI_TEST_CHECK( result );
1456 view.ResumeNetworkLoading();
1461 int UtcDaliWebViewMethodsForCoverage(void)
1463 ToolkitTestApplication application;
1465 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1467 view.LoadHtmlString( "<body>Hello World!</body>" );
1468 view.AddJavaScriptMessageHandler( "jsObject",
1469 []( const std::string& arg ) {
1472 view.SetTtsFocus(true);
1474 DALI_TEST_CHECK( view );
1479 // test cases for web backforward list.
1481 int UtcDaliWebBackForwardListCheckItem(void)
1483 ToolkitTestApplication application;
1485 WebView view = WebView::New();
1486 DALI_TEST_CHECK( view );
1488 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1489 DALI_TEST_CHECK( bfList != 0 )
1491 unsigned int itemCount = bfList->GetItemCount();
1492 DALI_TEST_CHECK( itemCount == 1 )
1494 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1495 DALI_TEST_CHECK( citem != 0 );
1497 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1498 DALI_TEST_CHECK( citemP != 0 );
1500 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1501 DALI_TEST_CHECK( citemN != 0 );
1503 const std::string kDefaultUrl( "http://url" );
1504 std::string testValue = citem->GetUrl();
1505 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1507 const std::string kDefaultTitle( "title" );
1508 testValue = citem->GetTitle();
1509 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1511 const std::string kDefaultOriginalUrl( "http://originalurl" );
1512 testValue = citem->GetOriginalUrl();
1513 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1515 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1516 DALI_TEST_CHECK( item != 0 );
1518 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1519 DALI_TEST_CHECK( vecBack.size() == 1 );
1521 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1522 DALI_TEST_CHECK( vecForward.size() == 1 );
1527 // test cases for web context.
1529 int UtcDaliWebContextGetSetCacheModel(void)
1531 ToolkitTestApplication application;
1533 WebView view = WebView::New();
1534 DALI_TEST_CHECK( view );
1536 Dali::Toolkit::WebContext* context = view.GetContext();
1537 DALI_TEST_CHECK( context != 0 )
1539 std::string kDefaultValue;
1542 context->SetAppId( "id" );
1543 context->SetApplicationType( Dali::WebEngineContext::ApplicationType::OTHER );
1544 context->SetTimeOffset( 0 );
1545 context->SetTimeZoneOffset( 0, 0 );
1546 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1547 context->DeleteAllWebDatabase();
1548 context->DeleteAllWebStorage();
1549 context->DeleteLocalFileSystem();
1550 context->ClearCache();
1551 context->DeleteAllFormPasswordData();
1552 context->DeleteAllFormCandidateData();
1554 // Check default value
1555 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1556 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1558 // Check Set/GetProperty
1559 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1560 value = context->GetCacheModel();
1561 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1563 // Get cache enabled
1564 context->EnableCache( true );
1565 DALI_TEST_CHECK( context->IsCacheEnabled() );
1568 context->SetCertificateFilePath( "test" );
1569 std::string str = context->GetCertificateFilePath();
1570 DALI_TEST_EQUALS( str, "test", TEST_LOCATION );
1573 DALI_TEST_CHECK( context->SetAppVersion( "test" ) );
1576 std::vector<std::string> temp;
1577 context->RegisterUrlSchemesAsCorsEnabled( temp );
1578 context->RegisterJsPluginMimeTypes( temp );
1579 context->DeleteFormPasswordDataList( temp );
1582 context->SetDefaultZoomFactor( 1.0f );
1583 DALI_TEST_EQUALS( context->GetDefaultZoomFactor(), float( 1.0f ), TEST_LOCATION );
1585 // Delete cache and database
1586 DALI_TEST_CHECK( context->DeleteAllApplicationCache() );
1587 DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() );
1590 context->SetProxyUri( "test" );
1591 DALI_TEST_EQUALS( context->GetProxyUri(), "test", TEST_LOCATION );
1592 context->SetProxyBypassRule("", "test");
1593 DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION );
1596 DALI_TEST_CHECK( context->FreeUnusedMemory() );
1601 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1603 ToolkitTestApplication application;
1605 WebView view = WebView::New();
1606 DALI_TEST_CHECK( view );
1608 Dali::Toolkit::WebContext* context = view.GetContext();
1609 DALI_TEST_CHECK( context != 0 )
1611 std::string kDefaultValue;
1613 // get origins of web database
1614 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1615 DALI_TEST_CHECK( result );
1617 Test::EmitGlobalTimerSignal();
1618 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1619 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1621 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1622 DALI_TEST_CHECK( origin );
1624 result = context->DeleteWebDatabase(*origin);
1625 DALI_TEST_CHECK( result );
1627 // get origins of web storage
1628 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1629 DALI_TEST_CHECK( result );
1631 Test::EmitGlobalTimerSignal();
1632 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1633 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1635 origin = gSecurityOriginList[0].get();
1636 DALI_TEST_CHECK( origin );
1638 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1639 DALI_TEST_CHECK( result );
1640 Test::EmitGlobalTimerSignal();
1641 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1643 result = context->DeleteWebStorage(*origin);
1644 DALI_TEST_CHECK( result );
1646 result = context->DeleteApplicationCache(*origin);
1647 DALI_TEST_CHECK( result );
1649 // form passwords, download state, mime type.
1650 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1651 Test::EmitGlobalTimerSignal();
1652 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1653 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1654 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1655 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1657 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1658 Test::EmitGlobalTimerSignal();
1659 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1661 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1662 Test::EmitGlobalTimerSignal();
1663 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1665 gSecurityOriginList.clear();
1666 gPasswordDataList.clear();
1671 // test cases for web cookie manager.
1673 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1675 ToolkitTestApplication application;
1677 WebView view = WebView::New();
1678 DALI_TEST_CHECK( view );
1680 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1681 DALI_TEST_CHECK( cookieManager != 0 )
1683 const std::string kDefaultValue;
1686 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1687 cookieManager->ClearCookies();
1689 // Check default value
1690 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1691 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1693 // Check Set/GetProperty
1694 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1695 value = cookieManager->GetCookieAcceptPolicy();
1696 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1701 int UtcDaliWebCookieManagerChangesWatch(void)
1703 ToolkitTestApplication application;
1705 WebView view = WebView::New();
1706 DALI_TEST_CHECK( view );
1708 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1709 DALI_TEST_CHECK( cookieManager != 0 )
1711 cookieManager->ChangesWatch(&OnChangesWatch);
1712 Test::EmitGlobalTimerSignal();
1713 DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
1718 // test cases for web settings.
1720 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1722 ToolkitTestApplication application;
1724 WebView view = WebView::New();
1725 DALI_TEST_CHECK( view );
1727 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1728 DALI_TEST_CHECK( settings != 0 )
1731 settings->AllowMixedContents( false );
1732 settings->EnableSpatialNavigation( false );
1733 settings->EnableWebSecurity( false );
1734 settings->EnableCacheBuilder( false );
1735 settings->EnableDoNotTrack( false );
1736 settings->UseScrollbarThumbFocusNotifications( false );
1737 settings->AllowFileAccessFromExternalUrl( false );
1738 settings->AllowScriptsOpenWindows( false );
1740 // Check default value
1741 int value = settings->GetDefaultFontSize();
1742 DALI_TEST_CHECK( value == 16 );
1744 // Check Set/GetProperty
1745 settings->SetDefaultFontSize( 20 );
1746 value = settings->GetDefaultFontSize();
1747 DALI_TEST_CHECK( value == 20 );
1752 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1754 ToolkitTestApplication application;
1756 WebView view = WebView::New();
1757 DALI_TEST_CHECK( view );
1759 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1760 DALI_TEST_CHECK( settings != 0 )
1763 settings->AllowMixedContents( false );
1764 settings->EnableSpatialNavigation( false );
1765 settings->EnableWebSecurity( false );
1766 settings->EnableCacheBuilder( false );
1767 settings->EnableDoNotTrack( false );
1768 settings->UseScrollbarThumbFocusNotifications( false );
1769 settings->AllowFileAccessFromExternalUrl( false );
1770 settings->AllowScriptsOpenWindows( false );
1772 // Check default value is true or not
1773 bool value = settings->IsJavaScriptEnabled();
1774 DALI_TEST_CHECK( value );
1776 // Check Set/GetProperty
1777 settings->EnableJavaScript( false );
1778 value = settings->IsJavaScriptEnabled();
1779 DALI_TEST_CHECK( !value );
1784 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1786 ToolkitTestApplication application;
1788 WebView view = WebView::New();
1789 DALI_TEST_CHECK( view );
1791 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1792 DALI_TEST_CHECK( settings != 0 )
1795 settings->AllowMixedContents( false );
1796 settings->EnableSpatialNavigation( false );
1797 settings->EnableWebSecurity( false );
1798 settings->EnableCacheBuilder( false );
1799 settings->EnableDoNotTrack( false );
1800 settings->UseScrollbarThumbFocusNotifications( false );
1801 settings->AllowFileAccessFromExternalUrl( false );
1802 settings->AllowScriptsOpenWindows( false );
1804 // Check default value is true or not
1805 bool value = settings->IsAutoFittingEnabled();
1806 DALI_TEST_CHECK( value );
1808 // Check Set/GetProperty
1809 settings->EnableAutoFitting( false );
1810 value = settings->IsAutoFittingEnabled();
1811 DALI_TEST_CHECK( !value );
1816 int UtcDaliWebSettingsCheckEnablePlugins(void)
1818 ToolkitTestApplication application;
1820 WebView view = WebView::New();
1821 DALI_TEST_CHECK( view );
1823 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1824 DALI_TEST_CHECK( settings != 0 )
1827 settings->AllowMixedContents( false );
1828 settings->EnableSpatialNavigation( false );
1829 settings->EnableWebSecurity( false );
1830 settings->EnableCacheBuilder( false );
1831 settings->EnableDoNotTrack( false );
1832 settings->UseScrollbarThumbFocusNotifications( false );
1833 settings->AllowFileAccessFromExternalUrl( false );
1834 settings->AllowScriptsOpenWindows( false );
1836 // Check default value is true or not
1837 bool value = settings->ArePluginsEnabled();
1838 DALI_TEST_CHECK( value );
1840 // Check Set/GetProperty
1841 settings->EnablePlugins( false );
1842 value = settings->ArePluginsEnabled();
1843 DALI_TEST_CHECK( !value );
1848 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1850 ToolkitTestApplication application;
1852 WebView view = WebView::New();
1853 DALI_TEST_CHECK( view );
1855 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1856 DALI_TEST_CHECK( settings != 0 )
1859 settings->AllowMixedContents( false );
1860 settings->EnableSpatialNavigation( false );
1861 settings->EnableWebSecurity( false );
1862 settings->EnableCacheBuilder( false );
1863 settings->EnableDoNotTrack( false );
1864 settings->UseScrollbarThumbFocusNotifications( false );
1865 settings->AllowFileAccessFromExternalUrl( false );
1866 settings->AllowScriptsOpenWindows( false );
1868 // Check default value is true or not
1869 bool value = settings->IsPrivateBrowsingEnabled();
1870 DALI_TEST_CHECK( value );
1872 // Check Set/GetProperty
1873 settings->EnablePrivateBrowsing( false );
1874 value = settings->IsPrivateBrowsingEnabled();
1875 DALI_TEST_CHECK( !value );
1880 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1882 ToolkitTestApplication application;
1884 WebView view = WebView::New();
1885 DALI_TEST_CHECK( view );
1887 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1888 DALI_TEST_CHECK( settings != 0 )
1891 settings->AllowMixedContents( false );
1892 settings->EnableSpatialNavigation( false );
1893 settings->EnableWebSecurity( false );
1894 settings->EnableCacheBuilder( false );
1895 settings->EnableDoNotTrack( false );
1896 settings->UseScrollbarThumbFocusNotifications( false );
1897 settings->AllowFileAccessFromExternalUrl( false );
1898 settings->AllowScriptsOpenWindows( false );
1900 // Check default value is true or not
1901 bool value = settings->IsLinkMagnifierEnabled();
1902 DALI_TEST_CHECK( value );
1904 // Check Set/GetProperty
1905 settings->EnableLinkMagnifier( false );
1906 value = settings->IsLinkMagnifierEnabled();
1907 DALI_TEST_CHECK( !value );
1912 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1914 ToolkitTestApplication application;
1916 WebView view = WebView::New();
1917 DALI_TEST_CHECK( view );
1919 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1920 DALI_TEST_CHECK( settings != 0 )
1923 settings->AllowMixedContents( false );
1924 settings->EnableSpatialNavigation( false );
1925 settings->EnableWebSecurity( false );
1926 settings->EnableCacheBuilder( false );
1927 settings->EnableDoNotTrack( false );
1928 settings->UseScrollbarThumbFocusNotifications( false );
1929 settings->AllowFileAccessFromExternalUrl( false );
1930 settings->AllowScriptsOpenWindows( false );
1932 // Check default value is true or not
1933 bool value = settings->IsKeypadWithoutUserActionUsed();
1934 DALI_TEST_CHECK( value );
1936 // Check Set/GetProperty
1937 settings->UseKeypadWithoutUserAction( false );
1938 value = settings->IsKeypadWithoutUserActionUsed();
1939 DALI_TEST_CHECK( !value );
1944 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1946 ToolkitTestApplication application;
1948 WebView view = WebView::New();
1949 DALI_TEST_CHECK( view );
1951 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1952 DALI_TEST_CHECK( settings != 0 )
1955 settings->AllowMixedContents( false );
1956 settings->EnableSpatialNavigation( false );
1957 settings->EnableWebSecurity( false );
1958 settings->EnableCacheBuilder( false );
1959 settings->EnableDoNotTrack( false );
1960 settings->UseScrollbarThumbFocusNotifications( false );
1961 settings->AllowFileAccessFromExternalUrl( false );
1962 settings->AllowScriptsOpenWindows( false );
1964 // Check default value is true or not
1965 bool value = settings->IsAutofillPasswordFormEnabled();
1966 DALI_TEST_CHECK( value );
1967 settings->EnableAutofillPasswordForm( false );
1968 value = settings->IsAutofillPasswordFormEnabled();
1969 DALI_TEST_CHECK( !value );
1973 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1975 ToolkitTestApplication application;
1977 WebView view = WebView::New();
1978 DALI_TEST_CHECK( view );
1980 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1981 DALI_TEST_CHECK( settings != 0 );
1984 settings->AllowMixedContents( false );
1985 settings->EnableSpatialNavigation( false );
1986 settings->EnableWebSecurity( false );
1987 settings->EnableCacheBuilder( false );
1988 settings->EnableDoNotTrack( false );
1989 settings->UseScrollbarThumbFocusNotifications( false );
1990 settings->AllowFileAccessFromExternalUrl( false );
1991 settings->AllowScriptsOpenWindows( false );
1993 // Check default value is true or not
1994 bool value = settings->IsFormCandidateDataEnabled();
1995 DALI_TEST_CHECK( value );
1997 // Check Set/GetProperty
1998 settings->EnableFormCandidateData( false );
1999 value = settings->IsFormCandidateDataEnabled();
2000 DALI_TEST_CHECK( !value );
2005 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2007 ToolkitTestApplication application;
2009 WebView view = WebView::New();
2010 DALI_TEST_CHECK( view );
2012 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2013 DALI_TEST_CHECK( settings != 0 );
2016 settings->AllowMixedContents( false );
2017 settings->EnableSpatialNavigation( false );
2018 settings->EnableWebSecurity( false );
2019 settings->EnableCacheBuilder( false );
2020 settings->EnableDoNotTrack( false );
2021 settings->UseScrollbarThumbFocusNotifications( false );
2022 settings->AllowFileAccessFromExternalUrl( false );
2023 settings->AllowScriptsOpenWindows( false );
2025 // Check default value is true or not
2026 bool value = settings->IsTextSelectionEnabled();
2027 DALI_TEST_CHECK( value );
2029 //Check Set/GetProperty
2030 settings->EnableTextSelection(false);
2031 value = settings->IsTextSelectionEnabled();
2032 DALI_TEST_CHECK( !value );
2037 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2039 ToolkitTestApplication application;
2041 WebView view = WebView::New();
2042 DALI_TEST_CHECK( view );
2044 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2045 DALI_TEST_CHECK( settings != 0 );
2048 settings->AllowMixedContents( false );
2049 settings->EnableSpatialNavigation( false );
2050 settings->EnableWebSecurity( false );
2051 settings->EnableCacheBuilder( false );
2052 settings->EnableDoNotTrack( false );
2053 settings->UseScrollbarThumbFocusNotifications( false );
2054 settings->AllowFileAccessFromExternalUrl( false );
2055 settings->AllowScriptsOpenWindows( false );
2057 // Check default value is true or not
2058 bool value = settings->IsTextAutosizingEnabled();
2059 DALI_TEST_CHECK( value );
2061 // Check Set/GetProperty
2062 settings->EnableTextAutosizing(false);
2063 value = settings->IsTextAutosizingEnabled();
2064 DALI_TEST_CHECK( !value );
2069 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2071 ToolkitTestApplication application;
2073 WebView view = WebView::New();
2074 DALI_TEST_CHECK( view );
2076 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2077 DALI_TEST_CHECK( settings != 0 );
2080 settings->AllowMixedContents( false );
2081 settings->EnableSpatialNavigation( false );
2082 settings->EnableWebSecurity( false );
2083 settings->EnableCacheBuilder( false );
2084 settings->EnableDoNotTrack( false );
2085 settings->UseScrollbarThumbFocusNotifications( false );
2086 settings->AllowFileAccessFromExternalUrl( false );
2087 settings->AllowScriptsOpenWindows( false );
2089 // Check default value is true or not
2090 bool value = settings->IsArrowScrollEnabled();
2091 DALI_TEST_CHECK( value );
2093 // Check Set/GetProperty
2094 settings->EnableArrowScroll(false);
2095 value = settings->IsArrowScrollEnabled();
2096 DALI_TEST_CHECK( !value );
2101 int UtcDaliWebSettingsCheckEnableClipboard(void)
2103 ToolkitTestApplication application;
2105 WebView view = WebView::New();
2106 DALI_TEST_CHECK( view );
2108 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2109 DALI_TEST_CHECK( settings != 0 );
2112 settings->AllowMixedContents( false );
2113 settings->EnableSpatialNavigation( false );
2114 settings->EnableWebSecurity( false );
2115 settings->EnableCacheBuilder( false );
2116 settings->EnableDoNotTrack( false );
2117 settings->UseScrollbarThumbFocusNotifications( false );
2118 settings->AllowFileAccessFromExternalUrl( false );
2119 settings->AllowScriptsOpenWindows( false );
2121 // Check default value is true or not
2122 bool value = settings->IsClipboardEnabled();
2123 DALI_TEST_CHECK( value );
2124 settings->EnableClipboard(false);
2125 value = settings->IsClipboardEnabled();
2126 DALI_TEST_CHECK( !value );
2130 int UtcDaliWebSettingsCheckEnableImePanel(void)
2132 ToolkitTestApplication application;
2134 WebView view = WebView::New();
2135 DALI_TEST_CHECK( view );
2137 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2138 DALI_TEST_CHECK( settings != 0 );
2141 settings->AllowMixedContents( false );
2142 settings->EnableSpatialNavigation( false );
2143 settings->EnableWebSecurity( false );
2144 settings->EnableCacheBuilder( false );
2145 settings->EnableDoNotTrack( false );
2146 settings->UseScrollbarThumbFocusNotifications( false );
2147 settings->AllowFileAccessFromExternalUrl( false );
2148 settings->AllowScriptsOpenWindows( false );
2150 // Check default value is true or not
2151 bool value = settings->IsImePanelEnabled();
2152 DALI_TEST_CHECK( value );
2154 // Check Set/GetProperty
2155 settings->EnableImePanel(false);
2156 value = settings->IsImePanelEnabled();
2157 DALI_TEST_CHECK( !value );
2162 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2164 ToolkitTestApplication application;
2166 WebView view = WebView::New();
2167 DALI_TEST_CHECK( view );
2169 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2170 DALI_TEST_CHECK( settings != 0 )
2173 settings->AllowMixedContents( false );
2174 settings->EnableSpatialNavigation( false );
2175 settings->EnableWebSecurity( false );
2176 settings->EnableCacheBuilder( false );
2177 settings->EnableDoNotTrack( false );
2178 settings->UseScrollbarThumbFocusNotifications( false );
2179 settings->AllowFileAccessFromExternalUrl( false );
2180 settings->AllowScriptsOpenWindows( false );
2182 // Check default value is true or not
2183 bool value = settings->AreImagesLoadedAutomatically();
2184 DALI_TEST_CHECK( value );
2186 // Check Set/GetProperty
2187 settings->AllowImagesLoadAutomatically( false );
2188 value = settings->AreImagesLoadedAutomatically();
2189 DALI_TEST_CHECK( !value );
2194 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2196 ToolkitTestApplication application;
2198 WebView view = WebView::New();
2199 DALI_TEST_CHECK( view );
2201 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2202 DALI_TEST_CHECK( settings != 0 )
2204 const std::string kDefaultValue;
2205 const std::string kTestValue = "UTF-8";
2208 settings->AllowMixedContents( false );
2209 settings->EnableSpatialNavigation( false );
2210 settings->EnableWebSecurity( false );
2211 settings->EnableCacheBuilder( false );
2212 settings->EnableDoNotTrack( false );
2213 settings->UseScrollbarThumbFocusNotifications( false );
2214 settings->AllowFileAccessFromExternalUrl( false );
2215 settings->AllowScriptsOpenWindows( false );
2217 // Check default value
2218 std::string value = settings->GetDefaultTextEncodingName();
2219 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2221 // Check Set/GetProperty
2222 settings->SetDefaultTextEncodingName( kTestValue );
2223 value = settings->GetDefaultTextEncodingName();
2224 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
2229 int UtcDaliWebSettingsSetViewportMetaTag(void)
2231 ToolkitTestApplication application;
2233 WebView view = WebView::New();
2234 DALI_TEST_CHECK( view );
2236 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2237 DALI_TEST_CHECK( settings != 0 )
2239 // Check the value is true or not
2240 bool value = settings->SetViewportMetaTag(true);
2241 DALI_TEST_CHECK( value );
2246 int UtcDaliWebSettingsSetForceZoom(void)
2248 ToolkitTestApplication application;
2250 WebView view = WebView::New();
2251 DALI_TEST_CHECK( view );
2253 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2254 DALI_TEST_CHECK( settings != 0 )
2256 // Check the value is true or not
2257 bool value = settings->SetForceZoom(true);
2258 DALI_TEST_CHECK( value );
2260 value = settings->IsZoomForced();
2261 DALI_TEST_CHECK( value );
2266 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2268 ToolkitTestApplication application;
2270 WebView view = WebView::New();
2271 DALI_TEST_CHECK( view );
2273 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2274 DALI_TEST_CHECK( settings != 0 )
2276 // Check the value is true or not
2277 bool value = settings->SetTextZoomEnabled(true);
2278 DALI_TEST_CHECK( value );
2280 value = settings->IsTextZoomEnabled();
2281 DALI_TEST_CHECK( value );
2286 int UtcDaliWebSettingsSetExtraFeature(void)
2288 ToolkitTestApplication application;
2290 WebView view = WebView::New();
2291 DALI_TEST_CHECK( view );
2293 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2294 DALI_TEST_CHECK( settings != 0 )
2296 // Check the value is true or not
2297 settings->SetExtraFeature("test", true);
2298 bool value = settings->IsExtraFeatureEnabled("test");
2299 DALI_TEST_CHECK( value );
2304 int UtcDaliWebViewGetPlainText(void)
2306 ToolkitTestApplication application;
2308 WebView view = WebView::New();
2309 DALI_TEST_CHECK(view);
2311 view.LoadUrl(TEST_URL1);
2313 view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2314 Test::EmitGlobalTimerSignal();
2315 DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);