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