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-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 std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
83 static int gCertificateConfirmCallbackCalled = 0;
84 static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
85 static int gSslCertificateChangedCallbackCalled = 0;
86 static std::unique_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
87 static int gHttpAuthHandlerCallbackCalled = 0;
88 static std::unique_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
89 static int gSecurityOriginsAcquiredCallbackCalled = 0;
90 static int gStorageUsageAcquiredCallbackCalled = 0;
91 static int gFormPasswordsAcquiredCallbackCalled = 0;
92 static int gDownloadStartedCallbackCalled = 0;
93 static int gMimeOverriddenCallbackCalled = 0;
94 static int gRequestInterceptedCallbackCalled = 0;
95 static Dali::WebEngineRequestInterceptorPtr gRequestInterceptorInstance = nullptr;
96 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
97 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
98 static int gContextMenuShownCallbackCalled = 0;
99 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuShownInstance = nullptr;
100 static int gContextMenuHiddenCallbackCalled = 0;
101 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuHiddenInstance = nullptr;
102 static int gHitTestCreatedCallbackCalled = 0;
103 static int gCookieManagerChangsWatchCallbackCalled = 0;
104 static int gPlainTextReceivedCallbackCalled = 0;
106 struct CallbackFunctor
108 CallbackFunctor(bool* callbackFlag)
109 : mCallbackFlag(callbackFlag)
115 *mCallbackFlag = true;
120 static void OnPageLoadStarted(const std::string& url)
122 gPageLoadStartedCallbackCalled++;
125 static void OnPageLoadInProgress(const std::string& url)
127 gPageLoadInProgressCallbackCalled++;
130 static void OnPageLoadFinished(const std::string& url)
132 gPageLoadFinishedCallbackCalled++;
135 static void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
137 gScrollEdgeReachedCallbackCalled++;
140 static void OnResponsePolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
142 gResponsePolicyDecidedCallbackCalled++;
143 gResponsePolicyDecisionInstance = std::move(decision);
146 static void OnNavigationPolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
148 gNavigationPolicyDecidedCallbackCalled++;
151 static void OnUrlChanged(const std::string& url)
153 gUrlChangedCallbackCalled++;
156 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
158 gHitTestCreatedCallbackCalled++;
162 static bool OnPlainTextReceived(const std::string& plainText)
164 gPlainTextReceivedCallbackCalled++;
168 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
170 gPageLoadErrorCallbackCalled++;
171 gPageLoadErrorInstance = std::move(error);
174 static void OnEvaluateJavaScript(const std::string& result)
176 gEvaluateJavaScriptCallbackCalled++;
179 static bool OnJavaScriptAlert(const std::string& result)
181 gJavaScriptAlertCallbackCalled++;
185 static bool OnJavaScriptConfirm(const std::string& result)
187 gJavaScriptConfirmCallbackCalled++;
191 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
193 gJavaScriptPromptCallbackCalled++;
197 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
199 gScreenshotCapturedCallbackCalled++;
202 static void OnVideoPlaying(bool isPlaying)
204 gVideoPlayingCallbackCalled++;
207 static bool OnGeolocationPermission(const std::string&, const std::string&)
209 gGeolocationPermissionCallbackCalled++;
213 static bool OnTouched(Actor actor, const Dali::TouchEvent& touch)
219 static void OnChangesWatch()
221 gCookieManagerChangsWatchCallbackCalled++;
224 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
230 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
232 gWheelEventHandled = true;
236 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
238 gFormRepostDecidedCallbackCalled++;
239 gFormRepostDecidedInstance = std::move(decision);
242 static void OnFrameRendered()
244 gFrameRenderedCallbackCalled++;
247 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
249 gConsoleMessageCallbackCalled++;
250 gConsoleMessageInstance = std::move(message);
253 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
255 gCertificateConfirmCallbackCalled++;
256 gCertificateConfirmInstance = std::move(certificate);
259 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
261 gSslCertificateChangedCallbackCalled++;
262 gSslCertificateInstance = std::move(certificate);
265 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
267 gHttpAuthHandlerCallbackCalled++;
268 gHttpAuthInstance = std::move(hander);
271 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
273 gSecurityOriginsAcquiredCallbackCalled++;
274 gSecurityOriginList.clear();
275 gSecurityOriginList.swap(origins);
278 static void OnStorageUsageAcquired(uint64_t usage)
280 gStorageUsageAcquiredCallbackCalled++;
283 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
285 gFormPasswordsAcquiredCallbackCalled++;
286 gPasswordDataList.clear();
287 gPasswordDataList.swap(passwords);
290 static void OnDownloadStarted(const std::string& url)
292 gDownloadStartedCallbackCalled++;
295 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
297 gMimeOverriddenCallbackCalled++;
301 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
303 gRequestInterceptedCallbackCalled++;
304 gRequestInterceptorInstance = interceptor;
308 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
310 gContextMenuShownCallbackCalled++;
311 gContextMenuShownInstance = std::move(menu);
314 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
316 gContextMenuHiddenCallbackCalled++;
317 gContextMenuHiddenInstance = std::move(menu);
322 void web_view_startup(void)
324 test_return_value = TET_UNDEF;
327 void web_view_cleanup(void)
329 test_return_value = TET_PASS;
332 int UtcDaliWebViewBasics(void)
334 ToolkitTestApplication application;
336 // Copy and Assignment Test
337 tet_infoline("UtcDaliWebViewBasic Copy and Assignment Test");
338 WebView view = WebView::New();
339 DALI_TEST_CHECK(view);
342 DALI_TEST_CHECK(view == copy);
345 DALI_TEST_CHECK(!assign);
348 DALI_TEST_CHECK(assign == view);
351 tet_infoline("UtcDaliWebViewBasic DownCast Test");
352 BaseHandle handle(view);
354 WebView view2 = WebView::DownCast(handle);
355 DALI_TEST_CHECK(view);
356 DALI_TEST_CHECK(view2);
357 DALI_TEST_CHECK(view == view2);
360 tet_infoline("UtcDaliWebViewBasic TypeRegistry Test");
361 TypeRegistry typeRegistry = TypeRegistry::Get();
362 DALI_TEST_CHECK(typeRegistry);
364 TypeInfo typeInfo = typeRegistry.GetTypeInfo("WebView");
365 DALI_TEST_CHECK(typeInfo);
367 BaseHandle handle2 = typeInfo.CreateInstance();
368 DALI_TEST_CHECK(handle2);
370 WebView view3 = WebView::DownCast(handle2);
371 DALI_TEST_CHECK(view3);
376 int UtcDaliWebViewPageNavigation(void)
378 ToolkitTestApplication application;
380 WebView view = WebView::New();
381 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
382 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
383 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
384 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
385 application.GetScene().Add(view);
386 application.SendNotification();
387 application.Render();
388 DALI_TEST_CHECK(view);
390 view.RegisterPageLoadStartedCallback(&OnPageLoadStarted);
391 view.RegisterPageLoadInProgressCallback(&OnPageLoadInProgress);
392 view.RegisterPageLoadFinishedCallback(&OnPageLoadFinished);
393 view.RegisterUrlChangedCallback(&OnUrlChanged);
394 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 0, TEST_LOCATION);
395 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION);
396 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION);
397 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 0, TEST_LOCATION);
399 view.LoadUrl(TEST_URL1);
400 view.GetNaturalSize();
401 Test::EmitGlobalTimerSignal();
402 DALI_TEST_EQUALS(view.CanGoBack(), false, TEST_LOCATION);
403 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 1, TEST_LOCATION);
404 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION);
405 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION);
406 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 1, TEST_LOCATION);
408 view.LoadUrl(TEST_URL2);
410 view.SetProperty(Actor::Property::SIZE, Vector2(400, 300));
411 application.SendNotification();
412 application.Render();
413 Test::EmitGlobalTimerSignal();
415 DALI_TEST_EQUALS(view.CanGoBack(), true, TEST_LOCATION);
416 DALI_TEST_EQUALS(view.CanGoForward(), false, TEST_LOCATION);
417 DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 2, TEST_LOCATION);
418 DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION);
419 DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION);
420 DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 2, TEST_LOCATION);
423 Test::EmitGlobalTimerSignal();
424 DALI_TEST_CHECK(!view.CanGoBack());
425 DALI_TEST_CHECK(view.CanGoForward());
428 Test::EmitGlobalTimerSignal();
429 DALI_TEST_CHECK(view.CanGoBack());
430 DALI_TEST_CHECK(!view.CanGoForward());
435 Test::EmitGlobalTimerSignal();
436 DALI_TEST_CHECK(!view.CanGoBack());
437 DALI_TEST_CHECK(!view.CanGoForward());
442 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
444 ToolkitTestApplication application;
446 WebView view = WebView::New();
447 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
448 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
449 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
450 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
451 application.GetScene().Add(view);
452 application.SendNotification();
453 application.Render();
454 DALI_TEST_CHECK(view);
456 view.RegisterPageLoadErrorCallback(&OnPageLoadError);
457 view.RegisterConsoleMessageReceivedCallback(&OnConsoleMessage);
458 DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 0, TEST_LOCATION);
459 DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 0, TEST_LOCATION);
461 view.LoadUrl(TEST_URL1);
462 Test::EmitGlobalTimerSignal();
463 DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 1, TEST_LOCATION);
464 DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 1, TEST_LOCATION);
467 DALI_TEST_CHECK(gPageLoadErrorInstance);
468 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
469 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
470 std::string testErrorDescription("This is an error.");
471 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
472 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
475 DALI_TEST_CHECK(gConsoleMessageInstance);
476 std::string testConsoleSource("source");
477 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
478 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
479 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
480 std::string testConsoleText("This is a text.");
481 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
484 gPageLoadErrorInstance = nullptr;
485 gConsoleMessageInstance = nullptr;
490 int UtcDaliWebViewTouchAndKeys(void)
492 ToolkitTestApplication application;
494 WebView view = WebView::New();
495 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
496 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
497 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
498 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
500 application.GetScene().Add(view);
501 application.SendNotification();
502 application.Render();
504 view.GetNaturalSize();
505 view.TouchedSignal().Connect(&OnTouched);
508 Dali::Integration::TouchEvent event;
509 Dali::Integration::Point pointDown, pointUp;
511 event = Dali::Integration::TouchEvent();
512 pointDown.SetState(PointState::DOWN);
513 pointDown.SetScreenPosition(Vector2(10, 10));
514 event.AddPoint(pointDown);
515 application.ProcessEvent(event);
517 event = Dali::Integration::TouchEvent();
518 pointUp.SetState(PointState::UP);
519 pointUp.SetScreenPosition(Vector2(10, 10));
520 event.AddPoint(pointUp);
521 application.ProcessEvent(event);
524 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor(view);
525 application.ProcessEvent(Integration::KeyEvent("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE));
526 application.SendNotification();
528 DALI_TEST_CHECK(gTouched);
529 DALI_TEST_CHECK(view);
534 int UtcDaliWebViewFocusGainedAndLost(void)
536 ToolkitTestApplication application;
538 WebView view = WebView::New();
539 DALI_TEST_CHECK(view);
541 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
542 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
543 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
544 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
546 application.GetScene().Add(view);
547 application.SendNotification();
548 application.Render();
550 view.SetKeyInputFocus();
551 DALI_TEST_CHECK(view.HasKeyInputFocus());
554 view.ClearKeyInputFocus();
555 DALI_TEST_CHECK(!view.HasKeyInputFocus());
560 int UtcDaliWebViewPropertyPageZoomFactor(void)
562 ToolkitTestApplication application;
564 WebView view = WebView::New();
565 DALI_TEST_CHECK(view);
567 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
568 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
569 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
570 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
572 application.GetScene().Add(view);
573 application.SendNotification();
574 application.Render();
576 view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
577 float zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
578 DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
580 view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
581 zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
582 DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
587 int UtcDaliWebViewPropertyTextZoomFactor(void)
589 ToolkitTestApplication application;
591 WebView view = WebView::New();
592 DALI_TEST_CHECK(view);
594 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
595 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
596 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
597 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
599 application.GetScene().Add(view);
600 application.SendNotification();
601 application.Render();
603 view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
604 float zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
605 DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
607 view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
608 zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
609 DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
614 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
616 ToolkitTestApplication application;
618 WebView view = WebView::New();
619 DALI_TEST_CHECK(view);
621 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
622 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
623 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
624 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
626 application.GetScene().Add(view);
627 application.SendNotification();
628 application.Render();
630 float percentage = view.GetProperty<float>(WebView::Property::LOAD_PROGRESS_PERCENTAGE);
631 DALI_TEST_EQUALS(percentage, 0.5f, TEST_LOCATION);
636 int UtcDaliWebViewMove(void)
638 ToolkitTestApplication application;
640 WebView view = WebView::New();
641 DALI_TEST_CHECK(view);
643 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
644 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
645 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
646 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
648 application.GetScene().Add(view);
649 application.SendNotification();
650 application.Render();
652 view.SetProperty(Actor::Property::POSITION, Vector2(100, 100));
653 Vector3 viewPos = view.GetProperty<Vector3>(Actor::Property::POSITION);
654 DALI_TEST_EQUALS(viewPos, Vector3(100, 100, 0), TEST_LOCATION);
659 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
661 ToolkitTestApplication application;
663 WebView view = WebView::New();
664 DALI_TEST_CHECK(view);
666 const bool kDefaultValue = false;
667 const bool kTestValue = true;
669 // Check default value
671 Property::Value value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
672 DALI_TEST_CHECK(value.Get(output));
673 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
675 // Check Set/GetProperty
676 view.SetProperty(WebView::Property::VIDEO_HOLE_ENABLED, kTestValue);
677 value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
678 DALI_TEST_CHECK(value.Get(output));
679 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
684 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
686 ToolkitTestApplication application;
688 WebView view = WebView::New();
689 DALI_TEST_CHECK(view);
691 const bool kDefaultValue = true;
692 const bool kTestValue = false;
694 // Check default value
696 Property::Value value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
697 DALI_TEST_CHECK(value.Get(output));
698 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
700 // Check Set/GetProperty
701 view.SetProperty(WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue);
702 value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
703 DALI_TEST_CHECK(value.Get(output));
704 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
709 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
711 ToolkitTestApplication application;
713 WebView view = WebView::New();
714 DALI_TEST_CHECK(view);
716 const bool kDefaultValue = true;
717 const bool kTestValue = false;
719 // Check default value
721 Property::Value value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
722 DALI_TEST_CHECK(value.Get(output));
723 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
725 // Check Set/GetProperty
726 view.SetProperty(WebView::Property::KEY_EVENTS_ENABLED, kTestValue);
727 value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
728 DALI_TEST_CHECK(value.Get(output));
729 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
734 int UtcDaliWebViewHoverAndWheel(void)
736 ToolkitTestApplication application;
738 WebView view = WebView::New();
739 DALI_TEST_CHECK(view);
740 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
741 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
742 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
743 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
745 application.GetScene().Add(view);
746 application.SendNotification();
747 application.Render();
749 view.GetNaturalSize();
750 view.HoveredSignal().Connect(&OnHovered);
751 view.WheelEventSignal().Connect(&OnWheelEvent);
754 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
755 Dali::Integration::Point pointDown;
756 pointDown.SetState(PointState::DOWN);
757 pointDown.SetScreenPosition(Vector2(10, 10));
758 event.AddPoint(pointDown);
759 application.ProcessEvent(event);
761 event = Dali::Integration::HoverEvent();
762 Dali::Integration::Point pointUp;
763 pointUp.SetState(PointState::UP);
764 pointUp.SetScreenPosition(Vector2(10, 10));
765 event.AddPoint(pointUp);
766 application.ProcessEvent(event);
768 event = Dali::Integration::HoverEvent();
769 Dali::Integration::Point pointMotion;
770 pointUp.SetState(PointState::MOTION);
771 pointUp.SetScreenPosition(Vector2(10, 10));
772 event.AddPoint(pointMotion);
773 application.ProcessEvent(event);
776 Dali::Integration::WheelEvent wheelEvent;
777 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
778 wheelEvent.direction = 0;
779 wheelEvent.point = Vector2(20, 20);
780 wheelEvent.delta = 10;
781 application.ProcessEvent(wheelEvent);
782 application.SendNotification();
784 DALI_TEST_CHECK(gHovered);
785 DALI_TEST_CHECK(gWheelEventHandled);
790 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
792 ToolkitTestApplication application;
794 WebView view = WebView::New();
795 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
796 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
797 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
798 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
799 application.GetScene().Add(view);
800 application.SendNotification();
801 application.Render();
802 DALI_TEST_CHECK(view);
804 view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
805 view.RegisterFrameRenderedCallback(&OnFrameRendered);
806 DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION);
807 DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 0, TEST_LOCATION);
809 view.LoadUrl(TEST_URL1);
810 Test::EmitGlobalTimerSignal();
811 DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION);
812 DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 1, TEST_LOCATION);
814 // form repost decision.
815 DALI_TEST_CHECK(gFormRepostDecidedInstance);
816 gFormRepostDecidedInstance->Reply(true);
819 gFormRepostDecidedInstance = nullptr;
824 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
826 ToolkitTestApplication application;
828 WebView view = WebView::New();
829 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
830 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
831 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
832 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
833 application.GetScene().Add(view);
834 application.SendNotification();
835 application.Render();
836 DALI_TEST_CHECK(view);
838 view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
839 view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
840 view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
841 DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 0, TEST_LOCATION);
842 DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION);
843 DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION);
845 view.LoadUrl(TEST_URL1);
846 Test::EmitGlobalTimerSignal();
847 DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 1, TEST_LOCATION);
848 DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION);
849 DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION);
852 DALI_TEST_CHECK(gCertificateConfirmInstance);
853 gCertificateConfirmInstance->Allow(true);
854 DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
856 DALI_TEST_CHECK(gSslCertificateInstance);
857 DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
858 DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
860 // http authentication.
861 DALI_TEST_CHECK(gHttpAuthInstance);
862 gHttpAuthInstance->Suspend();
863 gHttpAuthInstance->UseCredential("", "");
864 gHttpAuthInstance->CancelCredential();
865 DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
868 gCertificateConfirmInstance = nullptr;
869 gSslCertificateInstance = nullptr;
870 gHttpAuthInstance = nullptr;
875 int UtcDaliWebViewGetWebBackForwardList(void)
877 ToolkitTestApplication application;
879 WebView view = WebView::New();
880 DALI_TEST_CHECK(view);
882 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
883 DALI_TEST_CHECK(bfList != 0);
888 int UtcDaliWebViewGetWebContext(void)
890 ToolkitTestApplication application;
892 Dali::WebEngineContext* context = WebView::GetContext();
893 DALI_TEST_CHECK(context != nullptr);
898 int UtcDaliWebViewGetWebCookieManager(void)
900 ToolkitTestApplication application;
902 Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
903 DALI_TEST_CHECK(cookieManager != 0);
908 int UtcDaliWebViewGetWebSettings(void)
910 ToolkitTestApplication application;
912 WebView view = WebView::New();
913 DALI_TEST_CHECK(view);
915 Dali::Toolkit::WebSettings* settings = view.GetSettings();
916 DALI_TEST_CHECK(settings != 0);
921 int UtcDaliWebViewProperty1(void)
924 ToolkitTestApplication application;
926 WebView view = WebView::New();
927 DALI_TEST_CHECK(view);
930 view.SetProperty(WebView::Property::URL, TEST_URL1);
931 Property::Value val = view.GetProperty(WebView::Property::URL);
932 DALI_TEST_CHECK(val.Get(local));
933 DALI_TEST_EQUALS(local, TEST_URL1, TEST_LOCATION);
938 int UtcDaliWebViewProperty4(void)
941 ToolkitTestApplication application;
943 WebView view = WebView::New();
944 DALI_TEST_CHECK(view);
946 const std::string kDefaultValue;
947 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";
949 // Check default value
951 Property::Value value = view.GetProperty(WebView::Property::USER_AGENT);
952 DALI_TEST_CHECK(value.Get(output));
953 DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
955 // Check Set/GetProperty
956 view.SetProperty(WebView::Property::USER_AGENT, kTestValue);
957 value = view.GetProperty(WebView::Property::USER_AGENT);
958 DALI_TEST_CHECK(value.Get(output));
959 DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
964 int UtcDaliWebViewProperty9(void)
967 ToolkitTestApplication application;
969 WebView view = WebView::New();
970 DALI_TEST_CHECK(view);
972 // Check default value
973 Dali::Vector2 output = Dali::Vector2::ONE;
974 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
975 DALI_TEST_CHECK(output.x == 0 && output.y == 0);
977 // Check Set/GetProperty
978 Dali::Vector2 testValue = Dali::Vector2(100, 100);
979 view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
980 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
981 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
983 // Check default value of scroll size
984 output = Dali::Vector2::ONE;
985 view.GetProperty(WebView::Property::SCROLL_SIZE).Get(output);
986 DALI_TEST_CHECK(output.x == 500 && output.y == 500);
988 // Check default value of content size
989 output = Dali::Vector2::ONE;
990 view.GetProperty(WebView::Property::CONTENT_SIZE).Get(output);
991 DALI_TEST_CHECK(output.x == 500 && output.y == 500);
996 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
998 ToolkitTestApplication application;
1000 WebView view = WebView::New();
1001 DALI_TEST_CHECK(view);
1003 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1004 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1005 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1006 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1007 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1009 // Check default value
1010 std::string testText("test");
1012 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1013 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1018 int UtcDaliWebViewPropertyTitleFavicon(void)
1020 ToolkitTestApplication application;
1022 char argv[] = "--test";
1023 WebView view = WebView::New(1, (char**)&argv);
1024 DALI_TEST_CHECK(view);
1027 view.ClearAllTilesResources();
1029 // Check default value of title
1030 std::string testValue("title");
1032 view.GetProperty(WebView::Property::TITLE).Get(output);
1033 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1035 // Check the case that favicon is not null.
1036 Dali::Toolkit::ImageView favicon = view.GetFavicon();
1037 DALI_TEST_CHECK(favicon);
1038 Dali::Vector3 iconsize = favicon.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1039 DALI_TEST_CHECK((int)iconsize.width == 2 && (int)iconsize.height == 2);
1041 // Check the case that favicon is null.
1042 favicon = view.GetFavicon();
1043 DALI_TEST_CHECK(!favicon);
1048 int UtcDaliWebViewContextMenuShownAndHidden(void)
1050 ToolkitTestApplication application;
1052 WebView view = WebView::New();
1053 DALI_TEST_CHECK(view);
1056 view.RegisterContextMenuShownCallback(&OnContextMenuShown);
1057 view.RegisterContextMenuHiddenCallback(&OnContextMenuHidden);
1058 DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 0, TEST_LOCATION);
1059 DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION);
1060 DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1061 DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1063 view.LoadUrl(TEST_URL1);
1064 Test::EmitGlobalTimerSignal();
1065 DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 1, TEST_LOCATION);
1066 DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION);
1068 // check context meun & its items.
1069 DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1070 std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1071 DALI_TEST_CHECK(item.get() != 0);
1072 std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1073 DALI_TEST_CHECK(itemList.size() == 1);
1074 DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1075 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1076 DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1077 DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1078 DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1080 Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1081 DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1082 Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1083 DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1084 DALI_TEST_CHECK(item->IsEnabled());
1085 std::string testLinkUrl("http://test.html");
1086 DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1087 std::string testImageUrl("http://test.jpg");
1088 DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1089 std::string testTitle("title");
1090 DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1091 DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1093 DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1095 gContextMenuShownInstance = nullptr;
1096 gContextMenuHiddenInstance = nullptr;
1101 int UtcDaliWebViewScrollBy(void)
1103 ToolkitTestApplication application;
1105 WebView view = WebView::New();
1106 DALI_TEST_CHECK(view);
1109 view.RegisterScrollEdgeReachedCallback(&OnScrollEdgeReached);
1110 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION);
1112 view.LoadUrl(TEST_URL1);
1113 Test::EmitGlobalTimerSignal();
1115 // set scroll position.
1116 Dali::Vector2 output = Dali::Vector2::ONE;
1117 Dali::Vector2 testValue = Dali::Vector2(100, 100);
1118 view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
1119 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1120 DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1122 // scroll by and trigger scrollEdgeReached event.
1123 view.ScrollBy(50, 50);
1124 Test::EmitGlobalTimerSignal();
1126 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1127 DALI_TEST_CHECK(output.x == 150 && output.y == 150);
1128 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION);
1130 // scroll by and trigger scrollEdgeReached event.
1131 bool result = view.ScrollEdgeBy(50, 50);
1132 DALI_TEST_CHECK(result);
1133 Test::EmitGlobalTimerSignal();
1135 view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1136 DALI_TEST_CHECK(output.x == 200 && output.y == 200);
1137 DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION);
1142 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1144 ToolkitTestApplication application;
1146 WebView view = WebView::New();
1147 DALI_TEST_CHECK(view);
1149 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1150 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1151 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1152 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1154 application.GetScene().Add(view);
1155 application.SendNotification();
1156 application.Render();
1158 view.ActivateAccessibility(true);
1159 view.AddDynamicCertificatePath("host", "test/to/path");
1160 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1161 DALI_TEST_CHECK(found);
1163 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1164 float result = view.GetScaleFactor();
1165 DALI_TEST_EQUALS(result, 1.5f, TEST_LOCATION);
1167 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1168 result = view.GetScaleFactor();
1169 DALI_TEST_EQUALS(result, 1.0f, TEST_LOCATION);
1174 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1177 ToolkitTestApplication application;
1179 char argv[] = "--test";
1180 WebView view = WebView::New(1, (char**)&argv);
1181 DALI_TEST_CHECK(view);
1183 // Check GetScreenshot
1184 Dali::Rect<int> viewArea;
1187 viewArea.width = 10;
1188 viewArea.height = 10;
1189 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1190 DALI_TEST_CHECK(screenshot);
1191 Dali::Vector3 shotsize = screenshot.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1192 DALI_TEST_CHECK((int)shotsize.width == viewArea.width && (int)shotsize.height == viewArea.height);
1194 // Check GetScreenshotAsynchronously
1197 viewArea.width = 100;
1198 viewArea.height = 100;
1199 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1200 DALI_TEST_CHECK(result);
1202 Test::EmitGlobalTimerSignal();
1204 Test::EmitGlobalTimerSignal();
1205 DALI_TEST_EQUALS(gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION);
1210 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1213 ToolkitTestApplication application;
1215 char argv[] = "--test";
1216 WebView view = WebView::New(1, (char**)&argv);
1217 DALI_TEST_CHECK(view);
1219 // Check CheckVideoPlayingAsynchronously
1220 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1221 DALI_TEST_CHECK(result);
1222 Test::EmitGlobalTimerSignal();
1223 DALI_TEST_EQUALS(gVideoPlayingCallbackCalled, 1, TEST_LOCATION);
1225 // Check RegisterGeolocationPermissionCallback
1226 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1227 Test::EmitGlobalTimerSignal();
1228 DALI_TEST_EQUALS(gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION);
1233 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1235 ToolkitTestApplication application;
1237 WebView view = WebView::New();
1238 DALI_TEST_CHECK(view);
1241 view.RegisterResponsePolicyDecidedCallback(&OnResponsePolicyDecided);
1242 DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1243 DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1245 view.LoadUrl(TEST_URL1);
1246 Test::EmitGlobalTimerSignal();
1247 DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1249 // check response policy decision & its frame.
1250 DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1251 std::string testUrl("http://test.html");
1252 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1253 std::string testCookie("test:abc");
1254 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1255 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1256 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1257 std::string testResponseMime("txt/xml");
1258 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1259 int32_t ResponseStatusCode = 500;
1260 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1261 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1262 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1263 std::string testScheme("test");
1264 DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1265 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1266 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1267 DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1269 Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1270 DALI_TEST_CHECK(webFrame);
1271 DALI_TEST_CHECK(webFrame->IsMainFrame());
1273 gResponsePolicyDecisionInstance = nullptr;
1278 int UtcDaliWebViewNavigationPolicyDecisionRequest(void)
1280 ToolkitTestApplication application;
1282 WebView view = WebView::New();
1283 DALI_TEST_CHECK(view);
1286 view.RegisterNavigationPolicyDecidedCallback(&OnNavigationPolicyDecided);
1287 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1289 view.LoadUrl(TEST_URL1);
1290 Test::EmitGlobalTimerSignal();
1291 DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1296 int UtcDaliWebViewHitTest(void)
1298 ToolkitTestApplication application;
1300 WebView view = WebView::New();
1301 DALI_TEST_CHECK(view);
1304 view.LoadUrl(TEST_URL1);
1307 std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1308 DALI_TEST_CHECK(hitTest != 0);
1309 DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1310 std::string testLinkUri("http://test.html");
1311 DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1312 std::string testLinkTitle("test");
1313 DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1314 std::string testLinkLabel("label");
1315 DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1316 std::string testImageUri("http://test.jpg");
1317 DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1318 std::string testMediaUri("http://test.mp4");
1319 DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1320 std::string testTagName("img");
1321 DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1322 std::string testNodeValue("test");
1323 DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1324 Dali::Property::Map testMap = hitTest->GetAttributes();
1325 DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
1326 std::string testImageFileNameExtension("jpg");
1327 DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1328 Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1329 DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1332 bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1333 DALI_TEST_CHECK(result);
1334 Test::EmitGlobalTimerSignal();
1335 DALI_TEST_EQUALS(gHitTestCreatedCallbackCalled, 1, TEST_LOCATION);
1340 int UtcDaliWebViewEvaluteJavaScript(void)
1342 ToolkitTestApplication application;
1344 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1346 view.LoadHtmlString("<body>Hello World!</body>");
1347 view.EvaluateJavaScript("jsObject.postMessage('Hello')");
1348 view.EvaluateJavaScript("jsObject.postMessage('World')", OnEvaluateJavaScript);
1349 Test::EmitGlobalTimerSignal();
1351 DALI_TEST_EQUALS(gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION);
1356 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1358 ToolkitTestApplication application;
1360 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1362 view.RegisterJavaScriptAlertCallback(&OnJavaScriptAlert);
1363 view.LoadHtmlString("<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>");
1364 view.JavaScriptAlertReply();
1365 Test::EmitGlobalTimerSignal();
1366 DALI_TEST_EQUALS(gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION);
1368 view.RegisterJavaScriptConfirmCallback(&OnJavaScriptConfirm);
1369 view.LoadHtmlString("<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>");
1370 view.JavaScriptConfirmReply(true);
1371 Test::EmitGlobalTimerSignal();
1372 DALI_TEST_EQUALS(gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION);
1374 view.RegisterJavaScriptPromptCallback(&OnJavaScriptPrompt);
1375 view.LoadHtmlString("<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>");
1376 view.JavaScriptPromptReply("it is a prompt.");
1377 Test::EmitGlobalTimerSignal();
1378 DALI_TEST_EQUALS(gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION);
1383 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1385 ToolkitTestApplication application;
1387 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1388 DALI_TEST_CHECK(view);
1390 std::string html("<body>Hello World!</body>");
1391 std::string basicUri("http://basicurl");
1392 std::string unreachableUrl("http://unreachableurl");
1393 bool result = view.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
1394 DALI_TEST_CHECK(result);
1396 application.SendNotification();
1397 application.Render();
1398 Test::EmitGlobalTimerSignal();
1400 result = view.LoadContents(html, html.length(), "html/text", "utf-8", basicUri);
1401 DALI_TEST_CHECK(result);
1406 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1408 ToolkitTestApplication application;
1410 WebView view = WebView::New();
1411 view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1412 view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1413 view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1414 view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1416 application.GetScene().Add(view);
1417 application.SendNotification();
1418 application.Render();
1419 DALI_TEST_CHECK(view);
1421 view.LoadUrl("http://test.html");
1422 bool result = view.AddCustomHeader("key", "value");
1423 DALI_TEST_CHECK(result);
1425 result = view.ReloadWithoutCache();
1426 DALI_TEST_CHECK(result);
1428 uint32_t portNumber = view.StartInspectorServer(5000);
1429 DALI_TEST_EQUALS(portNumber, 5000, TEST_LOCATION);
1431 application.SendNotification();
1432 application.Render();
1433 Test::EmitGlobalTimerSignal();
1435 result = view.StopInspectorServer();
1436 DALI_TEST_CHECK(result);
1438 view.SuspendNetworkLoading();
1440 result = view.RemoveCustomHeader("key");
1441 DALI_TEST_CHECK(result);
1443 view.ResumeNetworkLoading();
1448 int UtcDaliWebViewMethodsForCoverage(void)
1450 ToolkitTestApplication application;
1452 WebView view = WebView::New("ko-KR", "Asia/Seoul");
1454 view.LoadHtmlString("<body>Hello World!</body>");
1455 view.AddJavaScriptMessageHandler("jsObject",
1456 [](const std::string& arg) {
1458 view.SetTtsFocus(true);
1460 DALI_TEST_CHECK(view);
1465 // test cases for web backforward list.
1467 int UtcDaliWebBackForwardListCheckItem(void)
1469 ToolkitTestApplication application;
1471 WebView view = WebView::New();
1472 DALI_TEST_CHECK(view);
1474 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1475 DALI_TEST_CHECK(bfList != 0)
1477 unsigned int itemCount = bfList->GetItemCount();
1478 DALI_TEST_CHECK(itemCount == 1)
1480 std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1481 DALI_TEST_CHECK(citem != 0);
1483 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1484 DALI_TEST_CHECK(citemP != 0);
1486 std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1487 DALI_TEST_CHECK(citemN != 0);
1489 const std::string kDefaultUrl("http://url");
1490 std::string testValue = citem->GetUrl();
1491 DALI_TEST_EQUALS(testValue, kDefaultUrl, TEST_LOCATION);
1493 const std::string kDefaultTitle("title");
1494 testValue = citem->GetTitle();
1495 DALI_TEST_EQUALS(testValue, kDefaultTitle, TEST_LOCATION);
1497 const std::string kDefaultOriginalUrl("http://originalurl");
1498 testValue = citem->GetOriginalUrl();
1499 DALI_TEST_EQUALS(testValue, kDefaultOriginalUrl, TEST_LOCATION);
1501 std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex(0);
1502 DALI_TEST_CHECK(item != 0);
1504 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1505 DALI_TEST_CHECK(vecBack.size() == 1);
1507 std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1508 DALI_TEST_CHECK(vecForward.size() == 1);
1513 // test cases for web context.
1515 int UtcDaliWebContextGetSetCacheModelEtc(void)
1517 ToolkitTestApplication application;
1519 Dali::WebEngineContext* context = WebView::GetContext();
1520 DALI_TEST_CHECK(context != 0)
1522 std::string kDefaultValue;
1525 context->SetAppId("id");
1526 context->SetApplicationType(Dali::WebEngineContext::ApplicationType::OTHER);
1527 context->SetTimeOffset(0);
1528 context->SetTimeZoneOffset(0, 0);
1529 context->SetDefaultProxyAuth(kDefaultValue, kDefaultValue);
1530 context->DeleteAllWebDatabase();
1531 context->DeleteAllWebStorage();
1532 context->DeleteLocalFileSystem();
1533 context->ClearCache();
1534 context->DeleteAllFormPasswordData();
1535 context->DeleteAllFormCandidateData();
1537 // Check default value
1538 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1539 DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER);
1541 // Check Set/GetProperty
1542 context->SetCacheModel(Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1543 value = context->GetCacheModel();
1544 DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1546 // Get cache enabled
1547 context->EnableCache(true);
1548 DALI_TEST_CHECK(context->IsCacheEnabled());
1551 context->SetCertificateFilePath("test");
1552 std::string str = context->GetCertificateFilePath();
1553 DALI_TEST_EQUALS(str, "test", TEST_LOCATION);
1556 DALI_TEST_CHECK(context->SetAppVersion("test"));
1559 std::vector<std::string> temp;
1560 context->RegisterUrlSchemesAsCorsEnabled(temp);
1561 context->RegisterJsPluginMimeTypes(temp);
1562 context->DeleteFormPasswordDataList(temp);
1565 context->SetDefaultZoomFactor(1.0f);
1566 DALI_TEST_EQUALS(context->GetDefaultZoomFactor(), float(1.0f), TEST_LOCATION);
1568 // Delete cache and database
1569 DALI_TEST_CHECK(context->DeleteAllApplicationCache());
1570 DALI_TEST_CHECK(context->DeleteAllWebIndexedDatabase());
1573 context->SetProxyUri("test");
1574 DALI_TEST_EQUALS(context->GetProxyUri(), "test", TEST_LOCATION);
1575 context->SetProxyBypassRule("", "test");
1576 DALI_TEST_EQUALS(context->GetProxyBypassRule(), "test", TEST_LOCATION);
1579 DALI_TEST_CHECK(context->FreeUnusedMemory());
1584 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1586 ToolkitTestApplication application;
1588 Dali::WebEngineContext* context = WebView::GetContext();
1589 DALI_TEST_CHECK(context != 0)
1591 std::string kDefaultValue;
1593 // get origins of web database
1594 bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1595 DALI_TEST_CHECK(result);
1597 Test::EmitGlobalTimerSignal();
1598 DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION);
1599 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1601 Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1602 DALI_TEST_CHECK(origin);
1604 result = context->DeleteWebDatabase(*origin);
1605 DALI_TEST_CHECK(result);
1607 // get origins of web storage
1608 result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1609 DALI_TEST_CHECK(result);
1611 Test::EmitGlobalTimerSignal();
1612 DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION);
1613 DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1615 origin = gSecurityOriginList[0].get();
1616 DALI_TEST_CHECK(origin);
1618 result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1619 DALI_TEST_CHECK(result);
1620 Test::EmitGlobalTimerSignal();
1621 DALI_TEST_EQUALS(gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION);
1623 result = context->DeleteWebStorage(*origin);
1624 DALI_TEST_CHECK(result);
1626 result = context->DeleteApplicationCache(*origin);
1627 DALI_TEST_CHECK(result);
1629 // form passwords, download state, mime type.
1630 context->GetFormPasswordList(&OnFormPasswordsAcquired);
1631 Test::EmitGlobalTimerSignal();
1632 DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1633 DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1634 DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1635 DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1637 context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1638 Test::EmitGlobalTimerSignal();
1639 DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1641 context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1642 Test::EmitGlobalTimerSignal();
1643 DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1645 gSecurityOriginList.clear();
1646 gPasswordDataList.clear();
1651 int UtcDaliWebContextHttpRequestInterceptor(void)
1653 ToolkitTestApplication application;
1655 Dali::WebEngineContext* context = WebView::GetContext();
1656 DALI_TEST_CHECK(context != 0)
1658 WebView view = WebView::New();
1659 DALI_TEST_CHECK(view);
1661 // Check if web view is found or not when plugin is null.
1662 DALI_TEST_CHECK(!WebView::FindWebView(nullptr));
1665 context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1666 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1667 DALI_TEST_CHECK(!gRequestInterceptorInstance);
1669 Test::EmitGlobalTimerSignal();
1670 DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 1, TEST_LOCATION);
1672 // check request interceptor.
1673 DALI_TEST_CHECK(gRequestInterceptorInstance);
1674 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1675 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1676 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
1677 Dali::Property::Map testHeaders;
1678 testHeaders.Insert("key2", "value2");
1679 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
1680 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody((const int8_t*)"test", 4));
1681 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", (const int8_t*)"test", 4));
1682 DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk((const int8_t*)"test", 4));
1684 DALI_TEST_CHECK(gRequestInterceptorInstance->GetWebEngine());
1685 // Check if web view is found or not when plugin is not null.
1686 DALI_TEST_CHECK(WebView::FindWebView(gRequestInterceptorInstance->GetWebEngine()));
1688 std::string testUrl("http://test.html");
1689 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1690 std::string testMethod("GET");
1691 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
1692 Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
1693 DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
1695 // Destroy web view.
1697 gRequestInterceptorInstance = nullptr;
1702 // test cases for web cookie manager.
1704 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1706 ToolkitTestApplication application;
1708 Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1709 DALI_TEST_CHECK(cookieManager != 0)
1711 const std::string kDefaultValue;
1714 cookieManager->SetPersistentStorage(kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE);
1715 cookieManager->ClearCookies();
1717 // Check default value
1718 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1719 DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY);
1721 // Check Set/GetProperty
1722 cookieManager->SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1723 value = cookieManager->GetCookieAcceptPolicy();
1724 DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1729 int UtcDaliWebCookieManagerChangesWatch(void)
1731 ToolkitTestApplication application;
1733 Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1734 DALI_TEST_CHECK(cookieManager != 0)
1736 cookieManager->ChangesWatch(&OnChangesWatch);
1737 Test::EmitGlobalTimerSignal();
1738 DALI_TEST_EQUALS(gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION);
1743 // test cases for web settings.
1745 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1747 ToolkitTestApplication application;
1749 WebView view = WebView::New();
1750 DALI_TEST_CHECK(view);
1752 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1753 DALI_TEST_CHECK(settings != 0)
1756 settings->AllowMixedContents(false);
1757 settings->EnableSpatialNavigation(false);
1758 settings->EnableWebSecurity(false);
1759 settings->EnableCacheBuilder(false);
1760 settings->EnableDoNotTrack(false);
1761 settings->UseScrollbarThumbFocusNotifications(false);
1762 settings->AllowFileAccessFromExternalUrl(false);
1763 settings->AllowScriptsOpenWindows(false);
1765 // Check default value
1766 int value = settings->GetDefaultFontSize();
1767 DALI_TEST_CHECK(value == 16);
1769 // Check Set/GetProperty
1770 settings->SetDefaultFontSize(20);
1771 value = settings->GetDefaultFontSize();
1772 DALI_TEST_CHECK(value == 20);
1777 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1779 ToolkitTestApplication application;
1781 WebView view = WebView::New();
1782 DALI_TEST_CHECK(view);
1784 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1785 DALI_TEST_CHECK(settings != 0)
1788 settings->AllowMixedContents(false);
1789 settings->EnableSpatialNavigation(false);
1790 settings->EnableWebSecurity(false);
1791 settings->EnableCacheBuilder(false);
1792 settings->EnableDoNotTrack(false);
1793 settings->UseScrollbarThumbFocusNotifications(false);
1794 settings->AllowFileAccessFromExternalUrl(false);
1795 settings->AllowScriptsOpenWindows(false);
1797 // Check default value is true or not
1798 bool value = settings->IsJavaScriptEnabled();
1799 DALI_TEST_CHECK(value);
1801 // Check Set/GetProperty
1802 settings->EnableJavaScript(false);
1803 value = settings->IsJavaScriptEnabled();
1804 DALI_TEST_CHECK(!value);
1809 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1811 ToolkitTestApplication application;
1813 WebView view = WebView::New();
1814 DALI_TEST_CHECK(view);
1816 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1817 DALI_TEST_CHECK(settings != 0)
1820 settings->AllowMixedContents(false);
1821 settings->EnableSpatialNavigation(false);
1822 settings->EnableWebSecurity(false);
1823 settings->EnableCacheBuilder(false);
1824 settings->EnableDoNotTrack(false);
1825 settings->UseScrollbarThumbFocusNotifications(false);
1826 settings->AllowFileAccessFromExternalUrl(false);
1827 settings->AllowScriptsOpenWindows(false);
1829 // Check default value is true or not
1830 bool value = settings->IsAutoFittingEnabled();
1831 DALI_TEST_CHECK(value);
1833 // Check Set/GetProperty
1834 settings->EnableAutoFitting(false);
1835 value = settings->IsAutoFittingEnabled();
1836 DALI_TEST_CHECK(!value);
1841 int UtcDaliWebSettingsCheckEnablePlugins(void)
1843 ToolkitTestApplication application;
1845 WebView view = WebView::New();
1846 DALI_TEST_CHECK(view);
1848 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1849 DALI_TEST_CHECK(settings != 0)
1852 settings->AllowMixedContents(false);
1853 settings->EnableSpatialNavigation(false);
1854 settings->EnableWebSecurity(false);
1855 settings->EnableCacheBuilder(false);
1856 settings->EnableDoNotTrack(false);
1857 settings->UseScrollbarThumbFocusNotifications(false);
1858 settings->AllowFileAccessFromExternalUrl(false);
1859 settings->AllowScriptsOpenWindows(false);
1861 // Check default value is true or not
1862 bool value = settings->ArePluginsEnabled();
1863 DALI_TEST_CHECK(value);
1865 // Check Set/GetProperty
1866 settings->EnablePlugins(false);
1867 value = settings->ArePluginsEnabled();
1868 DALI_TEST_CHECK(!value);
1873 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1875 ToolkitTestApplication application;
1877 WebView view = WebView::New();
1878 DALI_TEST_CHECK(view);
1880 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1881 DALI_TEST_CHECK(settings != 0)
1884 settings->AllowMixedContents(false);
1885 settings->EnableSpatialNavigation(false);
1886 settings->EnableWebSecurity(false);
1887 settings->EnableCacheBuilder(false);
1888 settings->EnableDoNotTrack(false);
1889 settings->UseScrollbarThumbFocusNotifications(false);
1890 settings->AllowFileAccessFromExternalUrl(false);
1891 settings->AllowScriptsOpenWindows(false);
1893 // Check default value is true or not
1894 bool value = settings->IsPrivateBrowsingEnabled();
1895 DALI_TEST_CHECK(value);
1897 // Check Set/GetProperty
1898 settings->EnablePrivateBrowsing(false);
1899 value = settings->IsPrivateBrowsingEnabled();
1900 DALI_TEST_CHECK(!value);
1905 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1907 ToolkitTestApplication application;
1909 WebView view = WebView::New();
1910 DALI_TEST_CHECK(view);
1912 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1913 DALI_TEST_CHECK(settings != 0)
1916 settings->AllowMixedContents(false);
1917 settings->EnableSpatialNavigation(false);
1918 settings->EnableWebSecurity(false);
1919 settings->EnableCacheBuilder(false);
1920 settings->EnableDoNotTrack(false);
1921 settings->UseScrollbarThumbFocusNotifications(false);
1922 settings->AllowFileAccessFromExternalUrl(false);
1923 settings->AllowScriptsOpenWindows(false);
1925 // Check default value is true or not
1926 bool value = settings->IsLinkMagnifierEnabled();
1927 DALI_TEST_CHECK(value);
1929 // Check Set/GetProperty
1930 settings->EnableLinkMagnifier(false);
1931 value = settings->IsLinkMagnifierEnabled();
1932 DALI_TEST_CHECK(!value);
1937 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1939 ToolkitTestApplication application;
1941 WebView view = WebView::New();
1942 DALI_TEST_CHECK(view);
1944 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1945 DALI_TEST_CHECK(settings != 0)
1948 settings->AllowMixedContents(false);
1949 settings->EnableSpatialNavigation(false);
1950 settings->EnableWebSecurity(false);
1951 settings->EnableCacheBuilder(false);
1952 settings->EnableDoNotTrack(false);
1953 settings->UseScrollbarThumbFocusNotifications(false);
1954 settings->AllowFileAccessFromExternalUrl(false);
1955 settings->AllowScriptsOpenWindows(false);
1957 // Check default value is true or not
1958 bool value = settings->IsKeypadWithoutUserActionUsed();
1959 DALI_TEST_CHECK(value);
1961 // Check Set/GetProperty
1962 settings->UseKeypadWithoutUserAction(false);
1963 value = settings->IsKeypadWithoutUserActionUsed();
1964 DALI_TEST_CHECK(!value);
1969 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1971 ToolkitTestApplication application;
1973 WebView view = WebView::New();
1974 DALI_TEST_CHECK(view);
1976 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1977 DALI_TEST_CHECK(settings != 0)
1980 settings->AllowMixedContents(false);
1981 settings->EnableSpatialNavigation(false);
1982 settings->EnableWebSecurity(false);
1983 settings->EnableCacheBuilder(false);
1984 settings->EnableDoNotTrack(false);
1985 settings->UseScrollbarThumbFocusNotifications(false);
1986 settings->AllowFileAccessFromExternalUrl(false);
1987 settings->AllowScriptsOpenWindows(false);
1989 // Check default value is true or not
1990 bool value = settings->IsAutofillPasswordFormEnabled();
1991 DALI_TEST_CHECK(value);
1992 settings->EnableAutofillPasswordForm(false);
1993 value = settings->IsAutofillPasswordFormEnabled();
1994 DALI_TEST_CHECK(!value);
1998 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
2000 ToolkitTestApplication application;
2002 WebView view = WebView::New();
2003 DALI_TEST_CHECK(view);
2005 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2006 DALI_TEST_CHECK(settings != 0);
2009 settings->AllowMixedContents(false);
2010 settings->EnableSpatialNavigation(false);
2011 settings->EnableWebSecurity(false);
2012 settings->EnableCacheBuilder(false);
2013 settings->EnableDoNotTrack(false);
2014 settings->UseScrollbarThumbFocusNotifications(false);
2015 settings->AllowFileAccessFromExternalUrl(false);
2016 settings->AllowScriptsOpenWindows(false);
2018 // Check default value is true or not
2019 bool value = settings->IsFormCandidateDataEnabled();
2020 DALI_TEST_CHECK(value);
2022 // Check Set/GetProperty
2023 settings->EnableFormCandidateData(false);
2024 value = settings->IsFormCandidateDataEnabled();
2025 DALI_TEST_CHECK(!value);
2030 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2032 ToolkitTestApplication application;
2034 WebView view = WebView::New();
2035 DALI_TEST_CHECK(view);
2037 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2038 DALI_TEST_CHECK(settings != 0);
2041 settings->AllowMixedContents(false);
2042 settings->EnableSpatialNavigation(false);
2043 settings->EnableWebSecurity(false);
2044 settings->EnableCacheBuilder(false);
2045 settings->EnableDoNotTrack(false);
2046 settings->UseScrollbarThumbFocusNotifications(false);
2047 settings->AllowFileAccessFromExternalUrl(false);
2048 settings->AllowScriptsOpenWindows(false);
2050 // Check default value is true or not
2051 bool value = settings->IsTextSelectionEnabled();
2052 DALI_TEST_CHECK(value);
2054 //Check Set/GetProperty
2055 settings->EnableTextSelection(false);
2056 value = settings->IsTextSelectionEnabled();
2057 DALI_TEST_CHECK(!value);
2062 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2064 ToolkitTestApplication application;
2066 WebView view = WebView::New();
2067 DALI_TEST_CHECK(view);
2069 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2070 DALI_TEST_CHECK(settings != 0);
2073 settings->AllowMixedContents(false);
2074 settings->EnableSpatialNavigation(false);
2075 settings->EnableWebSecurity(false);
2076 settings->EnableCacheBuilder(false);
2077 settings->EnableDoNotTrack(false);
2078 settings->UseScrollbarThumbFocusNotifications(false);
2079 settings->AllowFileAccessFromExternalUrl(false);
2080 settings->AllowScriptsOpenWindows(false);
2082 // Check default value is true or not
2083 bool value = settings->IsTextAutosizingEnabled();
2084 DALI_TEST_CHECK(value);
2086 // Check Set/GetProperty
2087 settings->EnableTextAutosizing(false);
2088 value = settings->IsTextAutosizingEnabled();
2089 DALI_TEST_CHECK(!value);
2094 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2096 ToolkitTestApplication application;
2098 WebView view = WebView::New();
2099 DALI_TEST_CHECK(view);
2101 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2102 DALI_TEST_CHECK(settings != 0);
2105 settings->AllowMixedContents(false);
2106 settings->EnableSpatialNavigation(false);
2107 settings->EnableWebSecurity(false);
2108 settings->EnableCacheBuilder(false);
2109 settings->EnableDoNotTrack(false);
2110 settings->UseScrollbarThumbFocusNotifications(false);
2111 settings->AllowFileAccessFromExternalUrl(false);
2112 settings->AllowScriptsOpenWindows(false);
2114 // Check default value is true or not
2115 bool value = settings->IsArrowScrollEnabled();
2116 DALI_TEST_CHECK(value);
2118 // Check Set/GetProperty
2119 settings->EnableArrowScroll(false);
2120 value = settings->IsArrowScrollEnabled();
2121 DALI_TEST_CHECK(!value);
2126 int UtcDaliWebSettingsCheckEnableClipboard(void)
2128 ToolkitTestApplication application;
2130 WebView view = WebView::New();
2131 DALI_TEST_CHECK(view);
2133 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2134 DALI_TEST_CHECK(settings != 0);
2137 settings->AllowMixedContents(false);
2138 settings->EnableSpatialNavigation(false);
2139 settings->EnableWebSecurity(false);
2140 settings->EnableCacheBuilder(false);
2141 settings->EnableDoNotTrack(false);
2142 settings->UseScrollbarThumbFocusNotifications(false);
2143 settings->AllowFileAccessFromExternalUrl(false);
2144 settings->AllowScriptsOpenWindows(false);
2146 // Check default value is true or not
2147 bool value = settings->IsClipboardEnabled();
2148 DALI_TEST_CHECK(value);
2149 settings->EnableClipboard(false);
2150 value = settings->IsClipboardEnabled();
2151 DALI_TEST_CHECK(!value);
2155 int UtcDaliWebSettingsCheckEnableImePanel(void)
2157 ToolkitTestApplication application;
2159 WebView view = WebView::New();
2160 DALI_TEST_CHECK(view);
2162 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2163 DALI_TEST_CHECK(settings != 0);
2166 settings->AllowMixedContents(false);
2167 settings->EnableSpatialNavigation(false);
2168 settings->EnableWebSecurity(false);
2169 settings->EnableCacheBuilder(false);
2170 settings->EnableDoNotTrack(false);
2171 settings->UseScrollbarThumbFocusNotifications(false);
2172 settings->AllowFileAccessFromExternalUrl(false);
2173 settings->AllowScriptsOpenWindows(false);
2175 // Check default value is true or not
2176 bool value = settings->IsImePanelEnabled();
2177 DALI_TEST_CHECK(value);
2179 // Check Set/GetProperty
2180 settings->EnableImePanel(false);
2181 value = settings->IsImePanelEnabled();
2182 DALI_TEST_CHECK(!value);
2187 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2189 ToolkitTestApplication application;
2191 WebView view = WebView::New();
2192 DALI_TEST_CHECK(view);
2194 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2195 DALI_TEST_CHECK(settings != 0)
2198 settings->AllowMixedContents(false);
2199 settings->EnableSpatialNavigation(false);
2200 settings->EnableWebSecurity(false);
2201 settings->EnableCacheBuilder(false);
2202 settings->EnableDoNotTrack(false);
2203 settings->UseScrollbarThumbFocusNotifications(false);
2204 settings->AllowFileAccessFromExternalUrl(false);
2205 settings->AllowScriptsOpenWindows(false);
2207 // Check default value is true or not
2208 bool value = settings->AreImagesLoadedAutomatically();
2209 DALI_TEST_CHECK(value);
2211 // Check Set/GetProperty
2212 settings->AllowImagesLoadAutomatically(false);
2213 value = settings->AreImagesLoadedAutomatically();
2214 DALI_TEST_CHECK(!value);
2219 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2221 ToolkitTestApplication application;
2223 WebView view = WebView::New();
2224 DALI_TEST_CHECK(view);
2226 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2227 DALI_TEST_CHECK(settings != 0)
2229 const std::string kDefaultValue;
2230 const std::string kTestValue = "UTF-8";
2233 settings->AllowMixedContents(false);
2234 settings->EnableSpatialNavigation(false);
2235 settings->EnableWebSecurity(false);
2236 settings->EnableCacheBuilder(false);
2237 settings->EnableDoNotTrack(false);
2238 settings->UseScrollbarThumbFocusNotifications(false);
2239 settings->AllowFileAccessFromExternalUrl(false);
2240 settings->AllowScriptsOpenWindows(false);
2242 // Check default value
2243 std::string value = settings->GetDefaultTextEncodingName();
2244 DALI_TEST_EQUALS(value, kDefaultValue, TEST_LOCATION);
2246 // Check Set/GetProperty
2247 settings->SetDefaultTextEncodingName(kTestValue);
2248 value = settings->GetDefaultTextEncodingName();
2249 DALI_TEST_EQUALS(value, kTestValue, TEST_LOCATION);
2254 int UtcDaliWebSettingsSetViewportMetaTag(void)
2256 ToolkitTestApplication application;
2258 WebView view = WebView::New();
2259 DALI_TEST_CHECK(view);
2261 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2262 DALI_TEST_CHECK(settings != 0)
2264 // Check the value is true or not
2265 bool value = settings->SetViewportMetaTag(true);
2266 DALI_TEST_CHECK(value);
2271 int UtcDaliWebSettingsSetForceZoom(void)
2273 ToolkitTestApplication application;
2275 WebView view = WebView::New();
2276 DALI_TEST_CHECK(view);
2278 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2279 DALI_TEST_CHECK(settings != 0)
2281 // Check the value is true or not
2282 bool value = settings->SetForceZoom(true);
2283 DALI_TEST_CHECK(value);
2285 value = settings->IsZoomForced();
2286 DALI_TEST_CHECK(value);
2291 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2293 ToolkitTestApplication application;
2295 WebView view = WebView::New();
2296 DALI_TEST_CHECK(view);
2298 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2299 DALI_TEST_CHECK(settings != 0)
2301 // Check the value is true or not
2302 bool value = settings->SetTextZoomEnabled(true);
2303 DALI_TEST_CHECK(value);
2305 value = settings->IsTextZoomEnabled();
2306 DALI_TEST_CHECK(value);
2311 int UtcDaliWebSettingsSetExtraFeature(void)
2313 ToolkitTestApplication application;
2315 WebView view = WebView::New();
2316 DALI_TEST_CHECK(view);
2318 Dali::Toolkit::WebSettings* settings = view.GetSettings();
2319 DALI_TEST_CHECK(settings != 0)
2321 // Check the value is true or not
2322 settings->SetExtraFeature("test", true);
2323 bool value = settings->IsExtraFeatureEnabled("test");
2324 DALI_TEST_CHECK(value);
2329 int UtcDaliWebViewGetPlainText(void)
2331 ToolkitTestApplication application;
2333 WebView view = WebView::New();
2334 DALI_TEST_CHECK(view);
2336 view.LoadUrl(TEST_URL1);
2338 view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2339 Test::EmitGlobalTimerSignal();
2340 DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);