Add APIs of webview back forward list 52/254352/15
authorzhouleonlei <zhouleon.lei@samsung.com>
Mon, 1 Mar 2021 07:19:43 +0000 (15:19 +0800)
committerzhouleonlei <zhouleon.lei@samsung.com>
Tue, 6 Apr 2021 12:40:24 +0000 (20:40 +0800)
API added list:
ewk_back_forward_list_previous_item_get
ewk_back_forward_list_next_item_get

Change-Id: Ia1f686d50d5805eca0ec179633c14c47d537f633

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp [deleted file]
dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h [deleted file]
dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp [changed mode: 0644->0755]
dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h [changed mode: 0644->0755]
dali-toolkit/devel-api/file.list

index 14f2c1f..132075a 100755 (executable)
@@ -203,19 +203,31 @@ class MockWebEngineBackForwardList : public Dali::WebEngineBackForwardList
 {
 public:
   MockWebEngineBackForwardList()
-    : mockItem(),
-      pMockItem( &mockItem )
   {
   }
 
-  Dali::WebEngineBackForwardListItem& GetCurrentItem() const override
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetCurrentItem() const override
   {
-    return *pMockItem;
+    std::unique_ptr<Dali::WebEngineBackForwardListItem> ret(new MockWebEngineBackForwardListItem());
+    return ret;
   }
 
-  Dali::WebEngineBackForwardListItem& GetItemAtIndex( uint32_t index ) const override
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetPreviousItem() const override
   {
-    return *pMockItem;
+    std::unique_ptr<Dali::WebEngineBackForwardListItem> ret(new MockWebEngineBackForwardListItem());
+    return ret;
+  }
+
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetNextItem() const override
+  {
+    std::unique_ptr<Dali::WebEngineBackForwardListItem> ret(new MockWebEngineBackForwardListItem());
+    return ret;
+  }
+
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetItemAtIndex( uint32_t index ) const override
+  {
+    std::unique_ptr<Dali::WebEngineBackForwardListItem> ret(new MockWebEngineBackForwardListItem());
+    return ret;
   }
 
   uint32_t GetItemCount() const override
@@ -223,11 +235,24 @@ public:
     return 1;
   }
 
-private:
-  MockWebEngineBackForwardListItem mockItem;
-  WebEngineBackForwardListItem*    pMockItem;
+  std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> GetBackwardItems(int limit) override
+  {
+    std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> ret;
+    std::unique_ptr<Dali::WebEngineBackForwardListItem> item(new MockWebEngineBackForwardListItem());
+    ret.push_back(std::move(item));
+    return ret;
+  }
+
+  std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> GetForwardItems(int limit) override
+  {
+    std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> ret;
+    std::unique_ptr<Dali::WebEngineBackForwardListItem> item(new MockWebEngineBackForwardListItem());
+    ret.push_back(std::move(item));
+    return ret;
+  }
 };
 
+
 class MockWebEngineCertificate : public Dali::WebEngineCertificate
 {
 public:
index 034e377..a311131 100755 (executable)
@@ -37,7 +37,6 @@
 #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-form-repost-decision.h>
@@ -162,7 +161,7 @@ static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string&
 
 static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
 {
-  gScreenshotCapturedCallbackCalled++;\r
+  gScreenshotCapturedCallbackCalled++;
 }
 
 static void OnVideoPlaying(bool isPlaying)
@@ -1358,9 +1357,15 @@ int UtcDaliWebBackForwardListCheckItem(void)
   unsigned int itemCount = bfList->GetItemCount();
   DALI_TEST_CHECK( itemCount == 1 )
 
-  Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> citem = bfList->GetCurrentItem();
   DALI_TEST_CHECK( citem != 0 );
 
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> citemP = bfList->GetPreviousItem();
+  DALI_TEST_CHECK( citemP != 0 );
+
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> citemN = bfList->GetNextItem();
+  DALI_TEST_CHECK( citemN != 0 );
+
   const std::string kDefaultUrl( "http://url" );
   std::string testValue = citem->GetUrl();
   DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
@@ -1373,9 +1378,15 @@ int UtcDaliWebBackForwardListCheckItem(void)
   testValue = citem->GetOriginalUrl();
   DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
 
-  Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> item = bfList->GetItemAtIndex( 0 );
   DALI_TEST_CHECK( item != 0 );
 
+  std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecBack = bfList->GetBackwardItems(-1);
+  DALI_TEST_CHECK( vecBack.size() == 1 );
+
+  std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> vecForward = bfList->GetForwardItems(-1);
+  DALI_TEST_CHECK( vecForward.size() == 1 );
+
   END_TEST;
 }
 
diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp
deleted file mode 100644 (file)
index f50a912..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2021 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-const std::string EMPTY_STRING;
-
-WebBackForwardListItem::WebBackForwardListItem(const Dali::WebEngineBackForwardListItem* item)
-: mWebEngineBackForwardListItem(item)
-{
-}
-
-WebBackForwardListItem::~WebBackForwardListItem()
-{
-}
-
-std::string WebBackForwardListItem::GetUrl() const
-{
-  return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetUrl() : EMPTY_STRING;
-}
-
-std::string WebBackForwardListItem::GetTitle() const
-{
-  return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetTitle() : EMPTY_STRING;
-}
-
-std::string WebBackForwardListItem::GetOriginalUrl() const
-{
-  return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetOriginalUrl() : EMPTY_STRING;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h
deleted file mode 100644 (file)
index 2ae0e35..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
-#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
-
-/*
- * Copyright (c) 2021 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/dali-toolkit-common.h>
-
-namespace Dali
-{
-class WebEngineBackForwardListItem;
-
-namespace Toolkit
-{
-/**
- * @addtogroup dali_toolkit_controls_web_view
- * @{
- */
-
-/**
- * @brief WebBackForwardListItem is a class for back-forward list item of WebView.
- *
- *
- * For working WebBackForwardListItem, a Dali::WebBackForwardListItem should be provided.
- *
- */
-class DALI_TOOLKIT_API WebBackForwardListItem
-{
-public:
-  /**
-   * @brief Creates a WebBackForwardListItem.
-   */
-  WebBackForwardListItem(const Dali::WebEngineBackForwardListItem* item);
-
-  /**
-   * @brief Destructor.
-   */
-  virtual ~WebBackForwardListItem() final;
-
-  /**
-   * @brief Returns the URL of the item.
-   *
-   * @details The returned URL may differ from the original URL (For example,
-   *          if the page is redirected).
-   *
-   * @return The URL of the @a item, otherwise "" in case of an error
-   */
-  std::string GetUrl() const;
-
-  /**
-   * @brief Returns the title of the item.
-   *
-   * @return The title of the @a item, otherwise "" in case of an error
-   */
-  std::string GetTitle() const;
-
-  /**
-   * @brief Returns the original URL of the item.
-   *
-   * @return The original URL of the @a item, otherwise "" in case of an error
-   */
-  std::string GetOriginalUrl() const;
-
-private:
-  const Dali::WebEngineBackForwardListItem* mWebEngineBackForwardListItem;
-};
-
-/**
- * @}
- */
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
old mode 100644 (file)
new mode 100755 (executable)
index 75014f0..8b3d8e1
 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
 
 namespace Dali
 {
 namespace Toolkit
 {
-WebBackForwardList::WebBackForwardList(const Dali::WebEngineBackForwardList& list)
-: mWebEngineBackForwardList(list),
-  mWebBackForwardListItem(0)
+WebBackForwardList::WebBackForwardList(Dali::WebEngineBackForwardList& list)
+: mWebEngineBackForwardList(list)
 {
 }
 
@@ -36,16 +34,24 @@ WebBackForwardList::~WebBackForwardList()
 {
 }
 
-WebBackForwardListItem* WebBackForwardList::GetCurrentItem()
+std::unique_ptr<Dali::WebEngineBackForwardListItem> WebBackForwardList::GetCurrentItem()
 {
-  mWebBackForwardListItem = WebBackForwardListItem(&mWebEngineBackForwardList.GetCurrentItem());
-  return &mWebBackForwardListItem;
+  return mWebEngineBackForwardList.GetCurrentItem();
 }
 
-WebBackForwardListItem* WebBackForwardList::GetItemAtIndex(uint32_t index)
+std::unique_ptr<Dali::WebEngineBackForwardListItem> WebBackForwardList::GetPreviousItem()
 {
-  mWebBackForwardListItem = WebBackForwardListItem(&mWebEngineBackForwardList.GetItemAtIndex(index));
-  return &mWebBackForwardListItem;
+  return mWebEngineBackForwardList.GetPreviousItem();
+}
+
+std::unique_ptr<Dali::WebEngineBackForwardListItem> WebBackForwardList::GetNextItem()
+{
+  return mWebEngineBackForwardList.GetNextItem();
+}
+
+std::unique_ptr<Dali::WebEngineBackForwardListItem> WebBackForwardList::GetItemAtIndex(uint32_t index)
+{
+  return mWebEngineBackForwardList.GetItemAtIndex(index);
 }
 
 uint32_t WebBackForwardList::GetItemCount() const
@@ -53,6 +59,16 @@ uint32_t WebBackForwardList::GetItemCount() const
   return mWebEngineBackForwardList.GetItemCount();
 }
 
+std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> WebBackForwardList::GetBackwardItems(int limit)
+{
+  return mWebEngineBackForwardList.GetBackwardItems(limit);
+}
+
+std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> WebBackForwardList::GetForwardItems(int limit)
+{
+  return mWebEngineBackForwardList.GetForwardItems(limit);
+}
+
 } // namespace Toolkit
 
 } // namespace Dali
