From f153679c09b85770c8f4491f70b8cf47517940a7 Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Mon, 24 Jun 2013 23:39:22 +0900 Subject: [PATCH] [Release] wrt-commons_0.2.134 Change-Id: Ib3164844a629a8ced82e2316eb8449c9799e8c5d --- modules/support/wrt_plugin_export.h | 10 +-- modules/widget_dao/dao/plugin_dao_read_only.cpp | 29 ++++++++ modules/widget_dao/dao/property_dao_read_only.cpp | 42 ++++++----- .../include/dpl/wrt-dao-ro/plugin_dao_read_only.h | 1 + packaging/wrt-commons.spec | 2 +- tests/dao/TestCases_PropertyDAO.cpp | 81 ++++++++++++++++++---- tests/dao/wrt_dao_tests_prepare_db.sh | 12 ++-- 7 files changed, 131 insertions(+), 46 deletions(-) diff --git a/modules/support/wrt_plugin_export.h b/modules/support/wrt_plugin_export.h index ae1e8e1..0cf4e37 100644 --- a/modules/support/wrt_plugin_export.h +++ b/modules/support/wrt_plugin_export.h @@ -138,7 +138,7 @@ typedef enum class_definition_iframe_behaviour_e //it is default one NONE, //object should be copied as reference to each iframe - REFERENCE, + REFERENCE, // deprecated //object should be created for each iframe and NOT inform plugin CREATE_INSTANCE } class_definition_iframe_behaviour_t; @@ -153,9 +153,9 @@ typedef enum class_definition_iframe_notice_e typedef enum class_definition_iframe_overlay_e { IGNORED, - USE_OVERLAYED, - OVERLAYED_BEFORE_ORIGINAL -} class_definition_iframe_overlay_t; + USE_OVERLAYED, //deprecated + OVERLAYED_BEFORE_ORIGINAL //deprecated +} class_definition_iframe_overlay_t; //deprecated typedef void* js_object_instance_t; //global_context - id @@ -170,7 +170,7 @@ typedef struct class_definition_options_s class_definition_type_t type; class_definition_iframe_behaviour_t iframe_option; class_definition_iframe_notice_t iframe_notice; - class_definition_iframe_overlay_t iframe_overlay; + class_definition_iframe_overlay_t iframe_overlay; //deprecated iframe_loaded_cb cb; void * private_data; js_function_impl function; diff --git a/modules/widget_dao/dao/plugin_dao_read_only.cpp b/modules/widget_dao/dao/plugin_dao_read_only.cpp index 045cdd6..a90e013 100644 --- a/modules/widget_dao/dao/plugin_dao_read_only.cpp +++ b/modules/widget_dao/dao/plugin_dao_read_only.cpp @@ -275,6 +275,35 @@ DbPluginHandle PluginDAOReadOnly::getPluginHandleForImplementedObject( } } +ImplementedObjectsList PluginDAOReadOnly::getImplementedObjects() +{ + LogDebug("getImplementedObjects"); + + Try + { + ImplementedObjectsList objectList; + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + WRT_DB_SELECT(select, PluginImplementedObjects, &WrtDatabase::interface()) + std::list valueList = select->GetValueList(); + + if (!valueList.empty()) { + FOREACH(it, valueList) + { + objectList.push_back(DPL::ToUTF8String(*it)); + } + } else { + LogWarning("PluginHandle for object not found"); + } + return objectList; + } + Catch(DPL::DB::SqlConnection::Exception::Base) { + ReThrowMsg(PluginDAOReadOnly::Exception::DatabaseError, + "Failed in GetPluginHandleForImplementedObject"); + } +} + ImplementedObjectsList PluginDAOReadOnly::getImplementedObjectsForPluginHandle( DbPluginHandle handle) { diff --git a/modules/widget_dao/dao/property_dao_read_only.cpp b/modules/widget_dao/dao/property_dao_read_only.cpp index 5e06afc..3676d5a 100644 --- a/modules/widget_dao/dao/property_dao_read_only.cpp +++ b/modules/widget_dao/dao/property_dao_read_only.cpp @@ -133,42 +133,40 @@ WidgetPropertyKeyList GetPropertyKeyList(TizenAppId tzAppid) } } -//deprecated -WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle) -{ - Try { - TizenAppId tzAppid = WidgetDAOReadOnly::getTzAppId(widgetHandle); - return GetPropertyList(tzAppid); - } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist){ - WidgetPreferenceList empty; - return empty; - } -} -WidgetPreferenceList GetPropertyList(TizenAppId tzAppId) +WidgetPreferenceList GetPropertyListRows(DbWidgetHandle widgetHandle) { - LogDebug("Get Property list. tizenAppId: " << tzAppId); Try { using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::wrt; - - DbWidgetHandle widgetHandle(WidgetDAOReadOnly::getHandle(tzAppId)); - WRT_DB_SELECT(select, WidgetPreference, &WrtDatabase::interface()) - select->Where(Equals(widgetHandle)); - + select->Where(Equals(widgetHandle)); ORMWidgetPreferenceList ormPrefList = select->GetRowList(); WidgetPreferenceList prefList; convertWidgetPreferenceRow(ormPrefList, prefList); - return prefList; - } - Catch(DPL::DB::SqlConnection::Exception::Base){ + }Catch(DPL::DB::SqlConnection::Exception::Base){ ReThrowMsg(Exception::DatabaseError, - "Failure during getting property list"); + "Failure during getting property list"); } } +WidgetPreferenceList GetPropertyList(DbWidgetHandle widgetHandle) +{ + if(!(WidgetDAOReadOnly::isWidgetInstalled(widgetHandle))) + ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, + "Failed to get widget"); + return GetPropertyListRows(widgetHandle); +} + +WidgetPreferenceList GetPropertyList(TizenAppId tzAppId) +{ + LogDebug("Get Property list. tizenAppId: " << tzAppId); + DbWidgetHandle widgetHandle(WidgetDAOReadOnly::getHandle(tzAppId)); + return GetPropertyListRows(widgetHandle); +} + + WidgetPropertyValue GetPropertyValue(TizenAppId tzAppid, const WidgetPropertyKey &key) { diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h index 293cf13..3be2441 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h @@ -90,6 +90,7 @@ class PluginDAOReadOnly static DbPluginHandle getPluginHandleForImplementedObject( const std::string& objectName); + static ImplementedObjectsList getImplementedObjects(); static ImplementedObjectsList getImplementedObjectsForPluginHandle( DbPluginHandle handle); diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec index 87da17f..42f9bbb 100644 --- a/packaging/wrt-commons.spec +++ b/packaging/wrt-commons.spec @@ -1,7 +1,7 @@ #git:framework/web/wrt-commons Name: wrt-commons Summary: Wrt common library -Version: 0.2.133 +Version: 0.2.134 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 diff --git a/tests/dao/TestCases_PropertyDAO.cpp b/tests/dao/TestCases_PropertyDAO.cpp index effd898..8ddc977 100644 --- a/tests/dao/TestCases_PropertyDAO.cpp +++ b/tests/dao/TestCases_PropertyDAO.cpp @@ -27,6 +27,7 @@ #include #include #include +#include using namespace WrtDB; using namespace WrtDB::PropertyDAOReadOnly; @@ -46,6 +47,7 @@ using namespace WrtDB::PropertyDAOReadOnly; RUNNER_TEST_GROUP_INIT(DAO) + /* * Name: property_dao_get_lists * Description: tests returning list of properties for given id @@ -55,20 +57,35 @@ RUNNER_TEST_GROUP_INIT(DAO) RUNNER_TEST(property_dao_get_lists) { { //property list - std::map prefsMap; - prefsMap.insert(std::pair(L"tizenid201", 2)); - prefsMap.insert(std::pair(L"tizenid202", 1)); - prefsMap.insert(std::pair(L"tizenid203", 2)); - //no widget - prefsMap.insert(std::pair(L"non_exists", 0)); - - FOREACH(it, prefsMap) { - PropertyDAOReadOnly::WidgetPreferenceList prefs = - PropertyDAOReadOnly::GetPropertyList(it->first); - RUNNER_ASSERT(prefs.size() == it->second); + struct three_field{ + WrtDB::TizenAppId tappid; + DbWidgetHandle whandleid; + size_t nrow; + }; + + three_field f3; + std::list prefList; + std::list::iterator it; + + f3.tappid=L"tizenid201";f3.whandleid=2000;f3.nrow=2; + prefList.push_back(f3); + f3.tappid=L"tizenid202"; f3.whandleid=2001;f3.nrow=1; + prefList.push_back(f3); + f3.tappid=L"tizenid203"; f3.whandleid=2002;f3.nrow=2; + prefList.push_back(f3); + f3.tappid=L"tizenid204"; f3.whandleid=2003;f3.nrow=0; + prefList.push_back(f3); + + for(it=prefList.begin();it!=prefList.end();++it) + { + PropertyDAOReadOnly::WidgetPreferenceList prefs_tid = + PropertyDAOReadOnly::GetPropertyList(it->tappid); + RUNNER_ASSERT(prefs_tid.size() == it->nrow); + PropertyDAOReadOnly::WidgetPreferenceList prefs_aid = + PropertyDAOReadOnly::GetPropertyList(it->whandleid); + RUNNER_ASSERT(prefs_aid.size() == it->nrow); } } - { //property key list WidgetPropertyKeyList orig_2000; orig_2000.push_back(DPL::FromUTF8String("key1_for_2000")); @@ -102,6 +119,46 @@ RUNNER_TEST(property_dao_get_lists) } } + +/* + * Name: property_dao_get_list_exceptions + * Description: tests returning exception for given tizen_appid if is + * not inserted into WidgetInfo table + * Expected: procedure passes when is exception. Widget absent in the WidgetInfo + * table. + */ +RUNNER_TEST(property_dao_get_list_exceptions) +{ + { + bool assert_flag; + WrtDB::TizenAppId app_id_non_exists = L"non_exists"; + + assert_flag=true; + Try{ + PropertyDAOReadOnly::WidgetPreferenceList prefs = + PropertyDAOReadOnly::GetPropertyList(app_id_non_exists); + } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) + { + assert_flag=false; + } + RUNNER_ASSERT_MSG(!(assert_flag),"Error, value doesn't make exception"); + } + { + bool assert_flag; + DbWidgetHandle handle_non_exist(2010); + assert_flag=true; + Try{ + PropertyDAOReadOnly::WidgetPreferenceList prefs = + PropertyDAOReadOnly::GetPropertyList(handle_non_exist); + } Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) + { + assert_flag=false; + } + RUNNER_ASSERT_MSG(!(assert_flag),"Error, value doesn't make exception"); + } +} + + /* * Name: property_dao_set_update_remove * Description: tests set new property for widget, updating property and diff --git a/tests/dao/wrt_dao_tests_prepare_db.sh b/tests/dao/wrt_dao_tests_prepare_db.sh index ccb98f6..9666e87 100755 --- a/tests/dao/wrt_dao_tests_prepare_db.sh +++ b/tests/dao/wrt_dao_tests_prepare_db.sh @@ -66,7 +66,7 @@ if [ "x$1" == "xstart" ]; then 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(tizen_appid, key_name, key_value, readonly)" + INS_ALL_WIDGET_PREF="insert into WidgetPreference(app_id,tizen_appid, key_name, key_value, readonly)" INS_ALL_WIDGET_FEATURE="insert into WidgetFeature(app_id, name)" INS_ALL_WIDGET_WINMODES="insert into WidgetWindowModes(app_id, window_mode)" INS_ALL_WIDGET_WARP="insert into WidgetWARPInfo(app_id, iri, subdomain_access)" @@ -106,11 +106,11 @@ if [ "x$1" == "xstart" ]; then sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2003, 4, 'en', '', '')"; #widget properties - sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid201', 'key1_for_2000', 'value_for_key1_2000', 0)"; - sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid201', 'key2_for_2000', 'value_for_key2_2000', 0)"; - sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid202', 'key1_for_2001', 'value1_for_key_2001', 1)"; - sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid203', 'key1_for_2002', 'value1_for_key_2002', 0)"; - sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tizenid203', 'key2_for_2002', 'value2_for_key_2002', 1)"; + sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES(2000,'tizenid201', 'key1_for_2000', 'value_for_key1_2000', 0)"; + sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES(2000,'tizenid201', 'key2_for_2000', 'value_for_key2_2000', 0)"; + sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES(2001,'tizenid202', 'key1_for_2001', 'value1_for_key_2001', 1)"; + sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES(2002,'tizenid203', 'key1_for_2002', 'value1_for_key_2002', 0)"; + sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES(2002,'tizenid203', 'key2_for_2002', 'value2_for_key_2002', 1)"; #create if not exists and fix autoincrement value sqlite3 $WRT_DB "INSERT INTO WidgetInfo(tizen_appid) VALUES('temp')"; -- 2.7.4