{
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
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:
#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>
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 );
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;
}
+++ /dev/null
-/*
- * 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
+++ /dev/null
-#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
#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)
{
}
{
}
-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
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
*
*/
+// 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
/**
* @brief Creates a WebBackForwardList.
*/
- WebBackForwardList(const Dali::WebEngineBackForwardList& list);
+ WebBackForwardList(Dali::WebEngineBackForwardList& list);
/**
* @brief Destructor.
* @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
*/
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;
};
/**
${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
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