2 * Copyright (c) 2022 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-context.h>
26 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
27 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
28 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
29 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
30 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
34 #include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
35 #include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
36 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
37 #include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
38 #include <dali/devel-api/adaptor-framework/web-engine-frame.h>
39 #include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
40 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
41 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
42 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
43 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
44 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
45 #include <dali/integration-api/events/hover-event-integ.h>
46 #include <dali/integration-api/events/key-event-integ.h>
47 #include <dali/integration-api/events/touch-event-integ.h>
48 #include <dali/integration-api/events/wheel-event-integ.h>
49 #include <dali/public-api/images/pixel-data.h>
52 using namespace Toolkit;
56 const char* const TEST_URL1("http://www.somewhere.valid1.com");
57 const char* const TEST_URL2("http://www.somewhere.valid2.com");
59 static int gPageLoadStartedCallbackCalled = 0;
60 static int gPageLoadInProgressCallbackCalled = 0;
61 static int gPageLoadFinishedCallbackCalled = 0;
62 static int gPageLoadErrorCallbackCalled = 0;
63 static std::unique_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
64 static int gScrollEdgeReachedCallbackCalled = 0;
65 static int gUrlChangedCallbackCalled = 0;
66 static int gEvaluateJavaScriptCallbackCalled = 0;
67 static int gJavaScriptAlertCallbackCalled = 0;
68 static int gJavaScriptConfirmCallbackCalled = 0;
69 static int gJavaScriptPromptCallbackCalled = 0;
70 static int gScreenshotCapturedCallbackCalled = 0;
71 static int gVideoPlayingCallbackCalled = 0;
72 static int gGeolocationPermissionCallbackCalled = 0;
73 static bool gTouched = false;
74 static bool gHovered = false;
75 static bool gWheelEventHandled = false;
76 static int gFormRepostDecidedCallbackCalled = 0;
77 static std::unique_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecidedInstance = nullptr;
78 static int gFrameRenderedCallbackCalled = 0;
79 static int gConsoleMessageCallbackCalled = 0;
80 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
81 static int gResponsePolicyDecidedCallbackCalled = 0;
82 static int gNavigationPolicyDecidedCallbackCalled = 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 OnUrlChanged(const std::string& url)
154 gUrlChangedCallbackCalled++;
157 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
159 gHitTestCreatedCallbackCalled++;
163 static bool OnPlainTextReceived(const std::string& plainText)
165 gPlainTextReceivedCallbackCalled++;
169 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
171 gPageLoadErrorCallbackCalled++;
172 gPageLoadErrorInstance = std::move(error);
175 static void OnEvaluateJavaScript(const std::string& result)
177 gEvaluateJavaScriptCallbackCalled++;
180 static bool OnJavaScriptAlert(const std::string& result)
182 gJavaScriptAlertCallbackCalled++;
186 static bool OnJavaScriptConfirm(const std::string& result)
188 gJavaScriptConfirmCallbackCalled++;
192 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
194 gJavaScriptPromptCallbackCalled++;
198 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
200 gScreenshotCapturedCallbackCalled++;
203 static void OnVideoPlaying(bool isPlaying)
205 gVideoPlayingCallbackCalled++;
208 static bool OnGeolocationPermission(const std::string&, const std::string&)
210 gGeolocationPermissionCallbackCalled++;
214 static bool OnTouched(Actor actor, const Dali::TouchEvent& touch)
220 static void OnChangesWatch()
222 gCookieManagerChangsWatchCallbackCalled++;
225 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
231 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
233 gWheelEventHandled = true;
237 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
239 gFormRepostDecidedCallbackCalled++;
240 gFormRepostDecidedInstance = std::move(decision);
243 static void OnFrameRendered()
245 gFrameRenderedCallbackCalled++;
248 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
250 gConsoleMessageCallbackCalled++;
251 gConsoleMessageInstance = std::move(message);
254 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
256 gCertificateConfirmCallbackCalled++;
257 gCertificateConfirmInstance = std::move(certificate);
260 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
262 gSslCertificateChangedCallbackCalled++;
263 gSslCertificateInstance = std::move(certificate);
266 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
268 gHttpAuthHandlerCallbackCalled++;
269 gHttpAuthInstance = std::move(hander);
272 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
274 gSecurityOriginsAcquiredCallbackCalled++;
275 gSecurityOriginList.clear();
276 gSecurityOriginList.swap(origins);
279 static void OnStorageUsageAcquired(uint64_t usage)
281 gStorageUsageAcquiredCallbackCalled++;
284 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
286 gFormPasswordsAcquiredCallbackCalled++;
287 gPasswordDataList.clear();
288 gPasswordDataList.swap(passwords);
291 static void OnDownloadStarted(const std::string& url)
293 gDownloadStartedCallbackCalled++;
296 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
298 gMimeOverriddenCallbackCalled++;
302 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
304 gRequestInterceptedCallbackCalled++;
305 gRequestInterceptorInstance = interceptor;
309 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
311 gContextMenuShownCallbackCalled++;
312 gContextMenuShownInstance = std::move(menu);
315 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
317 gContextMenuHiddenCallbackCalled++;
318 gContextMenuHiddenInstance = std::move(menu);
323 void web_view_startup(void)
325 test_return_value = TET_UNDEF;
328 void web_view_cleanup(void)
330 test_return_value = TET_PASS;
333 int UtcDaliWebViewBasics(void)
335 ToolkitTestApplication application;
337 // Copy and Assignment Test
338 tet_infoline("UtcDaliWebViewBasic Copy and Assignment Test");
339 WebView view = WebView::New();
340 DALI_TEST_CHECK(view);
343 DALI_TEST_CHECK(view == copy);
346 DALI_TEST_CHECK(!assign);
349 DALI_TEST_CHECK(assign == view);
352 tet_infoline("UtcDaliWebViewBasic DownCast Test");
353 BaseHandle handle(view);
355 WebView view2 = WebView::DownCast(handle);
356 DALI_TEST_CHECK(view);
357 DALI_TEST_CHECK(view2);
358 DALI_TEST_CHECK(view == view2);
361 tet_infoline("UtcDaliWebViewBasic TypeRegistry Test");
362 TypeRegistry typeRegistry = TypeRegistry::Get();
363 DALI_TEST_CHECK(typeRegistry);
365 TypeInfo typeInfo = typeRegistry.GetTypeInfo("WebView");
366 DALI_TEST_CHECK(typeInfo);
368 BaseHandle handle2 = typeInfo.CreateInstance();
369 DALI_TEST_CHECK(handle2);
371 WebView view3 = WebView::DownCast(handle2);
372 DALI_TEST_CHECK(view3);
377 int UtcDaliWebViewPageNavigation(void)
379 ToolkitTestApplication application;
381 WebView view = WebView::New();
382 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
383 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
384 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
385 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
386 application.GetScene().Add(view);
387 application.SendNotification();
388 application.Render();
389 DALI_TEST_CHECK(view);
391 view.RegisterPageLoadStartedCallback(&OnPageLoadStarted);
392 view.RegisterPageLoadInProgressCallback(&OnPageLoadInProgress);
393 view.RegisterPageLoadFinishedCallback(&OnPageLoadFinished);
394 view.RegisterUrlChangedCallback(&OnUrlChanged);
395 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 0, TEST_LOCATION);
396 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION);
397 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION);
398 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 0, TEST_LOCATION);
400 view.LoadUrl(TEST_URL1);
401 view.GetNaturalSize();
402 Test::EmitGlobalTimerSignal();
403 DALI_TEST_EQUALS(view.CanGoBack(), false, TEST_LOCATION);
404 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 1, TEST_LOCATION);
405 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION);
406 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION);
407 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 1, TEST_LOCATION);
409 view.LoadUrl(TEST_URL2);
411 view.SetProperty(Actor::Property::SIZE, Vector2(400, 300));
412 application.SendNotification();
413 application.Render();
414 Test::EmitGlobalTimerSignal();
416 DALI_TEST_EQUALS(view.CanGoBack(), true, TEST_LOCATION);
417 DALI_TEST_EQUALS(view.CanGoForward(), false, TEST_LOCATION);
418 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 2, TEST_LOCATION);
419 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION);
420 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION);
421 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 2, TEST_LOCATION);
424 Test::EmitGlobalTimerSignal();
425 DALI_TEST_CHECK(!view.CanGoBack());
426 DALI_TEST_CHECK(view.CanGoForward());
429 Test::EmitGlobalTimerSignal();
430 DALI_TEST_CHECK(view.CanGoBack());
431 DALI_TEST_CHECK(!view.CanGoForward());
436 Test::EmitGlobalTimerSignal();
437 DALI_TEST_CHECK(!view.CanGoBack());
438 DALI_TEST_CHECK(!view.CanGoForward());
443 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
445 ToolkitTestApplication application;
447 WebView view = WebView::New();
448 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
449 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
450 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
451 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
452 application.GetScene().Add(view);
453 application.SendNotification();
454 application.Render();
455 DALI_TEST_CHECK(view);
457 view.RegisterPageLoadErrorCallback(&OnPageLoadError);
458 view.RegisterConsoleMessageReceivedCallback(&OnConsoleMessage);
459 DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 0, TEST_LOCATION);
460 DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 0, TEST_LOCATION);
462 view.LoadUrl(TEST_URL1);
463 Test::EmitGlobalTimerSignal();
464 DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 1, TEST_LOCATION);
465 DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 1, TEST_LOCATION);
468 DALI_TEST_CHECK(gPageLoadErrorInstance);
469 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
470 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
471 std::string testErrorDescription("This is an error.");
472 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
473 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
476 DALI_TEST_CHECK(gConsoleMessageInstance);
477 std::string testConsoleSource("source");
478 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
479 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
480 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
481 std::string testConsoleText("This is a text.");
482 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
485 gPageLoadErrorInstance = nullptr;
486 gConsoleMessageInstance = nullptr;
491 int UtcDaliWebViewTouchAndKeys(void)
493 ToolkitTestApplication application;
495 WebView view = WebView::New();
496 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
497 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
498 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
499 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
501 application.GetScene().Add(view);
502 application.SendNotification();
503 application.Render();
505 view.GetNaturalSize();
506 view.TouchedSignal().Connect(&OnTouched);
509 Dali::Integration::TouchEvent event;
510 Dali::Integration::Point pointDown, pointUp;
512 event = Dali::Integration::TouchEvent();
513 pointDown.SetState(PointState::DOWN);
514 pointDown.SetScreenPosition(Vector2(10, 10));
515 event.AddPoint(pointDown);
516 application.ProcessEvent(event);
518 event = Dali::Integration::TouchEvent();
519 pointUp.SetState(PointState::UP);
520 pointUp.SetScreenPosition(Vector2(10, 10));
521 event.AddPoint(pointUp);
522 application.ProcessEvent(event);
525 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor(view);
526 application.ProcessEvent(Integration::KeyEvent("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE));
527 application.SendNotification();
529 DALI_TEST_CHECK(gTouched);
530 DALI_TEST_CHECK(view);
535 int UtcDaliWebViewFocusGainedAndLost(void)
537 ToolkitTestApplication application;
539 WebView view = WebView::New();
540 DALI_TEST_CHECK(view);
542 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
543 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
544 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
545 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
547 application.GetScene().Add(view);
548 application.SendNotification();
549 application.Render();
551 view.SetKeyInputFocus();
552 DALI_TEST_CHECK(view.HasKeyInputFocus());
555 view.ClearKeyInputFocus();
556 DALI_TEST_CHECK(!view.HasKeyInputFocus());
561 int UtcDaliWebViewPropertyPageZoomFactor(void)
563 ToolkitTestApplication application;
565 WebView view = WebView::New();
566 DALI_TEST_CHECK(view);
568 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
569 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
570 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
571 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
573 application.GetScene().Add(view);
574 application.SendNotification();
575 application.Render();
577 view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
578 float zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
579 DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
581 view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
582 zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
583 DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
588 int UtcDaliWebViewPropertyTextZoomFactor(void)
590 ToolkitTestApplication application;
592 WebView view = WebView::New();
593 DALI_TEST_CHECK(view);
595 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
596 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
597 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
598 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
600 application.GetScene().Add(view);
601 application.SendNotification();
602 application.Render();
604 view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
605 float zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
606 DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
608 view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
609 zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
610 DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
615 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
617 ToolkitTestApplication application;
619 WebView view = WebView::New();
620 DALI_TEST_CHECK(view);
622 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
623 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
624 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
625 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
627 application.GetScene().Add(view);
628 application.SendNotification();
629 application.Render();
631 float percentage = view.GetProperty<float>(WebView::Property::LOAD_PROGRESS_PERCENTAGE);
632 DALI_TEST_EQUALS(percentage, 0.5f, TEST_LOCATION);
637 int UtcDaliWebViewMove(void)
639 ToolkitTestApplication application;
641 WebView view = WebView::New();
642 DALI_TEST_CHECK(view);
644 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
645 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
646 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
647 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
649 application.GetScene().Add(view);
650 application.SendNotification();
651 application.Render();
653 view.SetProperty(Actor::Property::POSITION, Vector2(100, 100));
654 Vector3 viewPos = view.GetProperty<Vector3>(Actor::Property::POSITION);
655 DALI_TEST_EQUALS(viewPos, Vector3(100, 100, 0), TEST_LOCATION);
660 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
662 ToolkitTestApplication application;
664 WebView view = WebView::New();
665 DALI_TEST_CHECK(view);
667 const bool kDefaultValue = false;
668 const bool kTestValue = true;
670 // Check default value
672 Property::Value value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
673 DALI_TEST_CHECK(value.Get(output));
674 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
676 // Check Set/GetProperty
677 view.SetProperty(WebView::Property::VIDEO_HOLE_ENABLED, kTestValue);
678 value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
679 DALI_TEST_CHECK(value.Get(output));
680 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
685 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
687 ToolkitTestApplication application;
689 WebView view = WebView::New();
690 DALI_TEST_CHECK(view);
692 const bool kDefaultValue = true;
693 const bool kTestValue = false;
695 // Check default value
697 Property::Value value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
698 DALI_TEST_CHECK(value.Get(output));
699 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
701 // Check Set/GetProperty
702 view.SetProperty(WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue);
703 value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
704 DALI_TEST_CHECK(value.Get(output));
705 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
710 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
712 ToolkitTestApplication application;
714 WebView view = WebView::New();
715 DALI_TEST_CHECK(view);
717 const bool kDefaultValue = true;
718 const bool kTestValue = false;
720 // Check default value
722 Property::Value value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
723 DALI_TEST_CHECK(value.Get(output));
724 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
726 // Check Set/GetProperty
727 view.SetProperty(WebView::Property::KEY_EVENTS_ENABLED, kTestValue);
728 value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
729 DALI_TEST_CHECK(value.Get(output));
730 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
735 int UtcDaliWebViewHoverAndWheel(void)
737 ToolkitTestApplication application;
739 WebView view = WebView::New();
740 DALI_TEST_CHECK(view);
741 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
742 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
743 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
744 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
746 application.GetScene().Add(view);
747 application.SendNotification();
748 application.Render();
750 view.GetNaturalSize();
751 view.HoveredSignal().Connect(&OnHovered);
752 view.WheelEventSignal().Connect(&OnWheelEvent);
755 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
756 Dali::Integration::Point pointDown;
757 pointDown.SetState(PointState::DOWN);
758 pointDown.SetScreenPosition(Vector2(10, 10));
759 event.AddPoint(pointDown);
760 application.ProcessEvent(event);
762 event = Dali::Integration::HoverEvent();
763 Dali::Integration::Point pointUp;
764 pointUp.SetState(PointState::UP);
765 pointUp.SetScreenPosition(Vector2(10, 10));
766 event.AddPoint(pointUp);
767 application.ProcessEvent(event);
769 event = Dali::Integration::HoverEvent();
770 Dali::Integration::Point pointMotion;
771 pointUp.SetState(PointState::MOTION);
772 pointUp.SetScreenPosition(Vector2(10, 10));
773 event.AddPoint(pointMotion);
774 application.ProcessEvent(event);
777 Dali::Integration::WheelEvent wheelEvent;
778 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
779 wheelEvent.direction = 0;
780 wheelEvent.point = Vector2(20, 20);
781 wheelEvent.delta = 10;
782 application.ProcessEvent(wheelEvent);
783 application.SendNotification();
785 DALI_TEST_CHECK(gHovered);
786 DALI_TEST_CHECK(gWheelEventHandled);
791 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
793 ToolkitTestApplication application;
795 WebView view = WebView::New();
796 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
797 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
798 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
799 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
800 application.GetScene().Add(view);
801 application.SendNotification();
802 application.Render();
803 DALI_TEST_CHECK(view);
805 view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
806 view.RegisterFrameRenderedCallback(&OnFrameRendered);
807 DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION);
808 DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 0, TEST_LOCATION);
810 view.LoadUrl(TEST_URL1);
811 Test::EmitGlobalTimerSignal();
812 DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION);
813 DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 1, TEST_LOCATION);
815 // form repost decision.
816 DALI_TEST_CHECK(gFormRepostDecidedInstance);
817 gFormRepostDecidedInstance->Reply(true);
820 gFormRepostDecidedInstance = nullptr;
825 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
827 ToolkitTestApplication application;
829 WebView view = WebView::New();
830 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
831 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
832 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
833 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
834 application.GetScene().Add(view);
835 application.SendNotification();
836 application.Render();
837 DALI_TEST_CHECK(view);
839 view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
840 view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
841 view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
842 DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 0, TEST_LOCATION);
843 DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION);
844 DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION);
846 view.LoadUrl(TEST_URL1);
847 Test::EmitGlobalTimerSignal();
848 DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 1, TEST_LOCATION);
849 DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION);
850 DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION);
853 DALI_TEST_CHECK(gCertificateConfirmInstance);
854 gCertificateConfirmInstance->Allow(true);
855 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
857 DALI_TEST_CHECK(gSslCertificateInstance);
858 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
859 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
861 // http authentication.
862 DALI_TEST_CHECK(gHttpAuthInstance);
863 gHttpAuthInstance->Suspend();
864 gHttpAuthInstance->UseCredential("", "");
865 gHttpAuthInstance->CancelCredential();
866 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
869 gCertificateConfirmInstance = nullptr;
870 gSslCertificateInstance = nullptr;
871 gHttpAuthInstance = nullptr;
876 int UtcDaliWebViewGetWebBackForwardList(void)
878 ToolkitTestApplication application;
880 WebView view = WebView::New();
881 DALI_TEST_CHECK(view);
883 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
884 DALI_TEST_CHECK(bfList != 0);
889 int UtcDaliWebViewGetWebContext(void)
891 ToolkitTestApplication application;
893 WebView view = WebView::New();
894 DALI_TEST_CHECK(view);
896 Dali::Toolkit::WebContext* context = view.GetContext();
897 DALI_TEST_CHECK(context != 0);
902 int UtcDaliWebViewGetWebCookieManager(void)
904 ToolkitTestApplication application;
906 WebView view = WebView::New();
907 DALI_TEST_CHECK(view);
909 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
910 DALI_TEST_CHECK(cookieManager != 0);
915 int UtcDaliWebViewGetWebSettings(void)
917 ToolkitTestApplication application;
919 WebView view = WebView::New();
920 DALI_TEST_CHECK(view);
922 Dali::Toolkit::WebSettings* settings = view.GetSettings();
923 DALI_TEST_CHECK(settings != 0);
928 int UtcDaliWebViewProperty1(void)
931 ToolkitTestApplication application;
933 WebView view = WebView::New();
934 DALI_TEST_CHECK(view);
937 view.SetProperty(WebView::Property::URL, TEST_URL1);
938 Property::Value val = view.GetProperty(WebView::Property::URL);
939 DALI_TEST_CHECK(val.Get(local));
940 DALI_TEST_EQUALS(local, TEST_URL1, TEST_LOCATION);
945 int UtcDaliWebViewProperty4(void)
948 ToolkitTestApplication application;
950 WebView view = WebView::New();
951 DALI_TEST_CHECK(view);
953 const std::string kDefaultValue;
954 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";
956 // Check default value
958 Property::Value value = view.GetProperty(WebView::Property::USER_AGENT);
959 DALI_TEST_CHECK(value.Get(output));
960 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
962 // Check Set/GetProperty
963 view.SetProperty(WebView::Property::USER_AGENT, kTestValue);
964 value = view.GetProperty(WebView::Property::USER_AGENT);
965 DALI_TEST_CHECK(value.Get(output));
966 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
971 int UtcDaliWebViewProperty9(void)
974 ToolkitTestApplication application;
976 WebView view = WebView::New();
977 DALI_TEST_CHECK(view);
979 // Check default value
980 Dali::Vector2 output = Dali::Vector2::ONE;
981 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
982 DALI_TEST_CHECK(output.x == 0 && output.y == 0);
984 // Check Set/GetProperty
985 Dali::Vector2 testValue = Dali::Vector2(100, 100);
986 view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
987 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
988 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
990 // Check default value of scroll size
991 output = Dali::Vector2::ONE;
992 view.GetProperty(WebView::Property::SCROLL_SIZE).Get(output);
993 DALI_TEST_CHECK(output.x == 500 && output.y == 500);
995 // Check default value of content size
996 output = Dali::Vector2::ONE;
997 view.GetProperty(WebView::Property::CONTENT_SIZE).Get(output);
998 DALI_TEST_CHECK(output.x == 500 && output.y == 500);
1003 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1005 ToolkitTestApplication application;
1007 WebView view = WebView::New();
1008 DALI_TEST_CHECK(view);
1010 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1011 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1012 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1013 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1014 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1016 // Check default value
1017 std::string testText("test");
1019 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1020 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1025 int UtcDaliWebViewPropertyTitleFavicon(void)
1027 ToolkitTestApplication application;
1029 char argv[] = "--test";
1030 WebView view = WebView::New(1, (char**)&argv);
1031 DALI_TEST_CHECK(view);
1034 view.ClearAllTilesResources();
1036 // Check default value of title
1037 std::string testValue("title");
1039 view.GetProperty(WebView::Property::TITLE).Get(output);
1040 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1042 // Check the case that favicon is not null.
1043 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1044 DALI_TEST_CHECK(favicon);
1045 Dali::Vector3 iconsize = favicon.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1046 DALI_TEST_CHECK((int)iconsize.width == 2 && (int)iconsize.height == 2);
1048 // Check the case that favicon is null.
1049 favicon = view.GetFavicon();
1050 DALI_TEST_CHECK(!favicon);
1055 int UtcDaliWebViewContextMenuShownAndHidden(void)
1057 ToolkitTestApplication application;
1059 WebView view = WebView::New();
1060 DALI_TEST_CHECK(view);
1063 view.RegisterContextMenuShownCallback(&OnContextMenuShown);
1064 view.RegisterContextMenuHiddenCallback(&OnContextMenuHidden);
1065 DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 0, TEST_LOCATION);
1066 DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION);
1067 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1068 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1070 view.LoadUrl(TEST_URL1);
1071 Test::EmitGlobalTimerSignal();
1072 DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 1, TEST_LOCATION);
1073 DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION);
1075 // check context meun & its items.
1076 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1077 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1078 DALI_TEST_CHECK(item.get() != 0);
1079 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1080 DALI_TEST_CHECK(itemList.size() == 1);
1081 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1082 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1083 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1084 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1085 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1087 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1088 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1089 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1090 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1091 DALI_TEST_CHECK(item->IsEnabled());
1092 std::string testLinkUrl("http://test.html");
1093 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1094 std::string testImageUrl("http://test.jpg");
1095 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1096 std::string testTitle("title");
1097 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1098 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1100 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1102 gContextMenuShownInstance = nullptr;
1103 gContextMenuHiddenInstance = nullptr;
1108 int UtcDaliWebViewScrollBy(void)
1110 ToolkitTestApplication application;
1112 WebView view = WebView::New();
1113 DALI_TEST_CHECK(view);
1116 view.RegisterScrollEdgeReachedCallback(&OnScrollEdgeReached);
1117 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION);
1119 view.LoadUrl(TEST_URL1);
1120 Test::EmitGlobalTimerSignal();
1122 // set scroll position.
1123 Dali::Vector2 output = Dali::Vector2::ONE;
1124 Dali::Vector2 testValue = Dali::Vector2(100, 100);
1125 view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
1126 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1127 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1129 // scroll by and trigger scrollEdgeReached event.
1130 view.ScrollBy(50, 50);
1131 Test::EmitGlobalTimerSignal();
1133 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1134 DALI_TEST_CHECK(output.x == 150 && output.y == 150);
1135 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION);
1137 // scroll by and trigger scrollEdgeReached event.
1138 bool result = view.ScrollEdgeBy(50, 50);
1139 DALI_TEST_CHECK(result);
1140 Test::EmitGlobalTimerSignal();
1142 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1143 DALI_TEST_CHECK(output.x == 200 && output.y == 200);
1144 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION);
1149 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1151 ToolkitTestApplication application;
1153 WebView view = WebView::New();
1154 DALI_TEST_CHECK(view);
1156 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1157 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1158 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1159 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1161 application.GetScene().Add(view);
1162 application.SendNotification();
1163 application.Render();
1165 view.ActivateAccessibility(true);
1166 view.AddDynamicCertificatePath("host", "test/to/path");
1167 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1168 DALI_TEST_CHECK(found);
1170 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1171 float result = view.GetScaleFactor();
1172 DALI_TEST_EQUALS(result, 1.5f, TEST_LOCATION);
1174 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1175 result = view.GetScaleFactor();
1176 DALI_TEST_EQUALS(result, 1.0f, TEST_LOCATION);
1181 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1184 ToolkitTestApplication application;
1186 char argv[] = "--test";
1187 WebView view = WebView::New(1, (char**)&argv);
1188 DALI_TEST_CHECK(view);
1190 // Check GetScreenshot
1191 Dali::Rect<int> viewArea;
1194 viewArea.width = 10;
1195 viewArea.height = 10;
1196 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1197 DALI_TEST_CHECK(screenshot);
1198 Dali::Vector3 shotsize = screenshot.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1199 DALI_TEST_CHECK((int)shotsize.width == viewArea.width && (int)shotsize.height == viewArea.height);
1201 // Check GetScreenshotAsynchronously
1204 viewArea.width = 100;
1205 viewArea.height = 100;
1206 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1207 DALI_TEST_CHECK(result);
1209 Test::EmitGlobalTimerSignal();
1211 Test::EmitGlobalTimerSignal();
1212 DALI_TEST_EQUALS(gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION);
1217 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1220 ToolkitTestApplication application;
1222 char argv[] = "--test";
1223 WebView view = WebView::New(1, (char**)&argv);
1224 DALI_TEST_CHECK(view);
1226 // Check CheckVideoPlayingAsynchronously
1227 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1228 DALI_TEST_CHECK(result);
1229 Test::EmitGlobalTimerSignal();
1230 DALI_TEST_EQUALS(gVideoPlayingCallbackCalled, 1, TEST_LOCATION);
1232 // Check RegisterGeolocationPermissionCallback
1233 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1234 Test::EmitGlobalTimerSignal();
1235 DALI_TEST_EQUALS(gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION);
1240 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1242 ToolkitTestApplication application;
1244 WebView view = WebView::New();
1245 DALI_TEST_CHECK(view);
1248 view.RegisterResponsePolicyDecidedCallback(&OnResponsePolicyDecided);
1249 DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1250 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1252 view.LoadUrl(TEST_URL1);
1253 Test::EmitGlobalTimerSignal();
1254 DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1256 // check response policy decision & its frame.
1257 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1258 std::string testUrl("http://test.html");
1259 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1260 std::string testCookie("test:abc");
1261 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1262 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1263 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1264 std::string testResponseMime("txt/xml");
1265 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1266 int32_t ResponseStatusCode = 500;
1267 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1268 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1269 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1270 std::string testScheme("test");
1271 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1272 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1273 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1274 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1276 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1277 DALI_TEST_CHECK(webFrame);
1278 DALI_TEST_CHECK(webFrame->IsMainFrame());
1280 gResponsePolicyDecisionInstance = nullptr;
1285 int UtcDaliWebViewNavigationPolicyDecisionRequest(void)
1287 ToolkitTestApplication application;
1289 WebView view = WebView::New();
1290 DALI_TEST_CHECK(view);
1293 view.RegisterNavigationPolicyDecidedCallback(&OnNavigationPolicyDecided);
1294 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1296 view.LoadUrl(TEST_URL1);
1297 Test::EmitGlobalTimerSignal();
1298 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1303 int UtcDaliWebViewHitTest(void)
1305 ToolkitTestApplication application;
1307 WebView view = WebView::New();
1308 DALI_TEST_CHECK(view);
1311 view.LoadUrl(TEST_URL1);
1314 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1315 DALI_TEST_CHECK(hitTest != 0);
1316 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1317 std::string testLinkUri("http://test.html");
1318 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1319 std::string testLinkTitle("test");
1320 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1321 std::string testLinkLabel("label");
1322 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1323 std::string testImageUri("http://test.jpg");
1324 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1325 std::string testMediaUri("http://test.mp4");
1326 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1327 std::string testTagName("img");
1328 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1329 std::string testNodeValue("test");
1330 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1331 Dali::Property::Map testMap = hitTest->GetAttributes();
1332 DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
1333 std::string testImageFileNameExtension("jpg");
1334 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1335 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1336 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1339 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1340 DALI_TEST_CHECK(result);
1341 Test::EmitGlobalTimerSignal();
1342 DALI_TEST_EQUALS(gHitTestCreatedCallbackCalled, 1, TEST_LOCATION);
1347 int UtcDaliWebViewEvaluteJavaScript(void)
1349 ToolkitTestApplication application;
1351 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1353 view.LoadHtmlString("<body>Hello World!</body>");
1354 view.EvaluateJavaScript("jsObject.postMessage('Hello')");
1355 view.EvaluateJavaScript("jsObject.postMessage('World')", OnEvaluateJavaScript);
1356 Test::EmitGlobalTimerSignal();
1358 DALI_TEST_EQUALS(gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION);
1363 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1365 ToolkitTestApplication application;
1367 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1369 view.RegisterJavaScriptAlertCallback(&OnJavaScriptAlert);
1370 view.LoadHtmlString("<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>");
1371 view.JavaScriptAlertReply();
1372 Test::EmitGlobalTimerSignal();
1373 DALI_TEST_EQUALS(gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION);
1375 view.RegisterJavaScriptConfirmCallback(&OnJavaScriptConfirm);
1376 view.LoadHtmlString("<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>");
1377 view.JavaScriptConfirmReply(true);
1378 Test::EmitGlobalTimerSignal();
1379 DALI_TEST_EQUALS(gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION);
1381 view.RegisterJavaScriptPromptCallback(&OnJavaScriptPrompt);
1382 view.LoadHtmlString("<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>");
1383 view.JavaScriptPromptReply("it is a prompt.");
1384 Test::EmitGlobalTimerSignal();
1385 DALI_TEST_EQUALS(gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION);
1390 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1392 ToolkitTestApplication application;
1394 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1395 DALI_TEST_CHECK(view);
1397 std::string html("<body>Hello World!</body>");
1398 std::string basicUri("http://basicurl");
1399 std::string unreachableUrl("http://unreachableurl");
1400 bool result = view.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
1401 DALI_TEST_CHECK(result);
1403 application.SendNotification();
1404 application.Render();
1405 Test::EmitGlobalTimerSignal();
1407 result = view.LoadContents(html, html.length(), "html/text", "utf-8", basicUri);
1408 DALI_TEST_CHECK(result);
1413 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1415 ToolkitTestApplication application;
1417 WebView view = WebView::New();
1418 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1419 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1420 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1421 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1423 application.GetScene().Add(view);
1424 application.SendNotification();
1425 application.Render();
1426 DALI_TEST_CHECK(view);
1428 view.LoadUrl("http://test.html");
1429 bool result = view.AddCustomHeader("key", "value");
1430 DALI_TEST_CHECK(result);
1432 result = view.ReloadWithoutCache();
1433 DALI_TEST_CHECK(result);
1435 uint32_t portNumber = view.StartInspectorServer(5000);
1436 DALI_TEST_EQUALS(portNumber, 5000, TEST_LOCATION);
1438 application.SendNotification();
1439 application.Render();
1440 Test::EmitGlobalTimerSignal();
1442 result = view.StopInspectorServer();
1443 DALI_TEST_CHECK(result);
1445 view.SuspendNetworkLoading();
1447 result = view.RemoveCustomHeader("key");
1448 DALI_TEST_CHECK(result);
1450 view.ResumeNetworkLoading();
1455 int UtcDaliWebViewMethodsForCoverage(void)
1457 ToolkitTestApplication application;
1459 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1461 view.LoadHtmlString("<body>Hello World!</body>");
1462 view.AddJavaScriptMessageHandler("jsObject",
1463 [](const std::string& arg) {
1465 view.SetTtsFocus(true);
1467 DALI_TEST_CHECK(view);
1472 // test cases for web backforward list.
1474 int UtcDaliWebBackForwardListCheckItem(void)
1476 ToolkitTestApplication application;
1478 WebView view = WebView::New();
1479 DALI_TEST_CHECK(view);
1481 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1482 DALI_TEST_CHECK(bfList != 0)
1484 unsigned int itemCount = bfList->GetItemCount();
1485 DALI_TEST_CHECK(itemCount == 1)
1487 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1488 DALI_TEST_CHECK(citem != 0);
1490 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1491 DALI_TEST_CHECK(citemP != 0);
1493 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1494 DALI_TEST_CHECK(citemN != 0);
1496 const std::string kDefaultUrl("http://url");
1497 std::string testValue = citem->GetUrl();
1498 DALI_TEST_EQUALS(testValue, kDefaultUrl, TEST_LOCATION);
1500 const std::string kDefaultTitle("title");
1501 testValue = citem->GetTitle();
1502 DALI_TEST_EQUALS(testValue, kDefaultTitle, TEST_LOCATION);
1504 const std::string kDefaultOriginalUrl("http://originalurl");
1505 testValue = citem->GetOriginalUrl();
1506 DALI_TEST_EQUALS(testValue, kDefaultOriginalUrl, TEST_LOCATION);
1508 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex(0);
1509 DALI_TEST_CHECK(item != 0);
1511 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1512 DALI_TEST_CHECK(vecBack.size() == 1);
1514 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1515 DALI_TEST_CHECK(vecForward.size() == 1);
1520 // test cases for web context.
1522 int UtcDaliWebContextGetSetCacheModel(void)
1524 ToolkitTestApplication application;
1526 WebView view = WebView::New();
1527 DALI_TEST_CHECK(view);
1529 Dali::Toolkit::WebContext* context = view.GetContext();
1530 DALI_TEST_CHECK(context != 0)
1532 std::string kDefaultValue;
1535 context->SetAppId("id");
1536 context->SetApplicationType(Dali::WebEngineContext::ApplicationType::OTHER);
1537 context->SetTimeOffset(0);
1538 context->SetTimeZoneOffset(0, 0);
1539 context->SetDefaultProxyAuth(kDefaultValue, kDefaultValue);
1540 context->DeleteAllWebDatabase();
1541 context->DeleteAllWebStorage();
1542 context->DeleteLocalFileSystem();
1543 context->ClearCache();
1544 context->DeleteAllFormPasswordData();
1545 context->DeleteAllFormCandidateData();
1547 // Check default value
1548 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1549 DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER);
1551 // Check Set/GetProperty
1552 context->SetCacheModel(Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1553 value = context->GetCacheModel();
1554 DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1556 // Get cache enabled
1557 context->EnableCache(true);
1558 DALI_TEST_CHECK(context->IsCacheEnabled());
1561 context->SetCertificateFilePath("test");
1562 std::string str = context->GetCertificateFilePath();
1563 DALI_TEST_EQUALS(str, "test", TEST_LOCATION);
1566 DALI_TEST_CHECK(context->SetAppVersion("test"));
1569 std::vector<std::string> temp;
1570 context->RegisterUrlSchemesAsCorsEnabled(temp);
1571 context->RegisterJsPluginMimeTypes(temp);
1572 context->DeleteFormPasswordDataList(temp);
1575 context->SetDefaultZoomFactor(1.0f);
1576 DALI_TEST_EQUALS(context->GetDefaultZoomFactor(), float(1.0f), TEST_LOCATION);
1578 // Delete cache and database
1579 DALI_TEST_CHECK(context->DeleteAllApplicationCache());
1580 DALI_TEST_CHECK(context->DeleteAllWebIndexedDatabase());
1583 context->SetProxyUri("test");
1584 DALI_TEST_EQUALS(context->GetProxyUri(), "test", TEST_LOCATION);
1585 context->SetProxyBypassRule("", "test");
1586 DALI_TEST_EQUALS(context->GetProxyBypassRule(), "test", TEST_LOCATION);
1589 DALI_TEST_CHECK(context->FreeUnusedMemory());
1594 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1596 ToolkitTestApplication application;
1598 WebView view = WebView::New();
1599 DALI_TEST_CHECK(view);
1601 Dali::Toolkit::WebContext* context = view.GetContext();
1602 DALI_TEST_CHECK(context != 0)
1604 std::string kDefaultValue;
1606 // get origins of web database
1607 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1608 DALI_TEST_CHECK(result);
1610 Test::EmitGlobalTimerSignal();
1611 DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION);
1612 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1614 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1615 DALI_TEST_CHECK(origin);
1617 result = context->DeleteWebDatabase(*origin);
1618 DALI_TEST_CHECK(result);
1620 // get origins of web storage
1621 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1622 DALI_TEST_CHECK(result);
1624 Test::EmitGlobalTimerSignal();
1625 DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION);
1626 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1628 origin = gSecurityOriginList[0].get();
1629 DALI_TEST_CHECK(origin);
1631 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1632 DALI_TEST_CHECK(result);
1633 Test::EmitGlobalTimerSignal();
1634 DALI_TEST_EQUALS(gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION);
1636 result = context->DeleteWebStorage(*origin);
1637 DALI_TEST_CHECK(result);
1639 result = context->DeleteApplicationCache(*origin);
1640 DALI_TEST_CHECK(result);
1642 // form passwords, download state, mime type.
1643 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1644 Test::EmitGlobalTimerSignal();
1645 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1646 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1647 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1648 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1650 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1651 Test::EmitGlobalTimerSignal();
1652 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1654 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1655 Test::EmitGlobalTimerSignal();
1656 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1658 gSecurityOriginList.clear();
1659 gPasswordDataList.clear();
1664 int UtcDaliWebContextHttpRequestInterceptor(void)
1666 ToolkitTestApplication application;
1668 WebView view = WebView::New();
1669 DALI_TEST_CHECK(view);
1671 Dali::Toolkit::WebContext* context = view.GetContext();
1672 DALI_TEST_CHECK(context != 0)
1675 context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1676 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1677 DALI_TEST_CHECK(!gRequestInterceptorInstance);
1679 Test::EmitGlobalTimerSignal();
1680 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 1, TEST_LOCATION);
1682 // check request interceptor.
1683 DALI_TEST_CHECK(gRequestInterceptorInstance);
1684 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1685 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1686 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
1687 Dali::Property::Map testHeaders;
1688 testHeaders.Insert("key2", "value2");
1689 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
1690 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody((const int8_t*)"test", 4));
1691 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", (const int8_t*)"test", 4));
1692 DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk((const int8_t*)"test", 4));
1693 std::string testUrl("http://test.html");
1694 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1695 std::string testMethod("GET");
1696 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
1697 Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
1698 DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
1700 gRequestInterceptorInstance = nullptr;
1705 // test cases for web cookie manager.
1707 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1709 ToolkitTestApplication application;
1711 WebView view = WebView::New();
1712 DALI_TEST_CHECK(view);
1714 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1715 DALI_TEST_CHECK(cookieManager != 0)
1717 const std::string kDefaultValue;
1720 cookieManager->SetPersistentStorage(kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE);
1721 cookieManager->ClearCookies();
1723 // Check default value
1724 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1725 DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY);
1727 // Check Set/GetProperty
1728 cookieManager->SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1729 value = cookieManager->GetCookieAcceptPolicy();
1730 DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1735 int UtcDaliWebCookieManagerChangesWatch(void)
1737 ToolkitTestApplication application;
1739 WebView view = WebView::New();
1740 DALI_TEST_CHECK(view);
1742 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1743 DALI_TEST_CHECK(cookieManager != 0)
1745 cookieManager->ChangesWatch(&OnChangesWatch);
1746 Test::EmitGlobalTimerSignal();
1747 DALI_TEST_EQUALS(gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION);
1752 // test cases for web settings.
1754 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1756 ToolkitTestApplication application;
1758 WebView view = WebView::New();
1759 DALI_TEST_CHECK(view);
1761 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1762 DALI_TEST_CHECK(settings != 0)
1765 settings->AllowMixedContents(false);
1766 settings->EnableSpatialNavigation(false);
1767 settings->EnableWebSecurity(false);
1768 settings->EnableCacheBuilder(false);
1769 settings->EnableDoNotTrack(false);
1770 settings->UseScrollbarThumbFocusNotifications(false);
1771 settings->AllowFileAccessFromExternalUrl(false);
1772 settings->AllowScriptsOpenWindows(false);
1774 // Check default value
1775 int value = settings->GetDefaultFontSize();
1776 DALI_TEST_CHECK(value == 16);
1778 // Check Set/GetProperty
1779 settings->SetDefaultFontSize(20);
1780 value = settings->GetDefaultFontSize();
1781 DALI_TEST_CHECK(value == 20);
1786 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1788 ToolkitTestApplication application;
1790 WebView view = WebView::New();
1791 DALI_TEST_CHECK(view);
1793 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1794 DALI_TEST_CHECK(settings != 0)
1797 settings->AllowMixedContents(false);
1798 settings->EnableSpatialNavigation(false);
1799 settings->EnableWebSecurity(false);
1800 settings->EnableCacheBuilder(false);
1801 settings->EnableDoNotTrack(false);
1802 settings->UseScrollbarThumbFocusNotifications(false);
1803 settings->AllowFileAccessFromExternalUrl(false);
1804 settings->AllowScriptsOpenWindows(false);
1806 // Check default value is true or not
1807 bool value = settings->IsJavaScriptEnabled();
1808 DALI_TEST_CHECK(value);
1810 // Check Set/GetProperty
1811 settings->EnableJavaScript(false);
1812 value = settings->IsJavaScriptEnabled();
1813 DALI_TEST_CHECK(!value);
1818 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1820 ToolkitTestApplication application;
1822 WebView view = WebView::New();
1823 DALI_TEST_CHECK(view);
1825 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1826 DALI_TEST_CHECK(settings != 0)
1829 settings->AllowMixedContents(false);
1830 settings->EnableSpatialNavigation(false);
1831 settings->EnableWebSecurity(false);
1832 settings->EnableCacheBuilder(false);
1833 settings->EnableDoNotTrack(false);
1834 settings->UseScrollbarThumbFocusNotifications(false);
1835 settings->AllowFileAccessFromExternalUrl(false);
1836 settings->AllowScriptsOpenWindows(false);
1838 // Check default value is true or not
1839 bool value = settings->IsAutoFittingEnabled();
1840 DALI_TEST_CHECK(value);
1842 // Check Set/GetProperty
1843 settings->EnableAutoFitting(false);
1844 value = settings->IsAutoFittingEnabled();
1845 DALI_TEST_CHECK(!value);
1850 int UtcDaliWebSettingsCheckEnablePlugins(void)
1852 ToolkitTestApplication application;
1854 WebView view = WebView::New();
1855 DALI_TEST_CHECK(view);
1857 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1858 DALI_TEST_CHECK(settings != 0)
1861 settings->AllowMixedContents(false);
1862 settings->EnableSpatialNavigation(false);
1863 settings->EnableWebSecurity(false);
1864 settings->EnableCacheBuilder(false);
1865 settings->EnableDoNotTrack(false);
1866 settings->UseScrollbarThumbFocusNotifications(false);
1867 settings->AllowFileAccessFromExternalUrl(false);
1868 settings->AllowScriptsOpenWindows(false);
1870 // Check default value is true or not
1871 bool value = settings->ArePluginsEnabled();
1872 DALI_TEST_CHECK(value);
1874 // Check Set/GetProperty
1875 settings->EnablePlugins(false);
1876 value = settings->ArePluginsEnabled();
1877 DALI_TEST_CHECK(!value);
1882 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1884 ToolkitTestApplication application;
1886 WebView view = WebView::New();
1887 DALI_TEST_CHECK(view);
1889 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1890 DALI_TEST_CHECK(settings != 0)
1893 settings->AllowMixedContents(false);
1894 settings->EnableSpatialNavigation(false);
1895 settings->EnableWebSecurity(false);
1896 settings->EnableCacheBuilder(false);
1897 settings->EnableDoNotTrack(false);
1898 settings->UseScrollbarThumbFocusNotifications(false);
1899 settings->AllowFileAccessFromExternalUrl(false);
1900 settings->AllowScriptsOpenWindows(false);
1902 // Check default value is true or not
1903 bool value = settings->IsPrivateBrowsingEnabled();
1904 DALI_TEST_CHECK(value);
1906 // Check Set/GetProperty
1907 settings->EnablePrivateBrowsing(false);
1908 value = settings->IsPrivateBrowsingEnabled();
1909 DALI_TEST_CHECK(!value);
1914 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1916 ToolkitTestApplication application;
1918 WebView view = WebView::New();
1919 DALI_TEST_CHECK(view);
1921 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1922 DALI_TEST_CHECK(settings != 0)
1925 settings->AllowMixedContents(false);
1926 settings->EnableSpatialNavigation(false);
1927 settings->EnableWebSecurity(false);
1928 settings->EnableCacheBuilder(false);
1929 settings->EnableDoNotTrack(false);
1930 settings->UseScrollbarThumbFocusNotifications(false);
1931 settings->AllowFileAccessFromExternalUrl(false);
1932 settings->AllowScriptsOpenWindows(false);
1934 // Check default value is true or not
1935 bool value = settings->IsLinkMagnifierEnabled();
1936 DALI_TEST_CHECK(value);
1938 // Check Set/GetProperty
1939 settings->EnableLinkMagnifier(false);
1940 value = settings->IsLinkMagnifierEnabled();
1941 DALI_TEST_CHECK(!value);
1946 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1948 ToolkitTestApplication application;
1950 WebView view = WebView::New();
1951 DALI_TEST_CHECK(view);
1953 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1954 DALI_TEST_CHECK(settings != 0)
1957 settings->AllowMixedContents(false);
1958 settings->EnableSpatialNavigation(false);
1959 settings->EnableWebSecurity(false);
1960 settings->EnableCacheBuilder(false);
1961 settings->EnableDoNotTrack(false);
1962 settings->UseScrollbarThumbFocusNotifications(false);
1963 settings->AllowFileAccessFromExternalUrl(false);
1964 settings->AllowScriptsOpenWindows(false);
1966 // Check default value is true or not
1967 bool value = settings->IsKeypadWithoutUserActionUsed();
1968 DALI_TEST_CHECK(value);
1970 // Check Set/GetProperty
1971 settings->UseKeypadWithoutUserAction(false);
1972 value = settings->IsKeypadWithoutUserActionUsed();
1973 DALI_TEST_CHECK(!value);
1978 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1980 ToolkitTestApplication application;
1982 WebView view = WebView::New();
1983 DALI_TEST_CHECK(view);
1985 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1986 DALI_TEST_CHECK(settings != 0)
1989 settings->AllowMixedContents(false);
1990 settings->EnableSpatialNavigation(false);
1991 settings->EnableWebSecurity(false);
1992 settings->EnableCacheBuilder(false);
1993 settings->EnableDoNotTrack(false);
1994 settings->UseScrollbarThumbFocusNotifications(false);
1995 settings->AllowFileAccessFromExternalUrl(false);
1996 settings->AllowScriptsOpenWindows(false);
1998 // Check default value is true or not
1999 bool value = settings->IsAutofillPasswordFormEnabled();
2000 DALI_TEST_CHECK(value);
2001 settings->EnableAutofillPasswordForm(false);
2002 value = settings->IsAutofillPasswordFormEnabled();
2003 DALI_TEST_CHECK(!value);
2007 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
2009 ToolkitTestApplication application;
2011 WebView view = WebView::New();
2012 DALI_TEST_CHECK(view);
2014 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2015 DALI_TEST_CHECK(settings != 0);
2018 settings->AllowMixedContents(false);
2019 settings->EnableSpatialNavigation(false);
2020 settings->EnableWebSecurity(false);
2021 settings->EnableCacheBuilder(false);
2022 settings->EnableDoNotTrack(false);
2023 settings->UseScrollbarThumbFocusNotifications(false);
2024 settings->AllowFileAccessFromExternalUrl(false);
2025 settings->AllowScriptsOpenWindows(false);
2027 // Check default value is true or not
2028 bool value = settings->IsFormCandidateDataEnabled();
2029 DALI_TEST_CHECK(value);
2031 // Check Set/GetProperty
2032 settings->EnableFormCandidateData(false);
2033 value = settings->IsFormCandidateDataEnabled();
2034 DALI_TEST_CHECK(!value);
2039 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2041 ToolkitTestApplication application;
2043 WebView view = WebView::New();
2044 DALI_TEST_CHECK(view);
2046 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2047 DALI_TEST_CHECK(settings != 0);
2050 settings->AllowMixedContents(false);
2051 settings->EnableSpatialNavigation(false);
2052 settings->EnableWebSecurity(false);
2053 settings->EnableCacheBuilder(false);
2054 settings->EnableDoNotTrack(false);
2055 settings->UseScrollbarThumbFocusNotifications(false);
2056 settings->AllowFileAccessFromExternalUrl(false);
2057 settings->AllowScriptsOpenWindows(false);
2059 // Check default value is true or not
2060 bool value = settings->IsTextSelectionEnabled();
2061 DALI_TEST_CHECK(value);
2063 //Check Set/GetProperty
2064 settings->EnableTextSelection(false);
2065 value = settings->IsTextSelectionEnabled();
2066 DALI_TEST_CHECK(!value);
2071 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2073 ToolkitTestApplication application;
2075 WebView view = WebView::New();
2076 DALI_TEST_CHECK(view);
2078 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2079 DALI_TEST_CHECK(settings != 0);
2082 settings->AllowMixedContents(false);
2083 settings->EnableSpatialNavigation(false);
2084 settings->EnableWebSecurity(false);
2085 settings->EnableCacheBuilder(false);
2086 settings->EnableDoNotTrack(false);
2087 settings->UseScrollbarThumbFocusNotifications(false);
2088 settings->AllowFileAccessFromExternalUrl(false);
2089 settings->AllowScriptsOpenWindows(false);
2091 // Check default value is true or not
2092 bool value = settings->IsTextAutosizingEnabled();
2093 DALI_TEST_CHECK(value);
2095 // Check Set/GetProperty
2096 settings->EnableTextAutosizing(false);
2097 value = settings->IsTextAutosizingEnabled();
2098 DALI_TEST_CHECK(!value);
2103 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2105 ToolkitTestApplication application;
2107 WebView view = WebView::New();
2108 DALI_TEST_CHECK(view);
2110 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2111 DALI_TEST_CHECK(settings != 0);
2114 settings->AllowMixedContents(false);
2115 settings->EnableSpatialNavigation(false);
2116 settings->EnableWebSecurity(false);
2117 settings->EnableCacheBuilder(false);
2118 settings->EnableDoNotTrack(false);
2119 settings->UseScrollbarThumbFocusNotifications(false);
2120 settings->AllowFileAccessFromExternalUrl(false);
2121 settings->AllowScriptsOpenWindows(false);
2123 // Check default value is true or not
2124 bool value = settings->IsArrowScrollEnabled();
2125 DALI_TEST_CHECK(value);
2127 // Check Set/GetProperty
2128 settings->EnableArrowScroll(false);
2129 value = settings->IsArrowScrollEnabled();
2130 DALI_TEST_CHECK(!value);
2135 int UtcDaliWebSettingsCheckEnableClipboard(void)
2137 ToolkitTestApplication application;
2139 WebView view = WebView::New();
2140 DALI_TEST_CHECK(view);
2142 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2143 DALI_TEST_CHECK(settings != 0);
2146 settings->AllowMixedContents(false);
2147 settings->EnableSpatialNavigation(false);
2148 settings->EnableWebSecurity(false);
2149 settings->EnableCacheBuilder(false);
2150 settings->EnableDoNotTrack(false);
2151 settings->UseScrollbarThumbFocusNotifications(false);
2152 settings->AllowFileAccessFromExternalUrl(false);
2153 settings->AllowScriptsOpenWindows(false);
2155 // Check default value is true or not
2156 bool value = settings->IsClipboardEnabled();
2157 DALI_TEST_CHECK(value);
2158 settings->EnableClipboard(false);
2159 value = settings->IsClipboardEnabled();
2160 DALI_TEST_CHECK(!value);
2164 int UtcDaliWebSettingsCheckEnableImePanel(void)
2166 ToolkitTestApplication application;
2168 WebView view = WebView::New();
2169 DALI_TEST_CHECK(view);
2171 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2172 DALI_TEST_CHECK(settings != 0);
2175 settings->AllowMixedContents(false);
2176 settings->EnableSpatialNavigation(false);
2177 settings->EnableWebSecurity(false);
2178 settings->EnableCacheBuilder(false);
2179 settings->EnableDoNotTrack(false);
2180 settings->UseScrollbarThumbFocusNotifications(false);
2181 settings->AllowFileAccessFromExternalUrl(false);
2182 settings->AllowScriptsOpenWindows(false);
2184 // Check default value is true or not
2185 bool value = settings->IsImePanelEnabled();
2186 DALI_TEST_CHECK(value);
2188 // Check Set/GetProperty
2189 settings->EnableImePanel(false);
2190 value = settings->IsImePanelEnabled();
2191 DALI_TEST_CHECK(!value);
2196 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2198 ToolkitTestApplication application;
2200 WebView view = WebView::New();
2201 DALI_TEST_CHECK(view);
2203 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2204 DALI_TEST_CHECK(settings != 0)
2207 settings->AllowMixedContents(false);
2208 settings->EnableSpatialNavigation(false);
2209 settings->EnableWebSecurity(false);
2210 settings->EnableCacheBuilder(false);
2211 settings->EnableDoNotTrack(false);
2212 settings->UseScrollbarThumbFocusNotifications(false);
2213 settings->AllowFileAccessFromExternalUrl(false);
2214 settings->AllowScriptsOpenWindows(false);
2216 // Check default value is true or not
2217 bool value = settings->AreImagesLoadedAutomatically();
2218 DALI_TEST_CHECK(value);
2220 // Check Set/GetProperty
2221 settings->AllowImagesLoadAutomatically(false);
2222 value = settings->AreImagesLoadedAutomatically();
2223 DALI_TEST_CHECK(!value);
2228 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2230 ToolkitTestApplication application;
2232 WebView view = WebView::New();
2233 DALI_TEST_CHECK(view);
2235 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2236 DALI_TEST_CHECK(settings != 0)
2238 const std::string kDefaultValue;
2239 const std::string kTestValue = "UTF-8";
2242 settings->AllowMixedContents(false);
2243 settings->EnableSpatialNavigation(false);
2244 settings->EnableWebSecurity(false);
2245 settings->EnableCacheBuilder(false);
2246 settings->EnableDoNotTrack(false);
2247 settings->UseScrollbarThumbFocusNotifications(false);
2248 settings->AllowFileAccessFromExternalUrl(false);
2249 settings->AllowScriptsOpenWindows(false);
2251 // Check default value
2252 std::string value = settings->GetDefaultTextEncodingName();
2253 DALI_TEST_EQUALS(value, kDefaultValue, TEST_LOCATION);
2255 // Check Set/GetProperty
2256 settings->SetDefaultTextEncodingName(kTestValue);
2257 value = settings->GetDefaultTextEncodingName();
2258 DALI_TEST_EQUALS(value, kTestValue, TEST_LOCATION);
2263 int UtcDaliWebSettingsSetViewportMetaTag(void)
2265 ToolkitTestApplication application;
2267 WebView view = WebView::New();
2268 DALI_TEST_CHECK(view);
2270 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2271 DALI_TEST_CHECK(settings != 0)
2273 // Check the value is true or not
2274 bool value = settings->SetViewportMetaTag(true);
2275 DALI_TEST_CHECK(value);
2280 int UtcDaliWebSettingsSetForceZoom(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->SetForceZoom(true);
2292 DALI_TEST_CHECK(value);
2294 value = settings->IsZoomForced();
2295 DALI_TEST_CHECK(value);
2300 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2302 ToolkitTestApplication application;
2304 WebView view = WebView::New();
2305 DALI_TEST_CHECK(view);
2307 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2308 DALI_TEST_CHECK(settings != 0)
2310 // Check the value is true or not
2311 bool value = settings->SetTextZoomEnabled(true);
2312 DALI_TEST_CHECK(value);
2314 value = settings->IsTextZoomEnabled();
2315 DALI_TEST_CHECK(value);
2320 int UtcDaliWebSettingsSetExtraFeature(void)
2322 ToolkitTestApplication application;
2324 WebView view = WebView::New();
2325 DALI_TEST_CHECK(view);
2327 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2328 DALI_TEST_CHECK(settings != 0)
2330 // Check the value is true or not
2331 settings->SetExtraFeature("test", true);
2332 bool value = settings->IsExtraFeatureEnabled("test");
2333 DALI_TEST_CHECK(value);
2338 int UtcDaliWebViewGetPlainText(void)
2340 ToolkitTestApplication application;
2342 WebView view = WebView::New();
2343 DALI_TEST_CHECK(view);
2345 view.LoadUrl(TEST_URL1);
2347 view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2348 Test::EmitGlobalTimerSignal();
2349 DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);