2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include "dali-toolkit-test-utils/toolkit-timer.h"
25 #include <dali/devel-api/adaptor-framework/web-engine-frame.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
30 #include <dali/integration-api/events/hover-event-integ.h>
31 #include <dali/integration-api/events/key-event-integ.h>
32 #include <dali/integration-api/events/touch-event-integ.h>
33 #include <dali/integration-api/events/wheel-event-integ.h>
34 #include <dali/public-api/images/pixel-data.h>
35 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
36 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
37 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
38 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
39 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
40 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
41 #include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
42 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
43 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
46 using namespace Toolkit;
51 const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
52 const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
54 static int gPageLoadStartedCallbackCalled = 0;
55 static int gPageLoadInProgressCallbackCalled = 0;
56 static int gPageLoadFinishedCallbackCalled = 0;
57 static int gPageLoadErrorCallbackCalled = 0;
58 static std::shared_ptr<Dali::WebEngineLoadError> gPageLoadErrorInstance = nullptr;
59 static int gScrollEdgeReachedCallbackCalled = 0;
60 static int gUrlChangedCallbackCalled = 0;
61 static int gEvaluateJavaScriptCallbackCalled = 0;
62 static int gJavaScriptAlertCallbackCalled = 0;
63 static int gJavaScriptConfirmCallbackCalled = 0;
64 static int gJavaScriptPromptCallbackCalled = 0;
65 static int gScreenshotCapturedCallbackCalled = 0;
66 static int gVideoPlayingCallbackCalled = 0;
67 static int gGeolocationPermissionCallbackCalled = 0;
68 static bool gTouched = false;
69 static bool gHovered = false;
70 static bool gWheelEventHandled = false;
71 static int gFormRepostDecisionCallbackCalled = 0;
72 static std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> gFormRepostDecisionInstance = nullptr;
73 static int gFrameRenderedCallbackCalled = 0;
74 static int gRequestInterceptorCallbackCalled = 0;
75 static std::shared_ptr<Dali::WebEngineRequestInterceptor> gRequestInterceptorInstance = nullptr;
76 static int gConsoleMessageCallbackCalled = 0;
77 static std::shared_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
78 static int gPolicyDecisionCallbackCalled = 0;
79 static std::shared_ptr<Dali::WebEnginePolicyDecision> gPolicyDecisionInstance = nullptr;
81 struct CallbackFunctor
83 CallbackFunctor(bool* callbackFlag)
84 : mCallbackFlag( callbackFlag )
90 *mCallbackFlag = true;
95 static void OnPageLoadStarted( WebView view, const std::string& url )
97 gPageLoadStartedCallbackCalled++;
100 static void OnPageLoadInProgress( WebView view, const std::string& url )
102 gPageLoadInProgressCallbackCalled++;
105 static void OnPageLoadFinished( WebView view, const std::string& url )
107 gPageLoadFinishedCallbackCalled++;
110 static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
112 gScrollEdgeReachedCallbackCalled++;
115 static void OnPolicyDecisionRequest(WebView view, std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
117 gPolicyDecisionCallbackCalled++;
118 gPolicyDecisionInstance = std::move(decision);
121 static void OnUrlChanged( WebView view, const std::string& url )
123 gUrlChangedCallbackCalled++;
126 static void OnPageLoadError(WebView view, std::shared_ptr<Dali::WebEngineLoadError> error)
128 gPageLoadErrorCallbackCalled++;
129 gPageLoadErrorInstance = std::move(error);
132 static void OnEvaluateJavaScript( const std::string& result )
134 gEvaluateJavaScriptCallbackCalled++;
137 static bool OnJavaScriptAlert( const std::string& result )
139 gJavaScriptAlertCallbackCalled++;
143 static bool OnJavaScriptConfirm( const std::string& result )
145 gJavaScriptConfirmCallbackCalled++;
149 static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string& message2 )
151 gJavaScriptPromptCallbackCalled++;
155 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
157 gScreenshotCapturedCallbackCalled++;
\r
160 static void OnVideoPlaying(bool isPlaying)
162 gVideoPlayingCallbackCalled++;
165 static bool OnGeolocationPermission(const std::string&, const std::string&)
167 gGeolocationPermissionCallbackCalled++;
171 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
177 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
183 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheel )
185 gWheelEventHandled = true;
189 static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> decision)
191 gFormRepostDecisionCallbackCalled++;
192 gFormRepostDecisionInstance = std::move(decision);
195 static void OnFrameRendered(WebView)
197 gFrameRenderedCallbackCalled++;
200 static void OnRequestInterceptor(WebView view, std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
202 gRequestInterceptorCallbackCalled++;
203 gRequestInterceptorInstance = std::move(interceptor);
206 static void OnConsoleMessage(WebView view, std::shared_ptr<Dali::WebEngineConsoleMessage> message)
208 gConsoleMessageCallbackCalled++;
209 gConsoleMessageInstance = std::move(message);
214 void web_view_startup(void)
216 test_return_value = TET_UNDEF;
219 void web_view_cleanup(void)
221 test_return_value = TET_PASS;
224 int UtcDaliWebViewBasics(void)
226 ToolkitTestApplication application;
228 // Copy and Assignment Test
229 tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
230 WebView view = WebView::New();
231 DALI_TEST_CHECK( view );
233 WebView copy( view );
234 DALI_TEST_CHECK( view == copy );
237 DALI_TEST_CHECK( !assign );
240 DALI_TEST_CHECK( assign == view );
243 tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
244 BaseHandle handle(view);
246 WebView view2 = WebView::DownCast( handle );
247 DALI_TEST_CHECK( view );
248 DALI_TEST_CHECK( view2 );
249 DALI_TEST_CHECK( view == view2 );
252 tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
253 TypeRegistry typeRegistry = TypeRegistry::Get();
254 DALI_TEST_CHECK( typeRegistry );
256 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
257 DALI_TEST_CHECK( typeInfo );
259 BaseHandle handle2 = typeInfo.CreateInstance();
260 DALI_TEST_CHECK( handle2 );
262 WebView view3 = WebView::DownCast( handle2 );
263 DALI_TEST_CHECK( view3 );
268 int UtcDaliWebViewPageNavigation(void)
270 ToolkitTestApplication application;
272 WebView view = WebView::New();
273 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
274 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
275 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
276 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
277 application.GetScene().Add( view );
278 application.SendNotification();
279 application.Render();
280 DALI_TEST_CHECK( view );
282 ConnectionTracker* testTracker = new ConnectionTracker();
283 view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
284 view.PageLoadInProgressSignal().Connect( &OnPageLoadInProgress );
285 view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
286 view.UrlChangedSignal().Connect( &OnUrlChanged );
287 bool signal1 = false;
288 bool signal2 = false;
289 bool signal3 = false;
290 bool signal4 = false;
291 bool signal5 = false;
292 view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
293 view.ConnectSignal( testTracker, "pageLoadInProgress", CallbackFunctor(&signal2) );
294 view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal3) );
295 view.ConnectSignal( testTracker, "urlChanged", CallbackFunctor(&signal4) );
296 view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal5) );
297 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
298 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
299 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
300 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
302 view.LoadUrl( TEST_URL1 );
303 view.GetNaturalSize();
304 Test::EmitGlobalTimerSignal();
305 DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
306 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
307 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
308 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
309 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
310 DALI_TEST_CHECK( signal1 & signal2 & signal3 & signal4 );
311 DALI_TEST_CHECK( !signal5 );
313 view.LoadUrl( TEST_URL2 );
315 view.SetProperty( Actor::Property::SIZE, Vector2( 400, 300 ) );
316 application.SendNotification();
317 application.Render();
318 Test::EmitGlobalTimerSignal();
320 DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
321 DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
322 DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
323 DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
324 DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
325 DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
328 Test::EmitGlobalTimerSignal();
329 DALI_TEST_CHECK( !view.CanGoBack() );
330 DALI_TEST_CHECK( view.CanGoForward() );
333 Test::EmitGlobalTimerSignal();
334 DALI_TEST_CHECK( view.CanGoBack() );
335 DALI_TEST_CHECK( !view.CanGoForward() );
340 Test::EmitGlobalTimerSignal();
341 DALI_TEST_CHECK( !view.CanGoBack() );
342 DALI_TEST_CHECK( !view.CanGoForward() );
347 int UtcDaliWebViewPageLoadErrorConsoleMessage(void)
349 ToolkitTestApplication application;
351 WebView view = WebView::New();
352 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
353 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
354 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
355 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
356 application.GetScene().Add( view );
357 application.SendNotification();
358 application.Render();
359 DALI_TEST_CHECK( view );
361 ConnectionTracker* testTracker = new ConnectionTracker();
362 view.PageLoadErrorSignal().Connect( &OnPageLoadError );
363 view.ConsoleMessageSignal().Connect( &OnConsoleMessage );
364 bool signal1 = false;
365 bool signal2 = false;
366 view.ConnectSignal( testTracker, "pageLoadError", CallbackFunctor(&signal1) );
367 view.ConnectSignal( testTracker, "consoleMessage", CallbackFunctor(&signal2) );
368 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 0, TEST_LOCATION );
369 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 0, TEST_LOCATION );
371 view.LoadUrl( TEST_URL1 );
372 Test::EmitGlobalTimerSignal();
373 DALI_TEST_EQUALS( gPageLoadErrorCallbackCalled, 1, TEST_LOCATION );
374 DALI_TEST_EQUALS( gConsoleMessageCallbackCalled, 1, TEST_LOCATION );
375 DALI_TEST_CHECK( signal1 & signal2);
378 DALI_TEST_CHECK(gPageLoadErrorInstance);
379 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetUrl(), TEST_URL1, TEST_LOCATION);
380 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetCode(), Dali::WebEngineLoadError::ErrorCode::UNKNOWN, TEST_LOCATION);
381 std::string testErrorDescription("This is an error.");
382 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetDescription(), testErrorDescription, TEST_LOCATION);
383 DALI_TEST_EQUALS(gPageLoadErrorInstance->GetType(), Dali::WebEngineLoadError::ErrorType::NONE, TEST_LOCATION);
386 DALI_TEST_CHECK(gConsoleMessageInstance);
387 std::string testConsoleSource("source");
388 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSource(), testConsoleSource, TEST_LOCATION);
389 DALI_TEST_EQUALS(gConsoleMessageInstance->GetLine(), 10, TEST_LOCATION);
390 DALI_TEST_EQUALS(gConsoleMessageInstance->GetSeverityLevel(), Dali::WebEngineConsoleMessage::SeverityLevel::EMPTY, TEST_LOCATION);
391 std::string testConsoleText("This is a text.");
392 DALI_TEST_EQUALS(gConsoleMessageInstance->GetText(), testConsoleText, TEST_LOCATION);
395 gPageLoadErrorInstance = nullptr;
396 gConsoleMessageInstance = nullptr;
401 int UtcDaliWebViewTouchAndKeys(void)
403 ToolkitTestApplication application;
405 WebView view = WebView::New();
406 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
407 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
408 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
409 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
411 application.GetScene().Add( view );
412 application.SendNotification();
413 application.Render();
415 view.GetNaturalSize();
416 view.TouchedSignal().Connect( &OnTouched );
419 Dali::Integration::TouchEvent event;
420 Dali::Integration::Point pointDown, pointUp;
422 event = Dali::Integration::TouchEvent();
423 pointDown.SetState( PointState::DOWN );
424 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
425 event.AddPoint( pointDown );
426 application.ProcessEvent( event );
428 event = Dali::Integration::TouchEvent();
429 pointUp.SetState( PointState::UP );
430 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
431 event.AddPoint( pointUp );
432 application.ProcessEvent( event );
435 Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
436 application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
437 application.SendNotification();
439 DALI_TEST_CHECK( gTouched );
440 DALI_TEST_CHECK( view );
445 int UtcDaliWebViewFocusGainedAndLost(void)
447 ToolkitTestApplication application;
449 WebView view = WebView::New();
450 DALI_TEST_CHECK( view );
452 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
453 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
454 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
455 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
457 application.GetScene().Add( view );
458 application.SendNotification();
459 application.Render();
461 view.SetKeyInputFocus();
462 DALI_TEST_CHECK( view.HasKeyInputFocus() );
465 view.ClearKeyInputFocus();
466 DALI_TEST_CHECK( !view.HasKeyInputFocus() );
471 int UtcDaliWebViewPropertyPageZoomFactor(void)
473 ToolkitTestApplication application;
475 WebView view = WebView::New();
476 DALI_TEST_CHECK( view );
478 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
479 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
480 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
481 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
483 application.GetScene().Add( view );
484 application.SendNotification();
485 application.Render();
487 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
488 float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
489 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
491 view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
492 zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
493 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
498 int UtcDaliWebViewPropertyTextZoomFactor(void)
500 ToolkitTestApplication application;
502 WebView view = WebView::New();
503 DALI_TEST_CHECK( view );
505 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
506 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
507 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
508 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
510 application.GetScene().Add( view );
511 application.SendNotification();
512 application.Render();
514 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
515 float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
516 DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
518 view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
519 zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
520 DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
525 int UtcDaliWebViewPropertyLoadProgressPercentage(void)
527 ToolkitTestApplication application;
529 WebView view = WebView::New();
530 DALI_TEST_CHECK( view );
532 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
533 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
534 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
535 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
537 application.GetScene().Add( view );
538 application.SendNotification();
539 application.Render();
541 float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
542 DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
547 int UtcDaliWebViewMove(void)
549 ToolkitTestApplication application;
551 WebView view = WebView::New();
552 DALI_TEST_CHECK( view );
554 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
555 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
556 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
557 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
559 application.GetScene().Add( view );
560 application.SendNotification();
561 application.Render();
563 view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
564 Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
565 DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
570 int UtcDaliWebViewPropertyVideoHoleEnabled(void)
572 ToolkitTestApplication application;
574 WebView view = WebView::New();
575 DALI_TEST_CHECK( view );
577 const bool kDefaultValue = true;
578 const bool kTestValue = false;
580 // Check default value
582 Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
583 DALI_TEST_CHECK( value.Get( output ) );
584 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
586 // Check Set/GetProperty
587 view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
588 value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
589 DALI_TEST_CHECK( value.Get( output ) );
590 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
595 int UtcDaliWebViewPropertyMouseEventsEnabled(void)
597 ToolkitTestApplication application;
599 WebView view = WebView::New();
600 DALI_TEST_CHECK( view );
602 const bool kDefaultValue = true;
603 const bool kTestValue = false;
605 // Check default value
607 Property::Value value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
608 DALI_TEST_CHECK( value.Get( output ) );
609 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
611 // Check Set/GetProperty
612 view.SetProperty( WebView::Property::MOUSE_EVENTS_ENABLED, kTestValue );
613 value = view.GetProperty( WebView::Property::MOUSE_EVENTS_ENABLED );
614 DALI_TEST_CHECK( value.Get( output ) );
615 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
620 int UtcDaliWebViewPropertyKeyEventsEnabled(void)
622 ToolkitTestApplication application;
624 WebView view = WebView::New();
625 DALI_TEST_CHECK( view );
627 const bool kDefaultValue = true;
628 const bool kTestValue = false;
630 // Check default value
632 Property::Value value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
633 DALI_TEST_CHECK( value.Get( output ) );
634 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
636 // Check Set/GetProperty
637 view.SetProperty( WebView::Property::KEY_EVENTS_ENABLED, kTestValue );
638 value = view.GetProperty( WebView::Property::KEY_EVENTS_ENABLED );
639 DALI_TEST_CHECK( value.Get( output ) );
640 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
645 int UtcDaliWebViewHoverAndWheel(void)
647 ToolkitTestApplication application;
649 WebView view = WebView::New();
650 DALI_TEST_CHECK( view );
651 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
652 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
653 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
654 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
656 application.GetScene().Add( view );
657 application.SendNotification();
658 application.Render();
660 view.GetNaturalSize();
661 view.HoveredSignal().Connect( &OnHovered );
662 view.WheelEventSignal().Connect( &OnWheelEvent );
665 Dali::Integration::HoverEvent event = Dali::Integration::HoverEvent();
666 Dali::Integration::Point pointDown;
667 pointDown.SetState( PointState::DOWN );
668 pointDown.SetScreenPosition( Vector2( 10, 10 ) );
669 event.AddPoint( pointDown );
670 application.ProcessEvent( event );
672 event = Dali::Integration::HoverEvent();
673 Dali::Integration::Point pointUp;
674 pointUp.SetState( PointState::UP );
675 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
676 event.AddPoint( pointUp );
677 application.ProcessEvent( event );
679 event = Dali::Integration::HoverEvent();
680 Dali::Integration::Point pointMotion;
681 pointUp.SetState( PointState::MOTION );
682 pointUp.SetScreenPosition( Vector2( 10, 10 ) );
683 event.AddPoint( pointMotion );
684 application.ProcessEvent( event );
687 Dali::Integration::WheelEvent wheelEvent;
688 wheelEvent.type = Dali::Integration::WheelEvent::Type::MOUSE_WHEEL;
689 wheelEvent.direction = 0;
690 wheelEvent.point = Vector2( 20, 20 );
691 wheelEvent.delta = 10;
692 application.ProcessEvent( wheelEvent );
693 application.SendNotification();
695 DALI_TEST_CHECK( gHovered );
696 DALI_TEST_CHECK( gWheelEventHandled );
701 int UtcDaliWebViewFormRepostDecisionFrameRendering(void)
703 ToolkitTestApplication application;
705 WebView view = WebView::New();
706 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
707 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
708 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
709 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
710 application.GetScene().Add( view );
711 application.SendNotification();
712 application.Render();
713 DALI_TEST_CHECK( view );
715 ConnectionTracker* testTracker = new ConnectionTracker();
716 view.FormRepostDecisionSignal().Connect(&OnFormRepostDecision);
717 view.FrameRenderedSignal().Connect(&OnFrameRendered);
718 bool signal1 = false;
719 bool signal2 = false;
720 view.ConnectSignal( testTracker, "formRepostDecision", CallbackFunctor(&signal1) );
721 view.ConnectSignal( testTracker, "frameRendered", CallbackFunctor(&signal2) );
722 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 0, TEST_LOCATION );
723 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
725 view.LoadUrl( TEST_URL1 );
726 Test::EmitGlobalTimerSignal();
727 DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 1, TEST_LOCATION );
728 DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
729 DALI_TEST_CHECK( signal1 & signal2);
731 // form repost decision.
732 DALI_TEST_CHECK(gFormRepostDecisionInstance);
733 gFormRepostDecisionInstance->Reply(true);
736 gFormRepostDecisionInstance = nullptr;
741 int UtcDaliWebViewGetWebBackForwardList(void)
743 ToolkitTestApplication application;
745 WebView view = WebView::New();
746 DALI_TEST_CHECK( view );
748 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
749 DALI_TEST_CHECK( bfList != 0 );
754 int UtcDaliWebViewGetWebContext(void)
756 ToolkitTestApplication application;
758 WebView view = WebView::New();
759 DALI_TEST_CHECK( view );
761 Dali::Toolkit::WebContext* context = view.GetContext();
762 DALI_TEST_CHECK( context != 0 );
767 int UtcDaliWebViewGetWebCookieManager(void)
769 ToolkitTestApplication application;
771 WebView view = WebView::New();
772 DALI_TEST_CHECK( view );
774 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
775 DALI_TEST_CHECK( cookieManager != 0 );
780 int UtcDaliWebViewGetWebSettings(void)
782 ToolkitTestApplication application;
784 WebView view = WebView::New();
785 DALI_TEST_CHECK( view );
787 Dali::Toolkit::WebSettings* settings = view.GetSettings();
788 DALI_TEST_CHECK( settings != 0 );
793 int UtcDaliWebViewProperty1(void)
796 ToolkitTestApplication application;
798 WebView view = WebView::New();
799 DALI_TEST_CHECK( view );
802 view.SetProperty( WebView::Property::URL, TEST_URL1 );
803 Property::Value val = view.GetProperty( WebView::Property::URL );
804 DALI_TEST_CHECK( val.Get( local ) );
805 DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
810 int UtcDaliWebViewProperty4(void)
813 ToolkitTestApplication application;
815 WebView view = WebView::New();
816 DALI_TEST_CHECK( view );
818 const std::string kDefaultValue;
819 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";
821 // Check default value
823 Property::Value value = view.GetProperty( WebView::Property::USER_AGENT );
824 DALI_TEST_CHECK( value.Get( output ) );
825 DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
827 // Check Set/GetProperty
828 view.SetProperty( WebView::Property::USER_AGENT, kTestValue );
829 value = view.GetProperty( WebView::Property::USER_AGENT );
830 DALI_TEST_CHECK( value.Get( output ) );
831 DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
836 int UtcDaliWebViewProperty9(void)
839 ToolkitTestApplication application;
841 WebView view = WebView::New();
842 DALI_TEST_CHECK( view );
844 // Check default value
845 Dali::Vector2 output = Dali::Vector2::ONE;
846 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
847 DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
849 // Check Set/GetProperty
850 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
851 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
852 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
853 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
855 // Check default value of scroll size
856 output = Dali::Vector2::ONE;
857 view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
858 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
860 // Check default value of content size
861 output = Dali::Vector2::ONE;
862 view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
863 DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
868 int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void)
870 ToolkitTestApplication application;
872 WebView view = WebView::New();
873 DALI_TEST_CHECK( view );
875 Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f);
876 view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue);
877 view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true);
878 view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f);
879 view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true);
881 // Check default value
882 std::string testText("test");
884 view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output);
885 DALI_TEST_EQUALS(output, testText, TEST_LOCATION);
890 int UtcDaliWebViewPropertyTitleFavicon(void)
892 ToolkitTestApplication application;
894 char argv[] = "--test";
895 WebView view = WebView::New( 1, (char**)&argv );
896 DALI_TEST_CHECK( view );
899 view.ClearAllTilesResources();
901 // Check default value of title
902 std::string testValue("title");
904 view.GetProperty( WebView::Property::TITLE ).Get( output );
905 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
907 // Check default value of favicon
908 Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
909 DALI_TEST_CHECK( favicon );
910 Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
911 DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
916 int UtcDaliWebViewScrollBy(void)
918 ToolkitTestApplication application;
920 WebView view = WebView::New();
921 DALI_TEST_CHECK( view );
924 ConnectionTracker* testTracker = new ConnectionTracker();
925 view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
926 bool signal1 = false;
927 view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
928 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
930 view.LoadUrl( TEST_URL1 );
931 Test::EmitGlobalTimerSignal();
933 // set scroll position.
934 Dali::Vector2 output = Dali::Vector2::ONE;
935 Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
936 view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
937 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
938 DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
940 // scroll by and trigger scrollEdgeReached event.
941 view.ScrollBy( 50, 50 );
942 Test::EmitGlobalTimerSignal();
944 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
945 DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
946 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
947 DALI_TEST_CHECK( signal1 );
949 // scroll by and trigger scrollEdgeReached event.
950 bool result = view.ScrollEdgeBy( 50, 50 );
951 DALI_TEST_CHECK( result );
952 Test::EmitGlobalTimerSignal();
954 view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
955 DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
956 DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
957 DALI_TEST_CHECK( signal1 );
962 int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
964 ToolkitTestApplication application;
966 WebView view = WebView::New();
967 DALI_TEST_CHECK( view );
969 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
970 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
971 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
972 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
974 application.GetScene().Add( view );
975 application.SendNotification();
976 application.Render();
978 view.ActivateAccessibility(true);
979 view.AddDynamicCertificatePath("host", "test/to/path");
980 bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
981 DALI_TEST_CHECK( found );
983 view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
984 float result = view.GetScaleFactor();
985 DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
987 view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
988 result = view.GetScaleFactor();
989 DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
994 int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
997 ToolkitTestApplication application;
999 char argv[] = "--test";
1000 WebView view = WebView::New( 1, (char**)&argv );
1001 DALI_TEST_CHECK( view );
1003 // Check GetScreenshot
1004 Dali::Rect<int> viewArea;
1007 viewArea.width = 10;
1008 viewArea.height = 10;
1009 Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
1010 DALI_TEST_CHECK( screenshot );
1011 Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
1012 DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
1014 // Check GetScreenshotAsynchronously
1017 viewArea.width = 100;
1018 viewArea.height = 100;
1019 bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
1020 DALI_TEST_CHECK( result );
1022 Test::EmitGlobalTimerSignal();
1024 Test::EmitGlobalTimerSignal();
1025 DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
1030 int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
1033 ToolkitTestApplication application;
1035 char argv[] = "--test";
1036 WebView view = WebView::New( 1, (char**)&argv );
1037 DALI_TEST_CHECK( view );
1039 // Check CheckVideoPlayingAsynchronously
1040 bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
1041 DALI_TEST_CHECK( result );
1042 Test::EmitGlobalTimerSignal();
1043 DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
1045 // Check RegisterGeolocationPermissionCallback
1046 view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
1047 Test::EmitGlobalTimerSignal();
1048 DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
1053 int UtcDaliWebViewHttpRequestInterceptor(void)
1055 ToolkitTestApplication application;
1057 WebView view = WebView::New();
1058 DALI_TEST_CHECK( view );
1061 ConnectionTracker* testTracker = new ConnectionTracker();
1062 view.RequestInterceptorSignal().Connect( &OnRequestInterceptor );
1063 bool signal1 = false;
1064 view.ConnectSignal( testTracker, "requestInterceptor", CallbackFunctor(&signal1) );
1065 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 0, TEST_LOCATION );
1066 DALI_TEST_CHECK(gRequestInterceptorInstance == 0);
1068 view.LoadUrl( TEST_URL1 );
1069 Test::EmitGlobalTimerSignal();
1070 DALI_TEST_EQUALS( gRequestInterceptorCallbackCalled, 1, TEST_LOCATION );
1071 DALI_TEST_CHECK( signal1 );
1073 // check request interceptor.
1074 DALI_TEST_CHECK(gRequestInterceptorInstance != 0);
1075 DALI_TEST_CHECK(gRequestInterceptorInstance->Ignore());
1076 DALI_TEST_CHECK(gRequestInterceptorInstance->SetResponseStatus(400, "error"));
1077 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseHeader("key", "value"));
1078 DALI_TEST_CHECK(gRequestInterceptorInstance->AddResponseBody("test", 4));
1079 std::string testUrl("http://test.html");
1080 DALI_TEST_EQUALS(gRequestInterceptorInstance->GetUrl(), testUrl, TEST_LOCATION);
1082 gRequestInterceptorInstance = nullptr;
1087 int UtcDaliWebViewPolicyDecisionRequest(void)
1089 ToolkitTestApplication application;
1091 WebView view = WebView::New();
1092 DALI_TEST_CHECK( view );
1095 ConnectionTracker* testTracker = new ConnectionTracker();
1096 view.PolicyDecisionSignal().Connect( &OnPolicyDecisionRequest );
1097 bool signal1 = false;
1098 view.ConnectSignal( testTracker, "policyDecision", CallbackFunctor(&signal1) );
1099 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 0, TEST_LOCATION );
1100 DALI_TEST_CHECK(gPolicyDecisionInstance == 0);
1102 view.LoadUrl( TEST_URL1 );
1103 Test::EmitGlobalTimerSignal();
1104 DALI_TEST_EQUALS( gPolicyDecisionCallbackCalled, 1, TEST_LOCATION );
1105 DALI_TEST_CHECK( signal1 );
1107 // check policy decision & its frame.
1108 DALI_TEST_CHECK(gPolicyDecisionInstance != 0);
1109 std::string testUrl("http://test.html");
1110 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetUrl(), testUrl, TEST_LOCATION);
1111 std::string testCookie("test:abc");
1112 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetCookie(), testCookie, TEST_LOCATION);
1113 Dali::WebEnginePolicyDecision::DecisionType testDecisionType = Dali::WebEnginePolicyDecision::DecisionType::USE;
1114 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetDecisionType(), testDecisionType, TEST_LOCATION);
1115 std::string testResponseMime("txt/xml");
1116 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseMime(), testResponseMime, TEST_LOCATION);
1117 int32_t ResponseStatusCode = 500;
1118 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetResponseStatusCode(), ResponseStatusCode, TEST_LOCATION);
1119 Dali::WebEnginePolicyDecision::NavigationType testNavigationType = Dali::WebEnginePolicyDecision::NavigationType::LINK_CLICKED;
1120 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetNavigationType(), testNavigationType, TEST_LOCATION);
1121 std::string testScheme("test");
1122 DALI_TEST_EQUALS(gPolicyDecisionInstance->GetScheme(), testScheme, TEST_LOCATION);
1123 DALI_TEST_CHECK(gPolicyDecisionInstance->Use());
1124 DALI_TEST_CHECK(gPolicyDecisionInstance->Ignore());
1125 DALI_TEST_CHECK(gPolicyDecisionInstance->Suspend());
1127 Dali::WebEngineFrame* webFrame = &(gPolicyDecisionInstance->GetFrame());
1128 DALI_TEST_CHECK(webFrame);
1129 DALI_TEST_CHECK(webFrame->IsMainFrame());
1131 gPolicyDecisionInstance = nullptr;
1136 int UtcDaliWebViewEvaluteJavaScript(void)
1138 ToolkitTestApplication application;
1140 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1142 view.LoadHtmlString( "<body>Hello World!</body>" );
1143 view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
1144 view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
1145 Test::EmitGlobalTimerSignal();
1147 DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
1152 int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
1154 ToolkitTestApplication application;
1156 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1158 view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
1159 view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
1160 view.JavaScriptAlertReply();
1161 Test::EmitGlobalTimerSignal();
1162 DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
1164 view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
1165 view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
1166 view.JavaScriptConfirmReply( true );
1167 Test::EmitGlobalTimerSignal();
1168 DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
1170 view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
1171 view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
1172 view.JavaScriptPromptReply( "it is a prompt." );
1173 Test::EmitGlobalTimerSignal();
1174 DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
1179 int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
1181 ToolkitTestApplication application;
1183 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1184 DALI_TEST_CHECK( view );
1186 std::string html("<body>Hello World!</body>");
1187 std::string basicUri("http://basicurl");
1188 std::string unreachableUrl("http://unreachableurl");
1189 bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
1190 DALI_TEST_CHECK( result );
1192 application.SendNotification();
1193 application.Render();
1194 Test::EmitGlobalTimerSignal();
1196 result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
1197 DALI_TEST_CHECK( result );
1202 int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
1204 ToolkitTestApplication application;
1206 WebView view = WebView::New();
1207 view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1208 view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1209 view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
1210 view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
1212 application.GetScene().Add( view );
1213 application.SendNotification();
1214 application.Render();
1215 DALI_TEST_CHECK( view );
1217 view.LoadUrl( "http://test.html" );
1218 bool result = view.AddCustomHeader("key", "value");
1219 DALI_TEST_CHECK( result );
1221 result = view.ReloadWithoutCache();
1222 DALI_TEST_CHECK( result );
1224 uint32_t portNumber = view.StartInspectorServer(5000);
1225 DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
1227 application.SendNotification();
1228 application.Render();
1229 Test::EmitGlobalTimerSignal();
1231 result = view.StopInspectorServer();
1232 DALI_TEST_CHECK( result );
1234 view.SuspendNetworkLoading();
1236 result = view.RemoveCustomHeader("key");
1237 DALI_TEST_CHECK( result );
1239 view.ResumeNetworkLoading();
1244 int UtcDaliWebViewMethodsForCoverage(void)
1246 ToolkitTestApplication application;
1248 WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
1250 view.LoadHtmlString( "<body>Hello World!</body>" );
1251 view.AddJavaScriptMessageHandler( "jsObject",
1252 []( const std::string& arg ) {
1256 DALI_TEST_CHECK( view );
1261 // test cases for web backforward list.
1263 int UtcDaliWebBackForwardListCheckItem(void)
1265 ToolkitTestApplication application;
1267 WebView view = WebView::New();
1268 DALI_TEST_CHECK( view );
1270 Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
1271 DALI_TEST_CHECK( bfList != 0 )
1273 unsigned int itemCount = bfList->GetItemCount();
1274 DALI_TEST_CHECK( itemCount == 1 )
1276 Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
1277 DALI_TEST_CHECK( citem != 0 );
1279 const std::string kDefaultUrl( "http://url" );
1280 std::string testValue = citem->GetUrl();
1281 DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
1283 const std::string kDefaultTitle( "title" );
1284 testValue = citem->GetTitle();
1285 DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
1287 const std::string kDefaultOriginalUrl( "http://originalurl" );
1288 testValue = citem->GetOriginalUrl();
1289 DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
1291 Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
1292 DALI_TEST_CHECK( item != 0 );
1297 // test cases for web context.
1299 int UtcDaliWebContextGetSetCacheModel(void)
1301 ToolkitTestApplication application;
1303 WebView view = WebView::New();
1304 DALI_TEST_CHECK( view );
1306 Dali::Toolkit::WebContext* context = view.GetContext();
1307 DALI_TEST_CHECK( context != 0 )
1309 std::string kDefaultValue;
1312 context->SetProxyUri( kDefaultValue );
1313 context->SetCertificateFilePath( kDefaultValue );
1314 context->DisableCache( false );
1315 context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
1316 context->DeleteWebDatabase();
1317 context->DeleteWebStorage();
1318 context->DeleteLocalFileSystem();
1319 context->ClearCache();
1321 // Check default value
1322 Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
1323 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
1325 // Check Set/GetProperty
1326 context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1327 value = context->GetCacheModel();
1328 DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
1333 // test cases for web cookie manager.
1335 int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
1337 ToolkitTestApplication application;
1339 WebView view = WebView::New();
1340 DALI_TEST_CHECK( view );
1342 Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
1343 DALI_TEST_CHECK( cookieManager != 0 )
1345 const std::string kDefaultValue;
1348 cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
1349 cookieManager->ClearCookies();
1351 // Check default value
1352 Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
1353 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
1355 // Check Set/GetProperty
1356 cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1357 value = cookieManager->GetCookieAcceptPolicy();
1358 DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
1363 // test cases for web settings.
1365 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
1367 ToolkitTestApplication application;
1369 WebView view = WebView::New();
1370 DALI_TEST_CHECK( view );
1372 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1373 DALI_TEST_CHECK( settings != 0 )
1376 settings->AllowMixedContents( false );
1377 settings->EnableSpatialNavigation( false );
1378 settings->EnableWebSecurity( false );
1379 settings->EnableCacheBuilder( false );
1380 settings->EnableDoNotTrack( false );
1381 settings->UseScrollbarThumbFocusNotifications( false );
1382 settings->AllowFileAccessFromExternalUrl( false );
1383 settings->AllowScriptsOpenWindows( false );
1385 // Check default value
1386 int value = settings->GetDefaultFontSize();
1387 DALI_TEST_CHECK( value == 16 );
1389 // Check Set/GetProperty
1390 settings->SetDefaultFontSize( 20 );
1391 value = settings->GetDefaultFontSize();
1392 DALI_TEST_CHECK( value == 20 );
1397 int UtcDaliWebSettingsCheckEnableJavaScript(void)
1399 ToolkitTestApplication application;
1401 WebView view = WebView::New();
1402 DALI_TEST_CHECK( view );
1404 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1405 DALI_TEST_CHECK( settings != 0 )
1408 settings->AllowMixedContents( false );
1409 settings->EnableSpatialNavigation( false );
1410 settings->EnableWebSecurity( false );
1411 settings->EnableCacheBuilder( false );
1412 settings->EnableDoNotTrack( false );
1413 settings->UseScrollbarThumbFocusNotifications( false );
1414 settings->AllowFileAccessFromExternalUrl( false );
1415 settings->AllowScriptsOpenWindows( false );
1417 // Check default value is true or not
1418 bool value = settings->IsJavaScriptEnabled();
1419 DALI_TEST_CHECK( value );
1421 // Check Set/GetProperty
1422 settings->EnableJavaScript( false );
1423 value = settings->IsJavaScriptEnabled();
1424 DALI_TEST_CHECK( !value );
1429 int UtcDaliWebSettingsCheckEnableAutoFitting(void)
1431 ToolkitTestApplication application;
1433 WebView view = WebView::New();
1434 DALI_TEST_CHECK( view );
1436 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1437 DALI_TEST_CHECK( settings != 0 )
1440 settings->AllowMixedContents( false );
1441 settings->EnableSpatialNavigation( false );
1442 settings->EnableWebSecurity( false );
1443 settings->EnableCacheBuilder( false );
1444 settings->EnableDoNotTrack( false );
1445 settings->UseScrollbarThumbFocusNotifications( false );
1446 settings->AllowFileAccessFromExternalUrl( false );
1447 settings->AllowScriptsOpenWindows( false );
1449 // Check default value is true or not
1450 bool value = settings->IsAutoFittingEnabled();
1451 DALI_TEST_CHECK( value );
1453 // Check Set/GetProperty
1454 settings->EnableAutoFitting( false );
1455 value = settings->IsAutoFittingEnabled();
1456 DALI_TEST_CHECK( !value );
1461 int UtcDaliWebSettingsCheckEnablePlugins(void)
1463 ToolkitTestApplication application;
1465 WebView view = WebView::New();
1466 DALI_TEST_CHECK( view );
1468 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1469 DALI_TEST_CHECK( settings != 0 )
1472 settings->AllowMixedContents( false );
1473 settings->EnableSpatialNavigation( false );
1474 settings->EnableWebSecurity( false );
1475 settings->EnableCacheBuilder( false );
1476 settings->EnableDoNotTrack( false );
1477 settings->UseScrollbarThumbFocusNotifications( false );
1478 settings->AllowFileAccessFromExternalUrl( false );
1479 settings->AllowScriptsOpenWindows( false );
1481 // Check default value is true or not
1482 bool value = settings->ArePluginsEnabled();
1483 DALI_TEST_CHECK( value );
1485 // Check Set/GetProperty
1486 settings->EnablePlugins( false );
1487 value = settings->ArePluginsEnabled();
1488 DALI_TEST_CHECK( !value );
1493 int UtcDaliWebSettingsCheckEnablePrivateBrowsing(void)
1495 ToolkitTestApplication application;
1497 WebView view = WebView::New();
1498 DALI_TEST_CHECK( view );
1500 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1501 DALI_TEST_CHECK( settings != 0 )
1504 settings->AllowMixedContents( false );
1505 settings->EnableSpatialNavigation( false );
1506 settings->EnableWebSecurity( false );
1507 settings->EnableCacheBuilder( false );
1508 settings->EnableDoNotTrack( false );
1509 settings->UseScrollbarThumbFocusNotifications( false );
1510 settings->AllowFileAccessFromExternalUrl( false );
1511 settings->AllowScriptsOpenWindows( false );
1513 // Check default value is true or not
1514 bool value = settings->IsPrivateBrowsingEnabled();
1515 DALI_TEST_CHECK( value );
1517 // Check Set/GetProperty
1518 settings->EnablePrivateBrowsing( false );
1519 value = settings->IsPrivateBrowsingEnabled();
1520 DALI_TEST_CHECK( !value );
1525 int UtcDaliWebSettingsCheckEnableLinkMagnifier(void)
1527 ToolkitTestApplication application;
1529 WebView view = WebView::New();
1530 DALI_TEST_CHECK( view );
1532 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1533 DALI_TEST_CHECK( settings != 0 )
1536 settings->AllowMixedContents( false );
1537 settings->EnableSpatialNavigation( false );
1538 settings->EnableWebSecurity( false );
1539 settings->EnableCacheBuilder( false );
1540 settings->EnableDoNotTrack( false );
1541 settings->UseScrollbarThumbFocusNotifications( false );
1542 settings->AllowFileAccessFromExternalUrl( false );
1543 settings->AllowScriptsOpenWindows( false );
1545 // Check default value is true or not
1546 bool value = settings->IsLinkMagnifierEnabled();
1547 DALI_TEST_CHECK( value );
1549 // Check Set/GetProperty
1550 settings->EnableLinkMagnifier( false );
1551 value = settings->IsLinkMagnifierEnabled();
1552 DALI_TEST_CHECK( !value );
1557 int UtcDaliWebSettingsCheckUseKeypadWithoutUserAction(void)
1559 ToolkitTestApplication application;
1561 WebView view = WebView::New();
1562 DALI_TEST_CHECK( view );
1564 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1565 DALI_TEST_CHECK( settings != 0 )
1568 settings->AllowMixedContents( false );
1569 settings->EnableSpatialNavigation( false );
1570 settings->EnableWebSecurity( false );
1571 settings->EnableCacheBuilder( false );
1572 settings->EnableDoNotTrack( false );
1573 settings->UseScrollbarThumbFocusNotifications( false );
1574 settings->AllowFileAccessFromExternalUrl( false );
1575 settings->AllowScriptsOpenWindows( false );
1577 // Check default value is true or not
1578 bool value = settings->IsKeypadWithoutUserActionUsed();
1579 DALI_TEST_CHECK( value );
1581 // Check Set/GetProperty
1582 settings->UseKeypadWithoutUserAction( false );
1583 value = settings->IsKeypadWithoutUserActionUsed();
1584 DALI_TEST_CHECK( !value );
1589 int UtcDaliWebSettingsCheckEnableAutofillPasswordForm(void)
1591 ToolkitTestApplication application;
1593 WebView view = WebView::New();
1594 DALI_TEST_CHECK( view );
1596 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1597 DALI_TEST_CHECK( settings != 0 )
1600 settings->AllowMixedContents( false );
1601 settings->EnableSpatialNavigation( false );
1602 settings->EnableWebSecurity( false );
1603 settings->EnableCacheBuilder( false );
1604 settings->EnableDoNotTrack( false );
1605 settings->UseScrollbarThumbFocusNotifications( false );
1606 settings->AllowFileAccessFromExternalUrl( false );
1607 settings->AllowScriptsOpenWindows( false );
1609 // Check default value is true or not
1610 bool value = settings->IsAutofillPasswordFormEnabled();
1611 DALI_TEST_CHECK( value );
1612 settings->EnableAutofillPasswordForm( false );
1613 value = settings->IsAutofillPasswordFormEnabled();
1614 DALI_TEST_CHECK( !value );
1618 int UtcDaliWebSettingsCheckEnableFormCandidateData(void)
1620 ToolkitTestApplication application;
1622 WebView view = WebView::New();
1623 DALI_TEST_CHECK( view );
1625 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1626 DALI_TEST_CHECK( settings != 0 );
1629 settings->AllowMixedContents( false );
1630 settings->EnableSpatialNavigation( false );
1631 settings->EnableWebSecurity( false );
1632 settings->EnableCacheBuilder( false );
1633 settings->EnableDoNotTrack( false );
1634 settings->UseScrollbarThumbFocusNotifications( false );
1635 settings->AllowFileAccessFromExternalUrl( false );
1636 settings->AllowScriptsOpenWindows( false );
1638 // Check default value is true or not
1639 bool value = settings->IsFormCandidateDataEnabled();
1640 DALI_TEST_CHECK( value );
1642 // Check Set/GetProperty
1643 settings->EnableFormCandidateData( false );
1644 value = settings->IsFormCandidateDataEnabled();
1645 DALI_TEST_CHECK( !value );
1650 int UtcDaliWebSettingsCheckEnableTextSelection(void)
1652 ToolkitTestApplication application;
1654 WebView view = WebView::New();
1655 DALI_TEST_CHECK( view );
1657 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1658 DALI_TEST_CHECK( settings != 0 );
1661 settings->AllowMixedContents( false );
1662 settings->EnableSpatialNavigation( false );
1663 settings->EnableWebSecurity( false );
1664 settings->EnableCacheBuilder( false );
1665 settings->EnableDoNotTrack( false );
1666 settings->UseScrollbarThumbFocusNotifications( false );
1667 settings->AllowFileAccessFromExternalUrl( false );
1668 settings->AllowScriptsOpenWindows( false );
1670 // Check default value is true or not
1671 bool value = settings->IsTextSelectionEnabled();
1672 DALI_TEST_CHECK( value );
1674 //Check Set/GetProperty
1675 settings->EnableTextSelection(false);
1676 value = settings->IsTextSelectionEnabled();
1677 DALI_TEST_CHECK( !value );
1682 int UtcDaliWebSettingsCheckEnableTextAutosizing(void)
1684 ToolkitTestApplication application;
1686 WebView view = WebView::New();
1687 DALI_TEST_CHECK( view );
1689 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1690 DALI_TEST_CHECK( settings != 0 );
1693 settings->AllowMixedContents( false );
1694 settings->EnableSpatialNavigation( false );
1695 settings->EnableWebSecurity( false );
1696 settings->EnableCacheBuilder( false );
1697 settings->EnableDoNotTrack( false );
1698 settings->UseScrollbarThumbFocusNotifications( false );
1699 settings->AllowFileAccessFromExternalUrl( false );
1700 settings->AllowScriptsOpenWindows( false );
1702 // Check default value is true or not
1703 bool value = settings->IsTextAutosizingEnabled();
1704 DALI_TEST_CHECK( value );
1706 // Check Set/GetProperty
1707 settings->EnableTextAutosizing(false);
1708 value = settings->IsTextAutosizingEnabled();
1709 DALI_TEST_CHECK( !value );
1714 int UtcDaliWebSettingsCheckEnableArrowScroll(void)
1716 ToolkitTestApplication application;
1718 WebView view = WebView::New();
1719 DALI_TEST_CHECK( view );
1721 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1722 DALI_TEST_CHECK( settings != 0 );
1725 settings->AllowMixedContents( false );
1726 settings->EnableSpatialNavigation( false );
1727 settings->EnableWebSecurity( false );
1728 settings->EnableCacheBuilder( false );
1729 settings->EnableDoNotTrack( false );
1730 settings->UseScrollbarThumbFocusNotifications( false );
1731 settings->AllowFileAccessFromExternalUrl( false );
1732 settings->AllowScriptsOpenWindows( false );
1734 // Check default value is true or not
1735 bool value = settings->IsArrowScrollEnabled();
1736 DALI_TEST_CHECK( value );
1738 // Check Set/GetProperty
1739 settings->EnableArrowScroll(false);
1740 value = settings->IsArrowScrollEnabled();
1741 DALI_TEST_CHECK( !value );
1746 int UtcDaliWebSettingsCheckEnableClipboard(void)
1748 ToolkitTestApplication application;
1750 WebView view = WebView::New();
1751 DALI_TEST_CHECK( view );
1753 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1754 DALI_TEST_CHECK( settings != 0 );
1757 settings->AllowMixedContents( false );
1758 settings->EnableSpatialNavigation( false );
1759 settings->EnableWebSecurity( false );
1760 settings->EnableCacheBuilder( false );
1761 settings->EnableDoNotTrack( false );
1762 settings->UseScrollbarThumbFocusNotifications( false );
1763 settings->AllowFileAccessFromExternalUrl( false );
1764 settings->AllowScriptsOpenWindows( false );
1766 // Check default value is true or not
1767 bool value = settings->IsClipboardEnabled();
1768 DALI_TEST_CHECK( value );
1769 settings->EnableClipboard(false);
1770 value = settings->IsClipboardEnabled();
1771 DALI_TEST_CHECK( !value );
1775 int UtcDaliWebSettingsCheckEnableImePanel(void)
1777 ToolkitTestApplication application;
1779 WebView view = WebView::New();
1780 DALI_TEST_CHECK( view );
1782 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1783 DALI_TEST_CHECK( settings != 0 );
1786 settings->AllowMixedContents( false );
1787 settings->EnableSpatialNavigation( false );
1788 settings->EnableWebSecurity( false );
1789 settings->EnableCacheBuilder( false );
1790 settings->EnableDoNotTrack( false );
1791 settings->UseScrollbarThumbFocusNotifications( false );
1792 settings->AllowFileAccessFromExternalUrl( false );
1793 settings->AllowScriptsOpenWindows( false );
1795 // Check default value is true or not
1796 bool value = settings->IsImePanelEnabled();
1797 DALI_TEST_CHECK( value );
1799 // Check Set/GetProperty
1800 settings->EnableImePanel(false);
1801 value = settings->IsImePanelEnabled();
1802 DALI_TEST_CHECK( !value );
1807 int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
1809 ToolkitTestApplication application;
1811 WebView view = WebView::New();
1812 DALI_TEST_CHECK( view );
1814 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1815 DALI_TEST_CHECK( settings != 0 )
1818 settings->AllowMixedContents( false );
1819 settings->EnableSpatialNavigation( false );
1820 settings->EnableWebSecurity( false );
1821 settings->EnableCacheBuilder( false );
1822 settings->EnableDoNotTrack( false );
1823 settings->UseScrollbarThumbFocusNotifications( false );
1824 settings->AllowFileAccessFromExternalUrl( false );
1825 settings->AllowScriptsOpenWindows( false );
1827 // Check default value is true or not
1828 bool value = settings->AreImagesLoadedAutomatically();
1829 DALI_TEST_CHECK( value );
1831 // Check Set/GetProperty
1832 settings->AllowImagesLoadAutomatically( false );
1833 value = settings->AreImagesLoadedAutomatically();
1834 DALI_TEST_CHECK( !value );
1839 int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
1841 ToolkitTestApplication application;
1843 WebView view = WebView::New();
1844 DALI_TEST_CHECK( view );
1846 Dali::Toolkit::WebSettings* settings = view.GetSettings();
1847 DALI_TEST_CHECK( settings != 0 )
1849 const std::string kDefaultValue;
1850 const std::string kTestValue = "UTF-8";
1853 settings->AllowMixedContents( false );
1854 settings->EnableSpatialNavigation( false );
1855 settings->EnableWebSecurity( false );
1856 settings->EnableCacheBuilder( false );
1857 settings->EnableDoNotTrack( false );
1858 settings->UseScrollbarThumbFocusNotifications( false );
1859 settings->AllowFileAccessFromExternalUrl( false );
1860 settings->AllowScriptsOpenWindows( false );
1862 // Check default value
1863 std::string value = settings->GetDefaultTextEncodingName();
1864 DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
1866 // Check Set/GetProperty
1867 settings->SetDefaultTextEncodingName( kTestValue );
1868 value = settings->GetDefaultTextEncodingName();
1869 DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );