From: Tomasz Iwanek Date: Tue, 19 Feb 2013 13:42:24 +0000 (+0100) Subject: Enable DPL::Localization tests X-Git-Tag: submit/trunk/20130228.040740~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ccd2c3d3aaface161dee019b22160d1697264f1;p=platform%2Fframework%2Fweb%2Fwrt-commons.git Enable DPL::Localization tests [Issue#] LINUXWRT-132 [Bug] Localization mockup were broken [Cause] N/A [Solution] Remvoe mockups, make fake db as in dao tests [Verification] Run: dpl-tests-loc --output=text dpl-tests-core --output=text --regexp='StaticBlockInitCheck' Change-Id: I8986e3138a87440bd3d544c753deaa5066f37754 --- diff --git a/modules/core/config.cmake b/modules/core/config.cmake index 147f155..b681dd5 100644 --- a/modules/core/config.cmake +++ b/modules/core/config.cmake @@ -123,6 +123,7 @@ SET(DPL_CORE_HEADERS ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/singleton.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/singleton_impl.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/singleton_safe_impl.h + ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/static_block.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/string.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/sstream.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/task.h diff --git a/modules/core/include/dpl/static_block.h b/modules/core/include/dpl/static_block.h new file mode 100644 index 0000000..62fae46 --- /dev/null +++ b/modules/core/include/dpl/static_block.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @file static_block.h + * @author Iwanek Tomasz (t.iwanek@samsung.com) + * @version 1.0 + */ +#ifndef STATIC_BLOCK_H +#define STATIC_BLOCK_H + +#include + +//NOTE: order of static initialization of blocks is not specified + +// to be used only outside class of function scopes +#define STATIC_BLOCK_IMPL( UNIQUE ) \ + static void DPL_MACRO_CONCAT( _staticBlock , UNIQUE() ); \ + static int DPL_MACRO_CONCAT( _staticBlockInitAssurence , UNIQUE ) = []() -> int \ + { \ + (void) DPL_MACRO_CONCAT( _staticBlockInitAssurence , UNIQUE ); \ + DPL_MACRO_CONCAT( _staticBlock , UNIQUE() ); \ + return 0; \ + }(); \ + void DPL_MACRO_CONCAT( _staticBlock , UNIQUE() ) \ + +#define STATIC_BLOCK \ + STATIC_BLOCK_IMPL( __COUNTER__ ) \ + +//for class implementation +#define STATIC_BLOCK_CLASS( classname, methodname ) STATIC_BLOCK { classname::methodname(); } + +#endif // STATIC_BLOCK_H 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 c2b1de2..8152d4d 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 @@ -349,7 +349,7 @@ class WidgetDAOReadOnly * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in * DB table. */ - DPL::String getPath() const; + virtual DPL::String getPath() const; DPL::String getFullPath() const; diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec index 412ea1e..d8d7d6b 100644 --- a/packaging/wrt-commons.spec +++ b/packaging/wrt-commons.spec @@ -141,8 +141,10 @@ echo "[WRT] wrt-commons postinst done ..." %if %{with_tests} %attr(755,root,root) %{_bindir}/wrt-commons-tests-* %attr(755,root,root) %{_bindir}/wrt_dao_tests_prepare_db.sh + %attr(755,root,root) %{_bindir}/wrt_db_localization_prepare.sh %{_datadir}/dbus-1/services/org.tizen.DBusTestService.service /opt/share/wrt/wrt-commons/tests/* + /opt/share/widget/tests/localization/* %endif %files devel diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8ebf885..d3a9edf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,10 +16,10 @@ ADD_SUBDIRECTORY(dao) ADD_SUBDIRECTORY(db) ADD_SUBDIRECTORY(dbus) ADD_SUBDIRECTORY(event) -#ADD_SUBDIRECTORY(files_localization) TODO localization mockups need to be fixed +ADD_SUBDIRECTORY(files_localization) ADD_SUBDIRECTORY(localizationTagsProvider) ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(test) # Rollback CXX flags -#SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_BACKUP}) \ No newline at end of file +#SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_BACKUP}) diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index 9e7ffa4..73e7ec5 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -45,6 +45,7 @@ SET(DPL_TESTS_CORE_SOURCES ${TESTS_DIR}/core/test_scoped_ptr.cpp ${TESTS_DIR}/core/test_semaphore.cpp ${TESTS_DIR}/core/test_shared_ptr.cpp + ${TESTS_DIR}/core/test_static_block.cpp ${TESTS_DIR}/core/test_string.cpp ${TESTS_DIR}/core/test_thread.cpp ${TESTS_DIR}/core/test_type_list.cpp diff --git a/tests/core/test_static_block.cpp b/tests/core/test_static_block.cpp new file mode 100644 index 0000000..0fc686e --- /dev/null +++ b/tests/core/test_static_block.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file test_static_block.cpp + * @author Tomasz Iwanek (t.iwanek@samsung.com) + * @version 0.1 + * @brief + */ + +#include +#include + +RUNNER_TEST_GROUP_INIT(DPL) + +namespace { +bool ok_namespace = false; +bool ok_class = false; + +STATIC_BLOCK +{ + ok_namespace = true; +} + +struct A +{ + static void init() + { + ok_class = true; + } +}; +STATIC_BLOCK_CLASS( A, init ); +} + +/* +Name: StaticBlockInitCheck +Description: checks if static blocks were run +Expected: variables should be set +*/ +RUNNER_TEST(StaticBlockInitCheck) +{ + RUNNER_ASSERT(ok_namespace); + RUNNER_ASSERT(ok_class); +} diff --git a/tests/files_localization/CMakeLists.txt b/tests/files_localization/CMakeLists.txt index 37d79c1..3fdd256 100644 --- a/tests/files_localization/CMakeLists.txt +++ b/tests/files_localization/CMakeLists.txt @@ -29,23 +29,15 @@ SET(TARGET_LOC "wrt-commons-tests-loc") SET(LOC_TESTS_SOURCES - ${TESTS_DIR}/files_localization/test_localization.cpp - ${TESTS_DIR}/files_localization/test_suite01.cpp - #${DPL_TESTS_DIR}/localization/mockup_src/widget_dao.cpp - #${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp - #${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_localization.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_suite01.cpp ) -#WRT_INCLUDE_DIRECTORIES( - #${SYS_EFL_INCLUDE_DIRS} - #${DPL_TEST_INCLUDE_DIR} - #${DPL_TESTS_DIR}/localization/mockup_include - #${PROJECT_SOURCE_DIR}/modules/localization/include -#) - -#LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS}) - +WRT_TEST_ADD_INTERNAL_DEPENDENCIES(${TARGET_LOC} ${TARGET_WRT_DAO_RW_LIB} ${TARGET_CUSTOM_HANDLER_DAO_RW_LIB}) WRT_TEST_BUILD(${TARGET_LOC} ${LOC_TESTS_SOURCES}) WRT_TEST_INSTALL(${TARGET_LOC}) ADD_SUBDIRECTORY(files) + +INSTALL(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/wrt_db_localization_prepare.sh" + DESTINATION bin) diff --git a/tests/files_localization/files/CMakeLists.txt b/tests/files_localization/files/CMakeLists.txt index 17c7fda..65034d3 100644 --- a/tests/files_localization/files/CMakeLists.txt +++ b/tests/files_localization/files/CMakeLists.txt @@ -1,19 +1,19 @@ INSTALL(FILES - ${DPL_TESTS_DIR}/localization/files/one + ${CMAKE_CURRENT_SOURCE_DIR}/one DESTINATION - /opt/share/widget/tests/localization/widget1/locales/pl-en + /opt/share/widget/tests/localization/widget1/res/wgt/locales/pl-en ) INSTALL(FILES - ${DPL_TESTS_DIR}/localization/files/one - ${DPL_TESTS_DIR}/localization/files/two + ${CMAKE_CURRENT_SOURCE_DIR}/one + ${CMAKE_CURRENT_SOURCE_DIR}/two DESTINATION - /opt/share/widget/tests/localization/widget2/locales/pl-en + /opt/share/widget/tests/localization/widget2/res/wgt/locales/pl-en ) INSTALL(FILES - ${DPL_TESTS_DIR}/localization/files/two + ${CMAKE_CURRENT_SOURCE_DIR}/two DESTINATION - /opt/share/widget/tests/localization/widget2/locales/en-en + /opt/share/widget/tests/localization/widget2/res/wgt/locales/en-en ) diff --git a/tests/files_localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h b/tests/files_localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h deleted file mode 100644 index 06b7294..0000000 --- a/tests/files_localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file common_dao_types.h - * @author Michal Ciepielski (m.ciepielski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of common data types for wrtdb - */ - -#ifndef WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ -#define WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ - -#include -#include -#include -#include -#include -#include -#include - -namespace WrtDB { -namespace Powder { -typedef std::set StringSet; -//! Widget description -struct Description -{ - //!Content level - typedef enum - { - Level0 = 0, - Level1, - Level2, - Level3, - Level4, - Level5, - LevelUnknown - } LevelEnum; - struct LevelEntry - { - LevelEnum level; //!< content level - - typedef StringSet Context; - - //! POWDER context - //! xa This material appears in an artistic context - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - Context context; - explicit LevelEntry(LevelEnum level = LevelUnknown); - //! Function checks if context is valid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isContextValid(LevelEnum level, - const DPL::OptionalString& context) const; - }; - - struct CategoryEntry - { - //! Levels entries for POWDER description - typedef std::vector LevelsContainer; - LevelsContainer levels; - //! Function checks if context is valid - //! \param[out] reason set if context invalid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isCategoryValid(LevelEntry& reason, - LevelEnum level, - const DPL::OptionalString& context) const; - }; - - //! POWDER Category -> Category entry map for Widget - //! - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - typedef std::map CategoryEntries; - - CategoryEntries categories; - - //! Age rating for widget - //! If Null not set - DPL::OptionalInt ageRating; -}; -} // namespace Powder - -namespace ChildProtection { -//! Blacklist with forbidden URLs -//! It should be stored in WidgetDAO -typedef std::vector BlackList; - -//! Widget Child protection record -//! Record should be stored in WingetDAO -struct Record -{ - //! Child protection enabled - bool enabled; - explicit Record(bool enabled) : - enabled(enabled) - {} -}; - -//! Powder processing -struct PowderRules -{ - //! Rule set by parent about forbidden category - //! Powder category - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - //! Powder context - //! xa This material appears in an artistic conteaxt - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - struct CategoryRule - { - DPL::String category; - Powder::Description::LevelEnum level; - DPL::OptionalString context; - explicit CategoryRule( - const DPL::String& category = DPL::String(), - Powder::Description::LevelEnum level = - Powder::Description::LevelUnknown, - const DPL::OptionalString& context = - DPL::OptionalString()); - }; - - struct PowderResult - { - //! Reasoning outcome: part of POWDER description used to invalidate - Powder::Description::LevelEntry invalidDescription; - //! Reasoning outcome: rule set by parent not full filed by description - CategoryRule invalidRule; - - //! Reasoning outcome: type of invalidity - enum InvalidReason - { - InvalidRule, //!< One of rules was not fulfilled - InvalidAge, //!< Age is invalid - AgeRatingNotSet, //!< Age rating for widget is not set - Valid //!< Description valid - }; - InvalidReason reason; - explicit PowderResult( - InvalidReason reason = Valid, - const Powder::Description::LevelEntry& - invalidDescription = - Powder::Description::LevelEntry(), - const CategoryRule& invalidRule = CategoryRule()); - }; - - typedef std::pair ResultPair; - - //! Function checks if rule is fulfilled by description - //! \param[in] rule checked rule - //! \param[in] description - //! \retval true rule is valid - //! \retval false rule is invalid - ResultPair isRuleValidForDescription(const CategoryRule& rule, - const Powder::Description& description) - const; - //! Function checks if age limit is fulfilled by description - //! \param[in] description - //! \retval true age is valid - //! \retval false age is invalid - ResultPair isAgeValidForDescription( - const Powder::Description& description) const; - - //! It is the maximum age rating valid for child - //! Uniform age is stored in WidgetDAO - DPL::OptionalInt ageLimit; - - //! Set to true if age rating is required - //! If ageLimit is not set value is ignored - bool isAgeRatingRequired; - - //! Set of rules configured by parent - //! Rules are stored in WidgetDAO and are uniform for all widgets - typedef std::vector RulesContainer; - RulesContainer rules; - - //! Function check if Widget description is valid for ChildProtection - //! configuration - //! \param description widget description - //! \retval true widget is valid - //! \retval false widget is invalid - ResultPair isDescriptionValid(const Powder::Description& description) - const; - - PowderRules() : - isAgeRatingRequired(false) - {} -}; -} // namespace ChildProtection - -class PluginMetafileData -{ - public: - struct Feature - { - std::string m_name; - std::set m_deviceCapabilities; - - bool operator< (const Feature& obj) const - { - return m_name < obj.m_name; - } - }; - typedef std::set FeatureContainer; - - public: - - PluginMetafileData() - {} - - std::string m_libraryName; - std::string m_featuresInstallURI; - std::string m_featuresKeyCN; - std::string m_featuresRootCN; - std::string m_featuresRootFingerprint; - - FeatureContainer m_featureContainer; -}; - -class PluginObjectsDAO -{ - public: - typedef std::set Objects; - typedef std::shared_ptr ObjectsPtr; - - public: - explicit PluginObjectsDAO() {} - - protected: - ObjectsPtr m_implemented; - ObjectsPtr m_dependent; -}; - -/** - * @brief Widget id describes web-runtime global widget identifier. - * - * Notice that only up to one widget can exist at the same time. - * DbWidgetHandle can be translated into corresponding WidgetModel by invoking - * FindWidgetModel routine. - */ -typedef int DbWidgetHandle; - -/** - * @brief Structure to hold the information of widget's size - */ -struct DbWidgetSize -{ - DPL::OptionalInt width; - DPL::OptionalInt height; - - DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null, - DPL::OptionalInt h = DPL::OptionalInt::Null) : - width(w), - height(h) - {} -}; - -inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB) -{ - if (!objA.height || !objA.width || !objB.width || !objB.height) { - return false; - } else { - return *objA.height == *objB.height && *objA.width == *objB.width; - } -} - -/** - * Widget [G]lobal [U]nique [ID]entifier - * Orginated from appstore ID - */ -typedef DPL::OptionalString WidgetGUID; - -struct WidgetAccessInfo -{ - DPL::String strIRI; /* origin iri */ - bool bSubDomains; /* do we want access to subdomains ? */ - - bool operator ==(const WidgetAccessInfo& info) const - { - return info.strIRI == strIRI && - info.bSubDomains == bSubDomains; - } -}; - -typedef std::list WidgetAccessInfoList; - -typedef std::list WindowModeList; - -/** - * @brief Widget configuration parameter key - */ -typedef DPL::String WidgetParamKey; - -/** - * @brief Widget configuration parameter value - */ -typedef DPL::String WidgetParamValue; - -/** - * @brief A map of widget configuration parameters. - * - * Widget configuration parameters are read from database and are stored - * along with feature that they describe. - */ -typedef std::multimap WidgetParamMap; - -/** - * @brief Widget feature host information about possible javascript extensions - * that widget may use - * - * Widget features are declared in configuration file in widget installation - * package. Each declared special feature is contained in some wrt-plugin that - * declares to implement it. After widget launch wrt searches for proper plugin - * libraries and load needed features. - * - * Widget features can be required or optional. It is possible to start widget - * without missing feature. When required feature cannot be loaded widget will - * not start. - */ - -enum { - INVALID_PLUGIN_HANDLE = -1 -}; -typedef int DbPluginHandle; - -struct DbWidgetFeature -{ - DPL::String name; /// Feature name - bool required; /// Whether feature is required - DbPluginHandle pluginId; /// Plugin id that implement this - // feature - WidgetParamMap params; /// Widget's params - - DbWidgetFeature() : - required(false), - pluginId(INVALID_PLUGIN_HANDLE) - {} -}; - -inline bool operator < (const DbWidgetFeature &objA, - const DbWidgetFeature &objB) -{ - return objA.name.compare(objB.name) < 0; -} - -inline bool operator==(const DbWidgetFeature &featureA, - const DbWidgetFeature &featureB) -{ - return featureA.name == featureB.name && - featureA.required == featureB.required && - featureA.pluginId == featureB.pluginId; -} - -/** - * @brief Default container for features list - */ -typedef std::multiset DbWidgetFeatureSet; - -/** - * @brief Default container with DbWidgetHandle's - */ -typedef std::list DbWidgetHandleList; - -/** - * @brief Widget specific type - * - * Widget type describes belowed in WAC, TIZEN WebApp - */ -enum AppType -{ - APP_TYPE_UNKNOWN = 0, // unknown - APP_TYPE_WAC20, // WAC 2.0 - APP_TYPE_TIZENWEBAPP, // slp webapp -}; - -class WidgetType -{ - public: - WidgetType() : - appType(APP_TYPE_UNKNOWN) - {} - WidgetType(const AppType type) : - appType(type) - {} - bool operator== (const AppType& other) const - { - return appType == other; - } - std::string getApptypeToString() - { - switch (appType) { -#define X(x) case x: return #x; - X(APP_TYPE_UNKNOWN) - X(APP_TYPE_WAC20) - X(APP_TYPE_TIZENWEBAPP) -#undef X - default: - return "UNKNOWN"; - } - } - - AppType appType; -}; -} // namespace WrtDB - -struct WidgetSetting -{ - DPL::String settingName; - DPL::String settingValue; - - bool operator ==(const WidgetSetting& info) const - { - return (info.settingName == settingName && - info.settingValue == settingValue); - } - bool operator !=(const WidgetSetting& info) const - { - return (info.settingName != settingName || - info.settingValue != settingValue); - } -}; - -typedef std::list WidgetSettings; - -/** - * @brief Widget Application Service - * - * Application sercvice describes details of behaviour - * when widget receives aul bundle data. - */ -struct WidgetApplicationService -{ - public: - DPL::String src; /* start uri */ - DPL::String operation; /* service name */ - DPL::String scheme; /* scheme type*/ - DPL::String mime; /* mime type */ - - bool operator== (const WidgetApplicationService& other) const - { - return src == other.src && - operation == other.operation && - scheme == other.scheme && - mime == other.mime; - } -}; - -typedef std::list WidgetApplicationServiceList; -#endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */ diff --git a/tests/files_localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h b/tests/files_localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h deleted file mode 100644 index 264c6e4..0000000 --- a/tests/files_localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of widget dao class. - * - * @file widget_dao_read_only.h - * @author Yang Jie (jie2.yang@samsung.com) - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of widget dao - */ - -#ifndef _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ -#define _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -//#include "../wrt-dao-ro/common_dao_types.h" - -typedef DPL::OptionalString WidgetGUID; - -namespace ConfigParserData { -struct Icon -{ - Icon(const DPL::String& src) : src(src) - {} - DPL::String src; - DPL::OptionalInt width; - DPL::OptionalInt height; - bool operator==(const Icon&) const; - bool operator!=(const Icon&) const; - bool operator >(const Icon&) const; - bool operator>=(const Icon&) const; - bool operator <(const Icon&) const; - bool operator<=(const Icon&) const; -}; -} // namespace ConfigParserData -namespace WrtDB { -typedef std::list StringList; - -struct WidgetLocalizedInfo -{ - DPL::OptionalString name; - DPL::OptionalString shortName; - DPL::OptionalString description; - DPL::OptionalString license; - DPL::OptionalString licenseHref; -}; - -typedef std::list LanguageTagList; - -class WidgetDAO -{ - public: - /** - * WidgetDAO Exception classes - */ - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, DatabaseError) - DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty) - DECLARE_EXCEPTION_TYPE(Base, GUIDisNull) - DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult) - DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist) - DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered) - }; - - protected: - DbWidgetHandle m_widgetHandle; - - public: - struct WidgetLocalizedIconRow - { - int appId; - int iconId; - DPL::String widgetLocale; - }; - typedef std::list WidgetLocalizedIconList; - - struct WidgetIconRow - { - int iconId; - int appId; - DPL::String iconSrc; - DPL::OptionalInt iconWidth; - DPL::OptionalInt iconHeight; - }; - typedef std::list WidgetIconList; - - struct WidgetStartFileRow - { - int startFileId; - int appId; - DPL::String src; - }; - typedef std::list WidgetStartFileList; - - struct WidgetLocalizedStartFileRow - { - int startFileId; - int appId; - DPL::String widgetLocale; - DPL::String type; - DPL::String encoding; - }; - typedef std::list LocalizedStartFileList; - - /** - * This is a constructor. - * - * @param[in] widgetHandle application id of widget. - */ - WidgetDAO(DbWidgetHandle widgetHandle) : - m_widgetHandle(widgetHandle) - {} - - /** - * Destructor - */ - virtual ~WidgetDAO(){} - - /** - * This method returns widget handle(m_widgetHandle). - * - * @return widget handle(m_widgetHandle). - * @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. - */ - DbWidgetHandle getHandle() const - { - return m_widgetHandle; - } - DbWidgetHandle getHandle(const WidgetGUID GUID) const; - static DbWidgetHandle getHandle(const DPL::String tizenAppId); - - /** - * This method returns the root directory of widget resource. - * - * @return path name of root directory. - * @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::String getPath() const; - void setPath(const DPL::String &path) const; - - /** - * This method returns the defaultlocale for the widget. - * - * @return defaultlocale - * @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 getDefaultlocale() const; - - /** - * This method returns list of localized icons files; - * - * @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. - */ - WidgetLocalizedIconList getLocalizedIconList() const; - - /** - * This method returns list of icons files; - * - * @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. - */ - WidgetIconList getIconList() const; - - /** - * This method returns list of localized start files; - * - * @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. - */ - LocalizedStartFileList getLocalizedStartFileList() const; - void setLocalizedStartFileList(const LocalizedStartFileList &list) const; - /** - * This method returns list of start files; - * - * @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. - */ - WidgetStartFileList getStartFileList() const; - void setStartFileList(const WidgetStartFileList &list) const; - - WidgetLocalizedInfo getLocalizedInfo(const DPL::String& languageTag) const; - - protected: - static std::map s_startFileMap; - static std::map s_localizedStartFileMap; - static std::map s_pathMap; -}; -} // namespace WrtDB - -#endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ - diff --git a/tests/files_localization/mockup_src/widget_dao.cpp b/tests/files_localization/mockup_src/widget_dao.cpp deleted file mode 100644 index 170aad7..0000000 --- a/tests/files_localization/mockup_src/widget_dao.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of widget dao class. - * - * @file widget_dao_read_only.cpp - * @author Yang Jie (jie2.yang@samsung.com) - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of widget dao - */ - -//#include "../mockup_include/dpl/wrt-dao-rw/widget_dao.h" -#include - -#include -#include -#include -#include - -namespace WrtDB { -std::map WidgetDAO::s_startFileMap; -std::map WidgetDAO::s_localizedStartFileMap; -std::map WidgetDAO::s_pathMap; - -DbWidgetHandle WidgetDAO::getHandle(const WidgetGUID /* GUID */) const -{ - LogError("Not impleneted!"); - return 0; -} - -DbWidgetHandle WidgetDAO::getHandle(const DPL::String /* tizenAppId */) -{ - LogError("Not implemented!"); - return 0; -} - -DPL::String WidgetDAO::getPath() const -{ - return s_pathMap[m_widgetHandle]; -} - -void WidgetDAO::setPath(const DPL::String &path) const -{ - s_pathMap[m_widgetHandle] = path; -} - -WidgetLocalizedInfo -WidgetDAO::getLocalizedInfo(const DPL::String& /* languageTag */) -const -{ - LogError("Not implemented!"); - return WidgetLocalizedInfo(); -} - -DPL::OptionalString WidgetDAO::getDefaultlocale() const -{ - LogError("Not implemented!"); - return DPL::OptionalString(); -} - -WidgetDAO::WidgetLocalizedIconList WidgetDAO::getLocalizedIconList() const -{ - LogError("Not implemented!"); - return WidgetLocalizedIconList(); -} - -WidgetDAO::WidgetIconList WidgetDAO::getIconList() const -{ - LogError("Not implemented!"); - return WidgetIconList(); -} - -WidgetDAO::LocalizedStartFileList WidgetDAO::getLocalizedStartFileList() const -{ - return s_localizedStartFileMap[m_widgetHandle]; -} - -void WidgetDAO::setLocalizedStartFileList(const LocalizedStartFileList &list) -const -{ - s_localizedStartFileMap[m_widgetHandle] = list; -} - -WidgetDAO::WidgetStartFileList WidgetDAO::getStartFileList() const -{ - return s_startFileMap[m_widgetHandle]; -} - -void WidgetDAO::setStartFileList(const WidgetStartFileList &list) const -{ - s_startFileMap[m_widgetHandle] = list; -} -} // namespace WrtDB diff --git a/tests/files_localization/test_localization.cpp b/tests/files_localization/test_localization.cpp index 42ffe3a..ae4925a 100644 --- a/tests/files_localization/test_localization.cpp +++ b/tests/files_localization/test_localization.cpp @@ -20,9 +20,29 @@ * @brief This file is the implementation file of main */ #include +#include +#include int main(int argc, char *argv[]) { - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); + + int ret = system("/usr/bin/wrt_db_localization_prepare.sh start"); + if (ret != 0) { + LogError("Preparation script has return error: " << ret + << ". Quitting"); + return -1; + } + + WrtDB::WrtDatabase::attachToThreadRW(); + int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); + WrtDB::WrtDatabase::detachFromThread(); + + ret = system("/usr/bin/wrt_db_localization_prepare.sh stop"); + if (ret != 0) { + LogError("Preparation script has return error: " << ret + << ". Quitting"); + return -1; + } + return status; } diff --git a/tests/files_localization/test_suite01.cpp b/tests/files_localization/test_suite01.cpp index d3cb174..d2d28ed 100644 --- a/tests/files_localization/test_suite01.cpp +++ b/tests/files_localization/test_suite01.cpp @@ -24,22 +24,22 @@ #include #include - -//#include "mockup_include/dpl/wrt-dao-rw/widget_dao.h" -#include +#include +#include #include +#include namespace { -WrtDB::LanguageTagList generateLanguageTags() + +STATIC_BLOCK { WrtDB::LanguageTagList tags; tags.push_back(L"pl-pl"); tags.push_back(L"en-en"); tags.push_back(L"pl-en"); - return tags; + LanguageTagsProviderSingleton::Instance().setLanguageTags(tags); } -static const WrtDB::LanguageTagList languageTags = generateLanguageTags(); static const DPL::String widget1Path = L"/opt/share/widget/tests/localization/widget1/"; static const DPL::String widget2Path = @@ -47,73 +47,68 @@ static const DPL::String widget2Path = } // anonymous namespace RUNNER_TEST(test01_getFilePathInWidgetPackageFromUrl){ - const int widgetHandle = 1; - WrtDB::WidgetDAO dao(widgetHandle); - //dao.setPath(widget1Path); + WrtDB::WidgetPkgName name = L"tizenid201"; + WrtDB::WidgetDAOReadOnly dao(name); - auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( - widgetHandle, - languageTags, - L"widget://one"); + DPL::Optional result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( + name, + DPL::String(L"widget://one")); + RUNNER_ASSERT_MSG(!!result, "No result"); RUNNER_ASSERT( *result == - L"/opt/share/widget/tests/localization/widget1/locales/pl-en/one"); + L"/opt/share/widget/tests/localization/widget1/res/wgt/locales/pl-en/one"); } RUNNER_TEST(test02_getFilePathInWidgetPackageFromUrl){ - const int widgetHandle = 2; - WrtDB::WidgetDAO dao(widgetHandle); - //dao.setPath(widget2Path); + WrtDB::WidgetPkgName name = L"tizenid202"; + WrtDB::WidgetDAOReadOnly dao(name); - auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( - widgetHandle, - languageTags, - L"widget://one"); + DPL::Optional result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( + name, + DPL::String(L"widget://one")); + RUNNER_ASSERT_MSG(!!result, "No result"); RUNNER_ASSERT( *result == - L"/opt/share/widget/tests/localization/widget2/locales/pl-en/one"); + L"/opt/share/widget/tests/localization/widget2/res/wgt/locales/pl-en/one"); } RUNNER_TEST(test03_getFilePathInWidgetPackageFromUrl){ - const int widgetHandle = 2; - WrtDB::WidgetDAO dao(widgetHandle); - //dao.setPath(widget2Path); + WrtDB::WidgetPkgName name = L"tizenid202"; + WrtDB::WidgetDAOReadOnly dao(name); - auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( - widgetHandle, - languageTags, - L"widget://two"); + DPL::Optional result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl( + name, + DPL::String(L"widget://two")); + RUNNER_ASSERT_MSG(!!result, "No result"); RUNNER_ASSERT( *result == - L"/opt/share/widget/tests/localization/widget2/locales/en-en/two"); + L"/opt/share/widget/tests/localization/widget2/res/wgt/locales/en-en/two"); } RUNNER_TEST(test04_getFilePathInWidgetPackage){ - const int widgetHandle = 1; - WrtDB::WidgetDAO dao(widgetHandle); - //dao.setPath(widget1Path); + WrtDB::WidgetPkgName name = L"tizenid201"; + WrtDB::WidgetDAOReadOnly dao(name); - auto result = W3CFileLocalization::getFilePathInWidgetPackage( - widgetHandle, - languageTags, - L"one"); + DPL::Optional result = W3CFileLocalization::getFilePathInWidgetPackage( + name, + DPL::String(L"one")); + RUNNER_ASSERT_MSG(!!result, "No result"); RUNNER_ASSERT(*result == L"locales/pl-en/one"); } RUNNER_TEST(test05_getFilePathInWidgetPackage){ - const int widgetHandle = 2; - WrtDB::WidgetDAO dao(widgetHandle); - //dao.setPath(widget2Path); + WrtDB::WidgetPkgName name = L"tizenid202"; + WrtDB::WidgetDAOReadOnly dao(name); - auto result = W3CFileLocalization::getFilePathInWidgetPackage( - widgetHandle, - languageTags, - L"two"); + DPL::Optional result = W3CFileLocalization::getFilePathInWidgetPackage( + name, + DPL::String(L"two")); + RUNNER_ASSERT_MSG(!!result, "No result"); RUNNER_ASSERT(*result == L"locales/en-en/two"); } diff --git a/tests/files_localization/wrt_db_localization_prepare.sh b/tests/files_localization/wrt_db_localization_prepare.sh new file mode 100644 index 0000000..67bed04 --- /dev/null +++ b/tests/files_localization/wrt_db_localization_prepare.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -e + +trap 'echo "Script failed"; exit 1' ERR + +WRT_DB=/opt/dbspace/.wrt.db +WRT_DB_BCK=/tmp/wrt.db_backup +WIDGET_INSTALL_PATH=/opt/usr/apps + +case $1 in + start) + echo "start" + cp $WRT_DB $WRT_DB_BCK + wrt_commons_create_clean_db.sh + + #Widgets + INS_ALL_WIDGETEXT="insert into WidgetExtendedInfo(app_id, installed_path)" + INS_ALL_WIDGET="insert into WidgetInfo(app_id, tizen_appid)" + + sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(1, 'tizenid201')"; + sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2, 'tizenid202')"; + sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(1, '/opt/share/widget/tests/localization/widget1')"; + sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2, '/opt/share/widget/tests/localization/widget2')"; + exit 0 + ;; + stop) + echo "stop"; + cp $WRT_DB_BCK $WRT_DB + exit 0 + ;; + *) + echo "nothing to do" + exit 1 + ;; +esac