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