From 1905f3046baa40712d6521e4541b07e44538ea89 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Mon, 17 Dec 2012 15:28:30 +0100 Subject: [PATCH] registerWidgetSecuritySettings - nested transaction removal. New widget dao testcase [Issue#] LINUXNGWAP-592 [Bug] Not neccessary nested transaction [Cause] Not neccessary nested transaction [Solution] Remove it. Add testcase: widget_dao_test_register_widget_security_settings to widget_dao [Verification] Build repository. Run new test: wrt-tests-dao --output=text --regexp="widget_dao" (21 - all should pass, including new one) Change-Id: I40b5b6ed739809697706ed152b05df5d4a5c7f3f --- modules/widget_dao/dao/widget_dao.cpp | 27 ++++++--------- tests/dao/TestCases_WidgetDAO.cpp | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index 5f8ca9b..e078797 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -827,24 +827,17 @@ void WidgetDAO::registerExternalLocations(DbWidgetHandle widgetHandle, void WidgetDAO::registerWidgetSecuritySettings(DbWidgetHandle widgetHandle) { - SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN - { - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::wrt; - DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface()); - - WidgetSecuritySettings::Row row; - row.Set_app_id(widgetHandle); - row.Set_security_popup_usage(SETTINGS_TYPE_ON); - row.Set_geolocation_usage(SETTINGS_TYPE_ON); - row.Set_web_notification_usage(SETTINGS_TYPE_ON); - row.Set_web_database_usage(SETTINGS_TYPE_ON); - row.Set_file_system_usage(SETTINGS_TYPE_ON); + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + WidgetSecuritySettings::Row row; + row.Set_app_id(widgetHandle); + row.Set_security_popup_usage(SETTINGS_TYPE_ON); + row.Set_geolocation_usage(SETTINGS_TYPE_ON); + row.Set_web_notification_usage(SETTINGS_TYPE_ON); + row.Set_web_database_usage(SETTINGS_TYPE_ON); + row.Set_file_system_usage(SETTINGS_TYPE_ON); - DO_INSERT(row, WidgetSecuritySettings) - transaction.Commit(); - } - SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register external files"); + DO_INSERT(row, WidgetSecuritySettings) } void WidgetDAO::unregisterAllExternalLocations() diff --git a/tests/dao/TestCases_WidgetDAO.cpp b/tests/dao/TestCases_WidgetDAO.cpp index c04752a..e26f45d 100644 --- a/tests/dao/TestCases_WidgetDAO.cpp +++ b/tests/dao/TestCases_WidgetDAO.cpp @@ -535,6 +535,68 @@ RUNNER_TEST(widget_dao_test_register_widget_features) } /* +Name: widget_dao_test_register_widget_security_settings +Description: Tests registeration of dafault values of security settings +Expected: widget should be registered in database. + Returned values should match dafault. +*/ +RUNNER_TEST(widget_dao_test_register_widget_security_settings) +{ + WacSecurityMock sec; + WidgetRegisterInfo regInfo; + WidgetPkgName pkgname = REGISTER_WIDGET(regInfo, sec); + + WidgetDAO dao(pkgname); + 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"); + RUNNER_ASSERT_MSG(dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON, "WebDatabaseUsage is not deafult on"); + RUNNER_ASSERT_MSG(dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON, "FileSystemUsage is not deafult on"); + + dao.setSecurityPopupUsage(WrtDB::SETTINGS_TYPE_OFF); + RUNNER_ASSERT_MSG(dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF, "SecurityPopupUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ON, "GeolocationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_ON, "WebNotificationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON, "WebDatabaseUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON, "FileSystemUsage - wrong value"); + + dao.setGeolocationUsage(WrtDB::SETTINGS_TYPE_ALWAYS_ASK); + RUNNER_ASSERT_MSG(dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF, "SecurityPopupUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "GeolocationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_ON, "WebNotificationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON, "WebDatabaseUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON, "FileSystemUsage - wrong value"); + + dao.setWebNotificationUsage(WrtDB::SETTINGS_TYPE_OFF); + RUNNER_ASSERT_MSG(dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF, "SecurityPopupUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "GeolocationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF, "WebNotificationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ON, "WebDatabaseUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON, "FileSystemUsage - wrong value"); + + dao.setWebDatabaseUsage(WrtDB::SETTINGS_TYPE_ALWAYS_ASK); + RUNNER_ASSERT_MSG(dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF, "SecurityPopupUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "GeolocationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF, "WebNotificationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "WebDatabaseUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON, "FileSystemUsage - wrong value"); + + dao.setFileSystemUsage(WrtDB::SETTINGS_TYPE_OFF); + RUNNER_ASSERT_MSG(dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF, "SecurityPopupUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "GeolocationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF, "WebNotificationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "WebDatabaseUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_OFF, "FileSystemUsage - wrong value"); + + dao.setFileSystemUsage(WrtDB::SETTINGS_TYPE_ON); + RUNNER_ASSERT_MSG(dao.getSecurityPopupUsage() == WrtDB::SETTINGS_TYPE_OFF, "SecurityPopupUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getGeolocationUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "GeolocationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebNotificationUsage() == WrtDB::SETTINGS_TYPE_OFF, "WebNotificationUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getWebDatabaseUsage() == WrtDB::SETTINGS_TYPE_ALWAYS_ASK, "WebDatabaseUsage - wrong value"); + RUNNER_ASSERT_MSG(dao.getFileSystemUsage() == WrtDB::SETTINGS_TYPE_ON, "FileSystemUsage - wrong value"); +} + +/* Name: widget_dao_test_register_widget_win_modes Description: Tests registeration of window modes Expected: all modes should be returned from dao -- 2.7.4