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