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