From d08848a0c418c5d11b10ee1e9ab448527450e00e Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Wed, 21 Oct 2015 11:36:09 +0200 Subject: [PATCH 01/16] Fix compiler warning in SessionStorage [Issue] N/A [Problem] Compilation warning about initialization list ordering [Solution] Fix ordering [Verification] Build the project and verify that there are no warnings from SessionStorage Change-Id: I0d0f080ecdbbc9c2a492596358f87ce715d289ae --- services/SessionStorage/Session.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/SessionStorage/Session.cpp b/services/SessionStorage/Session.cpp index 9d999e1..10c527a 100644 --- a/services/SessionStorage/Session.cpp +++ b/services/SessionStorage/Session.cpp @@ -49,11 +49,11 @@ Session::~Session() } Session::Session(Session&& source) - :m_sessionId(std::move(source.m_sessionId)) - , m_lastModificationTime(std::move(source.m_lastModificationTime)) - , m_sessinName(std::move(source.m_sessinName)) - , m_isValid(std::move(source.m_isValid)) - , m_items(std::move(source.m_items)) + :m_sessionId(std::move(source.m_sessionId)) + ,m_lastModificationTime(std::move(source.m_lastModificationTime)) + ,m_sessinName(std::move(source.m_sessinName)) + ,m_items(std::move(source.m_items)) + ,m_isValid(std::move(source.m_isValid)) { } -- 2.7.4 From 8a083e3b943f0dd0b60effe060666aecbc9af911 Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Wed, 21 Oct 2015 09:48:41 +0200 Subject: [PATCH 02/16] Fix for compilation warnings in HistoryService [Issue] N/A [Problem] Compilation warnings: Wreorder and Wsign-compare [Solution] Fix initialization list ordering, fix method signature and cast values where appropriate [Verification] Build the project and verify that there are no warnings from HistoryService files Change-Id: I6ca4a185dc616e9c9290ba6e6a5f041467df960b --- services/HistoryService/HistoryItem.cpp | 2 +- services/HistoryService/HistoryService.cpp | 7 ++++--- services/HistoryService/HistoryService.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/services/HistoryService/HistoryItem.cpp b/services/HistoryService/HistoryItem.cpp index 6808685..cf299bf 100644 --- a/services/HistoryService/HistoryItem.cpp +++ b/services/HistoryService/HistoryItem.cpp @@ -31,8 +31,8 @@ HistoryItem::HistoryItem(const std::string & url, std::shared_ptr image) : m_url(url) , m_title(title) - , m_favIcon(image) , m_lastVisit() + , m_favIcon(image) { } diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index 1287c1c..8bd4f7c 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -486,7 +486,7 @@ std::shared_ptr HistoryService::getHistoryItemsByURL( std::shared_ptr HistoryService::getHistoryItemsByKeywordsString( const std::string& keywordsString, const int maxItems, - const int minKeywordLength) + const unsigned int minKeywordLength) { if (keywordsString.empty()) return std::make_shared(); @@ -500,7 +500,8 @@ std::shared_ptr HistoryService::getHistoryItemsByKeywordsStri std::string longestKeyword = keywords.at(longestKeywordPos); boost::algorithm::to_lower(longestKeyword); - // assumption: search starts when longest keyword is at least 3 characters long + // assumption: search starts when longest keyword is at least + // minKeywordLength characters long if (longestKeyword.length() < minKeywordLength) { return std::make_shared(); } @@ -517,7 +518,7 @@ std::shared_ptr HistoryService::getHistoryItemsByKeywordsStri } if (maxItems != -1) { - if (historyItems->size() > maxItems) { + if (historyItems->size() > static_cast(maxItems)) { historyItems->erase(historyItems->begin() + maxItems, historyItems->end()); } diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index fe23f8e..a01ed91 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -79,7 +79,7 @@ public: */ std::shared_ptr getHistoryItemsByKeywordsString( const std::string& keywordsString, const int maxItems, - const int minKeywordLength); + const unsigned int minKeywordLength); int getHistoryItemsCount(); void setStorageServiceTestMode(bool testmode = true); -- 2.7.4 From 0249a440b17b1807d01835d4ba8744b899581b4c Mon Sep 17 00:00:00 2001 From: Janusz Majnert Date: Wed, 21 Oct 2015 10:35:54 +0200 Subject: [PATCH 03/16] Fix compiler warning in HistoryUI [Issue] N/A [Problem] Compilation warning about unused variables and no return statement [Solution] Remove unused variables, change method return type [Verification] Build the project and verify that there are no warnings from HistoryUI Also changed one reinterpret_cast into a static_cast. Change-Id: I83fe252409475ef0918978d1d30560f6ab4f85a7 --- services/HistoryUI/HistoryUI.cpp | 6 +++--- services/HistoryUI/HistoryUI.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/HistoryUI/HistoryUI.cpp b/services/HistoryUI/HistoryUI.cpp index 094f04c..619d4a1 100644 --- a/services/HistoryUI/HistoryUI.cpp +++ b/services/HistoryUI/HistoryUI.cpp @@ -104,7 +104,7 @@ Evas_Object* HistoryUI::getContent() return m_history_layout; } -Evas_Object* HistoryUI::createHistoryUILayout(Evas_Object* parent) +void HistoryUI::createHistoryUILayout(Evas_Object* parent) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); @@ -301,10 +301,10 @@ void HistoryUI::clearItems() _history_item_data.clear(); } -void HistoryUI::_history_item_clicked_cb(void *data, Evas_Object *obj, void *event_info) +void HistoryUI::_history_item_clicked_cb(void *data, Evas_Object*, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - HistoryItemData * itemData = reinterpret_cast(data); + HistoryItemData * itemData = static_cast(data); itemData->historyUI->historyItemClicked(itemData->item); } diff --git a/services/HistoryUI/HistoryUI.h b/services/HistoryUI/HistoryUI.h index 859eddc..94579ff 100644 --- a/services/HistoryUI/HistoryUI.h +++ b/services/HistoryUI/HistoryUI.h @@ -53,7 +53,7 @@ public: boost::signals2::signal)> historyDeleteClicked; private: void clearItems(); - Evas_Object* createHistoryUILayout(Evas_Object* parent); + void createHistoryUILayout(Evas_Object* parent); Elm_Gengrid_Item_Class* crateItemClass(); static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _history_grid_content_get(void *data, Evas_Object *obj, const char *part); -- 2.7.4 From c7422b90fec128e4d9dff8edc24c463604502941 Mon Sep 17 00:00:00 2001 From: sungwon2han Date: Thu, 22 Oct 2015 15:33:44 +0900 Subject: [PATCH 04/16] Remove tab ID checker Tab ID checker is called after URI is changed. If a tab with URI chanage is not the current tab, it changes the current tab to a tab with URI change. This may cause unwanted tab switching when some backgound tabs change its URI for some reason. Change-Id: I6e8583f0952dc961a5a4d148c9e79bb25d536ac1 Signed-off-by: sungwon2han --- core/AbstractWebEngine/AbstractWebEngine.h | 5 ----- services/SimpleUI/SimpleUI.cpp | 9 --------- services/SimpleUI/SimpleUI.h | 6 ------ services/WebKitEngineService/WebKitEngineService.cpp | 7 ------- services/WebKitEngineService/WebKitEngineService.h | 1 - services/WebKitEngineService/WebView.cpp | 1 - services/WebKitEngineService/WebView.h | 1 - 7 files changed, 30 deletions(-) diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 39c23c7..91da16c 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -340,11 +340,6 @@ public: boost::signals2::signal uriChanged; /** - * URI on current/other page changed - */ - boost::signals2::signal uriOnTabChanged; - - /** * Possibility of go forward changed * \param bool true if it is possible to go forward, false otherwise */ diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 68a4215..f3b6504 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -396,7 +396,6 @@ void SimpleUI::connectModelSignals() m_webEngine->uriChanged.connect(boost::bind(&SimpleUI::webEngineURLChanged, this, _1)); m_webEngine->uriChanged.connect(boost::bind(&URIEntry::changeUri, &m_webPageUI->getURIEntry(), _1)); m_webEngine->uriChanged.connect(boost::bind(&MoreMenuUI::setURL, m_moreMenuUI.get(), _1)); - m_webEngine->uriOnTabChanged.connect(boost::bind(&SimpleUI::checkTabId,this,_1)); m_webEngine->webViewClicked.connect(boost::bind(&URIEntry::clearFocus, &m_webPageUI->getURIEntry())); m_webEngine->backwardEnableChanged.connect(boost::bind(&WebPageUI::setBackButtonEnabled, m_webPageUI.get(), _1)); m_webEngine->forwardEnableChanged.connect(boost::bind(&WebPageUI::setForwardButtonEnabled, m_webPageUI.get(), _1)); @@ -502,14 +501,6 @@ void SimpleUI::switchViewToIncognitoPage() m_viewManager->popStackTo(m_webPageUI.get()); } -void SimpleUI::checkTabId(const tizen_browser::basic_webengine::TabId& id){ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(m_webEngine->currentTabId() != id || isErrorPageActive()){ - BROWSER_LOGD("URL changed on non-visible tab, updating browser view"); - switchToTab(id); - } -} - void SimpleUI::openNewTab(const std::string &uri, bool desktopMode) { BROWSER_LOGD("[%s:%d] uri =%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str()); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 91d03fe..4a2293b 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -162,12 +162,6 @@ private: void onURLEntryEdited(); /** - * Checks if correct tab is visible to user, and if not, it update browser view - * @param id of tab that should be visible to user - */ - void checkTabId(const tizen_browser::basic_webengine::TabId& id); - - /** * \brief check if url comming back from WebEngine should be passed to URI. * * For filtered addresses we need to hide real URI so the user would be confused. diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 0841342..53beb2e 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -223,12 +223,6 @@ void WebKitEngineService::_uriChanged(const std::string & uri) uriChanged(uri); } -void WebKitEngineService::_uriChangedOnTab(TabId id) -{ - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - uriOnTabChanged(id); -} - void WebKitEngineService::_loadFinished() { loadFinished(); @@ -325,7 +319,6 @@ TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerI if (!uri.empty()) { p->setURI(uri); } - p->tabIdChecker.connect(boost::bind(&WebKitEngineService::_uriChangedOnTab,this,_1)); switchToTab(newTabId); AbstractWebEngine::tabCreated(); diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index be37eac..a85bac2 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -186,7 +186,6 @@ private: void _favIconChanged(std::shared_ptr bi); void _titleChanged(const std::string &); void _uriChanged(const std::string &); - void _uriChangedOnTab(TabId); void _loadFinished(); void _loadStarted(); void _loadStop(); diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index d8a1603..9a2a091 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -642,7 +642,6 @@ void WebView::__urlChanged(void * data, Evas_Object * /* obj */, void * /* event WebView * self = reinterpret_cast(data); BROWSER_LOGD("URL changed for tab: %s", self->getTabId().toString().c_str()); self->uriChanged(self->getURI()); - self->tabIdChecker(self->m_tabId); } void WebView::__backForwardListChanged(void * data, Evas_Object * /* obj */, void * /* event_info */) diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index 2243c19..f6aa423 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -159,7 +159,6 @@ public: boost::signals2::signal)> favIconChanged; boost::signals2::signal titleChanged; boost::signals2::signal uriChanged; - boost::signals2::signal tabIdChecker; boost::signals2::signal loadFinished; boost::signals2::signal loadStarted; -- 2.7.4 From 07e522a97b776eefad2b1acd714e19e5dbdc13e6 Mon Sep 17 00:00:00 2001 From: Kamil Nowac Date: Wed, 21 Oct 2015 09:20:31 +0200 Subject: [PATCH 05/16] Incognito Mode Add Tab button should open a new tab [Issue] https://bugs.tizen.org/jira/browse/TT-221 [Problem] Incognito mode Add Tab button doesn't create new tab [Solution] IncognitoMode always opens a new tab. [Verification] 1) Open Tab Manager 2) Add Incognito Tab 3) Type url address and press Enter 2 -> New tab should be opened. 3 -> site should be opened in the current tab. 1) Open Tab Manager 2) Add Incognito Tab 3) Press BookmarkManager and click bookmark 3-> site should be opened in the current tab. Change-Id: I7e2d98bbba1a2d5bc09afe8b4a4f5d055c2724c2 --- services/SimpleUI/SimpleUI.cpp | 20 +++++++++++++++----- services/WebPageUI/WebPageUI.cpp | 13 +++++++++++++ services/WebPageUI/WebPageUI.h | 1 + 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index f3b6504..c86fd31 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -495,9 +495,8 @@ void SimpleUI::switchViewToIncognitoPage() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); M_ASSERT(m_viewManager); - m_webPageUI->toIncognito(m_incognito); + openNewTab(""); m_webPageUI->switchViewToIncognitoPage(); - m_webEngine->disconnectCurrentWebViewSignals(); m_viewManager->popStackTo(m_webPageUI.get()); } @@ -593,12 +592,20 @@ void SimpleUI::onBookmarkClicked(std::shared_ptrpopStackTo(m_webPageUI.get()); std::string bookmarkAddress = bookmarkItem->getAddress(); - openNewTab(bookmarkAddress); + m_viewManager->popStackTo(m_webPageUI.get()); + if (!m_incognito) { + openNewTab(bookmarkAddress); + } else { + std::string bookmarkTitle = bookmarkItem->getTittle(); + m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), bookmarkAddress, bookmarkTitle); + m_webEngine->setURI(bookmarkAddress); + m_webPageUI->setPageTitle(bookmarkTitle); + m_webPageUI->getURIEntry().clearFocus(); + closeBookmarkManagerUI(); + } } - void SimpleUI::onHistoryRemoved(const std::string& uri) { BROWSER_LOGD("[%s] deleted %s", __func__, uri.c_str()); @@ -692,6 +699,9 @@ void SimpleUI::filterURL(const std::string& url) openNewTab(url); else m_webEngine->setURI(url); + + if (m_incognito) + switchViewToWebPage(); } m_webPageUI->getURIEntry().clearFocus(); } diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index 8e22e44..f617925 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -172,7 +172,11 @@ void WebPageUI::switchViewToIncognitoPage() m_homePageActive = false; setMainContent(m_privateLayout); evas_object_show(m_leftButtonBar->getContent()); + setPrivateButtons(); refreshFocusChain(); + m_URIEntry->changeUri(""); + m_URIEntry->setPageTitle("Start Incognito Browsing"); + m_URIEntry->setFocus(); } void WebPageUI::switchViewToWebPage(Evas_Object* content, const std::string uri, const std::string title) @@ -376,6 +380,15 @@ void WebPageUI::setErrorButtons() evas_object_hide(m_progressBar); } +void WebPageUI::setPrivateButtons() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_stopLoading->setEnabled(false); + m_reload->setEnabled(false); + m_forward->setEnabled(false); + evas_object_hide(m_progressBar); +} + void WebPageUI::updateURIBar(const std::string& uri) { BROWSER_LOGD("[%s:%d] URI:%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str()); diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 34b3717..a3e04f4 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -81,6 +81,7 @@ private: void hideProgressBar(); void hideWebView(); void setErrorButtons(); + void setPrivateButtons(); void setMainContent(Evas_Object* content); void updateURIBar(const std::string& uri); std::string edjePath(const std::string& file); -- 2.7.4 From 2fd1461537df171f703d7717ecd198159f881204 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Thu, 22 Oct 2015 14:28:05 +0200 Subject: [PATCH 06/16] Exiting from Screen zoom by pressing "Escape" or "Backspace" key. [Issue] https://bugs.tizen.org/jira/browse/TT-225 [Problem] User cannot exit the screen zoom. [Cause] Screen zoom is not in ViewManager stack, so it can't be supported by onBackPressed callback. [Solution] Added boost signal in PlatformInputManager on "Escape" and "Backspace" keys. [Verify] Launch browser > Open web page > More Menu > Screen zoom Zoom up/down the page. Then press "escape" -> Screen zoom should disappear and the page should return to normal scale. Change-Id: Ica7a37a9fe15f3bb27bf4f54dce53238b90cb7b5 --- services/PlatformInputManager/PlatformInputManager.cpp | 2 ++ services/PlatformInputManager/PlatformInputManager.h | 1 + services/SimpleUI/SimpleUI.cpp | 11 ++++++++++- services/SimpleUI/SimpleUI.h | 1 + services/ZoomUI/ZoomUI.cpp | 18 ++++++++++++++++++ services/ZoomUI/ZoomUI.h | 2 ++ 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index 4d6cd8f..8a552e9 100644 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -85,6 +85,8 @@ Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int ty // MERGE_ME dont know if should be commented out else if(!keyName.compare("BackSpace") || !keyName.compare("XF86Back")) self->backPressed(); + else if(!keyName.compare("Escape")) + self->escapePressed(); } else if(type == ECORE_EVENT_KEY_UP) { M_ASSERT(event); Ecore_Event_Key *ev = static_cast(event); diff --git a/services/PlatformInputManager/PlatformInputManager.h b/services/PlatformInputManager/PlatformInputManager.h index 781a418..4533561 100644 --- a/services/PlatformInputManager/PlatformInputManager.h +++ b/services/PlatformInputManager/PlatformInputManager.h @@ -54,6 +54,7 @@ public: boost::signals2::signal leftPressed; boost::signals2::signal rightPressed; boost::signals2::signal backPressed; + boost::signals2::signal escapePressed; boost::signals2::signal mouseClicked; /** diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index c86fd31..97b4ffa 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -420,6 +420,7 @@ void SimpleUI::connectModelSignals() m_platformInputManager->returnPressed.connect(boost::bind(&elm_exit)); m_platformInputManager->backPressed.connect(boost::bind(&SimpleUI::onBackPressed, this)); + m_platformInputManager->escapePressed.connect(boost::bind(&SimpleUI::onEscapePressed, this)); m_platformInputManager->mouseClicked.connect( boost::bind(&SimpleUI::onMouseClick, this)); @@ -628,7 +629,9 @@ void SimpleUI::setwvIMEStatus(bool status) void SimpleUI::onBackPressed() { BROWSER_LOGD("[%s]", __func__); - if (m_webPageUI->isHomePageActive()) { + if (m_zoomUI->isVisible()) { + m_zoomUI->escapeZoom(); + } else if (m_webPageUI->isHomePageActive()) { m_quickAccess->backButtonClicked(); } else { if (!m_webPageUI->getURIEntry().hasFocus() && !m_wvIMEStatus) @@ -636,6 +639,12 @@ void SimpleUI::onBackPressed() } } +void SimpleUI::onEscapePressed() +{ + BROWSER_LOGD("[%s]", __func__); + m_zoomUI->escapeZoom(); +} + void SimpleUI::reloadEnable(bool enable) { m_webPageUI->setReloadButtonEnabled(enable); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 4a2293b..35a56da 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -227,6 +227,7 @@ private: void onReturnPressed(MenuButton *m); void onBackPressed(); + void onEscapePressed(); void searchWebPage(std::string &text, int flags); diff --git a/services/ZoomUI/ZoomUI.cpp b/services/ZoomUI/ZoomUI.cpp index c7fa331..aa76abd 100644 --- a/services/ZoomUI/ZoomUI.cpp +++ b/services/ZoomUI/ZoomUI.cpp @@ -103,6 +103,15 @@ void ZoomUI::showNavigation() evas_object_show(m_nav_layout); } +bool ZoomUI::isVisible() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (evas_object_visible_get(m_layout) || (*(getZoom()) != ZOOM_DEFAULT)) + return true; + else + return false; +} + void ZoomUI::createLayout(Evas_Object *parent) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -248,6 +257,15 @@ void ZoomUI::_zoom_value_confirmed(void* data, Evas*, Evas_Object*, void* event_ } } +void ZoomUI::escapeZoom() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (isVisible()) { + setZoom(ZoomUI::ZOOM_DEFAULT); + hideUI(); + } +} + Eina_Bool ZoomUI::_key_down_cb(void* data, int, void* event_info) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/ZoomUI/ZoomUI.h b/services/ZoomUI/ZoomUI.h index a2966f2..c9dd81f 100644 --- a/services/ZoomUI/ZoomUI.h +++ b/services/ZoomUI/ZoomUI.h @@ -46,6 +46,8 @@ public: void show(Evas_Object* parent); void showNavigation(); void clearItems(); + bool isVisible(); + void escapeZoom(); boost::signals2::signal closeZoomUI; boost::signals2::signal setZoom; -- 2.7.4 From 368ebe024af26d8c1ab4d03a3f2e11eca190cc8e Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Mon, 26 Oct 2015 10:35:59 +0100 Subject: [PATCH 07/16] Fixed showing ZoomUI after closing History and Bookmark Manager [Issue] N/A [Problem] ZoomUI is shown on MoreMenuUI after closing History and Bookmark Manager. [Cause] showNavigation functions is called on 'close' button click [Solution] Removing calling showNavigation [Verify] Launch browser > Open web page > More Menu > Screen zoom > set big factor of zoom (so you can see arrows) > open History or Bookmark Manager > Obs ZoomUI should not be shown when you are in MoreMenu. Change-Id: I7aca3cb0e3e558944e0e1cc81fde64bf249c3067 --- services/SimpleUI/SimpleUI.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 97b4ffa..c0a7a2c 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -279,7 +279,6 @@ void SimpleUI::connectUISignals() M_ASSERT(m_historyUI.get()); m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryClicked, this)); m_historyUI->closeHistoryUIClicked.connect(boost::bind(&SimpleUI::closeHistoryUI, this)); - m_historyUI->closeHistoryUIClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); // desktop mode as default m_historyUI->historyItemClicked.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, true)); @@ -304,7 +303,6 @@ void SimpleUI::connectUISignals() M_ASSERT(m_bookmarkManagerUI.get()); m_bookmarkManagerUI->closeBookmarkManagerClicked.connect(boost::bind(&SimpleUI::closeBookmarkManagerUI, this)); - m_bookmarkManagerUI->closeBookmarkManagerClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_bookmarkManagerUI->bookmarkItemClicked.connect(boost::bind(&SimpleUI::onBookmarkClicked, this, _1)); M_ASSERT(m_zoomUI.get()); -- 2.7.4 From fef18fe6395202c3bc2ef7be15bb8f95446093c0 Mon Sep 17 00:00:00 2001 From: "m.kawonczyk" Date: Fri, 23 Oct 2015 13:34:56 +0200 Subject: [PATCH 08/16] Browser - Sometimes Reload button does not work after clicking Stop button [Issue] https://bugs.tizen.org/jira/browse/TT-173 [Problem] Sometimes Reload button does not work after clicking Stop button [Solution] Stop button created loadFinished signal, to solve this loadStopped was created. In addition, engine was still sending __loadProgress signal, which I blocked after Stop button was clicked. As you can not get title and snapshot from unloaded page, it was exchanged by blank image and url for view and for history manager. [Verification] Open new page and stop load. Page should not load any additional content. Reload and enter button on url should force webview to refresh. Change-Id: I5bdab33254ff8dd0ef5302443b21fd23ed82f661 --- services/SimpleUI/SimpleUI.cpp | 24 +++++++++++++++------- services/SimpleUI/SimpleUI.h | 1 + .../WebKitEngineService/WebKitEngineService.cpp | 24 ++++++++++++++++------ services/WebKitEngineService/WebKitEngineService.h | 1 + services/WebKitEngineService/WebView.cpp | 6 +++++- services/WebPageUI/URIEntry.cpp | 7 +++++++ services/WebPageUI/URIEntry.h | 1 + services/WebPageUI/WebPageUI.cpp | 8 ++++++++ services/WebPageUI/WebPageUI.h | 1 + 9 files changed, 59 insertions(+), 14 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index c0a7a2c..344fe49 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -248,7 +248,6 @@ void SimpleUI::connectUISignals() m_webPageUI->forwardPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::forward, m_webEngine.get())); m_webPageUI->forwardPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_webPageUI->stopLoadingPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::stopLoading, m_webEngine.get())); - m_webPageUI->stopLoadingPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_webPageUI->reloadPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::reload, m_webEngine.get())); m_webPageUI->reloadPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_webPageUI->showQuickAccess.connect(boost::bind(&SimpleUI::showQuickAccess, this)); @@ -393,22 +392,19 @@ void SimpleUI::connectModelSignals() m_webEngine->uriChanged.connect(boost::bind(&SimpleUI::webEngineURLChanged, this, _1)); m_webEngine->uriChanged.connect(boost::bind(&URIEntry::changeUri, &m_webPageUI->getURIEntry(), _1)); - m_webEngine->uriChanged.connect(boost::bind(&MoreMenuUI::setURL, m_moreMenuUI.get(), _1)); m_webEngine->webViewClicked.connect(boost::bind(&URIEntry::clearFocus, &m_webPageUI->getURIEntry())); m_webEngine->backwardEnableChanged.connect(boost::bind(&WebPageUI::setBackButtonEnabled, m_webPageUI.get(), _1)); m_webEngine->forwardEnableChanged.connect(boost::bind(&WebPageUI::setForwardButtonEnabled, m_webPageUI.get(), _1)); m_webEngine->loadStarted.connect(boost::bind(&SimpleUI::loadStarted, this)); m_webEngine->loadProgress.connect(boost::bind(&SimpleUI::progressChanged,this,_1)); m_webEngine->loadFinished.connect(boost::bind(&SimpleUI::loadFinished, this)); - m_webEngine->loadStop.connect(boost::bind(&SimpleUI::loadFinished, this)); + m_webEngine->loadStop.connect(boost::bind(&SimpleUI::loadStopped, this)); m_webEngine->loadError.connect(boost::bind(&SimpleUI::loadError, this)); m_webEngine->confirmationRequest.connect(boost::bind(&SimpleUI::handleConfirmationRequest, this, _1)); m_webEngine->tabCreated.connect(boost::bind(&SimpleUI::tabCreated, this)); m_webEngine->checkIfCreate.connect(boost::bind(&SimpleUI::checkIfCreate, this)); m_webEngine->tabClosed.connect(boost::bind(&SimpleUI::tabClosed,this,_1)); m_webEngine->IMEStateChanged.connect(boost::bind(&SimpleUI::setwvIMEStatus, this, _1)); - m_webEngine->favIconChanged.connect(boost::bind(&MoreMenuUI::setFavIcon, m_moreMenuUI.get(), _1)); - m_webEngine->titleChanged.connect(boost::bind(&MoreMenuUI::setWebTitle, m_moreMenuUI.get(), _1)); m_webEngine->titleChanged.connect(boost::bind(&WebPageUI::setPageTitle, m_webPageUI.get(), _1)); m_favoriteService->bookmarkAdded.connect(boost::bind(&SimpleUI::onBookmarkAdded, this,_1)); @@ -679,6 +675,20 @@ void SimpleUI::loadFinished() m_webPageUI->loadFinished(); } +void SimpleUI::loadStopped() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (!m_webEngine->isPrivateMode()) { + m_historyService->addHistoryItem(std::make_shared( + m_webEngine->getURI(), + m_webEngine->getURI(), + std::make_shared()), + std::make_shared()); + } + m_webPageUI->loadStopped(); +} + void SimpleUI::loadError() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -948,7 +958,7 @@ void SimpleUI::showMoreMenu() m_viewManager->pushViewToStack(m_moreMenuUI.get()); m_moreMenuUI->showCurrentTab(); - if(!m_webPageUI->isHomePageActive()) { + if (!m_webPageUI->isHomePageActive()) { m_moreMenuUI->setFavIcon(m_webEngine->getFavicon()); m_moreMenuUI->setWebTitle(m_webEngine->getTitle()); m_moreMenuUI->setURL(m_webEngine->getURI()); @@ -973,7 +983,7 @@ void SimpleUI::switchToMobileMode() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); if (!m_webPageUI->isHomePageActive()) { m_webEngine->switchToMobileMode(); - m_viewManager->popStackTo(m_webPageUI.get()); + m_viewManager->popStackTo(m_webPageUI.get()); m_webEngine->reload(); } else { m_quickAccess->setDesktopMode(false); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 35a56da..a4f8486 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -93,6 +93,7 @@ private: void stopEnable(bool enable); void reloadEnable(bool enable); + void loadStopped(); void loadFinished(); void progressChanged(double progress); void loadStarted(); diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 53beb2e..0e7a6ef 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -43,6 +43,7 @@ EXPORT_SERVICE(WebKitEngineService, "org.tizen.browser.webkitengineservice") WebKitEngineService::WebKitEngineService() : m_initialised(false) , m_privateMode(false) + , m_stopped(false) , m_guiParent(nullptr) , m_currentTabId(TabId::NONE) { @@ -116,6 +117,7 @@ void WebKitEngineService::setURI(const std::string & uri) { BROWSER_LOGD("%s:%d %s uri=%s", __FILE__, __LINE__, __func__, uri.c_str()); M_ASSERT(m_currentWebView); + m_stopped = false; m_currentWebView->setURI(uri); } @@ -137,9 +139,12 @@ bool WebKitEngineService::isLoadError() const std::string WebKitEngineService::getTitle() const { M_ASSERT(m_currentWebView); - if(m_currentWebView) - return m_currentWebView->getTitle(); - else + if (m_currentWebView) { + if (m_stopped) + return m_currentWebView->getURI(); + else + return m_currentWebView->getTitle(); + } else return std::string(""); } @@ -168,24 +173,28 @@ bool WebKitEngineService::isSuspended() const void WebKitEngineService::stopLoading(void) { M_ASSERT(m_currentWebView); + m_stopped = true; m_currentWebView->stopLoading(); } void WebKitEngineService::reload(void) { M_ASSERT(m_currentWebView); + m_stopped = false; m_currentWebView->reload(); } void WebKitEngineService::back(void) { M_ASSERT(m_currentWebView); + m_stopped = false; m_currentWebView->back(); } void WebKitEngineService::forward(void) { M_ASSERT(m_currentWebView); + m_stopped = false; m_currentWebView->forward(); } @@ -484,9 +493,12 @@ bool WebKitEngineService::hasFocus() const std::shared_ptr WebKitEngineService::getFavicon() { M_ASSERT(m_currentWebView); - if(m_currentWebView) - return m_currentWebView->getFavicon(); - else + if (m_currentWebView) { + if (m_stopped) + return std::make_shared(); + else + return m_currentWebView->getFavicon(); + } else return std::make_shared(); } diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index a85bac2..a60af08 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -215,6 +215,7 @@ private: bool m_initialised; bool m_privateMode; void * m_guiParent; + bool m_stopped; // current TabId TabId m_currentTabId; diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index 9a2a091..b81a334 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -247,6 +247,7 @@ void WebView::resume() void WebView::stopLoading(void) { #if defined(USE_EWEBKIT) + m_isLoading = false; ewk_view_stop(m_ewkView); #endif loadStop(); @@ -255,6 +256,7 @@ void WebView::stopLoading(void) void WebView::reload(void) { #if defined(USE_EWEBKIT) + m_isLoading = true; if(m_loadError) { m_loadError = false; @@ -596,6 +598,8 @@ void WebView::__loadProgress(void * data, Evas_Object * /* obj */, void * event_ BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); WebView * self = reinterpret_cast(data); + if (!self->isLoading()) + return; self->m_loadProgress = *(double *)event_info; self->loadProgress(self->m_loadProgress); } @@ -659,7 +663,7 @@ void WebView::__faviconChanged(void* data, Evas_Object*, void*) { WebView * self = static_cast(data); Evas_Object * favicon = ewk_context_icon_database_icon_object_add(ewk_view_context_get(self->m_ewkView), ewk_view_url_get(self->m_ewkView),evas_object_evas_get(self->m_ewkView)); - if (favicon) { + if (favicon && self->isLoading()) { BROWSER_LOGD("[%s:%d] Favicon received", __PRETTY_FUNCTION__, __LINE__); self->faviconImage = EflTools::getBrowserImage(favicon); evas_object_unref(favicon); diff --git a/services/WebPageUI/URIEntry.cpp b/services/WebPageUI/URIEntry.cpp index 9200abb..7be0408 100644 --- a/services/WebPageUI/URIEntry.cpp +++ b/services/WebPageUI/URIEntry.cpp @@ -151,6 +151,13 @@ void URIEntry::setPageTitle(const std::string& title) elm_entry_entry_set(m_entry, elm_entry_utf8_to_markup(m_pageTitle.c_str())); } +void URIEntry::setPageTitleFromURI() +{ + BROWSER_LOGD("%s", __func__); + m_pageTitle = m_URI; + elm_entry_entry_set(m_entry, elm_entry_utf8_to_markup(m_pageTitle.c_str())); +} + void URIEntry::setURI(const std::string& uri) { BROWSER_LOGD("%s, URI: %s", __func__, uri.c_str()); diff --git a/services/WebPageUI/URIEntry.h b/services/WebPageUI/URIEntry.h index c23a0c4..01a20ab 100644 --- a/services/WebPageUI/URIEntry.h +++ b/services/WebPageUI/URIEntry.h @@ -55,6 +55,7 @@ public: void setSearchIcon(); void setDocIcon(); void setPageTitle(const std::string& title); + void setPageTitleFromURI(); void setURI(const std::string& uri); void showPageTitle(); IconType getCurrentIconTyep(); diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index f617925..0772868 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -122,6 +122,14 @@ void WebPageUI::loadFinished() m_URIEntry->showPageTitle(); } +void WebPageUI::loadStopped() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_leftButtonBar->setActionForButton("refresh_stop_button", m_reload); + m_URIEntry->setPageTitleFromURI(); + m_URIEntry->showPageTitle(); +} + bool WebPageUI::isErrorPageActive() { return elm_object_part_content_get(m_mainLayout, "web_view") == m_errorLayout; diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index a3e04f4..f9c387a 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -38,6 +38,7 @@ public: virtual Evas_Object* getContent(); virtual void showUI(); virtual void hideUI(); + void loadStopped(); void loadStarted(); void progressChanged(double progress); void loadFinished(); -- 2.7.4 From 87a39ca48f54ae12d7ff3b093fdb6d23d26d2407 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Mon, 26 Oct 2015 12:32:56 +0100 Subject: [PATCH 09/16] Hiding UI using "Back" key. [Issue] https://bugs.tizen.org/jira/browse/TT-226 [Problem] UIs are not hidden when "Back" key is pressed. [Cause] ViewManager's method popTheStack() is not called. [Solution] Calling popTheStack method in inBackButton function. [Verify] Use "Backspace" key to close UIs. Change-Id: I4e1d279b8dc7e1fea071d0ab294795b9e05496f6 --- services/SimpleUI/SimpleUI.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 344fe49..0ab02e6 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -627,9 +627,10 @@ void SimpleUI::onBackPressed() m_zoomUI->escapeZoom(); } else if (m_webPageUI->isHomePageActive()) { m_quickAccess->backButtonClicked(); + } else if ((m_viewManager->topOfStack() == m_webPageUI.get()) && !m_webPageUI->getURIEntry().hasFocus() && !m_wvIMEStatus) { + m_webEngine->backButtonClicked(); } else { - if (!m_webPageUI->getURIEntry().hasFocus() && !m_wvIMEStatus) - m_webEngine->backButtonClicked(); + m_viewManager->popTheStack(); } } -- 2.7.4 From 0404a9471900781f4bebc4e35ac301e9c7d6ecf6 Mon Sep 17 00:00:00 2001 From: "m.kawonczyk" Date: Mon, 26 Oct 2015 14:23:25 +0100 Subject: [PATCH 10/16] Disappearing navigation buttons [Issue] https://bugs.tizen.org/jira/browse/TT-233 [Problem] Navigation buttons are missing [Solution] Calling efl program responsible of shrinking url bar. [Verification] 1) Load some webpage 2) Go to tab manager and open new blank page 3) From blank page go to tab manager and switch to previously loaded page Check if navigation buttons are present. Change-Id: If23ac877548465210fcc71fc64d19bd72be6a394 --- services/WebPageUI/WebPageUI.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index 0772868..da61712 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -170,6 +170,8 @@ void WebPageUI::switchViewToErrorPage() m_homePageActive = false; setMainContent(m_errorLayout); evas_object_show(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", "ui"); setErrorButtons(); refreshFocusChain(); } @@ -180,6 +182,8 @@ void WebPageUI::switchViewToIncognitoPage() m_homePageActive = false; setMainContent(m_privateLayout); evas_object_show(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", "ui"); setPrivateButtons(); refreshFocusChain(); m_URIEntry->changeUri(""); @@ -201,6 +205,8 @@ void WebPageUI::switchViewToWebPage(Evas_Object* content, const std::string uri, m_URIEntry->showPageTitle(); refreshFocusChain(); evas_object_show(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", "ui"); elm_object_focus_custom_chain_append(m_mainLayout, content, NULL); } -- 2.7.4 From 987c5bf343e988adff4f676c1c76e0865de6c104 Mon Sep 17 00:00:00 2001 From: "m.kawonczyk" Date: Mon, 26 Oct 2015 15:22:22 +0100 Subject: [PATCH 11/16] URL bar shows wrong text [Issue] https://bugs.tizen.org/jira/browse/TT-234 [Problem] URL bar shows wrong title [Solution] URL bar had correct url, however showPageTitle() was not called. Called this function in showUI. [Verification] 1) Open website in a tab 2) Type url in bar with other website address and click enter 3) Click on more menu or tabs button 4) Click on close button 5) Do not change focus to observe problem Check if title shown in URL bar is correct Change-Id: I569a50973b9bda3d934ff25617b85427581a55c4 --- services/WebPageUI/WebPageUI.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index da61712..439a59e 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -75,6 +75,8 @@ void WebPageUI::showUI() if (m_homePageActive) showQuickAccess(); + else + m_URIEntry->showPageTitle(); } -- 2.7.4 From 36cb30d49a9f9b8e13ec5a45ee7fa17ef6055814 Mon Sep 17 00:00:00 2001 From: Adam Skobodzinski Date: Tue, 27 Oct 2015 09:08:14 +0100 Subject: [PATCH 12/16] Displaying UrlHistoryList refactoring (moving class, focus chain). [Issue] https://bugs.tizen.org/jira/browse/TT-161 [Problem] UrlHistoryList was not included in focus chain and was not always visible in a WebPage view. [Solution] UrlHistoryList is moved to WebPageUI. UrlHistoryList is added to focus chain in 'WebPageUI::refreshFocusChain'. Inserting focused item's content to uri entry. [Verify] Displayed UrlHistoryList (QuickAccess view and WebPage view) should be included in focus chain. Focusing out from list and from UriEntry should cause list's scroll out. Focusing on item should change uri entry content. What is not solved yet: 1) list's width is not adapting to QuickAccess url width. 2) 'web_view' content in WebPage view is sometimes colliding with list's focus chain 3) If list is displaying small number of elements, it's partially covering web page view (blocks cursor focus events). Change-Id: Iab263e4e0421adab9e61ac6a6a16f926ace66f67 Signed-off-by: Adam Skobodzinski --- services/QuickAccess/CMakeLists.txt | 9 -- services/QuickAccess/QuickAccess.cpp | 28 +--- services/QuickAccess/QuickAccess.h | 9 -- .../QuickAccess/UrlHistoryList/UrlHistoryList.cpp | 106 ------------- services/QuickAccess/edc/QuickAccess.edc | 32 ---- services/SimpleUI/SimpleUI.cpp | 21 ++- services/SimpleUI/SimpleUI.h | 4 + services/WebPageUI/CMakeLists.txt | 11 ++ services/WebPageUI/URIEntry.cpp | 13 +- services/WebPageUI/URIEntry.h | 4 +- .../UrlHistoryList/GenlistItemsManager.cpp | 85 ++++++++++ .../WebPageUI/UrlHistoryList/GenlistItemsManager.h | 62 ++++++++ .../UrlHistoryList/GenlistManager.cpp | 137 +++++++++++------ .../UrlHistoryList/GenlistManager.h | 64 +++++--- .../UrlHistoryList/GenlistManagerCallbacks.cpp | 67 +++++--- .../UrlHistoryList/GenlistManagerCallbacks.h | 5 +- .../WebPageUI/UrlHistoryList/UrlHistoryList.cpp | 171 +++++++++++++++++++++ .../UrlHistoryList/UrlHistoryList.h | 66 ++++---- .../UrlHistoryList/UrlMatchesStyler.cpp | 0 .../UrlHistoryList/UrlMatchesStyler.h | 0 services/WebPageUI/WebPageUI.cpp | 11 ++ services/WebPageUI/WebPageUI.h | 5 + .../edc/UrlHistoryList.edc | 34 +--- 23 files changed, 583 insertions(+), 361 deletions(-) delete mode 100644 services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp create mode 100644 services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp create mode 100644 services/WebPageUI/UrlHistoryList/GenlistItemsManager.h rename services/{QuickAccess => WebPageUI}/UrlHistoryList/GenlistManager.cpp (61%) rename services/{QuickAccess => WebPageUI}/UrlHistoryList/GenlistManager.h (74%) rename services/{QuickAccess => WebPageUI}/UrlHistoryList/GenlistManagerCallbacks.cpp (52%) rename services/{QuickAccess => WebPageUI}/UrlHistoryList/GenlistManagerCallbacks.h (91%) create mode 100644 services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp rename services/{QuickAccess => WebPageUI}/UrlHistoryList/UrlHistoryList.h (68%) rename services/{QuickAccess => WebPageUI}/UrlHistoryList/UrlMatchesStyler.cpp (100%) rename services/{QuickAccess => WebPageUI}/UrlHistoryList/UrlMatchesStyler.h (100%) rename services/{QuickAccess => WebPageUI}/edc/UrlHistoryList.edc (78%) diff --git a/services/QuickAccess/CMakeLists.txt b/services/QuickAccess/CMakeLists.txt index 2b76470..bacd28d 100644 --- a/services/QuickAccess/CMakeLists.txt +++ b/services/QuickAccess/CMakeLists.txt @@ -3,19 +3,11 @@ project(QuickAccess) set(QuickAccess_SRCS QuickAccess.cpp DetailPopup.cpp - UrlHistoryList/UrlHistoryList.cpp - UrlHistoryList/GenlistManager.cpp - UrlHistoryList/GenlistManagerCallbacks.cpp - UrlHistoryList/UrlMatchesStyler.cpp ) set(QuickAccess_HEADERS QuickAccess.h DetailPopup.h - UrlHistoryList/UrlHistoryList.h - UrlHistoryList/GenlistManager.h - UrlHistoryList/GenlistManagerCallbacks.h - UrlHistoryList/UrlMatchesStyler.h ) include(Coreheaders) @@ -37,7 +29,6 @@ install(TARGETS ${PROJECT_NAME} set(edcFiles QuickAccess.edc DetailPopup.edc - UrlHistoryList.edc ) foreach(edec ${edcFiles}) diff --git a/services/QuickAccess/QuickAccess.cpp b/services/QuickAccess/QuickAccess.cpp index 9e34730..4dee510 100644 --- a/services/QuickAccess/QuickAccess.cpp +++ b/services/QuickAccess/QuickAccess.cpp @@ -25,7 +25,6 @@ #include "Tools/EflTools.h" #include "../Tools/BrowserImage.h" #include "Tools/GeneralTools.h" -#include "UrlHistoryList/UrlHistoryList.h" #define efl_scale (elm_config_scale_get() / elm_app_base_scale_get()) @@ -76,14 +75,10 @@ QuickAccess::QuickAccess() , m_detailPopup(this) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - edjFilePath = edjFilePathUrlHistoryList = EDJE_DIR; + edjFilePath = EDJE_DIR; edjFilePath.append("QuickAccess/QuickAccess.edj"); - edjFilePathUrlHistoryList.append("QuickAccess/UrlHistoryList.edj"); elm_theme_extension_add(nullptr, edjFilePath.c_str()); - elm_theme_extension_add(nullptr, edjFilePathUrlHistoryList.c_str()); QuickAccess::createItemClasses(); - - m_urlHistoryList = std::make_shared(this); } QuickAccess::~QuickAccess() @@ -105,7 +100,6 @@ Evas_Object* QuickAccess::getContent() M_ASSERT(m_parent); if (!m_layout) { m_layout = createQuickAccessLayout(m_parent); - m_urlHistoryListLayout = createUrlHistoryListLayout(m_layout); } return m_layout; } @@ -255,20 +249,6 @@ Evas_Object* QuickAccess::createBottomButton(Evas_Object *parent) return layoutBottom; } -Evas_Object* QuickAccess::createUrlHistoryListLayout(Evas_Object* parent) -{ - Evas_Object* urlHistoryListLayout = elm_layout_add(parent); - elm_layout_file_set(urlHistoryListLayout, edjFilePath.c_str(), "url_history_list_layout"); - evas_object_size_hint_weight_set(urlHistoryListLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set (urlHistoryListLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - m_urlHistoryList->createLayout(urlHistoryListLayout); - if(m_urlHistoryList->getLayout()) - { - elm_object_part_content_set(urlHistoryListLayout, "url_history_list_swallow", m_urlHistoryList->getLayout()); - } - return urlHistoryListLayout; -} void QuickAccess::_mostVisited_clicked(void * data, Evas_Object *, void *) { @@ -461,7 +441,6 @@ void QuickAccess::showUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); evas_object_show(m_layout); - evas_object_show(m_urlHistoryListLayout); if (elm_layout_content_get(m_layout, "elm.swallow.content") == m_bookmarksView) { evas_object_show(m_bookmarksView); } else { @@ -515,11 +494,6 @@ DetailPopup& QuickAccess::getDetailPopup() return m_detailPopup; } -UrlHistoryPtr QuickAccess::getUrlHistoryList() -{ - return m_urlHistoryList; -} - void QuickAccess::backButtonClicked() { if (m_detailPopup.isVisible()) { diff --git a/services/QuickAccess/QuickAccess.h b/services/QuickAccess/QuickAccess.h index 9dd5155..5418b38 100644 --- a/services/QuickAccess/QuickAccess.h +++ b/services/QuickAccess/QuickAccess.h @@ -31,9 +31,6 @@ namespace tizen_browser{ namespace base_ui{ -class UrlHistoryList; -typedef std::shared_ptr UrlHistoryPtr; - //TODO: This class name is not revelant to what this class actually does. //Rename this class and file to "QuickAccessUI". class BROWSER_EXPORT QuickAccess @@ -53,7 +50,6 @@ public: bool isDesktopMode() const; void setDesktopMode(bool mode); DetailPopup & getDetailPopup(); - UrlHistoryPtr getUrlHistoryList(); void backButtonClicked(); inline bool isMostVisitedActive() const; void refreshFocusChain(); @@ -84,7 +80,6 @@ private: Evas_Object* createBookmarksView(Evas_Object *parent); Evas_Object* createBottomButton(Evas_Object *parent); Evas_Object* createTopButtons(Evas_Object *parent); - Evas_Object* createUrlHistoryListLayout(Evas_Object *parent); static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part); @@ -109,15 +104,11 @@ private: std::vector m_tiles; Eina_List* m_parentFocusChain; - UrlHistoryPtr m_urlHistoryList; - Evas_Object* m_urlHistoryListLayout; - Elm_Gengrid_Item_Class * m_bookmark_item_class; DetailPopup m_detailPopup; services::HistoryItemVector m_historyItems; bool m_gengridSetup; std::string edjFilePath; - std::string edjFilePathUrlHistoryList; bool m_desktopMode; static const int MAX_TILES_NUMBER; diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp b/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp deleted file mode 100644 index 4e18d6b..0000000 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015 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. - */ - -#include -#include "UrlHistoryList.h" -#include "GenlistManager.h" -#include "BrowserLogger.h" -#include "../QuickAccess.h" - -namespace tizen_browser { -namespace base_ui { - -UrlHistoryList::UrlHistoryList(QuickAccess* quickAccess) : - m_layout(nullptr), m_quickAccess(quickAccess) -{ - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("QuickAccess/UrlHistoryList.edj"); - m_genlistListManager = make_shared(); - m_genlistListManager->signalItemSelected.connect( - boost::bind(&UrlHistoryList::onListItemSelect, this, _1)); - m_genlistListManager->signalWidgetFocused.connect( - boost::bind(&UrlHistoryList::onListWidgetFocused, this)); - m_genlistListManager->signalWidgetUnfocused.connect( - boost::bind(&UrlHistoryList::onListWidgetUnfocused, this)); -} - -UrlHistoryList::~UrlHistoryList() -{ -} - -Evas_Object* UrlHistoryList::getLayout() -{ - return m_layout; -} - -void UrlHistoryList::createLayout(Evas_Object* parentLayout) -{ - m_layout = elm_layout_add(parentLayout); - elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); - - m_genlistListManager->createWidget(m_layout); -} - -void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl, - shared_ptr matchedEntries) -{ - editedUrlStatesHelper.changeState(true); - - if (matchedEntries->size() == 0) { - m_genlistListManager->hideWidgetPretty(); - } else { - Evas_Object* widgetList = m_genlistListManager->getWidget(); - elm_object_part_content_set(m_layout, "list_swallow", widgetList); - m_genlistListManager->showWidget(editedUrl, matchedEntries); - evas_object_show(widgetList); - } -} - -void UrlHistoryList::onURLEntryEdited() -{ - editedUrlStatesHelper.changeState(false); - if (editedUrlStatesHelper.getCurrentState() - == EditedUrlState::EDITED_OTHER_FIRST) { - m_genlistListManager->hideWidgetPretty(); - } else { - // in this situation scroll will not work, it has to be hidden instantly - m_genlistListManager->hideWidgetInstant(); - } -} - -void UrlHistoryList::onMouseClick() -{ - m_genlistListManager->onMouseClick(); -} - -void UrlHistoryList::onListItemSelect(std::string content) -{ - openURLInNewTab(make_shared < services::HistoryItem > (content), - m_quickAccess->isDesktopMode()); -} - -void UrlHistoryList::onListWidgetFocused() -{ - // will be used soon: in a proper focus-chain solution -} - -void UrlHistoryList::onListWidgetUnfocused() -{ - // will be used soon: in a proper focus-chain solution -} - -}/* namespace base_ui */ -} /* namespace tizen_browser */ diff --git a/services/QuickAccess/edc/QuickAccess.edc b/services/QuickAccess/edc/QuickAccess.edc index ef1881b..c87299b 100644 --- a/services/QuickAccess/edc/QuickAccess.edc +++ b/services/QuickAccess/edc/QuickAccess.edc @@ -20,11 +20,6 @@ collections { #define ITEM_WIDTH 374 #define PARENT_ITEM_HEIGHT 36 -#define URI_INPUTBOX_LENGTH 1720 -#define URL_HISTORY_ITEM_H 82 -#define URL_HISTORY_ITEMS_VISIBLE_MAX 5 -#define URL_HISTORY_LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX - group{ name: "elm/button/base/invisible_button"; parts{ @@ -1388,33 +1383,6 @@ group { name: "top_button_item"; } } -group { - name: "url_history_list_layout"; - parts - { - part - { - name: "url_history_list_swallow"; - type: SWALLOW; - description { - state: "default" 0.0; - min: URI_INPUTBOX_LENGTH URL_HISTORY_LIST_MAX_H; - max: -1 -1; - align: 0.0 0.0; - fixed: 1 1; - visible: 1; - rel1 { - relative: 0 0; - offset: 10 106; - } - rel2 { - relative: 1.0 1.0; - } - } - } - } -} - group { name: "bottom_button_item"; min: 1920 181; max: 1920 181; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 0ab02e6..fc73d3a 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -238,7 +238,7 @@ void SimpleUI::connectUISignals() M_ASSERT(m_webPageUI.get()); m_webPageUI->getURIEntry().uriChanged.connect(boost::bind(&SimpleUI::filterURL, this, _1)); m_webPageUI->getURIEntry().uriEntryEditingChangedByUser.connect(boost::bind(&SimpleUI::onURLEntryEditedByUser, this, _1)); - m_webPageUI->getURIEntry().uriEntryEditingChanged.connect(boost::bind(&SimpleUI::onURLEntryEdited, this)); + m_webPageUI->getUrlHistoryList()->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1)); m_webPageUI->backPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); m_webPageUI->backPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::back, m_webEngine.get())); m_webPageUI->backPage.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); @@ -257,7 +257,6 @@ void SimpleUI::connectUISignals() M_ASSERT(m_quickAccess.get()); m_quickAccess->getDetailPopup().openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); - m_quickAccess->getUrlHistoryList()->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->mostVisitedTileClicked.connect(boost::bind(&SimpleUI::onMostVisitedTileClicked, this, _1, _2)); m_quickAccess->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this)); @@ -559,6 +558,11 @@ void SimpleUI::onOpenURLInNewTab(std::shared_ptr historyItem) +{ + onOpenURLInNewTab(historyItem, m_quickAccess->isDesktopMode()); +} + void SimpleUI::onMostVisitedTileClicked(std::shared_ptr< services::HistoryItem > historyItem, int itemsNumber) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); @@ -728,23 +732,18 @@ void SimpleUI::onURLEntryEditedByUser(const std::shared_ptr editedU { string editedUrl(*editedUrlPtr); int historyItemsVisibleMax = - m_quickAccess->getUrlHistoryList()->getVisibleItemsMax(); + m_webPageUI->getUrlHistoryList()->getVisibleItemsMax(); int minKeywordLength = - m_quickAccess->getUrlHistoryList()->getMinKeywordLength(); + m_webPageUI->getUrlHistoryList()->getMinKeywordLength(); std::shared_ptr result = m_historyService->getHistoryItemsByKeywordsString(editedUrl, historyItemsVisibleMax, minKeywordLength); - m_quickAccess->getUrlHistoryList()->onURLEntryEditedByUser(editedUrl, result); -} - -void SimpleUI::onURLEntryEdited() -{ - m_quickAccess->getUrlHistoryList()->onURLEntryEdited(); + m_webPageUI->getUrlHistoryList()->onURLEntryEditedByUser(editedUrl, result); } void SimpleUI::onMouseClick() { - m_quickAccess->getUrlHistoryList()->onMouseClick(); + m_webPageUI->getUrlHistoryList()->onMouseClick(); } void SimpleUI::webEngineURLChanged(const std::string url) diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index a4f8486..f50db74 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -132,6 +132,10 @@ private: void onHistoryRemoved(const std::string& uri); void onOpenURLInNewTab(std::shared_ptr historyItem, bool desktopMode); + /** + * @brief Handles 'openUrlInNewTab' signals. Uses QuickAccess to indicate desktop/mobile mode. + */ + void onOpenURLInNewTab(std::shared_ptr historyItem); void onMostVisitedTileClicked(std::shared_ptr historyItem, int itemsNumber); void onClearHistoryClicked(); diff --git a/services/WebPageUI/CMakeLists.txt b/services/WebPageUI/CMakeLists.txt index ddcb2e9..6171eae 100644 --- a/services/WebPageUI/CMakeLists.txt +++ b/services/WebPageUI/CMakeLists.txt @@ -4,12 +4,22 @@ set(WebPageUI_SRCS WebPageUI.cpp ButtonBar.cpp URIEntry.cpp + UrlHistoryList/UrlHistoryList.cpp + UrlHistoryList/GenlistManager.cpp + UrlHistoryList/GenlistManagerCallbacks.cpp + UrlHistoryList/UrlMatchesStyler.cpp + UrlHistoryList/GenlistItemsManager.cpp ) set(WebPageUI_HEADERS WebPageUI.h ButtonBar.h URIEntry.h + UrlHistoryList/UrlHistoryList.h + UrlHistoryList/GenlistManager.h + UrlHistoryList/GenlistManagerCallbacks.h + UrlHistoryList/UrlMatchesStyler.h + UrlHistoryList/GenlistItemsManager.h ) include(Coreheaders) @@ -59,6 +69,7 @@ set(edcFiles RightButtonBar.edc URIEntry.edc PrivateMode.edc + UrlHistoryList.edc ) foreach(edec ${edcFiles}) diff --git a/services/WebPageUI/URIEntry.cpp b/services/WebPageUI/URIEntry.cpp index 7be0408..0376a6a 100644 --- a/services/WebPageUI/URIEntry.cpp +++ b/services/WebPageUI/URIEntry.cpp @@ -80,7 +80,6 @@ Evas_Object* URIEntry::getContent() evas_object_smart_callback_add(m_entry, "activated", URIEntry::activated, this); evas_object_smart_callback_add(m_entry, "aborted", URIEntry::aborted, this); evas_object_smart_callback_add(m_entry, "preedit,changed", URIEntry::preeditChange, this); - evas_object_smart_callback_add(m_entry, "changed", URIEntry::_uri_entry_editing_changed, this); evas_object_smart_callback_add(m_entry, "changed,user", URIEntry::_uri_entry_editing_changed_user, this); evas_object_smart_callback_add(m_entry, "focused", URIEntry::focused, this); evas_object_smart_callback_add(m_entry, "unfocused", URIEntry::unfocused, this); @@ -102,6 +101,11 @@ Evas_Object* URIEntry::getContent() return m_entry_layout; } +Evas_Object* URIEntry::getEntryWidget() +{ + return m_entry; +} + void URIEntry::changeUri(const std::string& newUri) { BROWSER_LOGD("%s: newUri=%s", __func__, newUri.c_str()); @@ -237,12 +241,6 @@ void URIEntry::_uri_entry_editing_changed_user(void* data, Evas_Object* /* obj * self->uriEntryEditingChangedByUser(std::make_shared(entry)); } -void URIEntry::_uri_entry_editing_changed(void* data, Evas_Object* /* obj */, void* /* event_info */) -{ - URIEntry* self = static_cast(data); - self->uriEntryEditingChanged(); -} - void URIEntry::setUrlGuideText(const char* txt) const { #if PLATFORM(TIZEN) @@ -254,7 +252,6 @@ void URIEntry::setUrlGuideText(const char* txt) const void URIEntry::unfocused(void* data, Evas_Object*, void*) { - BROWSER_LOGD("%s", __func__); URIEntry* self = static_cast(data); self->m_entrySelectedAllFirst = false; self->setUrlGuideText(GUIDE_TEXT_UNFOCUSED); diff --git a/services/WebPageUI/URIEntry.h b/services/WebPageUI/URIEntry.h index 01a20ab..478bc5e 100644 --- a/services/WebPageUI/URIEntry.h +++ b/services/WebPageUI/URIEntry.h @@ -40,13 +40,12 @@ public: ~URIEntry(); void init(Evas_Object* parent); Evas_Object* getContent(); + Evas_Object* getEntryWidget(); void changeUri(const std::string&); boost::signals2::signal uriChanged; - // uri edition change - boost::signals2::signal uriEntryEditingChanged; // uri edition change (by a user) boost::signals2::signal)> uriEntryEditingChangedByUser; @@ -108,7 +107,6 @@ private: static void _fixed_entry_key_down_handler(void* data, Evas* e, Evas_Object* obj, void* event_info); static void _uri_entry_btn_clicked(void* data, Evas_Object* obj, void* event_info); static void _uri_entry_clicked(void* data, Evas_Object* obj, void* event_info); - static void _uri_entry_editing_changed(void* data, Evas_Object* obj, void* event_info); static void _uri_entry_editing_changed_user(void* data, Evas_Object* obj, void* event_info); static void focusedBtn(void* data, Evas_Object* obj, void* event_info); diff --git a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp new file mode 100644 index 0000000..b868747 --- /dev/null +++ b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp @@ -0,0 +1,85 @@ +/* + * GenlistItemsManager.cpp + * + * Created on: Oct 23, 2015 + * Author: a.skobodzins + */ + +#include "GenlistItemsManager.h" +#include "BrowserLogger.h" + +namespace tizen_browser { +namespace base_ui { + +GenlistItemsManager::GenlistItemsManager() +{ + ptrMap.insert( { GenlistItemType::ITEM_CURRENT, + make_shared() }); + ptrMap.insert( { GenlistItemType::ITEM_FIRST, + make_shared() }); + ptrMap.insert({ GenlistItemType::ITEM_LAST, + make_shared() }); + ptrMap.insert({ GenlistItemType::ITEM_SPACE_FIRST, + make_shared() }); + ptrMap.insert({ GenlistItemType::ITEM_SPACE_LAST, + make_shared() }); +} + +GenlistItemsManager::~GenlistItemsManager() +{ +} + +Elm_Object_Item* GenlistItemsManager::getItem(GenlistItemType type) +{ + return *ptrMap.at(type); +} + +void GenlistItemsManager::setItems(std::initializer_list types, + Elm_Object_Item* item) +{ + for (auto i : types) { + *ptrMap.at(i) = item; + } +} + +void GenlistItemsManager::setItemsIfNullptr( + std::initializer_list types, Elm_Object_Item* item) +{ + for (auto i : types) { + if (!getItem(i)) { + setItems( { i }, item); + } + } +} + +void GenlistItemsManager::assignItem(GenlistItemType dst, GenlistItemType src) +{ + setItems( { dst }, getItem(src)); +} + +bool GenlistItemsManager::shiftItemDown(GenlistItemType item) +{ + if (!getItem(item)) + return false; + Elm_Object_Item* item_next = elm_genlist_item_next_get(getItem(item)); + if (item_next) { + setItems( { item }, item_next); + return true; + } + return false; +} + +bool GenlistItemsManager::shiftItemUp(GenlistItemType item) +{ + if (!getItem(item)) + return false; + Elm_Object_Item* item_prev = elm_genlist_item_prev_get(getItem(item)); + if (item_prev) { + setItems( { item }, item_prev); + return true; + } + return false; +} + +} /* namespace base_ui */ +} /* namespace tizen_browser */ diff --git a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h new file mode 100644 index 0000000..b8901d3 --- /dev/null +++ b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h @@ -0,0 +1,62 @@ +/* + * GenlistItemsManager.h + * + * Created on: Oct 23, 2015 + * Author: a.skobodzins + */ + +#ifndef GENLISTITEMSMANAGER_H_ +#define GENLISTITEMSMANAGER_H_ + +#include +#include + +#include + +using namespace std; + +namespace tizen_browser { +namespace base_ui { + +enum class GenlistItemType +{ + ITEM_CURRENT, ITEM_FIRST, ITEM_LAST, ITEM_SPACE_FIRST, ITEM_SPACE_LAST +}; + +/** + * Stores and manipulated pointers on Elm_Object_Item for GenlistManager + */ +class GenlistItemsManager +{ +public: + GenlistItemsManager(); + virtual ~GenlistItemsManager(); + + Elm_Object_Item* getItem(GenlistItemType type); + void setItems(std::initializer_list types, + Elm_Object_Item* item); + /** + * Same as #setItems, except only nullptr value pointers are set + */ + void setItemsIfNullptr(std::initializer_list types, + Elm_Object_Item* item); + /** + * Assign src pointer value to dst. + */ + void assignItem(GenlistItemType dst, GenlistItemType src); + /** + * Assign item of a given type to a elm_genlist_item_next_get item, if + * there is one. Return false, if value has not changed. + */ + bool shiftItemDown(GenlistItemType item); + bool shiftItemUp(GenlistItemType item); + +private: + map> ptrMap; + +}; + +} /* namespace base_ui */ +} /* namespace tizen_browser */ + +#endif /* GENLISTITEMSMANAGER_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp b/services/WebPageUI/UrlHistoryList/GenlistManager.cpp similarity index 61% rename from services/QuickAccess/UrlHistoryList/GenlistManager.cpp rename to services/WebPageUI/UrlHistoryList/GenlistManager.cpp index 7977861..2b17152 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp +++ b/services/WebPageUI/UrlHistoryList/GenlistManager.cpp @@ -14,9 +14,11 @@ * limitations under the License. */ +#include "BrowserLogger.h" #include "GenlistManager.h" #include "GenlistManagerCallbacks.h" #include "UrlMatchesStyler.h" +#include "GenlistItemsManager.h" namespace tizen_browser { namespace base_ui { @@ -24,11 +26,12 @@ namespace base_ui { GenlistManager::GenlistManager() { m_urlMatchesStyler = make_shared(); + m_itemsManager = make_shared(); m_historyItemClass = elm_genlist_item_class_new(); m_historyItemClass->item_style = "url_historylist_grid_item"; m_historyItemClass->func.text_get = nullptr; - m_historyItemClass->func.content_get = m_contentGet; + m_historyItemClass->func.content_get = m_itemClassContentGet; m_historyItemClass->func.state_get = nullptr; m_historyItemClass->func.del = nullptr; @@ -49,7 +52,7 @@ GenlistManager::~GenlistManager() void GenlistManager::clearWidget() { - if(m_genlist && elm_genlist_items_count(m_genlist)) + if (m_genlist && elm_genlist_items_count(m_genlist)) elm_genlist_clear(m_genlist); } @@ -58,6 +61,16 @@ void GenlistManager::onMouseFocusChange(bool mouseInsideWidget) this->mouseInsideWidget = mouseInsideWidget; } +void GenlistManager::setSingleBlockHide(bool block) +{ + m_singleHideBlock = block; +} + +bool GenlistManager::getSingleBlockHide() +{ + return m_singleHideBlock; +} + Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) { if (!widgetExists()) { @@ -67,11 +80,12 @@ Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) EVAS_HINT_EXPAND); evas_object_size_hint_align_set(m_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); - if (!genlistShowScrollbar) { + if (!GENLIST_SHOW_SCROLLBAR) { elm_scroller_policy_set(m_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); } - + elm_object_event_callback_add(m_genlist, + GenlistManagerCallbacks::_object_event, this); evas_object_smart_callback_add(m_genlist, "edge,top", GenlistManagerCallbacks::_genlist_edge_top, this); evas_object_smart_callback_add(m_genlist, "edge,bottom", @@ -86,8 +100,6 @@ Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) GenlistManagerCallbacks::_genlist_focused, this); evas_object_smart_callback_add(m_genlist, "unfocused", GenlistManagerCallbacks::_genlist_unfocused, this); - - } return m_genlist; } @@ -99,47 +111,79 @@ Evas_Object* GenlistManager::getWidget() return m_genlist; } +GenlistItemsManagerPtr GenlistManager::getItemsManager() +{ + return m_itemsManager; +} + void GenlistManager::showWidget(const string& editedUrl, shared_ptr matchedEntries) { clearWidget(); prepareUrlsVector(editedUrl, matchedEntries); - m_itemUrlFirst = m_itemUrlLast = nullptr; + m_itemsManager->setItems( { GenlistItemType::ITEM_FIRST, + GenlistItemType::ITEM_LAST }, nullptr); Elm_Object_Item* itemAppended = nullptr; - for(auto it : m_readyUrlPairs) { + for (auto it : m_readyUrlPairs) { itemAppended = elm_genlist_item_append(m_genlist, m_historyItemClass, - it.get(), nullptr, ELM_GENLIST_ITEM_NONE, GenlistManagerCallbacks::_item_selected, it.get()); - if (!m_itemUrlFirst) - m_itemUrlFirst = itemAppended; + it.get(), nullptr, ELM_GENLIST_ITEM_NONE, + GenlistManagerCallbacks::_item_selected, it.get()); + m_itemsManager->setItemsIfNullptr( { GenlistItemType::ITEM_FIRST }, + itemAppended); } - m_itemUrlLast = itemAppended; + m_itemsManager->setItems( { GenlistItemType::ITEM_LAST }, itemAppended); - if (widgetPreviouslyHidden) { - widgetPreviouslyHidden = false; + if (getWidgetPreviouslyHidden()) { + setWidgetPreviouslyHidden(false); startScrollIn(); } } +const char* GenlistManager::getItemUrl(GenlistItemType type) +{ + if (!m_itemsManager->getItem( { type })) + return ""; + void* data = elm_object_item_data_get(m_itemsManager->getItem( { type })); + if (!data) + return ""; + const UrlPair* const urlPair = reinterpret_cast(data); + if (!urlPair) + return ""; + return urlPair->urlOriginal.c_str(); +} + void GenlistManager::hideWidgetPretty() { - if (widgetPreviouslyHidden) { + if (getSingleBlockHide()) { + setSingleBlockHide(false); + return; + } + + m_itemsManager->setItems( { GenlistItemType::ITEM_CURRENT }, nullptr); + + if (getWidgetPreviouslyHidden()) { hideWidgetInstant(); return; } startScrollOut(); - widgetPreviouslyHidden = true; + setWidgetPreviouslyHidden(true); } void GenlistManager::hideWidgetInstant() { - if(m_genlist) + if (m_genlist) evas_object_hide(m_genlist); } -bool GenlistManager::isWidgetHidden() +bool GenlistManager::getWidgetPreviouslyHidden() { - return widgetPreviouslyHidden; + return m_widgetPreviouslyHidden; +} + +void GenlistManager::setWidgetPreviouslyHidden(bool previouslyHidden) +{ + this->m_widgetPreviouslyHidden = previouslyHidden; } void GenlistManager::onMouseClick() @@ -151,10 +195,13 @@ void GenlistManager::onMouseClick() void GenlistManager::startScrollIn() { - if (m_itemUrlFirst) { + if (m_itemsManager->getItem(GenlistItemType::ITEM_FIRST)) { addSpaces(); - elm_genlist_item_show(m_itemSpaceLast, ELM_GENLIST_ITEM_SCROLLTO_TOP); - elm_genlist_item_bring_in(m_itemUrlFirst, + elm_genlist_item_show( + m_itemsManager->getItem(GenlistItemType::ITEM_SPACE_LAST), + ELM_GENLIST_ITEM_SCROLLTO_TOP); + elm_genlist_item_bring_in( + m_itemsManager->getItem(GenlistItemType::ITEM_FIRST), ELM_GENLIST_ITEM_SCROLLTO_TOP); } } @@ -162,48 +209,45 @@ void GenlistManager::startScrollIn() void GenlistManager::startScrollOut() { addSpaces(); - if (m_itemSpaceFirst) { - elm_genlist_item_bring_in(m_itemSpaceFirst, - ELM_GENLIST_ITEM_SCROLLTO_TOP); + Elm_Object_Item* first = m_itemsManager->getItem( + GenlistItemType::ITEM_SPACE_FIRST); + if (first) { + elm_genlist_item_bring_in(first, ELM_GENLIST_ITEM_SCROLLTO_TOP); } } -void GenlistManager::setLastEdgeTop(bool edgeTop) -{ - lastEdgeTop = edgeTop; -} - -bool GenlistManager::getLastEdgeTop() -{ - return lastEdgeTop; -} - void GenlistManager::addSpaces() { - if (m_itemUrlLast) { - m_itemSpaceFirst = m_itemSpaceLast = nullptr; + if (m_itemsManager->getItem(GenlistItemType::ITEM_LAST)) { + m_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_FIRST, + GenlistItemType::ITEM_SPACE_LAST }, nullptr); Elm_Object_Item* itemAppended = nullptr; for (auto i = 0; i < HISTORY_ITEMS_VISIBLE_MAX; ++i) { // append spaces to the last url item, so they can be easily cleared itemAppended = elm_genlist_item_append(m_genlist, - m_historyItemSpaceClass, nullptr, m_itemUrlLast, - ELM_GENLIST_ITEM_NONE, nullptr, this); - if (!m_itemSpaceFirst) - m_itemSpaceFirst = itemAppended; + m_historyItemSpaceClass, nullptr, + m_itemsManager->getItem(GenlistItemType::ITEM_LAST), + ELM_GENLIST_ITEM_NONE, nullptr, nullptr); + elm_object_focus_allow_set(itemAppended, EINA_FALSE); + m_itemsManager->setItemsIfNullptr( { + GenlistItemType::ITEM_SPACE_FIRST }, itemAppended); } - m_itemSpaceLast = itemAppended; + m_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_LAST }, + itemAppended); } } void GenlistManager::removeSpaces() { - if (m_itemUrlLast) { - elm_genlist_item_subitems_clear(m_itemUrlLast); + if (m_itemsManager->getItem(GenlistItemType::ITEM_LAST)) { + elm_genlist_item_subitems_clear( + m_itemsManager->getItem(GenlistItemType::ITEM_LAST)); } - m_itemSpaceFirst = m_itemSpaceLast = nullptr; + m_itemsManager->setItems( { GenlistItemType::ITEM_SPACE_FIRST, + GenlistItemType::ITEM_SPACE_LAST }, nullptr); } -Evas_Object* GenlistManager::m_contentGet(void* data, Evas_Object* obj, +Evas_Object* GenlistManager::m_itemClassContentGet(void* data, Evas_Object* obj, const char* part) { Evas_Object* label = elm_label_add(obj); @@ -225,7 +269,6 @@ void GenlistManager::prepareUrlsVector(const string& editedUrl, { // free previously used urls. IMPORTANT: it has to be assured that previous // genlist items are not using these pointers. - m_readyUrls.clear(); m_readyUrlPairs.clear(); for (auto it : *matchedEntries) { UrlPair newUrlPair(it->getUrl(), diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.h b/services/WebPageUI/UrlHistoryList/GenlistManager.h similarity index 74% rename from services/QuickAccess/UrlHistoryList/GenlistManager.h rename to services/WebPageUI/UrlHistoryList/GenlistManager.h index b1e91e1..bec4f4c 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.h +++ b/services/WebPageUI/UrlHistoryList/GenlistManager.h @@ -20,7 +20,6 @@ #include #include "services/HistoryService/HistoryItem.h" #include -#include "BrowserLogger.h" using namespace std; @@ -28,12 +27,23 @@ namespace tizen_browser { namespace base_ui { class GenlistManagerCallbacks; +class GenlistItemsManager; +enum class GenlistItemType +; +typedef shared_ptr GenlistItemsManagerPtr; class UrlMatchesStyler; typedef shared_ptr UrlMatchesStylerPtr; -typedef struct UrlPair_s { - UrlPair_s(string a, string b) : urlOriginal(a), urlHighlighted(b) {} +typedef struct UrlPair_s +{ + UrlPair_s(string a, string b) : + urlOriginal(a), urlHighlighted(b) + { + } string urlOriginal; + /** + * Url plus styling tags. + */ string urlHighlighted; } UrlPair; @@ -46,12 +56,20 @@ public: Evas_Object* createWidget(Evas_Object* parentLayout); Evas_Object* getWidget(); + GenlistItemsManagerPtr getItemsManager(); void showWidget(const string& editedUrl, shared_ptr matchedEntries); + /** + * Hide widget by scrolling out. + */ void hideWidgetPretty(); + /** + * Hide widget by evas_object_hide. + */ void hideWidgetInstant(); - bool isWidgetHidden(); + void setWidgetPreviouslyHidden(bool previouslyHidden); + bool getWidgetPreviouslyHidden(); void onMouseClick(); /** @@ -59,24 +77,32 @@ public: */ void addSpaces(); void removeSpaces(); + /** + * Clear all elements from a genlist. + */ void clearWidget(); + /** + * When set to true, the next hide attempt will be blocked. + */ + void setSingleBlockHide(bool block); + bool getSingleBlockHide(); boost::signals2::signal signalItemSelected; boost::signals2::signal signalWidgetFocused; boost::signals2::signal signalWidgetUnfocused; + boost::signals2::signal signalItemFocusChange; + + const char* getItemUrl(GenlistItemType type); private: - static Evas_Object* m_contentGet(void *data, Evas_Object *obj, + static Evas_Object* m_itemClassContentGet(void *data, Evas_Object *obj, const char *part); - bool widgetExists() - { - return m_genlist != nullptr; - } + + bool widgetExists() {return m_genlist != nullptr;} + void prepareUrlsVector(const string& editedUrl, shared_ptr matchedEntries); - void setLastEdgeTop(bool edgeTop); - bool getLastEdgeTop(); void onMouseFocusChange(bool mouseInsideWidget); void startScrollIn(); @@ -84,8 +110,8 @@ private: Evas_Object* m_parentLayout = nullptr; Evas_Object* m_genlist = nullptr; - const bool genlistShowScrollbar = false; + const bool GENLIST_SHOW_SCROLLBAR = false; // don't know how to get from edc: const int HISTORY_ITEM_H = 82; const int HISTORY_ITEMS_VISIBLE_MAX = 5; @@ -96,22 +122,17 @@ private: * Set to true, whenever hide request occurs. Set to false, whenever show * request occurs. Needed to indicate when genlist should slide in. */ - bool widgetPreviouslyHidden = true; + bool m_widgetPreviouslyHidden = true; + bool m_singleHideBlock = false; /* * If mouse click received and mouse is outside widget, hide it. */ bool mouseInsideWidget = true; - /* - * needed to indicate direction of the scroll in 'anim,stop' callback - */ - bool lastEdgeTop = true; Elm_Gengrid_Item_Class* m_historyItemClass; Elm_Gengrid_Item_Class* m_historyItemSpaceClass; - Elm_Object_Item* m_itemUrlFirst = nullptr; - Elm_Object_Item* m_itemUrlLast = nullptr; - Elm_Object_Item* m_itemSpaceFirst = nullptr; - Elm_Object_Item* m_itemSpaceLast = nullptr; + + GenlistItemsManagerPtr m_itemsManager; /* * keeps shared pointers to strings, that are ready to be displayed, so they can be @@ -120,7 +141,6 @@ private: * labels from these pointers in m_contentGet(). in case of segfaults, delete copy of pointers * manually in m_contentGet(). */ - vector> m_readyUrls; vector> m_readyUrlPairs; UrlMatchesStylerPtr m_urlMatchesStyler; diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp similarity index 52% rename from services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp rename to services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp index 17d1cf3..757d356 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp +++ b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp @@ -15,7 +15,9 @@ */ #include "BrowserLogger.h" -#include +#include "GenlistManagerCallbacks.h" +#include "GenlistItemsManager.h" +#include namespace tizen_browser { namespace base_ui { @@ -30,21 +32,19 @@ GenlistManagerCallbacks::~GenlistManagerCallbacks() { } -void GenlistManagerCallbacks::_genlist_edge_top(void *data, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_edge_top(void* data, + Evas_Object* /*obj*/, void* /*event_info*/) { auto manager = static_cast(data); - manager->setLastEdgeTop(false); // spaces added for 'slide in' effect are not longer needed manager->removeSpaces(); } -void GenlistManagerCallbacks::_genlist_edge_bottom(void *data, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_edge_bottom(void* data, + Evas_Object* /*obj*/, void* /*event_info*/) { auto manager = static_cast(data); - manager->setLastEdgeTop(true); - if (manager->isWidgetHidden()) { + if (manager->getWidgetPreviouslyHidden()) { manager->clearWidget(); evas_object_hide(manager->getWidget()); } @@ -56,6 +56,7 @@ void GenlistManagerCallbacks::_genlist_mouse_in(void* data, Evas* /*e*/, auto manager = static_cast(data); manager->onMouseFocusChange(true); } + void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/, Evas_Object* /*obj*/, void* /*event_info*/) { @@ -63,20 +64,18 @@ void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/, manager->onMouseFocusChange(false); } -void GenlistManagerCallbacks::_genlist_focused(void* /*data*/, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_focused(void* /*data*/, + Evas_Object* /*obj*/, void* /*event_info*/) { - if(genlistManager) - { + if (genlistManager) { genlistManager->signalWidgetFocused(); } } -void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/, Evas_Object* /*obj*/, - void* /*event_info*/) +void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/, + Evas_Object* /*obj*/, void* /*event_info*/) { - if(genlistManager) - { + if (genlistManager) { genlistManager->signalWidgetUnfocused(); } } @@ -86,13 +85,45 @@ void GenlistManagerCallbacks::_item_selected(void* data, Evas_Object* /*obj*/, { const UrlPair* const item = reinterpret_cast(data); if (item) { - if(genlistManager) - { + if (genlistManager) { genlistManager->signalItemSelected(item->urlOriginal); genlistManager->hideWidgetPretty(); } } } +Eina_Bool GenlistManagerCallbacks::_object_event(void* /*data*/, + Evas_Object* /*obj*/, Evas_Object* /*src*/, Evas_Callback_Type /*type*/, + void* event_info) +{ + genlistManager->removeSpaces(); + genlistManager->setWidgetPreviouslyHidden(false); + + if (genlistManager) { + Ecore_Event_Key *ev = static_cast(event_info); + const std::string keyName = ev->keyname; + if (!keyName.compare("Down") || !keyName.compare("Up")) { + GenlistItemsManagerPtr itemsManager = + genlistManager->getItemsManager(); + if (!itemsManager->getItem(GenlistItemType::ITEM_CURRENT)) { + itemsManager->assignItem(GenlistItemType::ITEM_CURRENT, + GenlistItemType::ITEM_FIRST); + } else { + if (!keyName.compare("Down")) { + itemsManager->shiftItemDown(GenlistItemType::ITEM_CURRENT); + } else { + if (!itemsManager->shiftItemUp( + GenlistItemType::ITEM_CURRENT)) { + // 'up' pressed on a first item. don't hide widget + genlistManager->setSingleBlockHide(true); + } + } + } + genlistManager->signalItemFocusChange(); + } + } + return EINA_FALSE; +} + } /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h similarity index 91% rename from services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h rename to services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h index 228108d..d87b590 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h +++ b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h @@ -17,7 +17,7 @@ #ifndef GENLISTMANAGERCALLBACKS_H_ #define GENLISTMANAGERCALLBACKS_H_ -#include +#include "GenlistManager.h" #include #include @@ -45,6 +45,9 @@ public: static void _genlist_unfocused(void* data, Evas_Object* obj, void* event_info); + static Eina_Bool _object_event(void* data, Evas_Object* obj, + Evas_Object* src, Evas_Callback_Type type, void* event_info); + static void _item_selected(void* data, Evas_Object* obj, void* event_info); static void setGenlistManager(GenlistManager* genlistManager) diff --git a/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp b/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp new file mode 100644 index 0000000..45e6d2a --- /dev/null +++ b/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2015 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. + */ + +#include +#include "UrlHistoryList.h" +#include "GenlistManager.h" +#include "BrowserLogger.h" +#include "GenlistItemsManager.h" + +namespace tizen_browser { +namespace base_ui { + +UrlHistoryList::UrlHistoryList() : + m_layout(nullptr) +{ + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("WebPageUI/UrlHistoryList.edj"); + m_genlistListManager = make_shared(); + m_genlistListManager->signalItemSelected.connect( + boost::bind(&UrlHistoryList::onListItemSelect, this, _1)); + m_genlistListManager->signalWidgetFocused.connect( + boost::bind(&UrlHistoryList::onListWidgetFocused, this)); + m_genlistListManager->signalWidgetUnfocused.connect( + boost::bind(&UrlHistoryList::onListWidgetUnfocused, this)); + m_genlistListManager->signalItemFocusChange.connect( + boost::bind(&UrlHistoryList::onItemFocusChange, this)); +} + +UrlHistoryList::~UrlHistoryList() +{ +} + +void UrlHistoryList::setMembers(Evas_Object* parent, Evas_Object* editedEntry) +{ + m_parent = parent; + m_entry = editedEntry; + + evas_object_smart_callback_add(m_entry, "changed,user", + UrlHistoryList::_uri_entry_editing_changed_user, this); + evas_object_smart_callback_add(m_entry, "unfocused", + UrlHistoryList::_uri_entry_unfocused, this); +} + +void UrlHistoryList::createLayout(Evas_Object* parentLayout) +{ + if (m_layout) + return; + + m_layout = elm_layout_add(parentLayout); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); + Evas_Object* widgetList = m_genlistListManager->createWidget(m_layout); + m_genlistListManager->hideWidgetPretty(); + elm_object_part_content_set(m_layout, "list_swallow", widgetList); + evas_object_show(widgetList); + evas_object_show(m_layout); +} + +Evas_Object* UrlHistoryList::getContent() +{ + if (!m_layout) + createLayout(m_parent); + + return m_layout; +} + +Evas_Object* UrlHistoryList::getEditedEntry() +{ + return m_entry; +} + +void UrlHistoryList::saveEntryEditedContent() +{ + m_entryEditedContent = elm_entry_entry_get(m_entry); +} + +void UrlHistoryList::restoreEntryEditedContent() +{ + elm_entry_entry_set(m_entry, m_entryEditedContent.c_str()); +} + +void UrlHistoryList::saveEntryURLContent() +{ + m_entryURLContent = elm_entry_entry_get(m_entry); +} + +void UrlHistoryList::restoreEntryURLContent() +{ + elm_entry_entry_set(m_entry, m_entryURLContent.c_str()); +} + +Evas_Object* UrlHistoryList::getGenlist() +{ + return m_genlistListManager->getWidget(); +} + +void UrlHistoryList::hideWidgetPretty() +{ + m_genlistListManager->hideWidgetPretty(); +} + +void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl, + shared_ptr matchedEntries) +{ + if (matchedEntries->size() == 0) { + m_genlistListManager->hideWidgetPretty(); + } else { + Evas_Object* widgetList = m_genlistListManager->getWidget(); + m_genlistListManager->showWidget(editedUrl, matchedEntries); + evas_object_show(m_parent); + evas_object_show(widgetList); + evas_object_show(m_layout); + } +} + +void UrlHistoryList::onItemFocusChange() +{ + elm_entry_entry_set(m_entry, + m_genlistListManager->getItemUrl(GenlistItemType::ITEM_CURRENT)); +} + +void UrlHistoryList::onMouseClick() +{ + m_genlistListManager->onMouseClick(); +} + +void UrlHistoryList::onListItemSelect(std::string content) +{ + openURLInNewTab (make_shared(content));hideWidgetPretty(); +} + +void UrlHistoryList::onListWidgetFocused() +{ + saveEntryURLContent(); +} + +void UrlHistoryList::onListWidgetUnfocused() +{ + m_genlistListManager->hideWidgetPretty(); + restoreEntryURLContent(); +} + +void UrlHistoryList::_uri_entry_editing_changed_user(void* data, + Evas_Object* /* obj */, void* /* event_info */) +{ + UrlHistoryList* self = reinterpret_cast(data); + self->saveEntryEditedContent(); +} + +void UrlHistoryList::_uri_entry_unfocused(void* data, Evas_Object* /* obj */, + void* /* event_info */) +{ + + UrlHistoryList* self = reinterpret_cast(data); + self->hideWidgetPretty(); +} + +}/* namespace base_ui */ +} /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h b/services/WebPageUI/UrlHistoryList/UrlHistoryList.h similarity index 68% rename from services/QuickAccess/UrlHistoryList/UrlHistoryList.h rename to services/WebPageUI/UrlHistoryList/UrlHistoryList.h index f42a425..02636d7 100644 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h +++ b/services/WebPageUI/UrlHistoryList/UrlHistoryList.h @@ -28,7 +28,6 @@ using namespace std; namespace tizen_browser { namespace base_ui { -class QuickAccess; class GenlistManager; typedef shared_ptr GenlistManagerPtr; @@ -43,56 +42,35 @@ enum class EditedUrlState }; /** - * Needed to indicate who did the last url entry edition (user/other/other many times). Used - * to indicate when widget can be hidden in a pretty way or an instant way. - */ -class EditedUrlStatesHelper -{ -public: - EditedUrlStatesHelper() - { - } - void changeState(bool editedByUser) - { - if (editedByUser) { - currentState = EditedUrlState::EDITED_BY_USER; - } else { - if (currentState == EditedUrlState::EDITED_BY_USER) { - currentState = EditedUrlState::EDITED_OTHER_FIRST; - } else { - currentState = EditedUrlState::EDITED_OTHER_MANY_TIMES; - } - } - } - EditedUrlState getCurrentState() - { - return currentState; - } -private: - EditedUrlState currentState = EditedUrlState::EDITED_BY_USER; -}; - -/** * Manages list of url matches (URL from history). Manages top layout, creates * widget displaying url items. */ class UrlHistoryList { public: - UrlHistoryList(QuickAccess* quickAccess); + UrlHistoryList(); virtual ~UrlHistoryList(); - void createLayout(Evas_Object* parentLayout); - Evas_Object* getLayout(); + Evas_Object* getContent(); + Evas_Object* getEditedEntry(); + void saveEntryEditedContent(); + void restoreEntryEditedContent(); + void saveEntryURLContent(); + void restoreEntryURLContent(); + Evas_Object* getGenlist(); + + // remove if unused + void hideWidgetPretty(); + + void setMembers(Evas_Object* parent, Evas_Object* chainObject); // // on uri entry widget "changed,user" signal void onURLEntryEditedByUser(const string& editedUrl, shared_ptr matchedEntries); - // on uri entry widget "changed" signal - void onURLEntryEdited(); + void onItemFocusChange(); void onMouseClick(); - boost::signals2::signal, bool)> openURLInNewTab; + boost::signals2::signal)> openURLInNewTab; int getVisibleItemsMax() const { @@ -105,21 +83,29 @@ public: } private: + void createLayout(Evas_Object* parentLayout); void onListItemSelect(std::string content); void onListWidgetFocused(); void onListWidgetUnfocused(); - EditedUrlStatesHelper editedUrlStatesHelper; + static void _uri_entry_editing_changed_user(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_unfocused(void* data, Evas_Object* obj, void* event_info); // the maximum items number on a list const int VISIBLE_ITEMS_MAX = 12; // the minimum length of the keyword used to search matches const int MIN_KEYWORD_LENGTH = 3; - Evas_Object* m_layout; + Evas_Object* m_parent = nullptr; + // entry widget from which change signals are received + Evas_Object* m_entry = nullptr; + // content of the entry, needed to restore edited value + string m_entryEditedContent; + // content of the entry before edition: needed to restore original URL value + string m_entryURLContent; + Evas_Object* m_layout = nullptr; string m_edjFilePath; GenlistManagerPtr m_genlistListManager = nullptr; - QuickAccess* m_quickAccess; }; diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp similarity index 100% rename from services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp rename to services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h similarity index 100% rename from services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h rename to services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index 439a59e..fef4f9d 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -21,6 +21,7 @@ #include "BrowserLogger.h" #include "ServiceManager.h" #include "BrowserAssert.h" +#include "UrlHistoryList/UrlHistoryList.h" namespace tizen_browser { namespace base_ui { @@ -35,6 +36,7 @@ WebPageUI::WebPageUI() , m_progressBar(nullptr) , m_bookmarkManagerButton(nullptr) , m_URIEntry(new URIEntry()) + , m_urlHistoryList(std::make_shared()) , m_homePageActive(false) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -62,6 +64,11 @@ Evas_Object* WebPageUI::getContent() return m_mainLayout; } +UrlHistoryPtr WebPageUI::getUrlHistoryList() +{ + return m_urlHistoryList; +} + void WebPageUI::showUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -286,6 +293,9 @@ void WebPageUI::createLayout() elm_layout_signal_callback_add(m_URIEntry->getContent(), "slide_websearch", "elm", faviconClicked, this); + elm_theme_extension_add(nullptr, edjePath("WebPageUI/UrlHistoryList.edj").c_str()); + m_urlHistoryList->setMembers(m_parent, m_URIEntry->getEntryWidget()); + connectActions(); } @@ -445,6 +455,7 @@ void WebPageUI::refreshFocusChain() m_reload->setEnabled(false); } elm_object_focus_custom_chain_append(m_mainLayout, m_URIEntry->getContent(), NULL); + elm_object_focus_custom_chain_append(m_mainLayout, m_urlHistoryList->getContent(), NULL); } } // namespace tizen_browser diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index f9c387a..712203a 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -29,6 +29,9 @@ namespace tizen_browser { namespace base_ui { +class UrlHistoryList; +typedef std::shared_ptr UrlHistoryPtr; + class BROWSER_EXPORT WebPageUI : public tizen_browser::core::AbstractService, public tizen_browser::interfaces::AbstractUIComponent { public: WebPageUI(); @@ -36,6 +39,7 @@ public: virtual std::string getName(); virtual void init(Evas_Object* parent); virtual Evas_Object* getContent(); + UrlHistoryPtr getUrlHistoryList(); virtual void showUI(); virtual void hideUI(); void loadStopped(); @@ -107,6 +111,7 @@ private: std::unique_ptr m_leftButtonBar; std::unique_ptr m_rightButtonBar; std::unique_ptr m_URIEntry; + UrlHistoryPtr m_urlHistoryList; bool m_homePageActive; sharedAction m_back; diff --git a/services/QuickAccess/edc/UrlHistoryList.edc b/services/WebPageUI/edc/UrlHistoryList.edc similarity index 78% rename from services/QuickAccess/edc/UrlHistoryList.edc rename to services/WebPageUI/edc/UrlHistoryList.edc index 9cc5fb3..156ad2e 100644 --- a/services/QuickAccess/edc/UrlHistoryList.edc +++ b/services/WebPageUI/edc/UrlHistoryList.edc @@ -1,10 +1,12 @@ +#define LIST_OFFSET_X 255 +#define LIST_OFFSET_Y 104 #define URI_INPUTBOX_LENGTH 1720 -#define URI_INPUTBOX_LENGTH_SMALL 1460 +#define URI_INPUTBOX_LENGTH_SHORT 1460 #define HISTORY_ITEM_W URI_INPUTBOX_LENGTH #define HISTORY_ITEM_H 82 #define HISTORY_ITEMS_VISIBLE_MAX 5 /* - Right now, has to be a multiple of item's height. + has to be a multiple of item's height. */ #define LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX @@ -14,41 +16,17 @@ collections { parts { part { - name: "bg"; - type: RECT; - mouse_events: 1; - description - { - color: 232 122 32 150; - state: "default" 0.0; - visible: 0; - min: URI_INPUTBOX_LENGTH LIST_MAX_H; - max: -1 -1; - align: 0.0 0.0; - fixed: 1 1; - rel1 - { - relative: 0 0; - } - rel2 - { - relative: 1.0 1.0; - } - } - } - - part { name: "list_swallow"; type: SWALLOW; description { color: 255 0 0 150; - min: URI_INPUTBOX_LENGTH LIST_MAX_H; + min: URI_INPUTBOX_LENGTH_SHORT LIST_MAX_H; max: -1 -1; visible: 1; align: 0.0 0.0; rel1 { relative: 0 0; - offset: 0 0; + offset: LIST_OFFSET_X LIST_OFFSET_Y; } rel2 { relative: 1.0 0.5; -- 2.7.4 From 1145dc8f4066ba18e2f4e32f579b40ee80471545 Mon Sep 17 00:00:00 2001 From: Albert Malewski Date: Tue, 27 Oct 2015 13:13:10 +0100 Subject: [PATCH 13/16] Cannot cancel edit mode in Tab Manager [Issue] https://bugs.tizen.org/jira/browse/TT-215 [Problem] Cannot cancel edit mode in Tab Manager. [Cause] N/A [Solution] Added onBackKey function that is called when "Back" key.: is pressed. This function switches off edit Mode. [Verify] Add few tabs > Click 'Close Tabs' > Press 'Back' key > Obs Change-Id: I83b093616e00772ba7c51c9385ccefd2cc908be6 --- services/SimpleUI/SimpleUI.cpp | 2 ++ services/TabUI/TabUI.cpp | 12 ++++++++++++ services/TabUI/TabUI.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index fc73d3a..36d9230 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -629,6 +629,8 @@ void SimpleUI::onBackPressed() BROWSER_LOGD("[%s]", __func__); if (m_zoomUI->isVisible()) { m_zoomUI->escapeZoom(); + } else if ((m_viewManager->topOfStack() == m_tabUI.get()) && m_tabUI->isEditMode()) { + m_tabUI->onBackKey(); } else if (m_webPageUI->isHomePageActive()) { m_quickAccess->backButtonClicked(); } else if ((m_viewManager->topOfStack() == m_webPageUI.get()) && !m_webPageUI->getURIEntry().hasFocus() && !m_wvIMEStatus) { diff --git a/services/TabUI/TabUI.cpp b/services/TabUI/TabUI.cpp index c258959..de525a4 100644 --- a/services/TabUI/TabUI.cpp +++ b/services/TabUI/TabUI.cpp @@ -210,6 +210,13 @@ void TabUI::_close_clicked(void* data, Evas_Object*, void*) } } +void TabUI::onBackKey() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + editMode = false; + elm_layout_text_set(elm_layout_content_get(m_tab_layout, "action_bar"), "closetabs_text", "Close Tabs"); +} + Evas_Object* TabUI::createTopButtons(Evas_Object* parent) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -433,5 +440,10 @@ void TabUI::_focus_in(void* data, Evas*, Evas_Object*, void* event_info) elm_object_item_signal_emit(it, "selected", "over3"); } +bool TabUI::isEditMode() +{ + return editMode; +} + } } diff --git a/services/TabUI/TabUI.h b/services/TabUI/TabUI.h index 7ee21a6..6ff6c71 100644 --- a/services/TabUI/TabUI.h +++ b/services/TabUI/TabUI.h @@ -45,6 +45,8 @@ public: virtual std::string getName(); void addTabItems(std::vector > items); + bool isEditMode(); + void onBackKey(); boost::signals2::signal tabClicked; boost::signals2::signal newTabClicked; -- 2.7.4 From 31f38a6786ee16e490b76e5e983f9f5f32d5814f Mon Sep 17 00:00:00 2001 From: Dariusz Frankiewicz Date: Wed, 21 Oct 2015 10:15:59 +0200 Subject: [PATCH 14/16] Fix D-pad navigation between URI bar and Webview. [Issue] https://bugs.tizen.org/jira/browse/TT-211 [Problem] Navigation on webview elements is not possible because focus go to URI bar when UP is pressed. [Cause] No webview focus lock implemented. [Solution] Implement focus auto lock on webview. [Verify] Load sample page, go by D-pad to webview, navigate on webview elements, to back to URI bar press RED button [F4 on keyboard]. Change-Id: Ia24378ac090364e43b85fba89f5fd3a42f48cc26 Signed-off-by: Dariusz Frankiewicz --- .../PlatformInputManager/PlatformInputManager.cpp | 9 ++++ .../PlatformInputManager/PlatformInputManager.h | 4 ++ services/SimpleUI/SimpleUI.cpp | 6 +++ services/SimpleUI/SimpleUI.h | 1 + services/WebPageUI/WebPageUI.cpp | 53 ++++++++++++++++++++++ services/WebPageUI/WebPageUI.h | 6 +++ 6 files changed, 79 insertions(+) diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index 8a552e9..a03efb3 100644 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -87,6 +87,15 @@ Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int ty self->backPressed(); else if(!keyName.compare("Escape")) self->escapePressed(); + else if(!keyName.compare("XF86Red")) // F4 - Red + self->redPressed(); + else if(!keyName.compare("XF86Green")) // F5 - Green + self->greenPressed(); + else if(!keyName.compare("XF86Yellow")) // F6 - Yellow + self->yellowPressed(); + else if(!keyName.compare("XF86Blue")) // F7 - Blue + self->bluePressed(); + } else if(type == ECORE_EVENT_KEY_UP) { M_ASSERT(event); Ecore_Event_Key *ev = static_cast(event); diff --git a/services/PlatformInputManager/PlatformInputManager.h b/services/PlatformInputManager/PlatformInputManager.h index 4533561..feb97b1 100644 --- a/services/PlatformInputManager/PlatformInputManager.h +++ b/services/PlatformInputManager/PlatformInputManager.h @@ -55,6 +55,10 @@ public: boost::signals2::signal rightPressed; boost::signals2::signal backPressed; boost::signals2::signal escapePressed; + boost::signals2::signal redPressed; + boost::signals2::signal greenPressed; + boost::signals2::signal yellowPressed; + boost::signals2::signal bluePressed; boost::signals2::signal mouseClicked; /** diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 36d9230..ab890cb 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -416,6 +416,7 @@ void SimpleUI::connectModelSignals() m_platformInputManager->escapePressed.connect(boost::bind(&SimpleUI::onEscapePressed, this)); m_platformInputManager->mouseClicked.connect( boost::bind(&SimpleUI::onMouseClick, this)); + m_platformInputManager->redPressed.connect(boost::bind(&SimpleUI::onRedKeyPressed, this)); } @@ -748,6 +749,11 @@ void SimpleUI::onMouseClick() m_webPageUI->getUrlHistoryList()->onMouseClick(); } +void SimpleUI::onRedKeyPressed() +{ + m_webPageUI->onRedKeyPressed(); +} + void SimpleUI::webEngineURLChanged(const std::string url) { BROWSER_LOGD("webEngineURLChanged:%s", url.c_str()); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index f50db74..1539a19 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -147,6 +147,7 @@ private: void onActionTriggered(const Action& action); void onMouseClick(); + void onRedKeyPressed(); void setwvIMEStatus(bool status); sharedAction m_showBookmarkManagerUI; diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index fef4f9d..f60578c 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -38,6 +38,7 @@ WebPageUI::WebPageUI() , m_URIEntry(new URIEntry()) , m_urlHistoryList(std::make_shared()) , m_homePageActive(false) + , m_webviewLocked(false) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } @@ -84,6 +85,12 @@ void WebPageUI::showUI() showQuickAccess(); else m_URIEntry->showPageTitle(); + + m_WebPageUIvisible = true; + + elm_object_event_callback_add(m_leftButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_add(m_rightButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_add(m_URIEntry->getContent(), _cb_down_pressed_on_urlbar, this); } @@ -102,6 +109,12 @@ void WebPageUI::hideUI() evas_object_hide(m_URIEntry->getContent()); evas_object_hide(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_left")); evas_object_hide(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_right")); + + m_WebPageUIvisible = false; + + elm_object_event_callback_del(m_leftButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_del(m_rightButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_del(m_URIEntry->getContent(), _cb_down_pressed_on_urlbar, this); } void WebPageUI::loadStarted() @@ -244,6 +257,20 @@ void WebPageUI::faviconClicked(void* data, Evas_Object*, const char*, const char } } +Eina_Bool WebPageUI::_cb_down_pressed_on_urlbar(void *data, Evas_Object */*obj*/, Evas_Object */*src*/, Evas_Callback_Type type, void *event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI* self = reinterpret_cast(data); + if(type == EVAS_CALLBACK_KEY_DOWN) { + Ecore_Event_Key *ev = static_cast(event_info); + const std::string keyName = ev->keyname; + if(!keyName.compare("Down")){ + self->lockWebview(); + } + } + return EINA_FALSE; +} + void WebPageUI::setTabsNumber(int tabs) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -254,6 +281,32 @@ void WebPageUI::setTabsNumber(int tabs) } } +void WebPageUI::lockWebview() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if(isWebPageUIvisible()) { + if(!isHomePageActive() && !isErrorPageActive()) { + elm_object_focus_custom_chain_unset(m_mainLayout); + elm_object_focus_custom_chain_append(m_mainLayout, elm_object_part_content_get(m_mainLayout, "web_view"), NULL); + m_webviewLocked = true; + } + } +} + +void WebPageUI::onRedKeyPressed() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if(isWebPageUIvisible()) { + if(!isHomePageActive()) { + if(m_webviewLocked) { + refreshFocusChain(); + m_URIEntry->setFocus(); + m_webviewLocked = false; + } + } + } +} + void WebPageUI::createLayout() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 712203a..0e88f30 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -49,6 +49,7 @@ public: bool isErrorPageActive(); bool isIncognitoPageActive(); bool isHomePageActive() { return m_homePageActive; } + bool isWebPageUIvisible() { return m_WebPageUIvisible; } void toIncognito(bool); void switchViewToErrorPage(); void switchViewToWebPage(Evas_Object* content, const std::string uri, const std::string title); @@ -62,6 +63,8 @@ public: void setReloadButtonEnabled(bool enabled) { m_reload->setEnabled(enabled); } void setStopButtonEnabled(bool enabled) { m_stopLoading->setEnabled(enabled); } void setMoreMenuButtonEnabled(bool enabled) { m_showMoreMenu->setEnabled(enabled); } + void lockWebview(); + void onRedKeyPressed(); boost::signals2::signal backPage; boost::signals2::signal forwardPage; @@ -75,6 +78,7 @@ public: boost::signals2::signal showZoomNavigation; static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source); + static Eina_Bool _cb_down_pressed_on_urlbar(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); private: void createLayout(); @@ -113,6 +117,8 @@ private: std::unique_ptr m_URIEntry; UrlHistoryPtr m_urlHistoryList; bool m_homePageActive; + bool m_webviewLocked; + bool m_WebPageUIvisible; sharedAction m_back; sharedAction m_forward; -- 2.7.4 From b0539a41d39d176c238f7025593a1e200809c15e Mon Sep 17 00:00:00 2001 From: Kamil Nowac Date: Thu, 22 Oct 2015 11:45:59 +0200 Subject: [PATCH 15/16] Update incognito mode ewk API [Issue] https://bugs.tizen.org/jira/browse/TT-230 [Problem] Using deprecated function [Solution] Added new function and reorganization of of current incognito mode solution [Verification] 1. Open page in incognito mode 2. Type URL that do not exist it the history 3. Type enter New URL shouldn't be inserted into history. 4. Close browser with ctrl+c 5. Open browser again Browser should open without the tab last opened in incognito mode. Change-Id: Ia4548e628b30d57e58f9aeee3c4563e39705ab27 --- core/AbstractWebEngine/AbstractWebEngine.h | 34 +++------- services/SimpleUI/SimpleUI.cpp | 78 ++++++---------------- services/SimpleUI/SimpleUI.h | 8 +-- .../WebKitEngineService/WebKitEngineService.cpp | 33 +-------- services/WebKitEngineService/WebKitEngineService.h | 9 +-- services/WebKitEngineService/WebView.cpp | 45 +++---------- services/WebKitEngineService/WebView.h | 13 ++-- 7 files changed, 50 insertions(+), 170 deletions(-) diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index 91da16c..bbbc8d8 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -147,10 +147,16 @@ public: /** * Adds new tab * @param uri if not empty opens specified uri + * @param openerId * @param desktopMode true if desktop mode, false if mobile mode + * @param incognitoMode true if incognito mode, false if not * @return TabId of created tab */ - virtual TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true) = 0; + virtual TabId addTab( + const std::string & uri = std::string(), + const TabId * openerId = NULL, + bool desktopMode = true, + bool incognitoMode = false) = 0; /** * @param tab id @@ -208,34 +214,12 @@ public: virtual std::shared_ptr getSnapshotData(TabId id, int width, int height) = 0; /** - * Set private mode on/off - * \param private mode on when true, off otherwise - */ - virtual void setPrivateMode(bool) = 0; - - /** - * Set the state of private mode for a specific tab - * - * \param id of snapshot - * \param state to set - */ - virtual void setPrivateMode(const TabId&, bool) = 0; - - /** - * Get the state of private mode - */ - virtual bool isPrivateMode() const = 0; - - /** * Get the state of private mode for a specific tab * * /param id of snapshot - * /return state of private mode where: - * -1 is "Not set" - * 0 is "False" - * 1 is "True" + * /return state of private mode */ - virtual int isPrivateMode(const TabId&) = 0; + virtual bool isPrivateMode(const TabId&) = 0; virtual bool isLoadError() const = 0; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index ab890cb..1e436f1 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -71,7 +71,6 @@ SimpleUI::SimpleUI() , m_tabUI() , m_initialised(false) , m_wvIMEStatus(false) - , m_incognito(false) , m_ewkContext(ewk_context_new()) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -137,7 +136,6 @@ int SimpleUI::exec(const std::string& _url) loadUIServices(); loadModelServices(); - createActions(); // initModelServices() needs to be called after initUIServices() initUIServices(); @@ -146,7 +144,6 @@ int SimpleUI::exec(const std::string& _url) connectModelSignals(); connectUISignals(); - connectActions(); //Push first view to stack. m_viewManager->pushViewToStack(m_webPageUI.get()); @@ -267,11 +264,9 @@ void SimpleUI::connectUISignals() m_tabUI->closeTabUIClicked.connect(boost::bind(&SimpleUI::closeTabUI, this)); m_tabUI->closeTabUIClicked.connect(boost::bind(&ZoomUI::showNavigation, m_zoomUI.get())); m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::newTabClicked, this)); - m_tabUI->newTabClicked.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, false)); m_tabUI->tabClicked.connect(boost::bind(&SimpleUI::tabClicked, this,_1)); m_tabUI->closeTabsClicked.connect(boost::bind(&SimpleUI::closeTabsClicked, this,_1)); - m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, true)); - m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::switchViewToIncognitoPage, this)); + m_tabUI->newIncognitoTabClicked.connect(boost::bind(&SimpleUI::openNewTab, this, "", false, true)); m_tabUI->tabsCount.connect(boost::bind(&SimpleUI::tabsCount, this)); M_ASSERT(m_historyUI.get()); @@ -420,24 +415,6 @@ void SimpleUI::connectModelSignals() } -void SimpleUI::createActions() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ///\todo Add MulitStateAction. and convert m_stopLoading and m_reload actons to it? - - m_settingPrivateBrowsing = sharedAction(new Action("Private browsing")); - m_settingPrivateBrowsing->setToolTip("On exit from private mode all cookies, history, and stored data will be deleted"); - m_settingPrivateBrowsing->setCheckable(true); - m_settingPrivateBrowsing->setChecked(m_webEngine->isPrivateMode()); - m_settingPrivateBrowsing->setEnabled(true); -} - -void SimpleUI::connectActions() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_settingPrivateBrowsing->toggled.connect(boost::bind(&SimpleUI::settingsPrivateModeSwitch, this, _1)); -} - void SimpleUI::switchViewToWebPage() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -490,17 +467,19 @@ void SimpleUI::switchViewToIncognitoPage() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); M_ASSERT(m_viewManager); - openNewTab(""); + m_webPageUI->toIncognito(true); m_webPageUI->switchViewToIncognitoPage(); m_viewManager->popStackTo(m_webPageUI.get()); } -void SimpleUI::openNewTab(const std::string &uri, bool desktopMode) +void SimpleUI::openNewTab(const std::string &uri, bool desktopMode, bool incognitoMode) { BROWSER_LOGD("[%s:%d] uri =%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str()); - tizen_browser::basic_webengine::TabId tab = m_webEngine->addTab(uri, nullptr, desktopMode); - applyPrivateModeToTab(tab); + tizen_browser::basic_webengine::TabId tab = m_webEngine->addTab(uri, nullptr, desktopMode, incognitoMode); switchToTab(tab); + m_webPageUI->toIncognito(incognitoMode); + if (incognitoMode) + switchViewToIncognitoPage(); } void SimpleUI::closeTab() @@ -592,11 +571,11 @@ void SimpleUI::onBookmarkClicked(std::shared_ptrgetAddress(); m_viewManager->popStackTo(m_webPageUI.get()); - if (!m_incognito) { + std::string bookmarkAddress = bookmarkItem->getAddress(); + if (!m_webEngine->isPrivateMode(m_webEngine->currentTabId())) openNewTab(bookmarkAddress); - } else { + else { std::string bookmarkTitle = bookmarkItem->getTittle(); m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), bookmarkAddress, bookmarkTitle); m_webEngine->setURI(bookmarkAddress); @@ -660,9 +639,8 @@ void SimpleUI::stopEnable(bool enable) void SimpleUI::loadStarted() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!m_webEngine->isPrivateMode()){ + if (!m_webEngine->isPrivateMode(m_webEngine->currentTabId())) m_currentSession.updateItem(m_webEngine->currentTabId().toString(), m_webEngine->getURI()); - } m_webPageUI->loadStarted(); } @@ -675,11 +653,13 @@ void SimpleUI::loadFinished() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!m_webEngine->isPrivateMode()){ - m_historyService->addHistoryItem(std::make_shared (m_webEngine->getURI(), + if (!m_webEngine->isPrivateMode(m_webEngine->currentTabId())) + m_historyService->addHistoryItem(std::make_shared(m_webEngine->getURI(), m_webEngine->getTitle(), - m_webEngine->getFavicon()), m_webEngine->getSnapshotData(QuickAccess::MAX_THUMBNAIL_WIDTH, QuickAccess::MAX_THUMBNAIL_HEIGHT)); - } + m_webEngine->getFavicon()), + m_webEngine->getSnapshotData( + QuickAccess::MAX_THUMBNAIL_WIDTH, + QuickAccess::MAX_THUMBNAIL_HEIGHT)); m_webPageUI->loadFinished(); } @@ -687,7 +667,7 @@ void SimpleUI::loadStopped() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!m_webEngine->isPrivateMode()) { + if (!m_webEngine->isPrivateMode(m_webEngine->currentTabId())) { m_historyService->addHistoryItem(std::make_shared( m_webEngine->getURI(), m_webEngine->getURI(), @@ -725,7 +705,7 @@ void SimpleUI::filterURL(const std::string& url) else m_webEngine->setURI(url); - if (m_incognito) + if (m_webEngine->isPrivateMode(m_webEngine->currentTabId())) switchViewToWebPage(); } m_webPageUI->getURIEntry().clearFocus(); @@ -818,6 +798,7 @@ void SimpleUI::newTabClicked() return; BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_webPageUI->toIncognito(false); switchViewToQuickAccess(); } @@ -825,7 +806,7 @@ void SimpleUI::tabClicked(const tizen_browser::basic_webengine::TabId& tabId) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_viewManager->popStackTo(m_webPageUI.get()); - applyPrivateModeToTab(tabId); + m_webPageUI->toIncognito(m_webEngine->isPrivateMode(tabId)); switchToTab(tabId); } @@ -1025,23 +1006,6 @@ void SimpleUI::closeBookmarkManagerUI() m_viewManager->popTheStack(); } -void SimpleUI::settingsPrivateModeSwitch(bool newState) -{ - BROWSER_LOGD("%s: Setting Private mode to: %s", __func__, (newState ? "true" : "false")); - m_incognito = newState; -} - -void SimpleUI::applyPrivateModeToTab(const tizen_browser::basic_webengine::TabId& tabId) -{ - if (m_webEngine->isPrivateMode(tabId) < 0) { - m_webEngine->setPrivateMode(tabId, m_incognito); - m_webPageUI->toIncognito(m_incognito); - } else { - m_webEngine->setPrivateMode(tabId, m_webEngine->isPrivateMode(tabId)); - m_webPageUI->toIncognito(m_webEngine->isPrivateMode(tabId)); - } -} - void SimpleUI::settingsDeleteSelectedData(const std::string& str) { BROWSER_LOGD("[%s]: Deleting selected data", __func__); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 1539a19..4924296 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -77,8 +77,6 @@ public: void destroyUI(); private: // setup functions - void createActions(); - void connectActions(); void loadUIServices(); void connectUISignals(); void loadModelServices(); @@ -111,7 +109,7 @@ private: void switchViewToWebPage(); void updateView(); - void openNewTab(const std::string &uri, bool desktopMode = true); + void openNewTab(const std::string &uri, bool desktopMode = true, bool incognitoMode = false); void switchToTab(const tizen_browser::basic_webengine::TabId& tabId); void newTabClicked(); void tabClicked(const tizen_browser::basic_webengine::TabId& tabId); @@ -151,7 +149,6 @@ private: void setwvIMEStatus(bool status); sharedAction m_showBookmarkManagerUI; - sharedAction m_settingPrivateBrowsing; /** * \brief filters URL before it is passed to WebEngine. @@ -220,8 +217,6 @@ private: void closeTab(); void closeTab(const tizen_browser::basic_webengine::TabId& id); - void settingsPrivateModeSwitch(bool newState); - void applyPrivateModeToTab(const tizen_browser::basic_webengine::TabId& id); void settingsDeleteSelectedData(const std::string& str); void settingsResetMostVisited(); void settingsResetBrowser(); @@ -260,7 +255,6 @@ private: int m_tabLimit; int m_favoritesLimit; bool m_wvIMEStatus; - bool m_incognito; //helper object used to view management ViewManager* m_viewManager; diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index 0e7a6ef..62e7fb4 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -42,7 +42,6 @@ EXPORT_SERVICE(WebKitEngineService, "org.tizen.browser.webkitengineservice") WebKitEngineService::WebKitEngineService() : m_initialised(false) - , m_privateMode(false) , m_stopped(false) , m_guiParent(nullptr) , m_currentTabId(TabId::NONE) @@ -303,7 +302,7 @@ std::vector > WebKitEngineService::getTabContents() return result; } -TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerId, bool desktopMode) +TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerId, bool desktopMode, bool incognitoMode) { AbstractWebEngine::checkIfCreate(); @@ -317,7 +316,7 @@ TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerI // searching for next available tabId TabId newTabId; - WebViewPtr p = std::make_shared(reinterpret_cast(m_guiParent), newTabId); + WebViewPtr p = std::make_shared(reinterpret_cast(m_guiParent), newTabId, incognitoMode); if (openerId) p->init(desktopMode, getTabView(*openerId)); else @@ -425,38 +424,12 @@ void WebKitEngineService::confirmationResult(WebConfirmationPtr c) m_tabs[c->getTabId()]->confirmationResult(c); } -void WebKitEngineService::setPrivateMode(bool state) -{ - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - - if (m_privateMode == state) { - BROWSER_LOGD("%s:%d %s new privateMode is the same", __FILE__, __LINE__, __func__); - return; - } - - m_privateMode = state; - - for(std::map::iterator it = m_tabs.begin(), end = m_tabs.end(); it != end; ++it) - it->second->setPrivateMode(state); -} - -void WebKitEngineService::setPrivateMode(const TabId& id, bool state) -{ - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - m_tabs[id]->setPrivateMode(state); -} - -int WebKitEngineService::isPrivateMode(const TabId& id) +bool WebKitEngineService::isPrivateMode(const TabId& id) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); return m_tabs[id]->isPrivateMode(); } -bool WebKitEngineService::isPrivateMode() const -{ - return m_privateMode; -} - std::shared_ptr WebKitEngineService::getSnapshotData(int width, int height) { M_ASSERT(m_currentWebView); diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index a60af08..beb9053 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -81,7 +81,7 @@ public: * @param uri * @return TabId of created tab */ - TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true); + TabId addTab(const std::string & uri = std::string(), const TabId * openerId = NULL, bool desktopMode = true, bool incognitoMode = false); Evas_Object* getTabView(TabId id); bool switchToTab(TabId); bool closeTab(); @@ -111,10 +111,6 @@ public: std::shared_ptr getSnapshotData(TabId id, int width, int height); - void setPrivateMode(bool); - void setPrivateMode(const TabId& id, bool state); - bool isPrivateMode() const; - /** * @brief Get the state of private mode for a specific tab * @@ -124,7 +120,7 @@ public: * 0 is "False" * 1 is "True" */ - int isPrivateMode(const TabId& id); + bool isPrivateMode(const TabId& id); /** @@ -213,7 +209,6 @@ private: private: bool m_initialised; - bool m_privateMode; void * m_guiParent; bool m_stopped; diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index b81a334..988d24d 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -63,7 +63,7 @@ namespace webkitengine_service { const std::string WebView::COOKIES_PATH = "cookies"; -WebView::WebView(Evas_Object * obj, TabId tabId) +WebView::WebView(Evas_Object * obj, TabId tabId, bool incognitoMode) : m_parent(obj) , m_tabId(tabId) , m_ewkView(nullptr) @@ -72,7 +72,7 @@ WebView::WebView(Evas_Object * obj, TabId tabId) , m_isLoading(false) , m_loadError(false) , m_suspended(false) - , m_private(-1) + , m_private(incognitoMode) { config.load("whatever"); } @@ -92,7 +92,14 @@ void WebView::init(bool desktopMode, Evas_Object*) { #if defined(USE_EWEBKIT) M_ASSERT(m_ewkContext); - m_ewkView = ewk_view_add_with_context(evas_object_evas_get(m_parent), m_ewkContext); + + m_ewkView = m_private ? ewk_view_add_in_incognito_mode(evas_object_evas_get(m_parent)) : + ewk_view_add_with_context(evas_object_evas_get(m_parent), m_ewkContext); + + Ewk_Context *context = ewk_view_context_get(m_ewkView); + if (context) + m_private ? ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_NEVER) : + ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); evas_object_data_set(m_ewkView, "_container", this); BROWSER_LOGD("%s:%d %s self=%p", __FILE__, __LINE__, __func__, this); @@ -311,38 +318,6 @@ bool WebView::isLoadError() const return m_loadError; } -void WebView::setPrivateMode(bool state) -{ - BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - M_ASSERT(m_ewkView); - if(m_private < 0){ -#if defined(USE_EWEBKIT) -#if PLATFORM(TIZEN) - Ewk_Settings * settings = ewk_view_settings_get(m_ewkView); -#else - Ewk_Settings * settings = ewk_page_group_settings_get(ewk_view_page_group_get(m_ewkView)); -#endif - ewk_settings_private_browsing_enabled_set(settings, state); - if (m_ewkView) - { - Ewk_Context *context = ewk_view_context_get(m_ewkView); - if (context) - { - if(state) - { - ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_NEVER); - } - else - { - ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - } - } - } -#endif - m_private = static_cast(state); - } -} - void WebView::confirmationResult(WebConfirmationPtr confirmation) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index f6aa423..f73919a 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -39,7 +39,7 @@ namespace webkitengine_service { class WebView { public: - WebView(Evas_Object *, TabId); + WebView(Evas_Object *, TabId, bool incognitoMode); virtual ~WebView(); void init(bool desktopMode, Evas_Object * opener = NULL); @@ -68,17 +68,12 @@ public: void confirmationResult(WebConfirmationPtr); - void setPrivateMode(bool); - /** * @brief Get the state of private mode * - * @return state of private mode where: - * -1 is "Not set" - * 0 is "False" - * 1 is "True" + * @return state of private mode */ - int isPrivateMode() {return m_private;} + bool isPrivateMode() {return m_private;} std::shared_ptr captureSnapshot(int width, int height); /** @@ -227,7 +222,7 @@ private: // true if desktop view is enabled, false if mobile bool m_desktopMode; bool m_suspended; - int m_private; + bool m_private; config::DefaultConfig config; -- 2.7.4 From d88819cde85d5c7e9688346abfc3a2d129c4a7f5 Mon Sep 17 00:00:00 2001 From: posial Date: Fri, 23 Oct 2015 15:44:57 +0200 Subject: [PATCH 16/16] Prepare running unit tests [Issue] https://bugs.tizen.org/jira/browse/TT-166 [Problem] When running unit tests segfault occurs and could not start browser [Solution] Remove unneeded files and disable corrupted test. [Verification] Build and run unit tests. Note that still there are some failing cases. Change-Id: If89a56e79015a29418974d6da012824245ec892c --- packaging/org.tizen.browser.spec | 4 - unit_tests/CMakeLists.txt | 4 +- unit_tests/Services/CMakeLists.txt | 81 ------------ unit_tests/Services/DirectAccess.cpp | 95 -------------- unit_tests/Services/IndirectAccess.cpp | 89 ------------- unit_tests/Services/ServiceInterface.cpp | 27 ---- unit_tests/Services/ServiceInterface.h | 34 ----- unit_tests/Services/TestServiceOne/CMakeLists.txt | 19 --- .../Services/TestServiceOne/TestServiceOne.cpp | 49 -------- .../Services/TestServiceOne/TestServiceOne.h | 47 ------- unit_tests/Services/TestServiceTwo/CMakeLists.txt | 19 --- .../Services/TestServiceTwo/TestServiceTwo.cpp | 49 -------- .../Services/TestServiceTwo/TestServiceTwo.h | 47 ------- unit_tests/ut_Action.cpp | 22 ++++ unit_tests/ut_BookmarkItem.cpp | 11 +- unit_tests/ut_Config.cpp | 26 +++- unit_tests/ut_FavoriteService.cpp | 30 +++-- unit_tests/ut_PlatformInputManager.cpp | 8 +- unit_tests/ut_SessionStorage.cpp | 25 +++- unit_tests/ut_StorageService.cpp | 9 +- unit_tests/ut_WebKitEngineService.cpp | 139 ++++++++++++++++----- unit_tests/ut_coreService.cpp | 18 ++- unit_tests/ut_logger.cpp | 9 ++ 23 files changed, 233 insertions(+), 628 deletions(-) delete mode 100644 unit_tests/Services/CMakeLists.txt delete mode 100644 unit_tests/Services/DirectAccess.cpp delete mode 100644 unit_tests/Services/IndirectAccess.cpp delete mode 100644 unit_tests/Services/ServiceInterface.cpp delete mode 100644 unit_tests/Services/ServiceInterface.h delete mode 100644 unit_tests/Services/TestServiceOne/CMakeLists.txt delete mode 100644 unit_tests/Services/TestServiceOne/TestServiceOne.cpp delete mode 100644 unit_tests/Services/TestServiceOne/TestServiceOne.h delete mode 100644 unit_tests/Services/TestServiceTwo/CMakeLists.txt delete mode 100644 unit_tests/Services/TestServiceTwo/TestServiceTwo.cpp delete mode 100644 unit_tests/Services/TestServiceTwo/TestServiceTwo.h diff --git a/packaging/org.tizen.browser.spec b/packaging/org.tizen.browser.spec index 7fd35cf..d131e9c 100644 --- a/packaging/org.tizen.browser.spec +++ b/packaging/org.tizen.browser.spec @@ -115,9 +115,6 @@ chmod -R 660 /opt/usr/data/webkit %defattr(-,root,root,-) %{_appdir}/bin/browser %{_appdir}/res/edje/*/*.edj -%if %BUILD_UT == "ON" -%exclude %{_appdir}/services/libTestService* -%endif %{_appdir}/services/* %{_appdir}/lib/* %defattr(-,app,app,-) @@ -137,6 +134,5 @@ BrowserAPP Unit Tests. %files ut %defattr(-,root,root,-) %{_appdir}/bin/browser-ut -%{_appdir}/services/libTestService* %endif diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 2f95cd9..febe51d 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -1,7 +1,6 @@ project(browser-ut) cmake_minimum_required(VERSION 2.8) -add_subdirectory(Services) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) include(Coreheaders) @@ -31,8 +30,7 @@ set(UNIT_TESTS_SRCS ut_StorageService.cpp ut_coreService.cpp ut_SessionStorage.cpp - Services/ServiceInterface.cpp - ut_WebKitEngineService.cpp +# ut_WebKitEngineService.cpp ) if(TIZEN_BUILD) diff --git a/unit_tests/Services/CMakeLists.txt b/unit_tests/Services/CMakeLists.txt deleted file mode 100644 index 815a7ad..0000000 --- a/unit_tests/Services/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -project(ServicesTest) - -add_subdirectory(TestServiceOne) -add_subdirectory(TestServiceTwo) - -#include(Coreheaders) - - - - - - - - - - - - - -####### INDIRECT ACCESS ########################### -#add_executable(indirectAccess ServiceInterface.cpp IndirectAccess.cpp) - -#add_dependencies(indirectAccess ServiceManager) -#add_dependencies(indirectAccess logger) -#add_dependencies(indirectAccess Config) - -#target_link_libraries(indirectAccess browserCore) - -#install(TARGETS indirectAccess RUNTIME DESTINATION bin) -######## END INDIRECT ACCESS ####################### - - - - - - - - - - - - - - - -####### DIRECT ACCESS ############################## -#add_executable(directAccess ServiceInterface.cpp DirectAccess.cpp) -#add_dependencies(directAccess ServiceManager) -#add_dependencies(directAccess logger) -#add_dependencies(directAccess Config) -#add_dependencies(directAccess TestServiceTwo) - -#target_link_libraries(directAccess browserCore) - -# TestServiceTwo is accessed directly so it requires linking -#target_link_libraries(directAccess TestServiceTwo) - -#install(TARGETS directAccess RUNTIME DESTINATION bin) -####### END DIRECT ACCESS ########################### - - - - - - - - - - - - - - - - - - - - - - diff --git a/unit_tests/Services/DirectAccess.cpp b/unit_tests/Services/DirectAccess.cpp deleted file mode 100644 index 6575fbb..0000000 --- a/unit_tests/Services/DirectAccess.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - -#include -#include - -#include "BrowserLogger.h" - -// for tests... -#include "Lifecycle.h" -#include "ServiceManager.h" - - -//Direct access requires service headers -#include "TestServiceTwo/TestServiceTwo.h" - -int main() try -{ - BEGIN() -#ifndef NDEBUG - //Initialization of logger module - tizen_browser::logger::Logger::getInstance().init(); - tizen_browser::logger::Logger::getInstance().setLogTag("DirectAccess Test"); -#endif - BROWSER_LOGD("BROWSER IS SAYING HELLO"); - //get the ServiceManager - tizen_browser::core::ServiceManager *svm = &tizen_browser::core::ServiceManager::getInstance(); - - //Sevice1 we will access indirectly - ///\todo: simplify casting! - std::shared_ptr service1 - = std::dynamic_pointer_cast - < - ServiceInterface,//casting to ServiceInterface - tizen_browser::core::AbstractService - > - (svm->getService("org.tizen.browser.TestServiceOne")); - - //Service2 we will access directly - std::shared_ptr service2 - = std::dynamic_pointer_cast - < - TestServiceTwo,//casting directly to explicit service - tizen_browser::core::AbstractService - > - (svm->getService("org.tizen.browser.TestServiceTwo")); - - if(service1){ - BROWSER_LOGD(service1->getName().c_str() ); - BROWSER_LOGD("%p" , service1.get() ); - service1->isRunning(); - - service1->isRunning(); - service1->run(); - service1->isRunning(); - service1->stop(); - service1->isRunning(); - } - - - if(service2){ - BROWSER_LOGD(service2->getName().c_str() ); - BROWSER_LOGD("%p", service2.get() ); - service2->isRunning(); - - service2->isRunning(); - service2->run(); - service2->isRunning(); - service2->stop(); - service2->isRunning(); - } - - END() - -} catch (std::exception & e) -{ - std::cerr << "UNHANDLED EXCEPTION " << e.what() << std::endl; -} catch (...) -{ - std::cerr << "UNHANDLED EXCEPTION" << std::endl; -} - diff --git a/unit_tests/Services/IndirectAccess.cpp b/unit_tests/Services/IndirectAccess.cpp deleted file mode 100644 index 58537c9..0000000 --- a/unit_tests/Services/IndirectAccess.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - -#include -#include "BrowserLogger.h" - -// for tests... -#include "Lifecycle.h" -#include "ServiceManager.h" -#include "ServiceInterface.h" - - -int main() try -{ - BEGIN() -#ifndef NDEBUG - //Initialization of logger module - tizen_browser::logger::Logger::getInstance().init(); - tizen_browser::logger::Logger::getInstance().setLogTag("IndirectAccess.cpp"); -#endif - BROWSER_LOGD("BROWSER IS SAYING HELLO"); - tizen_browser::core::ServiceManager *svm = &tizen_browser::core::ServiceManager::getInstance(); - - - - std::shared_ptr service1 - = std::dynamic_pointer_cast - < - ServiceInterface, - tizen_browser::core::AbstractService - > - (svm->getService("org.tizen.browser.TestServiceOne")); - - - - std::shared_ptr service2 - = std::dynamic_pointer_cast - < - ServiceInterface, - tizen_browser::core::AbstractService - > - (svm->getService("org.tizen.browser.TestServiceTwo")); - - if(service1){ - BROWSER_LOGD(service1->getName().c_str()); - BROWSER_LOGD("%p", service1.get() ); - service1->isRunning(); - - service1->isRunning(); - service1->run(); - service1->isRunning(); - service1->stop(); - service1->isRunning(); - } - if(service2){ - BROWSER_LOGD(service2->getName().c_str() ); - BROWSER_LOGD("%p" , service2.get() ); - service2->isRunning(); - - service2->isRunning(); - service2->run(); - service2->isRunning(); - service2->stop(); - service2->isRunning(); - } - - END() - -} catch (std::exception & e) -{ - std::cerr << "UNHANDLED EXCEPTION " << e.what() << std::endl ; -} catch (...) -{ - std::cerr << "UNHANDLED EXCEPTION" << std::endl; -} - diff --git a/unit_tests/Services/ServiceInterface.cpp b/unit_tests/Services/ServiceInterface.cpp deleted file mode 100644 index 3d41a4a..0000000 --- a/unit_tests/Services/ServiceInterface.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - -#include "ServiceInterface.h" - -ServiceInterface::ServiceInterface() -{ - -} - -ServiceInterface::~ServiceInterface() -{ - -} diff --git a/unit_tests/Services/ServiceInterface.h b/unit_tests/Services/ServiceInterface.h deleted file mode 100644 index 1893e3e..0000000 --- a/unit_tests/Services/ServiceInterface.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - -#ifndef SERVICEINTERFACE_H -#define SERVICEINTERFACE_H - -#include "AbstractService.h" -#include "ServiceFactory.h" -#include "service_macros.h" - -class ServiceInterface : public tizen_browser::core::AbstractService -{ -public: - ServiceInterface(); - virtual ~ServiceInterface(); - virtual void run() = 0; - virtual void stop() = 0 ; - virtual bool isRunning() = 0; -}; - -#endif // SERVICEINTERFACE_H diff --git a/unit_tests/Services/TestServiceOne/CMakeLists.txt b/unit_tests/Services/TestServiceOne/CMakeLists.txt deleted file mode 100644 index bae3bb3..0000000 --- a/unit_tests/Services/TestServiceOne/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -project(TestServiceOne) - -set(TestServiceOne_SRCS - TestServiceOne.cpp - ) - -set(TestServiceOne_HEDS - TestServiceOne.h - ) - -include(Coreheaders) - - -add_library(${PROJECT_NAME} SHARED ${TestServiceOne_SRCS}) - - -install(TARGETS ${PROJECT_NAME} - LIBRARY DESTINATION services - ARCHIVE DESTINATION services/static) diff --git a/unit_tests/Services/TestServiceOne/TestServiceOne.cpp b/unit_tests/Services/TestServiceOne/TestServiceOne.cpp deleted file mode 100644 index 85d5572..0000000 --- a/unit_tests/Services/TestServiceOne/TestServiceOne.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - -#include "TestServiceOne.h" -#include "service_macros.h" -#include "boost/test/unit_test.hpp" - - -TestServiceOne::TestServiceOne() - : m_isRunning(false) -{ - -} - -TestServiceOne::~TestServiceOne() -{ - BOOST_TEST_MESSAGE(__PRETTY_FUNCTION__); -} - -bool TestServiceOne::isRunning() -{ - BOOST_TEST_MESSAGE(std::string(__PRETTY_FUNCTION__) + "->" + (m_isRunning ? "true": "false")); - return m_isRunning; -} - -void TestServiceOne::run() -{ - BOOST_TEST_MESSAGE(__PRETTY_FUNCTION__); - m_isRunning=true; -} - -void TestServiceOne::stop() -{ - BOOST_TEST_MESSAGE(__PRETTY_FUNCTION__); - m_isRunning=false; -} diff --git a/unit_tests/Services/TestServiceOne/TestServiceOne.h b/unit_tests/Services/TestServiceOne/TestServiceOne.h deleted file mode 100644 index a5ee6a3..0000000 --- a/unit_tests/Services/TestServiceOne/TestServiceOne.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - -#ifndef TESTMASTER_H -#define TESTMASTER_H - -#include - -#include "AbstractService.h" -#include "ServiceFactory.h" -#include "service_macros.h" -#include "../ServiceInterface.h" -#include "Lifecycle.h" - - -class BROWSER_EXPORT TestServiceOne : public ServiceInterface , ShowLifeCycle -{ -public: - TestServiceOne(); - //TestMaster(const AbstractService::AgrsMap& args); - virtual ~TestServiceOne(); - void run(); - void stop(); - bool isRunning(); - virtual std::string getName(); -private: - bool m_isRunning; -}; - - -EXPORT_SERVICE(TestServiceOne, "org.tizen.browser.TestServiceOne") - - -#endif // TESTMASTER_H diff --git a/unit_tests/Services/TestServiceTwo/CMakeLists.txt b/unit_tests/Services/TestServiceTwo/CMakeLists.txt deleted file mode 100644 index 8763ba3..0000000 --- a/unit_tests/Services/TestServiceTwo/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -project(TestServiceTwo) - -set(TestServiceTwo_SRCS - TestServiceTwo.cpp - ) - -set(TestServiceTwo_HEDS - TestServiceTwo.h - ) - -include(Coreheaders) - - -add_library(${PROJECT_NAME} SHARED ${TestServiceTwo_SRCS}) - - -install(TARGETS ${PROJECT_NAME} - LIBRARY DESTINATION services - ARCHIVE DESTINATION services/static) diff --git a/unit_tests/Services/TestServiceTwo/TestServiceTwo.cpp b/unit_tests/Services/TestServiceTwo/TestServiceTwo.cpp deleted file mode 100644 index 8a123ae..0000000 --- a/unit_tests/Services/TestServiceTwo/TestServiceTwo.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - - -#include "TestServiceTwo.h" -#include "service_macros.h" -#include - -TestServiceTwo::TestServiceTwo() - : m_isRunning(false) -{ - -} - -TestServiceTwo::~TestServiceTwo() -{ - BOOST_TEST_MESSAGE(__PRETTY_FUNCTION__); -} - -bool TestServiceTwo::isRunning() -{ - BOOST_TEST_MESSAGE(std::string(__PRETTY_FUNCTION__) + "->" + (m_isRunning ? "true": "false")); - return m_isRunning; -} - -void TestServiceTwo::run() -{ - BOOST_TEST_MESSAGE(__PRETTY_FUNCTION__); - m_isRunning=true; -} - -void TestServiceTwo::stop() -{ - BOOST_TEST_MESSAGE(__PRETTY_FUNCTION__); - m_isRunning=false; -} diff --git a/unit_tests/Services/TestServiceTwo/TestServiceTwo.h b/unit_tests/Services/TestServiceTwo/TestServiceTwo.h deleted file mode 100644 index adbf102..0000000 --- a/unit_tests/Services/TestServiceTwo/TestServiceTwo.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ - -#ifndef TESTMASTER_H -#define TESTMASTER_H - -#include - -#include "AbstractService.h" -#include "ServiceFactory.h" -#include "service_macros.h" -#include "../ServiceInterface.h" -#include "Lifecycle.h" - - -class BROWSER_EXPORT TestServiceTwo : public ServiceInterface, ShowLifeCycle -{ -public: - TestServiceTwo(); - //TestMaster(const AbstractService::AgrsMap& args); - virtual ~TestServiceTwo(); - void run(); - void stop(); - bool isRunning(); - virtual std::string getName(); -private: - bool m_isRunning; -}; - - -EXPORT_SERVICE(TestServiceTwo, "org.tizen.browser.TestServiceTwo") - - -#endif // TESTMASTER_H diff --git a/unit_tests/ut_Action.cpp b/unit_tests/ut_Action.cpp index 597bbe0..093cf49 100644 --- a/unit_tests/ut_Action.cpp +++ b/unit_tests/ut_Action.cpp @@ -21,11 +21,15 @@ #include #include "Action.h" +#include "BrowserLogger.h" + BOOST_AUTO_TEST_SUITE(action) BOOST_AUTO_TEST_CASE(action_constructors) { + BROWSER_LOGI("[UT] Action - action_constructor - START --> "); + tizen_browser::base_ui::Action action_01; BOOST_CHECK_EQUAL(action_01.isEnabled(), true); BOOST_CHECK_EQUAL(action_01.isCheckable(), false); @@ -58,9 +62,12 @@ BOOST_AUTO_TEST_CASE(action_constructors) BOOST_CHECK_EQUAL(action_04.getText(), a04_text); BOOST_CHECK_EQUAL(action_04.getIcon(), a04_icon); + BROWSER_LOGI("[UT] --> END - Action - action_constructor"); } + BOOST_AUTO_TEST_CASE(action_get_and_set){ + BROWSER_LOGI("[UT] Action - action_get_and_set - START --> "); std::string iconText("iconText"); std::string text("text"); @@ -87,10 +94,14 @@ BOOST_AUTO_TEST_CASE(action_get_and_set){ BOOST_CHECK_EQUAL(action.getIcon(), icon); BOOST_CHECK_EQUAL(action.getSelIcon(), selIcon); BOOST_CHECK_EQUAL(action.getDisIcon(), disIcon); + + BROWSER_LOGI("[UT] --> END - Action - action_get_and_set"); } BOOST_AUTO_TEST_CASE(action_bool_behaviour){ + BROWSER_LOGI("[UT] Action - action_bool_behaviour - START --> "); + tizen_browser::base_ui::Action action_01; //action is not checkable by defalut, //this call should be ignored. @@ -108,9 +119,13 @@ BOOST_AUTO_TEST_CASE(action_bool_behaviour){ action_02.toggle(); BOOST_CHECK_EQUAL(action_02.isChecked(), false); + BROWSER_LOGI("[UT] --> END - Action - action_bool_behaviour"); } BOOST_AUTO_TEST_CASE(action_trigger_test){ + + BROWSER_LOGI("[UT] Action - action_trigger_test - START --> "); + struct TriggerHandler{ TriggerHandler() :beenCalled(false){}; @@ -130,9 +145,14 @@ BOOST_AUTO_TEST_CASE(action_trigger_test){ action_01.triggered.connect(boost::ref(triggered)); action_01.trigger(); BOOST_CHECK_EQUAL(triggered.beenCalled, true); + + BROWSER_LOGI("[UT] --> END - Action - action_trigger_test"); } BOOST_AUTO_TEST_CASE(action_togle_test){ + + BROWSER_LOGI("[UT] Action - action_togle_test - START --> "); + struct ToggleHandler{ ToggleHandler() :isChecked(false),beenCalled(false){}; @@ -155,6 +175,8 @@ BOOST_AUTO_TEST_CASE(action_togle_test){ action.toggle(); BOOST_CHECK_EQUAL(toggelHandler.beenCalled, true); BOOST_CHECK_EQUAL(action.isChecked(), toggelHandler.isChecked); + + BROWSER_LOGI("[UT] --> END - Action - action_togle_test"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_BookmarkItem.cpp b/unit_tests/ut_BookmarkItem.cpp index 5c8c7ad..b5336a3 100644 --- a/unit_tests/ut_BookmarkItem.cpp +++ b/unit_tests/ut_BookmarkItem.cpp @@ -27,8 +27,8 @@ BOOST_AUTO_TEST_SUITE(bookmark_item) BOOST_AUTO_TEST_CASE(bookm_item_set_get) { - BROWSER_LOGI("BOOKMARK_ITEM_TEST_CASE START --> "); - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGI("[UT] BookmarkItem - bookm_item_set_get - START --> "); + std::string retstr = ""; std::unique_ptr bitem(new tizen_browser::services::BookmarkItem()); @@ -54,11 +54,14 @@ BOOST_AUTO_TEST_CASE(bookm_item_set_get) BOOST_CHECK_EQUAL(0, bitem->getId()); bitem->setId(9999); BOOST_CHECK_EQUAL(9999, bitem->getId()); + + BROWSER_LOGI("[UT] --> END - BookmarkItem - bookm_item_set_get"); } BOOST_AUTO_TEST_CASE(bookm_item_favicon_thumb) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGI("[UT] BookmarkItem - bookm_item_favicon_thumb - START --> "); + std::unique_ptr bitem(new tizen_browser::services::BookmarkItem()); std::shared_ptr bimg @@ -78,7 +81,7 @@ BOOST_AUTO_TEST_CASE(bookm_item_favicon_thumb) BOOST_CHECK_EQUAL(10, bitem->getThumbnail()->height); BOOST_CHECK_EQUAL(500, bitem->getThumbnail()->dataSize); - BROWSER_LOGI("<-- BOOKMARK_ITEM_TEST_CASE END"); + BROWSER_LOGI("[UT] --> END - BookmarkItem - bookm_item_favicon_thumb"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_Config.cpp b/unit_tests/ut_Config.cpp index e9233ea..447507a 100644 --- a/unit_tests/ut_Config.cpp +++ b/unit_tests/ut_Config.cpp @@ -30,10 +30,14 @@ #include "BrowserLogger.h" #include "Config.h" +#define TAG "[UT] Config - " + BOOST_AUTO_TEST_SUITE(config) BOOST_AUTO_TEST_CASE(config_simple_get_set) { + BROWSER_LOGI(TAG "config_simple_get_set - START --> "); + std::unique_ptr defconf(new tizen_browser::config::DefaultConfig()); BOOST_CHECK(defconf); @@ -44,6 +48,8 @@ BOOST_AUTO_TEST_CASE(config_simple_get_set) defconf->set("intTestKey", testval); int retval = boost::any_cast(defconf->get(std::string("intTestKey"))); BOOST_CHECK_EQUAL(testval, retval); + + BROWSER_LOGI(TAG "Config - config_simple_get_set"); } /* @@ -51,6 +57,8 @@ BOOST_AUTO_TEST_CASE(config_simple_get_set) */ BOOST_AUTO_TEST_CASE(config_load_store) { + BROWSER_LOGI(TAG "config_load_store - START --> "); + std::unique_ptr configuration1(new tizen_browser::config::DefaultConfig()); std::unique_ptr configuration2(new tizen_browser::config::DefaultConfig()); BOOST_CHECK(&configuration1); @@ -66,12 +74,14 @@ BOOST_AUTO_TEST_CASE(config_load_store) retstring = boost::any_cast(configuration2->get(std::string("userInterface"))); } catch(boost::bad_any_cast & e){ /// \todo Need to resolve bad type (void *) from boost::any(empty_string)) - BROWSER_LOGI("[i] Catched error, msg: %s",e.what()); - BROWSER_LOGI("[i] std::map not found map[key] and returns NULL to boost::any_cast as type (void*) instead of std::string (this case)\n"); + BROWSER_LOGI(TAG "[i] Catched error, msg: %s",e.what()); + BROWSER_LOGI(TAG "[i] std::map not found map[key] and returns NULL to boost::any_cast as type (void*) instead of std::string (this case)\n"); } /// \todo Below test should be enabled when saving and loading to/from config file will be implemented. /// BOOST_CHECK_EQUAL(teststr, retstring); configuration2.reset(); + + BROWSER_LOGI(TAG "--> END - config_load_store"); } @@ -80,6 +90,8 @@ BOOST_AUTO_TEST_CASE(config_load_store) */ BOOST_AUTO_TEST_CASE(config_boundary_conditions) { + BROWSER_LOGI(TAG "config_boundary_conditions - START --> "); + std::unique_ptr configuration(new tizen_browser::config::DefaultConfig()); BOOST_CHECK(&configuration); std::string retstring; @@ -91,8 +103,8 @@ BOOST_AUTO_TEST_CASE(config_boundary_conditions) retany = configuration->get(NULL); } catch(std::logic_error & e){ /// \todo get() function expects string and cannot construct empty string from NULL - BROWSER_LOGI("[i] Catched error, msg: %s",e.what()); - BROWSER_LOGI("[i] get() function expects string and cannot construct empty string from NULL\n"); + BROWSER_LOGI(TAG "[i] Catched error, msg: %s",e.what()); + BROWSER_LOGI(TAG "[i] get() function expects string and cannot construct empty string from NULL\n"); } try{ @@ -100,8 +112,8 @@ BOOST_AUTO_TEST_CASE(config_boundary_conditions) BOOST_CHECK(retstring.empty()); }catch(boost::bad_any_cast & e){ /// \todo Need to resolve bad type (void *) from boost::any(empty_string)) - BROWSER_LOGI("[i] Catched error, msg: %s",e.what()); - BROWSER_LOGI("[i] std::map not found map[key] and returns NULL to boost::any_cast as type (void*) instead of std::string (this case)\n"); + BROWSER_LOGI(TAG "[i] Catched error, msg: %s",e.what()); + BROWSER_LOGI(TAG "[i] std::map not found map[key] and returns NULL to boost::any_cast as type (void*) instead of std::string (this case)\n"); } configuration->set(std::string(""), std::string("value")); retstring = boost::any_cast(configuration->get(std::string(""))); @@ -136,6 +148,8 @@ BOOST_AUTO_TEST_CASE(config_boundary_conditions) retstring = boost::any_cast(configuration->get(std::string("SameTestKey"))); BOOST_CHECK_EQUAL(std::string("valueB"), retstring); BOOST_CHECK_PREDICATE( std::not_equal_to(), (retstring)(std::string("valueA")) ); + + BROWSER_LOGI(TAG "--> END - config_boundary_conditions"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_FavoriteService.cpp b/unit_tests/ut_FavoriteService.cpp index fbaa74b..aab513f 100644 --- a/unit_tests/ut_FavoriteService.cpp +++ b/unit_tests/ut_FavoriteService.cpp @@ -30,6 +30,7 @@ #include "BookmarkService.h" #include "BookmarkItem.h" +#define TAG "[UT] Bookmarks - " BOOST_AUTO_TEST_SUITE(bookmarks) @@ -37,7 +38,8 @@ bool item_is_empty(std::shared_ptr item) BOOST_AUTO_TEST_CASE(bookmark_add_remove) { - BROWSER_LOGI("BOOKMARKS_TEST_CASE START --> "); + BROWSER_LOGI(TAG "bookmark_add_remove - START --> "); + /// \todo: clean casts, depends on ServiceManager std::shared_ptr fs = @@ -59,25 +61,25 @@ BOOST_AUTO_TEST_CASE(bookmark_add_remove) std::vector> bookmarks_list = fs->getBookmarks(); while(!bookmarks_list.empty()) { bitem = bookmarks_list.back(); - BROWSER_LOGI("Element from cached bookmark list: id: %d, tittle: %s, URL: %s", bitem->getId(), + BROWSER_LOGI(TAG "Element from cached bookmark list: id: %d, tittle: %s, URL: %s", bitem->getId(), bitem->getTittle().c_str(), bitem->getAddress().c_str()); bookmarks_list.pop_back(); } - BROWSER_LOGI("Above - current stored bookmarks (recently adder order"); + BROWSER_LOGI(TAG "Above - current stored bookmarks (recently adder order"); // clean all bookmarks resultflag = fs->deleteAllBookmarks(); BOOST_CHECK(resultflag); fs->getBookmarks(); - BROWSER_LOGI("Above - current stored bookmarks after deleteAll, deleting resultflag: %d", resultflag); + BROWSER_LOGI(TAG "Above - current stored bookmarks after deleteAll, deleting resultflag: %d", resultflag); // Empty bookmark test bookcount = fs->countBookmarks(); BOOST_CHECK(item_is_empty(fs->addToBookmarks("",""))); bookcount2 = fs->countBookmarks(); BOOST_CHECK_EQUAL(bookcount, bookcount2); - BROWSER_LOGI("Add empty bookmark test summary - number of bookmarks before: %d, after: %d", bookcount ,bookcount2); + BROWSER_LOGI(TAG "Add empty bookmark test summary - number of bookmarks before: %d, after: %d", bookcount ,bookcount2); fs->getBookmarks(); // Add bookmark with the same tittle @@ -86,28 +88,32 @@ BOOST_AUTO_TEST_CASE(bookmark_add_remove) std::shared_ptr item_to_delete = fs->addToBookmarks("www.thisis.url5","Tittle"); BOOST_CHECK(!item_is_empty(item_to_delete)); fs->getBookmarks(); - BROWSER_LOGI("Before delete last bookmark (%s)", item_to_delete->getAddress().c_str()); + BROWSER_LOGI(TAG "Before delete last bookmark (%s)", item_to_delete->getAddress().c_str()); BOOST_CHECK(fs->deleteBookmark(item_to_delete->getAddress())); - BROWSER_LOGI("After delete bookmark"); + BROWSER_LOGI(TAG "After delete bookmark"); fs->getBookmarks(); // Add duplicated url - BROWSER_LOGI("Add duplicated url"); + BROWSER_LOGI(TAG "Add duplicated url"); BOOST_CHECK(item_is_empty(fs->addToBookmarks("www.thisis.url4","Not duplicateTittle"))); fs->getBookmarks(); // check existing url resultflag = fs->bookmarkExists("www.not_existing.url"); - BROWSER_LOGI("Check not existing url (%s) resultflag: %d", "www.not_existing.url", resultflag); + BROWSER_LOGI(TAG "Check not existing url (%s) resultflag: %d", "www.not_existing.url", resultflag); BOOST_CHECK(!resultflag); resultflag = fs->bookmarkExists("www.thisis.url4"); - BROWSER_LOGI("Check existing url (%s) resultflag: %d", "www.thisis.url4", resultflag); + BROWSER_LOGI(TAG "Check existing url (%s) resultflag: %d", "www.thisis.url4", resultflag); BOOST_CHECK(resultflag); + + BROWSER_LOGI(TAG "--> END - bookmark_add_remove"); } BOOST_AUTO_TEST_CASE(bookmark_synchro) { /// \todo: clean casts, depends on ServiceManager + BROWSER_LOGI(TAG "bookmark_synchro - START --> "); + std::shared_ptr fs = std::dynamic_pointer_cast < @@ -116,11 +122,11 @@ BOOST_AUTO_TEST_CASE(bookmark_synchro) > (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice")); - BROWSER_LOGI("Bookmarks synchronize test"); + BROWSER_LOGI(TAG "Bookmarks synchronize test"); fs->synchronizeBookmarks(); BOOST_CHECK(!fs->getBookmarks().empty()); - BROWSER_LOGI("<-- BOOKMARKS_TEST_CASE END"); + BROWSER_LOGI(TAG "--> END - bookmark_synchro"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_PlatformInputManager.cpp b/unit_tests/ut_PlatformInputManager.cpp index 520c96e..728e0a4 100644 --- a/unit_tests/ut_PlatformInputManager.cpp +++ b/unit_tests/ut_PlatformInputManager.cpp @@ -20,12 +20,16 @@ #include "ServiceManager.h" #include "PlatformInputManager.h" +#include "BrowserLogger.h" + BOOST_AUTO_TEST_SUITE(PlatformInputManager) BOOST_AUTO_TEST_CASE(PointerModeSetting) { - std::shared_ptr platformInputManager = + BROWSER_LOGI("[UT] PlatformInputManager - PointerModeSetting - START --> "); + + std::shared_ptr platformInputManager = std::dynamic_pointer_cast (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.platforminputmanager")); @@ -41,6 +45,8 @@ BOOST_AUTO_TEST_CASE(PointerModeSetting) // platformInputManager->setPointerModeEnabled(true); // // BOOST_CHECK(platformInputManager->getPointerModeEnabled()); + + BROWSER_LOGI("[UT] --> END - PlatformInputManager - PointerModeSetting"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_SessionStorage.cpp b/unit_tests/ut_SessionStorage.cpp index 2651c83..7fb8ba9 100644 --- a/unit_tests/ut_SessionStorage.cpp +++ b/unit_tests/ut_SessionStorage.cpp @@ -25,11 +25,15 @@ #include "services/SessionStorage/Session.h" #include "AbstractWebEngine/TabId.h" #include +#include "BrowserLogger.h" + BOOST_AUTO_TEST_SUITE(SessionStorage) BOOST_AUTO_TEST_CASE(InitSession) { + BROWSER_LOGI("[UT] SessionStorage - InitSession - START --> "); + tizen_browser::config::DefaultConfig config; config.load("not used text"); std::string resourceDbDir(boost::any_cast < std::string > (config.get("resourcedb/dir"))); @@ -52,10 +56,14 @@ BOOST_AUTO_TEST_CASE(InitSession) storage = sessionService->getStorage(); BOOST_REQUIRE(storage); + + BROWSER_LOGI("[UT] --> END - SessionStorage - InitSession"); } BOOST_AUTO_TEST_CASE(CreateAndPopulateSession) { + BROWSER_LOGI("[UT] SessionStorage - CreateAndPopulateSession - START --> "); + std::shared_ptr sessionService = std::dynamic_pointer_cast < @@ -102,10 +110,13 @@ BOOST_AUTO_TEST_CASE(CreateAndPopulateSession) BOOST_CHECK_EQUAL(session.items().size(), 2); + BROWSER_LOGI("[UT] --> END - SessionStorage - CreateAndPopulateSession"); } BOOST_AUTO_TEST_CASE(getLastSession) { + BROWSER_LOGI("[UT] SessionStorage - getLastSession - START --> "); + std::shared_ptr sessionService = std::dynamic_pointer_cast < @@ -152,10 +163,14 @@ BOOST_AUTO_TEST_CASE(getLastSession) ); BOOST_CHECK_EQUAL(lastSession.items().size(), 3); + + BROWSER_LOGI("[UT] --> END - SessionStorage - getLastSession"); } BOOST_AUTO_TEST_CASE(getAllSessions) { + BROWSER_LOGI("[UT] SessionStorage - getAllSessions - START --> "); + std::shared_ptr sessionService = std::dynamic_pointer_cast < @@ -175,12 +190,14 @@ BOOST_AUTO_TEST_CASE(getAllSessions) BOOST_CHECK_EQUAL(sessions.size(), 2); - + BROWSER_LOGI("[UT] --> END - SessionStorage - getAllSessions"); } BOOST_AUTO_TEST_CASE(deleteSession) { + BROWSER_LOGI("[UT] SessionStorage - deleteSession - START --> "); + std::shared_ptr sessionService = std::dynamic_pointer_cast < @@ -203,11 +220,15 @@ BOOST_AUTO_TEST_CASE(deleteSession) tizen_browser::Session::SessionsVector sessionsBucket(storage->getAllSessions()); BOOST_CHECK_EQUAL(sessionsBucket.size(),1); + + BROWSER_LOGI("[UT] --> END - SessionStorage - deleteSession"); } BOOST_AUTO_TEST_CASE(deleteAllSessions) { + BROWSER_LOGI("[UT] SessionStorage - deleteAllSessions - START --> "); + std::shared_ptr sessionService = std::dynamic_pointer_cast < @@ -255,6 +276,8 @@ BOOST_AUTO_TEST_CASE(deleteAllSessions) sessionsBucket = storage->getAllSessions(); BOOST_CHECK_EQUAL(sessionsBucket.size(), 0); + + BROWSER_LOGI("[UT] --> END - SessionStorage - deleteAllSessions"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_StorageService.cpp b/unit_tests/ut_StorageService.cpp index 29987f0..c778a4b 100644 --- a/unit_tests/ut_StorageService.cpp +++ b/unit_tests/ut_StorageService.cpp @@ -82,7 +82,7 @@ BOOST_AUTO_TEST_SUITE(StorageService) BOOST_AUTO_TEST_CASE(storage_settings) { - BROWSER_LOGI("StorageService - history - START --> "); + BROWSER_LOGI("[UT] StorageService - storage_settings - START --> "); std::shared_ptr storageManager = std::dynamic_pointer_cast < tizen_browser::services::StorageService, @@ -107,13 +107,12 @@ BOOST_AUTO_TEST_CASE(storage_settings) auto sString = storageManager->getSettingsText(keyString, "0.0"); BOOST_CHECK("String" == sString); - - BROWSER_LOGI("<-- StorageService - history - END"); + BROWSER_LOGI("[UT] --> END - StorageService - storage_settings"); } BOOST_AUTO_TEST_CASE(storage_bookmark) { - BROWSER_LOGI("StorageService - bookmark - START --> "); + BROWSER_LOGI("[UT] StorageService - storage_bookmark - START --> "); std::shared_ptr storageManager = std::dynamic_pointer_cast < tizen_browser::services::StorageService, @@ -137,7 +136,7 @@ BOOST_AUTO_TEST_CASE(storage_bookmark) storageManager->deleteThumbnail(1);*/ - BROWSER_LOGI("<-- StorageService - bookmark - END"); + BROWSER_LOGI("[UT] --> END - StorageService - storage_bookmark"); } // Should it be moved to ut_historyService ???? diff --git a/unit_tests/ut_WebKitEngineService.cpp b/unit_tests/ut_WebKitEngineService.cpp index 7e3d489..57f4cea 100644 --- a/unit_tests/ut_WebKitEngineService.cpp +++ b/unit_tests/ut_WebKitEngineService.cpp @@ -15,14 +15,29 @@ */ #include +#include +#include #include "ServiceManager.h" #include "AbstractWebEngine.h" +#include "BrowserLogger.h" + +#define TAG "[UT] WebKitEngine - " + BOOST_AUTO_TEST_SUITE(WebKitEngineService) +BOOST_AUTO_TEST_CASE(EwkInit) +{ + BROWSER_LOGI(TAG "EwkInit - START --> "); + BOOST_REQUIRE(ewk_init() > 0); + BROWSER_LOGI(TAG "--> END - EwkInit"); +} + BOOST_AUTO_TEST_CASE(UriSetGet) { + BROWSER_LOGI(TAG "UriSetGet - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -30,7 +45,14 @@ BOOST_AUTO_TEST_CASE(UriSetGet) BOOST_CHECK(webkitEngineService); - webkitEngineService->init(NULL); +// elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); +// Evas_Object *main_window = elm_win_util_standard_add("browserApp-ut", "browserApp-ut"); +// if (main_window == nullptr) +// BROWSER_LOGE(TAG "Failed to create main window"); +// elm_win_autodel_set(main_window, EINA_TRUE); + Evas_Object *main_window = nullptr; + + webkitEngineService->init(main_window); tizen_browser::basic_webengine::TabId parentTabId = webkitEngineService->addTab("www.test.com"); @@ -39,15 +61,19 @@ BOOST_AUTO_TEST_CASE(UriSetGet) webkitEngineService->setURI("www.test2.com"); // URIs are different because of WebKit didn't load webpage (lack of initialization) - BOOST_TEST_MESSAGE("Print getURI():" << webkitEngineService->getURI()); + BOOST_TEST_MESSAGE(TAG "Print getURI():" << webkitEngineService->getURI()); - BOOST_TEST_MESSAGE("Print getTitle():" << webkitEngineService->getTitle()); + BOOST_TEST_MESSAGE(TAG "Print getTitle():" << webkitEngineService->getTitle()); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - UriSetGet"); } BOOST_AUTO_TEST_CASE(NavigationTest) { + BROWSER_LOGI(TAG "NavigationTest - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -65,21 +91,25 @@ BOOST_AUTO_TEST_CASE(NavigationTest) webkitEngineService->setURI("www.nextpage.com"); - BOOST_TEST_MESSAGE("Is back enabled: " << webkitEngineService->isBackEnabled()); + BOOST_TEST_MESSAGE(TAG "Is back enabled: " << webkitEngineService->isBackEnabled()); webkitEngineService->back(); - BOOST_TEST_MESSAGE("Is forward enabled: " << webkitEngineService->isForwardEnabled()); + BOOST_TEST_MESSAGE(TAG "Is forward enabled: " << webkitEngineService->isForwardEnabled()); webkitEngineService->forward(); - BOOST_TEST_MESSAGE("Is loading: " << webkitEngineService->isLoading()); + BOOST_TEST_MESSAGE(TAG "Is loading: " << webkitEngineService->isLoading()); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - NavigationTest"); } BOOST_AUTO_TEST_CASE(ClearPrivateData) { + BROWSER_LOGI(TAG "ClearPrivateData - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -91,11 +121,15 @@ BOOST_AUTO_TEST_CASE(ClearPrivateData) webkitEngineService->clearPrivateData(); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - ClearPrivateData"); } BOOST_AUTO_TEST_CASE(TabsCreationDeletion) { + BROWSER_LOGI(TAG "TabsCreationDeletion - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -103,7 +137,7 @@ BOOST_AUTO_TEST_CASE(TabsCreationDeletion) BOOST_CHECK(webkitEngineService); - BOOST_TEST_MESSAGE("Tabs count: " << webkitEngineService->tabsCount()); + BOOST_TEST_MESSAGE(TAG "Tabs count: " << webkitEngineService->tabsCount()); tizen_browser::basic_webengine::TabId first = webkitEngineService->addTab("www.first.com"); @@ -113,17 +147,21 @@ BOOST_AUTO_TEST_CASE(TabsCreationDeletion) BOOST_CHECK(webkitEngineService->tabsCount() == 2); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab(first)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab(first)); BOOST_CHECK(webkitEngineService->tabsCount() == 1); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab(second)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab(second)); BOOST_CHECK(!(webkitEngineService->tabsCount())); + + BROWSER_LOGI(TAG "--> END - TabsCreationDeletion"); } BOOST_AUTO_TEST_CASE(TabsSwitching) { + BROWSER_LOGI(TAG "TabsSwitching - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -131,12 +169,12 @@ BOOST_AUTO_TEST_CASE(TabsSwitching) BOOST_CHECK(webkitEngineService); - BOOST_TEST_MESSAGE("Tabs count: " << webkitEngineService->tabsCount()); + BOOST_TEST_MESSAGE(TAG "Tabs count: " << webkitEngineService->tabsCount()); - BOOST_TEST_MESSAGE("Initial current tab: " << webkitEngineService->currentTabId().toString()); + BOOST_TEST_MESSAGE(TAG "Initial current tab: " << webkitEngineService->currentTabId().toString()); tizen_browser::basic_webengine::TabId first = webkitEngineService->addTab("www.first.com"); - BOOST_TEST_MESSAGE("First tab: " << first.toString()); + BOOST_TEST_MESSAGE(TAG "First tab: " << first.toString()); webkitEngineService->switchToTab(first); @@ -145,7 +183,7 @@ BOOST_AUTO_TEST_CASE(TabsSwitching) BOOST_CHECK(webkitEngineService->tabsCount() == 1); tizen_browser::basic_webengine::TabId second = webkitEngineService->addTab("www.second.com"); - BOOST_TEST_MESSAGE("Second tab: " << second.toString()); + BOOST_TEST_MESSAGE(TAG "Second tab: " << second.toString()); BOOST_CHECK(webkitEngineService->currentTabId() == first); @@ -161,19 +199,23 @@ BOOST_AUTO_TEST_CASE(TabsSwitching) BOOST_CHECK(find(listTabs.begin(), listTabs.end(), second) != listTabs.end()); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab(second)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab(second)); BOOST_CHECK(webkitEngineService->currentTabId() == first); BOOST_CHECK(webkitEngineService->tabsCount() == 1); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab(first)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab(first)); BOOST_CHECK(!(webkitEngineService->tabsCount())); + + BROWSER_LOGI(TAG "--> END - TabsSwitching"); } BOOST_AUTO_TEST_CASE(Snapshots) { + BROWSER_LOGI(TAG "Snapshots - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -189,11 +231,15 @@ BOOST_AUTO_TEST_CASE(Snapshots) webkitEngineService->getSnapshotData(parentTabId, 100, 100); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - Snapshots"); } BOOST_AUTO_TEST_CASE(PrivateModeOnOff) { + BROWSER_LOGI(TAG "PrivateModeOnOff - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -215,11 +261,15 @@ BOOST_AUTO_TEST_CASE(PrivateModeOnOff) BOOST_CHECK(!(webkitEngineService->isPrivateMode())); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - PrivateModeOnOff"); } BOOST_AUTO_TEST_CASE(LoadErrorDefaultValue) { + BROWSER_LOGI(TAG "LoadErrorDefaultValue - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -233,11 +283,15 @@ BOOST_AUTO_TEST_CASE(LoadErrorDefaultValue) BOOST_CHECK(!(webkitEngineService->isLoadError())); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - LoadErrorDefaultValue"); } BOOST_AUTO_TEST_CASE(Focus) { + BROWSER_LOGI(TAG "Focus - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -249,25 +303,29 @@ BOOST_AUTO_TEST_CASE(Focus) tizen_browser::basic_webengine::TabId parentTabId = webkitEngineService->addTab("www.test.com"); - BOOST_TEST_MESSAGE("Has focus at start:" << webkitEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus at start:" << webkitEngineService->hasFocus()); webkitEngineService->setFocus(); - BOOST_TEST_MESSAGE("Has focus after setting focus:" << webkitEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus after setting focus:" << webkitEngineService->hasFocus()); webkitEngineService->clearFocus(); - BOOST_TEST_MESSAGE("Has focus after clearing focus:" << webkitEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus after clearing focus:" << webkitEngineService->hasFocus()); webkitEngineService->setFocus(); - BOOST_TEST_MESSAGE("Has focus after setting focus:" << webkitEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus after setting focus:" << webkitEngineService->hasFocus()); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - Focus"); } BOOST_AUTO_TEST_CASE(ZoomAndAutofit) { + BROWSER_LOGI(TAG "ZoomAndAutofit - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -279,21 +337,25 @@ BOOST_AUTO_TEST_CASE(ZoomAndAutofit) tizen_browser::basic_webengine::TabId parentTabId = webkitEngineService->addTab("www.test.com"); - BOOST_TEST_MESSAGE("Zoom factor at start:" << webkitEngineService->getZoomFactor()); + BOOST_TEST_MESSAGE(TAG "Zoom factor at start:" << webkitEngineService->getZoomFactor()); webkitEngineService->setZoomFactor(200); - BOOST_TEST_MESSAGE("Zoom factor after setting 200:" << webkitEngineService->getZoomFactor()); + BOOST_TEST_MESSAGE(TAG "Zoom factor after setting 200:" << webkitEngineService->getZoomFactor()); webkitEngineService->setZoomFactor(100); - BOOST_TEST_MESSAGE("Zoom factor after setting 100:" << webkitEngineService->getZoomFactor()); + BOOST_TEST_MESSAGE(TAG "Zoom factor after setting 100:" << webkitEngineService->getZoomFactor()); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - ZoomAndAutofit"); } BOOST_AUTO_TEST_CASE(Favicon) { + BROWSER_LOGI(TAG "Favicon - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -307,12 +369,16 @@ BOOST_AUTO_TEST_CASE(Favicon) webkitEngineService->getFavicon(); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - Favicon"); } BOOST_AUTO_TEST_CASE(SearchOnWebsite) { + BROWSER_LOGI(TAG "SearchOnWebsite - START --> "); + std::shared_ptr> webkitEngineService = std::dynamic_pointer_cast ,tizen_browser::core::AbstractService> @@ -330,7 +396,16 @@ BOOST_AUTO_TEST_CASE(SearchOnWebsite) webkitEngineService->searchOnWebsite("", 0); - BOOST_TEST_MESSAGE("Print closeTab():" << webkitEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webkitEngineService->closeTab()); + + BROWSER_LOGI(TAG "--> END - SearchOnWebsite"); } +//BOOST_AUTO_TEST_CASE(EwkShutdown) +//{ +// BROWSER_LOGI(TAG "EwkShutdown - START --> "); +// BOOST_CHECK(ewk_shutdown() == 0); +// BROWSER_LOGI(TAG "--> END - EwkShutdown"); +//} + BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_coreService.cpp b/unit_tests/ut_coreService.cpp index cfd0649..135e553 100644 --- a/unit_tests/ut_coreService.cpp +++ b/unit_tests/ut_coreService.cpp @@ -19,7 +19,9 @@ #include #include "ServiceManager.h" -#include "Services/ServiceInterface.h" +#include "BrowserLogger.h" +#include "BookmarkService.h" + BOOST_AUTO_TEST_SUITE(core_ServiceManager) @@ -27,19 +29,25 @@ namespace tbc=tizen_browser::core; BOOST_AUTO_TEST_CASE(singleton) { + BROWSER_LOGI("[UT] CoreService - singleton - START --> "); + // check if service manager is singleton tbc::ServiceManager *serviceManager_instance_01 = &tbc::ServiceManager::getInstance(); tbc::ServiceManager *serviceManager_instance_02 = &tbc::ServiceManager::getInstance(); BOOST_CHECK_EQUAL(serviceManager_instance_01, serviceManager_instance_02); + + BROWSER_LOGI("[UT] --> END - CoreService - singleton"); } BOOST_AUTO_TEST_CASE(getService) { - std::string serviceName("org.tizen.browser.TestServiceOne"); + BROWSER_LOGI("[UT] CoreService - getService - START --> "); + + std::string serviceName("org.tizen.browser.favoriteservice"); tbc::ServiceManager *servManager = &tbc::ServiceManager::getInstance(); - std::shared_ptr service1 = std::dynamic_pointer_cast - + std::shared_ptr service1 = std::dynamic_pointer_cast + (servManager->getService(serviceName)); BOOST_REQUIRE(service1); std::string nameFromService = service1->getName(); @@ -47,6 +55,8 @@ BOOST_AUTO_TEST_CASE(getService) nameFromService.end(), serviceName.begin(), serviceName.end()); + + BROWSER_LOGI("[UT] --> END - CoreService - getService"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_logger.cpp b/unit_tests/ut_logger.cpp index 1c321e2..d6250d9 100644 --- a/unit_tests/ut_logger.cpp +++ b/unit_tests/ut_logger.cpp @@ -29,6 +29,8 @@ #include "Logger.h" #include "AbstractLogger.h" +#include "BrowserLogger.h" + #define COLOR "\033[41m\033[37m" @@ -63,6 +65,8 @@ struct StubAbstractLogger: tizen_browser::logger::AbstractLogger { // simple tests for inherited interface BOOST_AUTO_TEST_CASE(logger_abstract_logger) { + BROWSER_LOGI("[UT] LOGGER - logger_abstract_logger - START --> "); + std::stringstream ss; ss << boost::unit_test::framework::current_test_case().p_name; @@ -73,6 +77,7 @@ BOOST_AUTO_TEST_CASE(logger_abstract_logger) { sl.log("a", "b", "c"); BOOST_CHECK_EQUAL(sl.getLog().compare("abc\n"), 0); + BROWSER_LOGI("[UT] --> END - LOGGER - logger_abstract_logger"); } class StubLogger: public tizen_browser::logger::Logger { @@ -89,6 +94,8 @@ private: }; BOOST_AUTO_TEST_CASE(logger_init) { + BROWSER_LOGI("[UT] LOGGER - logger_init - START --> "); + std::stringstream ss; ss << boost::unit_test::framework::current_test_case().p_name; @@ -124,6 +131,8 @@ BOOST_AUTO_TEST_CASE(logger_init) { checker.erase(checker.begin(), std::find(checker.begin(), checker.end(), ']') + 1); boost::algorithm::trim(checker); BOOST_CHECK_EQUAL(checker, msg); + + BROWSER_LOGI("[UT] --> END - LOGGER - logger_init"); } ///\todo p.chmielewski -- 2.7.4