[dali_2.3.41] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-WebView.cpp
1 /*
2  * Copyright (c) 2024 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-menu-item.h>
33 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context-menu.h>
34 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-context.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 int                                                                gNewWindowCreatedCallbackCalled        = 0;
83 static std::unique_ptr<Dali::WebEnginePolicyDecision>                     gResponsePolicyDecisionInstance        = nullptr;
84 static int                                                                gCertificateConfirmCallbackCalled      = 0;
85 static std::unique_ptr<Dali::WebEngineCertificate>                        gCertificateConfirmInstance            = nullptr;
86 static int                                                                gSslCertificateChangedCallbackCalled   = 0;
87 static std::unique_ptr<Dali::WebEngineCertificate>                        gSslCertificateInstance                = nullptr;
88 static int                                                                gHttpAuthHandlerCallbackCalled         = 0;
89 static std::unique_ptr<Dali::WebEngineHttpAuthHandler>                    gHttpAuthInstance                      = nullptr;
90 static int                                                                gSecurityOriginsAcquiredCallbackCalled = 0;
91 static int                                                                gStorageUsageAcquiredCallbackCalled    = 0;
92 static int                                                                gFormPasswordsAcquiredCallbackCalled   = 0;
93 static int                                                                gDownloadStartedCallbackCalled         = 0;
94 static int                                                                gMimeOverriddenCallbackCalled          = 0;
95 static int                                                                gRequestInterceptedCallbackCalled      = 0;
96 static Dali::WebEngineRequestInterceptorPtr                               gRequestInterceptorInstance            = nullptr;
97 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>        gSecurityOriginList;
98 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
99 static int                                                                gContextMenuShownCallbackCalled         = 0;
100 static std::unique_ptr<Dali::WebEngineContextMenu>                        gContextMenuShownInstance               = nullptr;
101 static int                                                                gContextMenuHiddenCallbackCalled        = 0;
102 static std::unique_ptr<Dali::WebEngineContextMenu>                        gContextMenuHiddenInstance              = nullptr;
103 static int                                                                gHitTestCreatedCallbackCalled           = 0;
104 static int                                                                gCookieManagerChangsWatchCallbackCalled = 0;
105 static int                                                                gPlainTextReceivedCallbackCalled        = 0;
106 static int                                                                gNewWindowPolicyDecidedCallbackCalled   = 0;
107 static int                                                                gFullscreenEnteredCallbackCalled        = 0;
108 static int                                                                gFullscreenExitedCallbackCalled         = 0;
109 static int                                                                gTextFoundCallbackCalled                = 0;
110
111 struct CallbackFunctor
112 {
113   CallbackFunctor(bool* callbackFlag)
114   : mCallbackFlag(callbackFlag)
115   {
116   }
117
118   void operator()()
119   {
120     *mCallbackFlag = true;
121   }
122   bool* mCallbackFlag;
123 };
124
125 static void OnPageLoadStarted(const std::string& url)
126 {
127   gPageLoadStartedCallbackCalled++;
128 }
129
130 static void OnPageLoadInProgress(const std::string& url)
131 {
132   gPageLoadInProgressCallbackCalled++;
133 }
134
135 static void OnPageLoadFinished(const std::string& url)
136 {
137   gPageLoadFinishedCallbackCalled++;
138 }
139
140 static void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
141 {
142   gScrollEdgeReachedCallbackCalled++;
143 }
144
145 static void OnResponsePolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
146 {
147   gResponsePolicyDecidedCallbackCalled++;
148   gResponsePolicyDecisionInstance = std::move(decision);
149 }
150
151 static void OnNavigationPolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
152 {
153   gNavigationPolicyDecidedCallbackCalled++;
154 }
155
156 static void OnNewWindowCreated(Dali::WebEnginePlugin*& outPlugin)
157 {
158   gNewWindowCreatedCallbackCalled++;
159   WebView newView = WebView::New();
160   outPlugin       = newView.GetPlugin();
161 }
162
163 static void OnUrlChanged(const std::string& url)
164 {
165   gUrlChangedCallbackCalled++;
166 }
167
168 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
169 {
170   gHitTestCreatedCallbackCalled++;
171   return true;
172 }
173
174 static bool OnPlainTextReceived(const std::string& plainText)
175 {
176   gPlainTextReceivedCallbackCalled++;
177   return true;
178 }
179
180 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
181 {
182   gPageLoadErrorCallbackCalled++;
183   gPageLoadErrorInstance = std::move(error);
184 }
185
186 static void OnEvaluateJavaScript(const std::string& result)
187 {
188   gEvaluateJavaScriptCallbackCalled++;
189 }
190
191 static bool OnJavaScriptAlert(const std::string& result)
192 {
193   gJavaScriptAlertCallbackCalled++;
194   return true;
195 }
196
197 static bool OnJavaScriptConfirm(const std::string& result)
198 {
199   gJavaScriptConfirmCallbackCalled++;
200   return true;
201 }
202
203 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
204 {
205   gJavaScriptPromptCallbackCalled++;
206   return true;
207 }
208
209 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
210 {
211   gScreenshotCapturedCallbackCalled++;
212 }
213
214 static void OnVideoPlaying(bool isPlaying)
215 {
216   gVideoPlayingCallbackCalled++;
217 }
218
219 static bool OnGeolocationPermission(const std::string&, const std::string&)
220 {
221   gGeolocationPermissionCallbackCalled++;
222   return true;
223 }
224
225 static bool OnTouched(Actor actor, const Dali::TouchEvent& touch)
226 {
227   gTouched = true;
228   return true;
229 }
230
231 static void OnChangesWatch()
232 {
233   gCookieManagerChangsWatchCallbackCalled++;
234 }
235
236 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
237 {
238   gHovered = true;
239   return true;
240 }
241
242 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
243 {
244   gWheelEventHandled = true;
245   return true;
246 }
247
248 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
249 {
250   gFormRepostDecidedCallbackCalled++;
251   gFormRepostDecidedInstance = std::move(decision);
252 }
253
254 static void OnFrameRendered()
255 {
256   gFrameRenderedCallbackCalled++;
257 }
258
259 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
260 {
261   gConsoleMessageCallbackCalled++;
262   gConsoleMessageInstance = std::move(message);
263 }
264
265 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
266 {
267   gCertificateConfirmCallbackCalled++;
268   gCertificateConfirmInstance = std::move(certificate);
269 }
270
271 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
272 {
273   gSslCertificateChangedCallbackCalled++;
274   gSslCertificateInstance = std::move(certificate);
275 }
276
277 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
278 {
279   gHttpAuthHandlerCallbackCalled++;
280   gHttpAuthInstance = std::move(hander);
281 }
282
283 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
284 {
285   gSecurityOriginsAcquiredCallbackCalled++;
286   gSecurityOriginList.clear();
287   gSecurityOriginList.swap(origins);
288 }
289
290 static void OnStorageUsageAcquired(uint64_t usage)
291 {
292   gStorageUsageAcquiredCallbackCalled++;
293 }
294
295 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
296 {
297   gFormPasswordsAcquiredCallbackCalled++;
298   gPasswordDataList.clear();
299   gPasswordDataList.swap(passwords);
300 }
301
302 static void OnDownloadStarted(const std::string& url)
303 {
304   gDownloadStartedCallbackCalled++;
305 }
306
307 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
308 {
309   gMimeOverriddenCallbackCalled++;
310   return false;
311 }
312
313 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
314 {
315   gRequestInterceptedCallbackCalled++;
316   gRequestInterceptorInstance = interceptor;
317   return false;
318 }
319
320 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
321 {
322   gContextMenuShownCallbackCalled++;
323   gContextMenuShownInstance = std::move(menu);
324 }
325
326 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
327 {
328   gContextMenuHiddenCallbackCalled++;
329   gContextMenuHiddenInstance = std::move(menu);
330 }
331
332 static void OnNewWindowPolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
333 {
334   gNewWindowPolicyDecidedCallbackCalled++;
335 }
336
337 static void OnFullscreenEntered()
338 {
339   gFullscreenEnteredCallbackCalled++;
340 }
341
342 static void OnFullscreenExited()
343 {
344   gFullscreenExitedCallbackCalled++;
345 }
346
347 static void OnTextFound(uint32_t arg)
348 {
349   gTextFoundCallbackCalled++;
350 }
351
352 } // namespace
353
354 void web_view_startup(void)
355 {
356   test_return_value = TET_UNDEF;
357 }
358
359 void web_view_cleanup(void)
360 {
361   test_return_value = TET_PASS;
362 }
363
364 int UtcDaliWebViewBasics(void)
365 {
366   ToolkitTestApplication application;
367
368   // Copy and Assignment Test
369   tet_infoline("UtcDaliWebViewBasic Copy and Assignment Test");
370   WebView view = WebView::New();
371   DALI_TEST_CHECK(view);
372
373   WebView copy(view);
374   DALI_TEST_CHECK(view == copy);
375
376   WebView assign;
377   DALI_TEST_CHECK(!assign);
378
379   assign = copy;
380   DALI_TEST_CHECK(assign == view);
381
382   // DownCast Test
383   tet_infoline("UtcDaliWebViewBasic DownCast Test");
384   BaseHandle handle(view);
385
386   WebView view2 = WebView::DownCast(handle);
387   DALI_TEST_CHECK(view);
388   DALI_TEST_CHECK(view2);
389   DALI_TEST_CHECK(view == view2);
390
391   // TypeRegistry Test
392   tet_infoline("UtcDaliWebViewBasic TypeRegistry Test");
393   TypeRegistry typeRegistry = TypeRegistry::Get();
394   DALI_TEST_CHECK(typeRegistry);
395
396   TypeInfo typeInfo = typeRegistry.GetTypeInfo("WebView");
397   DALI_TEST_CHECK(typeInfo);
398
399   BaseHandle handle2 = typeInfo.CreateInstance();
400   DALI_TEST_CHECK(handle2);
401
402   WebView view3 = WebView::DownCast(handle2);
403   DALI_TEST_CHECK(view3);
404
405   END_TEST;
406 }
407
408 int UtcDaliWebViewPageNavigation(void)
409 {
410   ToolkitTestApplication application;
411
412   WebView view = WebView::New();
413   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
414   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
415   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
416   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
417   application.GetScene().Add(view);
418   application.SendNotification();
419   application.Render();
420   DALI_TEST_CHECK(view);
421
422   view.RegisterPageLoadStartedCallback(&OnPageLoadStarted);
423   view.RegisterPageLoadInProgressCallback(&OnPageLoadInProgress);
424   view.RegisterPageLoadFinishedCallback(&OnPageLoadFinished);
425   view.RegisterUrlChangedCallback(&OnUrlChanged);
426   DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 0, TEST_LOCATION);
427   DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION);
428   DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION);
429   DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 0, TEST_LOCATION);
430
431   view.LoadUrl(TEST_URL1);
432   view.GetNaturalSize();
433   Test::EmitGlobalTimerSignal();
434   DALI_TEST_EQUALS(view.CanGoBack(), false, TEST_LOCATION);
435   DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 1, TEST_LOCATION);
436   DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION);
437   DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION);
438   DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 1, TEST_LOCATION);
439
440   view.LoadUrl(TEST_URL2);
441   view.Suspend();
442   view.SetProperty(Actor::Property::SIZE, Vector2(400, 300));
443   application.SendNotification();
444   application.Render();
445   Test::EmitGlobalTimerSignal();
446   view.Resume();
447   DALI_TEST_EQUALS(view.CanGoBack(), true, TEST_LOCATION);
448   DALI_TEST_EQUALS(view.CanGoForward(), false, TEST_LOCATION);
449   DALI_TEST_EQUALS(gPageLoadStartedCallbackCalled, 2, TEST_LOCATION);
450   DALI_TEST_EQUALS(gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION);
451   DALI_TEST_EQUALS(gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION);
452   DALI_TEST_EQUALS(gUrlChangedCallbackCalled, 2, TEST_LOCATION);
453
454   view.GoBack();
455   Test::EmitGlobalTimerSignal();
456   DALI_TEST_CHECK(!view.CanGoBack());
457   DALI_TEST_CHECK(view.CanGoForward());
458
459   view.GoForward();
460   Test::EmitGlobalTimerSignal();
461   DALI_TEST_CHECK(view.CanGoBack());
462   DALI_TEST_CHECK(!view.CanGoForward());
463
464   view.Reload();
465   view.StopLoading();
466   view.ClearHistory();
467   Test::EmitGlobalTimerSignal();
468   DALI_TEST_CHECK(!view.CanGoBack());
469   DALI_TEST_CHECK(!view.CanGoForward());
470
471   END_TEST;
472 }
473
474 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
475 {
476   ToolkitTestApplication application;
477
478   WebView view = WebView::New();
479   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
480   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
481   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
482   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
483   application.GetScene().Add(view);
484   application.SendNotification();
485   application.Render();
486   DALI_TEST_CHECK(view);
487
488   view.RegisterPageLoadErrorCallback(&OnPageLoadError);
489   view.RegisterConsoleMessageReceivedCallback(&OnConsoleMessage);
490   DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 0, TEST_LOCATION);
491   DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 0, TEST_LOCATION);
492
493   view.LoadUrl(TEST_URL1);
494   Test::EmitGlobalTimerSignal();
495   DALI_TEST_EQUALS(gPageLoadErrorCallbackCalled, 1, TEST_LOCATION);
496   DALI_TEST_EQUALS(gConsoleMessageCallbackCalled, 1, TEST_LOCATION);
497
498   // error code.
499   DALI_TEST_CHECK(gPageLoadErrorInstance);
500   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
501   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
502   std::string testErrorDescription("This is an error.");
503   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
504   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
505
506   // console message.
507   DALI_TEST_CHECK(gConsoleMessageInstance);
508   std::string testConsoleSource("source");
509   DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
510   DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
511   DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
512   std::string testConsoleText("This is a text.");
513   DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
514
515   // reset
516   gPageLoadErrorInstance  = nullptr;
517   gConsoleMessageInstance = nullptr;
518
519   END_TEST;
520 }
521
522 int UtcDaliWebViewTouchAndKeys(void)
523 {
524   ToolkitTestApplication application;
525
526   WebView view = WebView::New();
527   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
528   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
529   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
530   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
531
532   application.GetScene().Add(view);
533   application.SendNotification();
534   application.Render();
535
536   view.GetNaturalSize();
537   view.TouchedSignal().Connect(&OnTouched);
538
539   // Touch event
540   Dali::Integration::TouchEvent event;
541   Dali::Integration::Point      pointDown, pointUp;
542
543   event = Dali::Integration::TouchEvent();
544   pointDown.SetState(PointState::DOWN);
545   pointDown.SetScreenPosition(Vector2(10, 10));
546   event.AddPoint(pointDown);
547   application.ProcessEvent(event);
548
549   event = Dali::Integration::TouchEvent();
550   pointUp.SetState(PointState::UP);
551   pointUp.SetScreenPosition(Vector2(10, 10));
552   event.AddPoint(pointUp);
553   application.ProcessEvent(event);
554
555   // Key event
556   Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor(view);
557   application.ProcessEvent(Integration::KeyEvent("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE));
558   application.SendNotification();
559
560   DALI_TEST_CHECK(gTouched);
561   DALI_TEST_CHECK(view);
562
563   END_TEST;
564 }
565
566 int UtcDaliWebViewFocusGainedAndLost(void)
567 {
568   ToolkitTestApplication application;
569
570   WebView view = WebView::New();
571   DALI_TEST_CHECK(view);
572
573   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
574   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
575   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
576   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
577
578   application.GetScene().Add(view);
579   application.SendNotification();
580   application.Render();
581
582   view.SetKeyInputFocus();
583   DALI_TEST_CHECK(view.HasKeyInputFocus());
584
585   // reset
586   view.ClearKeyInputFocus();
587   DALI_TEST_CHECK(!view.HasKeyInputFocus());
588
589   END_TEST;
590 }
591
592 int UtcDaliWebViewPropertyPageZoomFactor(void)
593 {
594   ToolkitTestApplication application;
595
596   WebView view = WebView::New();
597   DALI_TEST_CHECK(view);
598
599   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
600   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
601   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
602   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
603
604   application.GetScene().Add(view);
605   application.SendNotification();
606   application.Render();
607
608   view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
609   float zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
610   DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
611
612   view.SetProperty(WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
613   zoomFactor = view.GetProperty<float>(WebView::Property::PAGE_ZOOM_FACTOR);
614   DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
615
616   END_TEST;
617 }
618
619 int UtcDaliWebViewPropertyTextZoomFactor(void)
620 {
621   ToolkitTestApplication application;
622
623   WebView view = WebView::New();
624   DALI_TEST_CHECK(view);
625
626   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
627   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
628   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
629   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
630
631   application.GetScene().Add(view);
632   application.SendNotification();
633   application.Render();
634
635   view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
636   float zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
637   DALI_TEST_EQUALS(zoomFactor, 1.5f, TEST_LOCATION);
638
639   view.SetProperty(WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
640   zoomFactor = view.GetProperty<float>(WebView::Property::TEXT_ZOOM_FACTOR);
641   DALI_TEST_EQUALS(zoomFactor, 1.0f, TEST_LOCATION);
642
643   END_TEST;
644 }
645
646 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
647 {
648   ToolkitTestApplication application;
649
650   WebView view = WebView::New();
651   DALI_TEST_CHECK(view);
652
653   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
654   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
655   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
656   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
657
658   application.GetScene().Add(view);
659   application.SendNotification();
660   application.Render();
661
662   float percentage = view.GetProperty<float>(WebView::Property::LOAD_PROGRESS_PERCENTAGE);
663   DALI_TEST_EQUALS(percentage, 0.5f, TEST_LOCATION);
664
665   END_TEST;
666 }
667
668 int UtcDaliWebViewMove(void)
669 {
670   ToolkitTestApplication application;
671
672   WebView view = WebView::New();
673   DALI_TEST_CHECK(view);
674
675   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
676   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
677   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
678   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
679
680   application.GetScene().Add(view);
681   application.SendNotification();
682   application.Render();
683
684   view.SetProperty(Actor::Property::POSITION, Vector2(100, 100));
685   Vector3 viewPos = view.GetProperty<Vector3>(Actor::Property::POSITION);
686   DALI_TEST_EQUALS(viewPos, Vector3(100, 100, 0), TEST_LOCATION);
687
688   END_TEST;
689 }
690
691 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
692 {
693   ToolkitTestApplication application;
694
695   WebView view = WebView::New();
696   DALI_TEST_CHECK(view);
697
698   const bool kDefaultValue = false;
699   const bool kTestValue    = true;
700
701   // Check default value
702   bool            output;
703   Property::Value value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
704   DALI_TEST_CHECK(value.Get(output));
705   DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
706
707   // Check Set/GetProperty
708   view.SetProperty(WebView::Property::VIDEO_HOLE_ENABLED, kTestValue);
709   value = view.GetProperty(WebView::Property::VIDEO_HOLE_ENABLED);
710   DALI_TEST_CHECK(value.Get(output));
711   DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
712
713   END_TEST;
714 }
715
716 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
717 {
718   ToolkitTestApplication application;
719
720   WebView view = WebView::New();
721   DALI_TEST_CHECK(view);
722
723   const bool kDefaultValue = true;
724   const bool kTestValue    = false;
725
726   // Check default value
727   bool            output;
728   Property::Value value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
729   DALI_TEST_CHECK(value.Get(output));
730   DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
731
732   // Check Set/GetProperty
733   view.SetProperty(WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue);
734   value = view.GetProperty(WebView::Property::MOUSE_EVENTS_ENABLED);
735   DALI_TEST_CHECK(value.Get(output));
736   DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
737
738   END_TEST;
739 }
740
741 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
742 {
743   ToolkitTestApplication application;
744
745   WebView view = WebView::New();
746   DALI_TEST_CHECK(view);
747
748   const bool kDefaultValue = true;
749   const bool kTestValue    = false;
750
751   // Check default value
752   bool            output;
753   Property::Value value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
754   DALI_TEST_CHECK(value.Get(output));
755   DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
756
757   // Check Set/GetProperty
758   view.SetProperty(WebView::Property::KEY_EVENTS_ENABLED, kTestValue);
759   value = view.GetProperty(WebView::Property::KEY_EVENTS_ENABLED);
760   DALI_TEST_CHECK(value.Get(output));
761   DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
762
763   END_TEST;
764 }
765
766 int UtcDaliWebViewHoverAndWheel(void)
767 {
768   ToolkitTestApplication application;
769
770   WebView view = WebView::New();
771   DALI_TEST_CHECK(view);
772   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
773   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
774   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
775   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
776
777   application.GetScene().Add(view);
778   application.SendNotification();
779   application.Render();
780
781   view.GetNaturalSize();
782   view.HoveredSignal().Connect(&OnHovered);
783   view.WheelEventSignal().Connect(&OnWheelEvent);
784
785   // Hover event
786   Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
787   Dali::Integration::Point      pointDown;
788   pointDown.SetState(PointState::DOWN);
789   pointDown.SetScreenPosition(Vector2(10, 10));
790   event.AddPoint(pointDown);
791   application.ProcessEvent(event);
792
793   event = Dali::Integration::HoverEvent();
794   Dali::Integration::Point pointUp;
795   pointUp.SetState(PointState::UP);
796   pointUp.SetScreenPosition(Vector2(10, 10));
797   event.AddPoint(pointUp);
798   application.ProcessEvent(event);
799
800   event = Dali::Integration::HoverEvent();
801   Dali::Integration::Point pointMotion;
802   pointUp.SetState(PointState::MOTION);
803   pointUp.SetScreenPosition(Vector2(10, 10));
804   event.AddPoint(pointMotion);
805   application.ProcessEvent(event);
806
807   // Wheel event
808   Dali::Integration::WheelEvent wheelEvent;
809   wheelEvent.type      = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
810   wheelEvent.direction = 0;
811   wheelEvent.point     = Vector2(20, 20);
812   wheelEvent.delta     = 10;
813   application.ProcessEvent(wheelEvent);
814   application.SendNotification();
815
816   DALI_TEST_CHECK(gHovered);
817   DALI_TEST_CHECK(gWheelEventHandled);
818
819   END_TEST;
820 }
821
822 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
823 {
824   ToolkitTestApplication application;
825
826   WebView view = WebView::New();
827   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
828   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
829   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
830   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
831   application.GetScene().Add(view);
832   application.SendNotification();
833   application.Render();
834   DALI_TEST_CHECK(view);
835
836   view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
837   view.RegisterFrameRenderedCallback(&OnFrameRendered);
838   DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION);
839   DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 0, TEST_LOCATION);
840
841   view.LoadUrl(TEST_URL1);
842   Test::EmitGlobalTimerSignal();
843   DALI_TEST_EQUALS(gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION);
844   DALI_TEST_EQUALS(gFrameRenderedCallbackCalled, 1, TEST_LOCATION);
845
846   // form repost decision.
847   DALI_TEST_CHECK(gFormRepostDecidedInstance);
848   gFormRepostDecidedInstance->Reply(true);
849
850   // reset
851   gFormRepostDecidedInstance = nullptr;
852
853   END_TEST;
854 }
855
856 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
857 {
858   ToolkitTestApplication application;
859
860   WebView view = WebView::New();
861   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
862   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
863   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
864   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
865   application.GetScene().Add(view);
866   application.SendNotification();
867   application.Render();
868   DALI_TEST_CHECK(view);
869
870   view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
871   view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
872   view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
873   DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 0, TEST_LOCATION);
874   DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION);
875   DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION);
876
877   view.LoadUrl(TEST_URL1);
878   Test::EmitGlobalTimerSignal();
879   DALI_TEST_EQUALS(gCertificateConfirmCallbackCalled, 1, TEST_LOCATION);
880   DALI_TEST_EQUALS(gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION);
881   DALI_TEST_EQUALS(gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION);
882
883   // certificate.
884   DALI_TEST_CHECK(gCertificateConfirmInstance);
885   gCertificateConfirmInstance->Allow(true);
886   DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
887
888   DALI_TEST_CHECK(gSslCertificateInstance);
889   DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
890   DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
891   DALI_TEST_EQUALS(gSslCertificateInstance->GetPolicyDecisionError(), 1, TEST_LOCATION);
892   DALI_TEST_CHECK(gSslCertificateInstance->SuspendPolicyDecision());
893
894   // http authentication.
895   DALI_TEST_CHECK(gHttpAuthInstance);
896   gHttpAuthInstance->Suspend();
897   gHttpAuthInstance->UseCredential("", "");
898   gHttpAuthInstance->CancelCredential();
899   DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
900
901   // reset
902   gCertificateConfirmInstance = nullptr;
903   gSslCertificateInstance     = nullptr;
904   gHttpAuthInstance           = nullptr;
905
906   END_TEST;
907 }
908
909 int UtcDaliWebViewGetWebBackForwardList(void)
910 {
911   ToolkitTestApplication application;
912
913   WebView view = WebView::New();
914   DALI_TEST_CHECK(view);
915
916   Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
917   DALI_TEST_CHECK(bfList != 0);
918
919   END_TEST;
920 }
921
922 int UtcDaliWebViewGetWebContext(void)
923 {
924   ToolkitTestApplication application;
925
926   Dali::WebEngineContext* context = WebView::GetContext();
927   DALI_TEST_CHECK(context != nullptr);
928
929   END_TEST;
930 }
931
932 int UtcDaliWebViewGetWebCookieManager(void)
933 {
934   ToolkitTestApplication application;
935
936   Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
937   DALI_TEST_CHECK(cookieManager != 0);
938
939   END_TEST;
940 }
941
942 int UtcDaliWebViewGetWebSettings(void)
943 {
944   ToolkitTestApplication application;
945
946   WebView view = WebView::New();
947   DALI_TEST_CHECK(view);
948
949   Dali::Toolkit::WebSettings* settings = view.GetSettings();
950   DALI_TEST_CHECK(settings != 0);
951
952   END_TEST;
953 }
954
955 int UtcDaliWebViewProperty1(void)
956 {
957   // URL
958   ToolkitTestApplication application;
959
960   WebView view = WebView::New();
961   DALI_TEST_CHECK(view);
962
963   std::string local;
964   view.SetProperty(WebView::Property::URL, TEST_URL1);
965   Property::Value val = view.GetProperty(WebView::Property::URL);
966   DALI_TEST_CHECK(val.Get(local));
967   DALI_TEST_EQUALS(local, TEST_URL1, TEST_LOCATION);
968
969   END_TEST;
970 }
971
972 int UtcDaliWebViewProperty4(void)
973 {
974   // USER_AGENT
975   ToolkitTestApplication application;
976
977   WebView view = WebView::New();
978   DALI_TEST_CHECK(view);
979
980   const std::string kDefaultValue;
981   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";
982
983   // Check default value
984   std::string     output;
985   Property::Value value = view.GetProperty(WebView::Property::USER_AGENT);
986   DALI_TEST_CHECK(value.Get(output));
987   DALI_TEST_EQUALS(output, kDefaultValue, TEST_LOCATION);
988
989   // Check Set/GetProperty
990   view.SetProperty(WebView::Property::USER_AGENT, kTestValue);
991   value = view.GetProperty(WebView::Property::USER_AGENT);
992   DALI_TEST_CHECK(value.Get(output));
993   DALI_TEST_EQUALS(output, kTestValue, TEST_LOCATION);
994
995   END_TEST;
996 }
997
998 int UtcDaliWebViewProperty9(void)
999 {
1000   // SCROLL_POSITION
1001   ToolkitTestApplication application;
1002
1003   WebView view = WebView::New();
1004   DALI_TEST_CHECK(view);
1005
1006   // Check default value
1007   Dali::Vector2 output = Dali::Vector2::ONE;
1008   view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1009   DALI_TEST_CHECK(output.x == 0 && output.y == 0);
1010
1011   // Check Set/GetProperty
1012   Dali::Vector2 testValue = Dali::Vector2(100, 100);
1013   view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
1014   view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1015   DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1016
1017   // Check default value of scroll size
1018   output = Dali::Vector2::ONE;
1019   view.GetProperty(WebView::Property::SCROLL_SIZE).Get(output);
1020   DALI_TEST_CHECK(output.x == 500 && output.y == 500);
1021
1022   // Check default value of content size
1023   output = Dali::Vector2::ONE;
1024   view.GetProperty(WebView::Property::CONTENT_SIZE).Get(output);
1025   DALI_TEST_CHECK(output.x == 500 && output.y == 500);
1026
1027   END_TEST;
1028 }
1029
1030 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
1031 {
1032   ToolkitTestApplication application;
1033
1034   WebView view = WebView::New();
1035   DALI_TEST_CHECK(view);
1036
1037   Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1038   view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
1039   view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
1040   view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
1041   view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
1042
1043   // Check default value
1044   std::string testText("test");
1045   std::string output;
1046   view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
1047   DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
1048
1049   END_TEST;
1050 }
1051
1052 int UtcDaliWebViewPropertyTitleFavicon(void)
1053 {
1054   ToolkitTestApplication application;
1055
1056   char    argv[] = "--test";
1057   WebView view   = WebView::New(1, (char**)&argv);
1058   DALI_TEST_CHECK(view);
1059
1060   // reset something
1061   view.ClearAllTilesResources();
1062
1063   // Check default value of title
1064   std::string testValue("title");
1065   std::string output;
1066   view.GetProperty(WebView::Property::TITLE).Get(output);
1067   DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1068
1069   // Check the case that favicon is not null.
1070   Dali::Toolkit::ImageView favicon = view.GetFavicon();
1071   DALI_TEST_CHECK(favicon);
1072   Dali::Vector3 iconsize = favicon.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1073   DALI_TEST_CHECK((int)iconsize.width == 2 && (int)iconsize.height == 2);
1074
1075   // Check the case that favicon is null.
1076   favicon = view.GetFavicon();
1077   DALI_TEST_CHECK(!favicon);
1078
1079   END_TEST;
1080 }
1081
1082 int UtcDaliWebViewContextMenuShownAndHidden(void)
1083 {
1084   ToolkitTestApplication application;
1085
1086   WebView view = WebView::New();
1087   DALI_TEST_CHECK(view);
1088
1089   // load url.
1090   view.RegisterContextMenuShownCallback(&OnContextMenuShown);
1091   view.RegisterContextMenuHiddenCallback(&OnContextMenuHidden);
1092   DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 0, TEST_LOCATION);
1093   DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 0, TEST_LOCATION);
1094   DALI_TEST_CHECK(gContextMenuShownInstance == 0);
1095   DALI_TEST_CHECK(gContextMenuHiddenInstance == 0);
1096
1097   view.LoadUrl(TEST_URL1);
1098   Test::EmitGlobalTimerSignal();
1099   DALI_TEST_EQUALS(gContextMenuShownCallbackCalled, 1, TEST_LOCATION);
1100   DALI_TEST_EQUALS(gContextMenuHiddenCallbackCalled, 1, TEST_LOCATION);
1101
1102   // check context meun & its items.
1103   DALI_TEST_CHECK(gContextMenuShownInstance != 0);
1104   std::unique_ptr<Dali::WebEngineContextMenuItem> item = gContextMenuShownInstance->GetItemAt(0);
1105   DALI_TEST_CHECK(item.get() != 0);
1106   std::vector<std::unique_ptr<Dali::WebEngineContextMenuItem>> itemList = gContextMenuShownInstance->GetItemList();
1107   DALI_TEST_CHECK(itemList.size() == 1);
1108   DALI_TEST_CHECK(gContextMenuShownInstance->RemoveItem(*(item.get())));
1109   DALI_TEST_CHECK(gContextMenuShownInstance->AppendItemAsAction(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", false));
1110   DALI_TEST_CHECK(gContextMenuShownInstance->AppendItem(WebEngineContextMenuItem::ItemTag::NO_ACTION, "", "", false));
1111   DALI_TEST_CHECK(gContextMenuShownInstance->SelectItem(*(item.get())));
1112   DALI_TEST_CHECK(gContextMenuShownInstance->Hide());
1113
1114   Dali::WebEngineContextMenuItem::ItemTag testItemTag = Dali::WebEngineContextMenuItem::ItemTag::NO_ACTION;
1115   DALI_TEST_EQUALS(item->GetTag(), testItemTag, TEST_LOCATION);
1116   Dali::WebEngineContextMenuItem::ItemType testItemType = Dali::WebEngineContextMenuItem::ItemType::ACTION;
1117   DALI_TEST_EQUALS(item->GetType(), testItemType, TEST_LOCATION);
1118   DALI_TEST_CHECK(item->IsEnabled());
1119   std::string testLinkUrl("http://test.html");
1120   DALI_TEST_EQUALS(item->GetLinkUrl(), testLinkUrl, TEST_LOCATION);
1121   std::string testImageUrl("http://test.jpg");
1122   DALI_TEST_EQUALS(item->GetImageUrl(), testImageUrl, TEST_LOCATION);
1123   std::string testTitle("title");
1124   DALI_TEST_EQUALS(item->GetTitle(), testTitle, TEST_LOCATION);
1125   DALI_TEST_CHECK(item->GetParentMenu().get() == 0);
1126
1127   DALI_TEST_CHECK(gContextMenuHiddenInstance != 0);
1128
1129   gContextMenuShownInstance  = nullptr;
1130   gContextMenuHiddenInstance = nullptr;
1131
1132   END_TEST;
1133 }
1134
1135 int UtcDaliWebViewScrollBy(void)
1136 {
1137   ToolkitTestApplication application;
1138
1139   WebView view = WebView::New();
1140   DALI_TEST_CHECK(view);
1141
1142   // load url.
1143   view.RegisterScrollEdgeReachedCallback(&OnScrollEdgeReached);
1144   DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION);
1145
1146   view.LoadUrl(TEST_URL1);
1147   Test::EmitGlobalTimerSignal();
1148
1149   // set scroll position.
1150   Dali::Vector2 output    = Dali::Vector2::ONE;
1151   Dali::Vector2 testValue = Dali::Vector2(100, 100);
1152   view.SetProperty(WebView::Property::SCROLL_POSITION, testValue);
1153   view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1154   DALI_TEST_EQUALS(output, testValue, TEST_LOCATION);
1155
1156   // scroll by and trigger scrollEdgeReached event.
1157   view.ScrollBy(50, 50);
1158   Test::EmitGlobalTimerSignal();
1159
1160   view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1161   DALI_TEST_CHECK(output.x == 150 && output.y == 150);
1162   DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION);
1163
1164   // scroll by and trigger scrollEdgeReached event.
1165   bool result = view.ScrollEdgeBy(50, 50);
1166   DALI_TEST_CHECK(result);
1167   Test::EmitGlobalTimerSignal();
1168
1169   view.GetProperty(WebView::Property::SCROLL_POSITION).Get(output);
1170   DALI_TEST_CHECK(output.x == 200 && output.y == 200);
1171   DALI_TEST_EQUALS(gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION);
1172
1173   END_TEST;
1174 }
1175
1176 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
1177 {
1178   ToolkitTestApplication application;
1179
1180   WebView view = WebView::New();
1181   DALI_TEST_CHECK(view);
1182
1183   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1184   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1185   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1186   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1187
1188   application.GetScene().Add(view);
1189   application.SendNotification();
1190   application.Render();
1191
1192   view.ActivateAccessibility(true);
1193   view.AddDynamicCertificatePath("host", "test/to/path");
1194   bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
1195   DALI_TEST_CHECK(found);
1196
1197   view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
1198   float result = view.GetScaleFactor();
1199   DALI_TEST_EQUALS(result, 1.5f, TEST_LOCATION);
1200
1201   view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
1202   result = view.GetScaleFactor();
1203   DALI_TEST_EQUALS(result, 1.0f, TEST_LOCATION);
1204
1205   END_TEST;
1206 }
1207
1208 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
1209 {
1210   // SCROLL_POSITION
1211   ToolkitTestApplication application;
1212
1213   char    argv[] = "--test";
1214   WebView view   = WebView::New(1, (char**)&argv);
1215   DALI_TEST_CHECK(view);
1216
1217   // Check GetScreenshot
1218   Dali::Rect<int> viewArea;
1219   viewArea.x                          = 100;
1220   viewArea.y                          = 100;
1221   viewArea.width                      = 10;
1222   viewArea.height                     = 10;
1223   Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1224   DALI_TEST_CHECK(screenshot);
1225   Dali::Vector3 shotsize = screenshot.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
1226   DALI_TEST_CHECK((int)shotsize.width == viewArea.width && (int)shotsize.height == viewArea.height);
1227
1228   // Check GetScreenshotAsynchronously
1229   viewArea.x      = 100;
1230   viewArea.y      = 100;
1231   viewArea.width  = 100;
1232   viewArea.height = 100;
1233   bool result     = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1234   DALI_TEST_CHECK(result);
1235
1236   Test::EmitGlobalTimerSignal();
1237
1238   Test::EmitGlobalTimerSignal();
1239   DALI_TEST_EQUALS(gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION);
1240
1241   END_TEST;
1242 }
1243
1244 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1245 {
1246   // SCROLL_POSITION
1247   ToolkitTestApplication application;
1248
1249   char    argv[] = "--test";
1250   WebView view   = WebView::New(1, (char**)&argv);
1251   DALI_TEST_CHECK(view);
1252
1253   // Check CheckVideoPlayingAsynchronously
1254   bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1255   DALI_TEST_CHECK(result);
1256   Test::EmitGlobalTimerSignal();
1257   DALI_TEST_EQUALS(gVideoPlayingCallbackCalled, 1, TEST_LOCATION);
1258
1259   // Check RegisterGeolocationPermissionCallback
1260   view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1261   Test::EmitGlobalTimerSignal();
1262   DALI_TEST_EQUALS(gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION);
1263
1264   END_TEST;
1265 }
1266
1267 int UtcDaliWebViewResponsePolicyDecisionRequest(void)
1268 {
1269   ToolkitTestApplication application;
1270
1271   WebView view = WebView::New();
1272   DALI_TEST_CHECK(view);
1273
1274   // load url.
1275   view.RegisterResponsePolicyDecidedCallback(&OnResponsePolicyDecided);
1276   DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1277   DALI_TEST_CHECK(gResponsePolicyDecisionInstance == 0);
1278
1279   view.LoadUrl(TEST_URL1);
1280   Test::EmitGlobalTimerSignal();
1281   DALI_TEST_EQUALS(gResponsePolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1282
1283   // check response policy decision & its frame.
1284   DALI_TEST_CHECK(gResponsePolicyDecisionInstance != 0);
1285   std::string testUrl("http://test.html");
1286   DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1287   std::string testCookie("test:abc");
1288   DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1289   Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1290   DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1291   std::string testResponseMime("txt/xml");
1292   DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1293   int32_t ResponseStatusCode = 500;
1294   DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1295   Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1296   DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1297   std::string testScheme("test");
1298   DALI_TEST_EQUALS(gResponsePolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1299   DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Use());
1300   DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Ignore());
1301   DALI_TEST_CHECK(gResponsePolicyDecisionInstance->Suspend());
1302
1303   Dali::WebEngineFrame* webFrame = &(gResponsePolicyDecisionInstance->GetFrame());
1304   DALI_TEST_CHECK(webFrame);
1305   DALI_TEST_CHECK(webFrame->IsMainFrame());
1306
1307   gResponsePolicyDecisionInstance = nullptr;
1308
1309   END_TEST;
1310 }
1311
1312 int UtcDaliWebViewNavigationPolicyDecisionRequest(void)
1313 {
1314   ToolkitTestApplication application;
1315
1316   WebView view = WebView::New();
1317   DALI_TEST_CHECK(view);
1318
1319   // load url.
1320   view.RegisterNavigationPolicyDecidedCallback(&OnNavigationPolicyDecided);
1321   DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 0, TEST_LOCATION);
1322
1323   view.LoadUrl(TEST_URL1);
1324   Test::EmitGlobalTimerSignal();
1325   DALI_TEST_EQUALS(gNavigationPolicyDecidedCallbackCalled, 1, TEST_LOCATION);
1326
1327   END_TEST;
1328 }
1329
1330 int UtcDaliWebViewNewWindowCreated(void)
1331 {
1332   ToolkitTestApplication application;
1333
1334   WebView view = WebView::New();
1335   DALI_TEST_CHECK(view);
1336
1337   // load url.
1338   view.RegisterNewWindowCreatedCallback(&OnNewWindowCreated);
1339   DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 0, TEST_LOCATION);
1340
1341   view.LoadUrl(TEST_URL1);
1342   Test::EmitGlobalTimerSignal();
1343   DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 1, TEST_LOCATION);
1344
1345   END_TEST;
1346 }
1347
1348 int UtcDaliWebViewHitTest(void)
1349 {
1350   ToolkitTestApplication application;
1351
1352   WebView view = WebView::New();
1353   DALI_TEST_CHECK(view);
1354
1355   // load url.
1356   view.LoadUrl(TEST_URL1);
1357
1358   // sync hit test.
1359   std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1360   DALI_TEST_CHECK(hitTest != 0);
1361   DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1362   std::string testLinkUri("http://test.html");
1363   DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1364   std::string testLinkTitle("test");
1365   DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1366   std::string testLinkLabel("label");
1367   DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1368   std::string testImageUri("http://test.jpg");
1369   DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1370   std::string testMediaUri("http://test.mp4");
1371   DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1372   std::string testTagName("img");
1373   DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1374   std::string testNodeValue("test");
1375   DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1376   Dali::Property::Map testMap = hitTest->GetAttributes();
1377   DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
1378   std::string testImageFileNameExtension("jpg");
1379   DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1380   Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1381   DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1382
1383   // async...
1384   bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1385   DALI_TEST_CHECK(result);
1386   Test::EmitGlobalTimerSignal();
1387   DALI_TEST_EQUALS(gHitTestCreatedCallbackCalled, 1, TEST_LOCATION);
1388
1389   END_TEST;
1390 }
1391
1392 int UtcDaliWebViewEvaluteJavaScript(void)
1393 {
1394   ToolkitTestApplication application;
1395
1396   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1397
1398   view.LoadHtmlString("<body>Hello World!</body>");
1399   view.EvaluateJavaScript("jsObject.postMessage('Hello')");
1400   view.EvaluateJavaScript("jsObject.postMessage('World')", OnEvaluateJavaScript);
1401   Test::EmitGlobalTimerSignal();
1402
1403   DALI_TEST_EQUALS(gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION);
1404
1405   END_TEST;
1406 }
1407
1408 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1409 {
1410   ToolkitTestApplication application;
1411
1412   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1413
1414   view.RegisterJavaScriptAlertCallback(&OnJavaScriptAlert);
1415   view.LoadHtmlString("<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>");
1416   view.JavaScriptAlertReply();
1417   Test::EmitGlobalTimerSignal();
1418   DALI_TEST_EQUALS(gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION);
1419
1420   view.RegisterJavaScriptConfirmCallback(&OnJavaScriptConfirm);
1421   view.LoadHtmlString("<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>");
1422   view.JavaScriptConfirmReply(true);
1423   Test::EmitGlobalTimerSignal();
1424   DALI_TEST_EQUALS(gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION);
1425
1426   view.RegisterJavaScriptPromptCallback(&OnJavaScriptPrompt);
1427   view.LoadHtmlString("<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>");
1428   view.JavaScriptPromptReply("it is a prompt.");
1429   Test::EmitGlobalTimerSignal();
1430   DALI_TEST_EQUALS(gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION);
1431
1432   END_TEST;
1433 }
1434
1435 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1436 {
1437   ToolkitTestApplication application;
1438
1439   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1440   DALI_TEST_CHECK(view);
1441
1442   std::string html("<body>Hello World!</body>");
1443   std::string basicUri("http://basicurl");
1444   std::string unreachableUrl("http://unreachableurl");
1445   bool        result = view.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
1446   DALI_TEST_CHECK(result);
1447
1448   application.SendNotification();
1449   application.Render();
1450   Test::EmitGlobalTimerSignal();
1451
1452   result = view.LoadContents((const int8_t*)html.c_str(), html.length(), "html/text", "utf-8", basicUri);
1453   DALI_TEST_CHECK(result);
1454
1455   END_TEST;
1456 }
1457
1458 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1459 {
1460   ToolkitTestApplication application;
1461
1462   WebView view = WebView::New();
1463   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1464   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1465   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
1466   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
1467
1468   application.GetScene().Add(view);
1469   application.SendNotification();
1470   application.Render();
1471   DALI_TEST_CHECK(view);
1472
1473   view.LoadUrl("http://test.html");
1474   bool result = view.AddCustomHeader("key", "value");
1475   DALI_TEST_CHECK(result);
1476
1477   result = view.ReloadWithoutCache();
1478   DALI_TEST_CHECK(result);
1479
1480   uint32_t portNumber = view.StartInspectorServer(5000);
1481   DALI_TEST_EQUALS(portNumber, 5000, TEST_LOCATION);
1482
1483   application.SendNotification();
1484   application.Render();
1485   Test::EmitGlobalTimerSignal();
1486
1487   result = view.StopInspectorServer();
1488   DALI_TEST_CHECK(result);
1489
1490   view.SuspendNetworkLoading();
1491
1492   result = view.RemoveCustomHeader("key");
1493   DALI_TEST_CHECK(result);
1494
1495   view.ResumeNetworkLoading();
1496
1497   END_TEST;
1498 }
1499
1500 int UtcDaliWebViewMethodsForCoverage(void)
1501 {
1502   ToolkitTestApplication application;
1503
1504   WebView view = WebView::New("ko-KR", "Asia/Seoul");
1505
1506   view.LoadHtmlString("<body>Hello World!</body>");
1507   view.AddJavaScriptMessageHandler("jsObject",
1508                                    [](const std::string& arg) {
1509                                    });
1510
1511   view.AddJavaScriptEntireMessageHandler("jsObject2",
1512                                    [](const std::string& arg, const std::string& arg2) {
1513                                    });
1514
1515   view.SetTtsFocus(true);
1516
1517   //view.ChangeOrientation(90);
1518
1519   DALI_TEST_CHECK(view);
1520
1521   //view.ExitFullscreen();
1522
1523   END_TEST;
1524 }
1525
1526 // test cases for web backforward list.
1527
1528 int UtcDaliWebBackForwardListCheckItem(void)
1529 {
1530   ToolkitTestApplication application;
1531
1532   WebView view = WebView::New();
1533   DALI_TEST_CHECK(view);
1534
1535   Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1536   DALI_TEST_CHECK(bfList != 0)
1537
1538   unsigned int itemCount = bfList->GetItemCount();
1539   DALI_TEST_CHECK(itemCount == 1)
1540
1541   std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1542   DALI_TEST_CHECK(citem != 0);
1543
1544   std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1545   DALI_TEST_CHECK(citemP != 0);
1546
1547   std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1548   DALI_TEST_CHECK(citemN != 0);
1549
1550   const std::string kDefaultUrl("http://url");
1551   std::string       testValue = citem->GetUrl();
1552   DALI_TEST_EQUALS(testValue, kDefaultUrl, TEST_LOCATION);
1553
1554   const std::string kDefaultTitle("title");
1555   testValue = citem->GetTitle();
1556   DALI_TEST_EQUALS(testValue, kDefaultTitle, TEST_LOCATION);
1557
1558   const std::string kDefaultOriginalUrl("http://originalurl");
1559   testValue = citem->GetOriginalUrl();
1560   DALI_TEST_EQUALS(testValue, kDefaultOriginalUrl, TEST_LOCATION);
1561
1562   std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex(0);
1563   DALI_TEST_CHECK(item != 0);
1564
1565   std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1566   DALI_TEST_CHECK(vecBack.size() == 1);
1567
1568   std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1569   DALI_TEST_CHECK(vecForward.size() == 1);
1570
1571   END_TEST;
1572 }
1573
1574 // test cases for web context.
1575
1576 int UtcDaliWebContextGetSetCacheModelEtc(void)
1577 {
1578   ToolkitTestApplication application;
1579
1580   Dali::WebEngineContext* context = WebView::GetContext();
1581   DALI_TEST_CHECK(context != 0)
1582
1583   std::string kDefaultValue;
1584
1585   // Reset something
1586   context->SetAppId("id");
1587   context->SetApplicationType(Dali::WebEngineContext::ApplicationType::OTHER);
1588   context->SetTimeOffset(0);
1589   context->SetTimeZoneOffset(0, 0);
1590   context->SetDefaultProxyAuth(kDefaultValue, kDefaultValue);
1591   context->DeleteAllWebDatabase();
1592   context->DeleteAllWebStorage();
1593   context->DeleteLocalFileSystem();
1594   context->ClearCache();
1595   context->DeleteAllFormPasswordData();
1596   context->DeleteAllFormCandidateData();
1597
1598   // Check default value
1599   Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1600   DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER);
1601
1602   // Check Set/GetProperty
1603   context->SetCacheModel(Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1604   value = context->GetCacheModel();
1605   DALI_TEST_CHECK(value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER);
1606
1607   // Get cache enabled
1608   context->EnableCache(true);
1609   DALI_TEST_CHECK(context->IsCacheEnabled());
1610
1611   // Get certificate
1612   context->SetCertificateFilePath("test");
1613   std::string str = context->GetCertificateFilePath();
1614   DALI_TEST_EQUALS(str, "test", TEST_LOCATION);
1615
1616   // Set version
1617   DALI_TEST_CHECK(context->SetAppVersion("test"));
1618
1619   // Register
1620   std::vector<std::string> temp;
1621   context->RegisterUrlSchemesAsCorsEnabled(temp);
1622   context->RegisterJsPluginMimeTypes(temp);
1623   context->DeleteFormPasswordDataList(temp);
1624
1625   // Get zoom factor
1626   context->SetDefaultZoomFactor(1.0f);
1627   DALI_TEST_EQUALS(context->GetDefaultZoomFactor(), float(1.0f), TEST_LOCATION);
1628
1629   // Delete cache and database
1630   DALI_TEST_CHECK(context->DeleteAllApplicationCache());
1631   DALI_TEST_CHECK(context->DeleteAllWebIndexedDatabase());
1632
1633   // Get contextProxy
1634   context->SetProxyUri("test");
1635   DALI_TEST_EQUALS(context->GetProxyUri(), "test", TEST_LOCATION);
1636   context->SetProxyBypassRule("", "test");
1637   DALI_TEST_EQUALS(context->GetProxyBypassRule(), "test", TEST_LOCATION);
1638
1639   //Notify low memory
1640   DALI_TEST_CHECK(context->FreeUnusedMemory());
1641
1642   END_TEST;
1643 }
1644
1645 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1646 {
1647   ToolkitTestApplication application;
1648
1649   Dali::WebEngineContext* context = WebView::GetContext();
1650   DALI_TEST_CHECK(context != 0)
1651
1652   std::string kDefaultValue;
1653
1654   // get origins of web database
1655   bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1656   DALI_TEST_CHECK(result);
1657
1658   Test::EmitGlobalTimerSignal();
1659   DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION);
1660   DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1661
1662   Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1663   DALI_TEST_CHECK(origin);
1664
1665   result = context->DeleteWebDatabase(*origin);
1666   DALI_TEST_CHECK(result);
1667
1668   // get origins of web storage
1669   result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1670   DALI_TEST_CHECK(result);
1671
1672   Test::EmitGlobalTimerSignal();
1673   DALI_TEST_EQUALS(gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION);
1674   DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1675
1676   origin = gSecurityOriginList[0].get();
1677   DALI_TEST_CHECK(origin);
1678
1679   result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1680   DALI_TEST_CHECK(result);
1681   Test::EmitGlobalTimerSignal();
1682   DALI_TEST_EQUALS(gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION);
1683
1684   result = context->DeleteWebStorage(*origin);
1685   DALI_TEST_CHECK(result);
1686
1687   result = context->DeleteApplicationCache(*origin);
1688   DALI_TEST_CHECK(result);
1689
1690   // form passwords, download state, mime type.
1691   context->GetFormPasswordList(&OnFormPasswordsAcquired);
1692   Test::EmitGlobalTimerSignal();
1693   DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1694   DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1695   DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1696   DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1697
1698   context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1699   Test::EmitGlobalTimerSignal();
1700   DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1701
1702   context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1703   Test::EmitGlobalTimerSignal();
1704   DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1705
1706   gSecurityOriginList.clear();
1707   gPasswordDataList.clear();
1708
1709   END_TEST;
1710 }
1711
1712 int UtcDaliWebContextHttpRequestInterceptor(void)
1713 {
1714   ToolkitTestApplication application;
1715
1716   Dali::WebEngineContext* context = WebView::GetContext();
1717   DALI_TEST_CHECK(context != 0)
1718
1719   WebView view = WebView::New();
1720   DALI_TEST_CHECK(view);
1721
1722   // Check if web view is found or not when plugin is null.
1723   DALI_TEST_CHECK(!WebView::FindWebView(nullptr));
1724
1725   // load url.
1726   context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1727   DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1728   DALI_TEST_CHECK(!gRequestInterceptorInstance);
1729
1730   Test::EmitGlobalTimerSignal();
1731   DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 1, TEST_LOCATION);
1732
1733   // check request interceptor.
1734   DALI_TEST_CHECK(gRequestInterceptorInstance);
1735   DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1736   DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1737   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
1738   Dali::Property::Map testHeaders;
1739   testHeaders.Insert("key2", "value2");
1740   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
1741   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody((const int8_t*)"test", 4));
1742   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", (const int8_t*)"test", 4));
1743   DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk((const int8_t*)"test", 4));
1744
1745   DALI_TEST_CHECK(gRequestInterceptorInstance->GetWebEngine());
1746   // Check if web view is found or not when plugin is not null.
1747   DALI_TEST_CHECK(WebView::FindWebView(gRequestInterceptorInstance->GetWebEngine()));
1748
1749   std::string testUrl("http://test.html");
1750   DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1751   std::string testMethod("GET");
1752   DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
1753   Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
1754   DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
1755
1756   // Destroy web view.
1757   view.Reset();
1758   gRequestInterceptorInstance = nullptr;
1759
1760   END_TEST;
1761 }
1762
1763 // test cases for web cookie manager.
1764
1765 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1766 {
1767   ToolkitTestApplication application;
1768
1769   Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1770   DALI_TEST_CHECK(cookieManager != 0)
1771
1772   const std::string kDefaultValue;
1773
1774   // Reset something
1775   cookieManager->SetPersistentStorage(kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE);
1776   cookieManager->ClearCookies();
1777
1778   // Check default value
1779   Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1780   DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY);
1781
1782   // Check Set/GetProperty
1783   cookieManager->SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1784   value = cookieManager->GetCookieAcceptPolicy();
1785   DALI_TEST_CHECK(value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS);
1786
1787   END_TEST;
1788 }
1789
1790 int UtcDaliWebCookieManagerChangesWatch(void)
1791 {
1792   ToolkitTestApplication application;
1793
1794   Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager();
1795   DALI_TEST_CHECK(cookieManager != 0)
1796
1797   cookieManager->ChangesWatch(&OnChangesWatch);
1798   Test::EmitGlobalTimerSignal();
1799   DALI_TEST_EQUALS(gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION);
1800
1801   END_TEST;
1802 }
1803
1804 // test cases for web settings.
1805
1806 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1807 {
1808   ToolkitTestApplication application;
1809
1810   WebView view = WebView::New();
1811   DALI_TEST_CHECK(view);
1812
1813   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1814   DALI_TEST_CHECK(settings != 0)
1815
1816   // Reset something
1817   settings->AllowMixedContents(false);
1818   settings->EnableSpatialNavigation(false);
1819   settings->EnableWebSecurity(false);
1820   settings->EnableCacheBuilder(false);
1821   settings->EnableDoNotTrack(false);
1822   settings->UseScrollbarThumbFocusNotifications(false);
1823   settings->AllowFileAccessFromExternalUrl(false);
1824   settings->AllowScriptsOpenWindows(false);
1825
1826   // Check default value
1827   int value = settings->GetDefaultFontSize();
1828   DALI_TEST_CHECK(value == 16);
1829
1830   // Check Set/GetProperty
1831   settings->SetDefaultFontSize(20);
1832   value = settings->GetDefaultFontSize();
1833   DALI_TEST_CHECK(value == 20);
1834
1835   END_TEST;
1836 }
1837
1838 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1839 {
1840   ToolkitTestApplication application;
1841
1842   WebView view = WebView::New();
1843   DALI_TEST_CHECK(view);
1844
1845   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1846   DALI_TEST_CHECK(settings != 0)
1847
1848   // Reset something
1849   settings->AllowMixedContents(false);
1850   settings->EnableSpatialNavigation(false);
1851   settings->EnableWebSecurity(false);
1852   settings->EnableCacheBuilder(false);
1853   settings->EnableDoNotTrack(false);
1854   settings->UseScrollbarThumbFocusNotifications(false);
1855   settings->AllowFileAccessFromExternalUrl(false);
1856   settings->AllowScriptsOpenWindows(false);
1857
1858   // Check default value is true or not
1859   bool value = settings->IsJavaScriptEnabled();
1860   DALI_TEST_CHECK(value);
1861
1862   // Check Set/GetProperty
1863   settings->EnableJavaScript(false);
1864   value = settings->IsJavaScriptEnabled();
1865   DALI_TEST_CHECK(!value);
1866
1867   END_TEST;
1868 }
1869
1870 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1871 {
1872   ToolkitTestApplication application;
1873
1874   WebView view = WebView::New();
1875   DALI_TEST_CHECK(view);
1876
1877   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1878   DALI_TEST_CHECK(settings != 0)
1879
1880   // Reset something
1881   settings->AllowMixedContents(false);
1882   settings->EnableSpatialNavigation(false);
1883   settings->EnableWebSecurity(false);
1884   settings->EnableCacheBuilder(false);
1885   settings->EnableDoNotTrack(false);
1886   settings->UseScrollbarThumbFocusNotifications(false);
1887   settings->AllowFileAccessFromExternalUrl(false);
1888   settings->AllowScriptsOpenWindows(false);
1889
1890   // Check default value is true or not
1891   bool value = settings->IsAutoFittingEnabled();
1892   DALI_TEST_CHECK(value);
1893
1894   // Check Set/GetProperty
1895   settings->EnableAutoFitting(false);
1896   value = settings->IsAutoFittingEnabled();
1897   DALI_TEST_CHECK(!value);
1898
1899   END_TEST;
1900 }
1901
1902 int UtcDaliWebSettingsCheckEnablePlugins(void)
1903 {
1904   ToolkitTestApplication application;
1905
1906   WebView view = WebView::New();
1907   DALI_TEST_CHECK(view);
1908
1909   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1910   DALI_TEST_CHECK(settings != 0)
1911
1912   // Reset something
1913   settings->AllowMixedContents(false);
1914   settings->EnableSpatialNavigation(false);
1915   settings->EnableWebSecurity(false);
1916   settings->EnableCacheBuilder(false);
1917   settings->EnableDoNotTrack(false);
1918   settings->UseScrollbarThumbFocusNotifications(false);
1919   settings->AllowFileAccessFromExternalUrl(false);
1920   settings->AllowScriptsOpenWindows(false);
1921
1922   // Check default value is true or not
1923   bool value = settings->ArePluginsEnabled();
1924   DALI_TEST_CHECK(value);
1925
1926   // Check Set/GetProperty
1927   settings->EnablePlugins(false);
1928   value = settings->ArePluginsEnabled();
1929   DALI_TEST_CHECK(!value);
1930
1931   END_TEST;
1932 }
1933
1934 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1935 {
1936   ToolkitTestApplication application;
1937
1938   WebView view = WebView::New();
1939   DALI_TEST_CHECK(view);
1940
1941   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1942   DALI_TEST_CHECK(settings != 0)
1943
1944   // Reset something
1945   settings->AllowMixedContents(false);
1946   settings->EnableSpatialNavigation(false);
1947   settings->EnableWebSecurity(false);
1948   settings->EnableCacheBuilder(false);
1949   settings->EnableDoNotTrack(false);
1950   settings->UseScrollbarThumbFocusNotifications(false);
1951   settings->AllowFileAccessFromExternalUrl(false);
1952   settings->AllowScriptsOpenWindows(false);
1953
1954   // Check default value is true or not
1955   bool value = settings->IsPrivateBrowsingEnabled();
1956   DALI_TEST_CHECK(value);
1957
1958   // Check Set/GetProperty
1959   settings->EnablePrivateBrowsing(false);
1960   value = settings->IsPrivateBrowsingEnabled();
1961   DALI_TEST_CHECK(!value);
1962
1963   END_TEST;
1964 }
1965
1966 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1967 {
1968   ToolkitTestApplication application;
1969
1970   WebView view = WebView::New();
1971   DALI_TEST_CHECK(view);
1972
1973   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1974   DALI_TEST_CHECK(settings != 0)
1975
1976   // Reset something
1977   settings->AllowMixedContents(false);
1978   settings->EnableSpatialNavigation(false);
1979   settings->EnableWebSecurity(false);
1980   settings->EnableCacheBuilder(false);
1981   settings->EnableDoNotTrack(false);
1982   settings->UseScrollbarThumbFocusNotifications(false);
1983   settings->AllowFileAccessFromExternalUrl(false);
1984   settings->AllowScriptsOpenWindows(false);
1985
1986   // Check default value is true or not
1987   bool value = settings->IsLinkMagnifierEnabled();
1988   DALI_TEST_CHECK(value);
1989
1990   // Check Set/GetProperty
1991   settings->EnableLinkMagnifier(false);
1992   value = settings->IsLinkMagnifierEnabled();
1993   DALI_TEST_CHECK(!value);
1994
1995   END_TEST;
1996 }
1997
1998 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(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->IsKeypadWithoutUserActionUsed();
2020   DALI_TEST_CHECK(value);
2021
2022   // Check Set/GetProperty
2023   settings->UseKeypadWithoutUserAction(false);
2024   value = settings->IsKeypadWithoutUserActionUsed();
2025   DALI_TEST_CHECK(!value);
2026
2027   END_TEST;
2028 }
2029
2030 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(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->IsAutofillPasswordFormEnabled();
2052   DALI_TEST_CHECK(value);
2053   settings->EnableAutofillPasswordForm(false);
2054   value = settings->IsAutofillPasswordFormEnabled();
2055   DALI_TEST_CHECK(!value);
2056   END_TEST;
2057 }
2058
2059 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
2060 {
2061   ToolkitTestApplication application;
2062
2063   WebView view = WebView::New();
2064   DALI_TEST_CHECK(view);
2065
2066   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2067   DALI_TEST_CHECK(settings != 0);
2068
2069   // Reset something
2070   settings->AllowMixedContents(false);
2071   settings->EnableSpatialNavigation(false);
2072   settings->EnableWebSecurity(false);
2073   settings->EnableCacheBuilder(false);
2074   settings->EnableDoNotTrack(false);
2075   settings->UseScrollbarThumbFocusNotifications(false);
2076   settings->AllowFileAccessFromExternalUrl(false);
2077   settings->AllowScriptsOpenWindows(false);
2078
2079   // Check default value is true or not
2080   bool value = settings->IsFormCandidateDataEnabled();
2081   DALI_TEST_CHECK(value);
2082
2083   // Check Set/GetProperty
2084   settings->EnableFormCandidateData(false);
2085   value = settings->IsFormCandidateDataEnabled();
2086   DALI_TEST_CHECK(!value);
2087
2088   END_TEST;
2089 }
2090
2091 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2092 {
2093   ToolkitTestApplication application;
2094
2095   WebView view = WebView::New();
2096   DALI_TEST_CHECK(view);
2097
2098   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2099   DALI_TEST_CHECK(settings != 0);
2100
2101   // Reset something
2102   settings->AllowMixedContents(false);
2103   settings->EnableSpatialNavigation(false);
2104   settings->EnableWebSecurity(false);
2105   settings->EnableCacheBuilder(false);
2106   settings->EnableDoNotTrack(false);
2107   settings->UseScrollbarThumbFocusNotifications(false);
2108   settings->AllowFileAccessFromExternalUrl(false);
2109   settings->AllowScriptsOpenWindows(false);
2110
2111   // Check default value is true or not
2112   bool value = settings->IsTextSelectionEnabled();
2113   DALI_TEST_CHECK(value);
2114
2115   //Check Set/GetProperty
2116   settings->EnableTextSelection(false);
2117   value = settings->IsTextSelectionEnabled();
2118   DALI_TEST_CHECK(!value);
2119
2120   END_TEST;
2121 }
2122
2123 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2124 {
2125   ToolkitTestApplication application;
2126
2127   WebView view = WebView::New();
2128   DALI_TEST_CHECK(view);
2129
2130   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2131   DALI_TEST_CHECK(settings != 0);
2132
2133   // Reset something
2134   settings->AllowMixedContents(false);
2135   settings->EnableSpatialNavigation(false);
2136   settings->EnableWebSecurity(false);
2137   settings->EnableCacheBuilder(false);
2138   settings->EnableDoNotTrack(false);
2139   settings->UseScrollbarThumbFocusNotifications(false);
2140   settings->AllowFileAccessFromExternalUrl(false);
2141   settings->AllowScriptsOpenWindows(false);
2142
2143   // Check default value is true or not
2144   bool value = settings->IsTextAutosizingEnabled();
2145   DALI_TEST_CHECK(value);
2146
2147   // Check Set/GetProperty
2148   settings->EnableTextAutosizing(false);
2149   value = settings->IsTextAutosizingEnabled();
2150   DALI_TEST_CHECK(!value);
2151
2152   END_TEST;
2153 }
2154
2155 int UtcDaliWebSettingsCheckEnableArrowScroll(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->IsArrowScrollEnabled();
2177   DALI_TEST_CHECK(value);
2178
2179   // Check Set/GetProperty
2180   settings->EnableArrowScroll(false);
2181   value = settings->IsArrowScrollEnabled();
2182   DALI_TEST_CHECK(!value);
2183
2184   END_TEST;
2185 }
2186
2187 int UtcDaliWebSettingsCheckEnableClipboard(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->IsClipboardEnabled();
2209   DALI_TEST_CHECK(value);
2210   settings->EnableClipboard(false);
2211   value = settings->IsClipboardEnabled();
2212   DALI_TEST_CHECK(!value);
2213   END_TEST;
2214 }
2215
2216 int UtcDaliWebSettingsCheckEnableImePanel(void)
2217 {
2218   ToolkitTestApplication application;
2219
2220   WebView view = WebView::New();
2221   DALI_TEST_CHECK(view);
2222
2223   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2224   DALI_TEST_CHECK(settings != 0);
2225
2226   // Reset something
2227   settings->AllowMixedContents(false);
2228   settings->EnableSpatialNavigation(false);
2229   settings->EnableWebSecurity(false);
2230   settings->EnableCacheBuilder(false);
2231   settings->EnableDoNotTrack(false);
2232   settings->UseScrollbarThumbFocusNotifications(false);
2233   settings->AllowFileAccessFromExternalUrl(false);
2234   settings->AllowScriptsOpenWindows(false);
2235
2236   // Check default value is true or not
2237   bool value = settings->IsImePanelEnabled();
2238   DALI_TEST_CHECK(value);
2239
2240   // Check Set/GetProperty
2241   settings->EnableImePanel(false);
2242   value = settings->IsImePanelEnabled();
2243   DALI_TEST_CHECK(!value);
2244
2245   END_TEST;
2246 }
2247
2248 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2249 {
2250   ToolkitTestApplication application;
2251
2252   WebView view = WebView::New();
2253   DALI_TEST_CHECK(view);
2254
2255   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2256   DALI_TEST_CHECK(settings != 0)
2257
2258   // Reset something
2259   settings->AllowMixedContents(false);
2260   settings->EnableSpatialNavigation(false);
2261   settings->EnableWebSecurity(false);
2262   settings->EnableCacheBuilder(false);
2263   settings->EnableDoNotTrack(false);
2264   settings->UseScrollbarThumbFocusNotifications(false);
2265   settings->AllowFileAccessFromExternalUrl(false);
2266   settings->AllowScriptsOpenWindows(false);
2267
2268   // Check default value is true or not
2269   bool value = settings->AreImagesLoadedAutomatically();
2270   DALI_TEST_CHECK(value);
2271
2272   // Check Set/GetProperty
2273   settings->AllowImagesLoadAutomatically(false);
2274   value = settings->AreImagesLoadedAutomatically();
2275   DALI_TEST_CHECK(!value);
2276
2277   END_TEST;
2278 }
2279
2280 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2281 {
2282   ToolkitTestApplication application;
2283
2284   WebView view = WebView::New();
2285   DALI_TEST_CHECK(view);
2286
2287   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2288   DALI_TEST_CHECK(settings != 0)
2289
2290   const std::string kDefaultValue;
2291   const std::string kTestValue = "UTF-8";
2292
2293   // Reset something
2294   settings->AllowMixedContents(false);
2295   settings->EnableSpatialNavigation(false);
2296   settings->EnableWebSecurity(false);
2297   settings->EnableCacheBuilder(false);
2298   settings->EnableDoNotTrack(false);
2299   settings->UseScrollbarThumbFocusNotifications(false);
2300   settings->AllowFileAccessFromExternalUrl(false);
2301   settings->AllowScriptsOpenWindows(false);
2302
2303   // Check default value
2304   std::string value = settings->GetDefaultTextEncodingName();
2305   DALI_TEST_EQUALS(value, kDefaultValue, TEST_LOCATION);
2306
2307   // Check Set/GetProperty
2308   settings->SetDefaultTextEncodingName(kTestValue);
2309   value = settings->GetDefaultTextEncodingName();
2310   DALI_TEST_EQUALS(value, kTestValue, TEST_LOCATION);
2311
2312   END_TEST;
2313 }
2314
2315 int UtcDaliWebSettingsSetViewportMetaTag(void)
2316 {
2317   ToolkitTestApplication application;
2318
2319   WebView view = WebView::New();
2320   DALI_TEST_CHECK(view);
2321
2322   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2323   DALI_TEST_CHECK(settings != 0)
2324
2325   // Check the value is true or not
2326   bool value = settings->SetViewportMetaTag(true);
2327   DALI_TEST_CHECK(value);
2328
2329   END_TEST;
2330 }
2331
2332 int UtcDaliWebSettingsSetForceZoom(void)
2333 {
2334   ToolkitTestApplication application;
2335
2336   WebView view = WebView::New();
2337   DALI_TEST_CHECK(view);
2338
2339   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2340   DALI_TEST_CHECK(settings != 0)
2341
2342   // Check the value is true or not
2343   bool value = settings->SetForceZoom(true);
2344   DALI_TEST_CHECK(value);
2345
2346   value = settings->IsZoomForced();
2347   DALI_TEST_CHECK(value);
2348
2349   END_TEST;
2350 }
2351
2352 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2353 {
2354   ToolkitTestApplication application;
2355
2356   WebView view = WebView::New();
2357   DALI_TEST_CHECK(view);
2358
2359   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2360   DALI_TEST_CHECK(settings != 0)
2361
2362   // Check the value is true or not
2363   bool value = settings->SetTextZoomEnabled(true);
2364   DALI_TEST_CHECK(value);
2365
2366   value = settings->IsTextZoomEnabled();
2367   DALI_TEST_CHECK(value);
2368
2369   END_TEST;
2370 }
2371
2372 int UtcDaliWebSettingsSetExtraFeature(void)
2373 {
2374   ToolkitTestApplication application;
2375
2376   WebView view = WebView::New();
2377   DALI_TEST_CHECK(view);
2378
2379   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2380   DALI_TEST_CHECK(settings != 0)
2381
2382   // Check the value is true or not
2383   settings->SetExtraFeature("test", true);
2384   bool value = settings->IsExtraFeatureEnabled("test");
2385   DALI_TEST_CHECK(value);
2386
2387   END_TEST;
2388 }
2389
2390 int UtcDaliWebViewGetPlainText(void)
2391 {
2392   ToolkitTestApplication application;
2393
2394   WebView view = WebView::New();
2395   DALI_TEST_CHECK(view);
2396
2397   view.LoadUrl(TEST_URL1);
2398
2399   view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2400   Test::EmitGlobalTimerSignal();
2401   DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);
2402
2403   END_TEST;
2404 }
2405
2406 int UtcDaliWebViewVisibilityChange(void)
2407 {
2408   ToolkitTestApplication application;
2409
2410   WebView view  = WebView::New();
2411   Control dummy = Control::New();
2412   DALI_TEST_CHECK(view);
2413   DALI_TEST_CHECK(dummy);
2414
2415   view.LoadUrl(TEST_URL1);
2416
2417   dummy.Add(view);
2418   auto window = application.GetWindow();
2419   window.Add(dummy);
2420
2421   application.SendNotification();
2422   application.Render();
2423
2424   try
2425   {
2426     // TODO : There is no way to check visiblity setting result from web engine.
2427     // Just call API and exception check.
2428     view.SetProperty(Actor::Property::VISIBLE, false);
2429     view.SetProperty(Actor::Property::VISIBLE, true);
2430     dummy.SetProperty(Actor::Property::VISIBLE, false);
2431     dummy.SetProperty(Actor::Property::VISIBLE, true);
2432     dummy.Unparent();
2433     window.Hide();
2434     window.Add(dummy);
2435     window.Show();
2436     window.Hide();
2437     window.Show();
2438     dummy.SetProperty(Actor::Property::VISIBLE, false);
2439     view.SetProperty(Actor::Property::VISIBLE, false);
2440     dummy.SetProperty(Actor::Property::VISIBLE, true);
2441     view.SetProperty(Actor::Property::VISIBLE, true);
2442     tet_result(TET_PASS);
2443   }
2444   catch(...)
2445   {
2446     // Should not throw exception
2447     tet_result(TET_FAIL);
2448   }
2449
2450   END_TEST;
2451 }
2452
2453 int UtcDaliWebViewMethodsForCoverage2(void)
2454 {
2455   ToolkitTestApplication application;
2456
2457   WebView view = WebView::New();
2458   view.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2459   view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2460   view.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
2461   view.SetProperty(Actor::Property::SIZE, Vector2(800, 600));
2462
2463   application.GetScene().Add(view);
2464   application.SendNotification();
2465   application.Render();
2466   DALI_TEST_CHECK(view);
2467
2468   try
2469   {
2470     // Just call API and exception check.
2471     view.ChangeOrientation(90);
2472     view.ExitFullscreen();
2473     tet_result(TET_PASS);
2474   }
2475   catch(...)
2476   {
2477     // Should not throw exception
2478     tet_result(TET_FAIL);
2479   }
2480
2481   END_TEST;
2482 }
2483
2484 int UtcDaliWebViewRegisterNewWindowPolicyDecidedCallback(void)
2485 {
2486   ToolkitTestApplication application;
2487
2488   WebView view = WebView::New();
2489   DALI_TEST_CHECK(view);
2490
2491   view.RegisterNewWindowPolicyDecidedCallback(&OnNewWindowPolicyDecided);
2492   DALI_TEST_EQUALS(gNewWindowPolicyDecidedCallbackCalled, 0, TEST_LOCATION);
2493
2494   view.LoadUrl(TEST_URL1);
2495   Test::EmitGlobalTimerSignal();
2496   DALI_TEST_EQUALS(gNewWindowPolicyDecidedCallbackCalled, 1, TEST_LOCATION);
2497   END_TEST;
2498 }
2499
2500 int UtcDaliWebViewRegisterFullscreenEnteredCallback(void)
2501 {
2502   ToolkitTestApplication application;
2503
2504   WebView view = WebView::New();
2505   DALI_TEST_CHECK(view);
2506
2507   view.RegisterFullscreenEnteredCallback(&OnFullscreenEntered);
2508   DALI_TEST_EQUALS(gFullscreenEnteredCallbackCalled, 0, TEST_LOCATION);
2509
2510   view.LoadUrl(TEST_URL1);
2511   Test::EmitGlobalTimerSignal();
2512   DALI_TEST_EQUALS(gFullscreenEnteredCallbackCalled, 1, TEST_LOCATION);
2513   END_TEST;
2514 }
2515
2516 int UtcDaliWebViewRegisterFullscreenExitedCallback(void)
2517 {
2518   ToolkitTestApplication application;
2519
2520   WebView view = WebView::New();
2521   DALI_TEST_CHECK(view);
2522
2523   view.RegisterFullscreenExitedCallback(&OnFullscreenExited);
2524   DALI_TEST_EQUALS(gFullscreenExitedCallbackCalled, 0, TEST_LOCATION);
2525
2526   view.LoadUrl(TEST_URL1);
2527   Test::EmitGlobalTimerSignal();
2528   DALI_TEST_EQUALS(gFullscreenExitedCallbackCalled, 1, TEST_LOCATION);
2529   END_TEST;
2530 }
2531
2532 int UtcDaliWebViewRegisterTextFoundCallback(void)
2533 {
2534   ToolkitTestApplication application;
2535
2536   WebView view = WebView::New();
2537   DALI_TEST_CHECK(view);
2538
2539   view.RegisterTextFoundCallback(&OnTextFound);
2540   DALI_TEST_EQUALS(gTextFoundCallbackCalled, 0, TEST_LOCATION);
2541
2542   view.LoadUrl(TEST_URL1);
2543   Test::EmitGlobalTimerSignal();
2544   DALI_TEST_EQUALS(gTextFoundCallbackCalled, 1, TEST_LOCATION);
2545   END_TEST;
2546 }