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