#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-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++;
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 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;
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();
END_TEST;
}
+int UtcDaliWebViewMove(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ 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
+ 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::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 );
+
+ END_TEST;
+}
+
int UtcDaliWebViewGetWebBackForwardList(void)
{
ToolkitTestApplication application;
END_TEST;
}
+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)
{
ToolkitTestApplication application;
// 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 );
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;