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