2 * Copyright (c) 2023 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"
24 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
25 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
26 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
27 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
28 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
30 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-certificate.h>
31 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-console-message.h>
32 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context.h>
33 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context-menu-item.h>
34 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context-menu.h>
35 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-cookie-manager.h>
36 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-form-repost-decision.h>
37 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-frame.h>
38 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-hit-test.h>
39 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-http-auth-handler.h>
40 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-load-error.h>
41 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-policy-decision.h>
42 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-request-interceptor.h>
43 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-security-origin.h>
44 #include <dali/integration-api/events/hover-event-integ.h>
45 #include <dali/integration-api/events/key-event-integ.h>
46 #include <dali/integration-api/events/touch-event-integ.h>
47 #include <dali/integration-api/events/wheel-event-integ.h>
48 #include <dali/public-api/images/pixel-data.h>
51 using namespace Toolkit;
55 const char* const TEST_URL1("http://www.somewhere.valid1.com");
56 const char* const TEST_URL2("http://www.somewhere.valid2.com");
58 static int gPageLoadStartedCallbackCalled = 0;
59 static int gPageLoadInProgressCallbackCalled = 0;
60 static int gPageLoadFinishedCallbackCalled = 0;
61 static int gPageLoadErrorCallbackCalled = 0;
62 static std::unique_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
63 static int gScrollEdgeReachedCallbackCalled = 0;
64 static int gUrlChangedCallbackCalled = 0;
65 static int gEvaluateJavaScriptCallbackCalled = 0;
66 static int gJavaScriptAlertCallbackCalled = 0;
67 static int gJavaScriptConfirmCallbackCalled = 0;
68 static int gJavaScriptPromptCallbackCalled = 0;
69 static int gScreenshotCapturedCallbackCalled = 0;
70 static int gVideoPlayingCallbackCalled = 0;
71 static int gGeolocationPermissionCallbackCalled = 0;
72 static bool gTouched = false;
73 static bool gHovered = false;
74 static bool gWheelEventHandled = false;
75 static int gFormRepostDecidedCallbackCalled = 0;
76 static std::unique_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecidedInstance = nullptr;
77 static int gFrameRenderedCallbackCalled = 0;
78 static int gConsoleMessageCallbackCalled = 0;
79 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
80 static int gResponsePolicyDecidedCallbackCalled = 0;
81 static int gNavigationPolicyDecidedCallbackCalled = 0;
82 static int gNewWindowCreatedCallbackCalled = 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 OnNavigationPolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
149 gNavigationPolicyDecidedCallbackCalled++;
152 static void OnNewWindowCreated(Dali::WebEnginePlugin*& outPlugin)
154 gNewWindowCreatedCallbackCalled++;
155 WebView newView = WebView::New();
156 outPlugin = newView.GetPlugin();
159 static void OnUrlChanged(const std::string& url)
161 gUrlChangedCallbackCalled++;
164 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
166 gHitTestCreatedCallbackCalled++;
170 static bool OnPlainTextReceived(const std::string& plainText)
172 gPlainTextReceivedCallbackCalled++;
176 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
178 gPageLoadErrorCallbackCalled++;
179 gPageLoadErrorInstance = std::move(error);
182 static void OnEvaluateJavaScript(const std::string& result)
184 gEvaluateJavaScriptCallbackCalled++;
187 static bool OnJavaScriptAlert(const std::string& result)
189 gJavaScriptAlertCallbackCalled++;
193 static bool OnJavaScriptConfirm(const std::string& result)
195 gJavaScriptConfirmCallbackCalled++;
199 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
201 gJavaScriptPromptCallbackCalled++;
205 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
207 gScreenshotCapturedCallbackCalled++;
210 static void OnVideoPlaying(bool isPlaying)
212 gVideoPlayingCallbackCalled++;
215 static bool OnGeolocationPermission(const std::string&, const std::string&)
217 gGeolocationPermissionCallbackCalled++;
221 static bool OnTouched(Actor actor, const Dali::TouchEvent& touch)
227 static void OnChangesWatch()
229 gCookieManagerChangsWatchCallbackCalled++;
232 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
238 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
240 gWheelEventHandled = true;
244 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
246 gFormRepostDecidedCallbackCalled++;
247 gFormRepostDecidedInstance = std::move(decision);
250 static void OnFrameRendered()
252 gFrameRenderedCallbackCalled++;
255 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
257 gConsoleMessageCallbackCalled++;
258 gConsoleMessageInstance = std::move(message);
261 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
263 gCertificateConfirmCallbackCalled++;
264 gCertificateConfirmInstance = std::move(certificate);
267 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
269 gSslCertificateChangedCallbackCalled++;
270 gSslCertificateInstance = std::move(certificate);
273 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
275 gHttpAuthHandlerCallbackCalled++;
276 gHttpAuthInstance = std::move(hander);
279 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
281 gSecurityOriginsAcquiredCallbackCalled++;
282 gSecurityOriginList.clear();
283 gSecurityOriginList.swap(origins);
286 static void OnStorageUsageAcquired(uint64_t usage)
288 gStorageUsageAcquiredCallbackCalled++;
291 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
293 gFormPasswordsAcquiredCallbackCalled++;
294 gPasswordDataList.clear();
295 gPasswordDataList.swap(passwords);
298 static void OnDownloadStarted(const std::string& url)
300 gDownloadStartedCallbackCalled++;
303 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
305 gMimeOverriddenCallbackCalled++;
309 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
311 gRequestInterceptedCallbackCalled++;
312 gRequestInterceptorInstance = interceptor;
316 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
318 gContextMenuShownCallbackCalled++;
319 gContextMenuShownInstance = std::move(menu);
322 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
324 gContextMenuHiddenCallbackCalled++;
325 gContextMenuHiddenInstance = std::move(menu);
330 void web_view_startup(void)
332 test_return_value = TET_UNDEF;
335 void web_view_cleanup(void)
337 test_return_value = TET_PASS;
340 int UtcDaliWebViewBasics(void)
342 ToolkitTestApplication application;
344 // Copy and Assignment Test
345 tet_infoline("UtcDaliWebViewBasic Copy and Assignment Test");
346 WebView view = WebView::New();
347 DALI_TEST_CHECK(view);
350 DALI_TEST_CHECK(view == copy);
353 DALI_TEST_CHECK(!assign);
356 DALI_TEST_CHECK(assign == view);
359 tet_infoline("UtcDaliWebViewBasic DownCast Test");
360 BaseHandle handle(view);
362 WebView view2 = WebView::DownCast(handle);
363 DALI_TEST_CHECK(view);
364 DALI_TEST_CHECK(view2);
365 DALI_TEST_CHECK(view == view2);
368 tet_infoline("UtcDaliWebViewBasic TypeRegistry Test");
369 TypeRegistry typeRegistry = TypeRegistry::Get();
370 DALI_TEST_CHECK(typeRegistry);
372 TypeInfo typeInfo = typeRegistry.GetTypeInfo("WebView");
373 DALI_TEST_CHECK(typeInfo);
375 BaseHandle handle2 = typeInfo.CreateInstance();
376 DALI_TEST_CHECK(handle2);
378 WebView view3 = WebView::DownCast(handle2);
379 DALI_TEST_CHECK(view3);
384 int UtcDaliWebViewPageNavigation(void)
386 ToolkitTestApplication application;
388 WebView view = WebView::New();
389 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
390 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
391 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
392 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
393 application.GetScene().Add(view);
394 application.SendNotification();
395 application.Render();
396 DALI_TEST_CHECK(view);
398 view.RegisterPageLoadStartedCallback(&OnPageLoadStarted);
399 view.RegisterPageLoadInProgressCallback(&OnPageLoadInProgress);
400 view.RegisterPageLoadFinishedCallback(&OnPageLoadFinished);
401 view.RegisterUrlChangedCallback(&OnUrlChanged);
402 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 0, TEST_LOCATION);
403 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION);
404 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION);
405 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 0, TEST_LOCATION);
407 view.LoadUrl(TEST_URL1);
408 view.GetNaturalSize();
409 Test::EmitGlobalTimerSignal();
410 DALI_TEST_EQUALS(view.CanGoBack(), false, TEST_LOCATION);
411 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 1, TEST_LOCATION);
412 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION);
413 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION);
414 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 1, TEST_LOCATION);
416 view.LoadUrl(TEST_URL2);
418 view.SetProperty(Actor::Property::SIZE, Vector2(400, 300));
419 application.SendNotification();
420 application.Render();
421 Test::EmitGlobalTimerSignal();
423 DALI_TEST_EQUALS(view.CanGoBack(), true, TEST_LOCATION);
424 DALI_TEST_EQUALS(view.CanGoForward(), false, TEST_LOCATION);
425 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 2, TEST_LOCATION);
426 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION);
427 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION);
428 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 2, TEST_LOCATION);
431 Test::EmitGlobalTimerSignal();
432 DALI_TEST_CHECK(!view.CanGoBack());
433 DALI_TEST_CHECK(view.CanGoForward());
436 Test::EmitGlobalTimerSignal();
437 DALI_TEST_CHECK(view.CanGoBack());
438 DALI_TEST_CHECK(!view.CanGoForward());
443 Test::EmitGlobalTimerSignal();
444 DALI_TEST_CHECK(!view.CanGoBack());
445 DALI_TEST_CHECK(!view.CanGoForward());
450 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
452 ToolkitTestApplication application;
454 WebView view = WebView::New();
455 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
456 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
457 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
458 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
459 application.GetScene().Add(view);
460 application.SendNotification();
461 application.Render();
462 DALI_TEST_CHECK(view);
464 view.RegisterPageLoadErrorCallback(&OnPageLoadError);
465 view.RegisterConsoleMessageReceivedCallback(&OnConsoleMessage);
466 DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 0, TEST_LOCATION);
467 DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 0, TEST_LOCATION);
469 view.LoadUrl(TEST_URL1);
470 Test::EmitGlobalTimerSignal();
471 DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 1, TEST_LOCATION);
472 DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 1, TEST_LOCATION);
475 DALI_TEST_CHECK(gPageLoadErrorInstance);
476 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
477 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
478 std::string testErrorDescription("This is an error.");
479 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
480 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
483 DALI_TEST_CHECK(gConsoleMessageInstance);
484 std::string testConsoleSource("source");
485 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
486 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
487 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
488 std::string testConsoleText("This is a text.");
489 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
492 gPageLoadErrorInstance = nullptr;
493 gConsoleMessageInstance = nullptr;
498 int UtcDaliWebViewTouchAndKeys(void)
500 ToolkitTestApplication application;
502 WebView view = WebView::New();
503 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
504 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
505 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
506 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
508 application.GetScene().Add(view);
509 application.SendNotification();
510 application.Render();
512 view.GetNaturalSize();
513 view.TouchedSignal().Connect(&OnTouched);
516 Dali::Integration::TouchEvent event;
517 Dali::Integration::Point pointDown, pointUp;
519 event = Dali::Integration::TouchEvent();
520 pointDown.SetState(PointState::DOWN);
521 pointDown.SetScreenPosition(Vector2(10, 10));
522 event.AddPoint(pointDown);
523 application.ProcessEvent(event);
525 event = Dali::Integration::TouchEvent();
526 pointUp.SetState(PointState::UP);
527 pointUp.SetScreenPosition(Vector2(10, 10));
528 event.AddPoint(pointUp);
529 application.ProcessEvent(event);
532 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor(view);
533 application.ProcessEvent(Integration::KeyEvent("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE));
534 application.SendNotification();
536 DALI_TEST_CHECK(gTouched);
537 DALI_TEST_CHECK(view);
542 int UtcDaliWebViewFocusGainedAndLost(void)
544 ToolkitTestApplication application;
546 WebView view = WebView::New();
547 DALI_TEST_CHECK(view);
549 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
550 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
551 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
552 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
554 application.GetScene().Add(view);
555 application.SendNotification();
556 application.Render();
558 view.SetKeyInputFocus();
559 DALI_TEST_CHECK(view.HasKeyInputFocus());
562 view.ClearKeyInputFocus();
563 DALI_TEST_CHECK(!view.HasKeyInputFocus());
568 int UtcDaliWebViewPropertyPageZoomFactor(void)
570 ToolkitTestApplication application;
572 WebView view = WebView::New();
573 DALI_TEST_CHECK(view);
575 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
576 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
577 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
578 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
580 application.GetScene().Add(view);
581 application.SendNotification();
582 application.Render();
584 view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
585 float zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
586 DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
588 view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
589 zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
590 DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
595 int UtcDaliWebViewPropertyTextZoomFactor(void)
597 ToolkitTestApplication application;
599 WebView view = WebView::New();
600 DALI_TEST_CHECK(view);
602 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
603 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
604 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
605 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
607 application.GetScene().Add(view);
608 application.SendNotification();
609 application.Render();
611 view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
612 float zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
613 DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
615 view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
616 zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
617 DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
622 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
624 ToolkitTestApplication application;
626 WebView view = WebView::New();
627 DALI_TEST_CHECK(view);
629 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
630 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
631 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
632 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
634 application.GetScene().Add(view);
635 application.SendNotification();
636 application.Render();
638 float percentage = view.GetProperty<float>(WebView::Property::LOAD_PROGRESS_PERCENTAGE);
639 DALI_TEST_EQUALS(percentage, 0.5f, TEST_LOCATION);
644 int UtcDaliWebViewMove(void)
646 ToolkitTestApplication application;
648 WebView view = WebView::New();
649 DALI_TEST_CHECK(view);
651 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
652 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
653 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
654 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
656 application.GetScene().Add(view);
657 application.SendNotification();
658 application.Render();
660 view.SetProperty(Actor::Property::POSITION, Vector2(100, 100));
661 Vector3 viewPos = view.GetProperty<Vector3>(Actor::Property::POSITION);
662 DALI_TEST_EQUALS(viewPos, Vector3(100, 100, 0), TEST_LOCATION);
667 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
669 ToolkitTestApplication application;
671 WebView view = WebView::New();
672 DALI_TEST_CHECK(view);
674 const bool kDefaultValue = false;
675 const bool kTestValue = true;
677 // Check default value
679 Property::Value value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
680 DALI_TEST_CHECK(value.Get(output));
681 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
683 // Check Set/GetProperty
684 view.SetProperty(WebView::Property::VIDEO_HOLE_ENABLED, kTestValue);
685 value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
686 DALI_TEST_CHECK(value.Get(output));
687 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
692 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
694 ToolkitTestApplication application;
696 WebView view = WebView::New();
697 DALI_TEST_CHECK(view);
699 const bool kDefaultValue = true;
700 const bool kTestValue = false;
702 // Check default value
704 Property::Value value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
705 DALI_TEST_CHECK(value.Get(output));
706 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
708 // Check Set/GetProperty
709 view.SetProperty(WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue);
710 value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
711 DALI_TEST_CHECK(value.Get(output));
712 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
717 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
719 ToolkitTestApplication application;
721 WebView view = WebView::New();
722 DALI_TEST_CHECK(view);
724 const bool kDefaultValue = true;
725 const bool kTestValue = false;
727 // Check default value
729 Property::Value value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
730 DALI_TEST_CHECK(value.Get(output));
731 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
733 // Check Set/GetProperty
734 view.SetProperty(WebView::Property::KEY_EVENTS_ENABLED, kTestValue);
735 value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
736 DALI_TEST_CHECK(value.Get(output));
737 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
742 int UtcDaliWebViewHoverAndWheel(void)
744 ToolkitTestApplication application;
746 WebView view = WebView::New();
747 DALI_TEST_CHECK(view);
748 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
749 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
750 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
751 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
753 application.GetScene().Add(view);
754 application.SendNotification();
755 application.Render();
757 view.GetNaturalSize();
758 view.HoveredSignal().Connect(&OnHovered);
759 view.WheelEventSignal().Connect(&OnWheelEvent);
762 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
763 Dali::Integration::Point pointDown;
764 pointDown.SetState(PointState::DOWN);
765 pointDown.SetScreenPosition(Vector2(10, 10));
766 event.AddPoint(pointDown);
767 application.ProcessEvent(event);
769 event = Dali::Integration::HoverEvent();
770 Dali::Integration::Point pointUp;
771 pointUp.SetState(PointState::UP);
772 pointUp.SetScreenPosition(Vector2(10, 10));
773 event.AddPoint(pointUp);
774 application.ProcessEvent(event);
776 event = Dali::Integration::HoverEvent();
777 Dali::Integration::Point pointMotion;
778 pointUp.SetState(PointState::MOTION);
779 pointUp.SetScreenPosition(Vector2(10, 10));
780 event.AddPoint(pointMotion);
781 application.ProcessEvent(event);
784 Dali::Integration::WheelEvent wheelEvent;
785 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
786 wheelEvent.direction = 0;
787 wheelEvent.point = Vector2(20, 20);
788 wheelEvent.delta = 10;
789 application.ProcessEvent(wheelEvent);
790 application.SendNotification();
792 DALI_TEST_CHECK(gHovered);
793 DALI_TEST_CHECK(gWheelEventHandled);
798 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
800 ToolkitTestApplication application;
802 WebView view = WebView::New();
803 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
804 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
805 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
806 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
807 application.GetScene().Add(view);
808 application.SendNotification();
809 application.Render();
810 DALI_TEST_CHECK(view);
812 view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
813 view.RegisterFrameRenderedCallback(&OnFrameRendered);
814 DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION);
815 DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 0, TEST_LOCATION);
817 view.LoadUrl(TEST_URL1);
818 Test::EmitGlobalTimerSignal();
819 DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION);
820 DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 1, TEST_LOCATION);
822 // form repost decision.
823 DALI_TEST_CHECK(gFormRepostDecidedInstance);
824 gFormRepostDecidedInstance->Reply(true);
827 gFormRepostDecidedInstance = nullptr;
832 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
834 ToolkitTestApplication application;
836 WebView view = WebView::New();
837 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
838 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
839 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
840 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
841 application.GetScene().Add(view);
842 application.SendNotification();
843 application.Render();
844 DALI_TEST_CHECK(view);
846 view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
847 view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
848 view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
849 DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 0, TEST_LOCATION);
850 DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION);
851 DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION);
853 view.LoadUrl(TEST_URL1);
854 Test::EmitGlobalTimerSignal();
855 DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 1, TEST_LOCATION);
856 DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION);
857 DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION);
860 DALI_TEST_CHECK(gCertificateConfirmInstance);
861 gCertificateConfirmInstance->Allow(true);
862 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
864 DALI_TEST_CHECK(gSslCertificateInstance);
865 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
866 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
868 // http authentication.
869 DALI_TEST_CHECK(gHttpAuthInstance);
870 gHttpAuthInstance->Suspend();
871 gHttpAuthInstance->UseCredential("", "");
872 gHttpAuthInstance->CancelCredential();
873 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
876 gCertificateConfirmInstance = nullptr;
877 gSslCertificateInstance = nullptr;
878 gHttpAuthInstance = nullptr;
883 int UtcDaliWebViewGetWebBackForwardList(void)
885 ToolkitTestApplication application;
887 WebView view = WebView::New();
888 DALI_TEST_CHECK(view);
890 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
891 DALI_TEST_CHECK(bfList != 0);
896 int UtcDaliWebViewGetWebContext(void)
898 ToolkitTestApplication application;
900 Dali::WebEngineContext* context = WebView::GetContext();
901 DALI_TEST_CHECK(context != nullptr);
906 int UtcDaliWebViewGetWebCookieManager(void)
908 ToolkitTestApplication application;
910 Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
911 DALI_TEST_CHECK(cookieManager != 0);
916 int UtcDaliWebViewGetWebSettings(void)
918 ToolkitTestApplication application;
920 WebView view = WebView::New();
921 DALI_TEST_CHECK(view);
923 Dali::Toolkit::WebSettings* settings = view.GetSettings();
924 DALI_TEST_CHECK(settings != 0);
929 int UtcDaliWebViewProperty1(void)
932 ToolkitTestApplication application;
934 WebView view = WebView::New();
935 DALI_TEST_CHECK(view);
938 view.SetProperty(WebView::Property::URL, TEST_URL1);
939 Property::Value val = view.GetProperty(WebView::Property::URL);
940 DALI_TEST_CHECK(val.Get(local));
941 DALI_TEST_EQUALS(local, TEST_URL1, TEST_LOCATION);
946 int UtcDaliWebViewProperty4(void)
949 ToolkitTestApplication application;
951 WebView view = WebView::New();
952 DALI_TEST_CHECK(view);
954 const std::string kDefaultValue;
955 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";
957 // Check default value
959 Property::Value value = view.GetProperty(WebView::Property::USER_AGENT);
960 DALI_TEST_CHECK(value.Get(output));
961 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
963 // Check Set/GetProperty
964 view.SetProperty(WebView::Property::USER_AGENT, kTestValue);
965 value = view.GetProperty(WebView::Property::USER_AGENT);
966 DALI_TEST_CHECK(value.Get(output));
967 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
972 int UtcDaliWebViewProperty9(void)
975 ToolkitTestApplication application;
977 WebView view = WebView::New();
978 DALI_TEST_CHECK(view);
980 // Check default value
981 Dali::Vector2 output = Dali::Vector2::ONE;
982 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
983 DALI_TEST_CHECK(output.x == 0 && output.y == 0);
985 // Check Set/GetProperty
986 Dali::Vector2 testValue = Dali::Vector2(100, 100);
987 view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
988 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
989 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
991 // Check default value of scroll size
992 output = Dali::Vector2::ONE;
993 view.GetProperty(WebView::Property::SCROLL_SIZE).Get(output);
994 DALI_TEST_CHECK(output.x == 500 && output.y == 500);
996 // Check default value of content size
997 output = Dali::Vector2::ONE;
998 view.GetProperty(WebView::Property::CONTENT_SIZE).Get(output);
999 DALI_TEST_CHECK(output.x == 500 && output.y == 500);
1004 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1006 ToolkitTestApplication application;
1008 WebView view = WebView::New();
1009 DALI_TEST_CHECK(view);
1011 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1012 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1013 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1014 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1015 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1017 // Check default value
1018 std::string testText("test");
1020 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1021 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1026 int UtcDaliWebViewPropertyTitleFavicon(void)
1028 ToolkitTestApplication application;
1030 char argv[] = "--test";
1031 WebView view = WebView::New(1, (char**)&argv);
1032 DALI_TEST_CHECK(view);
1035 view.ClearAllTilesResources();
1037 // Check default value of title
1038 std::string testValue("title");
1040 view.GetProperty(WebView::Property::TITLE).Get(output);
1041 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1043 // Check the case that favicon is not null.
1044 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1045 DALI_TEST_CHECK(favicon);
1046 Dali::Vector3 iconsize = favicon.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1047 DALI_TEST_CHECK((int)iconsize.width == 2 && (int)iconsize.height == 2);
1049 // Check the case that favicon is null.
1050 favicon = view.GetFavicon();
1051 DALI_TEST_CHECK(!favicon);
1056 int UtcDaliWebViewContextMenuShownAndHidden(void)
1058 ToolkitTestApplication application;
1060 WebView view = WebView::New();
1061 DALI_TEST_CHECK(view);
1064 view.RegisterContextMenuShownCallback(&OnContextMenuShown);
1065 view.RegisterContextMenuHiddenCallback(&OnContextMenuHidden);
1066 DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 0, TEST_LOCATION);
1067 DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION);
1068 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1069 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1071 view.LoadUrl(TEST_URL1);
1072 Test::EmitGlobalTimerSignal();
1073 DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 1, TEST_LOCATION);
1074 DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION);
1076 // check context meun & its items.
1077 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1078 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1079 DALI_TEST_CHECK(item.get() != 0);
1080 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1081 DALI_TEST_CHECK(itemList.size() == 1);
1082 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1083 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1084 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1085 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1086 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1088 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1089 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1090 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1091 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1092 DALI_TEST_CHECK(item->IsEnabled());
1093 std::string testLinkUrl("http://test.html");
1094 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1095 std::string testImageUrl("http://test.jpg");
1096 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1097 std::string testTitle("title");
1098 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1099 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1101 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1103 gContextMenuShownInstance = nullptr;
1104 gContextMenuHiddenInstance = nullptr;
1109 int UtcDaliWebViewScrollBy(void)
1111 ToolkitTestApplication application;
1113 WebView view = WebView::New();
1114 DALI_TEST_CHECK(view);
1117 view.RegisterScrollEdgeReachedCallback(&OnScrollEdgeReached);
1118 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION);
1120 view.LoadUrl(TEST_URL1);
1121 Test::EmitGlobalTimerSignal();
1123 // set scroll position.
1124 Dali::Vector2 output = Dali::Vector2::ONE;
1125 Dali::Vector2 testValue = Dali::Vector2(100, 100);
1126 view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
1127 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1128 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1130 // scroll by and trigger scrollEdgeReached event.
1131 view.ScrollBy(50, 50);
1132 Test::EmitGlobalTimerSignal();
1134 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1135 DALI_TEST_CHECK(output.x == 150 && output.y == 150);
1136 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION);
1138 // scroll by and trigger scrollEdgeReached event.
1139 bool result = view.ScrollEdgeBy(50, 50);
1140 DALI_TEST_CHECK(result);
1141 Test::EmitGlobalTimerSignal();
1143 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1144 DALI_TEST_CHECK(output.x == 200 && output.y == 200);
1145 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION);
1150 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1152 ToolkitTestApplication application;
1154 WebView view = WebView::New();
1155 DALI_TEST_CHECK(view);
1157 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1158 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1159 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1160 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1162 application.GetScene().Add(view);
1163 application.SendNotification();
1164 application.Render();
1166 view.ActivateAccessibility(true);
1167 view.AddDynamicCertificatePath("host", "test/to/path");
1168 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1169 DALI_TEST_CHECK(found);
1171 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1172 float result = view.GetScaleFactor();
1173 DALI_TEST_EQUALS(result, 1.5f, TEST_LOCATION);
1175 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1176 result = view.GetScaleFactor();
1177 DALI_TEST_EQUALS(result, 1.0f, TEST_LOCATION);
1182 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1185 ToolkitTestApplication application;
1187 char argv[] = "--test";
1188 WebView view = WebView::New(1, (char**)&argv);
1189 DALI_TEST_CHECK(view);
1191 // Check GetScreenshot
1192 Dali::Rect<int> viewArea;
1195 viewArea.width = 10;
1196 viewArea.height = 10;
1197 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1198 DALI_TEST_CHECK(screenshot);
1199 Dali::Vector3 shotsize = screenshot.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1200 DALI_TEST_CHECK((int)shotsize.width == viewArea.width && (int)shotsize.height == viewArea.height);
1202 // Check GetScreenshotAsynchronously
1205 viewArea.width = 100;
1206 viewArea.height = 100;
1207 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1208 DALI_TEST_CHECK(result);
1210 Test::EmitGlobalTimerSignal();
1212 Test::EmitGlobalTimerSignal();
1213 DALI_TEST_EQUALS(gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION);
1218 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1221 ToolkitTestApplication application;
1223 char argv[] = "--test";
1224 WebView view = WebView::New(1, (char**)&argv);
1225 DALI_TEST_CHECK(view);
1227 // Check CheckVideoPlayingAsynchronously
1228 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1229 DALI_TEST_CHECK(result);
1230 Test::EmitGlobalTimerSignal();
1231 DALI_TEST_EQUALS(gVideoPlayingCallbackCalled, 1, TEST_LOCATION);
1233 // Check RegisterGeolocationPermissionCallback
1234 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1235 Test::EmitGlobalTimerSignal();
1236 DALI_TEST_EQUALS(gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION);
1241 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1243 ToolkitTestApplication application;
1245 WebView view = WebView::New();
1246 DALI_TEST_CHECK(view);
1249 view.RegisterResponsePolicyDecidedCallback(&OnResponsePolicyDecided);
1250 DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1251 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1253 view.LoadUrl(TEST_URL1);
1254 Test::EmitGlobalTimerSignal();
1255 DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1257 // check response policy decision & its frame.
1258 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1259 std::string testUrl("http://test.html");
1260 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1261 std::string testCookie("test:abc");
1262 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1263 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1264 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1265 std::string testResponseMime("txt/xml");
1266 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1267 int32_t ResponseStatusCode = 500;
1268 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1269 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1270 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1271 std::string testScheme("test");
1272 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1273 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1274 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1275 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1277 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1278 DALI_TEST_CHECK(webFrame);
1279 DALI_TEST_CHECK(webFrame->IsMainFrame());
1281 gResponsePolicyDecisionInstance = nullptr;
1286 int UtcDaliWebViewNavigationPolicyDecisionRequest(void)
1288 ToolkitTestApplication application;
1290 WebView view = WebView::New();
1291 DALI_TEST_CHECK(view);
1294 view.RegisterNavigationPolicyDecidedCallback(&OnNavigationPolicyDecided);
1295 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1297 view.LoadUrl(TEST_URL1);
1298 Test::EmitGlobalTimerSignal();
1299 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1304 int UtcDaliWebViewNewWindowCreated(void)
1306 ToolkitTestApplication application;
1308 WebView view = WebView::New();
1309 DALI_TEST_CHECK(view);
1312 view.RegisterNewWindowCreatedCallback(&OnNewWindowCreated);
1313 DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 0, TEST_LOCATION);
1315 view.LoadUrl(TEST_URL1);
1316 Test::EmitGlobalTimerSignal();
1317 DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 1, TEST_LOCATION);
1322 int UtcDaliWebViewHitTest(void)
1324 ToolkitTestApplication application;
1326 WebView view = WebView::New();
1327 DALI_TEST_CHECK(view);
1330 view.LoadUrl(TEST_URL1);
1333 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1334 DALI_TEST_CHECK(hitTest != 0);
1335 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1336 std::string testLinkUri("http://test.html");
1337 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1338 std::string testLinkTitle("test");
1339 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1340 std::string testLinkLabel("label");
1341 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1342 std::string testImageUri("http://test.jpg");
1343 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1344 std::string testMediaUri("http://test.mp4");
1345 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1346 std::string testTagName("img");
1347 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1348 std::string testNodeValue("test");
1349 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1350 Dali::Property::Map testMap = hitTest->GetAttributes();
1351 DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
1352 std::string testImageFileNameExtension("jpg");
1353 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1354 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1355 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1358 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1359 DALI_TEST_CHECK(result);
1360 Test::EmitGlobalTimerSignal();
1361 DALI_TEST_EQUALS(gHitTestCreatedCallbackCalled, 1, TEST_LOCATION);
1366 int UtcDaliWebViewEvaluteJavaScript(void)
1368 ToolkitTestApplication application;
1370 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1372 view.LoadHtmlString("<body>Hello World!</body>");
1373 view.EvaluateJavaScript("jsObject.postMessage('Hello')");
1374 view.EvaluateJavaScript("jsObject.postMessage('World')", OnEvaluateJavaScript);
1375 Test::EmitGlobalTimerSignal();
1377 DALI_TEST_EQUALS(gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION);
1382 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1384 ToolkitTestApplication application;
1386 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1388 view.RegisterJavaScriptAlertCallback(&OnJavaScriptAlert);
1389 view.LoadHtmlString("<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>");
1390 view.JavaScriptAlertReply();
1391 Test::EmitGlobalTimerSignal();
1392 DALI_TEST_EQUALS(gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION);
1394 view.RegisterJavaScriptConfirmCallback(&OnJavaScriptConfirm);
1395 view.LoadHtmlString("<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>");
1396 view.JavaScriptConfirmReply(true);
1397 Test::EmitGlobalTimerSignal();
1398 DALI_TEST_EQUALS(gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION);
1400 view.RegisterJavaScriptPromptCallback(&OnJavaScriptPrompt);
1401 view.LoadHtmlString("<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>");
1402 view.JavaScriptPromptReply("it is a prompt.");
1403 Test::EmitGlobalTimerSignal();
1404 DALI_TEST_EQUALS(gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION);
1409 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1411 ToolkitTestApplication application;
1413 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1414 DALI_TEST_CHECK(view);
1416 std::string html("<body>Hello World!</body>");
1417 std::string basicUri("http://basicurl");
1418 std::string unreachableUrl("http://unreachableurl");
1419 bool result = view.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
1420 DALI_TEST_CHECK(result);
1422 application.SendNotification();
1423 application.Render();
1424 Test::EmitGlobalTimerSignal();
1426 result = view.LoadContents((const int8_t*)html.c_str(), html.length(), "html/text", "utf-8", basicUri);
1427 DALI_TEST_CHECK(result);
1432 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1434 ToolkitTestApplication application;
1436 WebView view = WebView::New();
1437 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1438 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1439 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1440 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1442 application.GetScene().Add(view);
1443 application.SendNotification();
1444 application.Render();
1445 DALI_TEST_CHECK(view);
1447 view.LoadUrl("http://test.html");
1448 bool result = view.AddCustomHeader("key", "value");
1449 DALI_TEST_CHECK(result);
1451 result = view.ReloadWithoutCache();
1452 DALI_TEST_CHECK(result);
1454 uint32_t portNumber = view.StartInspectorServer(5000);
1455 DALI_TEST_EQUALS(portNumber, 5000, TEST_LOCATION);
1457 application.SendNotification();
1458 application.Render();
1459 Test::EmitGlobalTimerSignal();
1461 result = view.StopInspectorServer();
1462 DALI_TEST_CHECK(result);
1464 view.SuspendNetworkLoading();
1466 result = view.RemoveCustomHeader("key");
1467 DALI_TEST_CHECK(result);
1469 view.ResumeNetworkLoading();
1474 int UtcDaliWebViewMethodsForCoverage(void)
1476 ToolkitTestApplication application;
1478 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1480 view.LoadHtmlString("<body>Hello World!</body>");
1481 view.AddJavaScriptMessageHandler("jsObject",
1482 [](const std::string& arg) {
1484 view.SetTtsFocus(true);
1486 DALI_TEST_CHECK(view);
1491 // test cases for web backforward list.
1493 int UtcDaliWebBackForwardListCheckItem(void)
1495 ToolkitTestApplication application;
1497 WebView view = WebView::New();
1498 DALI_TEST_CHECK(view);
1500 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1501 DALI_TEST_CHECK(bfList != 0)
1503 unsigned int itemCount = bfList->GetItemCount();
1504 DALI_TEST_CHECK(itemCount == 1)
1506 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1507 DALI_TEST_CHECK(citem != 0);
1509 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1510 DALI_TEST_CHECK(citemP != 0);
1512 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1513 DALI_TEST_CHECK(citemN != 0);
1515 const std::string kDefaultUrl("http://url");
1516 std::string testValue = citem->GetUrl();
1517 DALI_TEST_EQUALS(testValue, kDefaultUrl, TEST_LOCATION);
1519 const std::string kDefaultTitle("title");
1520 testValue = citem->GetTitle();
1521 DALI_TEST_EQUALS(testValue, kDefaultTitle, TEST_LOCATION);
1523 const std::string kDefaultOriginalUrl("http://originalurl");
1524 testValue = citem->GetOriginalUrl();
1525 DALI_TEST_EQUALS(testValue, kDefaultOriginalUrl, TEST_LOCATION);
1527 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex(0);
1528 DALI_TEST_CHECK(item != 0);
1530 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1531 DALI_TEST_CHECK(vecBack.size() == 1);
1533 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1534 DALI_TEST_CHECK(vecForward.size() == 1);
1539 // test cases for web context.
1541 int UtcDaliWebContextGetSetCacheModelEtc(void)
1543 ToolkitTestApplication application;
1545 Dali::WebEngineContext* context = WebView::GetContext();
1546 DALI_TEST_CHECK(context != 0)
1548 std::string kDefaultValue;
1551 context->SetAppId("id");
1552 context->SetApplicationType(Dali::WebEngineContext::ApplicationType::OTHER);
1553 context->SetTimeOffset(0);
1554 context->SetTimeZoneOffset(0, 0);
1555 context->SetDefaultProxyAuth(kDefaultValue, kDefaultValue);
1556 context->DeleteAllWebDatabase();
1557 context->DeleteAllWebStorage();
1558 context->DeleteLocalFileSystem();
1559 context->ClearCache();
1560 context->DeleteAllFormPasswordData();
1561 context->DeleteAllFormCandidateData();
1563 // Check default value
1564 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1565 DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER);
1567 // Check Set/GetProperty
1568 context->SetCacheModel(Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1569 value = context->GetCacheModel();
1570 DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1572 // Get cache enabled
1573 context->EnableCache(true);
1574 DALI_TEST_CHECK(context->IsCacheEnabled());
1577 context->SetCertificateFilePath("test");
1578 std::string str = context->GetCertificateFilePath();
1579 DALI_TEST_EQUALS(str, "test", TEST_LOCATION);
1582 DALI_TEST_CHECK(context->SetAppVersion("test"));
1585 std::vector<std::string> temp;
1586 context->RegisterUrlSchemesAsCorsEnabled(temp);
1587 context->RegisterJsPluginMimeTypes(temp);
1588 context->DeleteFormPasswordDataList(temp);
1591 context->SetDefaultZoomFactor(1.0f);
1592 DALI_TEST_EQUALS(context->GetDefaultZoomFactor(), float(1.0f), TEST_LOCATION);
1594 // Delete cache and database
1595 DALI_TEST_CHECK(context->DeleteAllApplicationCache());
1596 DALI_TEST_CHECK(context->DeleteAllWebIndexedDatabase());
1599 context->SetProxyUri("test");
1600 DALI_TEST_EQUALS(context->GetProxyUri(), "test", TEST_LOCATION);
1601 context->SetProxyBypassRule("", "test");
1602 DALI_TEST_EQUALS(context->GetProxyBypassRule(), "test", TEST_LOCATION);
1605 DALI_TEST_CHECK(context->FreeUnusedMemory());
1610 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1612 ToolkitTestApplication application;
1614 Dali::WebEngineContext* context = WebView::GetContext();
1615 DALI_TEST_CHECK(context != 0)
1617 std::string kDefaultValue;
1619 // get origins of web database
1620 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1621 DALI_TEST_CHECK(result);
1623 Test::EmitGlobalTimerSignal();
1624 DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION);
1625 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1627 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1628 DALI_TEST_CHECK(origin);
1630 result = context->DeleteWebDatabase(*origin);
1631 DALI_TEST_CHECK(result);
1633 // get origins of web storage
1634 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1635 DALI_TEST_CHECK(result);
1637 Test::EmitGlobalTimerSignal();
1638 DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION);
1639 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1641 origin = gSecurityOriginList[0].get();
1642 DALI_TEST_CHECK(origin);
1644 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1645 DALI_TEST_CHECK(result);
1646 Test::EmitGlobalTimerSignal();
1647 DALI_TEST_EQUALS(gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION);
1649 result = context->DeleteWebStorage(*origin);
1650 DALI_TEST_CHECK(result);
1652 result = context->DeleteApplicationCache(*origin);
1653 DALI_TEST_CHECK(result);
1655 // form passwords, download state, mime type.
1656 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1657 Test::EmitGlobalTimerSignal();
1658 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1659 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1660 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1661 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1663 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1664 Test::EmitGlobalTimerSignal();
1665 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1667 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1668 Test::EmitGlobalTimerSignal();
1669 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1671 gSecurityOriginList.clear();
1672 gPasswordDataList.clear();
1677 int UtcDaliWebContextHttpRequestInterceptor(void)
1679 ToolkitTestApplication application;
1681 Dali::WebEngineContext* context = WebView::GetContext();
1682 DALI_TEST_CHECK(context != 0)
1684 WebView view = WebView::New();
1685 DALI_TEST_CHECK(view);
1687 // Check if web view is found or not when plugin is null.
1688 DALI_TEST_CHECK(!WebView::FindWebView(nullptr));
1691 context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1692 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1693 DALI_TEST_CHECK(!gRequestInterceptorInstance);
1695 Test::EmitGlobalTimerSignal();
1696 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 1, TEST_LOCATION);
1698 // check request interceptor.
1699 DALI_TEST_CHECK(gRequestInterceptorInstance);
1700 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1701 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1702 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
1703 Dali::Property::Map testHeaders;
1704 testHeaders.Insert("key2", "value2");
1705 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
1706 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody((const int8_t*)"test", 4));
1707 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", (const int8_t*)"test", 4));
1708 DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk((const int8_t*)"test", 4));
1710 DALI_TEST_CHECK(gRequestInterceptorInstance->GetWebEngine());
1711 // Check if web view is found or not when plugin is not null.
1712 DALI_TEST_CHECK(WebView::FindWebView(gRequestInterceptorInstance->GetWebEngine()));
1714 std::string testUrl("http://test.html");
1715 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1716 std::string testMethod("GET");
1717 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
1718 Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
1719 DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
1721 // Destroy web view.
1723 gRequestInterceptorInstance = nullptr;
1728 // test cases for web cookie manager.
1730 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1732 ToolkitTestApplication application;
1734 Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1735 DALI_TEST_CHECK(cookieManager != 0)
1737 const std::string kDefaultValue;
1740 cookieManager->SetPersistentStorage(kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE);
1741 cookieManager->ClearCookies();
1743 // Check default value
1744 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1745 DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY);
1747 // Check Set/GetProperty
1748 cookieManager->SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1749 value = cookieManager->GetCookieAcceptPolicy();
1750 DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1755 int UtcDaliWebCookieManagerChangesWatch(void)
1757 ToolkitTestApplication application;
1759 Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1760 DALI_TEST_CHECK(cookieManager != 0)
1762 cookieManager->ChangesWatch(&OnChangesWatch);
1763 Test::EmitGlobalTimerSignal();
1764 DALI_TEST_EQUALS(gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION);
1769 // test cases for web settings.
1771 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1773 ToolkitTestApplication application;
1775 WebView view = WebView::New();
1776 DALI_TEST_CHECK(view);
1778 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1779 DALI_TEST_CHECK(settings != 0)
1782 settings->AllowMixedContents(false);
1783 settings->EnableSpatialNavigation(false);
1784 settings->EnableWebSecurity(false);
1785 settings->EnableCacheBuilder(false);
1786 settings->EnableDoNotTrack(false);
1787 settings->UseScrollbarThumbFocusNotifications(false);
1788 settings->AllowFileAccessFromExternalUrl(false);
1789 settings->AllowScriptsOpenWindows(false);
1791 // Check default value
1792 int value = settings->GetDefaultFontSize();
1793 DALI_TEST_CHECK(value == 16);
1795 // Check Set/GetProperty
1796 settings->SetDefaultFontSize(20);
1797 value = settings->GetDefaultFontSize();
1798 DALI_TEST_CHECK(value == 20);
1803 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1805 ToolkitTestApplication application;
1807 WebView view = WebView::New();
1808 DALI_TEST_CHECK(view);
1810 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1811 DALI_TEST_CHECK(settings != 0)
1814 settings->AllowMixedContents(false);
1815 settings->EnableSpatialNavigation(false);
1816 settings->EnableWebSecurity(false);
1817 settings->EnableCacheBuilder(false);
1818 settings->EnableDoNotTrack(false);
1819 settings->UseScrollbarThumbFocusNotifications(false);
1820 settings->AllowFileAccessFromExternalUrl(false);
1821 settings->AllowScriptsOpenWindows(false);
1823 // Check default value is true or not
1824 bool value = settings->IsJavaScriptEnabled();
1825 DALI_TEST_CHECK(value);
1827 // Check Set/GetProperty
1828 settings->EnableJavaScript(false);
1829 value = settings->IsJavaScriptEnabled();
1830 DALI_TEST_CHECK(!value);
1835 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1837 ToolkitTestApplication application;
1839 WebView view = WebView::New();
1840 DALI_TEST_CHECK(view);
1842 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1843 DALI_TEST_CHECK(settings != 0)
1846 settings->AllowMixedContents(false);
1847 settings->EnableSpatialNavigation(false);
1848 settings->EnableWebSecurity(false);
1849 settings->EnableCacheBuilder(false);
1850 settings->EnableDoNotTrack(false);
1851 settings->UseScrollbarThumbFocusNotifications(false);
1852 settings->AllowFileAccessFromExternalUrl(false);
1853 settings->AllowScriptsOpenWindows(false);
1855 // Check default value is true or not
1856 bool value = settings->IsAutoFittingEnabled();
1857 DALI_TEST_CHECK(value);
1859 // Check Set/GetProperty
1860 settings->EnableAutoFitting(false);
1861 value = settings->IsAutoFittingEnabled();
1862 DALI_TEST_CHECK(!value);
1867 int UtcDaliWebSettingsCheckEnablePlugins(void)
1869 ToolkitTestApplication application;
1871 WebView view = WebView::New();
1872 DALI_TEST_CHECK(view);
1874 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1875 DALI_TEST_CHECK(settings != 0)
1878 settings->AllowMixedContents(false);
1879 settings->EnableSpatialNavigation(false);
1880 settings->EnableWebSecurity(false);
1881 settings->EnableCacheBuilder(false);
1882 settings->EnableDoNotTrack(false);
1883 settings->UseScrollbarThumbFocusNotifications(false);
1884 settings->AllowFileAccessFromExternalUrl(false);
1885 settings->AllowScriptsOpenWindows(false);
1887 // Check default value is true or not
1888 bool value = settings->ArePluginsEnabled();
1889 DALI_TEST_CHECK(value);
1891 // Check Set/GetProperty
1892 settings->EnablePlugins(false);
1893 value = settings->ArePluginsEnabled();
1894 DALI_TEST_CHECK(!value);
1899 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1901 ToolkitTestApplication application;
1903 WebView view = WebView::New();
1904 DALI_TEST_CHECK(view);
1906 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1907 DALI_TEST_CHECK(settings != 0)
1910 settings->AllowMixedContents(false);
1911 settings->EnableSpatialNavigation(false);
1912 settings->EnableWebSecurity(false);
1913 settings->EnableCacheBuilder(false);
1914 settings->EnableDoNotTrack(false);
1915 settings->UseScrollbarThumbFocusNotifications(false);
1916 settings->AllowFileAccessFromExternalUrl(false);
1917 settings->AllowScriptsOpenWindows(false);
1919 // Check default value is true or not
1920 bool value = settings->IsPrivateBrowsingEnabled();
1921 DALI_TEST_CHECK(value);
1923 // Check Set/GetProperty
1924 settings->EnablePrivateBrowsing(false);
1925 value = settings->IsPrivateBrowsingEnabled();
1926 DALI_TEST_CHECK(!value);
1931 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1933 ToolkitTestApplication application;
1935 WebView view = WebView::New();
1936 DALI_TEST_CHECK(view);
1938 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1939 DALI_TEST_CHECK(settings != 0)
1942 settings->AllowMixedContents(false);
1943 settings->EnableSpatialNavigation(false);
1944 settings->EnableWebSecurity(false);
1945 settings->EnableCacheBuilder(false);
1946 settings->EnableDoNotTrack(false);
1947 settings->UseScrollbarThumbFocusNotifications(false);
1948 settings->AllowFileAccessFromExternalUrl(false);
1949 settings->AllowScriptsOpenWindows(false);
1951 // Check default value is true or not
1952 bool value = settings->IsLinkMagnifierEnabled();
1953 DALI_TEST_CHECK(value);
1955 // Check Set/GetProperty
1956 settings->EnableLinkMagnifier(false);
1957 value = settings->IsLinkMagnifierEnabled();
1958 DALI_TEST_CHECK(!value);
1963 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1965 ToolkitTestApplication application;
1967 WebView view = WebView::New();
1968 DALI_TEST_CHECK(view);
1970 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1971 DALI_TEST_CHECK(settings != 0)
1974 settings->AllowMixedContents(false);
1975 settings->EnableSpatialNavigation(false);
1976 settings->EnableWebSecurity(false);
1977 settings->EnableCacheBuilder(false);
1978 settings->EnableDoNotTrack(false);
1979 settings->UseScrollbarThumbFocusNotifications(false);
1980 settings->AllowFileAccessFromExternalUrl(false);
1981 settings->AllowScriptsOpenWindows(false);
1983 // Check default value is true or not
1984 bool value = settings->IsKeypadWithoutUserActionUsed();
1985 DALI_TEST_CHECK(value);
1987 // Check Set/GetProperty
1988 settings->UseKeypadWithoutUserAction(false);
1989 value = settings->IsKeypadWithoutUserActionUsed();
1990 DALI_TEST_CHECK(!value);
1995 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1997 ToolkitTestApplication application;
1999 WebView view = WebView::New();
2000 DALI_TEST_CHECK(view);
2002 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2003 DALI_TEST_CHECK(settings != 0)
2006 settings->AllowMixedContents(false);
2007 settings->EnableSpatialNavigation(false);
2008 settings->EnableWebSecurity(false);
2009 settings->EnableCacheBuilder(false);
2010 settings->EnableDoNotTrack(false);
2011 settings->UseScrollbarThumbFocusNotifications(false);
2012 settings->AllowFileAccessFromExternalUrl(false);
2013 settings->AllowScriptsOpenWindows(false);
2015 // Check default value is true or not
2016 bool value = settings->IsAutofillPasswordFormEnabled();
2017 DALI_TEST_CHECK(value);
2018 settings->EnableAutofillPasswordForm(false);
2019 value = settings->IsAutofillPasswordFormEnabled();
2020 DALI_TEST_CHECK(!value);
2024 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
2026 ToolkitTestApplication application;
2028 WebView view = WebView::New();
2029 DALI_TEST_CHECK(view);
2031 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2032 DALI_TEST_CHECK(settings != 0);
2035 settings->AllowMixedContents(false);
2036 settings->EnableSpatialNavigation(false);
2037 settings->EnableWebSecurity(false);
2038 settings->EnableCacheBuilder(false);
2039 settings->EnableDoNotTrack(false);
2040 settings->UseScrollbarThumbFocusNotifications(false);
2041 settings->AllowFileAccessFromExternalUrl(false);
2042 settings->AllowScriptsOpenWindows(false);
2044 // Check default value is true or not
2045 bool value = settings->IsFormCandidateDataEnabled();
2046 DALI_TEST_CHECK(value);
2048 // Check Set/GetProperty
2049 settings->EnableFormCandidateData(false);
2050 value = settings->IsFormCandidateDataEnabled();
2051 DALI_TEST_CHECK(!value);
2056 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2058 ToolkitTestApplication application;
2060 WebView view = WebView::New();
2061 DALI_TEST_CHECK(view);
2063 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2064 DALI_TEST_CHECK(settings != 0);
2067 settings->AllowMixedContents(false);
2068 settings->EnableSpatialNavigation(false);
2069 settings->EnableWebSecurity(false);
2070 settings->EnableCacheBuilder(false);
2071 settings->EnableDoNotTrack(false);
2072 settings->UseScrollbarThumbFocusNotifications(false);
2073 settings->AllowFileAccessFromExternalUrl(false);
2074 settings->AllowScriptsOpenWindows(false);
2076 // Check default value is true or not
2077 bool value = settings->IsTextSelectionEnabled();
2078 DALI_TEST_CHECK(value);
2080 //Check Set/GetProperty
2081 settings->EnableTextSelection(false);
2082 value = settings->IsTextSelectionEnabled();
2083 DALI_TEST_CHECK(!value);
2088 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2090 ToolkitTestApplication application;
2092 WebView view = WebView::New();
2093 DALI_TEST_CHECK(view);
2095 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2096 DALI_TEST_CHECK(settings != 0);
2099 settings->AllowMixedContents(false);
2100 settings->EnableSpatialNavigation(false);
2101 settings->EnableWebSecurity(false);
2102 settings->EnableCacheBuilder(false);
2103 settings->EnableDoNotTrack(false);
2104 settings->UseScrollbarThumbFocusNotifications(false);
2105 settings->AllowFileAccessFromExternalUrl(false);
2106 settings->AllowScriptsOpenWindows(false);
2108 // Check default value is true or not
2109 bool value = settings->IsTextAutosizingEnabled();
2110 DALI_TEST_CHECK(value);
2112 // Check Set/GetProperty
2113 settings->EnableTextAutosizing(false);
2114 value = settings->IsTextAutosizingEnabled();
2115 DALI_TEST_CHECK(!value);
2120 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2122 ToolkitTestApplication application;
2124 WebView view = WebView::New();
2125 DALI_TEST_CHECK(view);
2127 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2128 DALI_TEST_CHECK(settings != 0);
2131 settings->AllowMixedContents(false);
2132 settings->EnableSpatialNavigation(false);
2133 settings->EnableWebSecurity(false);
2134 settings->EnableCacheBuilder(false);
2135 settings->EnableDoNotTrack(false);
2136 settings->UseScrollbarThumbFocusNotifications(false);
2137 settings->AllowFileAccessFromExternalUrl(false);
2138 settings->AllowScriptsOpenWindows(false);
2140 // Check default value is true or not
2141 bool value = settings->IsArrowScrollEnabled();
2142 DALI_TEST_CHECK(value);
2144 // Check Set/GetProperty
2145 settings->EnableArrowScroll(false);
2146 value = settings->IsArrowScrollEnabled();
2147 DALI_TEST_CHECK(!value);
2152 int UtcDaliWebSettingsCheckEnableClipboard(void)
2154 ToolkitTestApplication application;
2156 WebView view = WebView::New();
2157 DALI_TEST_CHECK(view);
2159 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2160 DALI_TEST_CHECK(settings != 0);
2163 settings->AllowMixedContents(false);
2164 settings->EnableSpatialNavigation(false);
2165 settings->EnableWebSecurity(false);
2166 settings->EnableCacheBuilder(false);
2167 settings->EnableDoNotTrack(false);
2168 settings->UseScrollbarThumbFocusNotifications(false);
2169 settings->AllowFileAccessFromExternalUrl(false);
2170 settings->AllowScriptsOpenWindows(false);
2172 // Check default value is true or not
2173 bool value = settings->IsClipboardEnabled();
2174 DALI_TEST_CHECK(value);
2175 settings->EnableClipboard(false);
2176 value = settings->IsClipboardEnabled();
2177 DALI_TEST_CHECK(!value);
2181 int UtcDaliWebSettingsCheckEnableImePanel(void)
2183 ToolkitTestApplication application;
2185 WebView view = WebView::New();
2186 DALI_TEST_CHECK(view);
2188 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2189 DALI_TEST_CHECK(settings != 0);
2192 settings->AllowMixedContents(false);
2193 settings->EnableSpatialNavigation(false);
2194 settings->EnableWebSecurity(false);
2195 settings->EnableCacheBuilder(false);
2196 settings->EnableDoNotTrack(false);
2197 settings->UseScrollbarThumbFocusNotifications(false);
2198 settings->AllowFileAccessFromExternalUrl(false);
2199 settings->AllowScriptsOpenWindows(false);
2201 // Check default value is true or not
2202 bool value = settings->IsImePanelEnabled();
2203 DALI_TEST_CHECK(value);
2205 // Check Set/GetProperty
2206 settings->EnableImePanel(false);
2207 value = settings->IsImePanelEnabled();
2208 DALI_TEST_CHECK(!value);
2213 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2215 ToolkitTestApplication application;
2217 WebView view = WebView::New();
2218 DALI_TEST_CHECK(view);
2220 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2221 DALI_TEST_CHECK(settings != 0)
2224 settings->AllowMixedContents(false);
2225 settings->EnableSpatialNavigation(false);
2226 settings->EnableWebSecurity(false);
2227 settings->EnableCacheBuilder(false);
2228 settings->EnableDoNotTrack(false);
2229 settings->UseScrollbarThumbFocusNotifications(false);
2230 settings->AllowFileAccessFromExternalUrl(false);
2231 settings->AllowScriptsOpenWindows(false);
2233 // Check default value is true or not
2234 bool value = settings->AreImagesLoadedAutomatically();
2235 DALI_TEST_CHECK(value);
2237 // Check Set/GetProperty
2238 settings->AllowImagesLoadAutomatically(false);
2239 value = settings->AreImagesLoadedAutomatically();
2240 DALI_TEST_CHECK(!value);
2245 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2247 ToolkitTestApplication application;
2249 WebView view = WebView::New();
2250 DALI_TEST_CHECK(view);
2252 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2253 DALI_TEST_CHECK(settings != 0)
2255 const std::string kDefaultValue;
2256 const std::string kTestValue = "UTF-8";
2259 settings->AllowMixedContents(false);
2260 settings->EnableSpatialNavigation(false);
2261 settings->EnableWebSecurity(false);
2262 settings->EnableCacheBuilder(false);
2263 settings->EnableDoNotTrack(false);
2264 settings->UseScrollbarThumbFocusNotifications(false);
2265 settings->AllowFileAccessFromExternalUrl(false);
2266 settings->AllowScriptsOpenWindows(false);
2268 // Check default value
2269 std::string value = settings->GetDefaultTextEncodingName();
2270 DALI_TEST_EQUALS(value, kDefaultValue, TEST_LOCATION);
2272 // Check Set/GetProperty
2273 settings->SetDefaultTextEncodingName(kTestValue);
2274 value = settings->GetDefaultTextEncodingName();
2275 DALI_TEST_EQUALS(value, kTestValue, TEST_LOCATION);
2280 int UtcDaliWebSettingsSetViewportMetaTag(void)
2282 ToolkitTestApplication application;
2284 WebView view = WebView::New();
2285 DALI_TEST_CHECK(view);
2287 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2288 DALI_TEST_CHECK(settings != 0)
2290 // Check the value is true or not
2291 bool value = settings->SetViewportMetaTag(true);
2292 DALI_TEST_CHECK(value);
2297 int UtcDaliWebSettingsSetForceZoom(void)
2299 ToolkitTestApplication application;
2301 WebView view = WebView::New();
2302 DALI_TEST_CHECK(view);
2304 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2305 DALI_TEST_CHECK(settings != 0)
2307 // Check the value is true or not
2308 bool value = settings->SetForceZoom(true);
2309 DALI_TEST_CHECK(value);
2311 value = settings->IsZoomForced();
2312 DALI_TEST_CHECK(value);
2317 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2319 ToolkitTestApplication application;
2321 WebView view = WebView::New();
2322 DALI_TEST_CHECK(view);
2324 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2325 DALI_TEST_CHECK(settings != 0)
2327 // Check the value is true or not
2328 bool value = settings->SetTextZoomEnabled(true);
2329 DALI_TEST_CHECK(value);
2331 value = settings->IsTextZoomEnabled();
2332 DALI_TEST_CHECK(value);
2337 int UtcDaliWebSettingsSetExtraFeature(void)
2339 ToolkitTestApplication application;
2341 WebView view = WebView::New();
2342 DALI_TEST_CHECK(view);
2344 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2345 DALI_TEST_CHECK(settings != 0)
2347 // Check the value is true or not
2348 settings->SetExtraFeature("test", true);
2349 bool value = settings->IsExtraFeatureEnabled("test");
2350 DALI_TEST_CHECK(value);
2355 int UtcDaliWebViewGetPlainText(void)
2357 ToolkitTestApplication application;
2359 WebView view = WebView::New();
2360 DALI_TEST_CHECK(view);
2362 view.LoadUrl(TEST_URL1);
2364 view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2365 Test::EmitGlobalTimerSignal();
2366 DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);