[dali_2.1.5] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-WebView.cpp
1 /*
2  * Copyright (c) 2021 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 <iostream>
19 #include <stdlib.h>
20
21 #include <dali-toolkit-test-suite-utils.h>
22 #include "dali-toolkit-test-utils/toolkit-timer.h"
23
24 #include <dali.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-frame.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
34 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
35 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
36 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
37 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
38 #include <dali/integration-api/events/hover-event-integ.h>
39 #include <dali/integration-api/events/key-event-integ.h>
40 #include <dali/integration-api/events/touch-event-integ.h>
41 #include <dali/integration-api/events/wheel-event-integ.h>
42 #include <dali/public-api/images/pixel-data.h>
43 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
44 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
45 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
46 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
48 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
49 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
50
51 using namespace Dali;
52 using namespace Toolkit;
53
54 namespace
55 {
56
57 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
58 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
59
60 static int gPageLoadStartedCallbackCalled = 0;
61 static int gPageLoadInProgressCallbackCalled = 0;
62 static int gPageLoadFinishedCallbackCalled = 0;
63 static int gPageLoadErrorCallbackCalled = 0;
64 static std::unique_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
65 static int gScrollEdgeReachedCallbackCalled = 0;
66 static int gUrlChangedCallbackCalled = 0;
67 static int gEvaluateJavaScriptCallbackCalled = 0;
68 static int gJavaScriptAlertCallbackCalled = 0;
69 static int gJavaScriptConfirmCallbackCalled = 0;
70 static int gJavaScriptPromptCallbackCalled = 0;
71 static int gScreenshotCapturedCallbackCalled = 0;
72 static int gVideoPlayingCallbackCalled = 0;
73 static int gGeolocationPermissionCallbackCalled = 0;
74 static bool gTouched = false;
75 static bool gHovered = false;
76 static bool gWheelEventHandled = false;
77 static int gFormRepostDecidedCallbackCalled = 0;
78 static std::unique_ptr<Dali::WebEngineFormRepostDecision> gFormRepostDecidedInstance = nullptr;
79 static int gFrameRenderedCallbackCalled = 0;
80 static int gConsoleMessageCallbackCalled = 0;
81 static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
82 static int gResponsePolicyDecidedCallbackCalled = 0;
83 static int gNavigationPolicyDecidedCallbackCalled = 0;
84 static std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
85 static int gCertificateConfirmCallbackCalled = 0;
86 static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
87 static int gSslCertificateChangedCallbackCalled = 0;
88 static std::unique_ptr<Dali::WebEngineCertificate> gSslCertificateInstance = nullptr;
89 static int gHttpAuthHandlerCallbackCalled = 0;
90 static std::unique_ptr<Dali::WebEngineHttpAuthHandler> gHttpAuthInstance = nullptr;
91 static int gSecurityOriginsAcquiredCallbackCalled = 0;
92 static int gStorageUsageAcquiredCallbackCalled = 0;
93 static int gFormPasswordsAcquiredCallbackCalled = 0;
94 static int gDownloadStartedCallbackCalled = 0;
95 static int gMimeOverriddenCallbackCalled = 0;
96 static int gRequestInterceptedCallbackCalled = 0;
97 static Dali::WebEngineRequestInterceptorPtr gRequestInterceptorInstance = nullptr;
98 static std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>> gSecurityOriginList;
99 static std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>> gPasswordDataList;
100 static int gContextMenuShownCallbackCalled = 0;
101 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuShownInstance = nullptr;
102 static int gContextMenuHiddenCallbackCalled = 0;
103 static std::unique_ptr<Dali::WebEngineContextMenu> gContextMenuHiddenInstance = nullptr;
104 static int gHitTestCreatedCallbackCalled = 0;
105 static int gCookieManagerChangsWatchCallbackCalled = 0;
106 static int gPlainTextReceivedCallbackCalled = 0;
107
108 struct CallbackFunctor
109 {
110   CallbackFunctor(bool* callbackFlag)
111   : mCallbackFlag( callbackFlag )
112   {
113   }
114
115   void operator()()
116   {
117     *mCallbackFlag = true;
118   }
119   bool* mCallbackFlag;
120 };
121
122 static void OnPageLoadStarted(const std::string& url)
123 {
124   gPageLoadStartedCallbackCalled++;
125 }
126
127 static void OnPageLoadInProgress(const std::string& url)
128 {
129   gPageLoadInProgressCallbackCalled++;
130 }
131
132 static void OnPageLoadFinished(const std::string& url)
133 {
134   gPageLoadFinishedCallbackCalled++;
135 }
136
137 static void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
138 {
139   gScrollEdgeReachedCallbackCalled++;
140 }
141
142 static void OnResponsePolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
143 {
144   gResponsePolicyDecidedCallbackCalled++;
145   gResponsePolicyDecisionInstance = std::move(decision);
146 }
147
148 static void OnNavigationPolicyDecided(std::unique_ptr<Dali::WebEnginePolicyDecision> decision)
149 {
150   gNavigationPolicyDecidedCallbackCalled++;
151 }
152
153 static void OnUrlChanged(const std::string& url)
154 {
155   gUrlChangedCallbackCalled++;
156 }
157
158 static bool OnHitTestCreated(std::unique_ptr<Dali::WebEngineHitTest> test)
159 {
160   gHitTestCreatedCallbackCalled++;
161   return true;
162 }
163
164 static bool OnPlainTextReceived(const std::string& plainText)
165 {
166   gPlainTextReceivedCallbackCalled++;
167   return true;
168 }
169
170 static void OnPageLoadError(std::unique_ptr<Dali::WebEngineLoadError> error)
171 {
172   gPageLoadErrorCallbackCalled++;
173   gPageLoadErrorInstance = std::move(error);
174 }
175
176 static void OnEvaluateJavaScript(const std::string& result)
177 {
178   gEvaluateJavaScriptCallbackCalled++;
179 }
180
181 static bool OnJavaScriptAlert(const std::string& result)
182 {
183   gJavaScriptAlertCallbackCalled++;
184   return true;
185 }
186
187 static bool OnJavaScriptConfirm(const std::string& result)
188 {
189   gJavaScriptConfirmCallbackCalled++;
190   return true;
191 }
192
193 static bool OnJavaScriptPrompt(const std::string& meesage1, const std::string& message2)
194 {
195   gJavaScriptPromptCallbackCalled++;
196   return true;
197 }
198
199 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
200 {
201   gScreenshotCapturedCallbackCalled++;
202 }
203
204 static void OnVideoPlaying(bool isPlaying)
205 {
206   gVideoPlayingCallbackCalled++;
207 }
208
209 static bool OnGeolocationPermission(const std::string&, const std::string&)
210 {
211   gGeolocationPermissionCallbackCalled++;
212   return true;
213 }
214
215 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
216 {
217   gTouched = true;
218   return true;
219 }
220
221 static void OnChangesWatch()
222 {
223   gCookieManagerChangsWatchCallbackCalled++;
224 }
225
226 static bool OnHovered(Actor actor, const Dali::HoverEvent& hover)
227 {
228   gHovered = true;
229   return true;
230 }
231
232 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
233 {
234   gWheelEventHandled = true;
235   return true;
236 }
237
238 static void OnFormRepostDecided(std::unique_ptr<Dali::WebEngineFormRepostDecision> decision)
239 {
240   gFormRepostDecidedCallbackCalled++;
241   gFormRepostDecidedInstance = std::move(decision);
242 }
243
244 static void OnFrameRendered()
245 {
246   gFrameRenderedCallbackCalled++;
247 }
248
249 static void OnConsoleMessage(std::unique_ptr<Dali::WebEngineConsoleMessage> message)
250 {
251   gConsoleMessageCallbackCalled++;
252   gConsoleMessageInstance = std::move(message);
253 }
254
255 static void OnCertificateConfirm(std::unique_ptr<Dali::WebEngineCertificate> certificate)
256 {
257   gCertificateConfirmCallbackCalled++;
258   gCertificateConfirmInstance = std::move(certificate);
259 }
260
261 static void OnSslCertificateChanged(std::unique_ptr<Dali::WebEngineCertificate> certificate)
262 {
263   gSslCertificateChangedCallbackCalled++;
264   gSslCertificateInstance = std::move(certificate);
265 }
266
267 static void OnHttpAuthHandler(std::unique_ptr<Dali::WebEngineHttpAuthHandler> hander)
268 {
269   gHttpAuthHandlerCallbackCalled++;
270   gHttpAuthInstance = std::move(hander);
271 }
272
273 static void OnSecurityOriginsAcquired(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>& origins)
274 {
275   gSecurityOriginsAcquiredCallbackCalled++;
276   gSecurityOriginList.clear();
277   gSecurityOriginList.swap(origins);
278 }
279
280 static void OnStorageUsageAcquired(uint64_t usage)
281 {
282   gStorageUsageAcquiredCallbackCalled++;
283 }
284
285 static void OnFormPasswordsAcquired(std::vector<std::unique_ptr<Dali::WebEngineContext::PasswordData>>& passwords)
286 {
287   gFormPasswordsAcquiredCallbackCalled++;
288   gPasswordDataList.clear();
289   gPasswordDataList.swap(passwords);
290 }
291
292 static void OnDownloadStarted(const std::string& url)
293 {
294   gDownloadStartedCallbackCalled++;
295 }
296
297 static bool OnMimeOverridden(const std::string&, const std::string&, std::string&)
298 {
299   gMimeOverriddenCallbackCalled++;
300   return false;
301 }
302
303 static bool OnRequestIntercepted(Dali::WebEngineRequestInterceptorPtr interceptor)
304 {
305   gRequestInterceptedCallbackCalled++;
306   gRequestInterceptorInstance = interceptor;
307   return false;
308 }
309
310 static void OnContextMenuShown(std::unique_ptr<Dali::WebEngineContextMenu> menu)
311 {
312   gContextMenuShownCallbackCalled++;
313   gContextMenuShownInstance = std::move(menu);
314 }
315
316 static void OnContextMenuHidden(std::unique_ptr<Dali::WebEngineContextMenu> menu)
317 {
318   gContextMenuHiddenCallbackCalled++;
319   gContextMenuHiddenInstance = std::move(menu);
320 }
321
322 } // namespace
323
324 void web_view_startup(void)
325 {
326   test_return_value = TET_UNDEF;
327 }
328
329 void web_view_cleanup(void)
330 {
331   test_return_value = TET_PASS;
332 }
333
334 int UtcDaliWebViewBasics(void)
335 {
336   ToolkitTestApplication application;
337
338   // Copy and Assignment Test
339   tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
340   WebView view = WebView::New();
341   DALI_TEST_CHECK( view );
342
343   WebView copy( view );
344   DALI_TEST_CHECK( view == copy );
345
346   WebView assign;
347   DALI_TEST_CHECK( !assign );
348
349   assign = copy;
350   DALI_TEST_CHECK( assign == view );
351
352   // DownCast Test
353   tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
354   BaseHandle handle(view);
355
356   WebView view2 = WebView::DownCast( handle );
357   DALI_TEST_CHECK( view );
358   DALI_TEST_CHECK( view2 );
359   DALI_TEST_CHECK( view == view2 );
360
361   // TypeRegistry Test
362   tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
363   TypeRegistry typeRegistry = TypeRegistry::Get();
364   DALI_TEST_CHECK( typeRegistry );
365
366   TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
367   DALI_TEST_CHECK( typeInfo );
368
369   BaseHandle handle2 = typeInfo.CreateInstance();
370   DALI_TEST_CHECK( handle2 );
371
372   WebView view3 = WebView::DownCast( handle2 );
373   DALI_TEST_CHECK( view3 );
374
375   END_TEST;
376 }
377
378 int UtcDaliWebViewPageNavigation(void)
379 {
380   ToolkitTestApplication application;
381
382   WebView view = WebView::New();
383   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
384   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
385   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
386   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
387   application.GetScene().Add( view );
388   application.SendNotification();
389   application.Render();
390   DALI_TEST_CHECK( view );
391
392   view.RegisterPageLoadStartedCallback( &OnPageLoadStarted );
393   view.RegisterPageLoadInProgressCallback( &OnPageLoadInProgress );
394   view.RegisterPageLoadFinishedCallback( &OnPageLoadFinished );
395   view.RegisterUrlChangedCallback( &OnUrlChanged );
396   DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
397   DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
398   DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
399   DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
400
401   view.LoadUrl( TEST_URL1 );
402   view.GetNaturalSize();
403   Test::EmitGlobalTimerSignal();
404   DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
405   DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
406   DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
407   DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
408   DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
409
410   view.LoadUrl( TEST_URL2 );
411   view.Suspend();
412   view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
413   application.SendNotification();
414   application.Render();
415   Test::EmitGlobalTimerSignal();
416   view.Resume();
417   DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
418   DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
419   DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
420   DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
421   DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
422   DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
423
424   view.GoBack();
425   Test::EmitGlobalTimerSignal();
426   DALI_TEST_CHECK( !view.CanGoBack() );
427   DALI_TEST_CHECK( view.CanGoForward() );
428
429   view.GoForward();
430   Test::EmitGlobalTimerSignal();
431   DALI_TEST_CHECK( view.CanGoBack() );
432   DALI_TEST_CHECK( !view.CanGoForward() );
433
434   view.Reload();
435   view.StopLoading();
436   view.ClearHistory();
437   Test::EmitGlobalTimerSignal();
438   DALI_TEST_CHECK( !view.CanGoBack() );
439   DALI_TEST_CHECK( !view.CanGoForward() );
440
441   END_TEST;
442 }
443
444 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
445 {
446   ToolkitTestApplication application;
447
448   WebView view = WebView::New();
449   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
450   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
451   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
452   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
453   application.GetScene().Add( view );
454   application.SendNotification();
455   application.Render();
456   DALI_TEST_CHECK( view );
457
458   view.RegisterPageLoadErrorCallback( &OnPageLoadError );
459   view.RegisterConsoleMessageReceivedCallback( &OnConsoleMessage );
460   DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
461   DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
462
463   view.LoadUrl( TEST_URL1 );
464   Test::EmitGlobalTimerSignal();
465   DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
466   DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
467
468   // error code.
469   DALI_TEST_CHECK(gPageLoadErrorInstance);
470   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
471   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
472   std::string testErrorDescription("This is an error.");
473   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
474   DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
475
476   // console message.
477   DALI_TEST_CHECK(gConsoleMessageInstance);
478   std::string testConsoleSource("source");
479   DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
480   DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
481   DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
482   std::string testConsoleText("This is a text.");
483   DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
484
485   // reset
486   gPageLoadErrorInstance = nullptr;
487   gConsoleMessageInstance = nullptr;
488
489   END_TEST;
490 }
491
492 int UtcDaliWebViewTouchAndKeys(void)
493 {
494   ToolkitTestApplication application;
495
496   WebView view = WebView::New();
497   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
498   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
499   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
500   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
501
502   application.GetScene().Add( view );
503   application.SendNotification();
504   application.Render();
505
506   view.GetNaturalSize();
507   view.TouchedSignal().Connect( &OnTouched );
508
509   // Touch event
510   Dali::Integration::TouchEvent event;
511   Dali::Integration::Point pointDown, pointUp;
512
513   event = Dali::Integration::TouchEvent();
514   pointDown.SetState( PointState::DOWN );
515   pointDown.SetScreenPosition( Vector2( 10, 10 ) );
516   event.AddPoint( pointDown );
517   application.ProcessEvent( event );
518
519   event = Dali::Integration::TouchEvent();
520   pointUp.SetState( PointState::UP );
521   pointUp.SetScreenPosition( Vector2( 10, 10 ) );
522   event.AddPoint( pointUp );
523   application.ProcessEvent( event );
524
525   // Key event
526   Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
527   application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
528   application.SendNotification();
529
530   DALI_TEST_CHECK( gTouched );
531   DALI_TEST_CHECK( view );
532
533   END_TEST;
534 }
535
536 int UtcDaliWebViewFocusGainedAndLost(void)
537 {
538   ToolkitTestApplication application;
539
540   WebView view = WebView::New();
541   DALI_TEST_CHECK( view );
542
543   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
544   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
545   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
546   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
547
548   application.GetScene().Add( view );
549   application.SendNotification();
550   application.Render();
551
552   view.SetKeyInputFocus();
553   DALI_TEST_CHECK( view.HasKeyInputFocus() );
554
555   // reset
556   view.ClearKeyInputFocus();
557   DALI_TEST_CHECK( !view.HasKeyInputFocus() );
558
559   END_TEST;
560 }
561
562 int UtcDaliWebViewPropertyPageZoomFactor(void)
563 {
564   ToolkitTestApplication application;
565
566   WebView view = WebView::New();
567   DALI_TEST_CHECK( view );
568
569   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
570   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
571   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
572   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
573
574   application.GetScene().Add( view );
575   application.SendNotification();
576   application.Render();
577
578   view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
579   float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
580   DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
581
582   view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
583   zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
584   DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
585
586   END_TEST;
587 }
588
589 int UtcDaliWebViewPropertyTextZoomFactor(void)
590 {
591   ToolkitTestApplication application;
592
593   WebView view = WebView::New();
594   DALI_TEST_CHECK( view );
595
596   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
597   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
598   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
599   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
600
601   application.GetScene().Add( view );
602   application.SendNotification();
603   application.Render();
604
605   view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
606   float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
607   DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
608
609   view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
610   zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
611   DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
612
613   END_TEST;
614 }
615
616 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
617 {
618   ToolkitTestApplication application;
619
620   WebView view = WebView::New();
621   DALI_TEST_CHECK( view );
622
623   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
624   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
625   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
626   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
627
628   application.GetScene().Add( view );
629   application.SendNotification();
630   application.Render();
631
632   float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
633   DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
634
635   END_TEST;
636 }
637
638 int UtcDaliWebViewMove(void)
639 {
640   ToolkitTestApplication application;
641
642   WebView view = WebView::New();
643   DALI_TEST_CHECK( view );
644
645   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
646   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
647   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
648   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
649
650   application.GetScene().Add( view );
651   application.SendNotification();
652   application.Render();
653
654   view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
655   Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
656   DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
657
658   END_TEST;
659 }
660
661 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
662 {
663   ToolkitTestApplication application;
664
665   WebView view = WebView::New();
666   DALI_TEST_CHECK( view );
667
668   const bool kDefaultValue = false;
669   const bool kTestValue = true;
670
671   // Check default value
672   bool output;
673   Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
674   DALI_TEST_CHECK( value.Get( output ) );
675   DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
676
677   // Check Set/GetProperty
678   view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
679   value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
680   DALI_TEST_CHECK( value.Get( output ) );
681   DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
682
683   END_TEST;
684 }
685
686 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
687 {
688   ToolkitTestApplication application;
689
690   WebView view = WebView::New();
691   DALI_TEST_CHECK( view );
692
693   const bool kDefaultValue = true;
694   const bool kTestValue = false;
695
696   // Check default value
697   bool output;
698   Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
699   DALI_TEST_CHECK( value.Get( output ) );
700   DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
701
702   // Check Set/GetProperty
703   view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
704   value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
705   DALI_TEST_CHECK( value.Get( output ) );
706   DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
707
708   END_TEST;
709 }
710
711 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
712 {
713   ToolkitTestApplication application;
714
715   WebView view = WebView::New();
716   DALI_TEST_CHECK( view );
717
718   const bool kDefaultValue = true;
719   const bool kTestValue = false;
720
721   // Check default value
722   bool output;
723   Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
724   DALI_TEST_CHECK( value.Get( output ) );
725   DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
726
727   // Check Set/GetProperty
728   view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
729   value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
730   DALI_TEST_CHECK( value.Get( output ) );
731   DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
732
733   END_TEST;
734 }
735
736 int UtcDaliWebViewHoverAndWheel(void)
737 {
738   ToolkitTestApplication application;
739
740   WebView view = WebView::New();
741   DALI_TEST_CHECK( view );
742   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
743   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
744   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
745   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
746
747   application.GetScene().Add( view );
748   application.SendNotification();
749   application.Render();
750
751   view.GetNaturalSize();
752   view.HoveredSignal().Connect( &OnHovered );
753   view.WheelEventSignal().Connect( &OnWheelEvent );
754
755   // Hover event
756   Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
757   Dali::Integration::Point pointDown;
758   pointDown.SetState( PointState::DOWN );
759   pointDown.SetScreenPosition( Vector2( 10, 10 ) );
760   event.AddPoint( pointDown );
761   application.ProcessEvent( event );
762
763   event = Dali::Integration::HoverEvent();
764   Dali::Integration::Point pointUp;
765   pointUp.SetState( PointState::UP );
766   pointUp.SetScreenPosition( Vector2( 10, 10 ) );
767   event.AddPoint( pointUp );
768   application.ProcessEvent( event );
769
770   event = Dali::Integration::HoverEvent();
771   Dali::Integration::Point pointMotion;
772   pointUp.SetState( PointState::MOTION );
773   pointUp.SetScreenPosition( Vector2( 10, 10 ) );
774   event.AddPoint( pointMotion );
775   application.ProcessEvent( event );
776
777   // Wheel event
778   Dali::Integration::WheelEvent wheelEvent;
779   wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
780   wheelEvent.direction = 0;
781   wheelEvent.point = Vector2( 20, 20 );
782   wheelEvent.delta = 10;
783   application.ProcessEvent( wheelEvent );
784   application.SendNotification();
785
786   DALI_TEST_CHECK( gHovered );
787   DALI_TEST_CHECK( gWheelEventHandled );
788
789   END_TEST;
790 }
791
792 int UtcDaliWebViewFormRepostDecidedFrameRendering(void)
793 {
794   ToolkitTestApplication application;
795
796   WebView view = WebView::New();
797   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
798   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
799   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
800   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
801   application.GetScene().Add( view );
802   application.SendNotification();
803   application.Render();
804   DALI_TEST_CHECK( view );
805
806   view.RegisterFormRepostDecidedCallback(&OnFormRepostDecided);
807   view.RegisterFrameRenderedCallback(&OnFrameRendered);
808   DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 0, TEST_LOCATION );
809   DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
810
811   view.LoadUrl( TEST_URL1 );
812   Test::EmitGlobalTimerSignal();
813   DALI_TEST_EQUALS( gFormRepostDecidedCallbackCalled, 1, TEST_LOCATION );
814   DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
815
816   // form repost decision.
817   DALI_TEST_CHECK(gFormRepostDecidedInstance);
818   gFormRepostDecidedInstance->Reply(true);
819
820   // reset
821   gFormRepostDecidedInstance = nullptr;
822
823   END_TEST;
824 }
825
826 int UtcDaliWebViewSslCertificateHttpAuthentication(void)
827 {
828   ToolkitTestApplication application;
829
830   WebView view = WebView::New();
831   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
832   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
833   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
834   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
835   application.GetScene().Add( view );
836   application.SendNotification();
837   application.Render();
838   DALI_TEST_CHECK( view );
839
840   view.RegisterCertificateConfirmedCallback(&OnCertificateConfirm);
841   view.RegisterSslCertificateChangedCallback(&OnSslCertificateChanged);
842   view.RegisterHttpAuthHandlerCallback(&OnHttpAuthHandler);
843   DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 0, TEST_LOCATION );
844   DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 0, TEST_LOCATION );
845   DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 0, TEST_LOCATION );
846
847   view.LoadUrl( TEST_URL1 );
848   Test::EmitGlobalTimerSignal();
849   DALI_TEST_EQUALS( gCertificateConfirmCallbackCalled, 1, TEST_LOCATION );
850   DALI_TEST_EQUALS( gSslCertificateChangedCallbackCalled, 1, TEST_LOCATION );
851   DALI_TEST_EQUALS( gHttpAuthHandlerCallbackCalled, 1, TEST_LOCATION );
852
853   // certificate.
854   DALI_TEST_CHECK(gCertificateConfirmInstance);
855   gCertificateConfirmInstance->Allow(true);
856   DALI_TEST_CHECK(gCertificateConfirmInstance->IsFromMainFrame());
857
858   DALI_TEST_CHECK(gSslCertificateInstance);
859   DALI_TEST_EQUALS(gSslCertificateInstance->GetPem(), "abc", TEST_LOCATION);
860   DALI_TEST_CHECK(gSslCertificateInstance->IsContextSecure());
861
862   // http authentication.
863   DALI_TEST_CHECK(gHttpAuthInstance);
864   gHttpAuthInstance->Suspend();
865   gHttpAuthInstance->UseCredential("", "");
866   gHttpAuthInstance->CancelCredential();
867   DALI_TEST_EQUALS(gHttpAuthInstance->GetRealm(), "test", TEST_LOCATION);
868
869   // reset
870   gCertificateConfirmInstance = nullptr;
871   gSslCertificateInstance = nullptr;
872   gHttpAuthInstance = nullptr;
873
874   END_TEST;
875 }
876
877 int UtcDaliWebViewGetWebBackForwardList(void)
878 {
879   ToolkitTestApplication application;
880
881   WebView view = WebView::New();
882   DALI_TEST_CHECK( view );
883
884   Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
885   DALI_TEST_CHECK( bfList != 0 );
886
887   END_TEST;
888 }
889
890 int UtcDaliWebViewGetWebContext(void)
891 {
892   ToolkitTestApplication application;
893
894   WebView view = WebView::New();
895   DALI_TEST_CHECK( view );
896
897   Dali::Toolkit::WebContext* context = view.GetContext();
898   DALI_TEST_CHECK( context != 0 );
899
900   END_TEST;
901 }
902
903 int UtcDaliWebViewGetWebCookieManager(void)
904 {
905   ToolkitTestApplication application;
906
907   WebView view = WebView::New();
908   DALI_TEST_CHECK( view );
909
910   Dali::Toolkit::WebCookieManager* cookieManager = view.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 UtcDaliWebViewHitTest(void)
1305 {
1306   ToolkitTestApplication application;
1307
1308   WebView view = WebView::New();
1309   DALI_TEST_CHECK( view );
1310
1311   // load url.
1312   view.LoadUrl( TEST_URL1 );
1313
1314   // sync hit test.
1315   std::unique_ptr<Dali::WebEngineHitTest> hitTest = view.CreateHitTest(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT);
1316   DALI_TEST_CHECK(hitTest != 0);
1317   DALI_TEST_EQUALS(hitTest->GetResultContext(), Dali::WebEngineHitTest::ResultContext::DOCUMENT, TEST_LOCATION);
1318   std::string testLinkUri("http://test.html");
1319   DALI_TEST_EQUALS(hitTest->GetLinkUri(), testLinkUri, TEST_LOCATION);
1320   std::string testLinkTitle("test");
1321   DALI_TEST_EQUALS(hitTest->GetLinkTitle(), testLinkTitle, TEST_LOCATION);
1322   std::string testLinkLabel("label");
1323   DALI_TEST_EQUALS(hitTest->GetLinkLabel(), testLinkLabel, TEST_LOCATION);
1324   std::string testImageUri("http://test.jpg");
1325   DALI_TEST_EQUALS(hitTest->GetImageUri(), testImageUri, TEST_LOCATION);
1326   std::string testMediaUri("http://test.mp4");
1327   DALI_TEST_EQUALS(hitTest->GetMediaUri(), testMediaUri, TEST_LOCATION);
1328   std::string testTagName("img");
1329   DALI_TEST_EQUALS(hitTest->GetTagName(), testTagName, TEST_LOCATION);
1330   std::string testNodeValue("test");
1331   DALI_TEST_EQUALS(hitTest->GetNodeValue(), testNodeValue, TEST_LOCATION);
1332   Dali::Property::Map testMap = hitTest->GetAttributes();
1333   DALI_TEST_EQUALS(testMap.Count(), 0, TEST_LOCATION);
1334   std::string testImageFileNameExtension("jpg");
1335   DALI_TEST_EQUALS(hitTest->GetImageFileNameExtension(), testImageFileNameExtension, TEST_LOCATION);
1336   Dali::PixelData testImageBuffer = hitTest->GetImageBuffer();
1337   DALI_TEST_CHECK((int)testImageBuffer.GetWidth() == 2 && (int)testImageBuffer.GetHeight() == 2);
1338
1339   // async...
1340   bool result = view.CreateHitTestAsynchronously(100, 100, Dali::WebEngineHitTest::HitTestMode::DEFAULT, &OnHitTestCreated);
1341   DALI_TEST_CHECK(result);
1342   Test::EmitGlobalTimerSignal();
1343   DALI_TEST_EQUALS( gHitTestCreatedCallbackCalled, 1, TEST_LOCATION );
1344
1345   END_TEST;
1346 }
1347
1348 int UtcDaliWebViewEvaluteJavaScript(void)
1349 {
1350   ToolkitTestApplication application;
1351
1352   WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1353
1354   view.LoadHtmlString( "<body>Hello World!</body>" );
1355   view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1356   view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1357   Test::EmitGlobalTimerSignal();
1358
1359   DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1360
1361   END_TEST;
1362 }
1363
1364 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1365 {
1366   ToolkitTestApplication application;
1367
1368   WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1369
1370   view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1371   view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1372   view.JavaScriptAlertReply();
1373   Test::EmitGlobalTimerSignal();
1374   DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1375
1376   view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1377   view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1378   view.JavaScriptConfirmReply( true );
1379   Test::EmitGlobalTimerSignal();
1380   DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1381
1382   view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1383   view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1384   view.JavaScriptPromptReply( "it is a prompt." );
1385   Test::EmitGlobalTimerSignal();
1386   DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1387
1388   END_TEST;
1389 }
1390
1391 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1392 {
1393   ToolkitTestApplication application;
1394
1395   WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1396   DALI_TEST_CHECK( view );
1397
1398   std::string html("<body>Hello World!</body>");
1399   std::string basicUri("http://basicurl");
1400   std::string unreachableUrl("http://unreachableurl");
1401   bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1402   DALI_TEST_CHECK( result );
1403
1404   application.SendNotification();
1405   application.Render();
1406   Test::EmitGlobalTimerSignal();
1407
1408   result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1409   DALI_TEST_CHECK( result );
1410
1411   END_TEST;
1412 }
1413
1414 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1415 {
1416   ToolkitTestApplication application;
1417
1418   WebView view = WebView::New();
1419   view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1420   view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1421   view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1422   view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1423
1424   application.GetScene().Add( view );
1425   application.SendNotification();
1426   application.Render();
1427   DALI_TEST_CHECK( view );
1428
1429   view.LoadUrl( "http://test.html" );
1430   bool result = view.AddCustomHeader("key", "value");
1431   DALI_TEST_CHECK( result );
1432
1433   result = view.ReloadWithoutCache();
1434   DALI_TEST_CHECK( result );
1435
1436   uint32_t portNumber = view.StartInspectorServer(5000);
1437   DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1438
1439   application.SendNotification();
1440   application.Render();
1441   Test::EmitGlobalTimerSignal();
1442
1443   result = view.StopInspectorServer();
1444   DALI_TEST_CHECK( result );
1445
1446   view.SuspendNetworkLoading();
1447
1448   result = view.RemoveCustomHeader("key");
1449   DALI_TEST_CHECK( result );
1450
1451   view.ResumeNetworkLoading();
1452
1453   END_TEST;
1454 }
1455
1456 int UtcDaliWebViewMethodsForCoverage(void)
1457 {
1458   ToolkitTestApplication application;
1459
1460   WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1461
1462   view.LoadHtmlString( "<body>Hello World!</body>" );
1463   view.AddJavaScriptMessageHandler( "jsObject",
1464     []( const std::string& arg ) {
1465     }
1466   );
1467   view.SetTtsFocus(true);
1468
1469   DALI_TEST_CHECK( view );
1470
1471   END_TEST;
1472 }
1473
1474 // test cases for web backforward list.
1475
1476 int UtcDaliWebBackForwardListCheckItem(void)
1477 {
1478   ToolkitTestApplication application;
1479
1480   WebView view = WebView::New();
1481   DALI_TEST_CHECK( view );
1482
1483   Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1484   DALI_TEST_CHECK( bfList != 0 )
1485
1486   unsigned int itemCount = bfList->GetItemCount();
1487   DALI_TEST_CHECK( itemCount == 1 )
1488
1489   std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
1490   DALI_TEST_CHECK( citem != 0 );
1491
1492   std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
1493   DALI_TEST_CHECK( citemP != 0 );
1494
1495   std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
1496   DALI_TEST_CHECK( citemN != 0 );
1497
1498   const std::string kDefaultUrl( "http://url" );
1499   std::string testValue = citem->GetUrl();
1500   DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1501
1502   const std::string kDefaultTitle( "title" );
1503   testValue = citem->GetTitle();
1504   DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1505
1506   const std::string kDefaultOriginalUrl( "http://originalurl" );
1507   testValue = citem->GetOriginalUrl();
1508   DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1509
1510   std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
1511   DALI_TEST_CHECK( item != 0 );
1512
1513   std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
1514   DALI_TEST_CHECK( vecBack.size() == 1 );
1515
1516   std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
1517   DALI_TEST_CHECK( vecForward.size() == 1 );
1518
1519   END_TEST;
1520 }
1521
1522 // test cases for web context.
1523
1524 int UtcDaliWebContextGetSetCacheModel(void)
1525 {
1526   ToolkitTestApplication application;
1527
1528   WebView view = WebView::New();
1529   DALI_TEST_CHECK( view );
1530
1531   Dali::Toolkit::WebContext* context = view.GetContext();
1532   DALI_TEST_CHECK( context != 0 )
1533
1534   std::string kDefaultValue;
1535
1536   // Reset something
1537   context->SetAppId( "id" );
1538   context->SetApplicationType( Dali::WebEngineContext::ApplicationType::OTHER );
1539   context->SetTimeOffset( 0 );
1540   context->SetTimeZoneOffset( 0, 0 );
1541   context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1542   context->DeleteAllWebDatabase();
1543   context->DeleteAllWebStorage();
1544   context->DeleteLocalFileSystem();
1545   context->ClearCache();
1546   context->DeleteAllFormPasswordData();
1547   context->DeleteAllFormCandidateData();
1548
1549   // Check default value
1550   Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1551   DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1552
1553   // Check Set/GetProperty
1554   context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1555   value = context->GetCacheModel();
1556   DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1557
1558   // Get cache enabled
1559   context->EnableCache( true );
1560   DALI_TEST_CHECK( context->IsCacheEnabled() );
1561
1562   // Get certificate
1563   context->SetCertificateFilePath( "test" );
1564   std::string str = context->GetCertificateFilePath();
1565   DALI_TEST_EQUALS( str, "test", TEST_LOCATION );
1566
1567   // Set version
1568   DALI_TEST_CHECK( context->SetAppVersion( "test" ) );
1569
1570   // Register
1571   std::vector<std::string> temp;
1572   context->RegisterUrlSchemesAsCorsEnabled( temp );
1573   context->RegisterJsPluginMimeTypes( temp );
1574   context->DeleteFormPasswordDataList( temp );
1575
1576   // Get zoom factor
1577   context->SetDefaultZoomFactor( 1.0f );
1578   DALI_TEST_EQUALS( context->GetDefaultZoomFactor(), float( 1.0f ), TEST_LOCATION );
1579
1580   // Delete cache and database
1581   DALI_TEST_CHECK( context->DeleteAllApplicationCache() );
1582   DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() );
1583
1584   // Get contextProxy
1585   context->SetProxyUri( "test" );
1586   DALI_TEST_EQUALS( context->GetProxyUri(), "test", TEST_LOCATION );
1587   context->SetProxyBypassRule("", "test");
1588   DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION );
1589
1590   //Notify low memory
1591   DALI_TEST_CHECK( context->FreeUnusedMemory() );
1592
1593   END_TEST;
1594 }
1595
1596 int UtcDaliWebContextGetWebDatabaseStorageOrigins(void)
1597 {
1598   ToolkitTestApplication application;
1599
1600   WebView view = WebView::New();
1601   DALI_TEST_CHECK( view );
1602
1603   Dali::Toolkit::WebContext* context = view.GetContext();
1604   DALI_TEST_CHECK( context != 0 )
1605
1606   std::string kDefaultValue;
1607
1608   // get origins of web database
1609   bool result = context->GetWebDatabaseOrigins(&OnSecurityOriginsAcquired);
1610   DALI_TEST_CHECK( result );
1611
1612   Test::EmitGlobalTimerSignal();
1613   DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 1, TEST_LOCATION );
1614   DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1615
1616   Dali::WebEngineSecurityOrigin* origin = gSecurityOriginList[0].get();
1617   DALI_TEST_CHECK( origin );
1618
1619   result = context->DeleteWebDatabase(*origin);
1620   DALI_TEST_CHECK( result );
1621
1622   // get origins of web storage
1623   result = context->GetWebStorageOrigins(&OnSecurityOriginsAcquired);
1624   DALI_TEST_CHECK( result );
1625
1626   Test::EmitGlobalTimerSignal();
1627   DALI_TEST_EQUALS( gSecurityOriginsAcquiredCallbackCalled, 2, TEST_LOCATION );
1628   DALI_TEST_CHECK(gSecurityOriginList.size() == 1);
1629
1630   origin = gSecurityOriginList[0].get();
1631   DALI_TEST_CHECK( origin );
1632
1633   result = context->GetWebStorageUsageForOrigin(*origin, &OnStorageUsageAcquired);
1634   DALI_TEST_CHECK( result );
1635   Test::EmitGlobalTimerSignal();
1636   DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION );
1637
1638   result = context->DeleteWebStorage(*origin);
1639   DALI_TEST_CHECK( result );
1640
1641   result = context->DeleteApplicationCache(*origin);
1642   DALI_TEST_CHECK( result );
1643
1644   // form passwords, download state, mime type.
1645   context->GetFormPasswordList(&OnFormPasswordsAcquired);
1646   Test::EmitGlobalTimerSignal();
1647   DALI_TEST_EQUALS(gFormPasswordsAcquiredCallbackCalled, 1, TEST_LOCATION);
1648   DALI_TEST_CHECK(gPasswordDataList.size() == 1);
1649   DALI_TEST_EQUALS(gPasswordDataList[0]->url, "http://test.html", TEST_LOCATION);
1650   DALI_TEST_CHECK(gPasswordDataList[0]->useFingerprint == false);
1651
1652   context->RegisterDownloadStartedCallback(&OnDownloadStarted);
1653   Test::EmitGlobalTimerSignal();
1654   DALI_TEST_EQUALS(gDownloadStartedCallbackCalled, 1, TEST_LOCATION);
1655
1656   context->RegisterMimeOverriddenCallback(&OnMimeOverridden);
1657   Test::EmitGlobalTimerSignal();
1658   DALI_TEST_EQUALS(gMimeOverriddenCallbackCalled, 1, TEST_LOCATION);
1659
1660   gSecurityOriginList.clear();
1661   gPasswordDataList.clear();
1662
1663   END_TEST;
1664 }
1665
1666 int UtcDaliWebContextHttpRequestInterceptor(void)
1667 {
1668   ToolkitTestApplication application;
1669
1670   WebView view = WebView::New();
1671   DALI_TEST_CHECK( view );
1672
1673   Dali::Toolkit::WebContext* context = view.GetContext();
1674   DALI_TEST_CHECK( context != 0 )
1675
1676   // load url.
1677   context->RegisterRequestInterceptedCallback(&OnRequestIntercepted);
1678   DALI_TEST_EQUALS(gRequestInterceptedCallbackCalled, 0, TEST_LOCATION);
1679   DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1680
1681   Test::EmitGlobalTimerSignal();
1682   DALI_TEST_EQUALS( gRequestInterceptedCallbackCalled, 1, TEST_LOCATION );
1683
1684   // check request interceptor.
1685   DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1686   DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1687   DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1688   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key1", "value1"));
1689   Dali::Property::Map testHeaders;
1690   testHeaders.Insert("key2", "value2");
1691   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeaders(testHeaders));
1692   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1693   DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponse("key:value", "test", 4));
1694   DALI_TEST_CHECK(gRequestInterceptorInstance->WriteResponseChunk("test", 4));
1695   std::string testUrl("http://test.html");
1696   DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1697   std::string testMethod("GET");
1698   DALI_TEST_EQUALS(gRequestInterceptorInstance->GetMethod(), testMethod, TEST_LOCATION);
1699   Dali::Property::Map resultHeaders = gRequestInterceptorInstance->GetHeaders();
1700   DALI_TEST_EQUALS(resultHeaders.Count(), 2, TEST_LOCATION);
1701
1702   gRequestInterceptorInstance = nullptr;
1703
1704   END_TEST;
1705 }
1706
1707 // test cases for web cookie manager.
1708
1709 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1710 {
1711   ToolkitTestApplication application;
1712
1713   WebView view = WebView::New();
1714   DALI_TEST_CHECK( view );
1715
1716   Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1717   DALI_TEST_CHECK( cookieManager != 0 )
1718
1719   const std::string kDefaultValue;
1720
1721   // Reset something
1722   cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1723   cookieManager->ClearCookies();
1724
1725   // Check default value
1726   Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1727   DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1728
1729   // Check Set/GetProperty
1730   cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1731   value = cookieManager->GetCookieAcceptPolicy();
1732   DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1733
1734   END_TEST;
1735 }
1736
1737 int UtcDaliWebCookieManagerChangesWatch(void)
1738 {
1739   ToolkitTestApplication application;
1740
1741   WebView view = WebView::New();
1742   DALI_TEST_CHECK( view );
1743
1744   Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1745   DALI_TEST_CHECK( cookieManager != 0 )
1746
1747   cookieManager->ChangesWatch(&OnChangesWatch);
1748   Test::EmitGlobalTimerSignal();
1749   DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
1750
1751   END_TEST;
1752 }
1753
1754 // test cases for web settings.
1755
1756 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1757 {
1758   ToolkitTestApplication application;
1759
1760   WebView view = WebView::New();
1761   DALI_TEST_CHECK( view );
1762
1763   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1764   DALI_TEST_CHECK( settings != 0 )
1765
1766   // Reset something
1767   settings->AllowMixedContents( false );
1768   settings->EnableSpatialNavigation( false );
1769   settings->EnableWebSecurity( false );
1770   settings->EnableCacheBuilder( false );
1771   settings->EnableDoNotTrack( false );
1772   settings->UseScrollbarThumbFocusNotifications( false );
1773   settings->AllowFileAccessFromExternalUrl( false );
1774   settings->AllowScriptsOpenWindows( false );
1775
1776   // Check default value
1777   int value = settings->GetDefaultFontSize();
1778   DALI_TEST_CHECK( value == 16 );
1779
1780   // Check Set/GetProperty
1781   settings->SetDefaultFontSize( 20 );
1782   value = settings->GetDefaultFontSize();
1783   DALI_TEST_CHECK( value == 20 );
1784
1785   END_TEST;
1786 }
1787
1788 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1789 {
1790   ToolkitTestApplication application;
1791
1792   WebView view = WebView::New();
1793   DALI_TEST_CHECK( view );
1794
1795   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1796   DALI_TEST_CHECK( settings != 0 )
1797
1798   // Reset something
1799   settings->AllowMixedContents( false );
1800   settings->EnableSpatialNavigation( false );
1801   settings->EnableWebSecurity( false );
1802   settings->EnableCacheBuilder( false );
1803   settings->EnableDoNotTrack( false );
1804   settings->UseScrollbarThumbFocusNotifications( false );
1805   settings->AllowFileAccessFromExternalUrl( false );
1806   settings->AllowScriptsOpenWindows( false );
1807
1808   // Check default value is true or not
1809   bool value = settings->IsJavaScriptEnabled();
1810   DALI_TEST_CHECK( value );
1811
1812   // Check Set/GetProperty
1813   settings->EnableJavaScript( false );
1814   value = settings->IsJavaScriptEnabled();
1815   DALI_TEST_CHECK( !value );
1816
1817   END_TEST;
1818 }
1819
1820 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1821 {
1822   ToolkitTestApplication application;
1823
1824   WebView view = WebView::New();
1825   DALI_TEST_CHECK( view );
1826
1827   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1828   DALI_TEST_CHECK( settings != 0 )
1829
1830   // Reset something
1831   settings->AllowMixedContents( false );
1832   settings->EnableSpatialNavigation( false );
1833   settings->EnableWebSecurity( false );
1834   settings->EnableCacheBuilder( false );
1835   settings->EnableDoNotTrack( false );
1836   settings->UseScrollbarThumbFocusNotifications( false );
1837   settings->AllowFileAccessFromExternalUrl( false );
1838   settings->AllowScriptsOpenWindows( false );
1839
1840   // Check default value is true or not
1841   bool value = settings->IsAutoFittingEnabled();
1842   DALI_TEST_CHECK( value );
1843
1844   // Check Set/GetProperty
1845   settings->EnableAutoFitting( false );
1846   value = settings->IsAutoFittingEnabled();
1847   DALI_TEST_CHECK( !value );
1848
1849   END_TEST;
1850 }
1851
1852 int UtcDaliWebSettingsCheckEnablePlugins(void)
1853 {
1854   ToolkitTestApplication application;
1855
1856   WebView view = WebView::New();
1857   DALI_TEST_CHECK( view );
1858
1859   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1860   DALI_TEST_CHECK( settings != 0 )
1861
1862   // Reset something
1863   settings->AllowMixedContents( false );
1864   settings->EnableSpatialNavigation( false );
1865   settings->EnableWebSecurity( false );
1866   settings->EnableCacheBuilder( false );
1867   settings->EnableDoNotTrack( false );
1868   settings->UseScrollbarThumbFocusNotifications( false );
1869   settings->AllowFileAccessFromExternalUrl( false );
1870   settings->AllowScriptsOpenWindows( false );
1871
1872   // Check default value is true or not
1873   bool value = settings->ArePluginsEnabled();
1874   DALI_TEST_CHECK( value );
1875
1876   // Check Set/GetProperty
1877   settings->EnablePlugins( false );
1878   value = settings->ArePluginsEnabled();
1879   DALI_TEST_CHECK( !value );
1880
1881   END_TEST;
1882 }
1883
1884 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1885 {
1886   ToolkitTestApplication application;
1887
1888   WebView view = WebView::New();
1889   DALI_TEST_CHECK( view );
1890
1891   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1892   DALI_TEST_CHECK( settings != 0 )
1893
1894   // Reset something
1895   settings->AllowMixedContents( false );
1896   settings->EnableSpatialNavigation( false );
1897   settings->EnableWebSecurity( false );
1898   settings->EnableCacheBuilder( false );
1899   settings->EnableDoNotTrack( false );
1900   settings->UseScrollbarThumbFocusNotifications( false );
1901   settings->AllowFileAccessFromExternalUrl( false );
1902   settings->AllowScriptsOpenWindows( false );
1903
1904   // Check default value is true or not
1905   bool value = settings->IsPrivateBrowsingEnabled();
1906   DALI_TEST_CHECK( value );
1907
1908   // Check Set/GetProperty
1909   settings->EnablePrivateBrowsing( false );
1910   value = settings->IsPrivateBrowsingEnabled();
1911   DALI_TEST_CHECK( !value );
1912
1913   END_TEST;
1914 }
1915
1916 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1917 {
1918   ToolkitTestApplication application;
1919
1920   WebView view = WebView::New();
1921   DALI_TEST_CHECK( view );
1922
1923   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1924   DALI_TEST_CHECK( settings != 0 )
1925
1926   // Reset something
1927   settings->AllowMixedContents( false );
1928   settings->EnableSpatialNavigation( false );
1929   settings->EnableWebSecurity( false );
1930   settings->EnableCacheBuilder( false );
1931   settings->EnableDoNotTrack( false );
1932   settings->UseScrollbarThumbFocusNotifications( false );
1933   settings->AllowFileAccessFromExternalUrl( false );
1934   settings->AllowScriptsOpenWindows( false );
1935
1936   // Check default value is true or not
1937   bool value = settings->IsLinkMagnifierEnabled();
1938   DALI_TEST_CHECK( value );
1939
1940   // Check Set/GetProperty
1941   settings->EnableLinkMagnifier( false );
1942   value = settings->IsLinkMagnifierEnabled();
1943   DALI_TEST_CHECK( !value );
1944
1945   END_TEST;
1946 }
1947
1948 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1949 {
1950   ToolkitTestApplication application;
1951
1952   WebView view = WebView::New();
1953   DALI_TEST_CHECK( view );
1954
1955   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1956   DALI_TEST_CHECK( settings != 0 )
1957
1958   // Reset something
1959   settings->AllowMixedContents( false );
1960   settings->EnableSpatialNavigation( false );
1961   settings->EnableWebSecurity( false );
1962   settings->EnableCacheBuilder( false );
1963   settings->EnableDoNotTrack( false );
1964   settings->UseScrollbarThumbFocusNotifications( false );
1965   settings->AllowFileAccessFromExternalUrl( false );
1966   settings->AllowScriptsOpenWindows( false );
1967
1968   // Check default value is true or not
1969   bool value = settings->IsKeypadWithoutUserActionUsed();
1970   DALI_TEST_CHECK( value );
1971
1972   // Check Set/GetProperty
1973   settings->UseKeypadWithoutUserAction( false );
1974   value = settings->IsKeypadWithoutUserActionUsed();
1975   DALI_TEST_CHECK( !value );
1976
1977   END_TEST;
1978 }
1979
1980 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1981 {
1982   ToolkitTestApplication application;
1983
1984   WebView view = WebView::New();
1985   DALI_TEST_CHECK( view );
1986
1987   Dali::Toolkit::WebSettings* settings = view.GetSettings();
1988   DALI_TEST_CHECK( settings != 0 )
1989
1990   // Reset something
1991   settings->AllowMixedContents( false );
1992   settings->EnableSpatialNavigation( false );
1993   settings->EnableWebSecurity( false );
1994   settings->EnableCacheBuilder( false );
1995   settings->EnableDoNotTrack( false );
1996   settings->UseScrollbarThumbFocusNotifications( false );
1997   settings->AllowFileAccessFromExternalUrl( false );
1998   settings->AllowScriptsOpenWindows( false );
1999
2000   // Check default value is true or not
2001   bool value = settings->IsAutofillPasswordFormEnabled();
2002   DALI_TEST_CHECK( value );
2003   settings->EnableAutofillPasswordForm( false );
2004   value = settings->IsAutofillPasswordFormEnabled();
2005   DALI_TEST_CHECK( !value );
2006   END_TEST;
2007 }
2008
2009 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
2010 {
2011   ToolkitTestApplication application;
2012
2013   WebView view = WebView::New();
2014   DALI_TEST_CHECK( view );
2015
2016   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2017   DALI_TEST_CHECK( settings != 0 );
2018
2019   // Reset something
2020   settings->AllowMixedContents( false );
2021   settings->EnableSpatialNavigation( false );
2022   settings->EnableWebSecurity( false );
2023   settings->EnableCacheBuilder( false );
2024   settings->EnableDoNotTrack( false );
2025   settings->UseScrollbarThumbFocusNotifications( false );
2026   settings->AllowFileAccessFromExternalUrl( false );
2027   settings->AllowScriptsOpenWindows( false );
2028
2029   // Check default value is true or not
2030   bool value = settings->IsFormCandidateDataEnabled();
2031   DALI_TEST_CHECK( value );
2032
2033   // Check Set/GetProperty
2034   settings->EnableFormCandidateData( false );
2035   value = settings->IsFormCandidateDataEnabled();
2036   DALI_TEST_CHECK( !value );
2037
2038   END_TEST;
2039 }
2040
2041 int UtcDaliWebSettingsCheckEnableTextSelection(void)
2042 {
2043   ToolkitTestApplication application;
2044
2045   WebView view = WebView::New();
2046   DALI_TEST_CHECK( view );
2047
2048   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2049   DALI_TEST_CHECK( settings != 0 );
2050
2051   // Reset something
2052   settings->AllowMixedContents( false );
2053   settings->EnableSpatialNavigation( false );
2054   settings->EnableWebSecurity( false );
2055   settings->EnableCacheBuilder( false );
2056   settings->EnableDoNotTrack( false );
2057   settings->UseScrollbarThumbFocusNotifications( false );
2058   settings->AllowFileAccessFromExternalUrl( false );
2059   settings->AllowScriptsOpenWindows( false );
2060
2061   // Check default value is true or not
2062   bool value = settings->IsTextSelectionEnabled();
2063   DALI_TEST_CHECK( value );
2064
2065   //Check Set/GetProperty
2066   settings->EnableTextSelection(false);
2067   value = settings->IsTextSelectionEnabled();
2068   DALI_TEST_CHECK( !value );
2069
2070   END_TEST;
2071 }
2072
2073 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
2074 {
2075   ToolkitTestApplication application;
2076
2077   WebView view = WebView::New();
2078   DALI_TEST_CHECK( view );
2079
2080   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2081   DALI_TEST_CHECK( settings != 0 );
2082
2083   // Reset something
2084   settings->AllowMixedContents( false );
2085   settings->EnableSpatialNavigation( false );
2086   settings->EnableWebSecurity( false );
2087   settings->EnableCacheBuilder( false );
2088   settings->EnableDoNotTrack( false );
2089   settings->UseScrollbarThumbFocusNotifications( false );
2090   settings->AllowFileAccessFromExternalUrl( false );
2091   settings->AllowScriptsOpenWindows( false );
2092
2093   // Check default value is true or not
2094   bool value = settings->IsTextAutosizingEnabled();
2095   DALI_TEST_CHECK( value );
2096
2097   // Check Set/GetProperty
2098   settings->EnableTextAutosizing(false);
2099   value = settings->IsTextAutosizingEnabled();
2100   DALI_TEST_CHECK( !value );
2101
2102   END_TEST;
2103 }
2104
2105 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
2106 {
2107   ToolkitTestApplication application;
2108
2109   WebView view = WebView::New();
2110   DALI_TEST_CHECK( view );
2111
2112   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2113   DALI_TEST_CHECK( settings != 0 );
2114
2115   // Reset something
2116   settings->AllowMixedContents( false );
2117   settings->EnableSpatialNavigation( false );
2118   settings->EnableWebSecurity( false );
2119   settings->EnableCacheBuilder( false );
2120   settings->EnableDoNotTrack( false );
2121   settings->UseScrollbarThumbFocusNotifications( false );
2122   settings->AllowFileAccessFromExternalUrl( false );
2123   settings->AllowScriptsOpenWindows( false );
2124
2125   // Check default value is true or not
2126   bool value = settings->IsArrowScrollEnabled();
2127   DALI_TEST_CHECK( value );
2128
2129   // Check Set/GetProperty
2130   settings->EnableArrowScroll(false);
2131   value = settings->IsArrowScrollEnabled();
2132   DALI_TEST_CHECK( !value );
2133
2134   END_TEST;
2135 }
2136
2137 int UtcDaliWebSettingsCheckEnableClipboard(void)
2138 {
2139   ToolkitTestApplication application;
2140
2141   WebView view = WebView::New();
2142   DALI_TEST_CHECK( view );
2143
2144   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2145   DALI_TEST_CHECK( settings != 0 );
2146
2147   // Reset something
2148   settings->AllowMixedContents( false );
2149   settings->EnableSpatialNavigation( false );
2150   settings->EnableWebSecurity( false );
2151   settings->EnableCacheBuilder( false );
2152   settings->EnableDoNotTrack( false );
2153   settings->UseScrollbarThumbFocusNotifications( false );
2154   settings->AllowFileAccessFromExternalUrl( false );
2155   settings->AllowScriptsOpenWindows( false );
2156
2157   // Check default value is true or not
2158   bool value = settings->IsClipboardEnabled();
2159   DALI_TEST_CHECK( value );
2160   settings->EnableClipboard(false);
2161   value = settings->IsClipboardEnabled();
2162   DALI_TEST_CHECK( !value );
2163   END_TEST;
2164 }
2165
2166 int UtcDaliWebSettingsCheckEnableImePanel(void)
2167 {
2168   ToolkitTestApplication application;
2169
2170   WebView view = WebView::New();
2171   DALI_TEST_CHECK( view );
2172
2173   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2174   DALI_TEST_CHECK( settings != 0 );
2175
2176   // Reset something
2177   settings->AllowMixedContents( false );
2178   settings->EnableSpatialNavigation( false );
2179   settings->EnableWebSecurity( false );
2180   settings->EnableCacheBuilder( false );
2181   settings->EnableDoNotTrack( false );
2182   settings->UseScrollbarThumbFocusNotifications( false );
2183   settings->AllowFileAccessFromExternalUrl( false );
2184   settings->AllowScriptsOpenWindows( false );
2185
2186   // Check default value is true or not
2187   bool value = settings->IsImePanelEnabled();
2188   DALI_TEST_CHECK( value );
2189
2190   // Check Set/GetProperty
2191   settings->EnableImePanel(false);
2192   value = settings->IsImePanelEnabled();
2193   DALI_TEST_CHECK( !value );
2194
2195   END_TEST;
2196 }
2197
2198 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
2199 {
2200   ToolkitTestApplication application;
2201
2202   WebView view = WebView::New();
2203   DALI_TEST_CHECK( view );
2204
2205   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2206   DALI_TEST_CHECK( settings != 0 )
2207
2208   // Reset something
2209   settings->AllowMixedContents( false );
2210   settings->EnableSpatialNavigation( false );
2211   settings->EnableWebSecurity( false );
2212   settings->EnableCacheBuilder( false );
2213   settings->EnableDoNotTrack( false );
2214   settings->UseScrollbarThumbFocusNotifications( false );
2215   settings->AllowFileAccessFromExternalUrl( false );
2216   settings->AllowScriptsOpenWindows( false );
2217
2218   // Check default value is true or not
2219   bool value = settings->AreImagesLoadedAutomatically();
2220   DALI_TEST_CHECK( value );
2221
2222   // Check Set/GetProperty
2223   settings->AllowImagesLoadAutomatically( false );
2224   value = settings->AreImagesLoadedAutomatically();
2225   DALI_TEST_CHECK( !value );
2226
2227   END_TEST;
2228 }
2229
2230 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
2231 {
2232   ToolkitTestApplication application;
2233
2234   WebView view = WebView::New();
2235   DALI_TEST_CHECK( view );
2236
2237   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2238   DALI_TEST_CHECK( settings != 0 )
2239
2240   const std::string kDefaultValue;
2241   const std::string kTestValue = "UTF-8";
2242
2243   // Reset something
2244   settings->AllowMixedContents( false );
2245   settings->EnableSpatialNavigation( false );
2246   settings->EnableWebSecurity( false );
2247   settings->EnableCacheBuilder( false );
2248   settings->EnableDoNotTrack( false );
2249   settings->UseScrollbarThumbFocusNotifications( false );
2250   settings->AllowFileAccessFromExternalUrl( false );
2251   settings->AllowScriptsOpenWindows( false );
2252
2253   // Check default value
2254   std::string value = settings->GetDefaultTextEncodingName();
2255   DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
2256
2257   // Check Set/GetProperty
2258   settings->SetDefaultTextEncodingName( kTestValue );
2259   value = settings->GetDefaultTextEncodingName();
2260   DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
2261
2262   END_TEST;
2263 }
2264
2265 int UtcDaliWebSettingsSetViewportMetaTag(void)
2266 {
2267   ToolkitTestApplication application;
2268
2269   WebView view = WebView::New();
2270   DALI_TEST_CHECK( view );
2271
2272   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2273   DALI_TEST_CHECK( settings != 0 )
2274
2275   // Check the value is true or not
2276   bool value = settings->SetViewportMetaTag(true);
2277   DALI_TEST_CHECK( value );
2278
2279   END_TEST;
2280 }
2281
2282 int UtcDaliWebSettingsSetForceZoom(void)
2283 {
2284   ToolkitTestApplication application;
2285
2286   WebView view = WebView::New();
2287   DALI_TEST_CHECK( view );
2288
2289   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2290   DALI_TEST_CHECK( settings != 0 )
2291
2292   // Check the value is true or not
2293   bool value = settings->SetForceZoom(true);
2294   DALI_TEST_CHECK( value );
2295
2296   value = settings->IsZoomForced();
2297   DALI_TEST_CHECK( value );
2298
2299   END_TEST;
2300 }
2301
2302 int UtcDaliWebSettingsSetTextZoomEnabled(void)
2303 {
2304   ToolkitTestApplication application;
2305
2306   WebView view = WebView::New();
2307   DALI_TEST_CHECK( view );
2308
2309   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2310   DALI_TEST_CHECK( settings != 0 )
2311
2312   // Check the value is true or not
2313   bool value = settings->SetTextZoomEnabled(true);
2314   DALI_TEST_CHECK( value );
2315
2316   value = settings->IsTextZoomEnabled();
2317   DALI_TEST_CHECK( value );
2318
2319   END_TEST;
2320 }
2321
2322 int UtcDaliWebSettingsSetExtraFeature(void)
2323 {
2324   ToolkitTestApplication application;
2325
2326   WebView view = WebView::New();
2327   DALI_TEST_CHECK( view );
2328
2329   Dali::Toolkit::WebSettings* settings = view.GetSettings();
2330   DALI_TEST_CHECK( settings != 0 )
2331
2332   // Check the value is true or not
2333   settings->SetExtraFeature("test", true);
2334   bool value = settings->IsExtraFeatureEnabled("test");
2335   DALI_TEST_CHECK( value );
2336
2337   END_TEST;
2338 }
2339
2340 int UtcDaliWebViewGetPlainText(void)
2341 {
2342   ToolkitTestApplication application;
2343
2344   WebView view = WebView::New();
2345   DALI_TEST_CHECK(view);
2346
2347   view.LoadUrl(TEST_URL1);
2348
2349   view.GetPlainTextAsynchronously(&OnPlainTextReceived);
2350   Test::EmitGlobalTimerSignal();
2351   DALI_TEST_EQUALS(gPlainTextReceivedCallbackCalled, 1, TEST_LOCATION);
2352
2353   END_TEST;
2354 }
2355