registerWidgetSecuritySettings - nested transaction removal. New widget dao testcase
authorTomasz Iwanek <t.iwanek@samsung.com>
Mon, 17 Dec 2012 14:28:30 +0000 (15:28 +0100)
committerGerrit Code Review <gerrit2@kim11>
Wed, 19 Dec 2012 13:26:57 +0000 (22:26 +0900)
[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
tests/dao/TestCases_WidgetDAO.cpp

index 5f8ca9b..e078797 100644 (file)
@@ -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()
index c04752a..e26f45d 100644 (file)
@@ -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