Add an API for getting web view when request is intercepted.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-WebView.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <iostream>
20
21 #include <dali-toolkit-test-suite-utils.h>
22 #include "dali-toolkit-test-utils/toolkit-timer.h"
23
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>
29 #include <dali.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>
49
50 using namespace Dali;
51 using namespace Toolkit;
52
53 namespace
54 {
55 const char* const TEST_URL1("http://www.somewhere.valid1.com");
56 const char* const TEST_URL2("http://www.somewhere.valid2.com");
57
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;
105
106 struct CallbackFunctor
107 {
108   CallbackFunctor(bool* callbackFlag)
109   : mCallbackFlag(callbackFlag)
110   {
111   }
112
113   void operator()()
114   {
115     *mCallbackFlag = true;
116   }
117   bool* mCallbackFlag;
118 };
119
120 static void OnPageLoadStarted(const std::string& url)
121 {
122   gPageLoadStartedCallbackCalled++;
123 }
124
125 static void OnPageLoadInProgress(const std::string& url)
126 {
127   gPageLoadInProgressCallbackCalled++;
128 }
129
130 static void OnPageLoadFinished(const std::string& url)
131 {
132   gPageLoadFinishedCallbackCalled++;
133 }
134
135 static void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
136 {
137   gScrollEdgeReachedCallbackCalled++;
138 }
139
140 static void OnResponsePolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
141 {
142   gResponsePolicyDecidedCallbackCalled++;
143   gResponsePolicyDecisionInstance = std::move(decision);
144 }
145
146 static void OnNavigationPolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
147 {
148   gNavigationPolicyDecidedCallbackCalled++;
149 }
150
151 static void OnUrlChanged(const std::string& url)
152 {
153   gUrlChangedCallbackCalled++;
154 }
155
156 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
157 {
158   gHitTestCreatedCallbackCalled++;
159   return true;
160 }
161
162 static bool OnPlainTextReceived(const std::string& plainText)
163 {
164   gPlainTextReceivedCallbackCalled++;
165   return true;
166 }
167
168 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
169 {
170   gPageLoadErrorCallbackCalled++;
171   gPageLoadErrorInstance = std::move(error);
172 }
173
174 static void OnEvaluateJavaScript(const std::string& result)
175 {
176   gEvaluateJavaScriptCallbackCalled++;
177 }
178
179 static bool OnJavaScriptAlert(const std::string& result)
180 {
181   gJavaScriptAlertCallbackCalled++;
182   return true;
183 }
184
185 static bool OnJavaScriptConfirm(const std::string& result)
186 {
187   gJavaScriptConfirmCallbackCalled++;
188   return true;
189 }
190
191 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
192 {
193   gJavaScriptPromptCallbackCalled++;
194   return true;
195 }
196
197 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
198 {
199   gScreenshotCapturedCallbackCalled++;
200 }
201
202 static void OnVideoPlaying(bool isPlaying)
203 {
204   gVideoPlayingCallbackCalled++;
205 }
206
207 static bool OnGeolocationPermission(const std::string&, const std::string&)
208 {
209   gGeolocationPermissionCallbackCalled++;
210   return true;
211 }
212
213 static bool OnTouched(Actor actor, const Dali::TouchEvent& touch)
214 {
215   gTouched = true;
216   return true;
217 }
218
219 static void OnChangesWatch()
220 {
221   gCookieManagerChangsWatchCallbackCalled++;
222 }
223
224 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
225 {
226   gHovered = true;
227   return true;
228 }
229
230 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
231 {
232   gWheelEventHandled = true;
233   return true;
234 }
235
236 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
237 {
238   gFormRepostDecidedCallbackCalled++;
239   gFormRepostDecidedInstance = std::move(decision);
240 }
241
242 static void OnFrameRendered()
243 {
244   gFrameRenderedCallbackCalled++;
245 }
246
247 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
248 {
249   gConsoleMessageCallbackCalled++;
250   gConsoleMessageInstance = std::move(message);
251 }
252
253 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
254 {
255   gCertificateConfirmCallbackCalled++;
256   gCertificateConfirmInstance = std::move(certificate);
257 }
258
259 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
260 {
261   gSslCertificateChangedCallbackCalled++;
262   gSslCertificateInstance = std::move(certificate);
263 }
264
265 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
266 {
267   gHttpAuthHandlerCallbackCalled++;
268   gHttpAuthInstance = std::move(hander);
269 }
270
271 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
272 {
273   gSecurityOriginsAcquiredCallbackCalled++;
274   gSecurityOriginList.clear();
275   gSecurityOriginList.swap(origins);
276 }
277
278 static void OnStorageUsageAcquired(uint64_t usage)
279 {
280   gStorageUsageAcquiredCallbackCalled++;
281 }
282
283 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
284 {
285   gFormPasswordsAcquiredCallbackCalled++;
286   gPasswordDataList.clear();
287   gPasswordDataList.swap(passwords);
288 }
289
290 static void OnDownloadStarted(const std::string& url)
291 {
292   gDownloadStartedCallbackCalled++;
293 }
294
295 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
296 {
297   gMimeOverriddenCallbackCalled++;
298   return false;
299 }
300
301 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
302 {
303   gRequestInterceptedCallbackCalled++;
304   gRequestInterceptorInstance = interceptor;
305   return false;
306 }
307
308 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
309 {
310   gContextMenuShownCallbackCalled++;
311   gContextMenuShownInstance = std::move(menu);
312 }
313
314 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
315 {
316   gContextMenuHiddenCallbackCalled++;
317   gContextMenuHiddenInstance = std::move(menu);
318 }
319
320 } // namespace
321
322 void web_view_startup(void)
323 {
324   test_return_value = TET_UNDEF;
325 }
326
327 void web_view_cleanup(void)
328 {
329   test_return_value = TET_PASS;
330 }
331
332 int UtcDaliWebViewBasics(void)
333 {
334   ToolkitTestApplication application;
335
336   // Copy and Assignment Test
337   tet_infoline("UtcDaliWebViewBasic Copy and Assignment Test");
338   WebView view = WebView::New();
339   DALI_TEST_CHECK(view);
340
341   WebView copy(view);
342   DALI_TEST_CHECK(view == copy);
343
344   WebView assign;
345   DALI_TEST_CHECK(!assign);
346
347   assign = copy;
348   DALI_TEST_CHECK(assign == view);
349
350   // DownCast Test
351   tet_infoline("UtcDaliWebViewBasic DownCast Test");
352   BaseHandle handle(view);
353
354   WebView view2 = WebView::DownCast(handle);
355   DALI_TEST_CHECK(view);
356   DALI_TEST_CHECK(view2);
357   DALI_TEST_CHECK(view == view2);
358
359   // TypeRegistry Test
360   tet_infoline("UtcDaliWebViewBasic TypeRegistry Test");
361   TypeRegistry typeRegistry = TypeRegistry::Get();
362   DALI_TEST_CHECK(typeRegistry);
363
364   TypeInfo typeInfo = typeRegistry.GetTypeInfo("WebView");
365   DALI_TEST_CHECK(typeInfo);
366
367   BaseHandle handle2 = typeInfo.CreateInstance();
368   DALI_TEST_CHECK(handle2);
369
370   WebView view3 = WebView::DownCast(handle2);
371   DALI_TEST_CHECK(view3);
372
373   END_TEST;
374 }
375
376 int UtcDaliWebViewPageNavigation(void)
377 {
378   ToolkitTestApplication application;
379
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);
389
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);
398
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);
407
408   view.LoadUrl(TEST_URL2);
409   view.Suspend();
410   view.SetProperty(Actor::Property::SIZE, Vector2(400, 300));
411   application.SendNotification();
412   application.Render();
413   Test::EmitGlobalTimerSignal();
414   view.Resume();
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);
421
422   view.GoBack();
423   Test::EmitGlobalTimerSignal();
424   DALI_TEST_CHECK(!view.CanGoBack());
425   DALI_TEST_CHECK(view.CanGoForward());
426
427   view.GoForward();
428   Test::EmitGlobalTimerSignal();
429   DALI_TEST_CHECK(view.CanGoBack());
430   DALI_TEST_CHECK(!view.CanGoForward());
431
432   view.Reload();
433   view.StopLoading();
434   view.ClearHistory();
435   Test::EmitGlobalTimerSignal();
436   DALI_TEST_CHECK(!view.CanGoBack());
437   DALI_TEST_CHECK(!view.CanGoForward());
438
439   END_TEST;
440 }
441
442 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
443 {
444   ToolkitTestApplication application;
445
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);
455
456   view.RegisterPageLoadErrorCallback(&OnPageLoadError);
457   view.RegisterConsoleMessageReceivedCallback(&OnConsoleMessage);
458   DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 0, TEST_LOCATION);
459   DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 0, TEST_LOCATION);
460
461   view.LoadUrl(TEST_URL1);
462   Test::EmitGlobalTimerSignal();
463   DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 1, TEST_LOCATION);
464   DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 1, TEST_LOCATION);
465
466   // error code.
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);
473
474   // console message.
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);
482
483   // reset
484   gPageLoadErrorInstance  = nullptr;
485   gConsoleMessageInstance = nullptr;
486
487   END_TEST;
488 }
489
490 int UtcDaliWebViewTouchAndKeys(void)
491 {
492   ToolkitTestApplication application;
493
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));
499
500   application.GetScene().Add(view);
501   application.SendNotification();
502   application.Render();
503
504   view.GetNaturalSize();
505   view.TouchedSignal().Connect(&OnTouched);
506
507   // Touch event
508   Dali::Integration::TouchEvent event;
509   Dali::Integration::Point      pointDown, pointUp;
510
511   event = Dali::Integration::TouchEvent();
512   pointDown.SetState(PointState::DOWN);
513   pointDown.SetScreenPosition(Vector2(10, 10));
514   event.AddPoint(pointDown);
515   application.ProcessEvent(event);
516
517   event = Dali::Integration::TouchEvent();
518   pointUp.SetState(PointState::UP);
519   pointUp.SetScreenPosition(Vector2(10, 10));
520   event.AddPoint(pointUp);
521   application.ProcessEvent(event);
522
523   // Key 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();
527
528   DALI_TEST_CHECK(gTouched);
529   DALI_TEST_CHECK(view);
530
531   END_TEST;
532 }
533
534 int UtcDaliWebViewFocusGainedAndLost(void)
535 {
536   ToolkitTestApplication application;
537
538   WebView view = WebView::New();
539   DALI_TEST_CHECK(view);
540
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));
545
546   application.GetScene().Add(view);
547   application.SendNotification();
548   application.Render();
549
550   view.SetKeyInputFocus();
551   DALI_TEST_CHECK(view.HasKeyInputFocus());
552
553   // reset
554   view.ClearKeyInputFocus();
555   DALI_TEST_CHECK(!view.HasKeyInputFocus());
556
557   END_TEST;
558 }
559
560 int UtcDaliWebViewPropertyPageZoomFactor(void)
561 {
562   ToolkitTestApplication application;
563
564   WebView view = WebView::New();
565   DALI_TEST_CHECK(view);
566
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));
571
572   application.GetScene().Add(view);
573   application.SendNotification();
574   application.Render();
575
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);
579
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);
583
584   END_TEST;
585 }
586
587 int UtcDaliWebViewPropertyTextZoomFactor(void)
588 {
589   ToolkitTestApplication application;
590
591   WebView view = WebView::New();
592   DALI_TEST_CHECK(view);
593
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));
598
599   application.GetScene().Add(view);
600   application.SendNotification();
601   application.Render();
602
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);
606
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);
610
611   END_TEST;
612 }
613
614 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
615 {
616   ToolkitTestApplication application;
617
618   WebView view = WebView::New();
619   DALI_TEST_CHECK(view);
620
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));
625
626   application.GetScene().Add(view);
627   application.SendNotification();
628   application.Render();
629
630   float percentage = view.GetProperty<float>(WebView::Property::LOAD_PROGRESS_PERCENTAGE);
631   DALI_TEST_EQUALS(percentage, 0.5f, TEST_LOCATION);
632
633   END_TEST;
634 }
635
636 int UtcDaliWebViewMove(void)
637 {
638   ToolkitTestApplication application;
639
640   WebView view = WebView::New();
641   DALI_TEST_CHECK(view);
642
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));
647
648   application.GetScene().Add(view);
649   application.SendNotification();
650   application.Render();
651
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);
655
656   END_TEST;
657 }
658
659 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
660 {
661   ToolkitTestApplication application;
662
663   WebView view = WebView::New();
664   DALI_TEST_CHECK(view);
665
666   const bool kDefaultValue = false;
667   const bool kTestValue    = true;
668
669   // Check default value
670   bool            output;
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);
674
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);
680
681   END_TEST;
682 }
683
684 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
685 {
686   ToolkitTestApplication application;
687
688   WebView view = WebView::New();
689   DALI_TEST_CHECK(view);
690
691   const bool kDefaultValue = true;
692   const bool kTestValue    = false;
693
694   // Check default value
695   bool            output;
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);
699
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);
705
706   END_TEST;
707 }
708
709 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
710 {
711   ToolkitTestApplication application;
712
713   WebView view = WebView::New();
714   DALI_TEST_CHECK(view);
715
716   const bool kDefaultValue = true;
717   const bool kTestValue    = false;
718
719   // Check default value
720   bool            output;
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);
724
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);
730
731   END_TEST;
732 }
733
734 int UtcDaliWebViewHoverAndWheel(void)
735 {
736   ToolkitTestApplication application;
737
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));
744
745   application.GetScene().Add(view);
746   application.SendNotification();
747   application.Render();
748
749   view.GetNaturalSize();
750   view.HoveredSignal().Connect(&OnHovered);
751   view.WheelEventSignal().Connect(&OnWheelEvent);
752
753   // Hover event
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);
760
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);
767
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);
774
775   // Wheel 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();
783
784   DALI_TEST_CHECK(gHovered);
785   DALI_TEST_CHECK(gWheelEventHandled);
786
787   END_TEST;
788 }
789
790 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
791 {
792   ToolkitTestApplication application;
793
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);
803
804   view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
805   view.RegisterFrameRenderedCallback(&OnFrameRendered);
806   DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION);
807   DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 0, TEST_LOCATION);
808
809   view.LoadUrl(TEST_URL1);
810   Test::EmitGlobalTimerSignal();
811   DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION);
812   DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 1, TEST_LOCATION);
813
814   // form repost decision.
815   DALI_TEST_CHECK(gFormRepostDecidedInstance);
816   gFormRepostDecidedInstance->Reply(true);
817
818   // reset
819   gFormRepostDecidedInstance = nullptr;
820
821   END_TEST;
822 }
823
824 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
825 {
826   ToolkitTestApplication application;
827
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);
837
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);
844
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);
850
851   // certificate.
852   DALI_TEST_CHECK(gCertificateConfirmInstance);
853   gCertificateConfirmInstance->Allow(true);
854   DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
855
856   DALI_TEST_CHECK(gSslCertificateInstance);
857   DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
858   DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
859
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);
866
867   // reset
868   gCertificateConfirmInstance = nullptr;
869   gSslCertificateInstance     = nullptr;
870   gHttpAuthInstance           = nullptr;
871
872   END_TEST;
873 }
874
875 int UtcDaliWebViewGetWebBackForwardList(void)
876 {
877   ToolkitTestApplication application;
878
879   WebView view = WebView::New();
880   DALI_TEST_CHECK(view);
881
882   Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
883   DALI_TEST_CHECK(bfList != 0);
884
885   END_TEST;
886 }
887
888 int UtcDaliWebViewGetWebContext(void)
889 {
890   ToolkitTestApplication application;
891
892   Dali::WebEngineContext* context = WebView::GetContext();
893   DALI_TEST_CHECK(context != nullptr);
894
895   END_TEST;
896 }
897
898 int UtcDaliWebViewGetWebCookieManager(void)
899 {
900   ToolkitTestApplication application;
901
902   Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
903   DALI_TEST_CHECK(cookieManager != 0);
904
905   END_TEST;
906 }
907
908 int UtcDaliWebViewGetWebSettings(void)
909 {
910   ToolkitTestApplication application;
911
912   WebView view = WebView::New();
913   DALI_TEST_CHECK(view);
914
915   Dali::Toolkit::WebSettings* settings = view.GetSettings();
916   DALI_TEST_CHECK(settings != 0);
917
918   END_TEST;
919 }
920
921 int UtcDaliWebViewProperty1(void)
922 {
923   // URL
924   ToolkitTestApplication application;
925
926   WebView view = WebView::New();
927   DALI_TEST_CHECK(view);
928
929   std::string local;
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);
934
935   END_TEST;
936 }
937
938 int UtcDaliWebViewProperty4(void)
939 {
940   // USER_AGENT
941   ToolkitTestApplication application;
942
943   WebView view = WebView::New();
944   DALI_TEST_CHECK(view);
945
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";
948
949   // Check default value
950   std::string     output;
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);
954
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);
960
961   END_TEST;
962 }
963
964 int UtcDaliWebViewProperty9(void)
965 {
966   // SCROLL_POSITION
967   ToolkitTestApplication application;
968
969   WebView view = WebView::New();
970   DALI_TEST_CHECK(view);
971
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);
976
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);
982
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);
987
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);
992
993   END_TEST;
994 }
995
996 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
997 {
998   ToolkitTestApplication application;
999
1000   WebView view = WebView::New();
1001   DALI_TEST_CHECK(view);
1002
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);
1008
1009   // Check default value
1010   std::string testText("test");
1011   std::string output;
1012   view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1013   DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1014
1015   END_TEST;
1016 }
1017
1018 int UtcDaliWebViewPropertyTitleFavicon(void)
1019 {
1020   ToolkitTestApplication application;
1021
1022   char    argv[] = "--test";
1023   WebView view   = WebView::New(1, (char**)&argv);
1024   DALI_TEST_CHECK(view);
1025
1026   // reset something
1027   view.ClearAllTilesResources();
1028
1029   // Check default value of title
1030   std::string testValue("title");
1031   std::string output;
1032   view.GetProperty(WebView::Property::TITLE).Get(output);
1033   DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1034
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);
1040
1041   // Check the case that favicon is null.
1042   favicon = view.GetFavicon();
1043   DALI_TEST_CHECK(!favicon);
1044
1045   END_TEST;
1046 }
1047
1048 int UtcDaliWebViewContextMenuShownAndHidden(void)
1049 {
1050   ToolkitTestApplication application;
1051
1052   WebView view = WebView::New();
1053   DALI_TEST_CHECK(view);
1054
1055   // load url.
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);
1062
1063   view.LoadUrl(TEST_URL1);
1064   Test::EmitGlobalTimerSignal();
1065   DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 1, TEST_LOCATION);
1066   DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION);
1067
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());
1079
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);
1092
1093   DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1094
1095   gContextMenuShownInstance  = nullptr;
1096   gContextMenuHiddenInstance = nullptr;
1097
1098   END_TEST;
1099 }
1100
1101 int UtcDaliWebViewScrollBy(void)
1102 {
1103   ToolkitTestApplication application;
1104
1105   WebView view = WebView::New();
1106   DALI_TEST_CHECK(view);
1107
1108   // load url.
1109   view.RegisterScrollEdgeReachedCallback(&OnScrollEdgeReached);
1110   DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION);
1111
1112   view.LoadUrl(TEST_URL1);
1113   Test::EmitGlobalTimerSignal();
1114
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);
1121
1122   // scroll by and trigger scrollEdgeReached event.
1123   view.ScrollBy(50, 50);
1124   Test::EmitGlobalTimerSignal();
1125
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);
1129
1130   // scroll by and trigger scrollEdgeReached event.
1131   bool result = view.ScrollEdgeBy(50, 50);
1132   DALI_TEST_CHECK(result);
1133   Test::EmitGlobalTimerSignal();
1134
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);
1138
1139   END_TEST;
1140 }
1141
1142 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1143 {
1144   ToolkitTestApplication application;
1145
1146   WebView view = WebView::New();
1147   DALI_TEST_CHECK(view);
1148
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));
1153
1154   application.GetScene().Add(view);
1155   application.SendNotification();
1156   application.Render();
1157
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);
1162
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);
1166
1167   view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1168   result = view.GetScaleFactor();
1169   DALI_TEST_EQUALS(result, 1.0f, TEST_LOCATION);
1170
1171   END_TEST;
1172 }
1173
1174 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1175 {
1176   // SCROLL_POSITION
1177   ToolkitTestApplication application;
1178
1179   char    argv[] = "--test";
1180   WebView view   = WebView::New(1, (char**)&argv);
1181   DALI_TEST_CHECK(view);
1182
1183   // Check GetScreenshot
1184   Dali::Rect<int> viewArea;
1185   viewArea.x                          = 100;
1186   viewArea.y                          = 100;
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);
1193
1194   // Check GetScreenshotAsynchronously
1195   viewArea.x      = 100;
1196   viewArea.y      = 100;
1197   viewArea.width  = 100;
1198   viewArea.height = 100;
1199   bool result     = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1200   DALI_TEST_CHECK(result);
1201
1202   Test::EmitGlobalTimerSignal();
1203
1204   Test::EmitGlobalTimerSignal();
1205   DALI_TEST_EQUALS(gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION);
1206
1207   END_TEST;
1208 }
1209
1210 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1211 {
1212   // SCROLL_POSITION
1213   ToolkitTestApplication application;
1214
1215   char    argv[] = "--test";
1216   WebView view   = WebView::New(1, (char**)&argv);
1217   DALI_TEST_CHECK(view);
1218
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);
1224
1225   // Check RegisterGeolocationPermissionCallback
1226   view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1227   Test::EmitGlobalTimerSignal();
1228   DALI_TEST_EQUALS(gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION);
1229
1230   END_TEST;
1231 }
1232
1233 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1234 {
1235   ToolkitTestApplication application;
1236
1237   WebView view = WebView::New();
1238   DALI_TEST_CHECK(view);
1239
1240   // load url.
1241   view.RegisterResponsePolicyDecidedCallback(&OnResponsePolicyDecided);
1242   DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1243   DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1244
1245   view.LoadUrl(TEST_URL1);
1246   Test::EmitGlobalTimerSignal();
1247   DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1248
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());
1268
1269   Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1270   DALI_TEST_CHECK(webFrame);
1271   DALI_TEST_CHECK(webFrame->IsMainFrame());
1272
1273   gResponsePolicyDecisionInstance = nullptr;
1274
1275   END_TEST;
1276 }
1277
1278 int UtcDaliWebViewNavigationPolicyDecisionRequest(void)
1279 {
1280   ToolkitTestApplication application;
1281
1282   WebView view = WebView::New();
1283   DALI_TEST_CHECK(view);
1284
1285   // load url.
1286   view.RegisterNavigationPolicyDecidedCallback(&OnNavigationPolicyDecided);
1287   DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1288
1289   view.LoadUrl(TEST_URL1);
1290   Test::EmitGlobalTimerSignal();
1291   DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1292
1293   END_TEST;
1294 }
1295
1296 int UtcDaliWebViewHitTest(void)
1297 {
1298   ToolkitTestApplication application;
1299
1300   WebView view = WebView::New();
1301   DALI_TEST_CHECK(view);
1302
1303   // load url.
1304   view.LoadUrl(TEST_URL1);
1305
1306   // sync hit test.
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);
1330
1331   // async...
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);
1336
1337   END_TEST;
1338 }
1339
1340 int UtcDaliWebViewEvaluteJavaScript(void)
1341 {
1342   ToolkitTestApplication application;
1343
1344   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1345
1346   view.LoadHtmlString("<body>Hello World!</body>");
1347   view.EvaluateJavaScript("jsObject.postMessage('Hello')");
1348   view.EvaluateJavaScript("jsObject.postMessage('World')", OnEvaluateJavaScript);
1349   Test::EmitGlobalTimerSignal();
1350
1351   DALI_TEST_EQUALS(gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION);
1352
1353   END_TEST;
1354 }
1355
1356 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1357 {
1358   ToolkitTestApplication application;
1359
1360   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1361
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);
1367
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);
1373
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);
1379
1380   END_TEST;
1381 }
1382
1383 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1384 {
1385   ToolkitTestApplication application;
1386
1387   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1388   DALI_TEST_CHECK(view);
1389
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);
1395
1396   application.SendNotification();
1397   application.Render();
1398   Test::EmitGlobalTimerSignal();
1399
1400   result = view.LoadContents(html, html.length(), "html/text", "utf-8", basicUri);
1401   DALI_TEST_CHECK(result);
1402
1403   END_TEST;
1404 }
1405
1406 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1407 {
1408   ToolkitTestApplication application;
1409
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));
1415
1416   application.GetScene().Add(view);
1417   application.SendNotification();
1418   application.Render();
1419   DALI_TEST_CHECK(view);
1420
1421   view.LoadUrl("http://test.html");
1422   bool result = view.AddCustomHeader("key", "value");
1423   DALI_TEST_CHECK(result);
1424
1425   result = view.ReloadWithoutCache();
1426   DALI_TEST_CHECK(result);
1427
1428   uint32_t portNumber = view.StartInspectorServer(5000);
1429   DALI_TEST_EQUALS(portNumber, 5000, TEST_LOCATION);
1430
1431   application.SendNotification();
1432   application.Render();
1433   Test::EmitGlobalTimerSignal();
1434
1435   result = view.StopInspectorServer();
1436   DALI_TEST_CHECK(result);
1437
1438   view.SuspendNetworkLoading();
1439
1440   result = view.RemoveCustomHeader("key");
1441   DALI_TEST_CHECK(result);
1442
1443   view.ResumeNetworkLoading();
1444
1445   END_TEST;
1446 }
1447
1448 int UtcDaliWebViewMethodsForCoverage(void)
1449 {
1450   ToolkitTestApplication application;
1451
1452   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1453
1454   view.LoadHtmlString("<body>Hello World!</body>");
1455   view.AddJavaScriptMessageHandler("jsObject",
1456                                    [](const std::string& arg) {
1457                                    });
1458   view.SetTtsFocus(true);
1459
1460   DALI_TEST_CHECK(view);
1461
1462   END_TEST;
1463 }
1464
1465 // test cases for web backforward list.
1466
1467 int UtcDaliWebBackForwardListCheckItem(void)
1468 {
1469   ToolkitTestApplication application;
1470
1471   WebView view = WebView::New();
1472   DALI_TEST_CHECK(view);
1473
1474   Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1475   DALI_TEST_CHECK(bfList != 0)
1476
1477   unsigned int itemCount = bfList->GetItemCount();
1478   DALI_TEST_CHECK(itemCount == 1)
1479
1480   std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1481   DALI_TEST_CHECK(citem != 0);
1482
1483   std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1484   DALI_TEST_CHECK(citemP != 0);
1485
1486   std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1487   DALI_TEST_CHECK(citemN != 0);
1488
1489   const std::string kDefaultUrl("http://url");
1490   std::string       testValue = citem->GetUrl();
1491   DALI_TEST_EQUALS(testValue, kDefaultUrl, TEST_LOCATION);
1492
1493   const std::string kDefaultTitle("title");
1494   testValue = citem->GetTitle();
1495   DALI_TEST_EQUALS(testValue, kDefaultTitle, TEST_LOCATION);
1496
1497   const std::string kDefaultOriginalUrl("http://originalurl");
1498   testValue = citem->GetOriginalUrl();
1499   DALI_TEST_EQUALS(testValue, kDefaultOriginalUrl, TEST_LOCATION);
1500
1501   std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex(0);
1502   DALI_TEST_CHECK(item != 0);
1503
1504   std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1505   DALI_TEST_CHECK(vecBack.size() == 1);
1506
1507   std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1508   DALI_TEST_CHECK(vecForward.size() == 1);
1509
1510   END_TEST;
1511 }
1512
1513 // test cases for web context.
1514
1515 int UtcDaliWebContextGetSetCacheModelEtc(void)
1516 {
1517   ToolkitTestApplication application;
1518
1519   Dali::WebEngineContext* context = WebView::GetContext();
1520   DALI_TEST_CHECK(context != 0)
1521
1522   std::string kDefaultValue;
1523
1524   // Reset something
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();
1536
1537   // Check default value
1538   Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1539   DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER);
1540
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);
1545
1546   // Get cache enabled
1547   context->EnableCache(true);
1548   DALI_TEST_CHECK(context->IsCacheEnabled());
1549
1550   // Get certificate
1551   context->SetCertificateFilePath("test");
1552   std::string str = context->GetCertificateFilePath();
1553   DALI_TEST_EQUALS(str, "test", TEST_LOCATION);
1554
1555   // Set version
1556   DALI_TEST_CHECK(context->SetAppVersion("test"));
1557
1558   // Register
1559   std::vector<std::string> temp;
1560   context->RegisterUrlSchemesAsCorsEnabled(temp);
1561   context->RegisterJsPluginMimeTypes(temp);
1562   context->DeleteFormPasswordDataList(temp);
1563
1564   // Get zoom factor
1565   context->SetDefaultZoomFactor(1.0f);
1566   DALI_TEST_EQUALS(context->GetDefaultZoomFactor(), float(1.0f), TEST_LOCATION);
1567
1568   // Delete cache and database
1569   DALI_TEST_CHECK(context->DeleteAllApplicationCache());
1570   DALI_TEST_CHECK(context->DeleteAllWebIndexedDatabase());
1571
1572   // Get contextProxy
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);
1577
1578   //Notify low memory
1579   DALI_TEST_CHECK(context->FreeUnusedMemory());
1580
1581   END_TEST;
1582 }
1583
1584 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1585 {
1586   ToolkitTestApplication application;
1587
1588   Dali::WebEngineContext* context = WebView::GetContext();
1589   DALI_TEST_CHECK(context != 0)
1590
1591   std::string kDefaultValue;
1592
1593   // get origins of web database
1594   bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1595   DALI_TEST_CHECK(result);
1596
1597   Test::EmitGlobalTimerSignal();
1598   DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION);
1599   DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1600
1601   Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1602   DALI_TEST_CHECK(origin);
1603
1604   result = context->DeleteWebDatabase(*origin);
1605   DALI_TEST_CHECK(result);
1606
1607   // get origins of web storage
1608   result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1609   DALI_TEST_CHECK(result);
1610
1611   Test::EmitGlobalTimerSignal();
1612   DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION);
1613   DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1614
1615   origin = gSecurityOriginList[0].get();
1616   DALI_TEST_CHECK(origin);
1617
1618   result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1619   DALI_TEST_CHECK(result);
1620   Test::EmitGlobalTimerSignal();
1621   DALI_TEST_EQUALS(gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION);
1622
1623   result = context->DeleteWebStorage(*origin);
1624   DALI_TEST_CHECK(result);
1625
1626   result = context->DeleteApplicationCache(*origin);
1627   DALI_TEST_CHECK(result);
1628
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);
1636
1637   context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1638   Test::EmitGlobalTimerSignal();
1639   DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1640
1641   context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1642   Test::EmitGlobalTimerSignal();
1643   DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1644
1645   gSecurityOriginList.clear();
1646   gPasswordDataList.clear();
1647
1648   END_TEST;
1649 }
1650
1651 int UtcDaliWebContextHttpRequestInterceptor(void)
1652 {
1653   ToolkitTestApplication application;
1654
1655   Dali::WebEngineContext* context = WebView::GetContext();
1656   DALI_TEST_CHECK(context != 0)
1657
1658   WebView view = WebView::New();
1659   DALI_TEST_CHECK(view);
1660
1661   // Check if web view is found or not when plugin is null.
1662   DALI_TEST_CHECK(!WebView::FindWebView(nullptr));
1663
1664   // load url.
1665   context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1666   DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1667   DALI_TEST_CHECK(!gRequestInterceptorInstance);
1668
1669   Test::EmitGlobalTimerSignal();
1670   DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 1, TEST_LOCATION);
1671
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));
1683
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()));
1687
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);
1694
1695   // Destroy web view.
1696   view.Reset();
1697   gRequestInterceptorInstance = nullptr;
1698
1699   END_TEST;
1700 }
1701
1702 // test cases for web cookie manager.
1703
1704 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1705 {
1706   ToolkitTestApplication application;
1707
1708   Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1709   DALI_TEST_CHECK(cookieManager != 0)
1710
1711   const std::string kDefaultValue;
1712
1713   // Reset something
1714   cookieManager->SetPersistentStorage(kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE);
1715   cookieManager->ClearCookies();
1716
1717   // Check default value
1718   Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1719   DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY);
1720
1721   // Check Set/GetProperty
1722   cookieManager->SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1723   value = cookieManager->GetCookieAcceptPolicy();
1724   DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1725
1726   END_TEST;
1727 }
1728
1729 int UtcDaliWebCookieManagerChangesWatch(void)
1730 {
1731   ToolkitTestApplication application;
1732
1733   Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1734   DALI_TEST_CHECK(cookieManager != 0)
1735
1736   cookieManager->ChangesWatch(&OnChangesWatch);
1737   Test::EmitGlobalTimerSignal();
1738   DALI_TEST_EQUALS(gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION);
1739
1740   END_TEST;
1741 }
1742
1743 // test cases for web settings.
1744
1745 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1746 {
1747   ToolkitTestApplication application;
1748
1749   WebView view = WebView::New();
1750   DALI_TEST_CHECK(view);
1751
1752   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1753   DALI_TEST_CHECK(settings != 0)
1754
1755   // Reset something
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);
1764
1765   // Check default value
1766   int value = settings->GetDefaultFontSize();
1767   DALI_TEST_CHECK(value == 16);
1768
1769   // Check Set/GetProperty
1770   settings->SetDefaultFontSize(20);
1771   value = settings->GetDefaultFontSize();
1772   DALI_TEST_CHECK(value == 20);
1773
1774   END_TEST;
1775 }
1776
1777 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1778 {
1779   ToolkitTestApplication application;
1780
1781   WebView view = WebView::New();
1782   DALI_TEST_CHECK(view);
1783
1784   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1785   DALI_TEST_CHECK(settings != 0)
1786
1787   // Reset something
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);
1796
1797   // Check default value is true or not
1798   bool value = settings->IsJavaScriptEnabled();
1799   DALI_TEST_CHECK(value);
1800
1801   // Check Set/GetProperty
1802   settings->EnableJavaScript(false);
1803   value = settings->IsJavaScriptEnabled();
1804   DALI_TEST_CHECK(!value);
1805
1806   END_TEST;
1807 }
1808
1809 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1810 {
1811   ToolkitTestApplication application;
1812
1813   WebView view = WebView::New();
1814   DALI_TEST_CHECK(view);
1815
1816   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1817   DALI_TEST_CHECK(settings != 0)
1818
1819   // Reset something
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);
1828
1829   // Check default value is true or not
1830   bool value = settings->IsAutoFittingEnabled();
1831   DALI_TEST_CHECK(value);
1832
1833   // Check Set/GetProperty
1834   settings->EnableAutoFitting(false);
1835   value = settings->IsAutoFittingEnabled();
1836   DALI_TEST_CHECK(!value);
1837
1838   END_TEST;
1839 }
1840
1841 int UtcDaliWebSettingsCheckEnablePlugins(void)
1842 {
1843   ToolkitTestApplication application;
1844
1845   WebView view = WebView::New();
1846   DALI_TEST_CHECK(view);
1847
1848   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1849   DALI_TEST_CHECK(settings != 0)
1850
1851   // Reset something
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);
1860
1861   // Check default value is true or not
1862   bool value = settings->ArePluginsEnabled();
1863   DALI_TEST_CHECK(value);
1864
1865   // Check Set/GetProperty
1866   settings->EnablePlugins(false);
1867   value = settings->ArePluginsEnabled();
1868   DALI_TEST_CHECK(!value);
1869
1870   END_TEST;
1871 }
1872
1873 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1874 {
1875   ToolkitTestApplication application;
1876
1877   WebView view = WebView::New();
1878   DALI_TEST_CHECK(view);
1879
1880   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1881   DALI_TEST_CHECK(settings != 0)
1882
1883   // Reset something
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);
1892
1893   // Check default value is true or not
1894   bool value = settings->IsPrivateBrowsingEnabled();
1895   DALI_TEST_CHECK(value);
1896
1897   // Check Set/GetProperty
1898   settings->EnablePrivateBrowsing(false);
1899   value = settings->IsPrivateBrowsingEnabled();
1900   DALI_TEST_CHECK(!value);
1901
1902   END_TEST;
1903 }
1904
1905 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1906 {
1907   ToolkitTestApplication application;
1908
1909   WebView view = WebView::New();
1910   DALI_TEST_CHECK(view);
1911
1912   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1913   DALI_TEST_CHECK(settings != 0)
1914
1915   // Reset something
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);
1924
1925   // Check default value is true or not
1926   bool value = settings->IsLinkMagnifierEnabled();
1927   DALI_TEST_CHECK(value);
1928
1929   // Check Set/GetProperty
1930   settings->EnableLinkMagnifier(false);
1931   value = settings->IsLinkMagnifierEnabled();
1932   DALI_TEST_CHECK(!value);
1933
1934   END_TEST;
1935 }
1936
1937 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1938 {
1939   ToolkitTestApplication application;
1940
1941   WebView view = WebView::New();
1942   DALI_TEST_CHECK(view);
1943
1944   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1945   DALI_TEST_CHECK(settings != 0)
1946
1947   // Reset something
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);
1956
1957   // Check default value is true or not
1958   bool value = settings->IsKeypadWithoutUserActionUsed();
1959   DALI_TEST_CHECK(value);
1960
1961   // Check Set/GetProperty
1962   settings->UseKeypadWithoutUserAction(false);
1963   value = settings->IsKeypadWithoutUserActionUsed();
1964   DALI_TEST_CHECK(!value);
1965
1966   END_TEST;
1967 }
1968
1969 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1970 {
1971   ToolkitTestApplication application;
1972
1973   WebView view = WebView::New();
1974   DALI_TEST_CHECK(view);
1975
1976   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1977   DALI_TEST_CHECK(settings != 0)
1978
1979   // Reset something
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);
1988
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);
1995   END_TEST;
1996 }
1997
1998 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1999 {
2000   ToolkitTestApplication application;
2001
2002   WebView view = WebView::New();
2003   DALI_TEST_CHECK(view);
2004
2005   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2006   DALI_TEST_CHECK(settings != 0);
2007
2008   // Reset something
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);
2017
2018   // Check default value is true or not
2019   bool value = settings->IsFormCandidateDataEnabled();
2020   DALI_TEST_CHECK(value);
2021
2022   // Check Set/GetProperty
2023   settings->EnableFormCandidateData(false);
2024   value = settings->IsFormCandidateDataEnabled();
2025   DALI_TEST_CHECK(!value);
2026
2027   END_TEST;
2028 }
2029
2030 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2031 {
2032   ToolkitTestApplication application;
2033
2034   WebView view = WebView::New();
2035   DALI_TEST_CHECK(view);
2036
2037   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2038   DALI_TEST_CHECK(settings != 0);
2039
2040   // Reset something
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);
2049
2050   // Check default value is true or not
2051   bool value = settings->IsTextSelectionEnabled();
2052   DALI_TEST_CHECK(value);
2053
2054   //Check Set/GetProperty
2055   settings->EnableTextSelection(false);
2056   value = settings->IsTextSelectionEnabled();
2057   DALI_TEST_CHECK(!value);
2058
2059   END_TEST;
2060 }
2061
2062 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2063 {
2064   ToolkitTestApplication application;
2065
2066   WebView view = WebView::New();
2067   DALI_TEST_CHECK(view);
2068
2069   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2070   DALI_TEST_CHECK(settings != 0);
2071
2072   // Reset something
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);
2081
2082   // Check default value is true or not
2083   bool value = settings->IsTextAutosizingEnabled();
2084   DALI_TEST_CHECK(value);
2085
2086   // Check Set/GetProperty
2087   settings->EnableTextAutosizing(false);
2088   value = settings->IsTextAutosizingEnabled();
2089   DALI_TEST_CHECK(!value);
2090
2091   END_TEST;
2092 }
2093
2094 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2095 {
2096   ToolkitTestApplication application;
2097
2098   WebView view = WebView::New();
2099   DALI_TEST_CHECK(view);
2100
2101   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2102   DALI_TEST_CHECK(settings != 0);
2103
2104   // Reset something
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);
2113
2114   // Check default value is true or not
2115   bool value = settings->IsArrowScrollEnabled();
2116   DALI_TEST_CHECK(value);
2117
2118   // Check Set/GetProperty
2119   settings->EnableArrowScroll(false);
2120   value = settings->IsArrowScrollEnabled();
2121   DALI_TEST_CHECK(!value);
2122
2123   END_TEST;
2124 }
2125
2126 int UtcDaliWebSettingsCheckEnableClipboard(void)
2127 {
2128   ToolkitTestApplication application;
2129
2130   WebView view = WebView::New();
2131   DALI_TEST_CHECK(view);
2132
2133   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2134   DALI_TEST_CHECK(settings != 0);
2135
2136   // Reset something
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);
2145
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);
2152   END_TEST;
2153 }
2154
2155 int UtcDaliWebSettingsCheckEnableImePanel(void)
2156 {
2157   ToolkitTestApplication application;
2158
2159   WebView view = WebView::New();
2160   DALI_TEST_CHECK(view);
2161
2162   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2163   DALI_TEST_CHECK(settings != 0);
2164
2165   // Reset something
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);
2174
2175   // Check default value is true or not
2176   bool value = settings->IsImePanelEnabled();
2177   DALI_TEST_CHECK(value);
2178
2179   // Check Set/GetProperty
2180   settings->EnableImePanel(false);
2181   value = settings->IsImePanelEnabled();
2182   DALI_TEST_CHECK(!value);
2183
2184   END_TEST;
2185 }
2186
2187 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2188 {
2189   ToolkitTestApplication application;
2190
2191   WebView view = WebView::New();
2192   DALI_TEST_CHECK(view);
2193
2194   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2195   DALI_TEST_CHECK(settings != 0)
2196
2197   // Reset something
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);
2206
2207   // Check default value is true or not
2208   bool value = settings->AreImagesLoadedAutomatically();
2209   DALI_TEST_CHECK(value);
2210
2211   // Check Set/GetProperty
2212   settings->AllowImagesLoadAutomatically(false);
2213   value = settings->AreImagesLoadedAutomatically();
2214   DALI_TEST_CHECK(!value);
2215
2216   END_TEST;
2217 }
2218
2219 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2220 {
2221   ToolkitTestApplication application;
2222
2223   WebView view = WebView::New();
2224   DALI_TEST_CHECK(view);
2225
2226   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2227   DALI_TEST_CHECK(settings != 0)
2228
2229   const std::string kDefaultValue;
2230   const std::string kTestValue = "UTF-8";
2231
2232   // Reset something
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);
2241
2242   // Check default value
2243   std::string value = settings->GetDefaultTextEncodingName();
2244   DALI_TEST_EQUALS(value, kDefaultValue, TEST_LOCATION);
2245
2246   // Check Set/GetProperty
2247   settings->SetDefaultTextEncodingName(kTestValue);
2248   value = settings->GetDefaultTextEncodingName();
2249   DALI_TEST_EQUALS(value, kTestValue, TEST_LOCATION);
2250
2251   END_TEST;
2252 }
2253
2254 int UtcDaliWebSettingsSetViewportMetaTag(void)
2255 {
2256   ToolkitTestApplication application;
2257
2258   WebView view = WebView::New();
2259   DALI_TEST_CHECK(view);
2260
2261   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2262   DALI_TEST_CHECK(settings != 0)
2263
2264   // Check the value is true or not
2265   bool value = settings->SetViewportMetaTag(true);
2266   DALI_TEST_CHECK(value);
2267
2268   END_TEST;
2269 }
2270
2271 int UtcDaliWebSettingsSetForceZoom(void)
2272 {
2273   ToolkitTestApplication application;
2274
2275   WebView view = WebView::New();
2276   DALI_TEST_CHECK(view);
2277
2278   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2279   DALI_TEST_CHECK(settings != 0)
2280
2281   // Check the value is true or not
2282   bool value = settings->SetForceZoom(true);
2283   DALI_TEST_CHECK(value);
2284
2285   value = settings->IsZoomForced();
2286   DALI_TEST_CHECK(value);
2287
2288   END_TEST;
2289 }
2290
2291 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2292 {
2293   ToolkitTestApplication application;
2294
2295   WebView view = WebView::New();
2296   DALI_TEST_CHECK(view);
2297
2298   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2299   DALI_TEST_CHECK(settings != 0)
2300
2301   // Check the value is true or not
2302   bool value = settings->SetTextZoomEnabled(true);
2303   DALI_TEST_CHECK(value);
2304
2305   value = settings->IsTextZoomEnabled();
2306   DALI_TEST_CHECK(value);
2307
2308   END_TEST;
2309 }
2310
2311 int UtcDaliWebSettingsSetExtraFeature(void)
2312 {
2313   ToolkitTestApplication application;
2314
2315   WebView view = WebView::New();
2316   DALI_TEST_CHECK(view);
2317
2318   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2319   DALI_TEST_CHECK(settings != 0)
2320
2321   // Check the value is true or not
2322   settings->SetExtraFeature("test", true);
2323   bool value = settings->IsExtraFeatureEnabled("test");
2324   DALI_TEST_CHECK(value);
2325
2326   END_TEST;
2327 }
2328
2329 int UtcDaliWebViewGetPlainText(void)
2330 {
2331   ToolkitTestApplication application;
2332
2333   WebView view = WebView::New();
2334   DALI_TEST_CHECK(view);
2335
2336   view.LoadUrl(TEST_URL1);
2337
2338   view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2339   Test::EmitGlobalTimerSignal();
2340   DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);
2341
2342   END_TEST;
2343 }