Support scroll in web view.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-web-engine.cpp
index 372aec9..9d7a582 100755 (executable)
@@ -73,6 +73,9 @@ public:
     , mDefaultTextEncodingName()
     , mDefaultFontSize( 16 )
     , mEvaluating( false )
+    , mScrollPosition( 0, 0 )
+    , mScrollSize( 500, 500 )
+    , mContentSize( 500, 500 )
   {
     gInstanceCount++;
     gInstance = this;
@@ -205,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;
@@ -220,6 +256,11 @@ public:
     return mPageLoadErrorSignal;
   }
 
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal()
+  {
+    return mScrollEdgeReachedSignal;
+  }
+
   std::string                                                mUrl;
   std::vector< std::string >                                 mHistory;
   size_t                                                     mCurrentPlusOnePos;
@@ -235,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 )
@@ -522,6 +568,31 @@ 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 )
 {
 }
@@ -555,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;