From 65a8518ae5bbfcc58deb5d19e61466117e923d3c Mon Sep 17 00:00:00 2001 From: Taejeong Lee Date: Fri, 25 Jan 2013 22:50:35 +0900 Subject: [PATCH] [Release] wrt-commons_0.2.94 by sync with master branch Change-Id: Ie0f6f0b7084c750e3197bffe0e6df9cc9c45d33c --- debian/changelog | 20 +++ modules/core/include/dpl/singleton.h | 5 - modules/core/include/dpl/singleton_impl.h | 24 ---- .../core/include/dpl/singleton_safe_impl.h | 20 --- modules/db/include/dpl/db/orm.h | 61 +++++++++- modules/db/src/orm.cpp | 1 + modules/dbus/src/connection.cpp | 2 +- modules/event/include/dpl/event/property.h | 2 +- modules/log/src/old_style_log_provider.cpp | 1 + modules/utils/src/wrt_utility.cpp | 1 + modules/widget_dao/dao/widget_dao.cpp | 30 +---- .../widget_dao/dao/widget_dao_read_only.cpp | 16 +-- .../include/dpl/wrt-dao-ro/common_dao_types.h | 1 - .../dpl/wrt-dao-ro/widget_dao_read_only.h | 10 -- .../include/dpl/wrt-dao-rw/widget_dao.h | 3 +- packaging/wrt-commons.spec | 4 +- tests/dao/TestCases_WidgetDAO.cpp | 114 +++++++++--------- tests/dao/wrt_dao_tests_prepare_db.sh | 12 +- tests/dpl/db/test_orm.cpp | 54 ++++++++- .../dpl/wrt-dao-rw/widget_dao.h | 2 +- .../localization/mockup_src/widget_dao.cpp | 2 +- 21 files changed, 209 insertions(+), 176 deletions(-) diff --git a/debian/changelog b/debian/changelog index 736b898..226583a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,23 @@ +wrt-commons (0.2.94) unstable; urgency=low + + * Revert "Change pkgname to appid and add package id PART 1." + * Revert "change pkgname to appid PART 2." + * Fix build break in tests after API has been changed. + + -- Tae-Jeong Lee Fri, 25 Jan 2013 22:32:36 +0900 + +wrt-commons (0.2.93) unstable; urgency=low + + * Changed PkgName type from Optional to String PART 5 + * Support for GCC 4.7 + * Removing hard-coding in ORDER BY statement + * Fixing saving locale for each icon + * Singleton guard thread removal + * Change pkgname to appid and add package id PART 1. + * change pkgname to appid PART 2. + + -- Soyoung Kim Thu, 24 Jan 2013 15:53:03 +0900 + wrt-commons (0.2.92) unstable; urgency=low * Removal of popup implementation diff --git a/modules/core/include/dpl/singleton.h b/modules/core/include/dpl/singleton.h index 4e5b281..44886d9 100644 --- a/modules/core/include/dpl/singleton.h +++ b/modules/core/include/dpl/singleton.h @@ -45,7 +45,6 @@ private: } typedef Optional OptionalThreadPtr; - OptionalThreadPtr m_guard; static Singleton &InternalInstance(); @@ -55,10 +54,6 @@ public: } static Class &Instance(); - - // Thread guarding - static void SetThreadGuard(Thread *thread); - static void ResetThreadGuard(); }; } // namespace DPL diff --git a/modules/core/include/dpl/singleton_impl.h b/modules/core/include/dpl/singleton_impl.h index 365ec15..6ebe48c 100644 --- a/modules/core/include/dpl/singleton_impl.h +++ b/modules/core/include/dpl/singleton_impl.h @@ -44,37 +44,13 @@ template Class &Singleton::Instance() { Singleton& instance = Singleton::InternalInstance(); - - if (!!instance.m_guard) - { - Assert(Thread::GetCurrentThread() == *instance.m_guard && - "Singleton thread guard failed. A forbidden call from foreign thread was detected!"); - } - return instance; } -// Thread guarding -template -void Singleton::SetThreadGuard(Thread *thread) -{ - Singleton& instance = Singleton::InternalInstance(); - instance.m_guard = OptionalThreadPtr(thread); -} - -template -void Singleton::ResetThreadGuard() -{ - Singleton& instance = Singleton::InternalInstance(); - instance.m_guard = OptionalThreadPtr::Null; -} - } // namespace DPL #define IMPLEMENT_SINGLETON(Type) \ template DPL::Singleton& DPL::Singleton::InternalInstance(); \ template Type& DPL::Singleton::Instance(); \ -template void DPL::Singleton::SetThreadGuard(DPL::Thread *thread); \ -template void DPL::Singleton::ResetThreadGuard(); #endif // DPL_SINGLETON_IMPL_H diff --git a/modules/core/include/dpl/singleton_safe_impl.h b/modules/core/include/dpl/singleton_safe_impl.h index 8fbe009..6bf6451 100644 --- a/modules/core/include/dpl/singleton_safe_impl.h +++ b/modules/core/include/dpl/singleton_safe_impl.h @@ -35,31 +35,11 @@ template<> \ Class &Singleton::Instance() \ { \ Singleton& instance = Singleton::InternalInstance(); \ - if (!!instance.m_guard) \ - { \ - Assert(Thread::GetCurrentThread() == *instance.m_guard && \ - "Singleton thread guard failed. A forbidden call from foreign thread was detected!");\ - } \ return instance; \ } \ \ -template<> \ -void Singleton::SetThreadGuard(Thread *thread) \ -{ \ - Singleton& instance = Singleton::InternalInstance(); \ - instance.m_guard = OptionalThreadPtr(thread); \ -} \ - \ -template<> \ -void Singleton::ResetThreadGuard() \ -{ \ - Singleton& instance = Singleton::InternalInstance(); \ - instance.m_guard = OptionalThreadPtr::Null; \ -} \ template Singleton& Singleton::InternalInstance(); \ template Class& Singleton::Instance(); \ -template void Singleton::SetThreadGuard(Thread *thread); \ -template void Singleton::ResetThreadGuard(); \ } // namespace DPL diff --git a/modules/db/include/dpl/db/orm.h b/modules/db/include/dpl/db/orm.h index c404fba..652e8e1 100644 --- a/modules/db/include/dpl/db/orm.h +++ b/modules/db/include/dpl/db/orm.h @@ -86,6 +86,38 @@ public: typedef std::shared_ptr ExpressionPtr; +namespace OrderingUtils { + +template inline std::string OrderByInternal() +{ + std::string order = OrderByInternal(); + if(!order.empty()) return CompoundType::Head::GetString() + ", " + order; + else return CompoundType::Head::GetString(); +} + +template<> inline std::string OrderByInternal() +{ + return std::string(); +} + +} + +template +class __attribute__ ((visibility("hidden"))) OrderingExpression { +protected: + static std::string GetSchemaAndName() + { + std::string statement; + statement += ColumnType::GetTableName(); + statement += "."; + statement += ColumnType::GetColumnName(); + statement += " "; + return statement; + } +public: + virtual ~OrderingExpression() {} +}; + template class __attribute__ ((visibility("hidden"))) BinaryExpression : public Expression { protected: @@ -187,6 +219,22 @@ public: ORM_DEFINE_COMPARE_EXPRESSION(Equals, Equal) ORM_DEFINE_COMPARE_EXPRESSION(Is, Is) +#define ORM_DEFINE_ORDERING_EXPRESSION(name, value) \ + template \ + class __attribute__ ((visibility("hidden"))) name \ + : OrderingExpression { \ + public: \ + static std::string GetString() \ + { \ + std::string statement = OrderingExpression::GetSchemaAndName(); \ + statement += value; \ + return statement; \ + } \ + }; + +ORM_DEFINE_ORDERING_EXPRESSION(OrderingAscending, "ASC") +ORM_DEFINE_ORDERING_EXPRESSION(OrderingDescending, "DESC") + template class __attribute__ ((visibility("hidden"))) CompareBinaryColumn { private: @@ -844,11 +892,22 @@ public: m_distinctResults = true; } - void OrderBy(const std::string& orderBy) + template + void OrderBy(const CompoundType&) + { + m_orderBy = OrderingUtils::OrderByInternal(); + } + + void OrderBy(const std::string & orderBy) //backward compatibility { m_orderBy = orderBy; } + void OrderBy(const char * orderBy) //backward compatibility + { + m_orderBy = std::string(orderBy); + } + template void Join(const Expression& expression) { std::string usedTableNames = TableDefinition::GetName(); diff --git a/modules/db/src/orm.cpp b/modules/db/src/orm.cpp index 1d2f6b4..acdbcca 100644 --- a/modules/db/src/orm.cpp +++ b/modules/db/src/orm.cpp @@ -22,6 +22,7 @@ #include #include + namespace DPL { namespace DB { namespace ORM { diff --git a/modules/dbus/src/connection.cpp b/modules/dbus/src/connection.cpp index c9b7f8e..53d992c 100644 --- a/modules/dbus/src/connection.cpp +++ b/modules/dbus/src/connection.cpp @@ -109,7 +109,7 @@ Connection::~Connection() std::for_each(m_registeredObjects.begin(), m_registeredObjects.end(), - [m_connection] (const RegisteredObjects::value_type& value) + [this] (const RegisteredObjects::value_type& value) { g_dbus_connection_unregister_object( m_connection, diff --git a/modules/event/include/dpl/event/property.h b/modules/event/include/dpl/event/property.h index 7c87e50..2817007 100644 --- a/modules/event/include/dpl/event/property.h +++ b/modules/event/include/dpl/event/property.h @@ -511,7 +511,7 @@ public: this->m_storage.Set(value); - EmitEvent(PropertyEvent(value, this->m_model), + this->EmitEvent(PropertyEvent(value, this->m_model), EmitMode::Auto); } diff --git a/modules/log/src/old_style_log_provider.cpp b/modules/log/src/old_style_log_provider.cpp index 2ad499f..bd7db2b 100644 --- a/modules/log/src/old_style_log_provider.cpp +++ b/modules/log/src/old_style_log_provider.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace DPL { diff --git a/modules/utils/src/wrt_utility.cpp b/modules/utils/src/wrt_utility.cpp index 9bb2187..43888b3 100644 --- a/modules/utils/src/wrt_utility.cpp +++ b/modules/utils/src/wrt_utility.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index e078797..bd421dd 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -96,15 +96,7 @@ void WidgetDAO::setProperty( } } -void WidgetDAO::setPkgName(const DPL::OptionalString& pkgName) -{ - - // if(!!pkgName) - setPkgName_TEMPORARY_API(*pkgName); -} - - -void WidgetDAO::setPkgName_TEMPORARY_API(const WidgetPkgName& pkgName) +void WidgetDAO::setPkgName(const WidgetPkgName& pkgName) { SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN { @@ -538,25 +530,7 @@ void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle, row.Set_app_id(widgetHandle); row.Set_icon_id(icon_id); row.Set_widget_locale(*j); - WRT_DB_SELECT(select, WidgetLocalizedIcon, &WrtDatabase::interface()) - select->Where(And(Equals(widgetHandle), - Equals(*j))); - WidgetLocalizedIcon::Select::RowList rows = select->GetRowList(); - - bool flag = !rows.empty(); - - if(flag == true) - { - // already default icon value of same locale exists - WRT_DB_UPDATE(update, WidgetLocalizedIcon, &WrtDatabase::interface()) - update->Where(And(Equals(widgetHandle), - Equals(*j))); - update->Values(row); - update->Execute(); - }else{ - // any icon value of same locale doesn't exist - DO_INSERT(row, WidgetLocalizedIcon) - } + DO_INSERT(row, WidgetLocalizedIcon) } } } diff --git a/modules/widget_dao/dao/widget_dao_read_only.cpp b/modules/widget_dao/dao/widget_dao_read_only.cpp index ade490b..e5a528a 100644 --- a/modules/widget_dao/dao/widget_dao_read_only.cpp +++ b/modules/widget_dao/dao/widget_dao_read_only.cpp @@ -413,16 +413,6 @@ WidgetPkgNameList WidgetDAOReadOnly::getPkgnameList() SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get Pkgname list") } -WidgetPkgNameList_TEMPORARY_API WidgetDAOReadOnly::getPkgnameList_TEMPORARY_API() -{ - LogDebug("Getting Pkgname List "); - SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN - { - WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface()) - return select->GetValueList(); - } - SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get Pkgname list") -} DbWidgetDAOReadOnlyList WidgetDAOReadOnly::getWidgetList() { @@ -528,11 +518,6 @@ WidgetGUID WidgetDAOReadOnly::getGUID() const return row.Get_widget_id(); } -DPL::OptionalString WidgetDAOReadOnly::getPkgname() const -{ - return DPL::OptionalString(getPkgName()); -} - DPL::OptionalString WidgetDAOReadOnly::getDefaultlocale() const { WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle); @@ -734,6 +719,7 @@ WidgetDAOReadOnly::WidgetIconList WidgetDAOReadOnly::getIconList() const { WRT_DB_SELECT(select, wrt::WidgetIcon, &WrtDatabase::interface()) select->Where(Equals(m_widgetHandle)); + select->OrderBy(DPL::TypeListDecl >()); std::list list = select->GetRowList(); diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h b/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h index 444f176..3620658 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h @@ -237,7 +237,6 @@ typedef std::multiset DbWidgetFeatureSet; typedef std::list DbWidgetHandleList; typedef std::list WidgetPkgNameList; //TODO: this cannot be null -> appropriate changes in db schema needed -typedef std::list WidgetPkgNameList_TEMPORARY_API; //TODO: this cannot be null -> appropriate changes in db schema needed class WidgetDAOReadOnly; //forward declaration typedef std::shared_ptr WidgetDAOReadOnlyPtr; 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 f454637..8be742c 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 @@ -372,15 +372,6 @@ 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. - */ - DPL::OptionalString getPkgname() const; - /** * This method returns the defaultlocale for the widget. * @@ -574,7 +565,6 @@ class WidgetDAOReadOnly * @return list of pkgname of installed packages */ static WidgetPkgNameList getPkgnameList(); - static WidgetPkgNameList_TEMPORARY_API getPkgnameList_TEMPORARY_API(); /** * This method returns a list of all the installed widgets. diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h index 3f7b819..3137c24 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h @@ -132,8 +132,7 @@ class WidgetDAO : public WidgetDAOReadOnly /* set PkgName */ - void setPkgName(const DPL::OptionalString& pkgName); - void setPkgName_TEMPORARY_API(const WidgetPkgName& pkgName); + void setPkgName(const WidgetPkgName& pkgName); /* This function will update of api-feature status. * If status is true (feature rejected) plugin connected with this diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec index e217f8b..56ee397 100644 --- a/packaging/wrt-commons.spec +++ b/packaging/wrt-commons.spec @@ -1,7 +1,7 @@ -#git:framework/web/wrt-commons wrt-commons 0.2.92 +#git:framework/web/wrt-commons wrt-commons 0.2.94 Name: wrt-commons Summary: Wrt common library -Version: 0.2.92 +Version: 0.2.94 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 diff --git a/tests/dao/TestCases_WidgetDAO.cpp b/tests/dao/TestCases_WidgetDAO.cpp index 4964038..13ea61c 100644 --- a/tests/dao/TestCases_WidgetDAO.cpp +++ b/tests/dao/TestCases_WidgetDAO.cpp @@ -82,33 +82,33 @@ private: }; -WidgetPkgName _registerWidget(const WidgetRegisterInfo& regInfo, +TizenAppId _registerWidget(const WidgetRegisterInfo& regInfo, const IWacSecurity& sec, int line) { - WidgetPkgName pkgname; + TizenAppId tizenAppId; Try { - auto previous = WidgetDAO::getPkgnameList(); + auto previous = WidgetDAO::getTizenAppidList(); // register widget - pkgname = WidgetDAO::registerWidgetGenerateTizenId(regInfo, sec); + tizenAppId = WidgetDAO::registerWidgetGeneratePkgId(regInfo, sec); - RUNNER_ASSERT_MSG(!pkgname.empty(), + RUNNER_ASSERT_MSG(!tizenAppId.empty(), "(called from line " << line << ")"); - auto current = WidgetDAO::getPkgnameList(); + auto current = WidgetDAO::getTizenAppidList(); RUNNER_ASSERT_MSG(previous.size()+1 == current.size(), "(called from line " << line << ")"); - RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(pkgname), - "(called from line " << line << " pkgname: " << pkgname << ")"); + RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(tizenAppId), + "(called from line " << line << " tizenAppId: " << tizenAppId << ")"); } Catch (WidgetDAO::Exception::AlreadyRegistered) { RUNNER_ASSERT_MSG( false, "Unexpected exception (called from line " << line << ")"); } - return pkgname; + return tizenAppId; } #define REGISTER_WIDGET(regInfo, sec) _registerWidget((regInfo),(sec), __LINE__) @@ -257,16 +257,16 @@ RUNNER_TEST(widget_dao_test_register_widget_minimum_info) WacSecurityMock sec; const std::size_t NUMBER_OF_WIDGETS = 5; - WidgetPkgName lastPkgname; + TizenAppId lastTizenAppId; for (std::size_t number = 0; number < NUMBER_OF_WIDGETS; ++number) { WidgetRegisterInfo regInfo; - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - lastPkgname = pkgname; + lastTizenAppId = tizenAppId; - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); //TODO check nulls } } @@ -302,9 +302,9 @@ RUNNER_TEST(widget_dao_test_register_widget_info) regInfo.minVersion = DPL::FromUTF8String("1.0"); regInfo.configInfo.backSupported = true; - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), str.str()); RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), str.str()); RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getAuthorName(), str.str()); @@ -340,9 +340,9 @@ RUNNER_TEST(widget_dao_test_register_widget_extended_info) // regInfo.shareHref = str.str(); regInfo.configInfo.backgroundPage = L"background.html"; - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); // RUNNER_ASSERT_WHAT_EQUALS(dao.GetShareHref(), str.str()); RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getBackgroundPage(), @@ -391,9 +391,9 @@ RUNNER_TEST(widget_dao_test_register_widget_localized_info) std::make_pair(DPL::FromUTF8String("pl"),locDataPl)); } - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); RUNNER_ASSERT_MSG(dao.getLanguageTags().size() == 2, "language tags list invalid"); @@ -450,9 +450,9 @@ RUNNER_TEST(widget_dao_test_register_widget_icons) WidgetRegisterInfo::LocalizedIcon locIcon(icon,locs); regInfo.localizationData.icons.push_back(locIcon); - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); WidgetDAOReadOnly::WidgetIconList list = dao.getIconList(); RUNNER_ASSERT(list.size() == regInfo.localizationData.icons.size()); @@ -524,9 +524,9 @@ RUNNER_TEST(widget_dao_test_register_widget_features) FOREACH(it, features) regInfo.configInfo.featuresList.insert(*it); - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); WidgetFeatureSet out = dao.getFeaturesList(); RUNNER_ASSERT_MSG(out.size() == features.size(), "wrong number of features"); @@ -544,9 +544,9 @@ RUNNER_TEST(widget_dao_test_register_widget_security_settings) { WacSecurityMock sec; WidgetRegisterInfo regInfo; - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); RUNNER_ASSERT_MSG(dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_ON, "SecurityPopupUsage is not deafult on"); RUNNER_ASSERT_MSG(dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ON, "GeolocationUsage is not deafult on"); RUNNER_ASSERT_MSG(dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_ON, "WebNotificationUsage is not deafult on"); @@ -613,9 +613,9 @@ RUNNER_TEST(widget_dao_test_register_widget_win_modes) FOREACH(it, modes) regInfo.configInfo.windowModes.insert(*it); - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); std::list wins = dao.getWindowModes(); RUNNER_ASSERT_MSG(modes.size() == wins.size(), "wrong number of window modes"); @@ -643,9 +643,9 @@ RUNNER_TEST(widget_dao_test_register_widget_warp_info) FOREACH(it, orig) regInfo.configInfo.accessInfoSet.insert(*it); - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); WidgetAccessInfoList out; dao.getWidgetAccessInfo(out); @@ -680,9 +680,9 @@ RUNNER_TEST(widget_dao_test_register_widget_certificates) certListRef.push_back(cert); // register widget - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); // certificates WidgetCertificateDataList recList = dao.getCertificateDataList(); @@ -763,9 +763,9 @@ RUNNER_TEST(widget_dao_test_is_widget_installed) WacSecurityMock sec; WidgetRegisterInfo regInfo; - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(pkgname)); + RUNNER_ASSERT(WidgetDAO::isWidgetInstalled(tizenAppId)); } /* @@ -780,9 +780,9 @@ RUNNER_TEST(widget_dao_test_unregister_widget) WidgetRegisterInfo regInfo; - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO::unregisterWidget(pkgname); + WidgetDAO::unregisterWidget(tizenAppId); RUNNER_ASSERT_MSG(handles.size() == WidgetDAO::getHandleList().size(), "Widget unregister failed"); @@ -805,38 +805,38 @@ RUNNER_TEST(widget_dao_test_register_or_update_widget) regInfo2.configInfo.version = L"1.1"; regInfo2.configInfo.authorName = L"BBB"; - WrtDB::WidgetPkgName pkgname(L"abcdefghij"); + WrtDB::TizenAppId tizenAppId(L"abcdefghij"); //first installation - WidgetDAO::registerWidget(pkgname, regInfo, sec); - RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(pkgname), "Widget is not registered"); + WidgetDAO::registerWidget(tizenAppId, regInfo, sec); + RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(tizenAppId), "Widget is not registered"); //success full update - WidgetDAO::registerOrUpdateWidget(pkgname, regInfo2, sec); - RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(pkgname), "Widget is not reregistered"); - WidgetDAO dao(pkgname); + WidgetDAO::registerOrUpdateWidget(tizenAppId, regInfo2, sec); + RUNNER_ASSERT_MSG(WidgetDAO::isWidgetInstalled(tizenAppId), "Widget is not reregistered"); + WidgetDAO dao(tizenAppId); RUNNER_ASSERT_MSG(*dao.getVersion() == L"1.1", "Data widget was not updated"); RUNNER_ASSERT_MSG(*dao.getAuthorName() == L"BBB", "Data widget was not updated"); - WidgetDAO::unregisterWidget(pkgname); + WidgetDAO::unregisterWidget(tizenAppId); } /* -Name: widget_dao_test_get_widget_pkgname_list -Description: Tests getPkgnameList API for backendlib +Name: widget_dao_test_get_widget_tizenAppId_list +Description: Tests getTizenAppidList API for backendlib Expected: For all position in database should be returned one item in list */ -RUNNER_TEST(widget_dao_test_get_widget_pkgname_list) +RUNNER_TEST(widget_dao_test_get_widget_tizenAppId_list) { - WidgetPkgNameList pkgnames = WidgetDAO::getPkgnameList(); - RUNNER_ASSERT(pkgnames.size() >= 3); + TizenAppIdList tizenAppIds = WidgetDAO::getTizenAppidList(); + RUNNER_ASSERT(tizenAppIds.size() >= 3); } /* Name: widget_dao_test_get_widget_list -Description: Tests getPkgnameList API for backendlib +Description: Tests getTizenAppidList API for backendlib Expected: For all position in database should be returned one item in list - Those item should contain valid pkgname + Those item should contain valid tizenAppId */ RUNNER_TEST(widget_dao_test_get_widget_list) { @@ -854,8 +854,8 @@ Expected: Attributes should match values inserted into database RUNNER_TEST(widget_dao_test_get_widget_attributes) { { - WidgetPkgName pkgname = L"tizenid201"; - WidgetDAO dao(pkgname); + TizenAppId tizenAppId = L"tizenid201"; + WidgetDAO dao(tizenAppId); RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getGUID(), "w_id_2000"); RUNNER_ASSERT_WHAT_EQUALS_OPTIONAL(dao.getVersion(), "1.0.0"); @@ -907,9 +907,9 @@ RUNNER_TEST(widget_dao_test_localization) regInfo.localizationData.startFiles.push_back(file); // register widget - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + WidgetDAO dao(tizenAppId); // check localized icons WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList(); @@ -956,8 +956,8 @@ RUNNER_TEST(widget_dao_test_wac_security) WidgetRegisterInfo regInfo; { // register widget - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); + WidgetDAO dao(tizenAppId); RUNNER_ASSERT(!dao.isDistributorSigned()); RUNNER_ASSERT(!dao.isRecognized()); @@ -968,8 +968,8 @@ RUNNER_TEST(widget_dao_test_wac_security) sec.setWacSigned(true); { // register widget - WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); - WidgetDAO dao(pkgname); + TizenAppId tizenAppId = REGISTER_WIDGET(regInfo, sec); + WidgetDAO dao(tizenAppId); RUNNER_ASSERT(dao.isDistributorSigned()); RUNNER_ASSERT(dao.isRecognized()); diff --git a/tests/dao/wrt_dao_tests_prepare_db.sh b/tests/dao/wrt_dao_tests_prepare_db.sh index 4f989f0..c2bde92 100755 --- a/tests/dao/wrt_dao_tests_prepare_db.sh +++ b/tests/dao/wrt_dao_tests_prepare_db.sh @@ -59,14 +59,14 @@ if [ "x$1" == "xstart" ]; then #Widgets INS_ALL_WIDGETEXT="insert into WidgetExtendedInfo(app_id, share_href, signature_type)" - INS_ALL_WIDGET="insert into WidgetInfo(app_id, widget_id, widget_version, widget_width, widget_height, author_name, author_email, author_href, base_folder, webkit_plugins_required, recognized, wac_signed, distributor_signed, min_version, pkgname)" + INS_ALL_WIDGET="insert into WidgetInfo(app_id, widget_id, widget_version, widget_width, widget_height, author_name, author_email, author_href, base_folder, webkit_plugins_required, recognized, wac_signed, distributor_signed, min_version, tizen_appid)" INS_ALL_WIDGET_LOC="insert into LocalizedWidgetInfo(app_id, widget_locale, widget_name, widget_shortname, widget_description, widget_license, widget_license_file, widget_license_href)" INS_ALL_WIDGET_ICONS="insert into WidgetIcon(app_id, icon_src, icon_width, icon_height)" INS_ALL_WIDGET_LOC_ICONS="insert into WidgetLocalizedIcon(app_id, icon_id, widget_locale)" INS_ALL_WIDGET_STARTFILE="insert into WidgetStartFile(app_id, src)" INS_ALL_WIDGET_LOC_STARTFILE="insert into WidgetLocalizedStartFile(app_id, start_file_id, widget_locale, type, encoding)" INS_ALL_WIDGET_DEFPREF="insert into WidgetDefaultPreference(app_id, key_name, key_value, readonly)" - INS_ALL_WIDGET_PREF="insert into WidgetPreference(pkgname, key_name, key_value, readonly)" + INS_ALL_WIDGET_PREF="insert into WidgetPreference(tizen_appid, key_name, key_value, readonly)" INS_ALL_WIDGET_FEATURE="insert into WidgetFeature(app_id, name, required)" INS_ALL_WIDGET_FEATURE_PARAM="insert into FeatureParam(widget_feature_id, name, value)" INS_ALL_WIDGET_WINMODES="insert into WidgetWindowModes(app_id, window_mode)" @@ -78,8 +78,8 @@ if [ "x$1" == "xstart" ]; then sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2000, 'w_id_2000', '1.0.0', 100, 200, 'a_name_2000', 'a_email_2000', 'a_href_2000', 'basef_2000', 1, 1, 1, 1, '1.0', 'tizenid201')"; sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2001, 'w_id_2001', '2.0.0', 100, 200, 'a_name_2001', 'a_email_2001', 'a_href_2001', 'basef_2001', 1, 1, 1, 1, '0.5', 'tizenid202')"; - sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, pkgname) VALUES(2002, 0, 'tizenid203')"; - sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, pkgname) VALUES(2003, 0, 'tizenid204')"; # for properties tests + sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, tizen_appid) VALUES(2002, 0, 'tizenid203')"; + sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, tizen_appid) VALUES(2003, 0, 'tizenid204')"; # for properties tests sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2000, 'share_href_2000', 0)"; sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2001, 'share_href_2001', 0)"; @@ -114,8 +114,8 @@ if [ "x$1" == "xstart" ]; then sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid203', 'key2_for_2002', 'value2_for_key_2002', 1)"; #create if not exists and fix autoincrement value - sqlite3 $WRT_DB "INSERT INTO WidgetInfo(pkgname) VALUES('temp')"; - sqlite3 $WRT_DB "DELETE FROM WidgetInfo WHERE pkgname = 'temp'"; + sqlite3 $WRT_DB "INSERT INTO WidgetInfo(tizen_appid) VALUES('temp')"; + sqlite3 $WRT_DB "DELETE FROM WidgetInfo WHERE tizen_appid = 'temp'"; sqlite3 $WRT_DB "UPDATE sqlite_sequence SET seq = 2004 WHERE name = 'WidgetInfo'"; exit $? diff --git a/tests/dpl/db/test_orm.cpp b/tests/dpl/db/test_orm.cpp index 9295ed2..d2e224f 100644 --- a/tests/dpl/db/test_orm.cpp +++ b/tests/dpl/db/test_orm.cpp @@ -412,7 +412,7 @@ RUNNER_TEST(ORM_Delete) using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::dpl_orm_test; TestTableDelete::Select selectStart(interface.get()); - selectStart.OrderBy("ColumnInt2 ASC"); + selectStart.OrderBy(DPL::TypeListDecl >()); std::list list = selectStart.GetRowList(); std::list originalList = list; @@ -849,3 +849,55 @@ RUNNER_TEST(ORM_Join) oss.str(std::string()); } } + +RUNNER_TEST(ORM_SelectOrderByMultipleColumns) +{ + SmartAttach interface; + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::dpl_orm_test; + { + TestTableJoin3::Select select(interface.get()); + + // testing: " ORDER BY Value3 ASC, TestID DESC, TestID ASC" + select.OrderBy(DPL::TypeListDecl, + OrderingDescending, + OrderingAscending >()); + + std::list result = select.GetRowList(); + std::list::const_iterator iter = result.begin(); + { //1 row + RUNNER_ASSERT_MSG(*iter->Get_TestText33() == DPL::FromASCIIString("test 6"), "Wrong row 1 order"); + RUNNER_ASSERT_MSG(iter->Get_TestID() == 10, "Wrong row 1 order"); + iter++; + } + { //2 row + RUNNER_ASSERT_MSG(*iter->Get_TestText33() == DPL::FromASCIIString("test 5"), "Wrong row 2 order"); + RUNNER_ASSERT_MSG(iter->Get_TestID() == 7, "Wrong row 2 order"); + iter++; + } + { //3 row + RUNNER_ASSERT_MSG(iter->Get_Value3() == 111, "Wrong row 3 order"); + RUNNER_ASSERT_MSG(*iter->Get_TestText33() == DPL::FromASCIIString("test 2"), "Wrong row 3 order"); + RUNNER_ASSERT_MSG(iter->Get_TestID() == 2, "Wrong row 3 order"); + iter++; + } + { //4 row + RUNNER_ASSERT_MSG(iter->Get_Value3() == 111, "Wrong row 4 order"); + RUNNER_ASSERT_MSG(*iter->Get_TestText33() == DPL::FromASCIIString("test 1"), "Wrong row 4 order"); + RUNNER_ASSERT_MSG(iter->Get_TestID() == 1, "Wrong row 4 order"); + iter++; + } + { //5 row + RUNNER_ASSERT_MSG(iter->Get_Value3() == 222, "Wrong row 5 order"); + RUNNER_ASSERT_MSG(*iter->Get_TestText33() == DPL::FromASCIIString("test 4"), "Wrong row 5 order"); + RUNNER_ASSERT_MSG(iter->Get_TestID() == 6, "Wrong row 5 order"); + iter++; + } + { //6 row + RUNNER_ASSERT_MSG(iter->Get_Value3() == 222, "Wrong row 6 order"); + RUNNER_ASSERT_MSG(*iter->Get_TestText33() == DPL::FromASCIIString("test 3"), "Wrong row 6 order"); + RUNNER_ASSERT_MSG(iter->Get_TestID() == 3, "Wrong row 6 order"); + iter++; + } + } +} diff --git a/tests/dpl/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h b/tests/dpl/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h index aae9ce2..5f58018 100644 --- a/tests/dpl/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h +++ b/tests/dpl/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h @@ -158,7 +158,7 @@ class WidgetDAO */ DbWidgetHandle getHandle() const { return m_widgetHandle; } DbWidgetHandle getHandle(const WidgetGUID GUID) const; - static DbWidgetHandle getHandle(const DPL::String pkgName); + static DbWidgetHandle getHandle(const DPL::String tizenAppId); /** * This method returns the root directory of widget resource. diff --git a/tests/dpl/localization/mockup_src/widget_dao.cpp b/tests/dpl/localization/mockup_src/widget_dao.cpp index d781c05..6dc2739 100644 --- a/tests/dpl/localization/mockup_src/widget_dao.cpp +++ b/tests/dpl/localization/mockup_src/widget_dao.cpp @@ -44,7 +44,7 @@ DbWidgetHandle WidgetDAO::getHandle(const WidgetGUID /* GUID */) const return 0; } -DbWidgetHandle WidgetDAO::getHandle(const DPL::String /* pkgName */) +DbWidgetHandle WidgetDAO::getHandle(const DPL::String /* tizenAppId */) { LogError("Not implemented!"); return 0; -- 2.34.1