From 35458d8763d45a898e9e5325a4d2f1d0fe19f44c Mon Sep 17 00:00:00 2001 From: Jan Olszak Date: Tue, 18 Dec 2012 13:38:50 +0100 Subject: [PATCH] Changed PkgName type from DPL::Optional to DPL::String. PART 2 [Issue#] PkgName could have been NULL. [Bug] N/A [Cause] N/A [Solution] Changed Pkgname type, changed api methods. This is a temporary change, to test if the new API work. [Verification] Build commons, plugins, installer, wrt. Run tests. Change-Id: I55750b51fbdf4a68f2f44d2bb1884a8981346ab9 --- modules/widget_dao/dao/widget_dao_read_only.cpp | 21 ++++++--------------- .../include/dpl/wrt-dao-ro/widget_dao_read_only.h | 16 ++++++++-------- tests/dao/TestCases_WidgetDAO.cpp | 9 ++++----- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/modules/widget_dao/dao/widget_dao_read_only.cpp b/modules/widget_dao/dao/widget_dao_read_only.cpp index 5b13abe..58a8c27 100644 --- a/modules/widget_dao/dao/widget_dao_read_only.cpp +++ b/modules/widget_dao/dao/widget_dao_read_only.cpp @@ -127,12 +127,9 @@ WidgetPkgName getPkgNameByHandle(const DbWidgetHandle handle) ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, "Failed to get widget by handle"); } - DPL::OptionalString pkgname = rowList.front().Get_pkgname(); - if(pkgname.IsNull()){ - ThrowMsg(WidgetDAOReadOnly::Exception::DatabaseError, - "PkgName is null for this widget"); - } - return *pkgname; + WidgetPkgName pkgname = rowList.front().Get_pkgname(); + + return pkgname; } SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle") @@ -533,13 +530,7 @@ WidgetGUID WidgetDAOReadOnly::getGUID() const DPL::OptionalString WidgetDAOReadOnly::getPkgname() const { - return DPL::OptionalString(getPkgname_TEMPORARY_API()); -} - -WidgetPkgName WidgetDAOReadOnly::getPkgname_TEMPORARY_API() const -{ - WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle); - return row.Get_pkgname(); + return DPL::OptionalString(getPkgName()); } DPL::OptionalString WidgetDAOReadOnly::getDefaultlocale() const @@ -1015,7 +1006,7 @@ std::string WidgetDAOReadOnly::getCookieDatabasePath() const using namespace WrtDB::WidgetConfig; std::ostringstream path; - WidgetPkgName pkgname = getPkgname_TEMPORARY_API(); + WidgetPkgName pkgname = getPkgName(); path << GetWidgetPersistentStoragePath(pkgname); path << "/"; @@ -1027,7 +1018,7 @@ std::string WidgetDAOReadOnly::getCookieDatabasePath() const std::string WidgetDAOReadOnly::getPrivateLocalStoragePath() const { std::ostringstream path; - WidgetPkgName pkgname = getPkgname_TEMPORARY_API(); + WidgetPkgName pkgname = getPkgName(); path << WidgetConfig::GetWidgetWebLocalStoragePath(pkgname); path << "/"; diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h index 37a7138..f454637 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h @@ -177,7 +177,7 @@ struct WidgetRegisterInfo LocalizationData localizationData; DPL::OptionalString pkgname; - WidgetPkgName pkgname_TEMPORARY_API; + WidgetPkgName pkgName; time_t installedTime; PackagingType packagingType; @@ -371,15 +371,15 @@ class WidgetDAOReadOnly */ WidgetGUID getGUID() const; + /** - * This method returns the Package name of the widget. - * - * @return pkgname - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table. - */ + * This method returns the Package name of the widget. + * + * @return pkgname + * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. + * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table. + */ DPL::OptionalString getPkgname() const; - WidgetPkgName getPkgname_TEMPORARY_API() const; /** * This method returns the defaultlocale for the widget. diff --git a/tests/dao/TestCases_WidgetDAO.cpp b/tests/dao/TestCases_WidgetDAO.cpp index e26f45d..92e1995 100644 --- a/tests/dao/TestCases_WidgetDAO.cpp +++ b/tests/dao/TestCases_WidgetDAO.cpp @@ -88,7 +88,7 @@ WidgetPkgName _registerWidget(const WidgetRegisterInfo& regInfo, { WidgetPkgName pkgname; Try { - auto previous = WidgetDAO::getPkgnameList(); + auto previous = WidgetDAO::getPkgnameList_TEMPORARY_API(); // register widget pkgname = WidgetDAO::registerWidgetGenerateTizenId(regInfo, sec); @@ -96,7 +96,7 @@ WidgetPkgName _registerWidget(const WidgetRegisterInfo& regInfo, RUNNER_ASSERT_MSG(!pkgname.empty(), "(called from line " << line << ")"); - auto current = WidgetDAO::getPkgnameList(); + auto current = WidgetDAO::getPkgnameList_TEMPORARY_API(); RUNNER_ASSERT_MSG(previous.size()+1 == current.size(), "(called from line " << line << ")"); @@ -257,7 +257,7 @@ RUNNER_TEST(widget_dao_test_register_widget_minimum_info) WacSecurityMock sec; const std::size_t NUMBER_OF_WIDGETS = 5; - DPL::Optional lastPkgname; + WidgetPkgName lastPkgname; for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) { @@ -828,7 +828,7 @@ Expected: For all position in database should be returned one item in list */ RUNNER_TEST(widget_dao_test_get_widget_pkgname_list) { - WidgetPkgNameList pkgnames = WidgetDAO::getPkgnameList(); + WidgetPkgNameList_TEMPORARY_API pkgnames = WidgetDAO::getPkgnameList_TEMPORARY_API(); RUNNER_ASSERT(pkgnames.size() >= 3); } @@ -844,7 +844,6 @@ RUNNER_TEST(widget_dao_test_get_widget_list) RUNNER_ASSERT(list.size() >= 3); RUNNER_ASSERT_MSG(!!list.front(), "widget dao exists"); WidgetDAOReadOnlyPtr dao = list.front(); - RUNNER_ASSERT_MSG(!dao->getPkgname().IsNull(), "dao object do not have tizen id"); } /* -- 2.7.4