All tests now output results to xml files
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-web-engine.cpp
index 5316331..9d7a582 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -21,7 +21,6 @@
 #include <dali/public-api/object/any.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
-#include <dali/public-api/images/native-image.h>
 #include <toolkit-application.h>
 
 namespace Dali
@@ -74,6 +73,9 @@ public:
     , mDefaultTextEncodingName()
     , mDefaultFontSize( 16 )
     , mEvaluating( false )
+    , mScrollPosition( 0, 0 )
+    , mScrollSize( 500, 500 )
+    , mContentSize( 500, 500 )
   {
     gInstanceCount++;
     gInstance = this;
@@ -206,6 +208,39 @@ public:
     mDefaultFontSize = defaultFontSize;
   }
 
+  void ScrollBy( int dx, int dy )
+  {
+    mScrollPosition += Dali::Vector2( dx, dy );
+    if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
+    {
+      gInstance->mScrollEdgeReachedSignal.Emit( Dali::WebEnginePlugin::ScrollEdge::BOTTOM );
+    }
+  }
+
+  void SetScrollPosition( int x, int y )
+  {
+    mScrollPosition.x = x;
+    mScrollPosition.y = y;
+  }
+
+  void GetScrollPosition( int& x, int& y ) const
+  {
+    x = mScrollPosition.x;
+    y = mScrollPosition.y;
+  }
+
+  void GetScrollSize( int& w, int& h ) const
+  {
+    w = mScrollSize.width;
+    h = mScrollSize.height;
+  }
+
+  void GetContentSize( int& w, int& h ) const
+  {
+    w = mContentSize.width;
+    h = mContentSize.height;
+  }
+
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
   {
     return mPageLoadStartedSignal;
@@ -221,6 +256,11 @@ public:
     return mPageLoadErrorSignal;
   }
 
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal()
+  {
+    return mScrollEdgeReachedSignal;
+  }
+
   std::string                                                mUrl;
   std::vector< std::string >                                 mHistory;
   size_t                                                     mCurrentPlusOnePos;
@@ -236,6 +276,11 @@ public:
   Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType    mPageLoadErrorSignal;
   std::vector< std::function< void( const std::string& ) > > mResultCallbacks;
   bool                                                       mEvaluating;
+
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+  Dali::Vector2                                               mScrollPosition;
+  Dali::Vector2                                               mScrollSize;
+  Dali::Vector2                                               mContentSize;
 };
 
 inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
@@ -523,11 +568,36 @@ void WebEngine::SetDefaultFontSize( int defaultFontSize )
   Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize );
 }
 
+void WebEngine::ScrollBy( int dx, int dy )
+{
+  Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
+}
+
+void WebEngine::SetScrollPosition( int x, int y )
+{
+  Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollPosition( int& x, int& y ) const
+{
+  Internal::Adaptor::GetImplementation( *this ).GetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollSize( int& w, int& h ) const
+{
+  Internal::Adaptor::GetImplementation( *this ).GetScrollSize( w, h );
+}
+
+void WebEngine::GetContentSize( int& w, int& h ) const
+{
+  Internal::Adaptor::GetImplementation( *this ).GetContentSize( w, h );
+}
+
 void WebEngine::SetSize( int width, int height )
 {
 }
 
-bool WebEngine::SendTouchEvent( const TouchData& touch )
+bool WebEngine::SendTouchEvent( const TouchEvent& touch )
 {
   return true;
 }
@@ -537,6 +607,10 @@ bool WebEngine::SendKeyEvent( const KeyEvent& event )
   return true;
 }
 
+void WebEngine::SetFocus( bool focused )
+{
+}
+
 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
 {
   return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
@@ -552,5 +626,10 @@ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErro
   return Internal::Adaptor::GetImplementation( *this ).PageLoadErrorSignal();
 }
 
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
+{
+  return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeReachedSignal();
+}
+
 } // namespace Dali;