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