--- /dev/null
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*.ipk
+*~
+/cmake-build
+/bin
+/build-stamp
+/configure-stamp
+tests/db/orm/dpl_orm_test.db-journal
+.cproject
+.project
+debian/files
+debian/wrt-commons-dbg.substvars
+debian/wrt-commons-dbg/*
+debian/wrt-commons-dev.substvars
+debian/wrt-commons-dev/*
+debian/wrt-commons.postinst.debhelper
+debian/wrt-commons.postrm.debhelper
+debian/wrt-commons.substvars
+debian/wrt-commons/*
MESSAGE(STATUS "Logging disabled for DPL")
ENDIF(DPL_LOG)
-ADD_DEFINITIONS("-DSEPARATED_SINGLETON_IMPLEMENTATION")
STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}")
ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"")
+# Comment this to disable control of global settings with environment variable
+ADD_DEFINITIONS("-DGLOBAL_SETTINGS_CONTROL")
+
# Build type
-SET(CMAKE_BUILD_TYPE "Release")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
-SET(CMAKE_CXX_FLAGS "-O2 -g -fPIC -D_FORTIFY_SOURCE=0")
+IF(NOT CMAKE_BUILD_TYPE)
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF(NOT CMAKE_BUILD_TYPE)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+SET(CMAKE_CXX_FLAGS "-O2 -g -fPIC -D_FORTIFY_SOURCE=0")
+SET(CMAKE_CXX_FLAGS_CCOV "-O0 -g -fPIC -D_FORTIFY_SOURCE=0 --coverage")
# CMake settings
MESSAGE(STATUS "========================================")
+++ /dev/null
-#!/bin/sh
-
-./dpl-tests-core --output=text
-./dpl-tests-dbus --output=text
-./dpl-tests-db --output=text
-./dpl-tests-event --output=text
ADD_SUBDIRECTORY(auto_save_dao)
ADD_SUBDIRECTORY(popup)
ADD_SUBDIRECTORY(utils)
+ADD_SUBDIRECTORY(support)
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(SYS_EFL_DBUS
dbus-1
+ gio-2.0
REQUIRED)
# Add core include directories
# @brief
#
-SET(DPL_TEST_INCLUDE_DIR
- ${DPL_CORE_INCLUDE_DIR}
- ${DPL_EVENT_INCLUDE_DIR}
- ${DPL_DBUS_INCLUDE_DIR}
- ${DPL_DB_INCLUDE_DIR}
- ${DPL_RPC_INCLUDE_DIR}
- ${DPL_SOCKET_INCLUDE_DIR}
- ${DPL_TEST_ENGINE_INCLUDE_DIR}
- ${DPL_LOG_INCLUDE_DIR}
-)
+# Install headers
+INSTALL(FILES ${DPL_WRT_ENGINE_HEADERS}
+ DESTINATION include/dpl-efl/wrt-commons)
-ADD_SUBDIRECTORY(core)
-ADD_SUBDIRECTORY(dbus)
-ADD_SUBDIRECTORY(db)
-ADD_SUBDIRECTORY(event)
-ADD_SUBDIRECTORY(localization)
+# Install pkgconfig script
+configure_and_install_pkg(wrt-plugins-types.pc)
--- /dev/null
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: wrt-plugins-types
+Description: Header for plugins types
+Version: @VERSION@
+Requires:
+Libs:
+Cflags: -I${includedir}/dpl-efl/wrt-commons
${DPL_LOG_INCLUDE_DIR}
${DPL_CORE_INCLUDE_DIR}
${DPL_TEST_ENGINE_INCLUDE_DIR}
+ ${DPL_UTILS_INCLUDE_DIR}
${SYS_EFL_TEST_ENGINE_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(${TARGET_DPL_TEST_ENGINE_EFL}
${TARGET_DPL_EFL}
+ ${TARGET_DPL_UTILS_EFL}
)
# Target library properties
+wrt-commons (0.2.53) unstable; urgency=low
+
+ * Added new build type for code coverage
+ * User Agent Database update
+ * Added new SQLConnection flag - CRW and null query check
+ * Remove "auto" for fixed build break
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.53
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 09 Aug 2012 15:16:30 +0900
+
+wrt-commons (0.2.52) unstable; urgency=low
+
+ * Re-upload package
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.52
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Tue, 31 Jul 2012 11:15:58 +0900
+
+wrt-commons (0.2.51) unstable; urgency=low
+
+ * Re-upload package
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.51
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 30 Jul 2012 10:06:49 +0900
+
+wrt-commons (0.2.50) unstable; urgency=low
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.50
+
+ -- Leerang Song <leerang.song@samsung.com> Fri, 27 Jul 2012 12:02:06 +0900
+
+wrt-commons (0.2.49) unstable; urgency=low
+
+ * Add splash screen
+ * Fix circular dependency to cert-svc
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.49
+
+ -- Zbigniew Kostrzewa <z.kostrzewa@samsung.com> Wed, 25 Jul 2012 14:36:40 +0200
+
+wrt-commons (0.2.48) unstable; urgency=low
+
+ * Fixed CCR(#N_SE-3620)
+ * FeatureDAOReadOnly - performance improvement
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.48
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Wed, 25 Jul 2012 09:58:22 +0900
+
+wrt-commons (0.2.47) unstable; urgency=low
+
+ * Change installed resource path & Add PackageType
+ * support tizen extension requirement regarding application id / required version
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.47
+
+ -- Leerang Song <leerang.song@samsung.com> Thu, 19 Jul 2012 19:19:39 +0900
+
+wrt-commons (0.2.46-1) unstable; urgency=low
+
+ * Add tag for auto SR
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.46-1
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 12 Jul 2012 15:25:36 +0900
+
+wrt-commons (0.2.46) unstable; urgency=low
+
+ * Remove auto save for WK1
+ * Support auto save id/password for WK2
+ * Multiple INVALID_WIDGET_HANDLE definition
+ * Wrt DB DefferedWidgetPackageInstallation clean up
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.46
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 12 Jul 2012 10:56:48 +0900
+
+wrt-commons (0.2.45) unstable; urgency=low
+
+ * Fingerprint list should not contain empty strings
+ * Add frame load and unload callback
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.45
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 28 Jun 2012 16:30:53 +0900
+
+wrt-commons (0.2.44) unstable; urgency=low
+
+ * Move create directory("/opt/apps/widget/")
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.44
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 21 Jun 2012 11:13:38 +0900
+
+wrt-commons (0.2.43) unstable; urgency=low
+
+ * Remove WK1
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.43
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Tue, 19 Jun 2012 09:46:13 +0900
+
+wrt-commons (0.2.42) unstable; urgency=low
+
+ * Fix build break in wrt-security
+ * Remove warning when reset .wrt.db
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.42
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Fri, 15 Jun 2012 10:31:34 +0900
+
+wrt-commons (0.2.41) unstable; urgency=low
+
+ * Clean up unused api in FeatureDAO
+ * Nested loop removal
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.41
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 31 May 2012 11:40:41 +0900
+
+wrt-commons (0.2.40) unstable; urgency=low
+
+ * Unused code removal
+ * wrt_reset_all.sh changed to remove all widgets files
+ * Modify desktop default icon path for installer
+ * Add wrt-client prefix for wk2
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.40
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 24 May 2012 18:04:34 +0900
+
+wrt-commons (0.2.39) unstable; urgency=low
+
+ * Separated singleton implementation removal
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.39
+
+ -- Pawel Sikorski <p.sikorski@samsung.com> Mon, 21 May 2012 15:26:54 +0200
+
+wrt-commons (0.2.38) unstable; urgency=low
+
+ * Refactoring common_dao for auto_save
+ * ZipInput simplified
+ * Nested loop removall
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.38
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 21 May 2012 17:13:15 +0900
+
+wrt-commons (0.2.37) unstable; urgency=low
+
+ * Tests leftovers removal
+ * Remove unused DPL::MultiTaskDecl
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.37
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 17 May 2012 19:49:51 +0900
+
+wrt-commons (0.2.36) unstable; urgency=low
+
+ * Script to reset wrt (wrt_reset_all.sh)
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.36
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 14 May 2012 18:28:43 +0900
+
+wrt-commons (0.2.35) unstable; urgency=low
+
+ * Prepare widgetDAO to get different widget IDs
+ * depends on "add recovery mechanism.." commit
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.35
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 07 May 2012 17:35:10 +0900
+
+wrt-commons (0.2.34) unstable; urgency=low
+
+ * Patch for compliance test widget-api/NoInterfaceObject
+ * TLV pthread reference issue
+ * Changing WidgetDAO rw to ro permissions where appropriate
+ * JIL and WAC1.0 leftovers removal
+ * Widget StartFile localizedPath fix
+ * Switching to the TestModeFlag - final step
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.34
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 03 May 2012 10:11:41 +0900
+
+wrt-commons (0.2.33) unstable; urgency=low
+
+ * UserAgent locales removed
+ * Deprecated api removed
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.33
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 23 Apr 2012 14:10:21 +0900
+
+wrt-commons (0.2.32) unstable; urgency=low
+
+ * Language changed callback move to WRT engine
+ * Modify the access rights for Semaphore method
+ * Ultimate solution to test mode flag
+ * Web App data sharing From orange requirement
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.32
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 16 Apr 2012 09:48:09 +0900
+
+wrt-commons (0.2.31) unstable; urgency=low
+
+ * Mapping from features to device caps is obtained from .so
+ * Exposed pc file for wrt-plugin-export header
+ * Common environment test flag
+ * getUserAgentLocales added to WidgetDAOReadOnly
+ * TAP tests results collector
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.31
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 09 Apr 2012 10:25:57 +0900
+
+wrt-commons (0.2.30) unstable; urgency=low
+
+ * clean-up powder, parental mode
+ * Revert "[wrt-commons] Added global config API and desktop_file_name_field in wrt_db"
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.30
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Wed, 28 Mar 2012 18:25:06 +0900
+
+wrt-commons (0.2.29) unstable; urgency=low
+
+ * Change user name to user id
+ * Adding cookie sharing mode field
+ * Added global config API and desktop_file_name_field in wrt_db
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.29
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Tue, 27 Mar 2012 17:05:15 +0900
+
+wrt-commons (0.2.28) unstable; urgency=low
+
+ * Optimize OBS
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.28
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Fri, 23 Mar 2012 10:10:42 +0900
+
+wrt-commons (0.2.27) unstable; urgency=low
+
+ * add libxml2-dev to 'Depends' of wrt-commons-dev package
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.27
+
+ -- Yunchan Cho <yunchan.cho@samsung.com> Mon, 19 Mar 2012 19:01:09 +0900
+
+wrt-commons (0.2.26) unstable; urgency=low
+
+ * Create ".wrt_autosave.db"
+
+ * Git : slp/pkgs/w/wrt-commons
+ * Tag : wrt-commons_0.2.26
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Mon, 19 Mar 2012 13:31:14 +0900
+
wrt-commons (0.2.25-1) unstable; urgency=low
* Apply changed EFL APIs
Maintainer: Lukasz Wrzosek<l.wrzosek@samsung.com>, Taejeong.lee <taejeong.lee@samsung.com>
Standards-Version: 3.7.2
Uploaders: Yunchan Cho <yunchan.cho@samsung.com>,Przemyslaw Dobrowolski <p.dobrowolsk@samsung.com>, Pawel Sikorski <p.sikorski@samsung.com>, Zbigniew Kostrzewa <z.kostrzewa@samsung.com>
-Build-Depends: debhelper (>= 5), libecore-dev, libslp-setting-dev (>=0.2.5-2), libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libglib2.0-dev, libslp-db-util-dev (>= 0.1.0-23), zlib1g-dev, libpcre-dev, libicu-dev, libxmlsec1-dev, openssl, libxml2-dev, libsoup2.4-dev, libcert-svc-dev, libiri-dev, libidn11-dev
+Build-Depends: debhelper (>= 5), libecore-dev, libslp-setting-dev (>=0.2.5-2), libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libglib2.0-dev, libslp-db-util-dev (>= 0.1.0-23), zlib1g-dev, libpcre-dev, libicu-dev, libxmlsec1-dev, openssl, libxml2-dev, libsoup2.4-dev, libiri-dev, libidn11-dev
# If you want to build version of gtk, comment out above one live and use the following one line
#Build-Depends: debhelper (>= 5), libecore-dev, libslp-setting-dev (>=0.2.5-2), libappcore-efl-dev, libssl-dev, libsqlite3-dev, dlog-dev (>= 0.2.14-0), libglib2.0-dev, libslp-db-util-dev (>= 0.1.0-23), libgtk2.0-dev, zlib1g-dev, libpcre-dev, libicu-dev
+++ /dev/null
-/usr/bin/dpl-test*
-/usr/bin/dpl-dbus-test-service
-/opt/apps/wrt/wrt-commons/tests/*
-/usr/share/dbus-1/services/org.tizen.DBusTestService.service
-/opt/apps/widget/tests/localization/*
# limitations under the License.
#
-wrt_commons_create_clean_db.sh
-
rm -rf /opt/apps/widget/system/*
-# This directories contains test widgets and test keys. It shouldn't be removed.
-#rm -rf /opt/apps/widget/user/*
-#rm -rf /opt/apps/widget/data/*
-
#Removing of widget desktop icons
-WIDGET_EXEC_PATH=/opt/apps/widget/exec
-WIDGET_DESKTOP_PATH=/opt/share/install-info/application
-WIDGET_ICON_PATH=/opt/share/icons/default/small
-WIDGET_EXECS="${WIDGET_EXEC_PATH}/*";
-
-for file in $WIDGET_EXECS; do
- widget_id=${file#${WIDGET_EXEC_PATH}/};
-
- widget_desktop_file="${WIDGET_DESKTOP_PATH}/org.tizen.${widget_id}.desktop";
- if [ -f ${widget_desktop_file} ]; then
- echo "rm -f $widget_desktop_file";
- rm -f $widget_desktop_file;
- fi
-
- widget_icon_file="${WIDGET_ICON_PATH}/${widget_id}.*"
- if [ -f ${widget_icon_file} ]; then
- echo "rm -f $widget_icon_file";
- rm -f $widget_icon_file;
- fi
-done
-
-rm -rf /opt/apps/widget/exec/*
-touch /opt/apps/widget/plugin-installation-required
+WIDGET_EXEC_PATH=/opt/apps/
+WIDGET_DESKTOP_PATH=/opt/share/applications/
+WRT_DB=/opt/dbspace/.wrt.db
+PLUGINS_INSTALLATION_REQUIRED_PATH=/opt/apps/widget/
+PLUGINS_INSTALLATION_REQUIRED=plugin-installation-required
+
+if [ -f ${WRT_DB} ]
+then
+ PKG_NAME_SET=$(sqlite3 $WRT_DB 'select pkgname from WidgetInfo;')
+ for pkgname in $PKG_NAME_SET
+ do
+ rm -rf ${WIDGET_EXEC_PATH}${pkgname}
+ widget_desktop_file="${WIDGET_DESKTOP_PATH}${pkgname}.desktop";
+ if [ -f ${widget_desktop_file} ]; then
+ rm -f $widget_desktop_file;
+ fi
+ done
+else
+ echo "${WRT_DB} doesn't exist"
+fi
+wrt_commons_create_clean_db.sh
+if [ -e ${PLUGINS_INSTALLATION_REQUIRED_PATH} ] && [ -d ${PLUGINS_INSTALLATION_REQUIRED_PATH} ]
+then
+ touch ${PLUGINS_INSTALLATION_REQUIRED_PATH}${PLUGINS_INSTALLATION_REQUIRED}
+fi
include(popup/config.cmake)
include(utils/config.cmake)
include(localization/config.cmake)
+include(support/config.cmake)
#include <wrt-commons/auto-save-dao-rw/auto_save_dao.h>
#include <wrt-commons/auto-save-dao/AutoSaveDatabase.h>
#include <orm_generator_autosave.h>
+#include <dpl/foreach.h>
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::autosave;
m_autoSavedbInterface.DetachFromThread();
}
-void AutoSaveDAO::setAutoSaveIdPasswd(const DPL::String &url,
- const AutoSaveData &saveData)
+void AutoSaveDAO::setAutoSaveSubmitFormData(const DPL::String &url,
+ const SubmitFormData &submitFormData)
{
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
{
ScopedTransaction transaction(&m_autoSavedbInterface);
- AutoSaveIdPasswd::Row row;
- row.Set_address(url);
- row.Set_userId(saveData.userId);
- row.Set_passwd(saveData.passwd);
-
- DPL::Optional<AutoSaveData> savedData =
- getAutoSaveIdPasswd(url);
+ SubmitFormData submitData = getAutoSaveSubmitFormData(url);
+ if (!submitData.empty()) {
+ AUTOSAVE_DB_DELETE(del,
+ AutoSaveSubmitFormElement,
+ &m_autoSavedbInterface)
+ del->Where(Equals<AutoSaveSubmitFormElement::address>(url));
+ del->Execute();
+ }
- if (!savedData.IsNull()) {
- AUTOSAVE_DB_UPDATE(update, AutoSaveIdPasswd, &m_autoSavedbInterface)
+ FOREACH(pSubmitFormData, submitFormData) {
+ AutoSaveSubmitFormElement::Row row;
+ row.Set_address(url);
+ row.Set_key(pSubmitFormData->key);
+ row.Set_value(pSubmitFormData->value);
- update->Where(Equals<AutoSaveIdPasswd::address>(url));
- update->Values(row);
- update->Execute();
- } else {
AUTOSAVE_DB_INSERT(
- insert, AutoSaveIdPasswd, &m_autoSavedbInterface);
+ insert, AutoSaveSubmitFormElement, &m_autoSavedbInterface);
insert->Values(row);
insert->Execute();
}
SQL_CONNECTION_EXCEPTION_HANDLER_END(
"Fail to register id, passwd for autosave")
}
-
#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
#undef SQL_CONNECTION_EXCEPTION_HANDLER_END
#include <wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h>
#include <wrt-commons/auto-save-dao/AutoSaveDatabase.h>
#include <orm_generator_autosave.h>
+#include <dpl/foreach.h>
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::autosave;
m_autoSavedbInterface.DetachFromThread();
}
-DPL::Optional<AutoSaveData>
- AutoSaveDAOReadOnly::getAutoSaveIdPasswd(const DPL::String &url)
+SubmitFormData AutoSaveDAOReadOnly::getAutoSaveSubmitFormData(
+ const DPL::String &url)
{
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
{
- AUTOSAVE_DB_SELECT(select, AutoSaveIdPasswd, &m_autoSavedbInterface);
- select->Where(Equals<AutoSaveIdPasswd::address>(url));
- AutoSaveIdPasswd::Select::RowList rows = select->GetRowList();
+ AUTOSAVE_DB_SELECT(select, AutoSaveSubmitFormElement, &m_autoSavedbInterface);
+ select->Where(Equals<AutoSaveSubmitFormElement::address>(url));
+ AutoSaveSubmitFormElement::Select::RowList rows = select->GetRowList();
- if (rows.empty()) {
- return DPL::Optional<AutoSaveData>::Null;
+ SubmitFormData submitFormData;
+ FOREACH(it, rows) {
+ SubmitFormElement element;
+ element.key = it->Get_key();
+ element.value = it->Get_value();
+ submitFormData.push_back(element);
}
-
- AutoSaveData saveData;
- saveData.userId = rows.front().Get_userId();
- saveData.passwd = rows.front().Get_passwd();
- return saveData;
+ return submitFormData;
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get autosave data string")
}
#include <dpl/string.h>
#include <dpl/exception.h>
+#include <dpl/optional.h>
#include <wrt-commons/auto-save-dao/common_dao_types.h>
namespace AutoSaveDB {
/**
* This method gets Autofill for Webkit
*/
- static DPL::Optional<AutoSaveData> getAutoSaveIdPasswd(
+ static SubmitFormData getAutoSaveSubmitFormData(
const DPL::String &url);
};
/**
* This method sets Autofill for Webkit
*/
- static void setAutoSaveIdPasswd(
- const DPL::String &url, const AutoSaveData &saveData);
-
+ static void setAutoSaveSubmitFormData(
+ const DPL::String& url, const SubmitFormData &submitFormData);
};
} // namespace AutoSaveDB
#ifndef SHARE_COMMON_DAO_TYPES_H_
#define SHARE_COMMON_DAO_TYPES_H_
-#include <dpl/optional_typedefs.h>
+#include <list>
+#include <dpl/string.h>
namespace AutoSaveDB {
-struct AutoSaveData
+struct SubmitFormElement
{
- DPL::String userId;
- DPL::String passwd;
+ DPL::String key;
+ DPL::String value;
+
+ SubmitFormElement()
+ {
+ }
+
+ SubmitFormElement(
+ const DPL::String& keyData,
+ const DPL::String& valueData) :
+ key(keyData),
+ value(valueData)
+ {
+ }
+
+ bool operator== (const SubmitFormElement& other) const
+ {
+ return (!DPL::StringCompare(key, other.key) &&
+ !DPL::StringCompare(value, other.value));
+ }
+
+ bool operator!= (const SubmitFormElement& other) const
+ {
+ return !(*this == other);
+ }
};
+typedef std::list<SubmitFormElement> SubmitFormData;
} // namespace AutoSaveDB
BEGIN TRANSACTION;
)
-CREATE_TABLE(AutoSaveIdPasswd)
- COLUMN_NOT_NULL(address, VARCHAR(256), unique)
- COLUMN_NOT_NULL(userId, VARCHAR(128),)
- COLUMN_NOT_NULL(passwd, VARCHAR(128),)
+CREATE_TABLE(AutoSaveSubmitFormElement)
+ COLUMN_NOT_NULL(address, VARCHAR(256))
+ COLUMN_NOT_NULL(key, TEXT,)
+ COLUMN_NOT_NULL(value, TEXT,)
CREATE_TABLE_END()
SQL(
${PROJECT_SOURCE_DIR}/modules/core/src/exception.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/fast_delegate.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/file_input.cpp
- ${PROJECT_SOURCE_DIR}/modules/core/src/file_input_mapping.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/file_output.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/lexical_cast.cpp
${PROJECT_SOURCE_DIR}/modules/core/src/mutex.cpp
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/exception.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/fast_delegate.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_input.h
- ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_input_mapping.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_output.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/foreach.h
${PROJECT_SOURCE_DIR}/modules/core/include/dpl/generic_event.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.
- */
-/*
- * @file file_input_mapping.h
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the header file of file input mapping
- */
-#ifndef DPL_FILE_INPUT_MAPPING_H
-#define DPL_FILE_INPUT_MAPPING_H
-
-#include <dpl/exception.h>
-#include <dpl/noncopyable.h>
-
-namespace DPL
-{
-class FileInputMapping
- : private Noncopyable
-{
-public:
- class Exception
- {
- public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, OpenFailed)
- };
-
-private:
- int m_handle;
- off64_t m_size;
- unsigned char *m_address;
-
-public:
- /**
- * Constructor
- */
- explicit FileInputMapping(const std::string &fileName);
-
- /**
- * Destructor
- */
- ~FileInputMapping();
-
- /**
- * Get file mapping total size
- *
- * @return 64-bit size
- */
- off64_t GetSize() const;
-
- /**
- * Get file mapping base address
- *
- * @return Base address of file mapping
- */
- const unsigned char *GetAddress() const;
-};
-} // namespace DPL
-
-#endif // DPL_FILE_INPUT_MAPPING_H
sem_t *InternalGet() const;
void InternalDestroy();
+public:
+ /**
+ * decrement the semaphore counter
+ */
void Lock() const;
- void Unlock() const;
-public:
/**
+ * increment the semaphore counter
+ */
+ void Unlock() const;
+
+ /**
* Remove a named semaphore
*
* @param fileName Name of the semaphore
static void ResetThreadGuard();
};
-//This is needed for backward compatibility
-#ifndef SEPARATED_SINGLETON_IMPLEMENTATION
-template<typename Class>
-Singleton<Class>& Singleton<Class>::InternalInstance()
-{
- static Singleton<Class> instance;
- return instance;
-}
-
-template<typename Class>
-Class &Singleton<Class>::Instance()
-{
- Singleton<Class>& instance = Singleton<Class>::InternalInstance();
-
- if (!!instance.m_guard)
- {
- Assert(Thread::GetCurrentThread() == *instance.m_guard &&
- "Singleton thread guard failed. A forbidden call from foreign thread was detected!");
- }
-
- return instance;
-}
-
-// Thread guarding
-template<typename Class>
-void Singleton<Class>::SetThreadGuard(Thread *thread)
-{
- Singleton<Class>& instance = Singleton<Class>::InternalInstance();
- instance.m_guard = OptionalThreadPtr(thread);
-}
-
-template<typename Class>
-void Singleton<Class>::ResetThreadGuard()
-{
- Singleton<Class>& instance = Singleton<Class>::InternalInstance();
- instance.m_guard = OptionalThreadPtr::Null;
-}
-
-#endif
-
} // namespace DPL
#endif // DPL_SINGLETON_H
#ifndef DPL_TASK_H
#define DPL_TASK_H
-#include <dpl/scoped_array.h>
#include <dpl/noncopyable.h>
-#include <dpl/union_cast.h>
-#include <dpl/semaphore.h>
#include <dpl/foreach.h>
-#include <dpl/mutex.h>
#include <dpl/assert.h>
-#include <dpl/log/log.h>
#include <algorithm>
-#include <sstream>
-#include <iomanip>
#include <list>
-#include <stack>
-#include <cctype>
namespace DPL
{
return static_cast<size_t>(m_steps.size());
}
};
-
-template<typename ImplementationType>
-class MultiTaskDecl
- : public Task
-{
-protected:
- typedef void (ImplementationType::*Step)();
- typedef std::list<Step> StepList;
- typedef std::stack<Step> StepStack;
-
-private:
- static std::string StepToString(Step step)
- {
- std::ostringstream pseudoAddressStream;
- pseudoAddressStream << std::hex << union_cast<size_t>(step);
-
- std::string pseudoAddress = pseudoAddressStream.str();
-
- std::transform(pseudoAddress.begin(), pseudoAddress.end(),
- pseudoAddress.begin(), ::toupper);
-
- return std::string("0x") + pseudoAddress;
- }
-
- struct ConditionalStep
- {
- Step step;
-
- // Depencency lists
- StepList unsatisfiedDependencies;
- StepList satisfiedDependencies;
-
- ConditionalStep()
- : step(NULL)
- {
- }
-
- ConditionalStep(Step stepArg,
- StepList dependenciesArg)
- : step(stepArg),
- unsatisfiedDependencies(dependenciesArg)
- {
- }
- };
-
- typedef std::list<ConditionalStep> ConditionalStepList;
-
- // Synchronization
- Semaphore m_activeStepsSemaphore;
- mutable Mutex m_dependencyListMutex;
-
- // Those steps that have their dependency lists satified and are ready
- // to be executed
- // Current step is defined to be the front of satisfied list
- ConditionalStepList m_satisfiedSteps;
-
- // Those steps that are going to be executed but their dependency
- // lists have not been satified
- ConditionalStepList m_unsatisfiedSteps;
-
- // Those steps that have their dependency lists satified and are currently
- // being executed
- ConditionalStepList m_executingSteps;
-
- // Those steps that have been executed with their dependency lists
- // satisfied
- ConditionalStepList m_historicSteps;
-
- ///< Growing list of submitted abort steps
- StepStack m_abortSteps;
-
- // Deriving implementation
- ImplementationType *m_implementation;
-
- // Max parallel steps
- size_t m_maxParallelCount;
-
- ///< Valid in dependency list mutex only
- void SatisfyDependencies(const ConditionalStep &conditionalStep)
- {
- LogPedantic("Satisfying steps with dependecy to step: "
- << StepToString(conditionalStep.step));
-
- // Can satisfy conditional steps if and only if there are no more
- // satisfied, unsatisfied or running same steps
- // There is at least one historic step - this one
- if (IsContainingStep(conditionalStep.step, m_unsatisfiedSteps) ||
- IsContainingStep(conditionalStep.step, m_satisfiedSteps) ||
- IsContainingStep(conditionalStep.step, m_executingSteps))
- {
- LogPedantic("Step " << StepToString(conditionalStep.step)
- << " cannot satify other steps yet");
-
- return;
- }
-
- LogPedantic("Step " << StepToString(conditionalStep.step)
- << " can satify other steps");
-
- // Do satisfy
- typename ConditionalStepList::iterator unsatisfiedStepIterator =
- m_unsatisfiedSteps.begin();;
-
- while (unsatisfiedStepIterator != m_unsatisfiedSteps.end())
- {
- typename StepList::iterator iterator =
- std::find(
- unsatisfiedStepIterator->unsatisfiedDependencies.begin(),
- unsatisfiedStepIterator->unsatisfiedDependencies.end(),
- conditionalStep.step);
-
- // Does this conditional step need to be satisfied ?
- if (iterator ==
- unsatisfiedStepIterator->unsatisfiedDependencies.end())
- {
- continue;
- }
-
- LogPedantic("Satisfying step "
- << StepToString(unsatisfiedStepIterator->step)
- << " dependency to step "
- << StepToString(conditionalStep.step));
-
- // Satisfy dependency
- unsatisfiedStepIterator->unsatisfiedDependencies.erase(
- iterator);
-
- unsatisfiedStepIterator->satisfiedDependencies.push_back(
- conditionalStep.step);
-
- // If step is fully satisfied, transfer it to the satisfied
- // steps list
- if (unsatisfiedStepIterator->unsatisfiedDependencies.empty())
- {
- LogPedantic("Step "
- << StepToString(unsatisfiedStepIterator->step)
- << " is fully satisfied");
-
- // Move step
- m_satisfiedSteps.push_back(*unsatisfiedStepIterator);
-
- unsatisfiedStepIterator =
- m_unsatisfiedSteps.erase(unsatisfiedStepIterator);
-
- continue;
- }
-
- // Check next unsatisfied step
- ++unsatisfiedStepIterator;
- }
- }
-
- ///< Valid in dependency list mutex only
- bool IsContainingStep(Step step, const ConditionalStepList &dependencies) const
- {
- FOREACH (iterator, dependencies)
- if (iterator->step == step)
- return true;
-
- return false;
- }
-
- ///< Valid in dependency list mutex only
- bool IsStepDependecyListSatisfied(
- const StepList &dependencies) const
- {
- // All dependant step must be historic
- FOREACH (iterator, dependencies)
- if (!IsContainingStep(*iterator, m_historicSteps))
- return false;
-
- // Also, none dependant step can exist in
- // unsatisfied/satisfied/inProgress lists
- FOREACH (iterator, dependencies)
- {
- if (IsContainingStep(*iterator, m_unsatisfiedSteps) ||
- IsContainingStep(*iterator, m_satisfiedSteps) ||
- IsContainingStep(*iterator, m_executingSteps))
- {
- return false;
- }
- }
-
- return true;
- }
-
- bool AbortInternal()
- {
- // Clear all steps and construct
- // a single-dependency list of abort steps
- m_unsatisfiedSteps.clear();
- m_satisfiedSteps.clear();
- m_executingSteps.clear();
- m_historicSteps.clear();
-
- if (m_abortSteps.empty())
- return false;
-
- // Register last abort step as satisfied
- m_satisfiedSteps.push_back(
- ConditionalStep(
- m_abortSteps.top(),
- StepList()));
-
- Step lastStep = m_abortSteps.top();
- m_abortSteps.pop();
-
- // Create abort step list
- while (!m_abortSteps.empty())
- {
- // Add next unsatisfied step
- StepList dependencies;
- dependencies.push_back(lastStep);
-
- m_unsatisfiedSteps.push_back(
- ConditionalStep(
- m_abortSteps.top(),
- dependencies));
-
- // Remove top abort step
- lastStep = m_abortSteps.top();
- m_abortSteps.pop();
- }
-
- return true;
- }
-
-protected:
- void AddStep(Step step,
- const StepList &dependencies)
- {
- Mutex::ScopedLock lock(&m_dependencyListMutex);
-
- LogPedantic("Adding step: " << StepToString(step));
-
- FOREACH (iterator, dependencies)
- LogPedantic(" Dependency: " << StepToString(*iterator));
-
- // Add step to proper list
- if (IsStepDependecyListSatisfied(dependencies))
- {
- m_satisfiedSteps.push_back(ConditionalStep(step, dependencies));
-
- LogPedantic("Step " << StepToString(step) << " is satisfied");
- }
- else
- {
- m_unsatisfiedSteps.push_back(ConditionalStep(step, dependencies));
-
- LogPedantic("Step " << StepToString(step) << " is unsatisfied");
- }
-
- LogPedantic("Satisfied step count: " << m_satisfiedSteps.size());
- LogPedantic("Unsatisfied step count: " << m_unsatisfiedSteps.size());
- }
-
- void AddAbortStep(Step step)
- {
- Mutex::ScopedLock lock(&m_dependencyListMutex);
-
- m_abortSteps.push_front(step);
-
- LogPedantic("Abort step count: " << m_abortSteps.size());
- }
-
-public:
- MultiTaskDecl(ImplementationType *implementation,
- size_t maxParallelCount)
- : m_activeStepsSemaphore(maxParallelCount),
- m_implementation(implementation),
- m_maxParallelCount(maxParallelCount)
- {
- }
-
- bool NextStep()
- {
- ConditionalStep stepToExecute;
- typename ConditionalStepList::iterator executingStepIterator;
-
- // Take the main semaphore lock
- Semaphore::ScopedLock semaphoreLock(&m_activeStepsSemaphore);
-
- // Take the dependency list lock
- {
- Mutex::ScopedLock listLock(&m_dependencyListMutex);
-
- // Get next step to execute
- if (m_satisfiedSteps.empty())
- {
- LogPedantic("No more satisfied steps to execute");
- return false;
- }
-
- // Get next satisfied step to execute
- stepToExecute = m_satisfiedSteps.front();
- m_satisfiedSteps.pop_front();
-
- // Register it in executing step list
- m_executingSteps.push_back(stepToExecute);
- executingStepIterator = --m_executingSteps.end();
-
- // Leave the dependency list lock
- }
-
- // Execute step
- (*m_implementation.*stepToExecute.step)();
-
- // Take a lock again
- {
- Mutex::ScopedLock listLock(&m_dependencyListMutex);
-
- // Unregister executing step
- m_executingSteps.erase(executingStepIterator);
-
- // Add historic step
- m_historicSteps.push_back(stepToExecute);
-
- // Satisfy dependencies
- SatisfyDependencies(stepToExecute);
-
- // Leave lock
- }
-
- // Done
- return true;
- }
-
- bool Abort()
- {
- // Wait until all active steps are done
- // This is achieved by taking all semaphore slots
- ScopedArray<Semaphore::ScopedLock *> semaphoreLocks(
- new Semaphore::ScopedLock *[m_maxParallelCount]);
-
- for (size_t i = 0; i < m_maxParallelCount; ++i)
- semaphoreLocks[i] = new Semaphore::ScopedLock(
- &m_activeStepsSemaphore);
-
- // Result
- bool result;
-
- // Take step lists lock
- {
- Mutex::ScopedLock mutexLock(&m_dependencyListMutex);
-
- // Do internal abort
- result = AbortInternal();
-
- // Leave steps list lock
- }
-
- // Leave semaphore locks
- for (size_t i = 0; i < m_maxParallelCount; ++i)
- delete semaphoreLocks[i];
-
- // Return result
- return result;
- }
-
- size_t GetStepCount() const
- {
- // Return sum of sizes of all lists
- Mutex::ScopedLock lock(&m_dependencyListMutex);
-
- return static_cast<size_t>(
- m_unsatisfiedSteps.size() +
- m_satisfiedSteps.size() +
- m_executingSteps.size() +
- m_historicSteps.size());
- }
-};
} // namespace DPL
#endif // DPL_TASK_H
void Quit();
/**
+ * Checks if current thread is main one
+ * Returns true if it is main program thread, false otherwise
+ */
+ static bool IsMainThread();
+
+ /**
* Current thread retrieval
* Returns DPL thread handle or NULL if it is main program thread
*/
// If yes, pthread_exit(NULL) is required
if (!g_TLSforMainCreated)
{
- if (Thread::GetCurrentThread() == NULL)
+ if (Thread::IsMainThread())
{
g_TLSforMainCreated = true;
atexit(&MainThreadExitClean);
typedef std::pair<size_t, size_t> FileHandle;
- struct FileDateTime
- {
- unsigned int second; //< seconds after the minute - [0,59]
- unsigned int minute; //< minutes after the hour - [0,59]
- unsigned int hour; //< hours since midnight - [0,23]
- unsigned int day; //< day of the month - [1,31]
- unsigned int month; //< months since January - [0,11]
- unsigned int year; //< years - [1980..2044]
-
- FileDateTime()
- : second(0),
- minute(0),
- hour(0),
- day(0),
- month(0),
- year(0)
- {
- }
-
- FileDateTime(unsigned int secondArg,
- unsigned int minuteArg,
- unsigned int hourArg,
- unsigned int dayArg,
- unsigned int monthArg,
- unsigned int yearArg)
- : second(secondArg),
- minute(minuteArg),
- hour(hourArg),
- day(dayArg),
- month(monthArg),
- year(yearArg)
- {
- }
- };
-
struct FileInfo
{
// File handle
std::string comment;
// File information
- unsigned long version; //< version made by
- unsigned long versionNeeded; //< version needed to extract
- unsigned long flag; //< general purpose bit flag
- unsigned long compressionMethod; //< compression method
- unsigned long dosDate; //< last mod file date in Dos fmt
- unsigned long crc; //< crc-32
off64_t compressedSize; //< compressed size
off64_t uncompressedSize; //< uncompressed size
- unsigned long diskNumberStart; //< disk number start
- unsigned long internalFileAttributes; //< internal file attributes
- unsigned long externalFileAttributes; //< external file attributes
-
- FileDateTime dateTime;
FileInfo()
: handle(),
name(),
comment(),
- version(0),
- versionNeeded(0),
- flag(0),
- compressionMethod(0),
- dosDate(0),
- crc(0),
compressedSize(0),
- uncompressedSize(0),
- diskNumberStart(0),
- internalFileAttributes(0),
- externalFileAttributes(0),
- dateTime()
+ uncompressedSize(0)
{
}
FileInfo(const FileHandle &handleArg,
const std::string &nameArg,
const std::string &commentArg,
- unsigned long versionArg,
- unsigned long versionNeededArg,
- unsigned long flagArg,
- unsigned long compressionMethodArg,
- unsigned long dosDateArg,
- unsigned long crcArg,
const off64_t &compressedSizeArg,
- const off64_t &uncompressedSizeArg,
- unsigned long diskNumberStartArg,
- unsigned long internalFileAttributesArg,
- unsigned long externalFileAttributesArg,
- const FileDateTime &dateTimeArg)
+ const off64_t &uncompressedSizeArg)
: handle(handleArg),
name(nameArg),
comment(commentArg),
- version(versionArg),
- versionNeeded(versionNeededArg),
- flag(flagArg),
- compressionMethod(compressionMethodArg),
- dosDate(dosDateArg),
- crc(crcArg),
compressedSize(compressedSizeArg),
- uncompressedSize(uncompressedSizeArg),
- diskNumberStart(diskNumberStartArg),
- internalFileAttributes(internalFileAttributesArg),
- externalFileAttributes(externalFileAttributesArg),
- dateTime(dateTimeArg)
+ uncompressedSize(uncompressedSizeArg)
{
}
};
bool empty() const;
/**
- * Open a binary file for given file handle
- *
- * @return file object
- * @param[in] handle Zip file handle to open
- * @exception std::bad_alloc Cannot allocate memory to hold additional data
- * @exception SteamOpenFailed Cannot find file with given handle
- * @see BinaryQueue::BufferDeleterFree
- */
- File *OpenFile(FileHandle handle);
-
- /**
* Open a binary file for given file name
*
* @return file object
+++ /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 file_input_mapping.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of file input mapping
- */
-#include <dpl/file_input_mapping.h>
-#include <dpl/scoped_close.h>
-#include <dpl/log/log.h>
-#include <iomanip>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-
-namespace DPL
-{
-FileInputMapping::FileInputMapping(const std::string &fileName)
- : m_handle(-1),
- m_size(0),
- m_address(NULL)
-{
- // Open device and map it to user space
- int file = TEMP_FAILURE_RETRY(open(fileName.c_str(), O_RDONLY));
-
- if (file == -1)
- {
- int error = errno;
- ThrowMsg(FileInputMapping::Exception::OpenFailed,
- "Failed to open file. errno = " << error);
- }
-
- // Scoped close on file
- ScopedClose scopedClose(file);
-
- // Calculate file size
- off64_t size = lseek64(file, 0, SEEK_END);
-
- if (size == static_cast<off64_t>(-1))
- {
- int error = errno;
- ThrowMsg(FileInputMapping::Exception::OpenFailed,
- "Failed to seek file. errno = " << error);
- }
-
- // Map file to usespace
- void *address = mmap(0, static_cast<size_t>(size),
- PROT_READ, MAP_SHARED, file, 0);
-
- if (address == MAP_FAILED)
- {
- int error = errno;
- ThrowMsg(FileInputMapping::Exception::OpenFailed,
- "Failed to map file. errno = " << error);
- }
-
- // Release scoped close
- m_handle = scopedClose.Release();
-
- // Save mapped up address
- m_size = size;
- m_address = static_cast<unsigned char *>(address);
-
- LogPedantic("Created file mapping: " << fileName <<
- " of size: " << m_size <<
- " at address: " << std::hex << static_cast<void *>(m_address));
-}
-
-FileInputMapping::~FileInputMapping()
-{
- // Close mapping
- if (munmap(m_address, static_cast<size_t>(m_size)) == -1)
- {
- int error = errno;
- LogPedantic("Failed to munmap file. errno = " << error);
- }
-
- // Close file descriptor
- if (TEMP_FAILURE_RETRY(close(m_handle)) == -1)
- {
- int error = errno;
- LogPedantic("Failed to close file. errno = " << error);
- }
-}
-
-off64_t FileInputMapping::GetSize() const
-{
- return m_size;
-}
-
-const unsigned char *FileInputMapping::GetAddress() const
-{
- return m_address;
-}
-} // namespace DPL
m_eventList.clear();
}
+bool Thread::IsMainThread()
+{
+ return (pthread_equal(pthread_self(), g_mainThread));
+}
+
Thread *Thread::GetCurrentThread()
{
if (pthread_equal(pthread_self(), g_mainThread))
* @version 1.0
* @brief This file is the implementation file of zip input
*/
+#include <iomanip>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
#include <dpl/zip_input.h>
-#include <dpl/file_input_mapping.h>
+#include <dpl/scoped_close.h>
#include <dpl/binary_queue.h>
#include <dpl/scoped_free.h>
#include <dpl/scoped_ptr.h>
class Device
{
private:
- DPL::ScopedPtr<FileInputMapping> m_fileMapping;
+ int m_handle;
+ off64_t m_size; // file mapping size
+ unsigned char *m_address; // mapping base address
struct File
{
public:
Device(const std::string &fileName)
{
- Try
+ LogPedantic("Creating file mapping");
+ // Open device and map it to user space
+ int file = TEMP_FAILURE_RETRY(open(fileName.c_str(), O_RDONLY));
+
+ if (file == -1)
+ {
+ int error = errno;
+ ThrowMsg(ZipInput::Exception::OpenFailed,
+ "Failed to open file. errno = " << error);
+ }
+
+ // Scoped close on file
+ ScopedClose scopedClose(file);
+
+ // Calculate file size
+ off64_t size = lseek64(file, 0, SEEK_END);
+
+ if (size == static_cast<off64_t>(-1))
{
- LogPedantic("Creating file mapping");
- m_fileMapping.Reset(new FileInputMapping(fileName));
+ int error = errno;
+ ThrowMsg(ZipInput::Exception::OpenFailed,
+ "Failed to seek file. errno = " << error);
}
- Catch (FileInputMapping::Exception::Base)
+
+ // Map file to usespace
+ void *address = mmap(0, static_cast<size_t>(size),
+ PROT_READ, MAP_SHARED, file, 0);
+
+ if (address == MAP_FAILED)
{
- LogPedantic("Failed to create file mapping");
+ int error = errno;
+ ThrowMsg(ZipInput::Exception::OpenFailed,
+ "Failed to map file. errno = " << error);
+ }
+
+ // Release scoped close
+ m_handle = scopedClose.Release();
+
+ // Save mapped up address
+ m_size = size;
+ m_address = static_cast<unsigned char *>(address);
+
+ LogPedantic("Created file mapping: " << fileName <<
+ " of size: " << m_size <<
+ " at address: " << std::hex << static_cast<void *>(m_address));
+ }
- ReThrowMsg(ZipInput::Exception::OpenFailed,
- "Failed to open zip file mapping");
+ ~Device()
+ {
+ // Close mapping
+ if (munmap(m_address, static_cast<size_t>(m_size)) == -1)
+ {
+ int error = errno;
+ LogPedantic("Failed to munmap file. errno = " << error);
}
- LogPedantic("File mapping created");
+ // Close file descriptor
+ if (close(m_handle) == -1)
+ {
+ int error = errno;
+ LogPedantic("Failed to close file. errno = " << error);
+ }
}
// zlib_filefunc64_def interface: files
static voidpf ZCALLBACK open64_file(voidpf opaque,
- const void* filename,
- int mode)
+ const void* /*filename*/,
+ int /*mode*/)
{
- (void)filename;
- (void)mode;
-
Device *device = static_cast<Device *>(opaque);
// Open file for master device
File *deviceFile = static_cast<File *>(pstream);
// Check if offset is out of bounds
- if (deviceFile->offset >= device->m_fileMapping->GetSize())
+ if (deviceFile->offset >= device->m_size)
{
LogPedantic("Device: read offset out of bounds");
return -1;
}
- off64_t bytesLeft = device->m_fileMapping->GetSize() -
+ off64_t bytesLeft = device->m_size -
deviceFile->offset;
off64_t bytesToRead;
// Do copy
memcpy(buf,
- device->m_fileMapping->GetAddress() + deviceFile->offset,
+ device->m_address + deviceFile->offset,
static_cast<size_t>(bytesToRead));
// Increment file offset
return static_cast<uLong>(bytesToRead);
}
- static uLong ZCALLBACK write_file(voidpf opaque,
- voidpf stream,
- const void* buf,
- uLong size)
+ static uLong ZCALLBACK write_file(voidpf /*opaque*/,
+ voidpf /*stream*/,
+ const void* /*buf*/,
+ uLong /*size*/)
{
- (void)opaque;
- (void)stream;
- (void)buf;
- (void)size;
-
// Not supported by device
LogPedantic("Unsupported function called!");
return -1;
}
- static int ZCALLBACK close_file(voidpf opaque,
- voidpf stream)
+ static int ZCALLBACK close_file(voidpf /*opaque*/, voidpf stream)
{
- (void)opaque;
File *deviceFile = static_cast<File *>(stream);
// Delete file
return 0;
}
- static int ZCALLBACK testerror_file(voidpf opaque,
- voidpf stream)
+ static int ZCALLBACK testerror_file(voidpf /*opaque*/, voidpf /*stream*/)
{
- (void)opaque;
- (void)stream;
-
// No errors
return 0;
}
- static ZPOS64_T ZCALLBACK tell64_file(voidpf opaque,
- voidpf stream)
+ static ZPOS64_T ZCALLBACK tell64_file(voidpf /*opaque*/, voidpf stream)
{
- (void)opaque;
File *deviceFile = static_cast<File *>(stream);
return static_cast<ZPOS64_T>(deviceFile->offset);
case ZLIB_FILEFUNC_SEEK_END:
deviceFile->offset =
- device->m_fileMapping->GetSize() -
+ device->m_size -
static_cast<off64_t>(offset);
break;
),
std::string(fileName.Get()),
std::string(fileComment.Get()),
- static_cast<unsigned long>(fileInfo.version),
- static_cast<unsigned long>(fileInfo.version_needed),
- static_cast<unsigned long>(fileInfo.flag),
- static_cast<unsigned long>(fileInfo.compression_method),
- static_cast<unsigned long>(fileInfo.dosDate),
- static_cast<unsigned long>(fileInfo.crc),
static_cast<off64_t>(fileInfo.compressed_size),
- static_cast<off64_t>(fileInfo.uncompressed_size),
- static_cast<unsigned long>(fileInfo.disk_num_start),
- static_cast<unsigned long>(fileInfo.internal_fa),
- static_cast<unsigned long>(fileInfo.external_fa),
- FileDateTime(
- fileInfo.tmu_date.tm_sec,
- fileInfo.tmu_date.tm_min,
- fileInfo.tmu_date.tm_hour,
- fileInfo.tmu_date.tm_mday,
- fileInfo.tmu_date.tm_mon,
- fileInfo.tmu_date.tm_year
- )
+ static_cast<off64_t>(fileInfo.uncompressed_size)
)
);
return m_fileInfos.size();
}
-ZipInput::File *ZipInput::OpenFile(FileHandle handle)
-{
- return new File(m_device, handle);
-}
-
ZipInput::File *ZipInput::OpenFile(const std::string &fileName)
{
FOREACH(iterator, m_fileInfos)
#include <string>
#include <typeinfo>
#include <utility>
+#include <set>
#include <dpl/db/sql_connection.h>
#include <dpl/db/orm_interface.h>
#include <dpl/shared_ptr.h>
#include <dpl/type_list.h>
#include <dpl/assert.h>
+#include <dpl/foreach.h>
#ifndef DPL_ORM_H
#define DPL_ORM_H
(void)_ignored_; \
}
+#define DECLARE_COLUMN_TYPE_LIST() typedef DPL::TypeListDecl<
+#define SELECTED_COLUMN(table_name, column_name) table_name::column_name,
+#define DECLARE_COLUMN_TYPE_LIST_END(name) DPL::TypeListGuard>::Type name;
+
typedef size_t ColumnIndex;
typedef size_t ArgumentIndex;
typedef DPL::Optional<DPL::String> OptionalString;
extern const char And[];
extern const char Or[];
extern const char Is[];
+ extern const char In[];
//TODO define more relation types
}
virtual std::string GetString() const
{
std::string statement;
+ statement += ColumnData::GetTableName();
+ statement += ".";
statement += ColumnData::GetColumnName();
statement += " ";
statement += Relation;
ORM_DEFINE_COMPARE_EXPRESSION(Equals, Equal)
ORM_DEFINE_COMPARE_EXPRESSION(Is, Is)
+template<typename ColumnData1, typename ColumnData2>
+class CompareBinaryColumn {
+private:
+ std::string m_relation;
+public:
+ CompareBinaryColumn(const char* Relation) :
+ m_relation(Relation)
+ {}
+
+ virtual std::string GetString() const
+ {
+ std::string statement;
+ statement += ColumnData1::GetTableName();
+ statement += ".";
+ statement += ColumnData1::GetColumnName();
+ statement += " ";
+ statement += m_relation;
+ statement += " ";
+ statement += ColumnData2::GetTableName();
+ statement += ".";
+ statement += ColumnData2::GetColumnName();
+
+ return statement;
+ }
+};
+
+template<typename ColumnData1, typename ColumnData2>
+CompareBinaryColumn<ColumnData1, ColumnData2>
+ Equal()
+{
+ return CompareBinaryColumn<ColumnData1, ColumnData2>(RelationTypes::Equal);
+}
+
+template<typename ColumnData, const char* Relation>
+class NumerousArguments : public Expression {
+protected:
+ std::set<typename ColumnData::ColumnType> m_argumentList;
+public:
+ NumerousArguments(const std::set<typename ColumnData::ColumnType>& argumentList) : m_argumentList(argumentList) {}
+
+ virtual std::string GetString() const
+ {
+ std::string statement;
+ statement += ColumnData::GetColumnName();
+ statement += " ";
+ statement += Relation;
+ statement += " ( ";
+
+ int argumentCount = m_argumentList.size();
+ while(argumentCount)
+ {
+ statement += "?";
+ argumentCount--;
+ if (argumentCount)
+ {
+ statement += ", ";
+ }
+ }
+
+ statement += " )";
+
+ return statement;
+ }
+
+ virtual ArgumentIndex BindTo(DataCommand *command, ArgumentIndex index)
+ {
+ ArgumentIndex argumentIndex = index;
+ FOREACH(argumentIt, m_argumentList)
+ {
+ DataCommandUtils::BindArgument(command, argumentIndex, *argumentIt);
+ argumentIndex++;
+ }
+ return argumentIndex + 1;
+ }
+
+ template<typename TableDefinition>
+ struct ValidForTable {
+ typedef typename TableDefinition::ColumnList::template Contains<ColumnData> Yes;
+ };
+};
+
+#define ORM_DEFINE_COMPARE_EXPRESSION_NUMEROUS_ARGUMENTS(name, relationType) \
+ template<typename ColumnData> \
+ class name : public NumerousArguments<ColumnData, RelationTypes::relationType> { \
+ public: \
+ name(std::set<typename ColumnData::ColumnType> column) : \
+ NumerousArguments<ColumnData, RelationTypes::relationType>(column) \
+ {} \
+ };
+
+ORM_DEFINE_COMPARE_EXPRESSION_NUMEROUS_ARGUMENTS(In, In)
+
template<typename ColumnType>
ColumnType GetColumnFromCommand(ColumnIndex columnIndex, DataCommand *command);
+class CustomColumnBase {
+public:
+ CustomColumnBase() {}
+ virtual ~CustomColumnBase() {}
+};
+
+template<typename ColumnType>
+class CustomColumn : public CustomColumnBase {
+private:
+ ColumnType m_columnData;
+
+public:
+ CustomColumn() {}
+ CustomColumn(ColumnType data)
+ {
+ m_columnData = data;
+ }
+
+ void SetColumnData(ColumnType data)
+ {
+ m_columnData = data;
+ }
+
+ ColumnType GetColumnData() const
+ {
+ return m_columnData;
+ }
+};
+
+template<typename ColumnList>
+class CustomRowUtil {
+public:
+ static void MakeColumnList(std::vector<CustomColumnBase*>& columnList)
+ {
+ typedef CustomColumn<typename ColumnList::Head::ColumnType> Type;
+ Type* pColumn = new Type();
+ columnList.push_back(pColumn);
+ CustomRowUtil<typename ColumnList::Tail>::MakeColumnList(columnList);
+ }
+
+ static void CopyColumnList(const std::vector<CustomColumnBase*>& srcList, std::vector<CustomColumnBase*>& dstList)
+ {
+ CopyColumnList(srcList, dstList, 0);
+ }
+
+ static ColumnIndex GetColumnIndex(const std::string& columnName)
+ {
+ return GetColumnIndex(columnName, 0);
+ }
+
+private:
+ static void CopyColumnList(const std::vector<CustomColumnBase*>& srcList, std::vector<CustomColumnBase*>& dstList, ColumnIndex index)
+ {
+ typedef CustomColumn<typename ColumnList::Head::ColumnType> Type;
+ Type* pColumn = new Type(((Type*)(srcList.at(index)))->GetColumnData());
+ dstList.push_back(pColumn);
+ CustomRowUtil<typename ColumnList::Tail>::CopyColumnList(srcList, dstList, index + 1);
+ }
+
+ static ColumnIndex GetColumnIndex(const std::string& columnName, ColumnIndex index)
+ {
+ if (ColumnList::Head::GetColumnName() == columnName)
+ return index;
+
+ return CustomRowUtil<typename ColumnList::Tail>::GetColumnIndex(columnName, index + 1);
+ }
+
+template<typename Other>
+friend class CustomRowUtil;
+};
+
+template<>
+class CustomRowUtil<DPL::TypeListGuard> {
+public:
+ static void MakeColumnList(std::vector<CustomColumnBase*>&) {}
+private:
+ static void CopyColumnList(const std::vector<CustomColumnBase*>&, std::vector<CustomColumnBase*>&, ColumnIndex) {}
+ static ColumnIndex GetColumnIndex(const std::string&, ColumnIndex) { return -1; }
+
+template<typename Other>
+friend class CustomRowUtil;
+};
+
+template<typename ColumnList>
+class CustomRow {
+private:
+ std::vector<CustomColumnBase*> m_columns;
+
+public:
+ CustomRow()
+ {
+ CustomRowUtil<ColumnList>::MakeColumnList(m_columns);
+ }
+
+ CustomRow(const CustomRow& r)
+ {
+ CustomRowUtil<ColumnList>::CopyColumnList(r.m_columns, m_columns);
+ }
+
+ virtual ~CustomRow()
+ {
+ while (!m_columns.empty())
+ {
+ CustomColumnBase* pCustomColumn = m_columns.back();
+ m_columns.pop_back();
+ if (pCustomColumn)
+ delete pCustomColumn;
+ }
+ }
+
+ template<typename ColumnType>
+ void SetColumnData(ColumnIndex columnIndex, ColumnType data)
+ {
+ typedef CustomColumn<ColumnType> Type;
+ Assert(columnIndex >= 0 && columnIndex < m_columns.size());
+ Type* pColumn = dynamic_cast<Type*>(m_columns.at(columnIndex));
+ Assert(pColumn);
+ pColumn->SetColumnData(data);
+ }
+
+ template<typename ColumnData>
+ typename ColumnData::ColumnType GetColumnData()
+ {
+ typedef CustomColumn<typename ColumnData::ColumnType> Type;
+ ColumnIndex index = CustomRowUtil<ColumnList>::GetColumnIndex(ColumnData::GetColumnName());
+ Assert(index >= 0 && index < m_columns.size());
+ Type* pColumn = dynamic_cast<Type*>(m_columns.at(index));
+ Assert(pColumn);
+ return pColumn->GetColumnData();
+ }
+};
+
+template<typename CustomRow, typename ColumnType>
+void SetColumnData(CustomRow& row, ColumnType columnData, ColumnIndex columnIndex)
+{
+ row.SetColumnData<ColumnType>(columnIndex, columnData);
+}
+
+template<typename ColumnList, typename CustomRow>
+class FillCustomRowUtil {
+public:
+ static void FillCustomRow(CustomRow& row, DataCommand* command)
+ {
+ FillCustomRow(row, 0, command);
+ }
+
+private:
+ static void FillCustomRow(CustomRow& row, ColumnIndex columnIndex, DataCommand* command)
+ {
+ typename ColumnList::Head::ColumnType columnData;
+ columnData = GetColumnFromCommand<typename ColumnList::Head::ColumnType>(columnIndex, command);
+ SetColumnData<CustomRow, typename ColumnList::Head::ColumnType>(row, columnData, columnIndex);
+ FillCustomRowUtil<typename ColumnList::Tail, CustomRow>::FillCustomRow(row, columnIndex + 1, command);
+ }
+
+template<typename Other, typename OtherRow>
+friend class FillCustomRowUtil;
+};
+
+template<typename CustomRow>
+class FillCustomRowUtil<DPL::TypeListGuard, CustomRow> {
+private:
+ static void FillCustomRow(CustomRow&, ColumnIndex, DataCommand *)
+ { /* do nothing, we're past the last element of column list */ }
+
+template<typename Other, typename OtherRow>
+friend class FillCustomRowUtil;
+};
+
template<typename ColumnList, typename Row>
class FillRowUtil {
public:
+ static void FillRow(Row& row, DataCommand *command)
+ {
+ FillRow(row, 0, command);
+ }
+
+private:
static void FillRow(Row& row, ColumnIndex columnIndex, DataCommand *command)
{
typename ColumnList::Head::ColumnType rowField;
ColumnList::Head::SetRowField(row, rowField);
FillRowUtil<typename ColumnList::Tail, Row>::FillRow(row, columnIndex + 1, command);
}
+
+template<typename Other, typename OtherRow>
+friend class FillRowUtil;
};
template<typename Row>
class FillRowUtil<DPL::TypeListGuard, Row> {
-public:
+private:
static void FillRow(Row&, ColumnIndex, DataCommand *)
{ /* do nothing, we're past the last element of column list */ }
+
+template<typename Other, typename OtherRow>
+friend class FillRowUtil;
+};
+
+template<typename ColumnList>
+class JoinUtil {
+public:
+ static std::string GetColumnNames()
+ {
+ std::string result;
+ result = ColumnList::Head::GetTableName();
+ result += ".";
+ result += ColumnList::Head::GetColumnName();
+ if (ColumnList::Tail::Size > 0)
+ result += ", ";
+
+ return result += JoinUtil<typename ColumnList::Tail>::GetColumnNames();
+ }
+
+ static std::string GetJoinTableName(const std::string& tableName)
+ {
+ std::string joinTableName = ColumnList::Head::GetTableName();
+ if (tableName.find(joinTableName) == std::string::npos)
+ return joinTableName;
+
+ return JoinUtil<typename ColumnList::Tail>::GetJoinTableName(tableName);
+ }
+};
+
+template<>
+class JoinUtil<DPL::TypeListGuard> {
+public:
+ static std::string GetColumnNames() { return ""; }
+ static std::string GetJoinTableName(std::string) { return ""; }
};
class Exception {
typedef std::list<Row> RowList;
protected:
DPL::Optional<std::string> m_orderBy;
+ std::string m_JoinClause;
bool m_distinctResults;
void Prepare(const char* selectColumnName)
this->m_commandString += " FROM ";
this->m_commandString += TableDefinition::GetName();
+ this->m_commandString += m_JoinClause;
+
QueryWithWhereClause<TableDefinition>::Prepare();
if ( !m_orderBy.IsNull() )
Row GetRow()
{
Row row;
- FillRowUtil<ColumnList, Row>::FillRow(row, 0, this->m_command);
+ FillRowUtil<ColumnList, Row>::FillRow(row, this->m_command);
+ return row;
+ }
+
+ template<typename ColumnList, typename CustomRow>
+ CustomRow GetCustomRow()
+ {
+ CustomRow row;
+ FillCustomRowUtil<ColumnList, CustomRow>::FillCustomRow(row, this->m_command);
return row;
}
m_orderBy = orderBy;
}
+ template<typename ColumnList, typename Expression>
+ void Join(const Expression& expression) {
+ std::string usedTableNames = TableDefinition::GetName();
+ if (!m_JoinClause.empty())
+ usedTableNames += m_JoinClause;
+
+ this->m_JoinClause += " JOIN ";
+ this->m_JoinClause += JoinUtil<ColumnList>::GetJoinTableName(usedTableNames);
+ this->m_JoinClause += " ON ";
+ this->m_JoinClause += expression.GetString();
+ }
+
template<typename ColumnData>
typename ColumnData::ColumnType GetSingleValue()
{
this->m_command->Reset();
return resultList;
}
+
+ template<typename ColumnList, typename CustomRow>
+ CustomRow GetCustomSingleRow()
+ {
+ Prepare(JoinUtil<ColumnList>::GetColumnNames().c_str());
+ Bind();
+ this->m_command->Step();
+
+ CustomRow result = GetCustomRow<ColumnList, CustomRow>();
+
+ this->m_command->Reset();
+ return result;
+ }
+
+ template<typename ColumnList, typename CustomRow>
+ std::list<CustomRow> GetCustomRowList()
+ {
+ Prepare(JoinUtil<ColumnList>::GetColumnNames().c_str());
+ Bind();
+
+ std::list<CustomRow> resultList;
+
+ while (this->m_command->Step())
+ resultList.push_back(GetCustomRow<ColumnList, CustomRow>());
+
+ this->m_command->Reset();
+ return resultList;
+ }
};
template<typename TableDefinition>
#define DECLARE_COLUMN(FIELD, TYPE) \
struct FIELD { \
typedef TYPE ColumnType; \
+ static const char* GetTableName() { return GetName(); } \
static const char* GetColumnName() { return STRINGIFY(FIELD); } \
static void SetRowField(Row& row, const TYPE& value) { row.Set_##FIELD(value);} \
};
// Field structure declarations
-#define CREATE_TABLE(name) namespace name {
+#define CREATE_TABLE(name) namespace name { \
+ static const char* GetName() { return STRINGIFY(name); }
#define COLUMN_NOT_NULL(name, type, args...) DECLARE_COLUMN(name, type)
#define COLUMN(name, type, args...) DECLARE_COLUMN(name, OPTIONAL(type))
#define CREATE_TABLE_END() }
enum Option
{
RO = SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READONLY,
- RW =
- SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
+ /**
+ *TODO: please remove CREATE option from RW flag when all places
+ * that need that switched do CRW
+ */
+ RW = SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
+ CRW = RW | SQLITE_OPEN_CREATE,
};
};
const char And[] = "AND";
const char Or[] = "OR";
const char Is[] = "IS";
+const char In[] = "IN";
}
template<>
}
}
-}
\ No newline at end of file
+}
LogPedantic("Already connected.");
return;
}
-
LogPedantic("Connecting to DB: " << address << "...");
// Connect to database
int result;
-
if (type & Flag::UseLucene) {
result = db_util_open_with_options(
address.c_str(),
return;
}
+ if (format == NULL)
+ {
+ LogPedantic("Null query!");
+ ThrowMsg(Exception::SyntaxError, "Null statement");
+ }
+
char *rawBuffer;
va_list args;
${PROJECT_SOURCE_DIR}/modules/event/src/main_event_dispatcher.cpp
${PROJECT_SOURCE_DIR}/modules/event/src/thread_event_dispatcher.cpp
${PROJECT_SOURCE_DIR}/modules/event/src/inter_context_delegate.cpp
- ${PROJECT_SOURCE_DIR}/modules/event/src/nested_loop.cpp
${PROJECT_SOURCE_DIR}/modules/event/src/model.cpp
PARENT_SCOPE
)
${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/generic_event_call.h
${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/main_event_dispatcher.h
${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/thread_event_dispatcher.h
- ${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/nested_loop.h
${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/inter_context_delegate.h
${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/model.h
${PROJECT_SOURCE_DIR}/modules/event/include/dpl/event/property.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 the NestedLoopManager class.
- *
- * @file nested_loop.h
- * @author Lukasz Marek (l.marek@samsung.com)
- * @version 0.1
- * @brief This file contains the declaration of the NestedLoopManager class.
- */
-
-#ifndef DPL_NESTED_LOOP_H_
-#define DPL_NESTED_LOOP_H_
-
-#include <vector>
-#include <list>
-#include <map>
-#include <dpl/event/controller.h>
-#include <dpl/singleton.h>
-
-namespace DPL
-{
-namespace Event
-{
-
-class LoopExitEvent
-{
-};
-
-typedef unsigned LoopHandle;
-typedef std::list<LoopHandle> LoopHandleList;
-
-const LoopHandle UNDEFINED_LOOP_HANDLE = 0;
-
-class NestedLoopManager :
- protected Controller<TypeListDecl<LoopExitEvent>::Type>
-{
- public:
- void* begin(LoopHandle loopHandle);
- void exit(LoopHandle loopHandle,
- void *userParam = NULL);
- size_t getLevel() const;
- LoopHandle getNewHandle();
-
- protected:
- void OnEventReceived(const LoopExitEvent& event);
-
- private:
- struct LoopInformation
- {
- LoopInformation(LoopHandle handle) :
- loopHandle(handle),
- exitFlag(false),
- userParam(NULL)
- {
- }
-
- LoopHandle loopHandle;
- bool exitFlag;
- void *userParam;
- };
-
- class RunningLoopsHandlePredicate
- {
- public:
- RunningLoopsHandlePredicate(LoopHandle handle) :
- m_handle(handle)
- {
- }
-
- bool operator()(const LoopInformation &loopInformation) const
- {
- return loopInformation.loopHandle == m_handle;
- }
-
- private:
- LoopHandle m_handle;
- };
-
- NestedLoopManager();
- ~NestedLoopManager();
-
- typedef std::vector<LoopInformation> RunningLoopsList;
- typedef RunningLoopsList::iterator RunningLoopsListIterator;
-
- bool m_eventGuard; // only one event is allowed
- LoopHandle m_handle;
- RunningLoopsList m_runningLoops;
-
- friend class Singleton<NestedLoopManager>;
-};
-
-typedef Singleton<NestedLoopManager> NestedLoopManagerSingleton;
-
-}
-} // namespace DPL
-
-#endif // WRT_ENGINE_SRC_COMMON_NESTED_LOOP_H_
EmitEvent(PropertyEvent<Type>(value, this->m_model),
EmitMode::Auto);
}
+
+ void SetWithoutLock(const Type &value)
+ {
+ if (this->m_storage.Get() == value)
+ return;
+
+ this->m_storage.Set(value);
+ }
};
}
+++ /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 definition of the NestedLoopManager class.
- *
- * @file nested_loop.cpp
- * @author Lukasz Marek (l.marek@samsung.com)
- * @version 0.1
- * @brief This file contains the definition of the NestedLoopManager class.
- */
-
-#include <dpl/event/nested_loop.h>
-#include <algorithm>
-#include <Ecore.h>
-#include <dpl/log/log.h>
-#include <dpl/assert.h>
-#include <dpl/singleton_impl.h>
-
-IMPLEMENT_SINGLETON(DPL::Event::NestedLoopManager)
-
-namespace DPL
-{
-namespace Event
-{
-
-NestedLoopManager::NestedLoopManager() : m_eventGuard(false),
- m_handle(0)
-{
- Touch();
-}
-
-NestedLoopManager::~NestedLoopManager()
-{
-}
-
-void* NestedLoopManager::begin(LoopHandle loopHandle)
-{
- LoopInformation info(loopHandle);
- m_runningLoops.push_back(info);
- LogPedantic("Nested loop begin. Nested loop level: " << getLevel());
-
- ecore_main_loop_begin();
-
- Assert(m_runningLoops.size() && "No loop on the stack");
-
- info = m_runningLoops.back();
- m_runningLoops.pop_back();
-
- Assert(info.loopHandle == loopHandle && "You exit from wrong loop");
- Assert(info.exitFlag == true && "Exit flag not set");
-
- LogPedantic("Nested loop quit. Nested loop level: " << getLevel());
-
- if (!m_runningLoops.empty() && m_runningLoops.back().exitFlag &&
- !m_eventGuard) {
- m_eventGuard = true;
- LoopExitEvent event;
- PostEvent(event);
- }
- return info.userParam;
-}
-
-void NestedLoopManager::exit(LoopHandle loopHandle,
- void *userParam)
-{
- RunningLoopsListIterator iterator = std::find_if(
- m_runningLoops.begin(),
- m_runningLoops.end(),
- RunningLoopsHandlePredicate(loopHandle));
-
- Assert(iterator != m_runningLoops.end() && "Unknown loopHandle");
- Assert(iterator->exitFlag == false && "You cannot close a loop twice.");
-
- iterator->exitFlag = true;
- iterator->userParam = userParam;
-
- if (m_runningLoops.back().exitFlag && !m_eventGuard) {
- m_eventGuard = true;
- LoopExitEvent event;
- PostEvent(event);
- }
-}
-
-size_t NestedLoopManager::getLevel() const
-{
- return m_runningLoops.size();
-}
-
-LoopHandle NestedLoopManager::getNewHandle()
-{
- return m_handle++;
-}
-
-void NestedLoopManager::OnEventReceived(const LoopExitEvent& event)
-{
- (void)event;
- Assert(!m_runningLoops.empty());
- m_eventGuard = false; // no event in queue
- if (m_runningLoops.back().exitFlag) {
- //exit loop when last started one is readu to finish
- //this will post event if next loop is ready to exit
- ecore_main_loop_quit();
- }
-}
-
-}
-}
DPL::String BCP47LanguageTagToLocale(const DPL::String&);
DPL::String LocaleToBCP47LanguageTag(const DPL::String&);
-void SetUserLanguageTags(const LanguageTagsList& tags);
void SetSystemLanguageTags(const LanguageTagsList& tags);
LanguageTagsList GetUserAgentLanguageTags();
-
-void Initialize();
}
-
#endif //LOCALIZATION_UTILS_H
#ifndef W3C_FILE_LOCALIZATION_H
#define W3C_FILE_LOCALIZATION_H
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/optional.h>
#include <dpl/string.h>
#include <list>
#include <dpl/localization/localization_utils.h>
-#include <appcore-efl.h>
-#include <vconf.h>
-#include <dpl/framework_efl.h>
-
#include <dpl/foreach.h>
#include <dpl/mutex.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
-
-namespace {
-
-static int LanguageChanged(void *)
-{
- char* lang = vconf_get_str(VCONFKEY_LANGSET);
- if (!lang) {
- LogError("Cannot get locale settings from vconf");
- return 0;
- }
- LogDebug("Language set to: " << lang);
-
- using namespace LocalizationUtils;
-
- LanguageTagsList list;
- list.push_back(DPL::FromUTF8String(lang));
- SetSystemLanguageTags(list);
-
- LogDebug("LanguageChanged to " << lang);
-
- return 0;
-}
-}
namespace LocalizationUtils {
static LanguageTagsList m_systemLanguageTags;
-static LanguageTagsList m_userLanguageTags;
static LanguageTagsList m_languageTags;
static DPL::ReadWriteMutex m_readWriteMutex;
// WARNING!!!!! This function shall be called
// only when mutex is locked in readWriteMode!
- LanguageTagsList list = m_userLanguageTags;
- list.insert(list.begin(),
- m_systemLanguageTags.begin(),
- m_systemLanguageTags.end());
m_languageTags.clear();
- FOREACH(i, list) {
+ FOREACH(i, m_systemLanguageTags) {
DPL::String tag = LocaleToBCP47LanguageTag(*i);
while (true) { //W3C Packaging 9. Step 5. 2. D
if (tag.empty()) { continue; }
m_languageTags.push_back(L"");
}
-void SetUserLanguageTags(const LanguageTagsList& tags)
-{
- DPL::ReadWriteMutex::ScopedWriteLock lock(&m_readWriteMutex);
- if (m_userLanguageTags != tags) {
- m_userLanguageTags = tags;
- UpdateUserAgentLanguageTags();
- }
-}
-
void SetSystemLanguageTags(const LanguageTagsList& tags)
{
DPL::ReadWriteMutex::ScopedWriteLock lock(&m_readWriteMutex);
DPL::ReadWriteMutex::ScopedReadLock lock(&m_readWriteMutex);
return m_languageTags;
}
-
-void Initialize()
-{
- appcore_set_event_callback(
- APPCORE_EVENT_LANG_CHANGE,
- &LanguageChanged,
- NULL);
-
- LanguageChanged(NULL); // updating language for the first time
-}
-
}
#include <dpl/localization/w3c_file_localization.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/localization/localization_utils.h>
#include <dpl/log/log.h>
const DPL::String &url)
{
DPL::String req = url;
- WidgetDAO dao(widgetHandle);
+ WidgetDAOReadOnly dao(widgetHandle);
if (req.find(WIDGET_URI_BEGIN) == 0) {
req.erase(0, WIDGET_URI_BEGIN.length());
const LanguageTagsList &languageTags,
const DPL::String& file)
{
- WidgetDAO dao(widgetHandle);
+ WidgetDAOReadOnly dao(widgetHandle);
return GetFilePathInWidgetPackageInternal(languageTags, dao.getPath(), file);
}
{
using namespace LocalizationUtils;
- WidgetDAO dao(widgetHandle);
+ WidgetDAOReadOnly dao(widgetHandle);
- WidgetDAO::LocalizedStartFileList locList = dao.getLocalizedStartFileList();
- WidgetDAO::WidgetStartFileList list = dao.getStartFileList();
+ WidgetDAOReadOnly::LocalizedStartFileList locList = dao.getLocalizedStartFileList();
+ WidgetDAOReadOnly::WidgetStartFileList list = dao.getStartFileList();
LanguageTagsList tagsList = LocalizationUtils::GetUserAgentLanguageTags();
DPL::OptionalString defaultLoc = dao.getDefaultlocale();
OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle)
{
using namespace LocalizationUtils;
- WidgetDAO dao(widgetHandle);
+ WidgetDAOReadOnly dao(widgetHandle);
- WidgetDAO::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
- WidgetDAO::WidgetIconList list = dao.getIconList();
+ WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
+ WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
LanguageTagsList tagsList = LocalizationUtils::GetUserAgentLanguageTags();
DPL::OptionalString defaultLoc = dao.getDefaultlocale();
const LanguageTagsList &languageTags)
{
using namespace LocalizationUtils;
- WidgetDAO dao(widgetHandle);
- WidgetDAO::WidgetIconList list = dao.getIconList();
+ WidgetDAOReadOnly dao(widgetHandle);
+ WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
WidgetIconList outlist;
WidgetStartFileInfo info;
- WidgetDAO dao(widgetHandle);
- WidgetDAO::LocalizedStartFileList locList =
+ WidgetDAOReadOnly dao(widgetHandle);
+ WidgetDAOReadOnly::LocalizedStartFileList locList =
dao.getLocalizedStartFileList();
- WidgetDAO::WidgetStartFileList list = dao.getStartFileList();
+ WidgetDAOReadOnly::WidgetStartFileList list = dao.getStartFileList();
FOREACH(tag, tagsList)
{
if (tag->empty()) {
info.localizedPath = it->src;
} else {
- info.localizedPath = L"locales/" + *tag;
+ info.localizedPath = L"locales/" + *tag + L"/";
info.localizedPath += it->src;
}
return info;
{
LanguageTagList languages =
LocalizationUtils::GetUserAgentLanguageTags();
- WidgetDAO dao(handle);
+ WidgetDAOReadOnly dao(handle);
DPL::OptionalString dl = dao.getDefaultlocale();
if (!!dl) {
languages.push_back(*dl);
#include <string>
#include <dpl/optional.h>
#include <dpl/popup/popup_object.h>
-#include <dpl/event/nested_loop.h>
namespace DPL {
namespace Popup {
int buttonAnswer;
DPL::Optional<std::string> password;
bool chackState;
- DPL::Event::LoopHandle loopHandle;
};
class PopupManager;
#include <dpl/enable_shared_from_this.h>
#include <dpl/noncopyable.h>
#include <dpl/log/log.h>
-#include <dpl/event/nested_loop.h>
#include <dpl/popup/popup_manager.h>
namespace DPL {
CtrlPopupPtr,
PopupAnswerCallback,
AnswerCallbackData)
-DECLARE_GENERIC_EVENT_3(ShowPopupEvent,
+
+DECLARE_GENERIC_EVENT_2(ShowPopupEventShort,
CtrlPopupPtr,
- PopupAnswerCallback,
- DPL::Event::LoopHandle)
+ PopupAnswerCallback)
class CtrlPopup : public DPL::Event::EventSupport<PopupAnswerEvent>,
protected DPL::EnableSharedFromThis<CtrlPopup>
IPopupPtr m_popup;
PopupAnswerCallback m_callback;
- DPL::Event::LoopHandle m_loopHandle;
};
class PopupController :
- public DPL::Event::Controller<DPL::TypeListDecl<ShowPopupEvent>::Type>
+ public DPL::Event::Controller<DPL::TypeListDecl<ShowPopupEventShort>::Type>
{
public:
CtrlPopupPtr CreatePopup() const;
void* m_canvas;
protected:
- virtual void OnEventReceived(const ShowPopupEvent& event);
+ virtual void OnEventReceived(const ShowPopupEventShort& event);
PopupController();
private:
#include <dpl/optional.h>
#include <dpl/popup/popup.h>
#include <dpl/popup/popup_renderer.h>
+#include <dpl/log/log.h>
namespace DPL {
namespace Popup {
PopupManager() : m_initialized(false) {}
~PopupManager()
{
- Assert(!m_initialized);
+ if (m_initialized) {
+ LogError("Destroyed without Deinitialize");
+ }
}
void Initialize (PopupRendererPtr creator);
void Deinitialize();
void CtrlPopup::EmitAnswer(const AnswerCallbackData & answer)
{
AnswerCallbackData l_answer = answer;
- l_answer.loopHandle = m_loopHandle;
PopupAnswerEvent event(SharedFromThis(), m_callback, l_answer);
DPL::Event::EventSupport<PopupAnswerEvent>::EmitEvent(event);
}
new CtrlPopup(PopupManagerSingleton::Instance().CreatePopup()));
}
-void PopupController::OnEventReceived(const ShowPopupEvent& event)
+void PopupController::OnEventReceived(const ShowPopupEventShort& event)
{
CtrlPopupPtr popup = event.GetArg0();
popup->m_callback = event.GetArg1();
- popup->m_loopHandle = event.GetArg2();
//pass canvas from controller to manager
//canvas is not passed earlier because value wasn't set properly
~Impl()
{
- Assert(!m_initialized);
+ if (m_initialized) {
+ LogError("Destroyed without Deinitialize");
+ }
}
void Initialize()
--- /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 config.cmake
+# @author Lukasz Marek (l.marek@samsung.com)
+# @version 1.0
+# @brief
+#
+
+
+SET(DPL_WRT_ENGINE_HEADERS
+ ${PROJECT_SOURCE_DIR}/modules/support/wrt_plugin_export.h
+ PARENT_SCOPE
+)
--- /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 wrt_plugin_export.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief Header file for plugin export API
+ */
+#ifndef WRT_PLUGIN_EXPORT_H
+#define WRT_PLUGIN_EXPORT_H
+
+#include <stddef.h>
+
+/**
+ * Widget handle type
+ */
+typedef int widget_handle_t;
+
+/**
+ * Parameter which should be used during policy evaluation.
+ */
+typedef struct ace_param_s
+{
+ const char *name;
+ const char *value;
+} ace_param_t;
+
+/**
+ * List of additional parameters which should be used during policy evaluation.
+ */
+typedef struct ace_param_list_s
+{
+ size_t count;
+ ace_param_t *param;
+} ace_param_list_t;
+
+/**
+ * Contains list of device capabilities. Each device capability may have
+ * associated list of function params.
+ */
+typedef struct ace_device_cap_s
+{
+ size_t devcapsCount;
+ const char** dev_cap_names;
+ size_t paramsCount;
+ ace_param_list_t* params;
+} ace_device_cap_t;
+
+/**
+ * List of device capabilities which must be check.
+ */
+typedef struct ace_device_capabilities_s
+{
+ size_t count;
+ const char **device_cap;
+} ace_device_capabilities_t;
+
+/**
+ * List of api features that must be checked
+ */
+typedef struct ace_api_features_s
+{
+ size_t count;
+ const char **api_feature;
+} ace_api_features_t;
+
+/**
+ * Data from request will be used to evaluate policy file.
+ */
+typedef struct ace_request_s
+{
+ widget_handle_t widget_handle;
+ const char* feature_api;
+ const char* function_name;
+ ace_device_capabilities_t device_capabilities;
+ ace_param_list_t param_list;
+} ace_request_t;
+
+/**
+ * Data from request will be used to evaluate policy file.
+ */
+typedef struct ace_request_2_s
+{
+ widget_handle_t widget_handle;
+ ace_api_features_t api_features;
+ const char* function_name;
+ ace_device_cap_t device_capabilities;
+} ace_request_2_t;
+
+/**
+ * info returned by plugin_api_check_access
+ */
+#define PLUGIN_API_ACCESS_GRANTED 1
+#define PLUGIN_API_ACCESS_DENIED 0
+#define PLUGIN_API_ACCESS_ERROR -1
+
+
+typedef const void* java_script_context_t;
+
+typedef struct js_object_properties_s
+{
+ size_t count;
+ char** properties;
+} js_object_properties_t;
+
+typedef const void* js_class_template_t;
+typedef void* js_object_ref_t;
+typedef const void* js_value_ref_t;
+
+typedef js_class_template_t (*js_class_template_getter) (void);
+typedef void* (*js_class_constructor_cb_t)(js_class_template_t,
+ js_object_ref_t, size_t, js_value_ref_t[],
+ js_value_ref_t*);
+
+typedef enum class_definition_type_e
+{
+ JS_CLASS,
+ JS_FUNCTION,
+ JS_INTERFACE
+} class_definition_type_t;
+
+typedef enum class_definition_iframe_behaviour_e
+{
+ //object should not be initalized in iframes
+ //it is default one
+ NONE,
+ //object should be copied as reference to each iframe
+ REFERENCE,
+ //object should be created for each iframe and NOT inform plugin
+ CREATE_INSTANCE,
+} class_definition_iframe_behaviour_t;
+
+typedef enum class_definition_iframe_notice_e
+{
+ //it is default one
+ NONE_NOTICE,
+ ALWAYS_NOTICE
+} class_definition_iframe_notice_t;
+
+typedef enum class_definition_iframe_overlay_e
+{
+ IGNORED,
+ USE_OVERLAYED,
+ OVERLAYED_BEFORE_ORIGINAL
+} class_definition_iframe_overlay_t;
+
+typedef void* js_object_instance_t;
+//global_context - id
+typedef void(*iframe_loaded_cb)(java_script_context_t global_context,
+ js_object_instance_t iframe,
+ js_object_instance_t object);
+
+typedef void* (*js_function_impl)(void*);
+
+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;
+ iframe_loaded_cb cb;
+ void * private_data;
+ js_function_impl function;
+} class_definition_options_t;
+
+
+/*
+ * list of device caps
+ */
+typedef struct devcaps_s
+{
+ char** deviceCaps;
+ size_t devCapsCount;
+} devcaps_t;
+
+/*
+ * mapping from a feature to corresponding list of device capabilities
+ */
+typedef struct feature_devcaps_s
+{
+ char* feature_name;
+ devcaps_t devCaps;
+} feature_devcaps_t;
+
+/*
+ * list of feature_devcaps_t structs
+ */
+typedef struct feature_mapping_s
+{
+ feature_devcaps_t* features;
+ size_t featuresCount;
+} feature_mapping_t;
+
+
+typedef feature_mapping_t* pfeature_mapping_t;
+
+typedef pfeature_mapping_t (*features_getter)(void);
+
+typedef const devcaps_t* (*devcaps_getter)(pfeature_mapping_t /*features*/,
+ const char* /*featureName*/);
+typedef void (*deinitializer)(pfeature_mapping_t /*features*/);
+
+typedef struct feature_mapping_interface_s
+{
+ features_getter featGetter; /* returns a list of api features */
+ devcaps_getter dcGetter; /*
+ * for a given api feature returns a list of
+ * corresponding device capabilities
+ */
+
+ deinitializer release; /* as memory ownership of features is
+ * transfered to callee you have to call
+ * the release function ptr on features
+ */
+} feature_mapping_interface_t;
+
+
+/*
+ * This is a structure describing a JS entity template (a class, an interface
+ * or function), object name and it's parent class name (parent_name). JS
+ * entity will be bind to a parent class name (parent_name.js_entity_name).
+ * @param parent_name - parent name (ie Widget.Device)
+ * @param object_name - object name (DeviceStatus)
+ * @param interface_name - interface name (e.g. Widget)
+ * @param js_class_template_getter_fun - js_class_template required to create
+ * JS object
+ * @param js_class_consturctor_cb - constructor to call to when instance of
+ * certain interface is created
+ * @param private_data private data for object creator if required (usually
+ * NULL)
+ */
+typedef struct js_entity_definition_s
+{
+ const char *parent_name;
+ const char *object_name;
+ const char *interface_name;
+ js_class_template_getter js_class_template_getter_fun;
+ js_class_constructor_cb_t js_class_constructor_cb;
+ //class options may be null - default
+ class_definition_options_t* class_options;
+} js_entity_definition_t;
+
+typedef const js_entity_definition_t *js_entity_definition_ptr_t;
+
+/**
+ * Plugin export names
+ */
+#define PLUGIN_WIDGET_START_PROC on_widget_start
+#define PLUGIN_WIDGET_INIT_PROC on_widget_init
+#define PLUGIN_WIDGET_STOP_PROC on_widget_stop
+#define PLUGIN_FRAME_LOAD_PROC on_frame_load
+#define PLUGIN_FRAME_UNLOAD_PROC on_frame_unload
+#define PLUGIN_CLASS_MAP class_map
+#define PLUGIN_GET_CLASS_PROC_MAP get_widget_class_map
+
+#define PLUGIN_WIDGET_START_PROC_NAME "on_widget_start"
+#define PLUGIN_WIDGET_INIT_PROC_NAME "on_widget_init"
+#define PLUGIN_WIDGET_STOP_PROC_NAME "on_widget_stop"
+#define PLUGIN_FRAME_LOAD_PROC_NAME "on_frame_load"
+#define PLUGIN_FRAME_UNLOAD_PROC_NAME "on_frame_unload"
+#define PLUGIN_CLASS_MAP_NAME "class_map"
+#define PLUGIN_GET_CLASS_MAP_PROC_NAME "get_widget_class_map"
+
+/**
+ * Plugin export typedefs
+ */
+typedef void (*on_widget_start_proc)(int widgetId);
+
+typedef void (*on_widget_init_proc)(feature_mapping_interface_t *interface);
+
+/**
+ * FIXME: Add documentation
+ */
+typedef void (*on_widget_stop_proc)(int widgetId);
+
+typedef void (*on_frame_load_proc)(java_script_context_t context);
+
+typedef void (*on_frame_unload_proc)(java_script_context_t context);
+
+typedef const js_entity_definition_t* (*get_widget_entity_map_proc)();
+
+#endif // WRT_PLUGIN_EXPORT_H
#include <string>
#include <cstdio>
+#include <fstream>
+#include <sstream>
namespace DPL
{
namespace
{
const char *DEFAULT_HTML_FILE_NAME = "index.html";
+const char *DEFAULT_TAP_FILE_NAME = "results.tap";
class Statistic
{
}
+class TAPCollector
+ : public TestResultsCollectorBase
+{
+ public:
+ static TestResultsCollectorBase* Constructor();
+
+ private:
+ TAPCollector() : m_filename(DEFAULT_TAP_FILE_NAME) {}
+
+ virtual bool Configure()
+ {
+ m_output.open(m_filename.c_str(), std::ios_base::trunc);
+ if (m_output.fail()) {
+ LogError("Can't open output file: " << m_filename);
+ return false;
+ }
+ return true;
+ }
+ virtual std::string CollectorSpecificHelp() const
+ {
+ std::string retVal = "--file=<filename> - name of file for output\n"
+ " default - ";
+ retVal += DEFAULT_TAP_FILE_NAME;
+ retVal += "\n";
+ return retVal;
+ }
+
+ virtual void Start()
+ {
+ Assert(m_output.good() && "Output file must be opened.");
+ m_output << "TAP version 13" << std::endl;
+ m_testIndex = 0;
+ }
+
+ virtual void Finish()
+ {
+ m_output << "1.." << m_testIndex << std::endl;
+ m_output << m_collectedData.rdbuf();
+ m_output.close();
+ }
+
+ virtual bool ParseCollectorSpecificArg(const std::string& arg)
+ {
+ const std::string argname = "--file=";
+ if (0 == arg.find(argname)) {
+ m_filename = arg.substr(argname.size());
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+
+ virtual void CollectResult(const std::string& id,
+ const std::string& description,
+ const FailStatus::Type status = FailStatus::NONE,
+ const std::string& reason = "")
+ {
+ m_testIndex++;
+ switch(status) {
+ case TestResultsCollectorBase::FailStatus::NONE:
+ LogBasicTAP(true, id, description);
+ endTAPLine();
+ break;
+ case TestResultsCollectorBase::FailStatus::FAILED:
+ LogBasicTAP(false, id, description);
+ endTAPLine();
+ break;
+ case TestResultsCollectorBase::FailStatus::IGNORED:
+ LogBasicTAP(true, id, description);
+ m_collectedData << " # skip " << reason;
+ endTAPLine();
+ break;
+ case TestResultsCollectorBase::FailStatus::TODO:
+ LogBasicTAP(false, id, description);
+ m_collectedData << " # TODO " << reason;
+ endTAPLine();
+ break;
+ case TestResultsCollectorBase::FailStatus::INTERNAL:
+ LogBasicTAP(true, id, description);
+ endTAPLine();
+ m_collectedData << " ---" << std::endl;
+ m_collectedData << " message: " << reason << std::endl;
+ m_collectedData << " severity: Internal" << std::endl;
+ m_collectedData << " ..." << std::endl;
+ break;
+ default:
+ Assert(false && "Bad status");
+ }
+ }
+
+ void LogBasicTAP(bool isOK, const std::string& id,
+ const std::string& description)
+ {
+ if (!isOK) {
+ m_collectedData << "not ";
+ }
+ m_collectedData << "ok " << m_testIndex << " [" <<
+ id << "] " << description;
+ }
+
+ void endTAPLine()
+ {
+ m_collectedData << std::endl;
+ }
+
+
+ std::string m_filename;
+ std::stringstream m_collectedData;
+ std::ofstream m_output;
+ int m_testIndex;
+};
+
+
+TestResultsCollectorBase* TAPCollector::Constructor()
+{
+ return new TAPCollector();
+}
+
+
void TestResultsCollectorBase::RegisterCollectorConstructor(
const std::string& name,
TestResultsCollectorBase::CollectorConstructorFunc func)
TestResultsCollectorBase::RegisterCollectorConstructor(
"csv",
&CSVCollector::Constructor);
+ TestResultsCollectorBase::RegisterCollectorConstructor(
+ "tap",
+ &TAPCollector::Constructor);
return 0;
}
#include <memory.h>
#include <libgen.h>
#include <cstring>
+#include <cstdlib>
+#include <dpl/utils/wrt_global_settings.h>
#include <dpl/singleton_impl.h>
IMPLEMENT_SINGLETON(DPL::Test::TestRunner)
${PROJECT_SOURCE_DIR}/modules/utils/src/mime_type_utils.cpp
${PROJECT_SOURCE_DIR}/modules/utils/src/warp_iri.cpp
${PROJECT_SOURCE_DIR}/modules/utils/src/widget_version.cpp
- ${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_global_settings_internal.cpp
${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_global_settings.cpp
${PROJECT_SOURCE_DIR}/modules/utils/src/wrt_utility.cpp
PARENT_SCOPE
SET(DPL_UTILS_HEADERS
- ${PROJECT_SOURCE_DIR}/modules/utils/include/file_utils.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/folder_size.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/mime_type_utils.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/warp_iri.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/widget_version.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/wrt_global_settings.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/wrt_global_settings_internal.h
- ${PROJECT_SOURCE_DIR}/modules/utils/include/wrt_utility.h
+ ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/file_utils.h
+ ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/folder_size.h
+ ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/mime_type_utils.h
+ ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/warp_iri.h
+ ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/widget_version.h
+ ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/wrt_global_settings.h
+ ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/wrt_utility.h
PARENT_SCOPE
)
#define WRT_COMMON_GLOBAL_SETTINGS_H_
namespace GlobalSettings {
-//TODO description
-bool GetPopupsEnabledFlag();
+
+// Methods for getting/setting test mode environment flag
+bool TestModeEnabled();
+bool IsEmulator();
+
}
#endif /* WRT_COMMON_GLOBAL_SETTINGS_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.
- */
-/**
- * @file wrt_global_settings_internal.h
- * @version 0.6
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @brief Header file for global predefined wrt setting - internal interface
- */
-
-#ifndef WRT_SRC_COMMON_WRT_GLOBAL_SETTINGS_INTERNAL_H_
-#define WRT_SRC_COMMON_WRT_GLOBAL_SETTINGS_INTERNAL_H_
-
-namespace GlobalSettings {
-struct IGlobalSettingsFunctions
-{
- bool (*getPopupsEnabledFlag)();
-};
-
-void SetPredefinedGlobalSettings(IGlobalSettingsFunctions functions);
-}
-
-#endif //WRT_SRC_COMMON_WRT_GLOBAL_SETTINGS_INTERNAL_H_
#include <dpl/exception.h>
#include <dpl/errno_string.h>
-#include <file_utils.h>
+#include <dpl/utils/file_utils.h>
#include <dpl/wrt-dao-ro/path_builder.h>
#include <dpl/log/log.h>
#include <dpl/foreach.h>
-#include <folder_size.h>
+#include <dpl/utils/folder_size.h>
namespace Utils {
namespace {
#include <map>
-#include <mime_type_utils.h>
+#include <dpl/utils/mime_type_utils.h>
const std::set<DPL::String>& MimeTypeUtils::getMimeTypesSupportedForIcon()
{
#include <list>
#include <set>
#include <string>
-#include <warp_iri.h>
+#include <dpl/utils/warp_iri.h>
#include <dpl/string.h>
#include <dpl/auto_ptr.h>
#include <dpl/foreach.h>
* @version 1.0
* @brief Implementation file for widget version
*/
-#include <widget_version.h>
+#include <dpl/utils/widget_version.h>
#include <dpl/assert.h>
#include <dpl/log/log.h>
#include <ctype.h>
* @author Lukasz Wrzosek (l.wrzosek@samsung.com)
* @brief runtime
*/
-#include <dpl/assert.h>
-#include <dpl/log/log.h>
-#include <string.h>
-#include <stdlib.h>
-#include <wrt_global_settings_internal.h>
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <sys/utsname.h>
+#include <dpl/utils/wrt_global_settings.h>
+
+namespace GlobalSettings {
namespace {
-bool GetPopupsEnabledFlag()
+const char* MACHINE_NAME_EMUL = "emulated"; // "arch_emulated"
+enum MachineType
{
- //TODO : env var. will be removed after UX guide for POWDER is enabled.
- const char *env = getenv("WRT_POPUP_ENABLE");
- if (env && 0 == strcmp(env, "1")) {
- return true;
- } else {
- return false;
- }
-}
+ MACHINE_TYPE_TARGET,
+ MACHINE_TYPE_EMULATOR,
+ MACHINE_TYPE_UNKNOWN
+};
+
+struct Settings {
+ bool testMode;
+ bool isEmulator;
+
+ Settings()
+ : testMode(false),
+ isEmulator(false)
+ {}
+};
-static bool initializeGlobalSettings();
+Settings gSettings;
+
+bool initializeGlobalSettings();
+bool initHelper = initializeGlobalSettings();
+
+MachineType getMachineType()
+{
+ // get current machine name
+ struct utsname u;
+ if (0 == uname(&u)) {
+ if ((!u.machine) || (0 == strlen(u.machine))) {
+ return MACHINE_TYPE_UNKNOWN;
+ } else {
+ // If current machine is emul,
+ // machine name include "<arch>_emulated"
+ std::string machine = u.machine;
+ // find "emulated" string in the u.machine
+ if (std::string::npos != machine.find(MACHINE_NAME_EMUL)) {
+ return MACHINE_TYPE_EMULATOR;
+ } else {
+ return MACHINE_TYPE_TARGET;
+ }
+ }
+ }
-static bool initHelper = initializeGlobalSettings();
+ return MACHINE_TYPE_UNKNOWN;
+}
bool initializeGlobalSettings()
{
(void)initHelper;
- LogDebug("Initializing globall settings");
- GlobalSettings::IGlobalSettingsFunctions functions;
- functions.getPopupsEnabledFlag = &GetPopupsEnabledFlag;
- GlobalSettings::SetPredefinedGlobalSettings(functions);
+
+ // ignore environment variables if this flag is not set
+#ifdef GLOBAL_SETTINGS_CONTROL
+ const char *env = getenv("WRT_TEST_MODE");
+ gSettings.testMode = (env != NULL && 0 == strncmp(env, "1", 1));
+ // TODO other settings initialization
+
+#endif
+ gSettings.isEmulator = (MACHINE_TYPE_EMULATOR == getMachineType());
return false;
}
+} // namespace
+
+bool TestModeEnabled()
+{
+ return gSettings.testMode;
}
+
+bool IsEmulator()
+{
+ return gSettings.isEmulator;
+}
+
+} // GlobalSettings
+++ /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 wrt_global_settings_internal.cpp
- * @version 0.6
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- */
-
-#include <wrt_global_settings.h>
-#include <wrt_global_settings_internal.h>
-#include <dpl/assert.h>
-#include <dpl/log/log.h>
-
-namespace GlobalSettings {
-static IGlobalSettingsFunctions globalSettingsFunctions;
-
-// INTERNAL
-void SetPredefinedGlobalSettings(IGlobalSettingsFunctions functions)
-{
- globalSettingsFunctions = functions;
- LogDebug("Global settings are set");
-}
-
-// PUBLIC
-bool GetPopupsEnabledFlag()
-{
- Assert(globalSettingsFunctions.getPopupsEnabledFlag &&
- "Global settings are unset");
- return globalSettingsFunctions.getPopupsEnabledFlag();
-}
-} //namespace GlobalSettings
#include <sys/types.h>
#include <sys/stat.h>
#include <dpl/log/log.h>
-#include <wrt_utility.h>
+#include <dpl/utils/wrt_utility.h>
using namespace std;
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(WRT_DAO_DEPS
- cert-svc
ecore
appcore-efl
libxml-2.0
dao/common_dao_types.cpp
dao/feature_dao_read_only.cpp
dao/global_dao_read_only.cpp
- dao/global_config.cpp
dao/path_builder.cpp
dao/plugin_dao_read_only.cpp
dao/property_dao_read_only.cpp
dao/widget_dao.cpp
)
-ADD_DEFINITIONS("-DSEPARATED_SINGLETON_IMPLEMENTATION")
-
SET(WRT_DAO_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/modules/widget_dao/include
${PROJECT_SOURCE_DIR}/modules/event/include
namespace WrtDB {
namespace FeatureDAO {
-const int STRANGE_FEATURE_PROPERTIES_ID = 0;
-
FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
const DbPluginHandle pluginHandle)
{
}
}
-FeatureHandle RegisterStrangeFeature(const std::string& featureName)
-{
- Try
- {
- LogDebug("Registering Feature " << featureName);
- DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
-
- if (FeatureDAOReadOnly::isFeatureInstalled(featureName)) {
- LogError(" >> Feature " << featureName <<
- " is already registered.");
- transaction.Commit();
- return -1;
- }
-
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
-
- //register feature
- LogInfo(" |-- Registering feature " << featureName);
-
- FeaturesList::Row row;
- row.Set_FeatureName(DPL::FromUTF8String(featureName));
-
- // PluginPropertiesId '0' is not used as PluginPropertiesId for normal features(calendar, contact....).
- // PluginPropertiesId for normal features start from '1'
- row.Set_PluginPropertiesId(STRANGE_FEATURE_PROPERTIES_ID);
-
- WRT_DB_INSERT(insert, FeaturesList, &WrtDatabase::interface())
- insert->Values(row);
- insert->Execute();
-
- FeatureHandle featureHandle =
- FeatureDAOReadOnly(featureName).GetFeatureHandle();
-
- transaction.Commit();
-
- return featureHandle;
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
- "Failure during Registering Feature");
- }
-}
-
} // namespace FeatureDAO
} // namespace WrtDB
failure.str()); \
}
-std::string FeatureDAOReadOnly::GetInstallURI() const
-{
- GET_PLUGIN_DATA(getInstallURI)
-}
-
-std::string FeatureDAOReadOnly::GetKeyCn() const
-{
- GET_PLUGIN_DATA(getKeyCn)
-}
-
-std::string FeatureDAOReadOnly::GetRootKey() const
-{
- GET_PLUGIN_DATA(getRootKey)
-}
-
-std::string FeatureDAOReadOnly::GetRootKeyFingerprint() const
-{
- GET_PLUGIN_DATA(getRootKeyFingerprint)
-}
-
std::string FeatureDAOReadOnly::GetLibraryPath() const
{
GET_PLUGIN_DATA(getLibraryPath)
}
}
+FeatureDAOReadOnly::NameMap
+FeatureDAOReadOnly::GetNames()
+{
+ Try {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ WRT_DB_SELECT(select, FeaturesList, &WrtDatabase::interface())
+
+ NameMap nameMap;
+
+ FeaturesList::Select::RowList rows = select->GetRowList();
+ FOREACH(rowIt, rows)
+ {
+ nameMap.insert(std::pair<FeatureHandle, std::string>(rowIt->Get_FeatureUUID(), DPL::ToUTF8String(rowIt->Get_FeatureName())));
+ }
+
+ return nameMap;
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base){
+ ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
+ "Failure during getting GetNames");
+ }
+}
+
+FeatureDAOReadOnly::DeviceCapabilitiesMap
+FeatureDAOReadOnly::GetDevCapWithFeatureHandle()
+{
+ Try {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+
+ DECLARE_COLUMN_TYPE_LIST()
+ SELECTED_COLUMN(FeatureDeviceCapProxy, FeatureUUID)
+ SELECTED_COLUMN(DeviceCapabilities, DeviceCapName)
+ DECLARE_COLUMN_TYPE_LIST_END(DevCapNameList)
+
+ WRT_DB_SELECT(select, FeatureDeviceCapProxy, &WrtDatabase::interface())
+ select->Join<DevCapNameList>(Equal<FeatureDeviceCapProxy::DeviceCapID, DeviceCapabilities::DeviceCapID>());
+
+ DeviceCapabilitiesMap devCap;
+
+ std::list< CustomRow<DevCapNameList> > rowList = select->GetCustomRowList< DevCapNameList, CustomRow<DevCapNameList> >();
+ FOREACH(rowIt, rowList)
+ {
+ FeatureHandle featureHandle = (*rowIt).GetColumnData<FeatureDeviceCapProxy::FeatureUUID>();
+ std::string devName = DPL::ToUTF8String((*rowIt).GetColumnData<DeviceCapabilities::DeviceCapName>());
+ devCap.insert(std::pair<FeatureHandle, std::string>(featureHandle, devName));
+ }
+
+ return devCap;
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base){
+ ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError,
+ "Failure during getting DeviceCapabilities names");
+ }
+}
+
} // namespace WrtDB
+++ /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.
- */
-#include <dpl/wrt-dao-ro/global_config.h>
-
-#include <cstdlib>
-#include <cstring>
-
-namespace WrtDB {
-namespace GlobalConfig {
-bool IsOCSPEnabled()
-{
- static const char *val = getenv("WRT_OCSP_ENABLE");
- static bool enableOCSP = val && (strcmp(val, "1") == 0);
- return enableOCSP;
-}
-
-bool IsCRLEnabled()
-{
- static const char *val = getenv("WRT_CRL_ENABLE");
- static bool enableOCSP = val && (strcmp(val, "1") == 0);
- return enableOCSP;
-}
-
-} // namespace GlobalConfig
-} // namespace WrtDB
-
#include <dpl/wrt-dao-ro/WrtDatabase.h>
namespace WrtDB {
-void GlobalDAO::AddDefferedWidgetPackageInstallation(const DPL::String &path)
-{
- LogDebug("Adding widget package as defered. Path: " << path);
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- DefferedWidgetPackageInstallation::Row row;
- row.Set_path(path);
-
- WRT_DB_INSERT(insert, DefferedWidgetPackageInstallation, &WrtDatabase::interface())
- insert->Values(row);
- insert->Execute();
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(GlobalDAO::Exception::DatabaseError,
- "Failed to add defered widget package");
- }
-}
-
-void GlobalDAO::RemoveDefferedWidgetPackageInstallation(const DPL::String &path)
-{
- LogDebug("Remove widget package from differed list. Path: " << path);
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- WRT_DB_DELETE(del, DefferedWidgetPackageInstallation, &WrtDatabase::interface())
- del->Where(Equals<DefferedWidgetPackageInstallation::path>(path));
- del->Execute();
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(GlobalDAO::Exception::DatabaseError,
- "Failed to remove defered widget package");
- }
-}
-
void GlobalDAO::SetDeveloperMode(bool mode)
{
LogDebug("updating Developer mode to:" << mode);
}
}
+void GlobalDAO::SetCookieSharingMode(bool mode)
+{
+ LogDebug("updating Cookie Sharing mode to:" << mode);
+ Try {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ GlobalProperties::Row row;
+ row.Set_cookie_sharing_mode(mode);
+
+ WRT_DB_UPDATE(update, GlobalProperties, &WrtDatabase::interface())
+ update->Values(row);
+ update->Execute();
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base){
+ ReThrowMsg(GlobalDAO::Exception::DatabaseError,
+ "Failed to update Cookie Sharing Mode");
+ }
+}
+
} // namespace WrtDB
}
}
-WidgetPackageList GlobalDAOReadOnly::GetDefferedWidgetPackageInstallationList()
-{
- LogDebug("Getting widget packages list defered for installation");
- Try {
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
- WRT_DB_SELECT(select, DefferedWidgetPackageInstallation, &WrtDatabase::interface())
- return select->GetValueList<DefferedWidgetPackageInstallation::path>();
- }
- Catch(DPL::DB::SqlConnection::Exception::Base){
- ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
- "Failed to get defered widget packages list");
- }
-}
-
bool GlobalDAOReadOnly::GetSecureByDefault()
{
using namespace DPL::DB::ORM;
}
}
+bool GlobalDAOReadOnly::GetCookieSharingMode()
+{
+ LogDebug("Getting Cookie Sharing mode");
+ Try {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ WRT_DB_SELECT(select, GlobalProperties, &WrtDatabase::interface())
+ return select->GetSingleValue<GlobalProperties::cookie_sharing_mode>();
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base){
+ ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError,
+ "Failed to get Cookie Sharing mode");
+ }
+}
+
} // namespace WrtDB
row.Set_InstallationState(INSTALLATION_IN_PROGRESS);
row.Set_PluginLibraryPath(
DPL::FromUTF8String(pluginPath));
- row.Set_InstallURI(
- DPL::FromUTF8String(metafile.m_featuresInstallURI));
- row.Set_KeyCN(
- DPL::FromUTF8String(metafile.m_featuresKeyCN));
- row.Set_RootKeyCN(
- DPL::FromUTF8String(metafile.m_featuresRootCN));
- row.Set_RootKeyFingerprint(
- DPL::FromUTF8String(metafile.m_featuresRootFingerprint));
WRT_DB_INSERT(insert, PluginProperties, &WrtDatabase::interface())
insert->Values(row);
return ret;
}
-std::string PluginDAOReadOnly::getInstallURI() const
-{
- LogDebug("Getting plugin install URI. Handle: " << m_pluginHandle);
- PluginRow row = getPluginRow(m_pluginHandle);
- RETURN_STD_STRING(row.Get_InstallURI(), "install URI")
-}
-
-std::string PluginDAOReadOnly::getKeyCn() const
-{
- LogDebug("Getting plugin KeyCn. Handle: " << m_pluginHandle);
- PluginRow row = getPluginRow(m_pluginHandle);
- RETURN_STD_STRING(row.Get_KeyCN(), "keyCN")
-}
-
-std::string PluginDAOReadOnly::getRootKey() const
-{
- LogDebug("Getting plugin rootKey. Handle: " << m_pluginHandle);
- PluginRow row = getPluginRow(m_pluginHandle);
- RETURN_STD_STRING(row.Get_RootKeyCN(), "rootKey")
-}
-
-std::string PluginDAOReadOnly::getRootKeyFingerprint() const
-{
- LogDebug("Getting plugin rootKeyFingerprint. Handle: " << m_pluginHandle);
- PluginRow row = getPluginRow(m_pluginHandle);
- RETURN_STD_STRING(row.Get_RootKeyFingerprint(), "rootKeyFingerprint")
-}
-
#undef RETURN_STD_STRING
PluginHandleSetPtr PluginDAOReadOnly::getLibraryDependencies() const
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
}
-DbWidgetHandle WidgetDAO::registerWidget(const WidgetRegisterInfo &widgetRegInfo,
- const IWacSecurity &wacSecurity,
- const LanguageTagsList& languageTags)
+void WidgetDAO::registerWidget(
+ const DbWidgetHandle& widgetHandle,
+ const WidgetRegisterInfo &widgetRegInfo,
+ const IWacSecurity &wacSecurity)
{
LogDebug("Registering widget");
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
//Register into WidgetInfo has to be first
//as all other tables depend upon that
- DbWidgetHandle widgetHandle =
- registerWidgetInfo(widgetRegInfo, wacSecurity);
+ registerWidgetInfo(widgetHandle, widgetRegInfo, wacSecurity);
registerWidgetExtendedInfo(widgetHandle, widgetRegInfo);
registerWidgetLocalizedInfo(widgetHandle, widgetRegInfo);
- registerWidgetUserAgentLocales(
- widgetHandle, widgetRegInfo, languageTags);
-
registerWidgetIcons(widgetHandle, widgetRegInfo);
registerWidgetStartFile(widgetHandle, widgetRegInfo);
registerAppService(widgetHandle, widgetRegInfo);
transaction.Commit();
-
- return widgetHandle;
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
}
row.Set_factory_widget(regInfo.isFactoryWidget);
row.Set_test_widget(regInfo.isTestWidget);
row.Set_install_time(regInfo.installedTime);
+ row.Set_splash_img_src(regInfo.configInfo.splashImgSrc);
+
DO_INSERT(row, WidgetExtendedInfo)
}
-DbWidgetHandle WidgetDAO::registerWidgetInfo(const WidgetRegisterInfo ®Info,
- const IWacSecurity &wacSecurity)
+void WidgetDAO::registerWidgetInfo(
+ const DbWidgetHandle& widgetHandle,
+ const WidgetRegisterInfo ®Info,
+ const IWacSecurity &wacSecurity)
{
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
// Because of that, "Optional" is not used there
WidgetInfo::Row row;
+ row.Set_app_id(widgetHandle);
row.Set_widget_type(regInfo.type.appType);
row.Set_widget_id(widgetConfigurationInfo.widget_id);
row.Set_defaultlocale(widgetConfigurationInfo.defaultlocale);
row.Set_distributor_signed(wacSecurity.isDistributorSigned());
{
std::stringstream tmp;
- tmp << widgetConfigurationInfo.minVersionRequired;
+ tmp << regInfo.minVersion;
row.Set_min_version(DPL::FromUTF8String(tmp.str()));
}
row.Set_back_supported(widgetConfigurationInfo.backSupported);
row.Set_access_network(widgetConfigurationInfo.accessNetwork);
row.Set_pkgname(regInfo.pkgname);
+ row.Set_pkg_type(regInfo.pType.pkgType);
- wrt::WidgetInfo::app_id::ColumnType appID;
+ Try
{
- WRT_DB_INSERT(insert, WidgetInfo, &WrtDatabase::interface())
- insert->Values(row);
- appID = insert->Execute();
+ DO_INSERT(row, WidgetInfo);
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base)
+ {
+ ReThrowMsg(WidgetDAO::Exception::DatabaseError,
+ "Failed to register widget info.");
}
- return appID;
}
void WidgetDAO::registerWidgetLocalizedInfo(DbWidgetHandle widgetHandle,
}
}
-void WidgetDAO::registerWidgetUserAgentLocales(
- DbWidgetHandle widgetHandle,
- const WidgetRegisterInfo &/*regInfo*/,
- const LanguageTagsList& languageTags)
-{
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::wrt;
-
-
- FOREACH(i, languageTags)
- {
- wrt::WidgetUserAgentLocales::Row row;
- row.Set_app_id(widgetHandle);
- row.Set_language_tag(*i);
-
- DO_INSERT(row, wrt::WidgetUserAgentLocales)
- }
-}
-
void WidgetDAO::registerWidgetIcons(DbWidgetHandle widgetHandle,
const WidgetRegisterInfo ®Info)
{
{
}
+WidgetDAOReadOnly::WidgetDAOReadOnly(DPL::OptionalString widgetGUID) :
+ m_widgetHandle(WidgetDAOReadOnly::getHandle(widgetGUID))
+{
+}
+
WidgetDAOReadOnly::~WidgetDAOReadOnly()
{
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get widdget install time")
}
+DPL::OptionalString WidgetDAOReadOnly::getSplashImgSrc() const
+{
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ WRT_DB_SELECT(select, WidgetExtendedInfo, &WrtDatabase::interface())
+ select->Where(Equals<WidgetExtendedInfo::app_id>(m_widgetHandle));
+
+ WidgetExtendedInfo::Select::RowList rows = select->GetRowList();
+ if (rows.empty()) {
+ ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+ "Cannot find widget. Handle: " << m_widgetHandle);
+ }
+
+ DPL::OptionalString value = rows.front().Get_splash_img_src();
+ if (value.IsNull()) {
+ return DPL::OptionalString::Null;
+ }
+
+ return DPL::OptionalString(getPath() + *value);
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get splash image path")
+}
+
WidgetDAOReadOnly::WidgetLocalizedIconList WidgetDAOReadOnly::getLocalizedIconList() const
{
//TODO check widget existance??
FingerPrintList keys;
FOREACH(it, rows)
{
- DPL::Optional<DPL::String> md5 = it->Get_md5_fingerprint();
- keys.push_back(md5.IsNull() ? "" : DPL::ToUTF8String(*md5));
DPL::Optional<DPL::String> sha1 = it->Get_sha1_fingerprint();
- keys.push_back(sha1.IsNull() ? "" : DPL::ToUTF8String(*sha1));
+ if (!sha1.IsNull()) {
+ keys.push_back(DPL::ToUTF8String(*sha1));
+ }
+ DPL::Optional<DPL::String> md5 = it->Get_md5_fingerprint();
+ if (!md5.IsNull()) {
+ keys.push_back(DPL::ToUTF8String(*md5));
+ }
}
return keys;
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get access host list")
}
+PkgType WidgetDAOReadOnly::getPkgType() const
+{
+ WidgetInfoRow row = getWidgetInfoRow(m_widgetHandle);
+ DPL::OptionalInt result = row.Get_pkg_type();
+ return PkgType(static_cast<PackagingType>(*result));
+}
+
#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
#undef SQL_CONNECTION_EXCEPTION_HANDLER_END
#undef CHECK_WIDGET_EXISTENCE
}
std::string m_libraryName;
- std::string m_featuresInstallURI;
- std::string m_featuresKeyCN;
- std::string m_featuresRootCN;
- std::string m_featuresRootFingerprint;
-
FeatureContainer m_featureContainer;
};
typedef int DbWidgetHandle;
/**
+ * Value of invalid widget handle
+ */
+enum {
+ INVALID_WIDGET_HANDLE = -1
+};
+
+/**
* @brief Structure to hold the information of widget's size
*/
struct DbWidgetSize
enum AppType
{
APP_TYPE_UNKNOWN = 0, // unknown
- APP_TYPE_WAC10, // WAC 1.0
APP_TYPE_WAC20, // WAC 2.0
APP_TYPE_TIZENWEBAPP, // Tizen webapp
};
switch (appType) {
#define X(x) case x: return #x;
X(APP_TYPE_UNKNOWN)
- X(APP_TYPE_WAC10)
X(APP_TYPE_WAC20)
X(APP_TYPE_TIZENWEBAPP)
#undef X
AppType appType;
};
+/**
+ * @brief Package specific type
+ *
+ * Package type describes belowed in Tizen webapp, C++ service App
+ */
+enum PackagingType
+{
+ PKG_TYPE_UNKNOWN = 0, // unknown
+ PKG_TYPE_TIZEN_WEBAPP, // Tizen webapp
+ PKG_TYPE_TIZEN_WITHSVCAPP, // Tizen webapp with C++ service app
+};
+
+class PkgType
+{
+ public:
+ PkgType()
+ :pkgType(PKG_TYPE_UNKNOWN)
+ {
+ }
+ PkgType(const PackagingType type)
+ :pkgType(type)
+ {
+ }
+ bool operator== (const PackagingType& other) const
+ {
+ return pkgType == other;
+ }
+ std::string getPkgtypeToString()
+ {
+ switch (pkgType) {
+#define X(x) case x: return #x;
+ X(PKG_TYPE_UNKNOWN)
+ X(PKG_TYPE_TIZEN_WEBAPP)
+ X(PKG_TYPE_TIZEN_WITHSVCAPP)
+#undef X
+ default:
+ return "UNKNOWN";
+ }
+ }
+
+ PackagingType pkgType;
+};
+
} // namespace WrtDB
struct WidgetSetting
bool operator!=(const ServiceInfo&) const;
};
typedef std::list<ServiceInfo> ServiceInfoList;
+ typedef std::list<DPL::OptionalString> DependsPkgList;
StringsList nameSpaces;
DPL::OptionalString startFileContentType;
IconsList iconsList;
- // pakcage name determined by operator for TIZEN webapp
- DPL::OptionalString pkgname;
+ // tizen id / required platform min version for TIZEN webapp
+ DPL::OptionalString tizenId;
+ DPL::OptionalString tizenMinVersionRequired;
+
//Application service model list
ServiceInfoList appServiceList;
+ // For link shared directory
+ DependsPkgList dependsPkgList;
+ // Splash image path
+ DPL::OptionalString splashImgSrc;
ConfigParserData() :
flashNeeded(false),
};
typedef std::set<std::string> DeviceCapabilitiesList;
+ typedef std::multimap<FeatureHandle, std::string> DeviceCapabilitiesMap;
+ typedef std::map<FeatureHandle, std::string> NameMap;
static bool isDeviceCapabilityInstalled(const std::string &deviceCapName);
static FeatureHandleList GetHandleList();
std::string GetName() const;
- std::string GetInstallURI() const;
- std::string GetKeyCn() const;
- std::string GetRootKey() const;
- std::string GetRootKeyFingerprint() const;
FeatureHandle GetFeatureHandle() const;
std::string GetLibraryPath() const;
std::string GetLibraryName() const;
DeviceCapabilitiesList GetDeviceCapabilities() const;
DbPluginHandle GetPluginHandle() const;
+ static NameMap GetNames();
+ static DeviceCapabilitiesMap GetDevCapWithFeatureHandle();
+
protected:
FeatureHandle m_featureHandle;
};
PHandle(this, -1)
{
}
+
+ void SetData(const std::string& name, const std::set<std::string>& deviceCapabilities, const DbPluginHandle& pluginHandle)
+ {
+ Name.SetWithoutLock(name);
+ DeviceCapabilities.SetWithoutLock(deviceCapabilities);
+ PHandle.SetWithoutLock(pluginHandle);
+ }
};
typedef DPL::SharedPtr<FeatureModel> FeatureModelPtr;
*/
inline const char* GetWidgetSrcPath()
{
- return "res/src";
+ return "res/wgt";
}
/**
*/
inline const char* GetUserWidgetDesktopIconPath()
{
- return "res/icons/default/small";
+ return "/opt/share/icons/default/small";
}
/**
}
/**
+ * Plugin .so prefix
+ */
+inline const char* GetPluginPrefix()
+{
+ return "libwrt-plugins-";
+}
+
+/**
+ * Plugin .so suffix
+ */
+inline const char* GetPluginSuffix()
+{
+ return ".so";
+}
+
+/**
* WRT device plugins installation required
* File which indicate that new plugins
* are available and should be installed
{
return "/opt/dbspace/.vcore.db";
}
-bool IsOCSPEnabled();
-bool IsCRLEnabled();
/**
* widgets cookie database file name
{
return "2.0";
}
+
+inline const char* GetTizenVersion()
+{
+ return "1.0";
+}
+
+inline const char* GetShareDirectoryPath()
+{
+ return "/opt/share";
+}
+
+inline const char* GetTempInstallInfoPath()
+{
+ return "/opt/apps/widget/temp_info";
+}
} // namespace GlobalConfig
} // namespace WrtDB
static bool IsValidSubTag(const DPL::String& tag, int type);
- /**
- * Retrieve list of deffered widget packages to be installed
- *
- * @return Widget package list
- */
- static WidgetPackageList GetDefferedWidgetPackageInstallationList();
-
static bool GetDeveloperMode();
static bool GetSecureByDefault();
static WidgetAccessInfoList GetWhiteURIList();
+ static bool GetCookieSharingMode();
+
enum NetworkAccessMode
{
NEVER_CONNECT,
PluginInstallationState getInstallationStatus() const;
std::string getLibraryPath() const;
std::string getLibraryName() const;
- std::string getInstallURI() const;
- std::string getKeyCn() const;
- std::string getRootKey() const;
- std::string getRootKeyFingerprint() const;
PluginHandleSetPtr getLibraryDependencies() const;
private:
signatureType(SIGNATURE_TYPE_UNIDENTIFIED),
isFactoryWidget(0),
isTestWidget(0),
- configInfo()
+ configInfo(),
+ pType(PKG_TYPE_UNKNOWN)
{
}
LocalizationData localizationData;
DPL::OptionalString pkgname;
time_t installedTime;
+ PkgType pType;
};
typedef std::list<std::string> CertificateChainList;
* @param[in] widgetHandle application id of widget.
*/
WidgetDAOReadOnly(DbWidgetHandle widgetHandle);
+ WidgetDAOReadOnly(DPL::OptionalString widgetGUID);
/**
* Destructor
static bool isWidgetInstalled(DbWidgetHandle handle);
static bool isWidgetInstalled(DPL::String pkgName);
+ /* This method get path of the splash image.
+ *
+ * @return path of the widget's splash image
+ */
+ DPL::OptionalString getSplashImgSrc() const;
+
CertificateChainList getWidgetCertificate() const;
void getWidgetSettings(WidgetSettings& outWidgetSettings) const;
*/
void getAppServiceList(
WidgetApplicationServiceList& outAppServiceList) const;
+
+ /**
+ * This method returns the type of the package.
+ *
+ * @return PkgType
+ * @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.
+ */
+ PkgType getPkgType() const;
};
} // namespace WrtDB
namespace FeatureDAO {
FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature,
const DbPluginHandle pluginHandle);
-
- FeatureHandle RegisterStrangeFeature(const std::string& featureName);
} // namespace FeatureDB
} // namespace WrtDB
class GlobalDAO : public GlobalDAOReadOnly
{
public:
- /**
- * Add deffered widget packages to be installed
- */
- static void AddDefferedWidgetPackageInstallation(const DPL::String &path);
-
- /**
- * Remove deffered widget packages to be installed
- */
- static void RemoveDefferedWidgetPackageInstallation(const DPL::String &arg);
-
static void SetDeveloperMode(bool mode);
static void SetSecureByDefault(bool secureByDefault);
*/
static void SetRoamingDataUsage(NetworkAccessMode newMode);
+ static void SetCookieSharingMode(bool mode);
+
private:
GlobalDAO()
{
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <list>
#include <string>
+#include <sys/time.h>
+#include <ctime>
+#include <cstdlib>
#include <dpl/exception.h>
#include <dpl/db/orm.h>
#include <dpl/wrt-dao-ro/config_parser_data.h>
*
* @see WidgetRegisterInfo
* @see UnRegisterWidget()
+ * @param[in] widgetHandle Widget ID that will be registered.
* @param[in] pWidgetRegisterInfo Specified the widget's information needed to be registered.
- * @return widget's app id issued by app manager; 0 represents a failure during register.
+ * @param[in] wacSecurity Widget's security certificates.
*/
+ static void registerWidget(
+ const DbWidgetHandle& widgetHandle,
+ const WidgetRegisterInfo &pWidgetRegisterInfo,
+ const IWacSecurity &wacSecurity);
+
static DbWidgetHandle registerWidget(
const WidgetRegisterInfo &pWidgetRegisterInfo,
- const IWacSecurity &wacSecurity,
- const LanguageTagsList& languageTags);
+ const IWacSecurity &wacSecurity) __attribute__((deprecated))
+ {
+ //make it more precise due to very fast tests
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ srand(time(NULL) + tv.tv_usec);
+ DbWidgetHandle widgetHandle;
+ do {
+ widgetHandle = rand();
+ } while (isWidgetInstalled(widgetHandle));
+
+ registerWidget(widgetHandle, pWidgetRegisterInfo, wacSecurity);
+ return widgetHandle;
+ }
/**
* This method removes a widget's information from EmDB.
private:
//Methods used during widget registering
- static DbWidgetHandle registerWidgetInfo(
+ static void registerWidgetInfo(
+ const DbWidgetHandle& widgetHandle,
const WidgetRegisterInfo ®Info,
const IWacSecurity &wacSecurity);
static void registerWidgetExtendedInfo(
static void registerWidgetLocalizedInfo(
DbWidgetHandle widgetHandle,
const WidgetRegisterInfo ®Info);
- static void registerWidgetUserAgentLocales(
- DbWidgetHandle widgetHandle,
- const WidgetRegisterInfo &rInf,
- const LanguageTagsList& languageTags);
static void registerWidgetIcons(
DbWidgetHandle widgetHandle,
const WidgetRegisterInfo ®Info);
COLUMN_NOT_NULL(compliance_mode, TINYINT, DEFAULT 0)
COLUMN_NOT_NULL(compliance_fake_imei, VARCHAR(256), DEFAULT '')
COLUMN_NOT_NULL(compliance_fake_meid, VARCHAR(256), DEFAULT '')
+ COLUMN_NOT_NULL(cookie_sharing_mode, INT, DEFAULT 0)
CREATE_TABLE_END()
SQL(
)
CREATE_TABLE(WidgetInfo)
- COLUMN_NOT_NULL(app_id, INTEGER, PRIMARY KEY AUTOINCREMENT)
+ COLUMN_NOT_NULL(app_id, INTEGER, PRIMARY KEY)
COLUMN(widget_type, INT, DEFAULT 1)
COLUMN(widget_id, VARCHAR(256), DEFAULT '')
COLUMN(widget_version, VARCHAR(256), DEFAULT '')
COLUMN(access_network, TINYINT, DEFAULT 0)
COLUMN(defaultlocale, VARCHAR(256), DEFAULT 0)
COLUMN(pkgname, VARCHAR(256), DEFAULT 0)
+ COLUMN(pkg_type, INT, DEFAULT 0)
CREATE_TABLE_END()
CREATE_TABLE(WidgetCertificate)
)
CREATE_TABLE_END()
-CREATE_TABLE(WidgetUserAgentLocales)
- COLUMN_NOT_NULL(id, INTEGER, PRIMARY KEY AUTOINCREMENT)
- COLUMN_NOT_NULL(app_id, INT,)
- COLUMN_NOT_NULL(language_tag, TEXT,)
- TABLE_CONSTRAINTS(
- FOREIGN KEY (app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
- )
-CREATE_TABLE_END()
-
CREATE_TABLE(LocalizedWidgetInfo)
COLUMN_NOT_NULL(app_id, INT,)
COLUMN_NOT_NULL(widget_locale, TEXT,)
COLUMN(updated, INT, DEFAULT 0)
COLUMN(update_policy, INT, DEFAULT 0)
COLUMN_NOT_NULL(test_widget, INT, CHECK(test_widget between 0 and 1) DEFAULT 0)
+ COLUMN(splash_img_src, VARCHAR(256), DEFAULT '')
TABLE_CONSTRAINTS(
FOREIGN KEY(app_id) REFERENCES WidgetInfo (app_id) ON DELETE CASCADE
)
COLUMN_NOT_NULL(InstallationState, INTEGER, DEFAULT 0)
COLUMN_NOT_NULL(PluginLibraryName, TEXT, unique)
COLUMN(PluginLibraryPath, TEXT,)
- COLUMN(InstallURI, TEXT,)
- COLUMN(KeyCN, TEXT,)
- COLUMN(RootKeyCN, TEXT,)
- COLUMN(RootKeyFingerprint, TEXT,)
CREATE_TABLE_END()
CREATE_TABLE(PluginDependencies)
TABLE_CONSTRAINTS(PRIMARY KEY(FeatureUUID,DeviceCapID))
CREATE_TABLE_END()
-CREATE_TABLE(DefferedWidgetPackageInstallation)
- COLUMN_NOT_NULL(path, TEXT, unique)
-CREATE_TABLE_END()
-
CREATE_TABLE(OCSPResponseStorage)
COLUMN_NOT_NULL(cert_chain, TEXT, primary key)
COLUMN(end_entity_check, INT,)
CREATE_TABLE_END()
SQL(
- INSERT INTO UserAgents VALUES("Tizen", "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0");
+ INSERT INTO UserAgents VALUES("Galaxy S", "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; GT-I9000 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
+ INSERT INTO UserAgents VALUES("Galaxy S II", "Mozilla/5.0 (Linux; U; Android 2.3.5; en-gb; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
+ INSERT INTO UserAgents VALUES("Galaxy S III", "Mozilla/5.0 (Linux; U; Android 4.0.3; en-gb; GT-I9300 Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
+ INSERT INTO UserAgents VALUES("SLP Galaxy", "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; GT-I9500 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
+ INSERT INTO UserAgents VALUES("Tizen", "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0");
+ INSERT INTO UserAgents VALUES("Galaxy Nexus", "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; Galaxy Nexus Build/IML74K) AppleWebKit/535.7 (KHTML, like Gecko) Mobile Safari/535.7");
+ INSERT INTO UserAgents VALUES("Samsung", "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-I9200/1.0; U; Linux/SLP/2.0; ko-kr) AppleWebKit/534.4 (KHTML, like Gecko) Dolfin/2.0 Mobile");
+ INSERT INTO UserAgents VALUES("Samsung Dolfin", "SAMSUNG-GT-S8500/S8500XXJD2 SHP/VPP/R5 Dolfin/2.0 Nextreaming SMM-MMS/1.2.0 profile/MIDP-2.1 configuration/CLDC-1.1");
+ INSERT INTO UserAgents VALUES("Apple iPhone 3", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16");
+ INSERT INTO UserAgents VALUES("Apple iPhone 4", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5");
+ INSERT INTO UserAgents VALUES("Apple iOS 5", "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3");
+ INSERT INTO UserAgents VALUES("Android 2.3 (Nexus One)", "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Nexus One Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
+ INSERT INTO UserAgents VALUES("Opera Mobi", "Opera/9.80 (Windows NT 6.1; U; Edition IBIS; en) Presto/2.6.30 Version/10.63");
+ INSERT INTO UserAgents VALUES("Samsung Bada", "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/1.0; U; Bada/1.0; en-us) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.0 Mobile WVGA SMM-MMS/1.2.0 OPN-B");
+ INSERT INTO UserAgents VALUES("Orange TV 3.2 iPhone", "Mozilla/5.0 (OrangeTVPlayer4iPhone/iPhone2,1; U; CPU iPhone OS 4_3 like Mac OS X; fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F136 Safari/525.20 OrangeAppliTVHTTPLS/3.2.16");
+ INSERT INTO UserAgents VALUES("Orange TV 3.2 iPad", "Mozilla/5.0 (OrangeTVPlayer4iPhone/iPad1,1; U; CPU iPhone OS 4_3 like Mac OS X; fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F136 Safari/525.20 iPad=SIMENABLED OrangeAppliTVHTTPLS/3.2.16");
+ INSERT INTO UserAgents VALUES("Orange TV 3.3 iOS", "OrangeTVPlayer4iPhone/_iOS_3.3.3_Apple_iPhone2,1_4.1_OrangeAppliTVHTTPLS/3.3.3");
+ INSERT INTO UserAgents VALUES("Chrome Browser for android", "Mozilla/5.0 (Linux; U; Android 4.0.1; ko-kr; Galaxy Nexus Build/ITL41F) AppleWebKit/535.7 (KHTML, like Gecko) CrMo/16.0.912.75 Mobile Safari/535.7");
+ INSERT INTO UserAgents VALUES("MANGO(Nokia 800C)", "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; Nokia; 800C)");
+ INSERT INTO UserAgents VALUES("System user agent", "");
+ INSERT INTO UserAgents VALUES("Samsung Bada 2.0", "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/1.0; U; Bada/2.0; en-us) AppleWebKit/534.20 (KHTML, like Gecko) Mobile WVGA SMM-MMS/1.2.0 OPN-B Dolfin/3.0");
+ INSERT INTO UserAgents VALUES("Samsung Desktop", "Mozilla/5.0 (U; Linux/SLP/2.0; ko-kr) AppleWebKit/533.1 (KHTML, like Gecko)");
+ INSERT INTO UserAgents VALUES("Firefox 5", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");
+ INSERT INTO UserAgents VALUES("Firefox 5 Fennec(Mobile)", "Mozilla/5.0 (Android; Linux armv7l; rv:5.0) Gecko/20110615 Firefox/5.0 Fennec/5.0");
+ INSERT INTO UserAgents VALUES("Safari 5.0", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7");
+ INSERT INTO UserAgents VALUES("Google Chrome 18.0", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.16 (KHTML, like Gecko) Chrome/18.0.1003.1 Safari/535.16");
+ INSERT INTO UserAgents VALUES("Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
+ INSERT INTO UserAgents VALUES("Galaxy Tab 10.1", "Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; GT-P7100 Build/HRI83) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13");
+ INSERT INTO UserAgents VALUES("iPad 2", "Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5");
)
SQL(
-#sbs-git:public/pkgs/w/wrt-commons wrt-commons 0.2.25
+#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.53
Name: wrt-commons
Summary: Wrt common library
-Version: 0.2.25
+Version: 0.2.53
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(libpcrecpp)
BuildRequires: pkgconfig(icu-i18n)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(openssl)
-BuildRequires: pkgconfig(cert-svc)
BuildRequires: pkgconfig(libiri)
BuildRequires: pkgconfig(libidn)
%build
export LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed"
+
cmake . -DVERSION=%{version} \
-DDPL_LOG="OFF" \
- -DCMAKE_INSTALL_PREFIX=%{_prefix}
+ -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
%post
+mkdir -p /opt/apps/widget/system
+mkdir -p /opt/apps/widget/user
+mkdir -p /opt/apps/widget/exec
+mkdir -p /opt/apps/widget/data/Public
+mkdir -p /usr/lib/wrt-plugins
+
if [ -z ${2} ]; then
echo "This is new install of wrt-commons"
echo "Calling /usr/bin/wrt_commons_reset_db.sh"
+++ /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 CMakeLists.txt
-# @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
-# @version 1.0
-# @brief
-#
-
-#
-# Test files
-#
-# Define all DPL tests sources.
-# Runner is responsible for runnint it all and
-# generating proper output files
-#
-
-SET(TARGET_NAME "dpl-tests-core")
-
-# Set DPL tests sources
-SET(DPL_TESTS_SOURCES
- ${PROJECT_SOURCE_DIR}/tests/core/main.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_address.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_binary_queue.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_foreach.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_fast_delegate.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_log_unhandled_exception.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_once.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_serialization.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_array.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_close.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_fclose.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_free.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_scoped_ptr.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_semaphore.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_shared_ptr.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_string.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_task.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_thread.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_type_list.cpp
- ${PROJECT_SOURCE_DIR}/tests/core/test_zip_input.cpp
-)
-
-INCLUDE_DIRECTORIES(
- ${SYS_EFL_INCLUDE_DIRS}
- ${DPL_TEST_INCLUDE_DIR}
-)
-
-LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS})
-
-ADD_EXECUTABLE(${TARGET_NAME} ${DPL_TESTS_SOURCES})
-
-TARGET_LINK_LIBRARIES(
- ${TARGET_NAME}
- ${SYS_EFL_LIBRARIES}
- ${TARGET_DPL_EFL}
- ${TARGET_DPL_TEST_ENGINE_EFL}
-)
-
-SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_NAME}
- DESTINATION bin)
-
-INSTALL(FILES
- ${PROJECT_SOURCE_DIR}/tests/core/data/sample.zip
- DESTINATION /opt/apps/wrt/wrt-commons/tests/core
-)
+++ /dev/null
-!!!options!!! stop
-Test code
+++ /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 main.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of main
- */
-#include <dpl/test/test_runner.h>
-
-int main(int argc, char *argv[])
-{
- return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-}
-
+++ /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 test_address.cpp
- * @author Tomasz Swierczek (t.swierczek@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test address
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/address.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(Address_InitialEmpty)
-{
- DPL::Address address;
- RUNNER_ASSERT(address.ToString() == ":0");
-}
-
-RUNNER_TEST(Address_InitialAddress)
-{
- DPL::Address address("www.sample.com");
- RUNNER_ASSERT(address.ToString() == "www.sample.com:0");
-}
-
-RUNNER_TEST(Address_InitialAddressPort)
-{
- DPL::Address address("www.somewhere.com", 8080);
- RUNNER_ASSERT(address.ToString() == "www.somewhere.com:8080");
-}
-
-RUNNER_TEST(Address_Getters)
-{
- DPL::Address address("www.somewhere.com", 8080);
- RUNNER_ASSERT(address.GetAddress() == "www.somewhere.com");
- RUNNER_ASSERT(address.GetPort() == 8080);
-}
+++ /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 test_binary_queue.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test binary queue
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/binary_queue.h>
-RUNNER_TEST_GROUP_INIT(DPL)
-
-inline std::string BinaryQueueToString(const DPL::BinaryQueue &queue)
-{
- char *buffer = new char[queue.Size()];
- queue.Flatten(buffer, queue.Size());
- std::string result = std::string(buffer, buffer + queue.Size());
- delete [] buffer;
- return result;
-}
-
-RUNNER_TEST(BinaryQueue_InitialEmpty)
-{
- DPL::BinaryQueue queue;
- RUNNER_ASSERT(queue.Empty() == true);
-}
-
-RUNNER_TEST(BinaryQueue_InitialSize)
-{
- DPL::BinaryQueue queue;
- RUNNER_ASSERT(queue.Size() == 0);
-}
-
-RUNNER_TEST(BinaryQueue_InitialCopy)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy = queue;
-
- RUNNER_ASSERT(copy.Size() == 0);
-}
-
-RUNNER_TEST(BinaryQueue_InitialConsumeZero)
-{
- DPL::BinaryQueue queue;
- queue.Consume(0);
-}
-
-RUNNER_TEST(BinaryQueue_InitialFlattenConsumeZero)
-{
- DPL::BinaryQueue queue;
- queue.FlattenConsume(NULL, 0);
-}
-
-RUNNER_TEST(BinaryQueue_InitialFlattenZero)
-{
- DPL::BinaryQueue queue;
- queue.Flatten(NULL, 0);
-}
-
-RUNNER_TEST(BinaryQueue_InitialConsumeOne)
-{
- DPL::BinaryQueue queue;
-
- Try
- {
- queue.Consume(1);
- }
- Catch (DPL::BinaryQueue::Exception::OutOfData)
- {
- return;
- }
-
- RUNNER_FAIL;
-}
-
-RUNNER_TEST(BinaryQueue_InitialFlattenConsumeOne)
-{
- DPL::BinaryQueue queue;
-
- Try
- {
- char data;
- queue.FlattenConsume(&data, 1);
- }
- Catch (DPL::BinaryQueue::Exception::OutOfData)
- {
- return;
- }
-
- RUNNER_FAIL;
-}
-
-RUNNER_TEST(BinaryQueue_InitialFlattenOne)
-{
- DPL::BinaryQueue queue;
-
- Try
- {
- char data;
- queue.Flatten(&data, 1);
- }
- Catch (DPL::BinaryQueue::Exception::OutOfData)
- {
- return;
- }
-
- RUNNER_FAIL;
-}
-
-RUNNER_TEST(BinaryQueue_ZeroCopyFrom)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy;
-
- copy.AppendCopyFrom(queue);
- RUNNER_ASSERT(queue.Empty());
-}
-
-RUNNER_TEST(BinaryQueue_ZeroMoveFrom)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy;
-
- copy.AppendMoveFrom(queue);
- RUNNER_ASSERT(queue.Empty());
-}
-
-RUNNER_TEST(BinaryQueue_ZeroCopyTo)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy;
-
- queue.AppendCopyTo(copy);
- RUNNER_ASSERT(queue.Empty());
-}
-
-RUNNER_TEST(BinaryQueue_InsertSingleCharacters)
-{
- DPL::BinaryQueue queue;
-
- queue.AppendCopy("a", 1);
- queue.AppendCopy("b", 1);
- queue.AppendCopy("c", 1);
- queue.AppendCopy("d", 1);
-
- RUNNER_ASSERT(queue.Size() == 4);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "abcd");
-}
-
-RUNNER_TEST(BinaryQueue_Consume)
-{
- DPL::BinaryQueue queue;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
-
- RUNNER_ASSERT(queue.Size() == 6);
-
- queue.Consume(1);
- RUNNER_ASSERT(queue.Size() == 5);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "bcdef");
-
- queue.Consume(2);
- RUNNER_ASSERT(queue.Size() == 3);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "def");
-
- queue.Consume(1);
- RUNNER_ASSERT(queue.Size() == 2);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "ef");
-
- queue.Consume(2);
- RUNNER_ASSERT(queue.Size() == 0);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "");
-}
-
-RUNNER_TEST(BinaryQueue_Flatten)
-{
- DPL::BinaryQueue queue;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
- queue.AppendCopy("g", 1);
-
- RUNNER_ASSERT(queue.Size() == 7);
-
- RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdefg");
-}
-
-RUNNER_TEST(BinaryQueue_FlattenConsume)
-{
- DPL::BinaryQueue queue;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
-
- RUNNER_ASSERT(queue.Size() == 6);
-
- char buffer[7] = { '\0' };
- queue.FlattenConsume(buffer, 3);
-
- RUNNER_ASSERT(queue.Size() == 3);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "def");
-}
-
-RUNNER_TEST(BinaryQueue_AppendCopyFrom)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
-
- copy.AppendCopyFrom(queue);
-
- RUNNER_ASSERT(queue.Size() == 6);
- RUNNER_ASSERT(copy.Size() == 6);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdef");
- RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
-}
-
-RUNNER_TEST(BinaryQueue_AppendCopyTo)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
-
- queue.AppendCopyTo(copy);
-
- RUNNER_ASSERT(queue.Size() == 6);
- RUNNER_ASSERT(copy.Size() == 6);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "abcdef");
- RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
-}
-
-RUNNER_TEST(BinaryQueue_AppendMoveFrom)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
-
- copy.AppendMoveFrom(queue);
-
- RUNNER_ASSERT(queue.Size() == 0);
- RUNNER_ASSERT(copy.Size() == 6);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "");
- RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
-}
-
-RUNNER_TEST(BinaryQueue_AppendMoveTo)
-{
- DPL::BinaryQueue queue;
- DPL::BinaryQueue copy;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
-
- queue.AppendMoveTo(copy);
-
- RUNNER_ASSERT(queue.Size() == 0);
- RUNNER_ASSERT(copy.Size() == 6);
- RUNNER_ASSERT(BinaryQueueToString(queue) == "");
- RUNNER_ASSERT(BinaryQueueToString(copy) == "abcdef");
-}
-
-class Visitor
- : public DPL::BinaryQueue::BucketVisitor
-{
-private:
- int m_index;
-
-public:
- Visitor()
- : m_index(0)
- {
- }
-
- virtual void OnVisitBucket(const void *buffer, size_t bufferSize)
- {
- const char *str = static_cast<const char *>(buffer);
-
- if (m_index == 0)
- {
- RUNNER_ASSERT(bufferSize == 4);
- RUNNER_ASSERT(str[0] == 'a');
- RUNNER_ASSERT(str[1] == 'b');
- RUNNER_ASSERT(str[2] == 'c');
- RUNNER_ASSERT(str[3] == 'd');
- }
- else if (m_index == 1)
- {
- RUNNER_ASSERT(bufferSize == 2);
- RUNNER_ASSERT(str[0] == 'e');
- RUNNER_ASSERT(str[1] == 'f');
- }
- else
- {
- RUNNER_FAIL;
- }
-
- ++m_index;
- }
-};
-
-RUNNER_TEST(BinaryQueue_Visitor)
-{
- DPL::BinaryQueue queue;
-
- queue.AppendCopy("abcd", 4);
- queue.AppendCopy("ef", 2);
-
- Visitor visitor;
- queue.VisitBuckets(&visitor);
-}
-
-RUNNER_TEST(BinaryQueue_AbstracInputRead)
-{
- DPL::BinaryQueue queue;
-
- queue.AppendCopy("abcd", 4);
-
- queue.Read(0);
-
- RUNNER_ASSERT(BinaryQueueToString(*queue.Read(1).get()) == "a");
- RUNNER_ASSERT(BinaryQueueToString(*queue.Read(2).get()) == "bc");
- RUNNER_ASSERT(BinaryQueueToString(*queue.Read(1).get()) == "d");
-
- RUNNER_ASSERT(queue.Size() == 0);
-}
-
-RUNNER_TEST(BinaryQueue_AbstracOutputWrite)
-{
- DPL::BinaryQueue queue;
- queue.AppendCopy("abcd", 4);
-
- DPL::BinaryQueue stream;
-
- stream.Write(queue, 4);
-
- RUNNER_ASSERT(BinaryQueueToString(*queue.Read(4).get()) == "abcd");
-}
+++ /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 test_fast_delegate.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of fast delegate tests.
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/fast_delegate.h>
-#include <dpl/log/log.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-// Sample copied and adopted from
-// http://www.codeproject.com/KB/cpp/FastDelegate.aspx
-//
-// Demonstrate the syntax for FastDelegates.
-// -Don Clugston, May 2004.
-// It's a really boring example, but it shows the most important cases.
-// Declare some functions of varying complexity...
-void SimpleStaticFunction(int num, const char *str);
-void SimpleStaticFunction(int num, const char *str)
-{
- LogDebug("In SimpleStaticFunction. Num=" << num << ", str =" << str);
-}
-
-void SimpleVoidFunction();
-void SimpleVoidFunction()
-{
- LogDebug("In SimpleVoidFunction with no parameters.");
-}
-
-class CBaseClass
-{
-protected:
- const char *m_name;
-
-public:
- CBaseClass(const char *name)
- : m_name(name)
- {
- }
-
- virtual ~CBaseClass()
- {
- }
-
- void SimpleMemberFunction(int num, const char *str)
- {
- LogDebug("In SimpleMemberFunction in " << m_name << ". Num="
- << num << ", str = " << str);
- }
-
- int SimpleMemberFunctionReturnsInt(int num, const char *str)
- {
- LogDebug("In SimpleMemberFunctionReturnsInt in " << m_name << ". Num="
- << num << ", str = " << str);
- return -1;
- }
-
- void ConstMemberFunction(int num, const char *str) const
- {
- LogDebug("In ConstMemberFunction in " << m_name << ". Num="
- << num << ", str = " << str);
- }
-
- virtual void SimpleVirtualFunction(int num, const char *str)
- {
- LogDebug("In SimpleVirtualFunction in " << m_name << ". Num="
- << num << ", str = " << str);
- }
-
- static void StaticMemberFunction(int num, const char *str)
- {
- LogDebug("In StaticMemberFunction Num="
- << num << ", str = " << str);
- }
-};
-
-class COtherClass
-{
- double rubbish; // to ensure this class has non-zero size.
-
-public:
- virtual ~COtherClass()
- {
- }
-
- virtual void UnusedVirtualFunction(void)
- {
- }
- virtual void TrickyVirtualFunction(int num, const char *str) = 0;
-};
-
-class VeryBigClass
-{
- int letsMakeThingsComplicated[400];
-};
-
-// This declaration ensures that we get a convoluted class heirarchy.
-class CDerivedClass
- : public VeryBigClass,
- virtual public COtherClass,
- virtual public CBaseClass
-{
- double m_somemember[8];
-
-public:
- CDerivedClass()
- : CBaseClass("Base of Derived")
- {
- m_somemember[0] = 1.2345;
- }
-
- void SimpleDerivedFunction(int num, const char *str)
- {
- LogDebug("In SimpleDerivedFunction Num="
- << num << ", str = " << str);
- }
-
- virtual void AnotherUnusedVirtualFunction(int num, const char *str)
- {
- LogDebug("In AnotherUnusedVirtualFunction in " << m_name << ". Num="
- << num << ", str = " << str);
- }
-
- virtual void TrickyVirtualFunction(int num, const char *str)
- {
- LogDebug("In TrickyVirtualFunction in " << m_name << ". Num="
- << num << ", str = " << str);
- }
-};
-
-RUNNER_TEST(FastDelegate_Test)
-{
- // Delegates with up to 8 parameters are supported.
- // Here's the case for a void function.
- // We declare a delegate and attach it to SimpleVoidFunction()
- DPL::FastDelegate0<> noparameterdelegate(&SimpleVoidFunction);
-
- // invoke the delegate - this calls SimpleVoidFunction()
- noparameterdelegate();
-
- LogDebug("-- Examples using two-parameter delegates (int, char *) --");
-
- // By default, the return value is void.
- typedef DPL::FastDelegate2<int, const char *> MyDelegate;
-
- // If you want to have a non-void return value, put it at the end.
- typedef DPL::FastDelegate2<int, const char *, int> IntMyDelegate;
-
-
- MyDelegate funclist[12]; // delegates are initialized to empty
- CBaseClass a("Base A");
- CBaseClass b("Base B");
- CDerivedClass d;
- CDerivedClass c;
-
- IntMyDelegate newdeleg;
- newdeleg = DPL::MakeDelegate(&a,
- &CBaseClass::SimpleMemberFunctionReturnsInt);
-
- // Binding a simple member function
- funclist[0].bind(&a, &CBaseClass::SimpleMemberFunction);
-
- // You can also bind static (free) functions
- funclist[1].bind(&SimpleStaticFunction);
-
- // and static member functions
- funclist[2].bind(&CBaseClass::StaticMemberFunction);
-
- // and const member functions (these only need a const class pointer).
- funclist[3].bind((const CBaseClass *) &a,
- &CBaseClass::ConstMemberFunction);
-
- funclist[4].bind(&a, &CBaseClass::ConstMemberFunction);
-
- // and virtual member functions
- funclist[5].bind(&b, &CBaseClass::SimpleVirtualFunction);
-
- // You can also use the = operator. For static functions, a fastdelegate
- // looks identical to a simple function pointer.
- funclist[6] = &CBaseClass::StaticMemberFunction;
-
- // The weird rule about the class of derived member function pointers
- // is avoided. For MSVC, you can use &CDerivedClass::SimpleVirtualFunction
- // here, but DMC will complain. Note that as well as .bind(), you can also
- // use the MakeDelegate() global function.
- funclist[7] = DPL::MakeDelegate(&d, &CBaseClass::SimpleVirtualFunction);
-
- // The worst case is an abstract virtual function of a virtually-derived
- // class with at least one non-virtual base class. This is a VERY obscure
- // situation, which you're unlikely to encounter in the real world.
- // FastDelegate versions prior to 1.3 had problems with this case on VC6.
- // Now, it works without problems on all compilers.
- funclist[8].bind(&c, &CDerivedClass::TrickyVirtualFunction);
-
- // BUT... in such cases you should be using the base class as an
- // interface, anyway.
- funclist[9].bind(&c, &COtherClass::TrickyVirtualFunction);
-
- // Calling a function that was first declared in the derived class is
- // straightforward
- funclist[10] = DPL::MakeDelegate(&c, &CDerivedClass::SimpleDerivedFunction);
-
- // You can also bind directly using the constructor
- MyDelegate dg(&b, &CBaseClass::SimpleVirtualFunction);
-
- const char *msg = "Looking for equal delegate";
-
- for (int i = 0; i < 12; i++)
- {
- LogDebug(i << ":");
-
- // The == and != operators are provided
- // Note that they work even for inline functions.
- if (funclist[i] == dg)
- {
- msg = "Found equal delegate";
- }
-
- // operator ! can be used to test for an empty delegate
- // You can also use the .empty() member function.
- if (!funclist[i])
- {
- LogDebug("Delegate is empty");
- }
- else
- {
- // Invocation generates optimal assembly code.
- funclist[i](i, msg);
- }
- }
-}
+++ /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 test_foreach.cpp
- * @author Bartosz Janiak (b.janiak@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of foreach tests.
- */
-
-#include <dpl/test/test_runner.h>
-#include <dpl/foreach.h>
-#include <vector>
-#include <set>
-#include <list>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-static const size_t testContainerSize = 1024;
-
-template<typename Container>
-void VerifyForeach(Container& container)
-{
- size_t i = 0;
- FOREACH(it, container)
- {
- RUNNER_ASSERT(*it == i);
- i++;
- }
- RUNNER_ASSERT(i == container.size());
-}
-
-#define VERIFY_FOREACH(container) \
- { \
- size_t i = 0; \
- FOREACH(it, container) \
- { \
- RUNNER_ASSERT(*it == i); \
- i++; \
- } \
- }
-
-static size_t numberOfCallsToTemporaryList = 0;
-std::list<size_t> temporaryList();
-std::list<size_t> temporaryList()
-{
- ++numberOfCallsToTemporaryList;
- std::list<size_t> list;
- for (size_t i = 0 ; i < testContainerSize ; i++)
- {
- list.push_back(i);
- }
- return list;
-}
-
-static size_t numberOfCallsToTemporaryVector = 0;
-std::vector<size_t> temporaryVector();
-std::vector<size_t> temporaryVector()
-{
- ++numberOfCallsToTemporaryVector;
- std::vector<size_t> vector;
- for (size_t i = 0 ; i < testContainerSize ; i++)
- {
- vector.push_back(i);
- }
- return vector;
-}
-
-static size_t numberOfCallsToTemporarySet = 0;
-std::set<size_t> temporarySet();
-std::set<size_t> temporarySet()
-{
- ++numberOfCallsToTemporarySet;
- std::set<size_t> set;
- for (size_t i = 0 ; i < testContainerSize ; i++)
- {
- set.insert(i);
- }
- return set;
-}
-
-RUNNER_TEST(Foreach_std_containers)
-{
- std::vector<size_t> vector;
- std::list<size_t> list;
- std::set<size_t> set;
-
- for (size_t i = 0 ; i < testContainerSize ; i++)
- {
- vector.push_back(i);
- list.push_back(i);
- set.insert(i);
- }
-
- VerifyForeach(vector);
- VerifyForeach(list);
- VerifyForeach(set);
-
- VERIFY_FOREACH(temporaryList());
- VERIFY_FOREACH(temporaryVector());
- VERIFY_FOREACH(temporarySet());
-
- RUNNER_ASSERT(numberOfCallsToTemporaryList == 1);
- RUNNER_ASSERT(numberOfCallsToTemporaryVector == 1);
- RUNNER_ASSERT(numberOfCallsToTemporarySet == 1);
-}
+++ /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 test_log_unhandled_exception.cpp
- * @author Pawel Sikorski (p.marcinkiew@samsung.com)
- * @version 1.0
- * @brief
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/exception.h>
-#include <iostream>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-class MyException
-{
-};
-
-class MyDPLException
-{
-public:
- DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
- DECLARE_EXCEPTION_TYPE(Base, MyException)
-};
-
-class MySTDException
- : public std::exception
-{
-public:
- virtual const char* what()const throw() { return "my std exception occurred";}
-};
-
-RUNNER_TEST(Log_Unknown_Exception)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
-// throw MyException();
- }
- UNHANDLED_EXCEPTION_HANDLER_END
- RUNNER_ASSERT(true);
-}
-
-RUNNER_TEST(Log_DPL_Exception)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
-// Throw(MyDPLException::MyException);
- }
- UNHANDLED_EXCEPTION_HANDLER_END
- RUNNER_ASSERT(true);
-}
-
-RUNNER_TEST(Log_STD_Exception)
-{
- UNHANDLED_EXCEPTION_HANDLER_BEGIN
- {
-// throw MySTDException();
- }
- UNHANDLED_EXCEPTION_HANDLER_END
- RUNNER_ASSERT(true);
-}
+++ /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 test_once.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of once tests
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/once.h>
-#include <dpl/waitable_event.h>
-#include <dpl/waitable_handle.h>
-#include <dpl/thread.h>
-#include <dpl/shared_ptr.h>
-#include <dpl/atomic.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-namespace // anonymous
-{
-gint g_counter;
-
-void Delegate()
-{
- ++g_counter;
-}
-} // namespace anonymous
-
-RUNNER_TEST(Once_DoubleCall)
-{
- g_counter = 0;
-
- DPL::Once once;
-
- once.Call(&Delegate);
- once.Call(&Delegate);
-
- RUNNER_ASSERT_MSG(g_counter == 1, "Counter value is: " << g_counter);
-}
-
-class MyThread
- : public DPL::Thread
-{
-protected:
- virtual int ThreadEntry()
- {
- DPL::WaitForSingleHandle(m_event->GetHandle());
- m_once->Call(DPL::Once::Delegate(this, &MyThread::Call));
- return 0;
- }
-
- void Call()
- {
- ++*m_atom;
- }
-
-public:
- MyThread(DPL::WaitableEvent *event, DPL::Once *once, DPL::Atomic *atom)
- : m_event(event), m_once(once), m_atom(atom)
- {
- }
-
-private:
- DPL::WaitableEvent *m_event;
- DPL::Once *m_once;
- DPL::Atomic *m_atom;
-};
-
-RUNNER_TEST(Once_MultiThreadCall)
-{
- const size_t NUM_THREADS = 20;
- typedef DPL::SharedPtr<MyThread> ThreadPtr;
-
- ThreadPtr threads[NUM_THREADS];
- DPL::WaitableEvent event;
- DPL::Once once;
- DPL::Atomic atom;
-
- for (size_t i = 0; i< NUM_THREADS; ++i)
- {
- (threads[i] = ThreadPtr(new MyThread(&event, &once, &atom)))->Run();
- }
-
- event.Signal();
-
- for (size_t i = 0; i< NUM_THREADS; ++i)
- threads[i]->Quit();
-
- RUNNER_ASSERT_MSG(atom == 1, "Atom value is: " << atom);
-}
+++ /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 test_scoped_array.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test scoped array
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/scoped_array.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(ScopedArray_Zero)
-{
- DPL::ScopedArray<char> array;
-
- RUNNER_ASSERT(!array);
- RUNNER_ASSERT(!!!array);
-}
-
-RUNNER_TEST(ScopedArray_NonZero)
-{
- DPL::ScopedArray<char> array(new char[7]);
-
- RUNNER_ASSERT(array);
- RUNNER_ASSERT(!!array);
-}
-
-RUNNER_TEST(ScopedArray_Reset)
-{
- DPL::ScopedArray<char> array(new char[7]);
- array.Reset();
-
- RUNNER_ASSERT(!array);
-
- array.Reset(new char);
- RUNNER_ASSERT(array);
-}
-
-RUNNER_TEST(ScopedArray_ArrayOperator)
-{
- DPL::ScopedArray<char> array(new char[7]);
-
- array[1] = array[2] = 3;
-
- RUNNER_ASSERT(array[1] == 3);
- RUNNER_ASSERT(array[2] == 3);
-}
+++ /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 test_scoped_close.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test scoped close
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/scoped_close.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-// DUNNO
+++ /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 test_scoped_fclose.cpp
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test scoped fclose
- */
-
-#include <cstdio>
-#include <cerrno>
-
-#include <dpl/test/test_runner.h>
-#include <dpl/scoped_fclose.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-namespace
-{
-FILE* MakeTmp()
-{
- FILE* result = NULL;
- do
- {
- result = tmpfile();
- } while (NULL != result && EINTR == errno);
- return result;
-}
-}//anonymous namespace
-
-RUNNER_TEST(ScopedFClose_Zero)
-{
- DPL::ScopedFClose file;
-
- RUNNER_ASSERT(!file);
- RUNNER_ASSERT(!!!file);
-}
-
-RUNNER_TEST(ScopedFClose_NonZero)
-{
- DPL::ScopedFClose file(MakeTmp());
-
- RUNNER_ASSERT(file);
- RUNNER_ASSERT(!!file);
-}
-
-RUNNER_TEST(ScopedFClose_Reset)
-{
- DPL::ScopedFClose file(MakeTmp());
- file.Reset();
-
- RUNNER_ASSERT(!file);
-
- file.Reset(MakeTmp());
- RUNNER_ASSERT(file);
-}
-
+++ /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 test_scoped_free.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test scoped free
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/scoped_free.h>
-#include <malloc.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(ScopedFree_Zero)
-{
- DPL::ScopedFree<void> free;
-
- RUNNER_ASSERT(!free);
- RUNNER_ASSERT(!!!free);
-}
-
-RUNNER_TEST(ScopedFree_NonZero)
-{
- DPL::ScopedFree<void> free(malloc(7));
-
- RUNNER_ASSERT(free);
- RUNNER_ASSERT(!!free);
-}
-
-RUNNER_TEST(ScopedFree_Reset)
-{
- DPL::ScopedFree<void> free(malloc(7));
- free.Reset();
-
- RUNNER_ASSERT(!free);
-
- free.Reset(malloc(8));
- RUNNER_ASSERT(free);
-}
+++ /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 test_scoped_ptr.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test scoped ptr
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/scoped_ptr.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(ScopedPtr_Zero)
-{
- DPL::ScopedPtr<char> ptr;
-
- RUNNER_ASSERT(!ptr);
- RUNNER_ASSERT(!!!ptr);
-}
-
-RUNNER_TEST(ScopedPtr_NonZero)
-{
- DPL::ScopedPtr<char> ptr(new char(7));
-
- RUNNER_ASSERT(ptr);
- RUNNER_ASSERT(!!ptr);
-}
-
-RUNNER_TEST(ScopedPtr_Reset)
-{
- DPL::ScopedPtr<char> ptr(new char(7));
- ptr.Reset();
-
- RUNNER_ASSERT(!ptr);
-
- ptr.Reset(new char);
- RUNNER_ASSERT(ptr);
-}
-
-RUNNER_TEST(ScopedPtr_Operators)
-{
- DPL::ScopedPtr<char> ptr(new char(7));
-
- RUNNER_ASSERT(*ptr == *ptr.Get());
-}
+++ /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 test_semaphore.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of semaphore tests
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/lexical_cast.h>
-#include <dpl/semaphore.h>
-#include <dpl/thread.h>
-#include <dpl/log/log.h>
-#include <string>
-#include <ctime>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-class SemaphoreThread
- : public DPL::Thread
-{
- int m_delta;
- int m_times;
- int *m_value;
- std::string m_semaphoreName;
-
-public:
- SemaphoreThread(int delta,
- int times,
- int *value,
- const std::string &semaphoreName)
- : m_delta(delta),
- m_times(times),
- m_value(value),
- m_semaphoreName(semaphoreName)
- {
- }
-
-protected:
- virtual int ThreadEntry()
- {
- DPL::Semaphore semaphore(m_semaphoreName);
-
- for (int i = 0; i < m_times; ++i)
- {
- // Take scoped semaphore lock
- DPL::Semaphore::ScopedLock lock(&semaphore);
- *m_value += m_delta;
- }
-
- return 0;
- }
-};
-
-RUNNER_TEST(Semaphore_NamedIncrementDecrement)
-{
- std::string semaphoreName =
- "dpl_test_semaphore_" +
- DPL::lexical_cast<std::string>(std::time(NULL));
-
- int value = 0;
- SemaphoreThread threadA(-1, 10000, &value, semaphoreName);
- SemaphoreThread threadB(+1, 10000, &value, semaphoreName);
-
- threadA.Run();
- threadB.Run();
-
- threadA.Quit();
- threadB.Quit();
-
- RUNNER_ASSERT_MSG(value == 0, "Final value is: " << value);
-}
+++ /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 test_address.cpp
- * @author Tomasz Swierczek (t.swierczek@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of serialization tests
- */
-
-#include <vector>
-#include <string>
-#include <list>
-#include <map>
-
-#include <dpl/test/test_runner.h>
-#include <dpl/serialization.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-// test stream class
-class BinaryStream : public DPL::IStream {
- public:
- virtual void Read(size_t num, void * bytes)
- {
- for (unsigned i = 0; i < num; ++i) {
- ((unsigned char*)bytes)[i] = data[i + readPosition];
- }
- readPosition += num;
- }
- virtual void Write(size_t num, const void * bytes)
- {
- for (unsigned i = 0; i < num; ++i) {
- data.push_back(((unsigned char*)bytes)[i]);
- }
- }
- BinaryStream()
- {
- readPosition = 0;
- }
- virtual ~BinaryStream(){};
-
- private:
- std::vector<unsigned char> data;
- unsigned readPosition;
-};
-
-//test ISerializable class
-class TestClass : public DPL::ISerializable {
- public:
- TestClass(int val, std::string str1, std::string str2)
- {
- a = val;
- b = str1;
- c.push_back(str1);
- c.push_back(str2);
- c.push_back(str1 + str2);
- };
- TestClass(DPL::IStream& stream)
- {
- DPL::Deserialization::Deserialize(stream,a);
- DPL::Deserialization::Deserialize(stream,b);
- DPL::Deserialization::Deserialize(stream,c);
- };
- virtual void Serialize(DPL::IStream& stream) const
- {
- DPL::Serialization::Serialize(stream,a);
- DPL::Serialization::Serialize(stream,b);
- DPL::Serialization::Serialize(stream,c);
- }
- virtual ~TestClass(){}
- virtual bool operator==(const TestClass& other)
- {
- return (a == other.a &&
- b == other.b &&
- c.size() == other.c.size() &&
- c[0] == other.c[0] &&
- c[1] == other.c[1] &&
- c[2] == other.c[2]);
- }
- private:
- int a;
- std::string b;
- std::vector<std::string> c;
-};
-
-RUNNER_TEST(Serialize_primitives)
-{
- int a = 1;
- bool b = true;
- unsigned c = 23;
- BinaryStream stream;
- DPL::Serialization::Serialize(stream,a);
- DPL::Serialization::Serialize(stream,b);
- DPL::Serialization::Serialize(stream,c);
- int test_int;
- DPL::Deserialization::Deserialize(stream,test_int);
- RUNNER_ASSERT(test_int == a);
- bool test_bool;
- DPL::Deserialization::Deserialize(stream,test_bool);
- RUNNER_ASSERT(test_bool == b);
- unsigned test_unsigned;
- DPL::Deserialization::Deserialize(stream,test_unsigned);
- RUNNER_ASSERT(test_unsigned == c);
-}
-
-RUNNER_TEST(Serialize_primitive_pointers)
-{
- int a = 1;
- bool b = true;
- unsigned c = 23;
- BinaryStream stream;
- DPL::Serialization::Serialize(stream,&a);
- DPL::Serialization::Serialize(stream,&b);
- DPL::Serialization::Serialize(stream,&c);
- int* test_int;
- DPL::Deserialization::Deserialize(stream,test_int);
- RUNNER_ASSERT(test_int != NULL && *test_int == a);
- bool* test_bool;
- DPL::Deserialization::Deserialize(stream,test_bool);
- RUNNER_ASSERT(test_bool != NULL && *test_bool == b);
- unsigned* test_unsigned;
- DPL::Deserialization::Deserialize(stream,test_unsigned);
- RUNNER_ASSERT(test_unsigned != NULL && *test_unsigned == c);
- delete test_int;
- delete test_bool;
- delete test_unsigned;
-}
-
-RUNNER_TEST(Serialize_strings)
-{
- std::string str1 = "ALA MA KOTA";
- std::string str2 = "MULTILINE\nTEST";
- BinaryStream stream;
- DPL::Serialization::Serialize(stream,str1);
- DPL::Serialization::Serialize(stream,str2);
- std::string test_str1;
- DPL::Deserialization::Deserialize(stream,test_str1);
- RUNNER_ASSERT(test_str1 == str1);
- std::string test_str2;
- DPL::Deserialization::Deserialize(stream,test_str2);
- RUNNER_ASSERT(test_str2 == str2);
-}
-
-RUNNER_TEST(Serialize_string_pointers)
-{
- std::string str1 = "ALA MA KOTA";
- std::string str2 = "MULTILINE\nTEST";
- BinaryStream stream;
- DPL::Serialization::Serialize(stream,&str1);
- DPL::Serialization::Serialize(stream,&str2);
- std::string* test_str1;
- DPL::Deserialization::Deserialize(stream,test_str1);
- RUNNER_ASSERT(test_str1 != NULL && *test_str1 == str1);
- std::string* test_str2;
- DPL::Deserialization::Deserialize(stream,test_str2);
- RUNNER_ASSERT(test_str2 != NULL && *test_str2 == str2);
- delete test_str1;
- delete test_str2;
-}
-
-RUNNER_TEST(Serialize_containers)
-{
- std::vector<int> vec;
- vec.push_back(134);
- vec.push_back(265);
- std::list<bool> list;
- list.push_back(true);
- list.push_back(false);
- std::pair<int,unsigned> pair;
- pair.first = -23;
- pair.second = 1234;
- std::map<int,std::string> map;
- map.insert(std::pair<int,std::string>(45, "ALA MA CZARNEGO KOTA"));
- map.insert(std::pair<int,std::string>(-78, "...A MOZE\nMA\nWIELE LINIJEK"));
- BinaryStream stream;
- DPL::Serialization::Serialize(stream,vec);
- DPL::Serialization::Serialize(stream,list);
- DPL::Serialization::Serialize(stream,pair);
- DPL::Serialization::Serialize(stream,map);
- std::vector<int> test_vec;
- DPL::Deserialization::Deserialize(stream,test_vec);
- RUNNER_ASSERT(test_vec.size() == vec.size() &&
- test_vec[0] == vec[0] && test_vec[1] == vec[1]);
- std::list<bool> test_list;
- DPL::Deserialization::Deserialize(stream,test_list);
- RUNNER_ASSERT(test_list.size() == list.size() &&
- test_list.front() == list.front() &&
- test_list.back() == test_list.back());
- std::pair<int,unsigned> test_pair;
- DPL::Deserialization::Deserialize(stream,test_pair);
- RUNNER_ASSERT(test_pair.first == pair.first &&
- test_pair.second == pair.second);
- std::map<int,std::string> test_map;
- DPL::Deserialization::Deserialize(stream,test_map);
- RUNNER_ASSERT(test_map.size() == map.size() &&
- test_map.at(45) == map.at(45) &&
- test_map.at(-78) == map.at(-78));
-}
-
-RUNNER_TEST(Serialize_objects)
-{
- TestClass a(123,"ASDGHUADB\n\n5679b^^()*","TEST_STRING"),
- b(679,"HUSPIDNSAHDPA","\nASDSADASD\naDSADASD8");
- BinaryStream stream;
- DPL::Serialization::Serialize(stream,a);
- DPL::Serialization::Serialize(stream,b);
- TestClass test_a(0,"",""), test_b(0,"","");
- DPL::Deserialization::Deserialize(stream, test_a);
- RUNNER_ASSERT(test_a == a);
- DPL::Deserialization::Deserialize(stream, test_b);
- RUNNER_ASSERT(test_b == b);
-}
-
-RUNNER_TEST(Serialize_all)
-{
- std::map<std::string, std::vector<TestClass*> > map;
- std::vector<TestClass*> vec;
- vec.push_back(new TestClass(123,"ASDGHUADB\n\n5679b^^()*","TEST_STRING"));
- vec.push_back(new TestClass(679,"HUSPIDNSAHDPA","\nASDSADASD\naDSADASD8"));
- map.insert(std::pair<std::string,std::vector<TestClass*> >("KEY1",vec));
- map.insert(std::pair<std::string,std::vector<TestClass*> >("KEY2",vec));
- BinaryStream stream;
-
- DPL::Serialization::Serialize(stream, map);
-
- std::map<std::string, std::vector<TestClass*> > test_map;
- DPL::Deserialization::Deserialize(stream,test_map);
- RUNNER_ASSERT(map.size() == test_map.size());
- std::vector<TestClass*> test_vec1,test_vec2;
- test_vec1 = map.at("KEY1");
- test_vec2 = test_map.at("KEY1");
- RUNNER_ASSERT(test_vec1.size() == test_vec2.size());
- unsigned i;
- for (i = 0; i < test_vec1.size(); ++i)
- {
- RUNNER_ASSERT((*test_vec1[i]) == (*test_vec2[i]));
- }
- test_vec1 = map.at("KEY2");
- test_vec2 = test_map.at("KEY2");
- RUNNER_ASSERT(test_vec1.size() == test_vec2.size());
- for (i = 0; i < test_vec1.size(); ++i)
- {
- RUNNER_ASSERT((*test_vec1[i]) == (*test_vec2[i]));
- }
-}
-
+++ /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 test_shared_ptr.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test shared ptr
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/shared_ptr.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(SharedPtr_Zero)
-{
- DPL::SharedPtr<char> ptr;
-
- RUNNER_ASSERT(!ptr);
- RUNNER_ASSERT(!!!ptr);
- RUNNER_ASSERT(ptr == DPL::SharedPtr<char>());
-}
-
-RUNNER_TEST(SharedPtr_NonZero)
-{
- DPL::SharedPtr<char> ptr(new char(7));
-
- RUNNER_ASSERT(ptr);
- RUNNER_ASSERT(!!ptr);
- RUNNER_ASSERT(ptr != DPL::SharedPtr<char>());
-}
-
-RUNNER_TEST(SharedPtr_Copy)
-{
- DPL::SharedPtr<char> ptr1(new char(7));
- DPL::SharedPtr<char> ptr2(new char(7));
-
- RUNNER_ASSERT(ptr1 != ptr2);
-
- ptr2 = ptr1;
-
- RUNNER_ASSERT(ptr1 == ptr2);
-}
-
-RUNNER_TEST(SharedPtr_Reset)
-{
- DPL::SharedPtr<char> ptr(new char(7));
- ptr.Reset();
-
- RUNNER_ASSERT(!ptr);
-
- ptr.Reset(new char);
- RUNNER_ASSERT(ptr);
-}
-
-RUNNER_TEST(SharedPtr_RefCounting)
-{
- DPL::SharedPtr<char> ptr1(new char(7));
- DPL::SharedPtr<char> ptr2;
-
- ptr2 = ptr1;
-
- RUNNER_ASSERT(ptr1 == ptr2);
- RUNNER_ASSERT(ptr1.GetUseCount() == ptr2.GetUseCount());
- RUNNER_ASSERT(ptr1.GetUseCount() == 2);
-}
-
-RUNNER_TEST(SharedPtr_Operators)
-{
- DPL::SharedPtr<char> ptr(new char(7));
-
- RUNNER_ASSERT(*ptr == *ptr.Get());
-}
+++ /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 test_string.cpp
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of string tests
- */
-#include <stdlib.h>
-#include <cmath>
-#include <cstring>
-#include <vector>
-#include <dpl/test/test_runner.h>
-#include <dpl/string.h>
-#include <dpl/sstream.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-unsigned char GetBaseCode(int index);
-unsigned char GetBaseCode(int index)
-{
- /* aaaack but it's fast and const should make it shared text page. */
- static const unsigned char pr2six[256] =
- {
- /* ASCII table */
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
- 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64,
- 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
- };
- return pr2six[index];
-}
-
-
-/* Function adapted from APR library (http://apr.apache.org/) */
-int wbxml_base64_decode(const char *buffer, char **result);
-int wbxml_base64_decode(const char *buffer, char **result)
-{
- int nbytesdecoded = 0, nprbytes = 0;
- const char *bufin = NULL;
- char *bufout = NULL;
-
- if ((buffer == NULL) || (result == NULL))
- return 0;
-
- /* Initialize output buffer */
- *result = NULL;
-
- bufin = buffer;
- while (GetBaseCode(*(bufin++)) <= 63) {}
-
- nprbytes = (bufin - buffer) - 1;
- nbytesdecoded = ((nprbytes + 3) / 4) * 3;
-
- /* Malloc result buffer */
- if ((*result = (char*) malloc(nbytesdecoded + 1)) == NULL)
- return 0;
- memset(*result, nbytesdecoded + 1, 0);
-
- bufout = *result;
- bufin = buffer;
-
- while (nprbytes > 4)
- {
- *(bufout++) = (char)(GetBaseCode(*bufin) << 2 | GetBaseCode(bufin[1]) >> 4);
- *(bufout++) = (char)(GetBaseCode(bufin[1]) << 4 | GetBaseCode(bufin[2]) >> 2);
- *(bufout++) = (char)(GetBaseCode(bufin[2]) << 6 | GetBaseCode(bufin[3]));
- bufin += 4;
- nprbytes -= 4;
- }
-
- /* Note: (nprbytes == 1) would be an error, so just ingore that case */
- if (nprbytes > 1)
- {
- *(bufout++) = (char)(GetBaseCode(*bufin) << 2 | GetBaseCode(bufin[1]) >> 4);
- }
- if (nprbytes > 2)
- {
- *(bufout++) = (char)(GetBaseCode(bufin[1]) << 4 | GetBaseCode(bufin[2]) >> 2);
- }
- if (nprbytes > 3)
- {
- *(bufout++) = (char)(GetBaseCode(bufin[2]) << 6 | GetBaseCode(bufin[3]));
- }
-
- nbytesdecoded -= (4 - nprbytes) & 3;
-
- return nbytesdecoded;
-}
-
-//#define TEST_CONVERSION(in_string, out_string, buffer_type, function
-
-const char utf32Encoded[] =
-"RDAAAI0wAABvMAAAazAAAHswAAB4MAAAaDAAAAAwAABhMAAAijAAAGwwAACLMAAAkjAAAAAwAACP\
-MAAASzAAAIgwAABfMAAAjDAAAF0wAAAAMAAAZDAAAG0wAABqMAAAiTAAAIAwAAAAMAAARjAAAJAw\
-AABuMAAASjAAAE8wAACEMAAAfjAAAAAwAABRMAAAdTAAAFMwAABIMAAAZjAAAAAwAABCMAAAVTAA\
-AE0wAACGMAAAgTAAAH8wAABXMAAAADAAAJEwAAByMAAAgjAAAFswAABZMAAACgAAANsFAADaBQAA\
-IAAAANQFAADqBQAA6AUAAOEFAADnBQAAIAAAAOAFAADkBQAA5QUAACAAAADiBQAA3AUAACAAAADS\
-BQAA1QUAANYFAADcBQAAIAAAAOcFAADYBQAA3wUAACwAAAAgAAAA6QUAANMFAADXBQAA4wUAACAA\
-AADQBQAA6gUAACAAAADmBQAA0QUAANkFAAAgAAAA3AUAAN4FAADZBQAA3QUAAAoAAACk0AAApMIA\
-AFjHAAAgAAAA4KwAACDHAABwyAAAdKwAAEDHAAAgAAAAhccAACDCAAB8sAAArLkAACAAAADMuQAA\
-mLAAAHzFAAAgAAAAWNUAAOCsAAAgAAAAudIAAMS8AABc1QAAIAAAADCuAAAgwgAAQMcAACAAAABE\
-1QAAlMYAAFjOAAAgAAAASsUAAOSyAAAKAAAAUAAAAGMAAABoAAAAbgAAAAUBAAAHAQAAIAAAAHcA\
-AAAgAAAAdAAAABkBAAAgAAAAQgEAAPMAAABkAAAAegEAACAAAABqAAAAZQAAAHwBAABhAAAAIAAA\
-AGwAAAB1AAAAYgAAACAAAABvAAAAWwEAAG0AAAAgAAAAcwAAAGsAAAByAAAAegAAAHkAAABEAQAA\
-IAAAAGYAAABpAAAAZwAAAC4AAAAKAAAAQgAAAGwAAABvAAAAdwAAAHoAAAB5AAAAIAAAAG4AAABp\
-AAAAZwAAAGgAAAB0AAAALQAAAGYAAAByAAAAdQAAAG0AAABwAAAAcwAAACAAAAB2AAAAZQAAAHgA\
-AAAnAAAAZAAAACAAAABKAAAAYQAAAGMAAABrAAAAIAAAAFEAAAAuAAAACgAAAEYGAAA1BgAAIAAA\
-AC0GAABDBgAASgYAAEUGAAAgAAAARAYAAEcGAAAgAAAAMwYAADEGAAAgAAAAQgYAACcGAAA3BgAA\
-OQYAACAAAABIBgAAMAYAAEgGAAAgAAAANAYAACMGAABGBgAAIAAAADkGAAA4BgAASgYAAEUGAAAg\
-AAAARQYAAEMGAAAqBgAASAYAACgGAAAgAAAAOQYAAEQGAABJBgAAIAAAACsGAABIBgAAKAYAACAA\
-AAAjBgAALgYAADYGAAAxBgAAIAAAAEgGAABFBgAAOgYAAEQGAABBBgAAIAAAACgGAAAsBgAARAYA\
-AC8GAAAgAAAAIwYAADIGAAAxBgAAQgYAACAAAAAKAAAAEgQAACAAAABHBAAAMAQAAEkEAAAwBAAA\
-RQQAACAAAABOBAAAMwQAADAEAAAgAAAANgQAADgEAAA7BAAAIAAAADEEAABLBAAAIAAAAEYEAAA4\
-BAAAQgQAAEAEAABDBAAAQQQAAD8AAAAgAAAAFAQAADAEAAAsAAAAIAAAAD0EAAA+BAAAIAAAAEQE\
-AAAwBAAAOwQAAEwEAABIBAAAOAQAADIEAABLBAAAOQQAACAAAABNBAAAOgQAADcEAAA1BAAAPAQA\
-AD8EAAA7BAAATwQAAEAEAAAhAAAACgAAAKQDAACsAwAAxwMAALkDAADDAwAAxAMAALcDAAAgAAAA\
-sQMAALsDAADOAwAAwAMAALcDAAC+AwAAIAAAALIDAACxAwAAxgMAAK4DAADCAwAAIAAAAMgDAAC3\
-AwAAvAMAAK0DAAC9AwAAtwMAACAAAACzAwAAtwMAACwAAAAgAAAAtAMAAMEDAACxAwAAwwMAALoD\
-AAC1AwAAuwMAAK8DAAC2AwAAtQMAALkDAAAgAAAAxQMAAMADAACtAwAAwQMAACAAAAC9AwAAyQMA\
-ALgDAADBAwAAvwMAAM0DAAAgAAAAugMAAMUDAAC9AwAAzAMAAMIDAAAKAAAAVgAAAGkAAABjAAAA\
-dAAAAG8AAAByAAAAIAAAAGoAAABhAAAAZwAAAHQAAAAgAAAAegAAAHcAAAD2AAAAbAAAAGYAAAAg\
-AAAAQgAAAG8AAAB4AAAAawAAAOQAAABtAAAAcAAAAGYAAABlAAAAcgAAACAAAABxAAAAdQAAAGUA\
-AAByAAAAIAAAAPwAAABiAAAAZQAAAHIAAAAgAAAAZAAAAGUAAABuAAAAIAAAAGcAAAByAAAAbwAA\
-AN8AAABlAAAAbgAAACAAAABTAAAAeQAAAGwAAAB0AAAAZQAAAHIAAAAgAAAARAAAAGUAAABpAAAA\
-YwAAAGgAAAAKAAAAlokAAM6RAAAhcQAAUJYAAONeAAAM/wAAl3oAABZZAAAJZwAAzYUAAClZAAAK\
-AAAACgAAAAAAAAA=";
-
-const char utf8Encoded[] =
-"44GE44KN44Gv44Gr44G744G444Go44CA44Gh44KK44Gs44KL44KS44CA44KP44GL44KI44Gf44KM\
-44Gd44CA44Gk44Gt44Gq44KJ44KA44CA44GG44KQ44Gu44GK44GP44KE44G+44CA44GR44G144GT\
-44GI44Gm44CA44GC44GV44GN44KG44KB44G/44GX44CA44KR44Gy44KC44Gb44GZCteb15og15TX\
-qteo16HXpyDXoNek16Ug16LXnCDXkteV15bXnCDXp9eY158sINep15PXl9ejINeQ16og16bXkdeZ\
-INec157XmdedCu2CpOyKpOydmCDqs6DsnKDsobDqsbTsnYAg7J6F7Iig64G866asIOunjOuCmOyV\
-vCDtlZjqs6Ag7Yq567OE7ZWcIOq4sOyIoOydgCDtlYTsmpTsuZgg7JWK64ukClBjaG7EhcSHIHcg\
-dMSZIMWCw7NkxbogamXFvGEgbHViIG/Fm20gc2tyennFhCBmaWcuCkJsb3d6eSBuaWdodC1mcnVt\
-cHMgdmV4J2QgSmFjayBRLgrZhti1INit2YPZitmFINmE2Ycg2LPYsSDZgtin2LfYuSDZiNiw2Ygg\
-2LTYo9mGINi52LjZitmFINmF2YPYqtmI2Kgg2LnZhNmJINir2YjYqCDYo9iu2LbYsSDZiNmF2LrZ\
-hNmBINio2KzZhNivINij2LLYsdmCIArQkiDRh9Cw0YnQsNGFINGO0LPQsCDQttC40Lsg0LHRiyDR\
-htC40YLRgNGD0YE/INCU0LAsINC90L4g0YTQsNC70YzRiNC40LLRi9C5INGN0LrQt9C10LzQv9C7\
-0Y/RgCEKzqTOrM+HzrnPg8+EzrcgzrHOu8+Oz4DOt86+IM6yzrHPhs6uz4Igz4jOt868zq3Ovc63\
-IM6zzrcsIM60z4HOsc+DzrrOtc67zq/Ots61zrkgz4XPgM6tz4Egzr3Pic64z4HOv8+NIM66z4XO\
-vc+Mz4IKVmljdG9yIGphZ3QgenfDtmxmIEJveGvDpG1wZmVyIHF1ZXIgw7xiZXIgZGVuIGdyb8Of\
-ZW4gU3lsdGVyIERlaWNoCuimlumHjueEoemZkOW7o++8jOeql+WkluacieiXjeWkqQoKAA==";
-
-
-
-
-const char asciiEncodedIso1[] =
-"ISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZ\
-WltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fgA=";
-
-const char asciiEncodedUtf32[] =
-"IQAAACIAAAAjAAAAJAAAACUAAAAmAAAAJwAAACgAAAApAAAAKgAAACsAAAAsAAAALQAAAC4AAAAv\
-AAAAMAAAADEAAAAyAAAAMwAAADQAAAA1AAAANgAAADcAAAA4AAAAOQAAADoAAAA7AAAAPAAAAD0A\
-AAA+AAAAPwAAAEAAAABBAAAAQgAAAEMAAABEAAAARQAAAEYAAABHAAAASAAAAEkAAABKAAAASwAA\
-AEwAAABNAAAATgAAAE8AAABQAAAAUQAAAFIAAABTAAAAVAAAAFUAAABWAAAAVwAAAFgAAABZAAAA\
-WgAAAFsAAABcAAAAXQAAAF4AAABfAAAAYAAAAGEAAABiAAAAYwAAAGQAAABlAAAAZgAAAGcAAABo\
-AAAAaQAAAGoAAABrAAAAbAAAAG0AAABuAAAAbwAAAHAAAABxAAAAcgAAAHMAAAB0AAAAdQAAAHYA\
-AAB3AAAAeAAAAHkAAAB6AAAAewAAAHwAAAB9AAAAfgAAAAAAAAA=";
-
-
-RUNNER_TEST(String_ConverterFromASCII)
-{
- char* inStr = NULL;
- int inSize = wbxml_base64_decode(asciiEncodedIso1, &inStr);
- RUNNER_ASSERT(inSize > 0);
- RUNNER_ASSERT(NULL != inStr);
- inStr[inSize] = '\0';
- {
- DPL::String asciiString = DPL::FromASCIIString(inStr);
-
- std::string result = DPL::ToUTF8String(asciiString);
-
- RUNNER_ASSERT(strlen(inStr) == result.size());
-
- RUNNER_ASSERT(0 == memcmp(inStr, result.c_str(), result.size()));
- }
-
- free(inStr);
-}
-
-RUNNER_TEST(String_ConverterFromUTF8)
-{
- char* inStr = NULL;
- int inSize = wbxml_base64_decode(asciiEncodedIso1, &inStr);
- RUNNER_ASSERT(inSize > 0);
- RUNNER_ASSERT(NULL != inStr);
- {
- DPL::String asciiString = DPL::FromUTF8String(inStr);
-
- std::string result = DPL::ToUTF8String(asciiString);
-
- RUNNER_ASSERT(strlen(inStr) == result.size());
-
- RUNNER_ASSERT(0 == memcmp(inStr, result.c_str(), result.size()));
- }
-
- free(inStr);
-}
-
-RUNNER_TEST(String_ConverterFromUTF32)
-{
- wchar_t* inStr = NULL;
- int inSize = wbxml_base64_decode(utf32Encoded, reinterpret_cast<char**>(&inStr));
- RUNNER_ASSERT(inSize > 0);
- RUNNER_ASSERT(NULL != inStr);
- char* outStr = NULL;
- int outSize = wbxml_base64_decode(utf8Encoded, &outStr);
- RUNNER_ASSERT(outSize > 0);
- RUNNER_ASSERT(NULL != outStr);
- outStr[outSize] = '\0';
- {
- DPL::String utfString = DPL::FromUTF32String(inStr);
- std::string result = DPL::ToUTF8String(utfString);
-
- RUNNER_ASSERT(strlen(outStr) == result.size());
- RUNNER_ASSERT(0 == memcmp(outStr, result.c_str(), result.size()));
-
-
- RUNNER_ASSERT(inSize / sizeof(wchar_t) - 1 == utfString.size());
- RUNNER_ASSERT(0 == memcmp(inStr, &(utfString[0]), utfString.size() * sizeof(wchar_t)));
-
- }
-
- free(inStr);
-}
-
-template<typename DelimiterType>
-void String_TokenizeReal(const DelimiterType& delimiter)
-{
- DPL::String str(L".##..abc.#.");
- std::vector<DPL::String> tokens;
- DPL::Tokenize(str, delimiter, std::back_inserter(tokens));
-
- std::vector<DPL::String> expectedTokens;
- for ( int i = 0 ; i < 5 ; i++ )
- expectedTokens.push_back(L"");
- expectedTokens.push_back(L"abc");
- for ( int i = 0 ; i < 3 ; i++ )
- expectedTokens.push_back(L"");
-
- RUNNER_ASSERT(expectedTokens == tokens);
- tokens.clear();
- expectedTokens.clear();
-
- DPL::Tokenize(str, delimiter, std::back_inserter(tokens), true);
- expectedTokens.push_back(L"abc");
- RUNNER_ASSERT(expectedTokens == tokens);
-}
-
-RUNNER_TEST(String_Tokenize)
-{
- String_TokenizeReal(L"#.");
- String_TokenizeReal(L".#");
- String_TokenizeReal(L".....####.###..");
- String_TokenizeReal(DPL::String(L".#"));
-
- std::vector<std::string> tokens;
- DPL::Tokenize(std::string("abc.def"), '.', std::back_inserter(tokens));
- std::vector<std::string> expectedTokens;
- expectedTokens.push_back("abc");
- expectedTokens.push_back("def");
-
- RUNNER_ASSERT(tokens == expectedTokens);
-}
-
-template <typename TemplateArgumentCharTraits>
-void TestInStreams(
- std::basic_string<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits> argumentInString,
- std::basic_string<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits> argumentResultString)
-{
- typedef std::basic_string<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits>
- String;
- std::basic_istringstream<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits>
- istream(argumentInString);
- int intValue = 0;
- double doubleValue = 0.0;
- float floatValue = 0.0;
- String stringValue;
-
- istream >> intValue;
- RUNNER_ASSERT(!istream.fail());
- istream >> doubleValue;
- RUNNER_ASSERT(!istream.fail());
- istream >> floatValue;
- RUNNER_ASSERT(!istream.fail());
- istream >> stringValue;
- RUNNER_ASSERT(!istream.fail());
-
- RUNNER_ASSERT(1 == intValue);
- RUNNER_ASSERT(fabs(1.1f - doubleValue) < 0.00001);
- RUNNER_ASSERT(fabs(1.1f - floatValue) < 0.00001);
- RUNNER_ASSERT(argumentResultString == stringValue);
-}
-
-template <typename TemplateArgumentCharTraits>
-void TestOutStreams(
- std::basic_string<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits> argumentInString,
- std::basic_string<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits> argumentResultString)
-{
- typedef std::basic_string<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits>
- String;
-
- std::basic_ostringstream<typename TemplateArgumentCharTraits::char_type,
- TemplateArgumentCharTraits>
- ostream;
-
- int intValue = 1;
- double doubleValue = 1.1;
- float floatValue = 1.1f;
- String stringValue = argumentInString;
-
- ostream << intValue;
- RUNNER_ASSERT(!ostream.fail());
- ostream << doubleValue;
- RUNNER_ASSERT(!ostream.fail());
- ostream << floatValue;
- RUNNER_ASSERT(!ostream.fail());
- ostream << stringValue;
- RUNNER_ASSERT(!ostream.fail());
-
- RUNNER_ASSERT(ostream.str() == argumentResultString);
-}
-
-RUNNER_TEST(String_Streams)
-{
- TestInStreams<std::char_traits<char> >("1 1.1 1.1 test", "test");
- TestInStreams<std::char_traits<wchar_t> >(L"1 1.1 1.1 test", L"test");
- TestInStreams<DPL::CharTraits>(L"1 1.1 1.1 test", L"test");
- TestOutStreams<std::char_traits<char> >("test", "11.11.1test");
- TestOutStreams<std::char_traits<wchar_t> >(L"test", L"11.11.1test");
- TestOutStreams<DPL::CharTraits>(L"test", L"11.11.1test");
-}
-
-RUNNER_TEST(String_CompareCaseSensitive)
-{
- RUNNER_ASSERT(
- DPL::StringCompare(
- DPL::FromUTF32String(L"Ala Makota ma żołądkówkę"),
- DPL::FromUTF32String(L"Ala Makota ma żołądkówkę")) == 0);
-}
-
-RUNNER_TEST(String_CompareCaseInsensitive)
-{
- RUNNER_ASSERT(
- DPL::StringCompare(
- DPL::FromUTF32String(L"Ala Makota ma żołądkówkę"),
- DPL::FromUTF32String(L"AlA MakOTA ma ŻoŁąDKÓwkę"),
- true) == 0);
-}
-
+++ /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 test_task.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of task tests
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/task.h>
-#include <dpl/log/log.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-class MySingleTask
- : public DPL::TaskDecl<MySingleTask>
-{
-protected:
- void StepOne()
- {
- }
-
-public:
- MySingleTask()
- : DPL::TaskDecl<MySingleTask>(this)
- {
- AddStep(&MySingleTask::StepOne);
- }
-};
-
-class MyMultiTask
- : public DPL::MultiTaskDecl<MyMultiTask>
-{
-protected:
- typedef DPL::MultiTaskDecl<MyMultiTask> BaseType;
-
- void StepOne()
- {
- LogInfo("Step one");
- }
-
- void StepTwo()
- {
- LogInfo("Step two");
- }
-
- void StepThree()
- {
- LogInfo("Step three");
- }
-
-public:
- MyMultiTask()
- : BaseType(this, 2)
- {
- BaseType::StepList depListStepThree;
- depListStepThree.push_back(&MyMultiTask::StepOne);
- depListStepThree.push_back(&MyMultiTask::StepTwo);
- AddStep(&MyMultiTask::StepThree, depListStepThree);
-
- BaseType::StepList depListStepTwo;
- depListStepTwo.push_back(&MyMultiTask::StepOne);
- AddStep(&MyMultiTask::StepTwo, depListStepTwo);
-
- BaseType::StepList depListStepOne;
- AddStep(&MyMultiTask::StepOne, depListStepOne);
- }
-};
-
-RUNNER_TEST(Task_SingleTask)
-{
- MySingleTask task;
- while (task.NextStep());
-}
-
-RUNNER_TEST(Task_MultiTask)
-{
- MyMultiTask task;
- while (task.NextStep());
-}
+++ /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 test_thread.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of thread tests
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/thread.h>
-#include <dpl/log/log.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-bool g_wasFooDeleted;
-
-class Foo
-{
-public:
- int id;
- Foo(int i=0): id(i)
- {
- LogInfo("Foo: ctor: " << id);
- }
-
- ~Foo()
- {
- LogInfo("Foo: dtor: " << id);
- g_wasFooDeleted = true;
- }
-
- void Bar()
- {
- LogInfo("Foo: bar");
- }
-};
-
-typedef DPL::ThreadLocalVariable<Foo> TlsFoo;
-TlsFoo g_foo;
-
-class FooThread
- : public DPL::Thread
-{
-protected:
- virtual int ThreadEntry()
- {
- LogInfo("In thread");
-
- RUNNER_ASSERT(!g_foo);
- RUNNER_ASSERT(g_foo.IsNull());
-
- g_foo = Foo();
- g_foo->Bar();
-
- return 0;
- }
-};
-
-RUNNER_TEST(Thread_ThreadLocalVariable_FooDeletion)
-{
- static TlsFoo staticFooForMain;
- staticFooForMain = Foo(1);
-
- TlsFoo fooForMain;
- fooForMain = Foo(2);
-
- RUNNER_ASSERT(!g_foo);
- RUNNER_ASSERT(g_foo.IsNull());
-
- g_wasFooDeleted = false;
-
- FooThread thread1;
- thread1.Run();
- thread1.Quit();
-
- RUNNER_ASSERT(!g_foo);
- RUNNER_ASSERT(g_foo.IsNull());
-
- RUNNER_ASSERT(g_wasFooDeleted == true);
-
- FooThread thread2;
- thread2.Run();
- thread2.Quit();
-
- RUNNER_ASSERT(!g_foo);
- RUNNER_ASSERT(g_foo.IsNull());
-}
+++ /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 test_type_list.cpp
- * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @version 0.1
- * @brief
- */
-
-#include <dpl/test/test_runner.h>
-#include <dpl/type_list.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(TypeList_TypeCount)
-{
- typedef DPL::TypeListDecl<int, char, int[64]>::Type TestTypeList1;
- typedef DPL::TypeListDecl<int>::Type TestTypeList2;
- typedef DPL::TypeListDecl<>::Type TestTypeList3;
- typedef DPL::TypeList<int, TestTypeList1> TestTypeList4;
-
- RUNNER_ASSERT(TestTypeList1::Size == 3);
- RUNNER_ASSERT(TestTypeList2::Size == 1);
- RUNNER_ASSERT(TestTypeList3::Size == 0);
- RUNNER_ASSERT(TestTypeList4::Size == 4);
-
- RUNNER_ASSERT(TestTypeList4::Tail::Tail::Size == 2);
-}
+++ /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 test_zip_input.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of zip input tests
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/zip_input.h>
-#include <dpl/foreach.h>
-#include <dpl/abstract_waitable_input_adapter.h>
-#include <dpl/abstract_waitable_output_adapter.h>
-#include <dpl/binary_queue.h>
-#include <dpl/scoped_array.h>
-#include <dpl/copy.h>
-#include <dpl/log/log.h>
-
-namespace {
-const char* PATH_NO_FILE = "/opt/apps/wrt/wrt-commons/tests/core/no_such_file";
-const char* PATH_ARCHIVE = "/opt/apps/wrt/wrt-commons/tests/core/sample.zip";
-const char* ARCHIVED_FILE = "sample.txt";
-}
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(ZipInput_OpenFailed)
-{
- bool opened = true;
-
- Try
- {
- DPL::ZipInput zip(PATH_NO_FILE);
- (void)zip;
- }
- Catch(DPL::ZipInput::Exception::OpenFailed)
- {
- opened = false;
- }
-
- RUNNER_ASSERT(opened == false);
-}
-
-RUNNER_TEST(ZipInput_OpenFile)
-{
- DPL::ZipInput zip(PATH_ARCHIVE);
-
- FOREACH(iter, zip)
- {
- LogDebug("---------");
- LogDebug("FileInfo: ");
-#define FIELD(X) LogDebug(#X ": " << iter->X)
- FIELD(name);
- FIELD(comment);
- FIELD(version);
- FIELD(versionNeeded);
- FIELD(flag);
- FIELD(compressionMethod);
- FIELD(dosDate);
- FIELD(crc);
- FIELD(compressedSize);
- FIELD(uncompressedSize);
- FIELD(diskNumberStart);
- FIELD(internalFileAttributes);
- FIELD(externalFileAttributes);
-#undef FIELD
- }
-}
-
-RUNNER_TEST(ZipInput_UnzipSingleFile)
-{
- DPL::ZipInput zip(PATH_ARCHIVE);
- DPL::ZipInput::File *file = zip.OpenFile(ARCHIVED_FILE);
- DPL::AbstractWaitableInputAdapter fileAdapter(file);
- DPL::BinaryQueue buffer;
- DPL::AbstractWaitableOutputAdapter bufferAdapter(&buffer);
-
- DPL::Copy(&fileAdapter, &bufferAdapter);
-
- DPL::ScopedArray<char> data(new char[buffer.Size() + 1]);
- buffer.Flatten(data.Get(), buffer.Size());
- data[buffer.Size()] = '\0';
-
- RUNNER_ASSERT(std::string(data.Get()) == "test");
-}
+++ /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 CMakeLists.txt
-# @author Lukasz Marek (l.marek@samsung.com)
-# @version 1.0
-# @brief
-#
-
-#
-# Test files
-#
-# Define all DPL tests sources.
-# Runner is responsible for runnint it all and
-# generating proper output files
-#
-
-SET(TARGET_NAME "dpl-tests-db")
-
-# Set DPL tests sources
-SET(DPL_TESTS_SOURCES
- ${PROJECT_SOURCE_DIR}/tests/db/main.cpp
- ${PROJECT_SOURCE_DIR}/tests/db/test_orm.cpp
- ${PROJECT_SOURCE_DIR}/tests/db/test_sql_connection.cpp
-)
-
-ADD_SUBDIRECTORY(orm)
-
-INCLUDE_DIRECTORIES(
- ${SYS_EFL_INCLUDE_DIRS}
- ${DPL_TEST_INCLUDE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/orm
-)
-
-LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS})
-
-ADD_EXECUTABLE(${TARGET_NAME} ${DPL_TESTS_SOURCES})
-
-TARGET_LINK_LIBRARIES(
- ${TARGET_NAME}
- ${TARGET_DPL_EFL}
- ${TARGET_DPL_DB_EFL}
- ${TARGET_DPL_TEST_ENGINE_EFL}
-)
-
-SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_NAME}
- DESTINATION bin)
-
-INSTALL(FILES
- ${PROJECT_SOURCE_DIR}/tests/db/orm/dpl_orm_test.db
- DESTINATION /opt/apps/wrt/wrt-commons/tests/db
-)
+++ /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 main.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of main.
- */
-
-#include <dpl/test/test_runner.h>
-
-int main(int argc, char *argv[])
-{
- return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-}
+++ /dev/null
-
-ADD_CUSTOM_COMMAND( OUTPUT dpl_orm_test_db.sql
- COMMAND rm -f ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db
- COMMAND gcc -Wall -I${DPL_DB_INCLUDE_DIR} -E ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db_sql_generator.h | grep --invert-match "^#" > ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db.sql
- COMMAND sqlite3 ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db ".read ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db.sql" || rm -f ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test.db
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db_sql_generator.h ${CMAKE_CURRENT_SOURCE_DIR}/dpl_orm_test_db
-)
-
-ADD_CUSTOM_TARGET( Sqlite3Db ALL DEPENDS dpl_orm_test_db.sql )
+++ /dev/null
-
-CREATE_TABLE(TestTableInsert)
- COLUMN(ColumnOptInt, INT,)
- COLUMN(ColumnOptText, TEXT,)
- COLUMN_NOT_NULL(ColumnInt, INT, DEFAULT 99)
- COLUMN_NOT_NULL(ColumnInt2, INT,)
- COLUMN_NOT_NULL(ColumnText, TEXT,)
-CREATE_TABLE_END()
-
-CREATE_TABLE(TestTableDelete)
- COLUMN(ColumnOptInt, INT,)
- COLUMN(ColumnOptText, TEXT,)
- COLUMN_NOT_NULL(ColumnInt, INT, DEFAULT 99)
- COLUMN_NOT_NULL(ColumnInt2, INT,)
- COLUMN_NOT_NULL(ColumnText, TEXT,)
-CREATE_TABLE_END()
-
-SQL(
- INSERT INTO TestTableDelete VALUES(1, "two", 3, 4, "five");
- INSERT INTO TestTableDelete VALUES(6, "seven", 8, 9, "ten");
- INSERT INTO TestTableDelete (ColumnInt2, ColumnText) VALUES(11, "twelve");
- INSERT INTO TestTableDelete (ColumnInt2, ColumnText) VALUES(13, "fourteen");
-)
-
-CREATE_TABLE(TestTable)
- COLUMN(ColumnOptInt, INT,)
- COLUMN(ColumnOptText, TEXT,)
- COLUMN_NOT_NULL(ColumnInt, INT, DEFAULT 99)
- COLUMN_NOT_NULL(ColumnInt2, INT,)
- COLUMN_NOT_NULL(ColumnText, TEXT,)
-CREATE_TABLE_END()
-
-SQL(
- INSERT INTO TestTable VALUES(1, "two", 3, 4, "five");
- INSERT INTO TestTable VALUES(6, "seven", 8, 9, "ten");
- INSERT INTO TestTable (ColumnInt2, ColumnText) VALUES(11, "twelve");
- INSERT INTO TestTable (ColumnInt2, ColumnText) VALUES(13, "fourteen");
-)
+++ /dev/null
-
-
-
-
-CREATE TABLE TestTableInsert (
- ColumnOptInt INT ,
- ColumnOptText TEXT ,
- ColumnInt INT DEFAULT 99 not null,
- ColumnInt2 INT not null,
- ColumnText TEXT not null,
-CHECK(1) );
-
-CREATE TABLE TestTableDelete (
- ColumnOptInt INT ,
- ColumnOptText TEXT ,
- ColumnInt INT DEFAULT 99 not null,
- ColumnInt2 INT not null,
- ColumnText TEXT not null,
-CHECK(1) );
-
-INSERT INTO TestTableDelete VALUES(1, "two", 3, 4, "five"); INSERT INTO TestTableDelete VALUES(6, "seven", 8, 9, "ten"); INSERT INTO TestTableDelete (ColumnInt2, ColumnText) VALUES(11, "twelve"); INSERT INTO TestTableDelete (ColumnInt2, ColumnText) VALUES(13, "fourteen");
-
-
-
-
-
-
-CREATE TABLE TestTable (
- ColumnOptInt INT ,
- ColumnOptText TEXT ,
- ColumnInt INT DEFAULT 99 not null,
- ColumnInt2 INT not null,
- ColumnText TEXT not null,
-CHECK(1) );
-
-INSERT INTO TestTable VALUES(1, "two", 3, 4, "five"); INSERT INTO TestTable VALUES(6, "seven", 8, 9, "ten"); INSERT INTO TestTable (ColumnInt2, ColumnText) VALUES(11, "twelve"); INSERT INTO TestTable (ColumnInt2, ColumnText) VALUES(13, "fourteen");
-
-
+++ /dev/null
-DATABASE_START(dpl_orm_test)
-
-#include "dpl_orm_test_db"
-
-DATABASE_END()
+++ /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 dpl_orm_test_db_sql_generator.h
- * @author Lukasz Marek (l.marek@samsung.com)
- * @version 1.0
- * @brief Macro definitions for generating the SQL input file from database definition.
- */
-
-//Do not include this file directly! It is used only for SQL code generation.
-
-#include <dpl/db/orm_macros.h>
-
-#include "dpl_orm_test_db_definitions"
+++ /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.
- */
-
-#ifndef ORM_GENERATOR_DPL_ORM_TEST_H
-#define ORM_GENERATOR_DPL_ORM_TEST_H
-
-#define ORM_GENERATOR_DATABASE_NAME dpl_orm_test_db_definitions
-#include <dpl/db/orm_generator.h>
-#undef ORM_GENERATOR_DATABASE_NAME
-
-#endif
+++ /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.
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/foreach.h>
-#include <dpl/db/thread_database_support.h>
-#include <generator_dpl_orm_test.h>
-
-namespace {
-const char* PATH_DB = "/opt/apps/wrt/wrt-commons/tests/db/dpl_orm_test.db";
-}
-
-//utils
-
-#define TEST_REPETITION 16
-
-class SmartAttach
-{
-public:
-
- SmartAttach(bool autoattach = true) :
- m_interface(PATH_DB,
- DPL::DB::SqlConnection::Flag::UseLucene),
- m_autoattach(autoattach)
- {
- if (m_autoattach) {
- m_interface.AttachToThread();
- }
- }
-
- ~SmartAttach()
- {
- if (m_autoattach) {
- m_interface.DetachFromThread();
- }
- }
-
- DPL::DB::ThreadDatabaseSupport* get()
- {
- return &m_interface;
- }
-private:
- DPL::DB::ThreadDatabaseSupport m_interface;
- bool m_autoattach;
-};
-
-template<typename ContainerType1, typename ContainerType2>
-bool ContainerContentsEqual(const ContainerType1& container1, const ContainerType2& container2)
-{
- using namespace DPL::DB::ORM::dpl_orm_test::TestTableInsert;
- typedef std::set<typename ContainerType1::value_type> Set1;
- typedef std::set<typename ContainerType2::value_type> Set2;
- Set1 set1(container1.begin(), container1.end());
- Set2 set2(container2.begin(), container2.end());
-
- for (typename Set1::iterator it = set1.begin();
- it != set1.end();
- it++)
- {
- LogDebug("Set1 element: " << *it);
- }
-
- for (typename Set2::iterator it = set2.begin(); it != set2.end(); it++)
- {
- LogDebug("Set2 element: " << *it);
- }
-
- return set1 == set2;
-}
-
-template<typename T>
-std::list<T> makeList(const T& a, const T& b)
-{
- std::list<T> list;
- list.push_back(a);
- list.push_back(b);
- return list;
-}
-
-//tests
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-RUNNER_TEST(ORM_SelectSingleValue)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
- //Getting each column
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(8));
- int result;
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptInt>()) == 6, "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(8));
- DPL::String result;
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptText>()) == L"seven", "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(8));
- int result;
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt>()) == 8, "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(8));
- int result;
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 9, "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(8));
- DPL::String result;
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnText>()) == L"ten", "Got " << result);
- }
-
- //Where on each column
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnOptInt>(6));
- int result;
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptInt>()) == 6, "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnOptText>(DPL::String(L"seven")));
- DPL::String result;
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptText>()) == L"seven", "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(8));
- int result;
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt>()) == 8, "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt2>(9));
- int result;
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 9, "Got " << result);
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnText>(L"ten"));
- DPL::String result;
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnText>()) == L"ten", "Got " << result);
- }
-}
-
-RUNNER_TEST(ORM_SelectSingleRow)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(3));
- TestTable::Row result = select.GetSingleRow();
- TestTable::Row expected;
- expected.Set_ColumnOptInt(1);
- expected.Set_ColumnOptText(DPL::String(L"two"));
- expected.Set_ColumnInt(3);
- expected.Set_ColumnInt2(4);
- expected.Set_ColumnText(L"five");
- RUNNER_ASSERT_MSG(result == expected, "Got " << result);
- }
-
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnOptText>(DPL::String(L"seven")));
- TestTable::Row result = select.GetSingleRow();
- TestTable::Row expected;
- expected.Set_ColumnOptInt(6);
- expected.Set_ColumnOptText(DPL::String(L"seven"));
- expected.Set_ColumnInt(8);
- expected.Set_ColumnInt2(9);
- expected.Set_ColumnText(L"ten");
- RUNNER_ASSERT_MSG(result == expected, "Got " << result);
- }
-}
-
-RUNNER_TEST(ORM_SelectRowList)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(3));
- std::list<TestTable::Row> result = select.GetRowList();
- RUNNER_ASSERT_MSG(result.size() == 1, "Got " << result.size());
-
- TestTable::Row expected;
- expected.Set_ColumnOptInt(1);
- expected.Set_ColumnOptText(DPL::String(L"two"));
- expected.Set_ColumnInt(3);
- expected.Set_ColumnInt2(4);
- expected.Set_ColumnText(L"five");
- RUNNER_ASSERT_MSG(*(result.begin()) == expected, "Got " << *(result.begin()) );
- }
-
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnOptText>(DPL::String(L"seven")));
- std::list<TestTable::Row> result = select.GetRowList();
- RUNNER_ASSERT_MSG(result.size() == 1, "Got " << result.size());
-
- TestTable::Row expected;
- expected.Set_ColumnOptInt(6);
- expected.Set_ColumnOptText(DPL::String(L"seven"));
- expected.Set_ColumnInt(8);
- expected.Set_ColumnInt2(9);
- expected.Set_ColumnText(L"ten");
- RUNNER_ASSERT_MSG(*(result.begin()) == expected, "Got " << *(result.begin()) );
- }
-
- {
- TestTable::Select select(interface.get());
- select.Where(Equals<TestTable::ColumnInt>(99));
- std::list<TestTable::Row> result = select.GetRowList();
-
- TestTable::Row expected1;
- expected1.Set_ColumnInt(99);
- expected1.Set_ColumnInt2(11);
- expected1.Set_ColumnText(L"twelve");
-
- TestTable::Row expected2;
- expected2.Set_ColumnInt(99);
- expected2.Set_ColumnInt2(13);
- expected2.Set_ColumnText(L"fourteen");
-
- RUNNER_ASSERT(ContainerContentsEqual(makeList(expected1, expected2), result));
- }
-}
-
-RUNNER_TEST(ORM_SelectValueList)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
- //Getting each column
- {
- TestTable::Select select(interface.get());
- select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
- RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::ColumnInt>(),
- makeList(99, 99)));
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
- RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::ColumnInt2>(),
- makeList(11, 13)));
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
- RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::ColumnText>(),
- makeList(DPL::String(L"twelve"), DPL::String(L"fourteen"))));
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
- RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::ColumnOptText>(),
- makeList(DPL::Optional<DPL::String>::Null,DPL::Optional<DPL::String>::Null)));
- }
-
- //Where on each column
- {
- TestTable::Select select(interface.get());
- select.Where(Is<TestTable::ColumnOptInt>(DPL::Optional<int>::Null));
- RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::ColumnInt2>(),
- makeList(11, 13)));
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Is<TestTable::ColumnOptText>(DPL::Optional<DPL::String>::Null));
- RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::ColumnInt2>(),
- makeList(11, 13)));
- }
- {
- TestTable::Select select(interface.get());
- select.Where(Is<TestTable::ColumnInt>(99));
- RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList<TestTable::ColumnInt2>(),
- makeList(11, 13)));
- }
-}
-
-RUNNER_TEST(ORM_MultipleCalls)
-{
- for (int j = 0 ; j < TEST_REPETITION ; j++ )
- {
- for (int i = 0 ; i < TEST_REPETITION ; i++ )
- ORM_SelectSingleValue();
-
- for (int i = 0 ; i < TEST_REPETITION ; i++ )
- ORM_SelectSingleRow();
-
- for (int i = 0 ; i < TEST_REPETITION ; i++ )
- ORM_SelectRowList();
-
- for (int i = 0 ; i < TEST_REPETITION ; i++ )
- ORM_SelectValueList();
- }
-}
-
-RUNNER_TEST(ORM_Insert)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
-
- TestTableInsert::Select select1(interface.get());
- std::list<int> resultList = select1.GetValueList<TestTableInsert::ColumnInt>();
- RUNNER_ASSERT_MSG(resultList.size() == 0, "Returned list has wrong size: " << resultList.size());
- std::list<TestTableInsert::Row> list;
-
- TestTableInsert::Insert insert(interface.get());
- TestTableInsert::Row row;
- row.Set_ColumnOptInt(1);
- row.Set_ColumnInt2(2);
- row.Set_ColumnText(L"three");
- insert.Values(row);
- insert.Execute();
-
- row.Set_ColumnInt(99);
- list.push_back(row);
- {
- TestTableInsert::Select select2(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select2.GetRowList(), list), "Returned list doesn't match.");
- }
-
- TestTableInsert::Insert insert2(interface.get());
- TestTableInsert::Row row2;
- row2.Set_ColumnInt(4);
- row2.Set_ColumnInt2(5);
- row2.Set_ColumnText(L"six");
- insert2.Values(row2);
- insert2.Execute();
-
- list.push_back(row2);
- {
- TestTableInsert::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- TestTableInsert::Insert insert3(interface.get());
- TestTableInsert::Row row3;
- row3.Set_ColumnOptInt(1);
- row3.Set_ColumnInt2(7);
- row3.Set_ColumnText(L"eight");
- insert3.Values(row3);
- insert3.Execute();
-
- row3.Set_ColumnInt(99);
- list.push_back(row3);
- {
- TestTableInsert::Select select3(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select3.GetRowList(), list), "Returned list doesn't match.");
- }
-
- TestTableInsert::Insert insert4(interface.get());
- TestTableInsert::Row row4;
- row4.Set_ColumnOptInt(9);
- row4.Set_ColumnInt2(10);
- row4.Set_ColumnText(L"eleven");
- insert4.Values(row4);
- insert4.Execute();
-
- row4.Set_ColumnInt(99);
- list.push_back(row4);
- {
- TestTableInsert::Select select4(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select4.GetRowList(), list), "Returned list doesn't match.");
- }
-
- // restore original table state
- {
- TestTableInsert::Delete del(interface.get());
- del.Execute();
-
- TestTableInsert::Select select(interface.get());
- RUNNER_ASSERT(select.GetRowList().size() == 0);
- }
-}
-
-RUNNER_TEST(ORM_MultipleBindInsert)
-{
- for ( int i = 0 ; i < TEST_REPETITION ; i++ )
- {
- ORM_Insert();
- }
-}
-
-RUNNER_TEST(ORM_Delete)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
- TestTableDelete::Select selectStart(interface.get());
- selectStart.OrderBy("ColumnInt2 ASC");
- std::list<TestTableDelete::Row> list = selectStart.GetRowList();
- std::list<TestTableDelete::Row> originalList = list;
-
- std::vector<TestTableDelete::Row> vector(list.begin(), list.end());
- RUNNER_ASSERT_MSG(list.size() == 4, "Returned list has wrong size: " << list.size());
-
- typedef DPL::String S;
-
- //no-act deletes
- {
- TestTableDelete::Delete del(interface.get());
- del.Where(And(Equals<TestTableDelete::ColumnOptInt>(1), Equals<TestTableDelete::ColumnOptText>(S(L"seven"))));
- del.Execute();
-
- TestTableDelete::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- {
- TestTableDelete::Delete del(interface.get());
- del.Where(And(Equals<TestTableDelete::ColumnOptInt>(6), Equals<TestTableDelete::ColumnOptText>(S(L"two"))));
- del.Execute();
-
- TestTableDelete::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- {
- TestTableDelete::Delete del(interface.get());
- del.Where(Equals<TestTableDelete::ColumnInt2>(10));
- del.Execute();
-
- TestTableDelete::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- //act deletes
- {
- list.remove(vector[1]);
-
- TestTableDelete::Delete del(interface.get());
- del.Where(And(Equals<TestTableDelete::ColumnOptInt>(6), Equals<TestTableDelete::ColumnText>(L"ten")));
- del.Execute();
-
- TestTableDelete::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- {
- list.remove(vector[2]);
- list.remove(vector[3]);
-
- TestTableDelete::Delete del(interface.get());
- del.Where(Is<TestTableDelete::ColumnOptText>(DPL::Optional<DPL::String>::Null));
- del.Execute();
-
- TestTableDelete::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- {
- TestTableDelete::Delete del(interface.get());
- del.Execute();
-
- TestTableDelete::Select select(interface.get());
- RUNNER_ASSERT_MSG(select.GetRowList().size() == 0, "Returned list is not empty");
- }
-
- // Restore original table state
- // This also tests if multiple different binds for Insert are working properly
- for (std::list<TestTableDelete::Row>::iterator i = originalList.begin(); i != originalList.end(); i++)
- {
- TestTableDelete::Insert insert(interface.get());
- insert.Values(*i);
- insert.Execute();
- }
-
- {
- TestTableDelete::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), originalList), "Returned list doesn't match.");
- }
-
-}
-
-RUNNER_TEST(ORM_MultipleBindDelete)
-{
- for ( int i = 0 ; i < TEST_REPETITION ; i++ )
- {
- ORM_Delete();
- }
-}
-
-RUNNER_TEST(ORM_MultipleBindWhere)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
- {
- TestTable::Select select(interface.get());
- int result;
- select.Where(Equals<TestTable::ColumnInt>(8));
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptInt>()) == 6, "Got " << result);
-
- select.Where(Equals<TestTable::ColumnInt>(3));
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptInt>()) == 1, "Got " << result);
-
- select.Where(Equals<TestTable::ColumnInt>(8));
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptInt>()) == 6, "Got " << result);
-
- select.Where(Equals<TestTable::ColumnInt>(3));
- RUNNER_ASSERT_MSG((result = *select.GetSingleValue<TestTable::ColumnOptInt>()) == 1, "Got " << result);
- }
-
- {
- TestTable::Select select(interface.get());
- int result;
- select.Where(And(Equals<TestTable::ColumnInt>(99),
- Equals<TestTable::ColumnText>(L"fourteen")));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 13, "Got " << result);
-
- select.Where(And(Equals<TestTable::ColumnInt>(99),
- Equals<TestTable::ColumnText>(L"twelve")));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 11, "Got " << result);
-
- select.Where(And(Equals<TestTable::ColumnInt>(99),
- Equals<TestTable::ColumnText>(L"fourteen")));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 13, "Got " << result);
-
- select.Where(And(Equals<TestTable::ColumnInt>(99),
- Equals<TestTable::ColumnText>(L"twelve")));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 11, "Got " << result);
- }
-
- {
- TestTable::Select select(interface.get());
- int result;
- select.Where(And(Equals<TestTable::ColumnText>(L"fourteen"),
- Equals<TestTable::ColumnInt>(99)));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 13, "Got " << result);
-
- select.Where(And(Equals<TestTable::ColumnText>(L"twelve"),
- Equals<TestTable::ColumnInt>(99)));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 11, "Got " << result);
-
- select.Where(And(Equals<TestTable::ColumnText>(L"fourteen"),
- Equals<TestTable::ColumnInt>(99)));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 13, "Got " << result);
-
- select.Where(And(Equals<TestTable::ColumnText>(L"twelve"),
- Equals<TestTable::ColumnInt>(99)));
- RUNNER_ASSERT_MSG((result = select.GetSingleValue<TestTable::ColumnInt2>()) == 11, "Got " << result);
-
- }
-
-}
-
-RUNNER_TEST(ORM_Update)
-{
- SmartAttach interface;
- using namespace DPL::DB::ORM;
- using namespace DPL::DB::ORM::dpl_orm_test;
-
- std::list<TestTableInsert::Row> list;
-
- TestTableInsert::Delete del(interface.get());
- del.Execute();
-
- // INSERT
- {
- TestTableInsert::Insert insert(interface.get());
- TestTableInsert::Row row;
- row.Set_ColumnOptInt(5);
- row.Set_ColumnInt2(2);
- row.Set_ColumnText(L"two");
- insert.Values(row);
- insert.Execute();
-
- row.Set_ColumnInt(99);
- list.push_back(row);
- }
- {
- TestTableInsert::Insert insert(interface.get());
- TestTableInsert::Row row;
- row.Set_ColumnOptInt(1);
- row.Set_ColumnInt2(2);
- row.Set_ColumnText(L"three");
- insert.Values(row);
- insert.Execute();
-
- row.Set_ColumnInt(99);
- list.push_back(row);
- }
- {
- TestTableInsert::Insert insert(interface.get());
- TestTableInsert::Row row;
- row.Set_ColumnOptInt(2);
- row.Set_ColumnInt2(3);
- row.Set_ColumnText(L"three");
- insert.Values(row);
- insert.Execute();
-
- row.Set_ColumnInt(99);
- list.push_back(row);
-
- // CHECK
- TestTableInsert::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
- {
- // UPDATE - no rows
- TestTableInsert::Update update(interface.get());
- TestTableInsert::Row row;
- row.Set_ColumnInt2(4);
- row.Set_ColumnText(L"four");
- update.Values(row);
- update.Where(Equals<TestTableInsert::ColumnInt2>(12));
- update.Execute();
-
- // CHECK
- TestTableInsert::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
- {
- // UPDATE - one row
- TestTableInsert::Update update(interface.get());
- TestTableInsert::Row row;
- row.Set_ColumnInt2(2);
- row.Set_ColumnText(L"four");
- update.Values(row);
- update.Where(Equals<TestTableInsert::ColumnInt2>(3));
- update.Execute();
-
- list.back().Set_ColumnInt2(2);
- list.back().Set_ColumnText(L"four");
-
- // CHECK
- TestTableInsert::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- {
- // UPDATE - multiple rows
- TestTableInsert::Update update(interface.get());
- TestTableInsert::Row row;
- row.Set_ColumnText(L"dup");
- update.Values(row);
- update.Where(Equals<TestTableInsert::ColumnInt2>(2));
- update.Execute();
-
- FOREACH(it, list)
- {
- it->Set_ColumnText(L"dup");
- }
-
- // CHECK
- TestTableInsert::Select select(interface.get());
- RUNNER_ASSERT_MSG(ContainerContentsEqual(select.GetRowList(), list), "Returned list doesn't match.");
- }
-
- // restore original table state
- {
- TestTableInsert::Delete del2(interface.get());
- del2.Execute();
-
- TestTableInsert::Select select(interface.get());
- RUNNER_ASSERT(select.GetRowList().size() == 0);
- }
-}
-
-RUNNER_TEST(ORM_MultipleBindUpdate)
-{
- for ( int i = 0 ; i < TEST_REPETITION ; i++ )
- {
- ORM_Update();
- }
-}
-
-RUNNER_TEST(ORM_transactions)
-{
- SmartAttach interface;
- DPL::DB::ORM::dpl_orm_test::ScopedTransaction transaction(interface.get());
-}
-
-RUNNER_TEST(ORM_MultiAttach)
-{
- SmartAttach interface(false);
- RUNNER_ASSERT_MSG(!interface.get()->IsAttached(), "Is attached, but shouldn't be.");
- interface.get()->AttachToThread();
- RUNNER_ASSERT_MSG(interface.get()->IsAttached(), "Isn't attached, but should be.");
- interface.get()->AttachToThread();
- RUNNER_ASSERT_MSG(interface.get()->IsAttached(), "Isn't attached, but should be.");
- interface.get()->DetachFromThread();
- RUNNER_ASSERT_MSG(interface.get()->IsAttached(), "Isn't attached, but should be.");
- interface.get()->DetachFromThread();
- RUNNER_ASSERT_MSG(!interface.get()->IsAttached(), "Is attached, but shouldn't be.");
-}
+++ /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 test_sql_connection.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of sql connection tests
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/db/sql_connection.h>
-#include <dpl/db/naive_synchronization_object.h>
-#include <dpl/shared_ptr.h>
-#include <dpl/log/log.h>
-#include <sstream>
-#include <string>
-#include <cstdlib>
-#include <ctime>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-class AbstractSynchronizationObjectGenerator
-{
-public:
- virtual ~AbstractSynchronizationObjectGenerator() {}
-
- virtual DPL::DB::SqlConnection::SynchronizationObject *Create() = 0;
-};
-
-class NaiveSynchronizationObjectGenerator
- : public AbstractSynchronizationObjectGenerator
-{
-public:
- virtual DPL::DB::SqlConnection::SynchronizationObject *Create()
- {
- return new DPL::DB::NaiveSynchronizationObject();
- }
-};
-
-void MassiveReadWriteTest(AbstractSynchronizationObjectGenerator *generator);
-
-class StressGenerator
- : public DPL::Thread
-{
-private:
- size_t m_prefix;
- std::string m_dbFileName;
- AbstractSynchronizationObjectGenerator *m_generator;
-
-protected:
- virtual int ThreadEntry()
- {
- DPL::DB::SqlConnection connection(
- m_dbFileName,
- DPL::DB::SqlConnection::Flag::None,
- DPL::DB::SqlConnection::Flag::RW,
- m_generator->Create());
-
- DPL::DB::SqlConnection::DataCommandAutoPtr countCommand =
- connection.PrepareDataCommand(
- "SELECT COUNT(*) FROM test WHERE value=?");
-
- for (size_t i = 0; i < 10; ++i)
- {
- std::ostringstream valueStream;
-
- valueStream << "value_";
- valueStream << static_cast<unsigned long>(m_prefix);
- valueStream << "_";
- valueStream << static_cast<unsigned long>(i);
-
- std::string value = valueStream.str();
-
- connection.ExecCommand(
- "INSERT INTO test VALUES ('%s');",
- value.c_str());
-
- countCommand->BindString(1, value.c_str());
-
- RUNNER_ASSERT(countCommand->Step());
-
- RUNNER_ASSERT(countCommand->GetColumnString(0) == "1");
-
- countCommand->Reset();
- }
-
- countCommand.reset();
-
- return 0;
- }
-
-public:
- StressGenerator(size_t prefix,
- const std::string &dbFileName,
- AbstractSynchronizationObjectGenerator *generator)
- : m_prefix(prefix),
- m_dbFileName(dbFileName),
- m_generator(generator)
- {
- }
-};
-
-typedef DPL::SharedPtr<DPL::Thread> ThreadPtr;
-
-void MassiveReadWriteTest(AbstractSynchronizationObjectGenerator *generator)
-{
- std::ostringstream dbFileNameStream;
- dbFileNameStream << "/tmp/dpl_tests_db_";
- dbFileNameStream << rand() << ".db";
-
- std::string dbFileName = dbFileNameStream.str();
-
- LogDebug("Temporary database used: " << dbFileName);
-
- DPL::DB::SqlConnection connection(dbFileName);
- connection.ExecCommand("BEGIN TRANSACTION;");
- connection.ExecCommand("CREATE TABLE test(value TEXT);");
- connection.ExecCommand("COMMIT;");
-
- const size_t STRESS_GENERATOR_COUNT = 5;
- ThreadPtr stressGenerators[STRESS_GENERATOR_COUNT];
-
- for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i)
- {
- stressGenerators[i].Reset(
- new StressGenerator(i, dbFileName, generator));
-
- stressGenerators[i]->Run();
- }
-
- for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i)
- stressGenerators[i]->Quit();
-
- unlink(dbFileName.c_str());
-}
-
-RUNNER_TEST(SqlConnection_MassiveReadWrite_NaiveSynchronization)
-{
- srand(time(NULL));
-
- NaiveSynchronizationObjectGenerator m_generator;
- MassiveReadWriteTest(&m_generator);
-}
+++ /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 CMakeLists.txt
-# @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
-# @version 1.0
-# @brief
-#
-
-INCLUDE(FindPkgConfig)
-
-SET(TARGET_DBUS_TESTS "dpl-tests-dbus")
-SET(TARGET_DBUS_TEST_SERVICE "dpl-dbus-test-service")
-
-PKG_CHECK_MODULES(DBUS_PKG
- ecore
- appcore-efl
- gio-2.0
- gobject-2.0
- REQUIRED
-)
-
-SET(DBUS_TESTS_SRCS
- ${PROJECT_SOURCE_DIR}/tests/dbus/main.cpp
- ${PROJECT_SOURCE_DIR}/tests/dbus/test_cases.cpp
- ${PROJECT_SOURCE_DIR}/tests/dbus/dbus_test.cpp
- ${PROJECT_SOURCE_DIR}/tests/dbus/loop_control.cpp
-)
-
-SET(DBUS_TEST_SERVICE_SRCS
- ${PROJECT_SOURCE_DIR}/tests/dbus/test_service.cpp
- ${PROJECT_SOURCE_DIR}/tests/dbus/loop_control.cpp
-)
-
-INCLUDE_DIRECTORIES(
- ${DBUS_PKG_INCLUDE_DIRS}
- ${DPL_TEST_INCLUDE_DIR}
-)
-
-LINK_DIRECTORIES(${DBUS_PKG_LIBRARY_DIRS})
-
-ADD_EXECUTABLE(${TARGET_DBUS_TESTS}
- ${DBUS_TESTS_SRCS}
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_DBUS_TESTS}
- ${DBUS_PKG_LIBRARIES}
- ${TARGET_DPL_EFL}
- ${TARGET_DPL_DBUS_EFL}
- ${TARGET_DPL_TEST_ENGINE_EFL}
-)
-
-SET_TARGET_PROPERTIES(${TARGET_DBUS_TESTS} PROPERTIES
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-ADD_EXECUTABLE(${TARGET_DBUS_TEST_SERVICE}
- ${DBUS_TEST_SERVICE_SRCS}
-)
-
-TARGET_LINK_LIBRARIES(${TARGET_DBUS_TEST_SERVICE}
- ${DBUS_PKG_LIBRARIES}
- ${TARGET_DPL_EFL}
- ${TARGET_DPL_DBUS_EFL}
-)
-
-SET_TARGET_PROPERTIES(${TARGET_DBUS_TEST_SERVICE} PROPERTIES
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_DBUS_TESTS} ${TARGET_DBUS_TEST_SERVICE}
- DESTINATION bin)
-
-INSTALL(FILES
- ${PROJECT_SOURCE_DIR}/tests/dbus/data/org.tizen.DBusTestService.service
- DESTINATION /usr/share/dbus-1/services
-)
+++ /dev/null
-[D-BUS Service]
-Name=org.tizen.DBusTestService
-Exec=/usr/bin/dpl-dbus-test-service
+++ /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 dbus_test.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @brief Implementation file for DBusTest and DBusTestManager.
- */
-
-#include <dpl/test/test_runner.h>
-#include "loop_control.h"
-#include "dbus_test.h"
-
-DBusTest::DBusTest(const std::string& name)
- : m_name(name),
- m_status(Status::NONE)
-{
-}
-
-void DBusTest::run(unsigned int timeout)
-{
- DPL::Event::ControllerEventHandler<TimeoutEvent>::Touch();
- DPL::Event::ControllerEventHandler<QuitEvent>::Touch();
-
- DPL::Event::ControllerEventHandler<TimeoutEvent>::PostTimedEvent(
- TimeoutEvent(), timeout);
-
- LoopControl::wrt_start_loop();
-
- switch (m_status)
- {
- case Status::FAILED:
- throw DPL::Test::TestRunner::TestFailed(m_name.c_str(),
- __FILE__,
- __LINE__,
- m_message);
-
- default:
- break;
- }
-}
-
-void DBusTest::quit()
-{
- DPL::Event::ControllerEventHandler<QuitEvent>::PostEvent(QuitEvent());
-}
-
-void DBusTest::setStatus(Status status)
-{
- m_status = status;
-}
-
-void DBusTest::setMessage(const std::string& message)
-{
- m_message = message;
-}
-
-void DBusTest::success()
-{
- m_status = Status::SUCCESS;
-}
-
-void DBusTest::fail(const std::string& message)
-{
- m_status = Status::FAILED;
- m_message = message;
-}
-
-void DBusTest::OnEventReceived(const TimeoutEvent& /*event*/)
-{
- fail("Test timed out.");
-
- // Saving one event dispatch since Quit and Timeout work on the same thread.
- LoopControl::wrt_end_loop();
-}
-
-void DBusTest::OnEventReceived(const QuitEvent& /*event*/)
-{
- LoopControl::wrt_end_loop();
-}
-
-DBusTestManager& DBusTestManager::getInstance()
-{
- static DBusTestManager instance;
- return instance;
-}
-
-DBusTestManager::DBusTestManager() : m_test(NULL) { }
-
-DBusTest& DBusTestManager::getCurrentTest() const
-{
- Assert(NULL != m_test && "Test not set.");
-
- return *m_test;
-}
-
-void DBusTestManager::setCurrentTest(DBusTest& test)
-{
- m_test = &test;
-}
-
-void DBusTestManager::clear()
-{
- m_test = NULL;
-}
+++ /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 dbus_test.h
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @brief Header file for DBusTest and DBusTestManager.
- */
-
-#ifndef WRT_TESTS_DBUS_TESTS_DBUS_TEST_H
-#define WRT_TESTS_DBUS_TESTS_DBUS_TEST_H
-
-#include <string>
-#include <dpl/event/controller.h>
-#include <dpl/generic_event.h>
-
-DECLARE_GENERIC_EVENT_0(QuitEvent)
-DECLARE_GENERIC_EVENT_0(TimeoutEvent)
-
-class DBusTest :
- private DPL::Event::Controller<DPL::TypeListDecl<QuitEvent, TimeoutEvent>::Type>
-{
-public:
- enum class Status
- {
- NONE,
- SUCCESS,
- FAILED
- };
-
- explicit DBusTest(const std::string& name);
-
- void run(unsigned int timeout);
- void quit();
-
- void setStatus(Status status);
- void setMessage(const std::string& message);
-
- void success();
- void fail(const std::string& message = std::string());
-
-private:
- void OnEventReceived(const TimeoutEvent& event);
- void OnEventReceived(const QuitEvent& event);
-
- std::string m_name;
- Status m_status;
- std::string m_message;
-};
-
-class DBusTestManager : private DPL::Noncopyable
-{
-public:
- static DBusTestManager& getInstance();
-
- DBusTest& getCurrentTest() const;
- void setCurrentTest(DBusTest& test);
-
- void clear();
-
-private:
- DBusTestManager();
-
- DBusTest* m_test;
-};
-
-#define DBUS_TEST(TestProc) \
- void DBus##TestProc(); \
- RUNNER_TEST(TestProc) \
- { \
- DBusTest test(#TestProc); \
- DBusTestManager::getInstance().setCurrentTest(test); \
- DBus##TestProc(); \
- DBusTestManager::getInstance().clear(); \
- } \
- void DBus##TestProc()
-
-#endif
+++ /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 loop_control.cpp
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @version 1.0
- * @brief This is implementation of EFL version of loop control
- */
-
-#include "loop_control.h"
-#include <dpl/log/log.h>
-
-#include <dpl/framework_efl.h>
-
-#include <glib.h>
-#include <glib-object.h>
-
-
-namespace LoopControl
-{
-void init_loop(int argc, char *argv[])
-{
- (void)argc;
- (void)argv;
- g_type_init();
- g_thread_init(NULL);
-
- LogInfo("Starting");
- elm_init(argc, argv);
-}
-
-void wait_for_wrt_init()
-{
- ecore_main_loop_begin();
-}
-
-void finish_wait_for_wrt_init()
-{
- ecore_main_loop_quit();
-}
-
-void quit_loop()
-{
- elm_shutdown();
-}
-
-void wrt_start_loop()
-{
- ecore_main_loop_begin();
-}
-
-void wrt_end_loop()
-{
- ecore_main_loop_quit();
-}
-
-void *abstract_window()
-{
- return elm_win_add(NULL, "hello", ELM_WIN_BASIC);
-}
-
-}//end of LoopControl namespace
+++ /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 loop_control.cpp
- * @author Jaroslaw Osmanski (j.osmanski@samsung.com)
- * @version 1.0
- * @brief This file is the definitions of loop controlling utilities
- */
-
-
-#ifndef LOOP_CONTROL_H_
-#define LOOP_CONTROL_H_
-
-namespace LoopControl
-{
-
-void init_loop(int argc, char *argv[]);
-void wait_for_wrt_init();
-void finish_wait_for_wrt_init();
-void quit_loop();
-
-void wrt_start_loop();
-void wrt_end_loop();
-
-void *abstract_window();
-
-}
-
-#endif /* LOOP_CONTROL_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.
- */
-/**
- * @file main.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of main.
- */
-
-#include "loop_control.h"
-#include <dpl/test/test_runner.h>
-#include <dpl/log/log.h>
-
-int main(int argc, char *argv[])
-{
- LoopControl::init_loop(argc, argv);
-
- LogInfo("Running tests...");
- int status = DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-
- return status;
-}
+++ /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 TestCases.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief Implementation file for test cases for DBus internal tests.
- */
-
-#include <string>
-#include <dpl/test/test_runner.h>
-#include <dpl/event/event_listener.h>
-#include <dpl/dbus/exception.h>
-#include <dpl/dbus/connection.h>
-#include <dpl/dbus/interface.h>
-#include "dbus_test.h"
-
-namespace {
-const std::string dbusServiceName = "org.freedesktop.DBus";
-const std::string dbusObjectPath = "/";
-const std::string dbusInterfaceName = "org.freedesktop.DBus";
-const std::string dbusMethodGetId = "GetId";
-
-const std::string serviceName = "org.tizen.DBusTestService";
-const std::string objectPath = "/org/tizen/DBusTestService";
-const std::string interfaceName = "org.tizen.DBusTestService";
-const std::string methodNameEcho = "echo";
-const std::string methodNameQuit = "quit";
-const std::string nodeInfo =
- "<?xml version='1.0'?>"
- "<node>"
- " <interface name='" + interfaceName + "'>"
- " <method name='" + methodNameEcho + "'>"
- " <arg type='s' name='challenge' direction='in'/>"
- " <arg type='s' name='response' direction='out'/>"
- " </method>"
- " <method name='" + methodNameQuit + "'>"
- " </method>"
- " </interface>"
- "</node>";
-
-const std::string challenge = "Hello world!";
-
-const int DEFAULT_TIMEOUT = 2; // in seconds
-}
-
-RUNNER_TEST(AcquireSessionBus)
-{
- try
- {
- DPL::DBus::Connection::sessionBus();
- }
- catch (const DPL::DBus::Exception& ex)
- {
- RUNNER_ASSERT_MSG(false, ex.DumpToString());
- }
-}
-
-RUNNER_TEST(AcquireSystemBus)
-{
- try
- {
- DPL::DBus::Connection::systemBus();
- }
- catch (const DPL::DBus::Exception& ex)
- {
- RUNNER_ASSERT_MSG(false, ex.DumpToString());
- }
-}
-
-RUNNER_TEST(ParseNodeInfo)
-{
- try
- {
- auto ifaces = DPL::DBus::Interface::fromXMLString(nodeInfo);
- RUNNER_ASSERT(!ifaces.empty());
-
- auto iface = ifaces.at(0);
- RUNNER_ASSERT(NULL != iface->getVTable());
- RUNNER_ASSERT(NULL != iface->getInfo());
- }
- catch (const DPL::DBus::Exception& ex)
- {
- RUNNER_ASSERT_MSG(false, ex.DumpToString());
- }
-}
-
-RUNNER_TEST(InvokeRemoteMethod)
-{
- try
- {
- auto connection = DPL::DBus::Connection::systemBus();
- auto freedesktop = connection->createObjectProxy(dbusServiceName,
- dbusObjectPath);
- auto getId = freedesktop->createMethodProxy<std::string>
- (dbusInterfaceName, dbusMethodGetId);
- RUNNER_ASSERT(!getId().empty());
- }
- catch (const DPL::DBus::Exception& ex)
- {
- RUNNER_ASSERT_MSG(false, ex.DumpToString());
- }
-}
-
-class RegisterServiceListener :
- public DPL::Event::EventListener<DPL::DBus::ConnectionEvents::ServiceNameAcquiredEvent>
-{
-public:
- void OnEventReceived(
- const DPL::DBus::ConnectionEvents::ServiceNameAcquiredEvent& event)
- {
- DBusTest& test = DBusTestManager::getInstance().getCurrentTest();
-
- auto name = event.GetArg0();
- if (serviceName == name)
- {
- test.success();
- }
- else
- {
- test.fail("Acquired service name: " + name);
- }
- test.quit();
- }
-};
-
-DBUS_TEST(RegisterService)
-{
- try
- {
- RegisterServiceListener listener;
-
- auto connection = DPL::DBus::Connection::sessionBus();
- connection->DPL::Event::EventSupport<DPL::DBus::ConnectionEvents::
- ServiceNameAcquiredEvent>::AddListener(&listener);
- connection->registerService(serviceName);
-
- DBusTestManager::getInstance().getCurrentTest().run(DEFAULT_TIMEOUT);
- }
- catch (const DPL::DBus::Exception& ex)
- {
- RUNNER_ASSERT_MSG(false, ex.DumpToString());
- }
-}
-
-/**
- * This test checks:
- * - object registration (done on the wrt-dbus-test-service side)
- * - service registration (done on the wrt-dbus-test-service side)
- * - dispatching method calls (done on the wrt-dbus-test-service side)
- * - launching dbus service on demand
- * - invoking remote method(s)
- */
-DBUS_TEST(InvokeTestService)
-{
- try
- {
- auto connection = DPL::DBus::Connection::sessionBus();
- auto testService = connection->createObjectProxy(serviceName,
- objectPath);
- auto echo = testService->createMethodProxy<std::string, std::string>
- (interfaceName, methodNameEcho);
- auto response = echo(challenge);
-
- testService->createMethodProxy<void>(interfaceName, methodNameQuit)();
-
- RUNNER_ASSERT_MSG(response == challenge,
- "[challenge = " << challenge <<
- ", response = " << response << "]");
- }
- catch (const DPL::DBus::Exception& ex)
- {
- RUNNER_ASSERT_MSG(false, ex.DumpToString());
- }
-}
+++ /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 test_service.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @brief Implementation file for wrt-dbus-test-service.
- */
-
-#include <string>
-#include <dpl/dbus/connection.h>
-#include <dpl/dbus/object.h>
-#include <dpl/dbus/interface.h>
-#include <dpl/dbus/dispatcher.h>
-#include "loop_control.h"
-
-namespace {
-const std::string serviceName = "org.tizen.DBusTestService";
-const std::string objectPath = "/org/tizen/DBusTestService";
-const std::string interfaceName = "org.tizen.DBusTestService";
-const std::string methodNameEcho = "echo";
-const std::string methodNameQuit = "quit";
-const std::string nodeInfo =
- "<?xml version='1.0'?>"
- "<node>"
- " <interface name='" + interfaceName + "'>"
- " <method name='" + methodNameEcho + "'>"
- " <arg type='s' name='challenge' direction='in'/>"
- " <arg type='s' name='response' direction='out'/>"
- " </method>"
- " <method name='" + methodNameQuit + "'>"
- " </method>"
- " </interface>"
- "</node>";
-}
-
-class TestServiceDispatcher : public DPL::DBus::Dispatcher
-{
-private:
- void onMethodCall(GDBusConnection* /*connection*/,
- const gchar* /*sender*/,
- const gchar* /*objectPath*/,
- const gchar* /*interfaceName*/,
- const gchar* methodName,
- GVariant* parameters,
- GDBusMethodInvocation* invocation)
- {
- if (methodNameEcho == methodName)
- {
- LogDebug("Echo");
- g_dbus_method_invocation_return_value(invocation,
- parameters);
- }
- else if (methodNameQuit == methodName)
- {
- LogDebug("Quit");
- g_dbus_method_invocation_return_value(invocation, NULL);
- LoopControl::wrt_end_loop();
- }
- }
-};
-
-int main(int argc, char* argv[])
-{
- LoopControl::init_loop(argc, argv);
-
- TestServiceDispatcher dispatcher;
-
- auto iface = DPL::DBus::Interface::fromXMLString(nodeInfo).at(0);
- iface->setDispatcher(&dispatcher);
-
- auto object = DPL::DBus::Object::create(objectPath, iface);
-
- auto connection = DPL::DBus::Connection::sessionBus();
- connection->registerObject(object);
- connection->registerService(serviceName);
-
- LoopControl::wrt_start_loop();
-
- return 0;
-}
+++ /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 CMakeLists.txt
-# @author Lukasz Marek (l.marek@samsung.com)
-# @version 1.0
-# @brief
-#
-
-#
-# Test files
-#
-# Define all DPL tests sources.
-# Runner is responsible for runnint it all and
-# generating proper output files
-#
-
-SET(TARGET_NAME "dpl-tests-event")
-
-# Set DPL tests sources
-SET(DPL_TESTS_SOURCES
- ${PROJECT_SOURCE_DIR}/tests/event/main.cpp
- ${PROJECT_SOURCE_DIR}/tests/event/test_controller.cpp
- ${PROJECT_SOURCE_DIR}/tests/event/test_event_support.cpp
- ${PROJECT_SOURCE_DIR}/tests/event/test_ic_delegate.cpp
- ${PROJECT_SOURCE_DIR}/tests/event/test_property.cpp
-)
-
-INCLUDE_DIRECTORIES(
- ${SYS_EFL_INCLUDE_DIRS}
- ${DPL_TEST_INCLUDE_DIR}
-)
-
-LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS})
-
-ADD_EXECUTABLE(${TARGET_NAME} ${DPL_TESTS_SOURCES})
-
-TARGET_LINK_LIBRARIES(
- ${TARGET_NAME}
- ${TARGET_DPL_EFL}
- ${TARGET_DPL_EVENT_EFL}
- ${TARGET_DPL_TEST_ENGINE_EFL}
-)
-
-SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_NAME}
- DESTINATION bin)
+++ /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 main.cpp
- * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of main.
- */
-
-#include <dpl/test/test_runner.h>
-
-int main(int argc, char *argv[])
-{
- return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-}
+++ /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 test_controller.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test controller
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/event/controller.h>
-#include <dpl/thread.h>
-#include <dpl/generic_event.h>
-#include <dpl/waitable_handle.h>
-#include <dpl/waitable_event.h>
-#include <dpl/type_list.h>
-#include <dpl/application.h>
-#include <dpl/atomic.h>
-#include <dpl/scoped_ptr.h>
-#include <dpl/shared_ptr.h>
-#include <list>
-#include <vector>
-RUNNER_TEST_GROUP_INIT(DPL)
-
-class IntController
- : public DPL::Event::Controller<DPL::TypeListDecl<int>::Type>
-{
-private:
- int m_value;
-
-protected:
- virtual void OnEventReceived(const int &event)
- {
- m_value = event;
- }
-
-public:
- IntController()
- : m_value(-1)
- {
- }
-
- int Value() const
- {
- return m_value;
- }
-};
-
-DECLARE_GENERIC_EVENT_1(DoneSignalEvent, DPL::WaitableEvent *)
-
-class ThreadController
- : public DPL::Event::Controller<DPL::TypeListDecl<DoneSignalEvent>::Type>
-{
-private:
- DPL::Thread *m_value;
-
-protected:
- virtual void OnEventReceived(const DoneSignalEvent &event)
- {
- m_value = DPL::Thread::GetCurrentThread();
- event.GetArg0()->Signal();
- }
-
-public:
- ThreadController()
- : m_value(NULL)
- {
- }
-
- DPL::Thread *Value() const
- {
- return m_value;
- }
-};
-
-struct StrangeStruct
-{
- int a;
- float b;
- double c;
-};
-
-class StrangeController
- : public DPL::Event::Controller<DPL::TypeListDecl<char, short, int, long,
- unsigned char, unsigned short, unsigned int, unsigned long,
- float, double, StrangeStruct>::Type>
-{
-protected:
- virtual void OnEventReceived(const char &event) { (void)event; }
- virtual void OnEventReceived(const short &event) { (void)event; }
- virtual void OnEventReceived(const int &event) { (void)event; }
- virtual void OnEventReceived(const long &event) { (void)event; }
- virtual void OnEventReceived(const unsigned char &event) { (void)event; }
- virtual void OnEventReceived(const unsigned short &event) { (void)event; }
- virtual void OnEventReceived(const unsigned int &event) { (void)event; }
- virtual void OnEventReceived(const unsigned long &event) { (void)event; }
- virtual void OnEventReceived(const float &event) { (void)event; }
- virtual void OnEventReceived(const double &event) { (void)event; }
- virtual void OnEventReceived(const StrangeStruct &event) { (void)event; }
-};
-
-RUNNER_TEST(Controller_InitSimple)
-{
- IntController controller;
- controller.Touch();
- RUNNER_ASSERT(controller.Value() == -1);
-}
-
-RUNNER_TEST(Controller_InitStrange)
-{
- StrangeController controller;
- controller.Touch();
-}
-
-RUNNER_TEST(Controller_PostEventToThread)
-{
- ThreadController controller;
- controller.Touch();
-
- DPL::Thread thread;
- thread.Run();
-
- controller.SwitchToThread(&thread);
-
- DPL::WaitableEvent waitHandle;
-
- controller.PostEvent(DoneSignalEvent(&waitHandle));
-
- DPL::WaitForSingleHandle(waitHandle.GetHandle());
-
- controller.SwitchToThread(NULL);
-
- RUNNER_ASSERT(controller.Value() == &thread);
-}
-
-RUNNER_TEST(Controller_PostTimedEventToThread)
-{
- ThreadController controller;
- controller.Touch();
-
- DPL::Thread thread;
- thread.Run();
-
- controller.SwitchToThread(&thread);
-
- DPL::WaitableEvent waitHandle;
-
- controller.PostTimedEvent(DoneSignalEvent(&waitHandle), 0.5);
-
- DPL::WaitForSingleHandle(waitHandle.GetHandle());
-
- controller.SwitchToThread(NULL);
-
- RUNNER_ASSERT(controller.Value() == &thread);
-}
-
-DECLARE_GENERIC_EVENT_2(TouchInThread, DPL::WaitableEvent *, DPL::Thread **)
-DECLARE_GENERIC_EVENT_2(TouchedControllerSignal, DPL::WaitableEvent *, DPL::Thread **)
-
-class TouchInThreadController
- : public DPL::Event::Controller<DPL::TypeListDecl<TouchInThread>::Type>,
- private DPL::Event::Controller<DPL::TypeListDecl<TouchedControllerSignal>::Type>
-{
-public:
- typedef DPL::Event::Controller<DPL::TypeListDecl<TouchInThread>::Type> PublicController;
- typedef DPL::Event::Controller<DPL::TypeListDecl<TouchedControllerSignal>::Type> PrivateController;
-
- virtual void OnEventReceived(const TouchInThread &event)
- {
- // Touch controller in thread
- PrivateController::Touch();
-
- // Post signal
- PrivateController::PostEvent(TouchedControllerSignal(event.GetArg0(), event.GetArg1()));
- }
-
- virtual void OnEventReceived(const TouchedControllerSignal &event)
- {
- // Return touched thread
- *event.GetArg1() = DPL::Thread::GetCurrentThread();
-
- // Signal waitable event
- event.GetArg0()->Signal();
- }
-};
-
-RUNNER_TEST(Controller_TouchInThread)
-{
- TouchInThreadController controller;
- controller.PublicController::Touch();
-
- DPL::Thread thread;
- thread.Run();
-
- controller.PublicController::SwitchToThread(&thread);
-
- DPL::WaitableEvent waitHandle;
- DPL::Thread *touchedThread = NULL;
-
- controller.PublicController::PostEvent(TouchInThread(&waitHandle, &touchedThread));
-
- DPL::WaitForSingleHandle(waitHandle.GetHandle());
-
- controller.PublicController::SwitchToThread(NULL);
-
- RUNNER_ASSERT(touchedThread == &thread);
-}
-
-RUNNER_TEST(Controller_SynchronizedEvent)
-{
- IntController controller;
- controller.Touch();
-
- DPL::Thread thread;
- thread.Run();
-
- controller.SwitchToThread(&thread);
- controller.PostSyncEvent(12345);
- controller.SwitchToThread(NULL);
-
- RUNNER_ASSERT(controller.Value() == 12345);
-}
-
-const int ControllersNumber = 5;
-const int MaxEventsPerController = 1;
-const int MaxEvents = ControllersNumber * MaxEventsPerController;
-const int ControllersPerThread = 1;
-
-class TestController; //Forward Declaration
-
-typedef DPL::SharedPtr<TestController> ControllerPtr;
-typedef DPL::SharedPtr<DPL::Thread> ThreadPtr;
-typedef std::vector<ControllerPtr> ControllerList;
-typedef std::list<ThreadPtr> ThreadList;
-
-DECLARE_GENERIC_EVENT_0(QuitEvent)
-class QuitController
- : public DPL::Event::Controller<DPL::TypeListDecl<QuitEvent>::Type>,
- public DPL::ApplicationExt
-{
-public:
- explicit QuitController( ) : DPL::ApplicationExt(1, NULL, "test-app") { Touch(); }
-protected:
- virtual void OnEventReceived(const QuitEvent &) { Quit(); }
-};
-
-struct TestContext
-{
- ControllerList controllers;
- ThreadList threads;
- QuitController quitter;
- DPL::Atomic g_ReceivedCounter;
- DPL::Atomic g_SentCounter;
-};
-typedef DPL::ScopedPtr<TestContext> TestContextPtr;
-TestContextPtr testContextPtr;
-
-DECLARE_GENERIC_EVENT_0(StartSendEvent)
-DECLARE_GENERIC_EVENT_0(RandomEvent)
-class TestController
- : public DPL::Event::Controller<DPL::TypeListDecl<RandomEvent, StartSendEvent>::Type>
-{
-public:
- explicit TestController() { Touch(); }
-protected:
- virtual void OnEventReceived(const RandomEvent &)
- {
- ++testContextPtr->g_ReceivedCounter;
- if(testContextPtr->g_ReceivedCounter == MaxEvents)
- {
- testContextPtr->quitter.DPL::Event::ControllerEventHandler<QuitEvent>::PostEvent(QuitEvent());
- return;
- }
- }
- virtual void OnEventReceived(const StartSendEvent &)
- {
- for (int i=0 ; i<MaxEventsPerController ;++i)
- {
- if(testContextPtr->g_SentCounter > MaxEvents)
- {
- return;
- }
- ++testContextPtr->g_SentCounter;
- int id = rand() % static_cast<int>(testContextPtr->controllers.size());
- testContextPtr->controllers.at(id)->DPL::Event::ControllerEventHandler<RandomEvent>::PostEvent(RandomEvent());
- }
- }
-};
-
-RUNNER_TEST(Controllers_MultipleEvents)
-{
- srand ( time(NULL) );
-
- testContextPtr.Reset(new TestContext());
- testContextPtr->controllers.reserve(ControllersNumber);
-
- for (int i = 0; i < ControllersNumber ; ++i)
- {
- if(testContextPtr->controllers.size() % ControllersPerThread ==0)
- {
- ThreadPtr thread = ThreadPtr(new DPL::Thread());
- testContextPtr->threads.push_back(thread);
- thread->Run();
- }
-
- ControllerPtr controller = ControllerPtr(new TestController());
- testContextPtr->controllers.push_back(controller);
- if(testContextPtr->controllers.size() % 2 == 0)
- {
- //This controller is being switched to thread (otherwise it is touched to main thread)
- ThreadPtr thread = testContextPtr->threads.back();
- controller->SwitchToThread(thread.Get());
- }
- controller->DPL::Event::ControllerEventHandler<StartSendEvent>::PostEvent(StartSendEvent());
- }
- testContextPtr->quitter.Exec();
- RUNNER_ASSERT(testContextPtr->g_SentCounter == testContextPtr->g_ReceivedCounter);
- testContextPtr.Reset();
-}
+++ /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 test_event_support.cpp
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @version 1.0
- * @brief This file contains test for event support
- */
-
-#include <dpl/test/test_runner.h>
-#include <dpl/generic_event.h>
-#include <dpl/event/event_listener.h>
-#include <dpl/event/event_support.h>
-#include <dpl/application.h>
-#include <dpl/event/controller.h>
-#include <dpl/fast_delegate.h>
-#include <dpl/log/log.h>
-
-DECLARE_GENERIC_EVENT_0(TestEvent)
-
-class TestListener: public DPL::Event::EventListener<TestEvent>
-{
-public:
- explicit TestListener() : m_dummyVar(0) { }
- void OnEventReceived(const TestEvent &) { m_dummyVar = 1; }
- int GetDummyVar() const { return m_dummyVar; }
- void ZeroDummyVar() { m_dummyVar = 0; }
-
-private:
- int m_dummyVar;
-};
-
-class TestEventSupport
- : public DPL::Event::EventSupport<TestEvent>
-{
-public:
- void TestEmitEvent() { EmitEvent(TestEvent()); }
-};
-
-DECLARE_GENERIC_EVENT_0(QuitEvent)
-
-class QuitController
- : public DPL::Event::Controller<DPL::TypeListDecl<QuitEvent>::Type>,
- public DPL::ApplicationExt
-{
-public:
- QuitController() : DPL::ApplicationExt(1, NULL, "test-app") { Touch(); }
-
-protected:
- virtual void OnEventReceived(const QuitEvent &) { Quit(); }
-};
-
-RUNNER_TEST(EventSupport_DestroyBeforeProcessing)
-{
- QuitController quitter;
- quitter.PostTimedEvent(QuitEvent(), 1.0);
-
- TestListener eventListener;
- {
- TestEventSupport eventSupport;
- eventSupport.AddListener(&eventListener);
- eventSupport.TestEmitEvent();
- eventSupport.RemoveListener(&eventListener);
- }
- eventListener.ZeroDummyVar();
-
- quitter.Exec();
- RUNNER_ASSERT(eventListener.GetDummyVar() == 0);
-}
-
-int g_delegateTest;
-
-void OnDelegateTest(const int &k);
-
-void OnDelegateTest(const int &k)
-{
- LogInfo("Got delegate call");
- g_delegateTest = k;
-}
-
-class DelegateTestSupport
- : public DPL::Event::EventSupport<int>
-{
-public:
- void Test()
- {
- EmitEvent(7);
- }
-};
-
-RUNNER_TEST(EventSupport_BindDelegate)
-{
- g_delegateTest = 0;
-
- DelegateTestSupport support;
- support.AddListener(&OnDelegateTest);
-
- QuitController quitter;
- quitter.PostTimedEvent(QuitEvent(), 1.0);
-
- support.Test();
-
- quitter.Exec();
-
- support.RemoveListener(&OnDelegateTest);
-
- RUNNER_ASSERT(g_delegateTest == 7);
-}
+++ /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 test_ic_delegate.cpp
- * @author Pawel Sikorski (p.sikorski@samsung.com)
- * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of fast delegate tests.
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/application.h>
-#include <dpl/event/controller.h>
-#include <dpl/log/log.h>
-#include <dpl/fast_delegate.h>
-#include <dpl/event/inter_context_delegate.h>
-#include <dpl/thread.h>
-#include <dpl/shared_ptr.h>
-#include <dpl/waitable_event.h>
-#include <dpl/assert.h>
-#include <dpl/mutex.h>
-#include <dpl/type_list.h>
-
-RUNNER_TEST_GROUP_INIT(DPL)
-
-const int IntVal = 123;
-const std::string StringVal = "someString";
-
-typedef DPL::Event::ICDelegate<> GetNothingDlpType;
-typedef DPL::Event::ICDelegate<int> GetIntDlgType;
-typedef DPL::Event::ICDelegate<int, std::string> GetIntAndStringDlgType;
-DECLARE_GENERIC_EVENT_1(GetNothingEvent, GetNothingDlpType)
-DECLARE_GENERIC_EVENT_1(GetIntEvent, GetIntDlgType)
-DECLARE_GENERIC_EVENT_1(GetIntAndStringEvent, GetIntAndStringDlgType)
-
-class ICTestController
-: public DPL::Event::Controller<DPL::TypeListDecl<GetNothingEvent,
- GetIntEvent,
- GetIntAndStringEvent>::Type>
-{
- public:
- ICTestController() { }
-
- protected:
- virtual void OnEventReceived(const GetNothingEvent& event)
- {
- event.GetArg0()(); //calling intercontext delegate
- }
- virtual void OnEventReceived(const GetIntEvent& event)
- {
- event.GetArg0()(IntVal); //calling intercontext delegate
- }
-
- virtual void OnEventReceived(const GetIntAndStringEvent& event)
- {
- event.GetArg0()(IntVal, StringVal); //calling intercontext delegate
- }
-};
-
-struct TestResult
-{
- TestResult() :
- m_correctThread0(false),
- m_correctThread1(false),
- m_correctThread2(false),
- m_int(-1),
- m_int2(-1),
- m_string("")
- {
- }
-
- void TestEventsPassed()
- {
- RUNNER_ASSERT(m_correctThread0);
- RUNNER_ASSERT(m_correctThread1);
- RUNNER_ASSERT(m_int == IntVal);
- RUNNER_ASSERT(m_correctThread2);
- RUNNER_ASSERT(m_int2 == IntVal);
- RUNNER_ASSERT(m_string == StringVal);
- }
-
- void TestEventsDidNotPass()
- {
- RUNNER_ASSERT(!m_correctThread0);
- RUNNER_ASSERT(!m_correctThread1);
- RUNNER_ASSERT(m_int == -1);
- RUNNER_ASSERT(!m_correctThread2);
- RUNNER_ASSERT(m_int2 == -1);
- RUNNER_ASSERT(m_string == "");
- }
-
- bool m_correctThread0;
- bool m_correctThread1;
- bool m_correctThread2;
- int m_int;
- int m_int2;
- std::string m_string;
-};
-
-class TestContextFreeClass :
- protected DPL::Thread,
- public DPL::Event::ICDelegateSupport<TestContextFreeClass>
-{
- public:
- TestContextFreeClass(ICTestController* controller, TestResult* result) :
- Thread(),
- m_testResult(result),
- m_controller(controller)
- {
- LogDebug("Context thread id = " << this);
- }
-
- void Run()
- {
- LogDebug("Running Context Free thread");
- Thread::Run();
- }
-
- void Quit()
- {
- LogDebug("Exiting Context Free thread");
- Thread::Quit();
- }
-
-
- void Wait()
- {
- LogDebug("Waiting for thread");
- DPL::WaitForSingleHandle(m_waitable.GetHandle());
- }
-
- protected:
- void OnNothing()
- {
- LogDebug("Received nothing in thread = " << GetCurrentThread());
- m_testResult->m_correctThread0 = (GetCurrentThread() == this);
- }
-
- void OnIntReceive(int val)
- {
- LogDebug("Received int in thread = " << GetCurrentThread());
- m_testResult->m_correctThread1 = (GetCurrentThread() == this);
- m_testResult->m_int = val;
- }
-
- void OnIntAndStringReceive(int val, std::string stringval)
- {
- LogDebug("Received int and string in thread = " << GetCurrentThread());
- m_testResult->m_correctThread2 = (GetCurrentThread() == this);
- m_testResult->m_int2 = val;
- m_testResult->m_string = stringval;
- m_waitable.Signal();
- }
-
- virtual int ThreadEntry()
- {
- GetNothingEvent getNothingEvent(
- makeICDelegate(
- &TestContextFreeClass::OnNothing));
- m_controller->DPL::Event::ControllerEventHandler<GetNothingEvent>::PostEvent(
- getNothingEvent);
-
- GetIntEvent getIntEvent(
- makeICDelegate(
- &TestContextFreeClass::OnIntReceive));
- m_controller->DPL::Event::ControllerEventHandler<GetIntEvent>::PostEvent(
- getIntEvent);
-
- GetIntAndStringEvent getIntAndStringEvent(
- makeICDelegate(
- &TestContextFreeClass::OnIntAndStringReceive));
- m_controller->DPL::Event::ControllerEventHandler<GetIntAndStringEvent>::PostEvent(
- getIntAndStringEvent);
-
- return Thread::ThreadEntry();
- }
-
- private:
- TestResult* m_testResult;
- DPL::WaitableEvent m_waitable;
- ICTestController* m_controller;
-};
-
-RUNNER_TEST(ICDelegate_0)
-{
- DPL::Thread thread;
- thread.Run();
- LogDebug("Controller thread id = " << &thread);
-
- ICTestController testController;
- testController.Touch();
- testController.SwitchToThread(&thread);
-
- TestResult result;
- TestContextFreeClass* contextFree =
- new TestContextFreeClass(&testController, &result);
- result.TestEventsDidNotPass();
-
- thread.Run();
- contextFree->Run();
- contextFree->Wait();
- contextFree->Quit();
- thread.Quit();
-
- delete contextFree;
-
- result.TestEventsPassed();
-}
-
-RUNNER_TEST(ICDelegate_1)
-{
- DPL::Thread thread;
- LogDebug("Controller thread id = " << &thread);
-
- ICTestController testController;
- testController.Touch();
- testController.SwitchToThread(&thread);
-
- TestResult result;
- TestContextFreeClass* contextFree =
- new TestContextFreeClass(&testController, &result);
- result.TestEventsDidNotPass();
-
- contextFree->Run();
- contextFree->Quit();
- delete contextFree; //deleting Delegates before actual Events are worked out
- thread.Run();
- thread.Quit();
-
- result.TestEventsDidNotPass();
-}
-
-class TestContextFree;
-class TestRunnerInThread;
-
-namespace
-{
-const int ControllersPerThread = 40;
-const int ContextFreePerThread = 180;
-const int TestsPerController = 110;
-const int TestThreads = 23;
-const int TestsPerThread = 100;
-const int NumberOfEvents = 230;
-
-typedef DPL::SharedPtr<ICTestController> ICTestControllerPtr;
-typedef DPL::SharedPtr<TestContextFree> TestContextFreePtr;
-typedef DPL::SharedPtr<TestRunnerInThread> TestRunnerInThreadPtr;
-typedef DPL::SharedPtr<DPL::Thread> ThreadPtr;
-
-DPL::Mutex mutex;
-std::list<TestContextFreePtr> frees;
-std::list<ICTestControllerPtr> ctrls;
-std::list<TestRunnerInThreadPtr> frees_threads;
-std::list<ThreadPtr> ctrls_threads;
-
-}
-
-class TestContextFree : public DPL::Event::ICDelegateSupport<TestContextFree>
-{
- public:
- TestContextFree(ICTestController* controller,
- int eventsCount) :
- m_controller(controller),
- m_eventsCount(eventsCount)
- {
- }
-
- void Wait()
- {
- LogDebug("Waiting for thread");
- DPL::WaitForSingleHandle(m_waitable.GetHandle());
- }
-
-
- void OnNothing()
- {
- LogDebug("Got");
- m_eventsCount--;
- if (m_eventsCount > 0) {
- LogDebug("posting next event");
- GetIntAndStringEvent getIntAndStringEvent(
- makeICDelegate(
- &TestContextFree::OnIntAndStringReceive));
- LogDebug("posting next event ...");
- m_controller->DPL::Event::ControllerEventHandler<GetIntAndStringEvent>::PostEvent(
- getIntAndStringEvent);
- LogDebug("posting next event done");
- } else {
- LogDebug("test finished");
- m_waitable.Signal();
- }
- }
-
- void OnIntReceive(int)
- {
- LogDebug("Got");
- m_eventsCount--;
- if (m_eventsCount > 0) {
- LogDebug("posting next event");
- GetNothingEvent getNothingEvent(
- makeICDelegate(
- &TestContextFree::OnNothing));
- LogDebug("posting next event ...");
- m_controller->DPL::Event::ControllerEventHandler<GetNothingEvent>::PostEvent(
- getNothingEvent);
- LogDebug("posting next event done");
- } else {
- LogDebug("test finished");
- m_waitable.Signal();
- }
- }
-
- void OnIntAndStringReceive(int, std::string)
- {
- LogDebug("Got");
- m_eventsCount--;
- if (m_eventsCount > 0) {
- LogDebug("posting next event");
-
- GetIntEvent getIntEvent(
- makeICDelegate(
- &TestContextFree::OnIntReceive));
- LogDebug("posting next event ...");
- m_controller->DPL::Event::ControllerEventHandler<GetIntEvent>::PostEvent(
- getIntEvent);
- LogDebug("posting next event done");
- } else {
- LogDebug("test finished");
- m_waitable.Signal();
- }
- }
-
- void StartTestOnNothing()
- {
- GetNothingEvent getNothingEvent(
- makeICDelegate(
- &TestContextFree::OnNothing));
- m_controller->DPL::Event::ControllerEventHandler<GetNothingEvent>::PostEvent(
- getNothingEvent);
- }
-
- void StartTestOnInt()
- {
- GetIntEvent getIntEvent(
- makeICDelegate(
- &TestContextFree::OnIntReceive));
- m_controller->DPL::Event::ControllerEventHandler<GetIntEvent>::PostEvent(
- getIntEvent);
- }
-
- void StartTestOnIntAndString()
- {
- GetIntAndStringEvent getIntAndStringEvent(
- makeICDelegate(
- &TestContextFree::OnIntAndStringReceive));
- m_controller->DPL::Event::ControllerEventHandler<GetIntAndStringEvent>::PostEvent(
- getIntAndStringEvent);
- }
-
- bool CheckTest()
- {
- LogDebug("Checking test result");
- return m_eventsCount == 0;
- }
-
- private:
- ICTestController* m_controller;
- int m_eventsCount;
- DPL::WaitableEvent m_waitable;
-};
-
-class TestRunnerInThread : public DPL::Thread
-{
- public:
- TestRunnerInThread(int events, int tests) :
- m_eventsCount(events),
- m_tests(tests) {}
-
- void WaitForInit()
- {
- LogDebug("Waiting for thread");
- DPL::WaitForSingleHandle(m_init.GetHandle());
- }
-
- protected:
- virtual int ThreadEntry()
- {
- LogDebug("Thread starts");
- {
- DPL::Mutex::ScopedLock lock(&mutex);
- for (int i = 0; i < m_tests; ++i)
- {
- if (i % TestsPerController == 0) {
- if (ctrls.size() % ControllersPerThread == 0) {
- ThreadPtr thread(new DPL::Thread());
- thread->Run();
- ctrls_threads.push_back(thread);
- }
- ICTestControllerPtr ptr(new ICTestController());
- ptr->Touch();
- ptr->SwitchToThread(ctrls_threads.back().Get());
- ctrls.push_back(ptr);
-
- TestContextFreePtr t(new TestContextFree(ctrls.back().Get(),
- m_eventsCount));
- t->StartTestOnNothing();
- LogDebug("");
- frees.push_back(t);
- }
- }
- }
- m_init.Signal();
- LogDebug("Thread starts loop");
- return DPL::Thread::ThreadEntry();
- }
-
- private:
- DPL::WaitableEvent m_init;
- int m_eventsCount;
- int m_tests;
-};
-
-RUNNER_TEST(ICDelegate_2)
-{
- LogDebug("Creating test threads");
- for (int i = 0; i < TestThreads; ++i)
- {
- TestRunnerInThreadPtr ptr(
- new TestRunnerInThread(NumberOfEvents, TestsPerThread));
- frees_threads.push_back(ptr);
- frees_threads.back()->Run();
- }
-
- FOREACH(it, frees_threads) {
- (*it)->WaitForInit();
- }
- LogDebug("Creating test threads done");
-
- FOREACH(it, frees) {
- LogDebug("...");
- (*it)->Wait();
- }
-
- FOREACH(it, frees) {
- RUNNER_ASSERT((*it)->CheckTest());
- }
-
- frees.clear();
-
- FOREACH(it, frees_threads) {
- (*it)->Quit();
- }
-
- frees_threads.clear();
-
- FOREACH(it, ctrls) {
- (*it)->SwitchToThread(NULL);
- }
-
- FOREACH(it, ctrls_threads) {
- (*it)->Quit();
- }
-
- ctrls.clear();
- ctrls_threads.clear();
-}
-
-namespace ReuseCheck {
-const int ReuseCount = 5;
-typedef DPL::Event::ICDelegate<> GetNothingDlpType;
-DECLARE_GENERIC_EVENT_1(ReuseCountEvent, GetNothingDlpType)
-
-class ICReuseTestController
-: public DPL::Event::Controller<DPL::TypeListDecl<ReuseCountEvent>::Type>
-{
- public:
- ICReuseTestController() { m_reuseCount = 0; }
-
- protected:
- virtual void OnEventReceived(const ReuseCountEvent& event)
- {
- event.GetArg0()(); //calling intercontext delegate
- if(++m_reuseCount < ReuseCount){
- LogInfo("[Send] Reuse: " << m_reuseCount);
- DPL::Event::ControllerEventHandler<ReuseCountEvent>::PostEvent(event);
- }
- }
-
- int m_reuseCount;
-};
-
-class ReuseTestContextFreeClass :
- protected DPL::Thread,
- public DPL::Event::ICDelegateSupport<ReuseTestContextFreeClass>
-{
- public:
- ReuseTestContextFreeClass(ICReuseTestController* controller) :
- Thread(),
- m_controller(controller),
- m_reuseCount(0)
- { }
-
- void Run() { Thread::Run(); }
- void Quit() { Thread::Quit(); }
- void Wait() { DPL::WaitForSingleHandle(m_waitable.GetHandle()); }
-
- protected:
- void OnReuseReceive()
- {
- LogDebug("[Received] : " << ++m_reuseCount);
- if(m_reuseCount == ReuseCount)
- m_waitable.Signal();
- }
-
- virtual int ThreadEntry()
- {
- ReuseCountEvent reuseEvent(
- makeICDelegate(
- &ReuseTestContextFreeClass::OnReuseReceive,
- DPL::Event::ICD::Reuse::Yes));
- m_controller->DPL::Event::ControllerEventHandler<ReuseCountEvent>::PostEvent(
- reuseEvent);
-
- return Thread::ThreadEntry();
- }
-
- private:
- DPL::WaitableEvent m_waitable;
- ICReuseTestController* m_controller;
- int m_reuseCount;
-};
-
-RUNNER_TEST(ICDelegate_3)
-{
- DPL::Thread thread;
- thread.Run();
- LogDebug("Controller thread id = " << &thread);
-
- ICReuseTestController testController;
- testController.Touch();
- testController.SwitchToThread(&thread);
-
- ReuseTestContextFreeClass* contextFree =
- new ReuseTestContextFreeClass(&testController);
-
- thread.Run();
- contextFree->Run();
- contextFree->Wait();
- contextFree->Quit();
- thread.Quit();
-
- delete contextFree;
-
- RUNNER_ASSERT(true);
-}
-} //namespace ReuseCheck
+++ /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 test_property.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of test property
- */
-#include <dpl/test/test_runner.h>
-#include <dpl/event/property.h>
-#include <dpl/event/model.h>
-#include <string>
-
-namespace {
-const int PROPERTY_VALUE_INT = 2;
-const std::string PROPERTY_VALUE_STRING = "aaa";
-}
-
-int ReadSomething2(DPL::Event::Model */*model*/);
-int ReadSomething2(DPL::Event::Model */*model*/)
-{
- return PROPERTY_VALUE_INT;
-}
-
-std::string ReadSomething(DPL::Event::Model */*model*/);
-std::string ReadSomething(DPL::Event::Model */*model*/)
-{
- return PROPERTY_VALUE_STRING;
-}
-
-void WriteSomething(const std::string &/*value*/, DPL::Event::Model */*model*/);
-void WriteSomething(const std::string &/*value*/, DPL::Event::Model */*model*/)
-{
-}
-
-class MyModel
- : public DPL::Event::Model
-{
-public:
- ~MyModel() {}
-
- DPL::Event::Property<std::string>
- Caption;
-
- DPL::Event::Property<std::string>
- Testproperty0;
-
- DPL::Event::Property<std::string, DPL::Event::PropertyReadOnly>
- Testproperty1;
-
- DPL::Event::Property<std::string, DPL::Event::PropertyReadWrite>
- Testproperty2;
-
- DPL::Event::Property<std::string, DPL::Event::PropertyReadWrite,
- DPL::Event::PropertyStorageCached> Testproperty3;
-
- DPL::Event::Property<std::string, DPL::Event::PropertyReadWrite,
- DPL::Event::PropertyStorageDynamic> Testproperty4;
-
- DPL::Event::Property<int, DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> Testproperty5;
-
- MyModel()
- : Caption(this, "Foo caption"),
- Testproperty0(this, "", &ReadSomething),
- Testproperty1(this),
- Testproperty2(this),
- Testproperty3(this),
- Testproperty4(this, "test", &ReadSomething, &WriteSomething),
- Testproperty5(this, &ReadSomething2)
- {
- }
-};
-
-std::string g_caption;
-
-void OnNameChanged(const DPL::Event::PropertyEvent<std::string> &event);
-void OnNameChanged(const DPL::Event::PropertyEvent<std::string> &event)
-{
- g_caption = event.value;
-}
-
-RUNNER_TEST(Model_Test)
-{
- MyModel model;
-
- g_caption = "It is a bad caption";
-
- model.Caption.AddListener(&OnNameChanged);
- model.Caption.Set("Test name");
-
- RUNNER_ASSERT(model.Testproperty4.Get() == PROPERTY_VALUE_STRING);
- RUNNER_ASSERT(PROPERTY_VALUE_INT == model.Testproperty5.Get());
- RUNNER_ASSERT(g_caption == "Test name");
- RUNNER_ASSERT(model.Caption.Get() == "Test name");
-
- model.Caption.RemoveListener(&OnNameChanged);
-}
+++ /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 CMakeLists.txt
-# @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
-# @version 1.0
-# @brief
-#
-
-#
-# Test files
-#
-# Define all DPL tests sources.
-# Runner is responsible for runnint it all and
-# generating proper output files
-#
-
-SET(TARGET_LOC "dpl-tests-loc")
-
-SET(MAIN_DIR ${PROJECT_SOURCE_DIR}/tests/localization)
-
-SET(LOC_TESTS_SOURCES
- ${MAIN_DIR}/test_localization.cpp
- ${MAIN_DIR}/test_suite01.cpp
- ${MAIN_DIR}/mockup_src/widget_dao.cpp
- ${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp
- ${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp
-)
-
-INCLUDE_DIRECTORIES(
- ${SYS_EFL_INCLUDE_DIRS}
- ${DPL_TEST_INCLUDE_DIR}
- ${MAIN_DIR}/mockup_include
- ${PROJECT_SOURCE_DIR}/modules/localization/include
-)
-
-LINK_DIRECTORIES(${SYS_EFL_LIBRARY_DIRS})
-
-ADD_EXECUTABLE(${TARGET_LOC} ${LOC_TESTS_SOURCES})
-
-TARGET_LINK_LIBRARIES(
- ${TARGET_LOC}
- ${SYS_EFL_LIBRARIES}
- ${TARGET_DPL_EFL}
- ${TARGET_DPL_TEST_ENGINE_EFL}
-)
-
-SET_TARGET_PROPERTIES(${TARGET_LOC} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/
- BUILD_WITH_INSTALL_RPATH ON
- INSTALL_RPATH_USE_LINK_PATH ON
-)
-
-INSTALL(TARGETS ${TARGET_LOC}
- DESTINATION bin)
-
-ADD_SUBDIRECTORY(files)
+++ /dev/null
-INSTALL(FILES
- ${PROJECT_SOURCE_DIR}/tests/localization/files/one
- DESTINATION
- /opt/apps/widget/tests/localization/widget1/locales/pl-en
- )
-
-INSTALL(FILES
- ${PROJECT_SOURCE_DIR}/tests/localization/files/one
- ${PROJECT_SOURCE_DIR}/tests/localization/files/two
- DESTINATION
- /opt/apps/widget/tests/localization/widget2/locales/pl-en
- )
-
-INSTALL(FILES
- ${PROJECT_SOURCE_DIR}/tests/localization/files/two
- DESTINATION
- /opt/apps/widget/tests/localization/widget2/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 <dpl/shared_ptr.h>
-
-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 DPL::SharedPtr<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_WAC10, // WAC 1.0
- 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_WAC10)
- 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>
-
-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 pkgName);
-
- /**
- * 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 <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 /* pkgName */)
-{
- 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
+++ /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 main.cpp
- * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
- * @version 1.0
- * @brief This file is the implementation file of main
- */
-#include <dpl/test/test_runner.h>
-
-int main(int argc, char *argv[])
-{
- return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
-}
-
+++ /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.
- */
-
-#include <dpl/log/log.h>
-#include <dpl/test/test_runner.h>
-
-#include <dpl/wrt-dao-rw/widget_dao.h>
-#include <dpl/localization/w3c_file_localization.h>
-
-namespace {
-
-WrtDB::LanguageTagList generateLanguageTags(){
- WrtDB::LanguageTagList tags;
- tags.push_back(L"pl-pl");
- tags.push_back(L"en-en");
- tags.push_back(L"pl-en");
- return tags;
-}
-
-static const WrtDB::LanguageTagList languageTags = generateLanguageTags();
-static const DPL::String widget1Path = L"/opt/apps/widget/tests/localization/widget1/";
-static const DPL::String widget2Path = L"/opt/apps/widget/tests/localization/widget2/";
-
-} // anonymous namespace
-
-RUNNER_TEST(test01_getFilePathInWidgetPackageFromUrl){
- const int widgetHandle = 1;
- WrtDB::WidgetDAO dao(widgetHandle);
- dao.setPath(widget1Path);
-
- auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
- widgetHandle,
- languageTags,
- L"widget://one");
-
- RUNNER_ASSERT(*result == L"/opt/apps/widget/tests/localization/widget1/locales/pl-en/one");
-}
-
-RUNNER_TEST(test02_getFilePathInWidgetPackageFromUrl){
- const int widgetHandle = 2;
- WrtDB::WidgetDAO dao(widgetHandle);
- dao.setPath(widget2Path);
-
- auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
- widgetHandle,
- languageTags,
- L"widget://one");
-
- RUNNER_ASSERT(*result == L"/opt/apps/widget/tests/localization/widget2/locales/pl-en/one");
-}
-
-RUNNER_TEST(test03_getFilePathInWidgetPackageFromUrl){
- const int widgetHandle = 2;
- WrtDB::WidgetDAO dao(widgetHandle);
- dao.setPath(widget2Path);
-
- auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
- widgetHandle,
- languageTags,
- L"widget://two");
-
- RUNNER_ASSERT(*result == L"/opt/apps/widget/tests/localization/widget2/locales/en-en/two");
-}
-
-RUNNER_TEST(test04_getFilePathInWidgetPackage){
- const int widgetHandle = 1;
- WrtDB::WidgetDAO dao(widgetHandle);
- dao.setPath(widget1Path);
-
- auto result = W3CFileLocalization::getFilePathInWidgetPackage(
- widgetHandle,
- languageTags,
- L"one");
-
- RUNNER_ASSERT(*result == L"locales/pl-en/one");
-}
-
-RUNNER_TEST(test05_getFilePathInWidgetPackage){
- const int widgetHandle = 2;
- WrtDB::WidgetDAO dao(widgetHandle);
- dao.setPath(widget2Path);
-
- auto result = W3CFileLocalization::getFilePathInWidgetPackage(
- widgetHandle,
- languageTags,
- L"two");
-
- RUNNER_ASSERT(*result == L"locales/en-en/two");
-}
-