${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
--- /dev/null
+/*
+ * 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 <dpl/preprocessor.h>
+
+//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
* @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;
%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
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})
${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
--- /dev/null
+/*
+ * 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 <dpl/test/test_runner.h>
+#include <dpl/static_block.h>
+
+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);
+}
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)
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
)
+++ /dev/null
-/*
- * 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 <set>
-#include <string>
-#include <map>
-#include <vector>
-#include <list>
-#include <dpl/optional_typedefs.h>
-#include <memory>
-
-namespace WrtDB {
-namespace Powder {
-typedef std::set<DPL::String> 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 <LevelEntry> 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<DPL::String, CategoryEntry> 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<DPL::String> 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<bool, PowderResult> 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<CategoryRule> 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<std::string> m_deviceCapabilities;
-
- bool operator< (const Feature& obj) const
- {
- return m_name < obj.m_name;
- }
- };
- typedef std::set<Feature> 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<std::string> Objects;
- typedef std::shared_ptr<Objects> 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<WidgetAccessInfo> WidgetAccessInfoList;
-
-typedef std::list<DPL::String> 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<WidgetParamKey, WidgetParamValue> 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<DbWidgetFeature> DbWidgetFeatureSet;
-
-/**
- * @brief Default container with DbWidgetHandle's
- */
-typedef std::list<DbWidgetHandle> 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<WidgetSetting> 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<WidgetApplicationService> WidgetApplicationServiceList;
-#endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */
+++ /dev/null
-/*
- * 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 <time.h>
-
-#include <list>
-#include <map>
-#include <set>
-#include <string>
-
-#include <dpl/string.h>
-#include <dpl/exception.h>
-#include <dpl/optional_typedefs.h>
-
-#include <dpl/wrt-dao-ro/common_dao_types.h>
-//#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<DPL::String> StringList;
-
-struct WidgetLocalizedInfo
-{
- DPL::OptionalString name;
- DPL::OptionalString shortName;
- DPL::OptionalString description;
- DPL::OptionalString license;
- DPL::OptionalString licenseHref;
-};
-
-typedef std::list<DPL::String> 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<WidgetLocalizedIconRow> WidgetLocalizedIconList;
-
- struct WidgetIconRow
- {
- int iconId;
- int appId;
- DPL::String iconSrc;
- DPL::OptionalInt iconWidth;
- DPL::OptionalInt iconHeight;
- };
- typedef std::list<WidgetIconRow> WidgetIconList;
-
- struct WidgetStartFileRow
- {
- int startFileId;
- int appId;
- DPL::String src;
- };
- typedef std::list<WidgetStartFileRow> WidgetStartFileList;
-
- struct WidgetLocalizedStartFileRow
- {
- int startFileId;
- int appId;
- DPL::String widgetLocale;
- DPL::String type;
- DPL::String encoding;
- };
- typedef std::list<WidgetLocalizedStartFileRow> 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<DbWidgetHandle, WidgetStartFileList> s_startFileMap;
- static std::map<DbWidgetHandle,
- LocalizedStartFileList> s_localizedStartFileMap;
- static std::map<DbWidgetHandle, DPL::String> s_pathMap;
-};
-} // namespace WrtDB
-
-#endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_
-
+++ /dev/null
-/*
- * 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 <dpl/wrt-dao-rw/widget_dao.h>
-
-#include <sstream>
-#include <dpl/foreach.h>
-#include <dpl/log/log.h>
-#include <dpl/sstream.h>
-
-namespace WrtDB {
-std::map<DbWidgetHandle,
- WidgetDAO::WidgetStartFileList> WidgetDAO::s_startFileMap;
-std::map<DbWidgetHandle,
- WidgetDAO::LocalizedStartFileList> WidgetDAO::s_localizedStartFileMap;
-std::map<DbWidgetHandle, DPL::String> 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
* @brief This file is the implementation file of main
*/
#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
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;
}
#include <dpl/log/log.h>
#include <dpl/test/test_runner.h>
-
-//#include "mockup_include/dpl/wrt-dao-rw/widget_dao.h"
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/static_block.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/localization/w3c_file_localization.h>
+#include <LanguageTagsProvider.h>
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 =
} // 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<DPL::String> 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<DPL::String> 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<DPL::String> 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<DPL::String> 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<DPL::String> result = W3CFileLocalization::getFilePathInWidgetPackage(
+ name,
+ DPL::String(L"two"));
+ RUNNER_ASSERT_MSG(!!result, "No result");
RUNNER_ASSERT(*result == L"locales/en-en/two");
}
--- /dev/null
+#!/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