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 gConsoleMessageCallbackCalled = 0;
81 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
82 static int gResponsePolicyDecidedCallbackCalled = 0;
83 static std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
84 static int gCertificateConfirmCallbackCalled = 0;
85 static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
86 static int gSslCertificateChangedCallbackCalled = 0;
87 static std::unique_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
88 static int gHttpAuthHandlerCallbackCalled = 0;
89 static std::unique_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
90 static int gSecurityOriginsAcquiredCallbackCalled = 0;
91 static int gStorageUsageAcquiredCallbackCalled = 0;
92 static int gFormPasswordsAcquiredCallbackCalled = 0;
93 static int gDownloadStartedCallbackCalled = 0;
94 static int gMimeOverriddenCallbackCalled = 0;
95 static int gRequestInterceptedCallbackCalled = 0;
96 static Dali::WebEngineRequestInterceptorPtr gRequestInterceptorInstance = nullptr;
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 OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
245 gConsoleMessageCallbackCalled++;
246 gConsoleMessageInstance = std::move(message);
249 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
251 gCertificateConfirmCallbackCalled++;
252 gCertificateConfirmInstance = std::move(certificate);
255 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
257 gSslCertificateChangedCallbackCalled++;
258 gSslCertificateInstance = std::move(certificate);
261 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
263 gHttpAuthHandlerCallbackCalled++;
264 gHttpAuthInstance = std::move(hander);
267 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
269 gSecurityOriginsAcquiredCallbackCalled++;
270 gSecurityOriginList.clear();
271 gSecurityOriginList.swap(origins);
274 static void OnStorageUsageAcquired(uint64_t usage)
276 gStorageUsageAcquiredCallbackCalled++;
279 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
281 gFormPasswordsAcquiredCallbackCalled++;
282 gPasswordDataList.clear();
283 gPasswordDataList.swap(passwords);
286 static void OnDownloadStarted(const std::string& url)
288 gDownloadStartedCallbackCalled++;
291 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
293 gMimeOverriddenCallbackCalled++;
297 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
299 gRequestInterceptedCallbackCalled++;
300 gRequestInterceptorInstance = interceptor;
304 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
306 gContextMenuShownCallbackCalled++;
307 gContextMenuShownInstance = std::move(menu);
310 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
312 gContextMenuHiddenCallbackCalled++;
313 gContextMenuHiddenInstance = std::move(menu);
318 void web_view_startup(void)
320 test_return_value = TET_UNDEF;
323 void web_view_cleanup(void)
325 test_return_value = TET_PASS;
328 int UtcDaliWebViewBasics(void)
330 ToolkitTestApplication application;
332 // Copy and Assignment Test
333 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
334 WebView view = WebView::New();
335 DALI_TEST_CHECK( view );
337 WebView copy( view );
338 DALI_TEST_CHECK( view == copy );
341 DALI_TEST_CHECK( !assign );
344 DALI_TEST_CHECK( assign == view );
347 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
348 BaseHandle handle(view);
350 WebView view2 = WebView::DownCast( handle );
351 DALI_TEST_CHECK( view );
352 DALI_TEST_CHECK( view2 );
353 DALI_TEST_CHECK( view == view2 );
356 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
357 TypeRegistry typeRegistry = TypeRegistry::Get();
358 DALI_TEST_CHECK( typeRegistry );
360 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
361 DALI_TEST_CHECK( typeInfo );
363 BaseHandle handle2 = typeInfo.CreateInstance();
364 DALI_TEST_CHECK( handle2 );
366 WebView view3 = WebView::DownCast( handle2 );
367 DALI_TEST_CHECK( view3 );
372 int UtcDaliWebViewPageNavigation(void)
374 ToolkitTestApplication application;
376 WebView view = WebView::New();
377 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
378 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
379 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
380 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
381 application.GetScene().Add( view );
382 application.SendNotification();
383 application.Render();
384 DALI_TEST_CHECK( view );
386 view.RegisterPageLoadStartedCallback( &OnPageLoadStarted );
387 view.RegisterPageLoadInProgressCallback( &OnPageLoadInProgress );
388 view.RegisterPageLoadFinishedCallback( &OnPageLoadFinished );
389 view.RegisterUrlChangedCallback( &OnUrlChanged );
390 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
391 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
392 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
393 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
395 view.LoadUrl( TEST_URL1 );
396 view.GetNaturalSize();
397 Test::EmitGlobalTimerSignal();
398 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
399 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
400 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
401 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
402 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
404 view.LoadUrl( TEST_URL2 );
406 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
407 application.SendNotification();
408 application.Render();
409 Test::EmitGlobalTimerSignal();
411 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
412 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
413 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
414 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
415 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
416 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
419 Test::EmitGlobalTimerSignal();
420 DALI_TEST_CHECK( !view.CanGoBack() );
421 DALI_TEST_CHECK( view.CanGoForward() );
424 Test::EmitGlobalTimerSignal();
425 DALI_TEST_CHECK( view.CanGoBack() );
426 DALI_TEST_CHECK( !view.CanGoForward() );
431 Test::EmitGlobalTimerSignal();
432 DALI_TEST_CHECK( !view.CanGoBack() );
433 DALI_TEST_CHECK( !view.CanGoForward() );
438 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
440 ToolkitTestApplication application;
442 WebView view = WebView::New();
443 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
444 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
445 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
446 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
447 application.GetScene().Add( view );
448 application.SendNotification();
449 application.Render();
450 DALI_TEST_CHECK( view );
452 view.RegisterPageLoadErrorCallback( &OnPageLoadError );
453 view.RegisterConsoleMessageReceivedCallback( &OnConsoleMessage );
454 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
455 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
457 view.LoadUrl( TEST_URL1 );
458 Test::EmitGlobalTimerSignal();
459 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
460 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
463 DALI_TEST_CHECK(gPageLoadErrorInstance);
464 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
465 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
466 std::string testErrorDescription("This is an error.");
467 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
468 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
471 DALI_TEST_CHECK(gConsoleMessageInstance);
472 std::string testConsoleSource("source");
473 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
474 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
475 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
476 std::string testConsoleText("This is a text.");
477 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
480 gPageLoadErrorInstance = nullptr;
481 gConsoleMessageInstance = nullptr;
486 int UtcDaliWebViewTouchAndKeys(void)
488 ToolkitTestApplication application;
490 WebView view = WebView::New();
491 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
492 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
493 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
494 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
496 application.GetScene().Add( view );
497 application.SendNotification();
498 application.Render();
500 view.GetNaturalSize();
501 view.TouchedSignal().Connect( &OnTouched );
504 Dali::Integration::TouchEvent event;
505 Dali::Integration::Point pointDown, pointUp;
507 event = Dali::Integration::TouchEvent();
508 pointDown.SetState( PointState::DOWN );
509 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
510 event.AddPoint( pointDown );
511 application.ProcessEvent( event );
513 event = Dali::Integration::TouchEvent();
514 pointUp.SetState( PointState::UP );
515 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
516 event.AddPoint( pointUp );
517 application.ProcessEvent( event );
520 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
521 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
522 application.SendNotification();
524 DALI_TEST_CHECK( gTouched );
525 DALI_TEST_CHECK( view );
530 int UtcDaliWebViewFocusGainedAndLost(void)
532 ToolkitTestApplication application;
534 WebView view = WebView::New();
535 DALI_TEST_CHECK( view );
537 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
538 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
539 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
540 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
542 application.GetScene().Add( view );
543 application.SendNotification();
544 application.Render();
546 view.SetKeyInputFocus();
547 DALI_TEST_CHECK( view.HasKeyInputFocus() );
550 view.ClearKeyInputFocus();
551 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
556 int UtcDaliWebViewPropertyPageZoomFactor(void)
558 ToolkitTestApplication application;
560 WebView view = WebView::New();
561 DALI_TEST_CHECK( view );
563 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
564 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
565 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
566 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
568 application.GetScene().Add( view );
569 application.SendNotification();
570 application.Render();
572 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
573 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
574 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
576 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
577 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
578 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
583 int UtcDaliWebViewPropertyTextZoomFactor(void)
585 ToolkitTestApplication application;
587 WebView view = WebView::New();
588 DALI_TEST_CHECK( view );
590 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
591 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
592 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
593 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
595 application.GetScene().Add( view );
596 application.SendNotification();
597 application.Render();
599 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
600 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
601 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
603 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
604 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
605 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
610 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
612 ToolkitTestApplication application;
614 WebView view = WebView::New();
615 DALI_TEST_CHECK( view );
617 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
618 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
619 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
620 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
622 application.GetScene().Add( view );
623 application.SendNotification();
624 application.Render();
626 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
627 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
632 int UtcDaliWebViewMove(void)
634 ToolkitTestApplication application;
636 WebView view = WebView::New();
637 DALI_TEST_CHECK( view );
639 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
640 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
641 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
642 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
644 application.GetScene().Add( view );
645 application.SendNotification();
646 application.Render();
648 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
649 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
650 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
655 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
657 ToolkitTestApplication application;
659 WebView view = WebView::New();
660 DALI_TEST_CHECK( view );
662 const bool kDefaultValue = false;
663 const bool kTestValue = true;
665 // Check default value
667 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
668 DALI_TEST_CHECK( value.Get( output ) );
669 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
671 // Check Set/GetProperty
672 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
673 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
674 DALI_TEST_CHECK( value.Get( output ) );
675 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
680 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
682 ToolkitTestApplication application;
684 WebView view = WebView::New();
685 DALI_TEST_CHECK( view );
687 const bool kDefaultValue = true;
688 const bool kTestValue = false;
690 // Check default value
692 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
693 DALI_TEST_CHECK( value.Get( output ) );
694 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
696 // Check Set/GetProperty
697 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
698 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
699 DALI_TEST_CHECK( value.Get( output ) );
700 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
705 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
707 ToolkitTestApplication application;
709 WebView view = WebView::New();
710 DALI_TEST_CHECK( view );
712 const bool kDefaultValue = true;
713 const bool kTestValue = false;
715 // Check default value
717 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
718 DALI_TEST_CHECK( value.Get( output ) );
719 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
721 // Check Set/GetProperty
722 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
723 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
724 DALI_TEST_CHECK( value.Get( output ) );
725 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
730 int UtcDaliWebViewHoverAndWheel(void)
732 ToolkitTestApplication application;
734 WebView view = WebView::New();
735 DALI_TEST_CHECK( view );
736 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
737 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
738 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
739 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
741 application.GetScene().Add( view );
742 application.SendNotification();
743 application.Render();
745 view.GetNaturalSize();
746 view.HoveredSignal().Connect( &OnHovered );
747 view.WheelEventSignal().Connect( &OnWheelEvent );
750 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
751 Dali::Integration::Point pointDown;
752 pointDown.SetState( PointState::DOWN );
753 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
754 event.AddPoint( pointDown );
755 application.ProcessEvent( event );
757 event = Dali::Integration::HoverEvent();
758 Dali::Integration::Point pointUp;
759 pointUp.SetState( PointState::UP );
760 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
761 event.AddPoint( pointUp );
762 application.ProcessEvent( event );
764 event = Dali::Integration::HoverEvent();
765 Dali::Integration::Point pointMotion;
766 pointUp.SetState( PointState::MOTION );
767 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
768 event.AddPoint( pointMotion );
769 application.ProcessEvent( event );
772 Dali::Integration::WheelEvent wheelEvent;
773 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
774 wheelEvent.direction = 0;
775 wheelEvent.point = Vector2( 20, 20 );
776 wheelEvent.delta = 10;
777 application.ProcessEvent( wheelEvent );
778 application.SendNotification();
780 DALI_TEST_CHECK( gHovered );
781 DALI_TEST_CHECK( gWheelEventHandled );
786 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
788 ToolkitTestApplication application;
790 WebView view = WebView::New();
791 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
792 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
793 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
794 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
795 application.GetScene().Add( view );
796 application.SendNotification();
797 application.Render();
798 DALI_TEST_CHECK( view );
800 view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
801 view.RegisterFrameRenderedCallback(&OnFrameRendered);
802 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION );
803 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
805 view.LoadUrl( TEST_URL1 );
806 Test::EmitGlobalTimerSignal();
807 DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION );
808 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
810 // form repost decision.
811 DALI_TEST_CHECK(gFormRepostDecidedInstance);
812 gFormRepostDecidedInstance->Reply(true);
815 gFormRepostDecidedInstance = nullptr;
820 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
822 ToolkitTestApplication application;
824 WebView view = WebView::New();
825 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
826 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
827 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
828 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
829 application.GetScene().Add( view );
830 application.SendNotification();
831 application.Render();
832 DALI_TEST_CHECK( view );
834 view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
835 view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
836 view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
837 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
838 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
839 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
841 view.LoadUrl( TEST_URL1 );
842 Test::EmitGlobalTimerSignal();
843 DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
844 DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
845 DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
848 DALI_TEST_CHECK(gCertificateConfirmInstance);
849 gCertificateConfirmInstance->Allow(true);
850 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
852 DALI_TEST_CHECK(gSslCertificateInstance);
853 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
854 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
856 // http authentication.
857 DALI_TEST_CHECK(gHttpAuthInstance);
858 gHttpAuthInstance->Suspend();
859 gHttpAuthInstance->UseCredential("", "");
860 gHttpAuthInstance->CancelCredential();
861 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
864 gCertificateConfirmInstance = nullptr;
865 gSslCertificateInstance = nullptr;
866 gHttpAuthInstance = nullptr;
871 int UtcDaliWebViewGetWebBackForwardList(void)
873 ToolkitTestApplication application;
875 WebView view = WebView::New();
876 DALI_TEST_CHECK( view );
878 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
879 DALI_TEST_CHECK( bfList != 0 );
884 int UtcDaliWebViewGetWebContext(void)
886 ToolkitTestApplication application;
888 WebView view = WebView::New();
889 DALI_TEST_CHECK( view );
891 Dali::Toolkit::WebContext* context = view.GetContext();
892 DALI_TEST_CHECK( context != 0 );
897 int UtcDaliWebViewGetWebCookieManager(void)
899 ToolkitTestApplication application;
901 WebView view = WebView::New();
902 DALI_TEST_CHECK( view );
904 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
905 DALI_TEST_CHECK( cookieManager != 0 );
910 int UtcDaliWebViewGetWebSettings(void)
912 ToolkitTestApplication application;
914 WebView view = WebView::New();
915 DALI_TEST_CHECK( view );
917 Dali::Toolkit::WebSettings* settings = view.GetSettings();
918 DALI_TEST_CHECK( settings != 0 );
923 int UtcDaliWebViewProperty1(void)
926 ToolkitTestApplication application;
928 WebView view = WebView::New();
929 DALI_TEST_CHECK( view );
932 view.SetProperty( WebView::Property::URL, TEST_URL1 );
933 Property::Value val = view.GetProperty( WebView::Property::URL );
934 DALI_TEST_CHECK( val.Get( local ) );
935 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
940 int UtcDaliWebViewProperty4(void)
943 ToolkitTestApplication application;
945 WebView view = WebView::New();
946 DALI_TEST_CHECK( view );
948 const std::string kDefaultValue;
949 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";
951 // Check default value
953 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
954 DALI_TEST_CHECK( value.Get( output ) );
955 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
957 // Check Set/GetProperty
958 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
959 value = view.GetProperty( WebView::Property::USER_AGENT );
960 DALI_TEST_CHECK( value.Get( output ) );
961 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
966 int UtcDaliWebViewProperty9(void)
969 ToolkitTestApplication application;
971 WebView view = WebView::New();
972 DALI_TEST_CHECK( view );
974 // Check default value
975 Dali::Vector2 output = Dali::Vector2::ONE;
976 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
977 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
979 // Check Set/GetProperty
980 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
981 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
982 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
983 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
985 // Check default value of scroll size
986 output = Dali::Vector2::ONE;
987 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
988 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
990 // Check default value of content size
991 output = Dali::Vector2::ONE;
992 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
993 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
998 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1000 ToolkitTestApplication application;
1002 WebView view = WebView::New();
1003 DALI_TEST_CHECK( view );
1005 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1006 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1007 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1008 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1009 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1011 // Check default value
1012 std::string testText("test");
1014 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1015 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1020 int UtcDaliWebViewPropertyTitleFavicon(void)
1022 ToolkitTestApplication application;
1024 char argv[] = "--test";
1025 WebView view = WebView::New( 1, (char**)&argv );
1026 DALI_TEST_CHECK( view );
1029 view.ClearAllTilesResources();
1031 // Check default value of title
1032 std::string testValue("title");
1034 view.GetProperty( WebView::Property::TITLE ).Get( output );
1035 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1037 // Check the case that favicon is not null.
1038 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1039 DALI_TEST_CHECK( favicon );
1040 Dali::Vector3 iconsize = favicon.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1041 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
1043 // Check the case that favicon is null.
1044 favicon = view.GetFavicon();
1045 DALI_TEST_CHECK( !favicon );
1050 int UtcDaliWebViewContextMenuShownAndHidden(void)
1052 ToolkitTestApplication application;
1054 WebView view = WebView::New();
1055 DALI_TEST_CHECK( view );
1058 view.RegisterContextMenuShownCallback( &OnContextMenuShown );
1059 view.RegisterContextMenuHiddenCallback( &OnContextMenuHidden );
1060 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 0, TEST_LOCATION );
1061 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION );
1062 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1063 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1065 view.LoadUrl( TEST_URL1 );
1066 Test::EmitGlobalTimerSignal();
1067 DALI_TEST_EQUALS( gContextMenuShownCallbackCalled, 1, TEST_LOCATION );
1068 DALI_TEST_EQUALS( gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION );
1070 // check context meun & its items.
1071 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1072 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1073 DALI_TEST_CHECK(item.get() != 0);
1074 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1075 DALI_TEST_CHECK(itemList.size() == 1);
1076 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1077 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1078 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1079 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1080 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1082 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1083 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1084 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1085 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1086 DALI_TEST_CHECK(item->IsEnabled());
1087 std::string testLinkUrl("http://test.html");
1088 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1089 std::string testImageUrl("http://test.jpg");
1090 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1091 std::string testTitle("title");
1092 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1093 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1095 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1097 gContextMenuShownInstance = nullptr;
1098 gContextMenuHiddenInstance = nullptr;
1103 int UtcDaliWebViewScrollBy(void)
1105 ToolkitTestApplication application;
1107 WebView view = WebView::New();
1108 DALI_TEST_CHECK( view );
1111 view.RegisterScrollEdgeReachedCallback( &OnScrollEdgeReached );
1112 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
1114 view.LoadUrl( TEST_URL1 );
1115 Test::EmitGlobalTimerSignal();
1117 // set scroll position.
1118 Dali::Vector2 output = Dali::Vector2::ONE;
1119 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
1120 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
1121 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1122 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
1124 // scroll by and trigger scrollEdgeReached event.
1125 view.ScrollBy( 50, 50 );
1126 Test::EmitGlobalTimerSignal();
1128 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1129 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
1130 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
1132 // scroll by and trigger scrollEdgeReached event.
1133 bool result = view.ScrollEdgeBy( 50, 50 );
1134 DALI_TEST_CHECK( result );
1135 Test::EmitGlobalTimerSignal();
1137 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
1138 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
1139 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
1144 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1146 ToolkitTestApplication application;
1148 WebView view = WebView::New();
1149 DALI_TEST_CHECK( view );
1151 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1152 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1153 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1154 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1156 application.GetScene().Add( view );
1157 application.SendNotification();
1158 application.Render();
1160 view.ActivateAccessibility(true);
1161 view.AddDynamicCertificatePath("host", "test/to/path");
1162 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1163 DALI_TEST_CHECK( found );
1165 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1166 float result = view.GetScaleFactor();
1167 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
1169 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1170 result = view.GetScaleFactor();
1171 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
1176 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1179 ToolkitTestApplication application;
1181 char argv[] = "--test";
1182 WebView view = WebView::New( 1, (char**)&argv );
1183 DALI_TEST_CHECK( view );
1185 // Check GetScreenshot
1186 Dali::Rect<int> viewArea;
1189 viewArea.width = 10;
1190 viewArea.height = 10;
1191 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1192 DALI_TEST_CHECK( screenshot );
1193 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1194 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1196 // Check GetScreenshotAsynchronously
1199 viewArea.width = 100;
1200 viewArea.height = 100;
1201 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1202 DALI_TEST_CHECK( result );
1204 Test::EmitGlobalTimerSignal();
1206 Test::EmitGlobalTimerSignal();
1207 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1212 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1215 ToolkitTestApplication application;
1217 char argv[] = "--test";
1218 WebView view = WebView::New( 1, (char**)&argv );
1219 DALI_TEST_CHECK( view );
1221 // Check CheckVideoPlayingAsynchronously
1222 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1223 DALI_TEST_CHECK( result );
1224 Test::EmitGlobalTimerSignal();
1225 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1227 // Check RegisterGeolocationPermissionCallback
1228 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1229 Test::EmitGlobalTimerSignal();
1230 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1235 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1237 ToolkitTestApplication application;
1239 WebView view = WebView::New();
1240 DALI_TEST_CHECK( view );
1243 view.RegisterResponsePolicyDecidedCallback( &OnResponsePolicyDecided );
1244 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION );
1245 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1247 view.LoadUrl( TEST_URL1 );
1248 Test::EmitGlobalTimerSignal();
1249 DALI_TEST_EQUALS( gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION );
1251 // check response policy decision & its frame.
1252 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1253 std::string testUrl("http://test.html");
1254 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1255 std::string testCookie("test:abc");
1256 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1257 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1258 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1259 std::string testResponseMime("txt/xml");
1260 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1261 int32_t ResponseStatusCode = 500;
1262 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1263 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1264 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1265 std::string testScheme("test");
1266 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1267 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1268 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1269 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1271 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1272 DALI_TEST_CHECK(webFrame);
1273 DALI_TEST_CHECK(webFrame->IsMainFrame());
1275 gResponsePolicyDecisionInstance = nullptr;
1280 int UtcDaliWebViewHitTest(void)
1282 ToolkitTestApplication application;
1284 WebView view = WebView::New();
1285 DALI_TEST_CHECK( view );
1288 view.LoadUrl( TEST_URL1 );
1291 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1292 DALI_TEST_CHECK(hitTest != 0);
1293 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1294 std::string testLinkUri("http://test.html");
1295 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1296 std::string testLinkTitle("test");
1297 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1298 std::string testLinkLabel("label");
1299 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1300 std::string testImageUri("http://test.jpg");
1301 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1302 std::string testMediaUri("http://test.mp4");
1303 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1304 std::string testTagName("img");
1305 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1306 std::string testNodeValue("test");
1307 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1308 Dali::Property::Map testMap = hitTest->GetAttributes();
1309 DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
1310 std::string testImageFileNameExtension("jpg");
1311 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1312 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1313 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1316 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1317 DALI_TEST_CHECK(result);
1318 Test::EmitGlobalTimerSignal();
1319 DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
1324 int UtcDaliWebViewEvaluteJavaScript(void)
1326 ToolkitTestApplication application;
1328 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1330 view.LoadHtmlString( "<body>Hello World!</body>" );
1331 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1332 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1333 Test::EmitGlobalTimerSignal();
1335 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1340 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1342 ToolkitTestApplication application;
1344 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1346 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1347 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1348 view.JavaScriptAlertReply();
1349 Test::EmitGlobalTimerSignal();
1350 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1352 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1353 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1354 view.JavaScriptConfirmReply( true );
1355 Test::EmitGlobalTimerSignal();
1356 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1358 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1359 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1360 view.JavaScriptPromptReply( "it is a prompt." );
1361 Test::EmitGlobalTimerSignal();
1362 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1367 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1369 ToolkitTestApplication application;
1371 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1372 DALI_TEST_CHECK( view );
1374 std::string html("<body>Hello World!</body>");
1375 std::string basicUri("http://basicurl");
1376 std::string unreachableUrl("http://unreachableurl");
1377 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1378 DALI_TEST_CHECK( result );
1380 application.SendNotification();
1381 application.Render();
1382 Test::EmitGlobalTimerSignal();
1384 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1385 DALI_TEST_CHECK( result );
1390 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1392 ToolkitTestApplication application;
1394 WebView view = WebView::New();
1395 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1396 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1397 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1398 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1400 application.GetScene().Add( view );
1401 application.SendNotification();
1402 application.Render();
1403 DALI_TEST_CHECK( view );
1405 view.LoadUrl( "http://test.html" );
1406 bool result = view.AddCustomHeader("key", "value");
1407 DALI_TEST_CHECK( result );
1409 result = view.ReloadWithoutCache();
1410 DALI_TEST_CHECK( result );
1412 uint32_t portNumber = view.StartInspectorServer(5000);
1413 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1415 application.SendNotification();
1416 application.Render();
1417 Test::EmitGlobalTimerSignal();
1419 result = view.StopInspectorServer();
1420 DALI_TEST_CHECK( result );
1422 view.SuspendNetworkLoading();
1424 result = view.RemoveCustomHeader("key");
1425 DALI_TEST_CHECK( result );
1427 view.ResumeNetworkLoading();
1432 int UtcDaliWebViewMethodsForCoverage(void)
1434 ToolkitTestApplication application;
1436 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1438 view.LoadHtmlString( "<body>Hello World!</body>" );
1439 view.AddJavaScriptMessageHandler( "jsObject",
1440 []( const std::string& arg ) {
1443 view.SetTtsFocus(true);
1445 DALI_TEST_CHECK( view );
1450 // test cases for web backforward list.
1452 int UtcDaliWebBackForwardListCheckItem(void)
1454 ToolkitTestApplication application;
1456 WebView view = WebView::New();
1457 DALI_TEST_CHECK( view );
1459 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1460 DALI_TEST_CHECK( bfList != 0 )
1462 unsigned int itemCount = bfList->GetItemCount();
1463 DALI_TEST_CHECK( itemCount == 1 )
1465 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1466 DALI_TEST_CHECK( citem != 0 );
1468 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1469 DALI_TEST_CHECK( citemP != 0 );
1471 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1472 DALI_TEST_CHECK( citemN != 0 );
1474 const std::string kDefaultUrl( "http://url" );
1475 std::string testValue = citem->GetUrl();
1476 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1478 const std::string kDefaultTitle( "title" );
1479 testValue = citem->GetTitle();
1480 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1482 const std::string kDefaultOriginalUrl( "http://originalurl" );
1483 testValue = citem->GetOriginalUrl();
1484 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1486 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1487 DALI_TEST_CHECK( item != 0 );
1489 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1490 DALI_TEST_CHECK( vecBack.size() == 1 );
1492 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1493 DALI_TEST_CHECK( vecForward.size() == 1 );
1498 // test cases for web context.
1500 int UtcDaliWebContextGetSetCacheModel(void)
1502 ToolkitTestApplication application;
1504 WebView view = WebView::New();
1505 DALI_TEST_CHECK( view );
1507 Dali::Toolkit::WebContext* context = view.GetContext();
1508 DALI_TEST_CHECK( context != 0 )
1510 std::string kDefaultValue;
1513 context->SetAppId( "id" );
1514 context->SetApplicationType( Dali::WebEngineContext::ApplicationType::OTHER );
1515 context->SetTimeOffset( 0 );
1516 context->SetTimeZoneOffset( 0, 0 );
1517 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1518 context->DeleteAllWebDatabase();
1519 context->DeleteAllWebStorage();
1520 context->DeleteLocalFileSystem();
1521 context->ClearCache();
1522 context->DeleteAllFormPasswordData();
1523 context->DeleteAllFormCandidateData();
1525 // Check default value
1526 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1527 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1529 // Check Set/GetProperty
1530 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1531 value = context->GetCacheModel();
1532 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1534 // Get cache enabled
1535 context->EnableCache( true );
1536 DALI_TEST_CHECK( context->IsCacheEnabled() );
1539 context->SetCertificateFilePath( "test" );
1540 std::string str = context->GetCertificateFilePath();
1541 DALI_TEST_EQUALS( str, "test", TEST_LOCATION );
1544 DALI_TEST_CHECK( context->SetAppVersion( "test" ) );
1547 std::vector<std::string> temp;
1548 context->RegisterUrlSchemesAsCorsEnabled( temp );
1549 context->RegisterJsPluginMimeTypes( temp );
1550 context->DeleteFormPasswordDataList( temp );
1553 context->SetDefaultZoomFactor( 1.0f );
1554 DALI_TEST_EQUALS( context->GetDefaultZoomFactor(), float( 1.0f ), TEST_LOCATION );
1556 // Delete cache and database
1557 DALI_TEST_CHECK( context->DeleteAllApplicationCache() );
1558 DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() );
1561 context->SetProxyUri( "test" );
1562 DALI_TEST_EQUALS( context->GetProxyUri(), "test", TEST_LOCATION );
1563 context->SetProxyBypassRule("", "test");
1564 DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION );
1567 DALI_TEST_CHECK( context->FreeUnusedMemory() );
1572 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1574 ToolkitTestApplication application;
1576 WebView view = WebView::New();
1577 DALI_TEST_CHECK( view );
1579 Dali::Toolkit::WebContext* context = view.GetContext();
1580 DALI_TEST_CHECK( context != 0 )
1582 std::string kDefaultValue;
1584 // get origins of web database
1585 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1586 DALI_TEST_CHECK( result );
1588 Test::EmitGlobalTimerSignal();
1589 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1590 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1592 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1593 DALI_TEST_CHECK( origin );
1595 result = context->DeleteWebDatabase(*origin);
1596 DALI_TEST_CHECK( result );
1598 // get origins of web storage
1599 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1600 DALI_TEST_CHECK( result );
1602 Test::EmitGlobalTimerSignal();
1603 DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1604 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1606 origin = gSecurityOriginList[0].get();
1607 DALI_TEST_CHECK( origin );
1609 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1610 DALI_TEST_CHECK( result );
1611 Test::EmitGlobalTimerSignal();
1612 DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1614 result = context->DeleteWebStorage(*origin);
1615 DALI_TEST_CHECK( result );
1617 result = context->DeleteApplicationCache(*origin);
1618 DALI_TEST_CHECK( result );
1620 // form passwords, download state, mime type.
1621 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1622 Test::EmitGlobalTimerSignal();
1623 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1624 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1625 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1626 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1628 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1629 Test::EmitGlobalTimerSignal();
1630 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1632 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1633 Test::EmitGlobalTimerSignal();
1634 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1636 gSecurityOriginList.clear();
1637 gPasswordDataList.clear();
1642 int UtcDaliWebContextHttpRequestInterceptor(void)
1644 ToolkitTestApplication application;
1646 WebView view = WebView::New();
1647 DALI_TEST_CHECK( view );
1649 Dali::Toolkit::WebContext* context = view.GetContext();
1650 DALI_TEST_CHECK( context != 0 )
1653 context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1654 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1655 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1657 Test::EmitGlobalTimerSignal();
1658 DALI_TEST_EQUALS( gRequestInterceptedCallbackCalled, 1, TEST_LOCATION );
1660 // check request interceptor.
1661 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1662 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1663 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1664 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
1665 Dali::Property::Map testHeaders;
1666 testHeaders.Insert("key2", "value2");
1667 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
1668 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1669 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", "test", 4));
1670 DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk("test", 4));
1671 std::string testUrl("http://test.html");
1672 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1673 std::string testMethod("GET");
1674 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
1675 Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
1676 DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
1678 gRequestInterceptorInstance = nullptr;
1683 // test cases for web cookie manager.
1685 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1687 ToolkitTestApplication application;
1689 WebView view = WebView::New();
1690 DALI_TEST_CHECK( view );
1692 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1693 DALI_TEST_CHECK( cookieManager != 0 )
1695 const std::string kDefaultValue;
1698 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1699 cookieManager->ClearCookies();
1701 // Check default value
1702 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1703 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1705 // Check Set/GetProperty
1706 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1707 value = cookieManager->GetCookieAcceptPolicy();
1708 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1713 int UtcDaliWebCookieManagerChangesWatch(void)
1715 ToolkitTestApplication application;
1717 WebView view = WebView::New();
1718 DALI_TEST_CHECK( view );
1720 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1721 DALI_TEST_CHECK( cookieManager != 0 )
1723 cookieManager->ChangesWatch(&OnChangesWatch);
1724 Test::EmitGlobalTimerSignal();
1725 DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
1730 // test cases for web settings.
1732 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1734 ToolkitTestApplication application;
1736 WebView view = WebView::New();
1737 DALI_TEST_CHECK( view );
1739 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1740 DALI_TEST_CHECK( settings != 0 )
1743 settings->AllowMixedContents( false );
1744 settings->EnableSpatialNavigation( false );
1745 settings->EnableWebSecurity( false );
1746 settings->EnableCacheBuilder( false );
1747 settings->EnableDoNotTrack( false );
1748 settings->UseScrollbarThumbFocusNotifications( false );
1749 settings->AllowFileAccessFromExternalUrl( false );
1750 settings->AllowScriptsOpenWindows( false );
1752 // Check default value
1753 int value = settings->GetDefaultFontSize();
1754 DALI_TEST_CHECK( value == 16 );
1756 // Check Set/GetProperty
1757 settings->SetDefaultFontSize( 20 );
1758 value = settings->GetDefaultFontSize();
1759 DALI_TEST_CHECK( value == 20 );
1764 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1766 ToolkitTestApplication application;
1768 WebView view = WebView::New();
1769 DALI_TEST_CHECK( view );
1771 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1772 DALI_TEST_CHECK( settings != 0 )
1775 settings->AllowMixedContents( false );
1776 settings->EnableSpatialNavigation( false );
1777 settings->EnableWebSecurity( false );
1778 settings->EnableCacheBuilder( false );
1779 settings->EnableDoNotTrack( false );
1780 settings->UseScrollbarThumbFocusNotifications( false );
1781 settings->AllowFileAccessFromExternalUrl( false );
1782 settings->AllowScriptsOpenWindows( false );
1784 // Check default value is true or not
1785 bool value = settings->IsJavaScriptEnabled();
1786 DALI_TEST_CHECK( value );
1788 // Check Set/GetProperty
1789 settings->EnableJavaScript( false );
1790 value = settings->IsJavaScriptEnabled();
1791 DALI_TEST_CHECK( !value );
1796 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1798 ToolkitTestApplication application;
1800 WebView view = WebView::New();
1801 DALI_TEST_CHECK( view );
1803 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1804 DALI_TEST_CHECK( settings != 0 )
1807 settings->AllowMixedContents( false );
1808 settings->EnableSpatialNavigation( false );
1809 settings->EnableWebSecurity( false );
1810 settings->EnableCacheBuilder( false );
1811 settings->EnableDoNotTrack( false );
1812 settings->UseScrollbarThumbFocusNotifications( false );
1813 settings->AllowFileAccessFromExternalUrl( false );
1814 settings->AllowScriptsOpenWindows( false );
1816 // Check default value is true or not
1817 bool value = settings->IsAutoFittingEnabled();
1818 DALI_TEST_CHECK( value );
1820 // Check Set/GetProperty
1821 settings->EnableAutoFitting( false );
1822 value = settings->IsAutoFittingEnabled();
1823 DALI_TEST_CHECK( !value );
1828 int UtcDaliWebSettingsCheckEnablePlugins(void)
1830 ToolkitTestApplication application;
1832 WebView view = WebView::New();
1833 DALI_TEST_CHECK( view );
1835 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1836 DALI_TEST_CHECK( settings != 0 )
1839 settings->AllowMixedContents( false );
1840 settings->EnableSpatialNavigation( false );
1841 settings->EnableWebSecurity( false );
1842 settings->EnableCacheBuilder( false );
1843 settings->EnableDoNotTrack( false );
1844 settings->UseScrollbarThumbFocusNotifications( false );
1845 settings->AllowFileAccessFromExternalUrl( false );
1846 settings->AllowScriptsOpenWindows( false );
1848 // Check default value is true or not
1849 bool value = settings->ArePluginsEnabled();
1850 DALI_TEST_CHECK( value );
1852 // Check Set/GetProperty
1853 settings->EnablePlugins( false );
1854 value = settings->ArePluginsEnabled();
1855 DALI_TEST_CHECK( !value );
1860 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1862 ToolkitTestApplication application;
1864 WebView view = WebView::New();
1865 DALI_TEST_CHECK( view );
1867 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1868 DALI_TEST_CHECK( settings != 0 )
1871 settings->AllowMixedContents( false );
1872 settings->EnableSpatialNavigation( false );
1873 settings->EnableWebSecurity( false );
1874 settings->EnableCacheBuilder( false );
1875 settings->EnableDoNotTrack( false );
1876 settings->UseScrollbarThumbFocusNotifications( false );
1877 settings->AllowFileAccessFromExternalUrl( false );
1878 settings->AllowScriptsOpenWindows( false );
1880 // Check default value is true or not
1881 bool value = settings->IsPrivateBrowsingEnabled();
1882 DALI_TEST_CHECK( value );
1884 // Check Set/GetProperty
1885 settings->EnablePrivateBrowsing( false );
1886 value = settings->IsPrivateBrowsingEnabled();
1887 DALI_TEST_CHECK( !value );
1892 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1894 ToolkitTestApplication application;
1896 WebView view = WebView::New();
1897 DALI_TEST_CHECK( view );
1899 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1900 DALI_TEST_CHECK( settings != 0 )
1903 settings->AllowMixedContents( false );
1904 settings->EnableSpatialNavigation( false );
1905 settings->EnableWebSecurity( false );
1906 settings->EnableCacheBuilder( false );
1907 settings->EnableDoNotTrack( false );
1908 settings->UseScrollbarThumbFocusNotifications( false );
1909 settings->AllowFileAccessFromExternalUrl( false );
1910 settings->AllowScriptsOpenWindows( false );
1912 // Check default value is true or not
1913 bool value = settings->IsLinkMagnifierEnabled();
1914 DALI_TEST_CHECK( value );
1916 // Check Set/GetProperty
1917 settings->EnableLinkMagnifier( false );
1918 value = settings->IsLinkMagnifierEnabled();
1919 DALI_TEST_CHECK( !value );
1924 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1926 ToolkitTestApplication application;
1928 WebView view = WebView::New();
1929 DALI_TEST_CHECK( view );
1931 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1932 DALI_TEST_CHECK( settings != 0 )
1935 settings->AllowMixedContents( false );
1936 settings->EnableSpatialNavigation( false );
1937 settings->EnableWebSecurity( false );
1938 settings->EnableCacheBuilder( false );
1939 settings->EnableDoNotTrack( false );
1940 settings->UseScrollbarThumbFocusNotifications( false );
1941 settings->AllowFileAccessFromExternalUrl( false );
1942 settings->AllowScriptsOpenWindows( false );
1944 // Check default value is true or not
1945 bool value = settings->IsKeypadWithoutUserActionUsed();
1946 DALI_TEST_CHECK( value );
1948 // Check Set/GetProperty
1949 settings->UseKeypadWithoutUserAction( false );
1950 value = settings->IsKeypadWithoutUserActionUsed();
1951 DALI_TEST_CHECK( !value );
1956 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1958 ToolkitTestApplication application;
1960 WebView view = WebView::New();
1961 DALI_TEST_CHECK( view );
1963 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1964 DALI_TEST_CHECK( settings != 0 )
1967 settings->AllowMixedContents( false );
1968 settings->EnableSpatialNavigation( false );
1969 settings->EnableWebSecurity( false );
1970 settings->EnableCacheBuilder( false );
1971 settings->EnableDoNotTrack( false );
1972 settings->UseScrollbarThumbFocusNotifications( false );
1973 settings->AllowFileAccessFromExternalUrl( false );
1974 settings->AllowScriptsOpenWindows( false );
1976 // Check default value is true or not
1977 bool value = settings->IsAutofillPasswordFormEnabled();
1978 DALI_TEST_CHECK( value );
1979 settings->EnableAutofillPasswordForm( false );
1980 value = settings->IsAutofillPasswordFormEnabled();
1981 DALI_TEST_CHECK( !value );
1985 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1987 ToolkitTestApplication application;
1989 WebView view = WebView::New();
1990 DALI_TEST_CHECK( view );
1992 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1993 DALI_TEST_CHECK( settings != 0 );
1996 settings->AllowMixedContents( false );
1997 settings->EnableSpatialNavigation( false );
1998 settings->EnableWebSecurity( false );
1999 settings->EnableCacheBuilder( false );
2000 settings->EnableDoNotTrack( false );
2001 settings->UseScrollbarThumbFocusNotifications( false );
2002 settings->AllowFileAccessFromExternalUrl( false );
2003 settings->AllowScriptsOpenWindows( false );
2005 // Check default value is true or not
2006 bool value = settings->IsFormCandidateDataEnabled();
2007 DALI_TEST_CHECK( value );
2009 // Check Set/GetProperty
2010 settings->EnableFormCandidateData( false );
2011 value = settings->IsFormCandidateDataEnabled();
2012 DALI_TEST_CHECK( !value );
2017 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2019 ToolkitTestApplication application;
2021 WebView view = WebView::New();
2022 DALI_TEST_CHECK( view );
2024 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2025 DALI_TEST_CHECK( settings != 0 );
2028 settings->AllowMixedContents( false );
2029 settings->EnableSpatialNavigation( false );
2030 settings->EnableWebSecurity( false );
2031 settings->EnableCacheBuilder( false );
2032 settings->EnableDoNotTrack( false );
2033 settings->UseScrollbarThumbFocusNotifications( false );
2034 settings->AllowFileAccessFromExternalUrl( false );
2035 settings->AllowScriptsOpenWindows( false );
2037 // Check default value is true or not
2038 bool value = settings->IsTextSelectionEnabled();
2039 DALI_TEST_CHECK( value );
2041 //Check Set/GetProperty
2042 settings->EnableTextSelection(false);
2043 value = settings->IsTextSelectionEnabled();
2044 DALI_TEST_CHECK( !value );
2049 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2051 ToolkitTestApplication application;
2053 WebView view = WebView::New();
2054 DALI_TEST_CHECK( view );
2056 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2057 DALI_TEST_CHECK( settings != 0 );
2060 settings->AllowMixedContents( false );
2061 settings->EnableSpatialNavigation( false );
2062 settings->EnableWebSecurity( false );
2063 settings->EnableCacheBuilder( false );
2064 settings->EnableDoNotTrack( false );
2065 settings->UseScrollbarThumbFocusNotifications( false );
2066 settings->AllowFileAccessFromExternalUrl( false );
2067 settings->AllowScriptsOpenWindows( false );
2069 // Check default value is true or not
2070 bool value = settings->IsTextAutosizingEnabled();
2071 DALI_TEST_CHECK( value );
2073 // Check Set/GetProperty
2074 settings->EnableTextAutosizing(false);
2075 value = settings->IsTextAutosizingEnabled();
2076 DALI_TEST_CHECK( !value );
2081 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2083 ToolkitTestApplication application;
2085 WebView view = WebView::New();
2086 DALI_TEST_CHECK( view );
2088 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2089 DALI_TEST_CHECK( settings != 0 );
2092 settings->AllowMixedContents( false );
2093 settings->EnableSpatialNavigation( false );
2094 settings->EnableWebSecurity( false );
2095 settings->EnableCacheBuilder( false );
2096 settings->EnableDoNotTrack( false );
2097 settings->UseScrollbarThumbFocusNotifications( false );
2098 settings->AllowFileAccessFromExternalUrl( false );
2099 settings->AllowScriptsOpenWindows( false );
2101 // Check default value is true or not
2102 bool value = settings->IsArrowScrollEnabled();
2103 DALI_TEST_CHECK( value );
2105 // Check Set/GetProperty
2106 settings->EnableArrowScroll(false);
2107 value = settings->IsArrowScrollEnabled();
2108 DALI_TEST_CHECK( !value );
2113 int UtcDaliWebSettingsCheckEnableClipboard(void)
2115 ToolkitTestApplication application;
2117 WebView view = WebView::New();
2118 DALI_TEST_CHECK( view );
2120 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2121 DALI_TEST_CHECK( settings != 0 );
2124 settings->AllowMixedContents( false );
2125 settings->EnableSpatialNavigation( false );
2126 settings->EnableWebSecurity( false );
2127 settings->EnableCacheBuilder( false );
2128 settings->EnableDoNotTrack( false );
2129 settings->UseScrollbarThumbFocusNotifications( false );
2130 settings->AllowFileAccessFromExternalUrl( false );
2131 settings->AllowScriptsOpenWindows( false );
2133 // Check default value is true or not
2134 bool value = settings->IsClipboardEnabled();
2135 DALI_TEST_CHECK( value );
2136 settings->EnableClipboard(false);
2137 value = settings->IsClipboardEnabled();
2138 DALI_TEST_CHECK( !value );
2142 int UtcDaliWebSettingsCheckEnableImePanel(void)
2144 ToolkitTestApplication application;
2146 WebView view = WebView::New();
2147 DALI_TEST_CHECK( view );
2149 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2150 DALI_TEST_CHECK( settings != 0 );
2153 settings->AllowMixedContents( false );
2154 settings->EnableSpatialNavigation( false );
2155 settings->EnableWebSecurity( false );
2156 settings->EnableCacheBuilder( false );
2157 settings->EnableDoNotTrack( false );
2158 settings->UseScrollbarThumbFocusNotifications( false );
2159 settings->AllowFileAccessFromExternalUrl( false );
2160 settings->AllowScriptsOpenWindows( false );
2162 // Check default value is true or not
2163 bool value = settings->IsImePanelEnabled();
2164 DALI_TEST_CHECK( value );
2166 // Check Set/GetProperty
2167 settings->EnableImePanel(false);
2168 value = settings->IsImePanelEnabled();
2169 DALI_TEST_CHECK( !value );
2174 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2176 ToolkitTestApplication application;
2178 WebView view = WebView::New();
2179 DALI_TEST_CHECK( view );
2181 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2182 DALI_TEST_CHECK( settings != 0 )
2185 settings->AllowMixedContents( false );
2186 settings->EnableSpatialNavigation( false );
2187 settings->EnableWebSecurity( false );
2188 settings->EnableCacheBuilder( false );
2189 settings->EnableDoNotTrack( false );
2190 settings->UseScrollbarThumbFocusNotifications( false );
2191 settings->AllowFileAccessFromExternalUrl( false );
2192 settings->AllowScriptsOpenWindows( false );
2194 // Check default value is true or not
2195 bool value = settings->AreImagesLoadedAutomatically();
2196 DALI_TEST_CHECK( value );
2198 // Check Set/GetProperty
2199 settings->AllowImagesLoadAutomatically( false );
2200 value = settings->AreImagesLoadedAutomatically();
2201 DALI_TEST_CHECK( !value );
2206 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2208 ToolkitTestApplication application;
2210 WebView view = WebView::New();
2211 DALI_TEST_CHECK( view );
2213 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2214 DALI_TEST_CHECK( settings != 0 )
2216 const std::string kDefaultValue;
2217 const std::string kTestValue = "UTF-8";
2220 settings->AllowMixedContents( false );
2221 settings->EnableSpatialNavigation( false );
2222 settings->EnableWebSecurity( false );
2223 settings->EnableCacheBuilder( false );
2224 settings->EnableDoNotTrack( false );
2225 settings->UseScrollbarThumbFocusNotifications( false );
2226 settings->AllowFileAccessFromExternalUrl( false );
2227 settings->AllowScriptsOpenWindows( false );
2229 // Check default value
2230 std::string value = settings->GetDefaultTextEncodingName();
2231 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2233 // Check Set/GetProperty
2234 settings->SetDefaultTextEncodingName( kTestValue );
2235 value = settings->GetDefaultTextEncodingName();
2236 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
2241 int UtcDaliWebSettingsSetViewportMetaTag(void)
2243 ToolkitTestApplication application;
2245 WebView view = WebView::New();
2246 DALI_TEST_CHECK( view );
2248 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2249 DALI_TEST_CHECK( settings != 0 )
2251 // Check the value is true or not
2252 bool value = settings->SetViewportMetaTag(true);
2253 DALI_TEST_CHECK( value );
2258 int UtcDaliWebSettingsSetForceZoom(void)
2260 ToolkitTestApplication application;
2262 WebView view = WebView::New();
2263 DALI_TEST_CHECK( view );
2265 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2266 DALI_TEST_CHECK( settings != 0 )
2268 // Check the value is true or not
2269 bool value = settings->SetForceZoom(true);
2270 DALI_TEST_CHECK( value );
2272 value = settings->IsZoomForced();
2273 DALI_TEST_CHECK( value );
2278 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2280 ToolkitTestApplication application;
2282 WebView view = WebView::New();
2283 DALI_TEST_CHECK( view );
2285 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2286 DALI_TEST_CHECK( settings != 0 )
2288 // Check the value is true or not
2289 bool value = settings->SetTextZoomEnabled(true);
2290 DALI_TEST_CHECK( value );
2292 value = settings->IsTextZoomEnabled();
2293 DALI_TEST_CHECK( value );
2298 int UtcDaliWebSettingsSetExtraFeature(void)
2300 ToolkitTestApplication application;
2302 WebView view = WebView::New();
2303 DALI_TEST_CHECK( view );
2305 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2306 DALI_TEST_CHECK( settings != 0 )
2308 // Check the value is true or not
2309 settings->SetExtraFeature("test", true);
2310 bool value = settings->IsExtraFeatureEnabled("test");
2311 DALI_TEST_CHECK( value );
2316 int UtcDaliWebViewGetPlainText(void)
2318 ToolkitTestApplication application;
2320 WebView view = WebView::New();
2321 DALI_TEST_CHECK(view);
2323 view.LoadUrl(TEST_URL1);
2325 view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2326 Test::EmitGlobalTimerSignal();
2327 DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);