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