/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/public-api/images/pixel-data.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
-
using namespace Dali;
using namespace Toolkit;
const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
static int gPageLoadStartedCallbackCalled = 0;
+static int gPageLoadInProgressCallbackCalled = 0;
static int gPageLoadFinishedCallbackCalled = 0;
+static int gScrollEdgeReachedCallbackCalled = 0;
+static int gUrlChangedCallbackCalled = 0;
static int gEvaluateJavaScriptCallbackCalled = 0;
+static int gJavaScriptAlertCallbackCalled = 0;
+static int gJavaScriptConfirmCallbackCalled = 0;
+static int gJavaScriptPromptCallbackCalled = 0;
static bool gTouched = false;
struct CallbackFunctor
gPageLoadStartedCallbackCalled++;
}
+static void OnPageLoadInProgress( WebView view, const std::string& url )
+{
+ gPageLoadInProgressCallbackCalled++;
+}
+
static void OnPageLoadFinished( WebView view, const std::string& url )
{
gPageLoadFinishedCallbackCalled++;
}
+static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
+{
+ gScrollEdgeReachedCallbackCalled++;
+}
+
+static void OnUrlChanged( WebView view, const std::string& url )
+{
+ gUrlChangedCallbackCalled++;
+}
+
static void OnPageLoadError( WebView view, const std::string& url, WebView::LoadErrorCode errorCode )
{
}
gEvaluateJavaScriptCallbackCalled++;
}
-static bool OnTouched( Actor actor, const Dali::TouchData& touch )
+static bool OnJavaScriptAlert( const std::string& result )
+{
+ gJavaScriptAlertCallbackCalled++;
+ return true;
+}
+
+static bool OnJavaScriptConfirm( const std::string& result )
+{
+ gJavaScriptConfirmCallbackCalled++;
+ return true;
+}
+
+static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string& message2 )
+{
+ gJavaScriptPromptCallbackCalled++;
+ return true;
+}
+
+static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
{
gTouched = true;
return true;
view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
- Stage::GetCurrent().Add( view );
+ application.GetScene().Add( view );
application.SendNotification();
application.Render();
DALI_TEST_CHECK( view );
ConnectionTracker* testTracker = new ConnectionTracker();
view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
+ view.PageLoadInProgressSignal().Connect( &OnPageLoadInProgress );
view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
view.PageLoadErrorSignal().Connect( &OnPageLoadError );
+ view.UrlChangedSignal().Connect( &OnUrlChanged );
bool signal1 = false;
bool signal2 = false;
bool signal3 = false;
+ bool signal4 = false;
+ bool signal5 = false;
view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
- view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal2) );
- view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal3) );
+ view.ConnectSignal( testTracker, "pageLoadInProgress", CallbackFunctor(&signal2) );
+ view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal3) );
+ view.ConnectSignal( testTracker, "urlChanged", CallbackFunctor(&signal4) );
+ view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal5) );
DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 0, TEST_LOCATION );
DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
-
+ DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 0, TEST_LOCATION );
view.LoadUrl( TEST_URL1 );
view.GetNaturalSize();
Test::EmitGlobalTimerSignal();
DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 1, TEST_LOCATION );
DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
- DALI_TEST_CHECK( signal1 & signal2 );
- DALI_TEST_CHECK( !signal3 );
+ DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_CHECK( signal1 & signal2 & signal3 & signal4 );
+ DALI_TEST_CHECK( !signal5 );
view.LoadUrl( TEST_URL2 );
view.Suspend();
DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadInProgressCallbackCalled, 2, TEST_LOCATION );
DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( gUrlChangedCallbackCalled, 2, TEST_LOCATION );
view.GoBack();
Test::EmitGlobalTimerSignal();
view.Reload();
view.StopLoading();
view.ClearHistory();
- view.ClearCache();
- view.ClearCookies();
Test::EmitGlobalTimerSignal();
DALI_TEST_CHECK( !view.CanGoBack() );
DALI_TEST_CHECK( !view.CanGoForward() );
view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
- Stage::GetCurrent().Add( view );
+ application.GetScene().Add( view );
application.SendNotification();
application.Render();
view.GetNaturalSize();
- view.TouchSignal().Connect( &OnTouched );
+ view.TouchedSignal().Connect( &OnTouched );
// Touch event
Dali::Integration::TouchEvent event;
// Key event
Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
- application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( Integration::KeyEvent( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
application.SendNotification();
DALI_TEST_CHECK( gTouched );
END_TEST;
}
-int UtcDaliWebViewProperty1(void)
+int UtcDaliWebViewFocusGainedAndLost(void)
{
- // URL
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- std::string local;
- view.SetProperty( WebView::Property::URL, TEST_URL1 );
- Property::Value val = view.GetProperty( WebView::Property::URL );
- DALI_TEST_CHECK( val.Get( local ) );
- DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
+ view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+ view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+ application.GetScene().Add( view );
+ application.SendNotification();
+ application.Render();
+
+ view.SetKeyInputFocus();
+ DALI_TEST_CHECK( view.HasKeyInputFocus() );
+
+ // reset
+ view.ClearKeyInputFocus();
+ DALI_TEST_CHECK( !view.HasKeyInputFocus() );
END_TEST;
}
-int UtcDaliWebViewProperty2(void)
+int UtcDaliWebViewMove(void)
{
- // CACHE_MODEL
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const std::string kDefaultValue = "DOCUMENT_VIEWER";
- const WebView::CacheModel::Type kTestEnum = WebView::CacheModel::PRIMARY_WEB_BROWSER;
- const std::string kTestValue = "PRIMARY_WEB_BROWSER";
+ view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+ view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+ application.GetScene().Add( view );
+ application.SendNotification();
+ application.Render();
+
+ view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
+ Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
+ DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewPropertyVideoHole(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ const bool kDefaultValue = true;
+ const bool kTestValue = false;
// Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::CACHE_MODEL );
+ bool output;
+ Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
DALI_TEST_CHECK( value.Get( output ) );
DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::CACHE_MODEL, kTestEnum );
- value = view.GetProperty( WebView::Property::CACHE_MODEL );
+ view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
+ value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
DALI_TEST_CHECK( value.Get( output ) );
DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
- view.SetProperty( WebView::Property::CACHE_MODEL, kTestValue );
- value = view.GetProperty( WebView::Property::CACHE_MODEL );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliWebViewGetWebBackForwardList(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+ DALI_TEST_CHECK( bfList != 0 );
END_TEST;
}
-int UtcDaliWebViewProperty3(void)
+int UtcDaliWebViewGetWebContext(void)
{
- // COOKIE_ACCEPT_POLICY
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const std::string kDefaultValue = "NO_THIRD_PARTY";
- const WebView::CookieAcceptPolicy::Type kTestEnum = WebView::CookieAcceptPolicy::NEVER;
- const std::string kTestValue = "NEVER";
+ Dali::Toolkit::WebContext* context = view.GetContext();
+ DALI_TEST_CHECK( context != 0 );
- // Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ END_TEST;
+}
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestEnum );
- value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+int UtcDaliWebViewGetWebCookieManager(void)
+{
+ ToolkitTestApplication application;
- view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestValue );
- value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+ DALI_TEST_CHECK( cookieManager != 0 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewGetWebSettings(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewProperty1(void)
+{
+ // URL
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ std::string local;
+ view.SetProperty( WebView::Property::URL, TEST_URL1 );
+ Property::Value val = view.GetProperty( WebView::Property::URL );
+ DALI_TEST_CHECK( val.Get( local ) );
+ DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
-int UtcDaliWebViewProperty5(void)
+int UtcDaliWebViewProperty9(void)
{
- // ENABLE_JAVASCRIPT
+ // SCROLL_POSITION
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const bool kDefaultValue = true;
- const bool kTestValue = false;
-
// Check default value
- bool output;
- Property::Value value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ Dali::Vector2 output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::ENABLE_JAVASCRIPT, kTestValue );
- value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+ view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // Check default value of scroll size
+ output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
+ DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+ // Check default value of content size
+ output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
+ DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
END_TEST;
}
-int UtcDaliWebViewProperty6(void)
+int UtcDaliWebViewPropertyTitleFavicon(void)
+{
+ // SCROLL_POSITION
+ ToolkitTestApplication application;
+
+ char argv[] = "--test";
+ WebView view = WebView::New( 1, (char**)&argv );
+ DALI_TEST_CHECK( view );
+
+ // reset something
+ view.ClearAllTilesResources();
+
+ // Check default value of title
+ std::string testValue("title");
+ std::string output;
+ view.GetProperty( WebView::Property::TITLE ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // Check default value of favicon
+ Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
+ DALI_TEST_CHECK( favicon );
+ Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
+ DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewScrollBy(void)
{
- // LOAD_IMAGES_AUTOMATICALLY
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const bool kDefaultValue = true;
- const bool kTestValue = false;
+ // load url.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
+ bool signal1 = false;
+ view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
+ DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
+
+ view.LoadUrl( TEST_URL1 );
+ Test::EmitGlobalTimerSignal();
+
+ // set scroll position.
+ Dali::Vector2 output = Dali::Vector2::ONE;
+ Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+ view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // scroll by and trigger scrollEdgeReached event.
+ view.ScrollBy( 50, 50 );
+ Test::EmitGlobalTimerSignal();
+
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
+ DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_CHECK( signal1 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewEvaluteJavaScript(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+ view.LoadHtmlString( "<body>Hello World!</body>" );
+ view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
+ view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
+ Test::EmitGlobalTimerSignal();
+
+ DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+ view.RegisterJavaScriptAlertCallback( &OnJavaScriptAlert );
+ view.LoadHtmlString( "<head><script type='text/javascript'>alert('this is an alert popup.');</script></head><body>Hello World!</body>" );
+ view.JavaScriptAlertReply();
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS( gJavaScriptAlertCallbackCalled, 1, TEST_LOCATION );
+
+ view.RegisterJavaScriptConfirmCallback( &OnJavaScriptConfirm );
+ view.LoadHtmlString( "<head><script type='text/javascript'>confirm('this is a confirm popup.');</script></head><body>Hello World!</body>" );
+ view.JavaScriptConfirmReply( true );
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS( gJavaScriptConfirmCallbackCalled, 1, TEST_LOCATION );
+
+ view.RegisterJavaScriptPromptCallback( &OnJavaScriptPrompt );
+ view.LoadHtmlString( "<head><script type='text/javascript'>prompt('this is a prompt popup.');</script></head><body>Hello World!</body>" );
+ view.JavaScriptPromptReply( "it is a prompt." );
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS( gJavaScriptPromptCallbackCalled, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewMethodsForCoverage(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+ view.LoadHtmlString( "<body>Hello World!</body>" );
+ view.AddJavaScriptMessageHandler( "jsObject",
+ []( const std::string& arg ) {
+ }
+ );
+
+ DALI_TEST_CHECK( view );
+
+ END_TEST;
+}
+
+// test cases for web backforward list.
+
+int UtcDaliWebBackForwardListCheckItem(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+ DALI_TEST_CHECK( bfList != 0 )
+
+ unsigned int itemCount = bfList->GetItemCount();
+ DALI_TEST_CHECK( itemCount == 1 )
+
+ Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
+ DALI_TEST_CHECK( citem != 0 );
+
+ const std::string kDefaultUrl( "http://url" );
+ std::string testValue = citem->GetUrl();
+ DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
+
+ const std::string kDefaultTitle( "title" );
+ testValue = citem->GetTitle();
+ DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
+
+ const std::string kDefaultOriginalUrl( "http://originalurl" );
+ testValue = citem->GetOriginalUrl();
+ DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
+
+ Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
+ DALI_TEST_CHECK( item != 0 );
+
+ END_TEST;
+}
+
+// test cases for web context.
+
+int UtcDaliWebContextGetSetCacheModel(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebContext* context = view.GetContext();
+ DALI_TEST_CHECK( context != 0 )
+
+ std::string kDefaultValue;
+
+ // Reset something
+ context->SetProxyUri( kDefaultValue );
+ context->SetCertificateFilePath( kDefaultValue );
+ context->DisableCache( false );
+ context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
+ context->DeleteWebDatabase();
+ context->DeleteWebStorage();
+ context->DeleteLocalFileSystem();
+ context->ClearCache();
// Check default value
- bool output;
- Property::Value value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
+ DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY, kTestValue );
- value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
+ value = context->GetCacheModel();
+ DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
END_TEST;
}
-int UtcDaliWebViewProperty7(void)
+// test cases for web cookie manager.
+
+int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
{
- // DEFAULT_TEXT_ENCODING_NAME
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
+ Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+ DALI_TEST_CHECK( cookieManager != 0 )
+
const std::string kDefaultValue;
- const std::string kTestValue = "UTF-8";
+
+ // Reset something
+ cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
+ cookieManager->ClearCookies();
// Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
+ DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME, kTestValue );
- value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
+ value = cookieManager->GetCookieAcceptPolicy();
+ DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
END_TEST;
}
-int UtcDaliWebViewProperty8(void)
+// test cases for web settings.
+
+int UtcDaliWebSettingsGetSetDefaultFontSize(void)
{
- // DEFAULT_FONT_SIZE
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const int kDefaultValue = 16;
- const int kTestValue = 26;
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
// Check default value
- int output;
- Property::Value value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ int value = settings->GetDefaultFontSize();
+ DALI_TEST_CHECK( value == 16 );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::DEFAULT_FONT_SIZE, kTestValue );
- value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ settings->SetDefaultFontSize( 20 );
+ value = settings->GetDefaultFontSize();
+ DALI_TEST_CHECK( value == 20 );
END_TEST;
}
-int UtcDaliWebViewEvaluteJavaScript(void)
+int UtcDaliWebSettingsCheckEnableJavaScript(void)
{
ToolkitTestApplication application;
- WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
- view.LoadHTMLString( "<body>Hello World!</body>" );
- view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
- view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
- Test::EmitGlobalTimerSignal();
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
- DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value is true or not
+ bool value = settings->IsJavaScriptEnabled();
+ DALI_TEST_CHECK( value );
+
+ // Check Set/GetProperty
+ settings->EnableJavaScript( false );
+ value = settings->IsJavaScriptEnabled();
+ DALI_TEST_CHECK( !value );
END_TEST;
}
-
-int UtcDaliWebViewMethodsForCoverage(void)
+int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
{
ToolkitTestApplication application;
- WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
- view.LoadHTMLString( "<body>Hello World!</body>" );
- view.AddJavaScriptMessageHandler( "jsObject",
- []( const std::string& arg ) {
- }
- );
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value is true or not
+ bool value = settings->AreImagesLoadedAutomatically();
+ DALI_TEST_CHECK( value );
+
+ // Check Set/GetProperty
+ settings->AllowImagesLoadAutomatically( false );
+ value = settings->AreImagesLoadedAutomatically();
+ DALI_TEST_CHECK( !value );
+ END_TEST;
+}
+
+int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
DALI_TEST_CHECK( view );
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ const std::string kDefaultValue;
+ const std::string kTestValue = "UTF-8";
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value
+ std::string value = settings->GetDefaultTextEncodingName();
+ DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
+
+ // Check Set/GetProperty
+ settings->SetDefaultTextEncodingName( kTestValue );
+ value = settings->GetDefaultTextEncodingName();
+ DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
+
END_TEST;
}
+