old mode 100644 (file)
new mode 100755 (executable)
index 9dc81fc..0b015bc
  *
  */
 
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+#include <vector>
+#include <memory>
+
 // INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
 #include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
@@ -48,7 +52,7 @@ public:
   /**
    * @brief Creates a WebBackForwardList.
    */
-  WebBackForwardList(const Dali::WebEngineBackForwardList& list);
+  WebBackForwardList(Dali::WebEngineBackForwardList& list);
 
   /**
    * @brief Destructor.
@@ -59,14 +63,26 @@ public:
    * @brief Returns the current item in the @a list.
    * @return The current item in list.
    */
-  WebBackForwardListItem* GetCurrentItem();
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetCurrentItem();
+
+  /**
+   * @brief Returns the previous item in the @a list.
+   * @return The previous item in list.
+   */
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetPreviousItem();
+
+  /**
+   * @brief Returns the next item in the @a list.
+   * @return The next item in list.
+   */
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetNextItem();
 
   /**
    * @brief Returns the item at a given @a index relative to the current item.
    * @param[in] index The index of the item
    * @return The current item in list.
    */
-  WebBackForwardListItem* GetItemAtIndex(uint32_t index);
+  std::unique_ptr<Dali::WebEngineBackForwardListItem> GetItemAtIndex(uint32_t index);
 
   /**
    * @brief Returns the length of the back-forward list including the current
@@ -76,9 +92,38 @@ public:
    */
   uint32_t GetItemCount() const;
 
+  /**
+   * @brief Creates a list containing the items preceding the current item limited
+   *        by @a limit.
+   *
+   * @details The WebEngineBackForwardListItem elements are located in the result
+              list starting with the oldest one.\n
+   *          If @a limit is equal to @c -1 all the items preceding the current
+   *          item are returned.
+   *
+   * @param[in] limit The number of items to retrieve
+   *
+   * @return @c vector containing @c WebEngineBackForwardListItem elements,\n
+   */
+  std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> GetBackwardItems(int limit);
+
+  /**
+   * @brief Creates the list containing the items following the current item
+   *        limited by @a limit.
+   *
+   * @details The @c WebEngineBackForwardListItem elements are located in the result
+   *          list starting with the oldest one.\n
+   *          If @a limit is equal to @c -1 all the items preceding the current
+   *          item are returned.
+   *
+   * @param[in] limit The number of items to retrieve
+   *
+   * @return @c vector containing @c WebEngineBackForwardListItem elements,\n
+   */
+  std::vector<std::unique_ptr<Dali::WebEngineBackForwardListItem>> GetForwardItems(int limit);
+
 private:
-  const Dali::WebEngineBackForwardList& mWebEngineBackForwardList;
-  Dali::Toolkit::WebBackForwardListItem mWebBackForwardListItem;
+  Dali::WebEngineBackForwardList& mWebEngineBackForwardList;
 };
 
 /**
index cc7dd45..334be34 100755 (executable)
@@ -39,7 +39,6 @@ SET( devel_api_src_files
   ${devel_api_src_dir}/controls/tool-bar/tool-bar.cpp
   ${devel_api_src_dir}/controls/video-view/video-view-devel.cpp
   ${devel_api_src_dir}/controls/web-view/web-back-forward-list.cpp
-  ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.cpp
   ${devel_api_src_dir}/controls/web-view/web-context.cpp
   ${devel_api_src_dir}/controls/web-view/web-cookie-manager.cpp
   ${devel_api_src_dir}/controls/web-view/web-form-repost-decision.cpp
@@ -256,7 +255,6 @@ SET( devel_api_video_view_header_files
 
 SET( devel_api_web_view_header_files
   ${devel_api_src_dir}/controls/web-view/web-back-forward-list.h
-  ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.h
   ${devel_api_src_dir}/controls/web-view/web-context.h
   ${devel_api_src_dir}/controls/web-view/web-cookie-manager.h
   ${devel_api_src_dir}/controls/web-view/web-form-repost-decision.h