From 69ebfa96994d3fa7db584dc36b0f0aef0de9de68 Mon Sep 17 00:00:00 2001 From: "jihoon.chung" Date: Wed, 22 Aug 2012 23:26:12 +0900 Subject: [PATCH] Update wrt-commons_0.2.53 --- .gitignore | 28 + CMakeLists.txt | 13 +- bin/run_all.sh | 6 - build/CMakeLists.txt | 1 + build/dbus/CMakeLists.txt | 1 + {tests => build/support}/CMakeLists.txt | 20 +- build/support/wrt-plugins-types.pc.in | 11 + build/test/CMakeLists.txt | 2 + debian/changelog | 294 +++++++++ debian/control | 2 +- debian/wrt-commons-test.install | 5 - etc/wrt_commons_reset_db.sh | 54 +- modules/CMakeLists.txt | 1 + modules/auto_save_dao/dao/auto_save_dao.cpp | 34 +- .../auto_save_dao/dao/auto_save_dao_read_only.cpp | 25 +- .../auto-save-dao-ro/auto_save_dao_read_only.h | 3 +- .../wrt-commons/auto-save-dao-rw/auto_save_dao.h | 5 +- .../wrt-commons/auto-save-dao/common_dao_types.h | 33 +- modules/auto_save_dao/orm/autosave_db | 8 +- modules/core/config.cmake | 2 - modules/core/include/dpl/file_input_mapping.h | 73 --- modules/core/include/dpl/semaphore.h | 11 +- modules/core/include/dpl/singleton.h | 40 -- modules/core/include/dpl/task.h | 380 ----------- modules/core/include/dpl/thread.h | 8 +- modules/core/include/dpl/zip_input.h | 93 +-- modules/core/src/file_input_mapping.cpp | 110 ---- modules/core/src/thread.cpp | 5 + modules/core/src/zip_input.cpp | 141 ++-- modules/db/include/dpl/db/orm.h | 369 ++++++++++- modules/db/include/dpl/db/orm_generator.h | 4 +- modules/db/include/dpl/db/sql_connection.h | 8 +- modules/db/src/orm.cpp | 3 +- modules/db/src/sql_connection.cpp | 8 +- modules/event/config.cmake | 2 - modules/event/include/dpl/event/nested_loop.h | 111 ---- modules/event/include/dpl/event/property.h | 8 + modules/event/src/nested_loop.cpp | 120 ---- .../include/dpl/localization/localization_utils.h | 4 - .../dpl/localization/w3c_file_localization.h | 2 +- modules/localization/src/localization_utils.cpp | 55 +- modules/localization/src/w3c_file_localization.cpp | 32 +- modules/popup/include/dpl/popup/popup.h | 2 - modules/popup/include/dpl/popup/popup_controller.h | 12 +- modules/popup/include/dpl/popup/popup_manager.h | 5 +- modules/popup/src/popup_controller.cpp | 4 +- modules/popup/src/popup_renderer.cpp | 4 +- modules/support/config.cmake | 26 + modules/support/wrt_plugin_export.h | 295 +++++++++ modules/test/src/test_results_collector.cpp | 127 ++++ modules/test/src/test_runner.cpp | 2 + modules/utils/config.cmake | 16 +- modules/utils/include/{ => dpl/utils}/file_utils.h | 0 .../utils/include/{ => dpl/utils}/folder_size.h | 0 .../include/{ => dpl/utils}/mime_type_utils.h | 0 modules/utils/include/{ => dpl/utils}/warp_iri.h | 0 .../utils/include/{ => dpl/utils}/widget_version.h | 0 .../include/{ => dpl/utils}/wrt_global_settings.h | 7 +- .../utils/include/{ => dpl/utils}/wrt_utility.h | 0 .../utils/include/wrt_global_settings_internal.h | 35 - modules/utils/src/file_utils.cpp | 2 +- modules/utils/src/folder_size.cpp | 2 +- modules/utils/src/mime_type_utils.cpp | 2 +- modules/utils/src/warp_iri.cpp | 2 +- modules/utils/src/widget_version.cpp | 2 +- modules/utils/src/wrt_global_settings.cpp | 90 ++- modules/utils/src/wrt_global_settings_internal.cpp | 44 -- modules/utils/src/wrt_utility.cpp | 2 +- modules/widget_dao/CMakeLists.txt | 4 - modules/widget_dao/dao/feature_dao.cpp | 46 -- modules/widget_dao/dao/feature_dao_read_only.cpp | 77 ++- modules/widget_dao/dao/global_config.cpp | 39 -- modules/widget_dao/dao/global_dao.cpp | 54 +- modules/widget_dao/dao/global_dao_read_only.cpp | 30 +- modules/widget_dao/dao/plugin_dao.cpp | 8 - modules/widget_dao/dao/plugin_dao_read_only.cpp | 28 - modules/widget_dao/dao/widget_dao.cpp | 58 +- modules/widget_dao/dao/widget_dao_read_only.cpp | 47 +- .../include/dpl/wrt-dao-ro/common_dao_types.h | 57 +- .../include/dpl/wrt-dao-ro/config_parser_data.h | 11 +- .../include/dpl/wrt-dao-ro/feature_dao_read_only.h | 9 +- .../include/dpl/wrt-dao-ro/feature_model.h | 7 + .../include/dpl/wrt-dao-ro/global_config.h | 37 +- .../include/dpl/wrt-dao-ro/global_dao_read_only.h | 9 +- .../include/dpl/wrt-dao-ro/plugin_dao_read_only.h | 4 - .../include/dpl/wrt-dao-ro/widget_dao_read_only.h | 21 +- .../include/dpl/wrt-dao-rw/feature_dao.h | 2 - .../widget_dao/include/dpl/wrt-dao-rw/global_dao.h | 12 +- .../widget_dao/include/dpl/wrt-dao-rw/widget_dao.h | 34 +- modules/widget_dao/orm/wrt_db | 52 +- packaging/wrt-commons.spec | 16 +- tests/core/CMakeLists.txt | 82 --- tests/core/DESCRIPTION | 2 - tests/core/data/sample.zip | Bin 174 -> 0 bytes tests/core/main.cpp | 28 - tests/core/test_address.cpp | 50 -- tests/core/test_binary_queue.cpp | 357 ----------- tests/core/test_fast_delegate.cpp | 248 ------- tests/core/test_foreach.cpp | 118 ---- tests/core/test_log_unhandled_exception.cpp | 74 --- tests/core/test_once.cpp | 103 --- tests/core/test_scoped_array.cpp | 62 -- tests/core/test_scoped_close.cpp | 27 - tests/core/test_scoped_fclose.cpp | 70 -- tests/core/test_scoped_free.cpp | 53 -- tests/core/test_scoped_ptr.cpp | 59 -- tests/core/test_semaphore.cpp | 85 --- tests/core/test_serialization.cpp | 259 -------- tests/core/test_shared_ptr.cpp | 85 --- tests/core/test_string.cpp | 384 ----------- tests/core/test_task.cpp | 93 --- tests/core/test_thread.cpp | 100 --- tests/core/test_type_list.cpp | 41 -- tests/core/test_zip_input.cpp | 98 --- tests/db/CMakeLists.txt | 68 -- tests/db/main.cpp | 28 - tests/db/orm/CMakeLists.txt | 9 - tests/db/orm/dpl_orm_test.db | Bin 16384 -> 0 bytes tests/db/orm/dpl_orm_test_db | 38 -- tests/db/orm/dpl_orm_test_db.sql | 38 -- tests/db/orm/dpl_orm_test_db_definitions | 5 - tests/db/orm/dpl_orm_test_db_sql_generator.h | 27 - tests/db/orm/generator_dpl_orm_test.h | 24 - tests/db/test_orm.cpp | 712 --------------------- tests/db/test_sql_connection.cpp | 155 ----- tests/dbus/CMakeLists.txt | 90 --- tests/dbus/data/org.tizen.DBusTestService.service | 3 - tests/dbus/dbus_test.cpp | 117 ---- tests/dbus/dbus_test.h | 90 --- tests/dbus/loop_control.cpp | 75 --- tests/dbus/loop_control.h | 42 -- tests/dbus/main.cpp | 35 - tests/dbus/test_cases.cpp | 188 ------ tests/dbus/test_service.cpp | 93 --- tests/event/CMakeLists.txt | 62 -- tests/event/main.cpp | 28 - tests/event/test_controller.cpp | 331 ---------- tests/event/test_event_support.cpp | 122 ---- tests/event/test_ic_delegate.cpp | 568 ---------------- tests/event/test_property.cpp | 111 ---- tests/localization/CMakeLists.txt | 68 -- tests/localization/files/CMakeLists.txt | 19 - tests/localization/files/one | 0 tests/localization/files/two | 0 .../dpl/wrt-dao-ro/common_dao_types.h | 487 -------------- .../mockup_include/dpl/wrt-dao-rw/widget_dao.h | 230 ------- tests/localization/mockup_src/widget_dao.cpp | 107 ---- tests/localization/test_localization.cpp | 28 - tests/localization/test_suite01.cpp | 103 --- 149 files changed, 1864 insertions(+), 8193 deletions(-) create mode 100755 .gitignore delete mode 100755 bin/run_all.sh rename {tests => build/support}/CMakeLists.txt (66%) create mode 100644 build/support/wrt-plugins-types.pc.in delete mode 100644 debian/wrt-commons-test.install delete mode 100644 modules/core/include/dpl/file_input_mapping.h delete mode 100644 modules/core/src/file_input_mapping.cpp delete mode 100644 modules/event/include/dpl/event/nested_loop.h delete mode 100644 modules/event/src/nested_loop.cpp create mode 100644 modules/support/config.cmake create mode 100644 modules/support/wrt_plugin_export.h rename modules/utils/include/{ => dpl/utils}/file_utils.h (100%) rename modules/utils/include/{ => dpl/utils}/folder_size.h (100%) rename modules/utils/include/{ => dpl/utils}/mime_type_utils.h (100%) rename modules/utils/include/{ => dpl/utils}/warp_iri.h (100%) rename modules/utils/include/{ => dpl/utils}/widget_version.h (100%) rename modules/utils/include/{ => dpl/utils}/wrt_global_settings.h (90%) rename modules/utils/include/{ => dpl/utils}/wrt_utility.h (100%) delete mode 100644 modules/utils/include/wrt_global_settings_internal.h delete mode 100644 modules/utils/src/wrt_global_settings_internal.cpp mode change 100644 => 100755 modules/widget_dao/dao/feature_dao.cpp delete mode 100644 modules/widget_dao/dao/global_config.cpp mode change 100644 => 100755 modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h delete mode 100644 tests/core/CMakeLists.txt delete mode 100644 tests/core/DESCRIPTION delete mode 100644 tests/core/data/sample.zip delete mode 100644 tests/core/main.cpp delete mode 100644 tests/core/test_address.cpp delete mode 100644 tests/core/test_binary_queue.cpp delete mode 100644 tests/core/test_fast_delegate.cpp delete mode 100644 tests/core/test_foreach.cpp delete mode 100644 tests/core/test_log_unhandled_exception.cpp delete mode 100644 tests/core/test_once.cpp delete mode 100644 tests/core/test_scoped_array.cpp delete mode 100644 tests/core/test_scoped_close.cpp delete mode 100644 tests/core/test_scoped_fclose.cpp delete mode 100644 tests/core/test_scoped_free.cpp delete mode 100644 tests/core/test_scoped_ptr.cpp delete mode 100644 tests/core/test_semaphore.cpp delete mode 100644 tests/core/test_serialization.cpp delete mode 100644 tests/core/test_shared_ptr.cpp delete mode 100644 tests/core/test_string.cpp delete mode 100644 tests/core/test_task.cpp delete mode 100644 tests/core/test_thread.cpp delete mode 100644 tests/core/test_type_list.cpp delete mode 100644 tests/core/test_zip_input.cpp delete mode 100644 tests/db/CMakeLists.txt delete mode 100644 tests/db/main.cpp delete mode 100644 tests/db/orm/CMakeLists.txt delete mode 100644 tests/db/orm/dpl_orm_test.db delete mode 100644 tests/db/orm/dpl_orm_test_db delete mode 100644 tests/db/orm/dpl_orm_test_db.sql delete mode 100644 tests/db/orm/dpl_orm_test_db_definitions delete mode 100644 tests/db/orm/dpl_orm_test_db_sql_generator.h delete mode 100644 tests/db/orm/generator_dpl_orm_test.h delete mode 100644 tests/db/test_orm.cpp delete mode 100644 tests/db/test_sql_connection.cpp delete mode 100644 tests/dbus/CMakeLists.txt delete mode 100644 tests/dbus/data/org.tizen.DBusTestService.service delete mode 100644 tests/dbus/dbus_test.cpp delete mode 100644 tests/dbus/dbus_test.h delete mode 100644 tests/dbus/loop_control.cpp delete mode 100644 tests/dbus/loop_control.h delete mode 100644 tests/dbus/main.cpp delete mode 100644 tests/dbus/test_cases.cpp delete mode 100644 tests/dbus/test_service.cpp delete mode 100644 tests/event/CMakeLists.txt delete mode 100644 tests/event/main.cpp delete mode 100644 tests/event/test_controller.cpp delete mode 100644 tests/event/test_event_support.cpp delete mode 100644 tests/event/test_ic_delegate.cpp delete mode 100644 tests/event/test_property.cpp delete mode 100644 tests/localization/CMakeLists.txt delete mode 100644 tests/localization/files/CMakeLists.txt delete mode 100644 tests/localization/files/one delete mode 100644 tests/localization/files/two delete mode 100644 tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h delete mode 100644 tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h delete mode 100644 tests/localization/mockup_src/widget_dao.cpp delete mode 100644 tests/localization/test_localization.cpp delete mode 100644 tests/localization/test_suite01.cpp diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..415fe75 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +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/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e139d9..e0122e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,14 +34,19 @@ ELSE(DPL_LOG) 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 "========================================") diff --git a/bin/run_all.sh b/bin/run_all.sh deleted file mode 100755 index a245ea7..0000000 --- a/bin/run_all.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -./dpl-tests-core --output=text -./dpl-tests-dbus --output=text -./dpl-tests-db --output=text -./dpl-tests-event --output=text diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 28fa73e..bc09abc 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -30,3 +30,4 @@ ADD_SUBDIRECTORY(widget_dao) ADD_SUBDIRECTORY(auto_save_dao) ADD_SUBDIRECTORY(popup) ADD_SUBDIRECTORY(utils) +ADD_SUBDIRECTORY(support) diff --git a/build/dbus/CMakeLists.txt b/build/dbus/CMakeLists.txt index 1fdda87..a7d0b63 100644 --- a/build/dbus/CMakeLists.txt +++ b/build/dbus/CMakeLists.txt @@ -22,6 +22,7 @@ INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(SYS_EFL_DBUS dbus-1 + gio-2.0 REQUIRED) # Add core include directories diff --git a/tests/CMakeLists.txt b/build/support/CMakeLists.txt similarity index 66% rename from tests/CMakeLists.txt rename to build/support/CMakeLists.txt index f98876f..f0a67a4 100644 --- a/tests/CMakeLists.txt +++ b/build/support/CMakeLists.txt @@ -18,19 +18,9 @@ # @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) diff --git a/build/support/wrt-plugins-types.pc.in b/build/support/wrt-plugins-types.pc.in new file mode 100644 index 0000000..b35b9b4 --- /dev/null +++ b/build/support/wrt-plugins-types.pc.in @@ -0,0 +1,11 @@ +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 diff --git a/build/test/CMakeLists.txt b/build/test/CMakeLists.txt index b0f07b6..52fee02 100644 --- a/build/test/CMakeLists.txt +++ b/build/test/CMakeLists.txt @@ -29,6 +29,7 @@ INCLUDE_DIRECTORIES( ${DPL_LOG_INCLUDE_DIR} ${DPL_CORE_INCLUDE_DIR} ${DPL_TEST_ENGINE_INCLUDE_DIR} + ${DPL_UTILS_INCLUDE_DIR} ${SYS_EFL_TEST_ENGINE_INCLUDE_DIRS} ) @@ -45,6 +46,7 @@ ADD_LIBRARY(${TARGET_DPL_TEST_ENGINE_EFL} SHARED ${DPL_TEST_ENGINE_SOURCES}) TARGET_LINK_LIBRARIES(${TARGET_DPL_TEST_ENGINE_EFL} ${TARGET_DPL_EFL} + ${TARGET_DPL_UTILS_EFL} ) # Target library properties diff --git a/debian/changelog b/debian/changelog index 1b484bc..06e8bfb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,297 @@ +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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 Mon, 19 Mar 2012 13:31:14 +0900 + wrt-commons (0.2.25-1) unstable; urgency=low * Apply changed EFL APIs diff --git a/debian/control b/debian/control index ee7ace9..e8aeeed 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: extra Maintainer: Lukasz Wrzosek, Taejeong.lee Standards-Version: 3.7.2 Uploaders: Yunchan Cho ,Przemyslaw Dobrowolski , Pawel Sikorski , Zbigniew Kostrzewa -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 diff --git a/debian/wrt-commons-test.install b/debian/wrt-commons-test.install deleted file mode 100644 index dfd898d..0000000 --- a/debian/wrt-commons-test.install +++ /dev/null @@ -1,5 +0,0 @@ -/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/* diff --git a/etc/wrt_commons_reset_db.sh b/etc/wrt_commons_reset_db.sh index d6e70f6..3016223 100755 --- a/etc/wrt_commons_reset_db.sh +++ b/etc/wrt_commons_reset_db.sh @@ -14,36 +14,32 @@ # 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 diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index e638768..204fd74 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -32,3 +32,4 @@ ADD_SUBDIRECTORY(auto_save_dao) include(popup/config.cmake) include(utils/config.cmake) include(localization/config.cmake) +include(support/config.cmake) diff --git a/modules/auto_save_dao/dao/auto_save_dao.cpp b/modules/auto_save_dao/dao/auto_save_dao.cpp index 28d4f58..e8f9e82 100644 --- a/modules/auto_save_dao/dao/auto_save_dao.cpp +++ b/modules/auto_save_dao/dao/auto_save_dao.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::autosave; @@ -59,30 +60,30 @@ void AutoSaveDAO::detachDatabase(void) 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 savedData = - getAutoSaveIdPasswd(url); + SubmitFormData submitData = getAutoSaveSubmitFormData(url); + if (!submitData.empty()) { + AUTOSAVE_DB_DELETE(del, + AutoSaveSubmitFormElement, + &m_autoSavedbInterface) + del->Where(Equals(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(url)); - update->Values(row); - update->Execute(); - } else { AUTOSAVE_DB_INSERT( - insert, AutoSaveIdPasswd, &m_autoSavedbInterface); + insert, AutoSaveSubmitFormElement, &m_autoSavedbInterface); insert->Values(row); insert->Execute(); } @@ -92,7 +93,6 @@ void AutoSaveDAO::setAutoSaveIdPasswd(const DPL::String &url, SQL_CONNECTION_EXCEPTION_HANDLER_END( "Fail to register id, passwd for autosave") } - #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN #undef SQL_CONNECTION_EXCEPTION_HANDLER_END diff --git a/modules/auto_save_dao/dao/auto_save_dao_read_only.cpp b/modules/auto_save_dao/dao/auto_save_dao_read_only.cpp index 33a1372..a134fab 100644 --- a/modules/auto_save_dao/dao/auto_save_dao_read_only.cpp +++ b/modules/auto_save_dao/dao/auto_save_dao_read_only.cpp @@ -25,6 +25,7 @@ #include #include #include +#include using namespace DPL::DB::ORM; using namespace DPL::DB::ORM::autosave; @@ -61,23 +62,23 @@ void AutoSaveDAOReadOnly::detachDatabase(void) m_autoSavedbInterface.DetachFromThread(); } -DPL::Optional - 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(url)); - AutoSaveIdPasswd::Select::RowList rows = select->GetRowList(); + AUTOSAVE_DB_SELECT(select, AutoSaveSubmitFormElement, &m_autoSavedbInterface); + select->Where(Equals(url)); + AutoSaveSubmitFormElement::Select::RowList rows = select->GetRowList(); - if (rows.empty()) { - return DPL::Optional::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") } diff --git a/modules/auto_save_dao/include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h b/modules/auto_save_dao/include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h index ac57432..96a665b 100644 --- a/modules/auto_save_dao/include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h +++ b/modules/auto_save_dao/include/wrt-commons/auto-save-dao-ro/auto_save_dao_read_only.h @@ -27,6 +27,7 @@ #include #include +#include #include namespace AutoSaveDB { @@ -55,7 +56,7 @@ class AutoSaveDAOReadOnly /** * This method gets Autofill for Webkit */ - static DPL::Optional getAutoSaveIdPasswd( + static SubmitFormData getAutoSaveSubmitFormData( const DPL::String &url); }; diff --git a/modules/auto_save_dao/include/wrt-commons/auto-save-dao-rw/auto_save_dao.h b/modules/auto_save_dao/include/wrt-commons/auto-save-dao-rw/auto_save_dao.h index 29c9d0f..123d5f1 100644 --- a/modules/auto_save_dao/include/wrt-commons/auto-save-dao-rw/auto_save_dao.h +++ b/modules/auto_save_dao/include/wrt-commons/auto-save-dao-rw/auto_save_dao.h @@ -41,9 +41,8 @@ class AutoSaveDAO : public AutoSaveDAOReadOnly /** * 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 diff --git a/modules/auto_save_dao/include/wrt-commons/auto-save-dao/common_dao_types.h b/modules/auto_save_dao/include/wrt-commons/auto-save-dao/common_dao_types.h index 4a58c25..420725d 100644 --- a/modules/auto_save_dao/include/wrt-commons/auto-save-dao/common_dao_types.h +++ b/modules/auto_save_dao/include/wrt-commons/auto-save-dao/common_dao_types.h @@ -24,15 +24,40 @@ #ifndef SHARE_COMMON_DAO_TYPES_H_ #define SHARE_COMMON_DAO_TYPES_H_ -#include +#include +#include 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 SubmitFormData; } // namespace AutoSaveDB diff --git a/modules/auto_save_dao/orm/autosave_db b/modules/auto_save_dao/orm/autosave_db index f5bf78e..aef6234 100644 --- a/modules/auto_save_dao/orm/autosave_db +++ b/modules/auto_save_dao/orm/autosave_db @@ -2,10 +2,10 @@ SQL( 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( diff --git a/modules/core/config.cmake b/modules/core/config.cmake index 0df7b21..75ec25b 100644 --- a/modules/core/config.cmake +++ b/modules/core/config.cmake @@ -36,7 +36,6 @@ SET(DPL_CORE_SOURCES ${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 @@ -95,7 +94,6 @@ SET(DPL_CORE_HEADERS ${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 diff --git a/modules/core/include/dpl/file_input_mapping.h b/modules/core/include/dpl/file_input_mapping.h deleted file mode 100644 index fd2d206..0000000 --- a/modules/core/include/dpl/file_input_mapping.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include - -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 diff --git a/modules/core/include/dpl/semaphore.h b/modules/core/include/dpl/semaphore.h index 420d9a5..8d51071 100644 --- a/modules/core/include/dpl/semaphore.h +++ b/modules/core/include/dpl/semaphore.h @@ -81,11 +81,18 @@ private: 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 diff --git a/modules/core/include/dpl/singleton.h b/modules/core/include/dpl/singleton.h index 24d2e64..4e5b281 100644 --- a/modules/core/include/dpl/singleton.h +++ b/modules/core/include/dpl/singleton.h @@ -61,46 +61,6 @@ public: static void ResetThreadGuard(); }; -//This is needed for backward compatibility -#ifndef SEPARATED_SINGLETON_IMPLEMENTATION -template -Singleton& Singleton::InternalInstance() -{ - static Singleton instance; - return instance; -} - -template -Class &Singleton::Instance() -{ - Singleton& instance = Singleton::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 -void Singleton::SetThreadGuard(Thread *thread) -{ - Singleton& instance = Singleton::InternalInstance(); - instance.m_guard = OptionalThreadPtr(thread); -} - -template -void Singleton::ResetThreadGuard() -{ - Singleton& instance = Singleton::InternalInstance(); - instance.m_guard = OptionalThreadPtr::Null; -} - -#endif - } // namespace DPL #endif // DPL_SINGLETON_H diff --git a/modules/core/include/dpl/task.h b/modules/core/include/dpl/task.h index 7e43253..84f5b45 100644 --- a/modules/core/include/dpl/task.h +++ b/modules/core/include/dpl/task.h @@ -23,20 +23,11 @@ #ifndef DPL_TASK_H #define DPL_TASK_H -#include #include -#include -#include #include -#include #include -#include #include -#include -#include #include -#include -#include namespace DPL { @@ -159,377 +150,6 @@ public: return static_cast(m_steps.size()); } }; - -template -class MultiTaskDecl - : public Task -{ -protected: - typedef void (ImplementationType::*Step)(); - typedef std::list StepList; - typedef std::stack StepStack; - -private: - static std::string StepToString(Step step) - { - std::ostringstream pseudoAddressStream; - pseudoAddressStream << std::hex << union_cast(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 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 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( - m_unsatisfiedSteps.size() + - m_satisfiedSteps.size() + - m_executingSteps.size() + - m_historicSteps.size()); - } -}; } // namespace DPL #endif // DPL_TASK_H diff --git a/modules/core/include/dpl/thread.h b/modules/core/include/dpl/thread.h index b49ee09..422239d 100644 --- a/modules/core/include/dpl/thread.h +++ b/modules/core/include/dpl/thread.h @@ -172,6 +172,12 @@ public: 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 */ @@ -281,7 +287,7 @@ private: // If yes, pthread_exit(NULL) is required if (!g_TLSforMainCreated) { - if (Thread::GetCurrentThread() == NULL) + if (Thread::IsMainThread()) { g_TLSforMainCreated = true; atexit(&MainThreadExitClean); diff --git a/modules/core/include/dpl/zip_input.h b/modules/core/include/dpl/zip_input.h index f4b8e34..633dbc8 100644 --- a/modules/core/include/dpl/zip_input.h +++ b/modules/core/include/dpl/zip_input.h @@ -50,41 +50,6 @@ public: typedef std::pair 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 @@ -95,69 +60,28 @@ public: 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) { } }; @@ -221,17 +145,6 @@ public: 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 diff --git a/modules/core/src/file_input_mapping.cpp b/modules/core/src/file_input_mapping.cpp deleted file mode 100644 index 2bfcd15..0000000 --- a/modules/core/src/file_input_mapping.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @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 -#include -#include -#include -#include -#include -#include -#include - -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(-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), - 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(address); - - LogPedantic("Created file mapping: " << fileName << - " of size: " << m_size << - " at address: " << std::hex << static_cast(m_address)); -} - -FileInputMapping::~FileInputMapping() -{ - // Close mapping - if (munmap(m_address, static_cast(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 diff --git a/modules/core/src/thread.cpp b/modules/core/src/thread.cpp index ec7166a..0a06b0a 100644 --- a/modules/core/src/thread.cpp +++ b/modules/core/src/thread.cpp @@ -89,6 +89,11 @@ Thread::~Thread() m_eventList.clear(); } +bool Thread::IsMainThread() +{ + return (pthread_equal(pthread_self(), g_mainThread)); +} + Thread *Thread::GetCurrentThread() { if (pthread_equal(pthread_self(), g_mainThread)) diff --git a/modules/core/src/zip_input.cpp b/modules/core/src/zip_input.cpp index d862c01..0245abe 100644 --- a/modules/core/src/zip_input.cpp +++ b/modules/core/src/zip_input.cpp @@ -19,8 +19,13 @@ * @version 1.0 * @brief This file is the implementation file of zip input */ +#include +#include +#include +#include +#include #include -#include +#include #include #include #include @@ -87,7 +92,9 @@ public: class Device { private: - DPL::ScopedPtr m_fileMapping; + int m_handle; + off64_t m_size; // file mapping size + unsigned char *m_address; // mapping base address struct File { @@ -104,30 +111,75 @@ private: 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(-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), + 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(address); + + LogPedantic("Created file mapping: " << fileName << + " of size: " << m_size << + " at address: " << std::hex << static_cast(m_address)); + } - ReThrowMsg(ZipInput::Exception::OpenFailed, - "Failed to open zip file mapping"); + ~Device() + { + // Close mapping + if (munmap(m_address, static_cast(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(opaque); // Open file for master device @@ -143,13 +195,13 @@ public: File *deviceFile = static_cast(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; @@ -162,7 +214,7 @@ public: // Do copy memcpy(buf, - device->m_fileMapping->GetAddress() + deviceFile->offset, + device->m_address + deviceFile->offset, static_cast(bytesToRead)); // Increment file offset @@ -172,25 +224,18 @@ public: return static_cast(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(stream); // Delete file @@ -200,20 +245,14 @@ public: 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(stream); return static_cast(deviceFile->offset); @@ -241,7 +280,7 @@ public: case ZLIB_FILEFUNC_SEEK_END: deviceFile->offset = - device->m_fileMapping->GetSize() - + device->m_size - static_cast(offset); break; @@ -414,25 +453,8 @@ void ZipInput::ReadInfos(void *masterFile) ), std::string(fileName.Get()), std::string(fileComment.Get()), - static_cast(fileInfo.version), - static_cast(fileInfo.version_needed), - static_cast(fileInfo.flag), - static_cast(fileInfo.compression_method), - static_cast(fileInfo.dosDate), - static_cast(fileInfo.crc), static_cast(fileInfo.compressed_size), - static_cast(fileInfo.uncompressed_size), - static_cast(fileInfo.disk_num_start), - static_cast(fileInfo.internal_fa), - static_cast(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(fileInfo.uncompressed_size) ) ); @@ -476,11 +498,6 @@ ZipInput::size_type ZipInput::size() const 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) diff --git a/modules/db/include/dpl/db/orm.h b/modules/db/include/dpl/db/orm.h index f4df084..fa4ea3a 100644 --- a/modules/db/include/dpl/db/orm.h +++ b/modules/db/include/dpl/db/orm.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #ifndef DPL_ORM_H #define DPL_ORM_H @@ -48,6 +50,10 @@ namespace ORM { (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 OptionalString; @@ -60,6 +66,7 @@ namespace RelationTypes { extern const char And[]; extern const char Or[]; extern const char Is[]; + extern const char In[]; //TODO define more relation types } @@ -147,6 +154,8 @@ public: virtual std::string GetString() const { std::string statement; + statement += ColumnData::GetTableName(); + statement += "."; statement += ColumnData::GetColumnName(); statement += " "; statement += Relation; @@ -171,12 +180,279 @@ public: ORM_DEFINE_COMPARE_EXPRESSION(Equals, Equal) ORM_DEFINE_COMPARE_EXPRESSION(Is, Is) +template +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 +CompareBinaryColumn + Equal() +{ + return CompareBinaryColumn(RelationTypes::Equal); +} + +template +class NumerousArguments : public Expression { +protected: + std::set m_argumentList; +public: + NumerousArguments(const std::set& 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 + struct ValidForTable { + typedef typename TableDefinition::ColumnList::template Contains Yes; + }; +}; + +#define ORM_DEFINE_COMPARE_EXPRESSION_NUMEROUS_ARGUMENTS(name, relationType) \ + template \ + class name : public NumerousArguments { \ + public: \ + name(std::set column) : \ + NumerousArguments(column) \ + {} \ + }; + +ORM_DEFINE_COMPARE_EXPRESSION_NUMEROUS_ARGUMENTS(In, In) + template ColumnType GetColumnFromCommand(ColumnIndex columnIndex, DataCommand *command); +class CustomColumnBase { +public: + CustomColumnBase() {} + virtual ~CustomColumnBase() {} +}; + +template +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 +class CustomRowUtil { +public: + static void MakeColumnList(std::vector& columnList) + { + typedef CustomColumn Type; + Type* pColumn = new Type(); + columnList.push_back(pColumn); + CustomRowUtil::MakeColumnList(columnList); + } + + static void CopyColumnList(const std::vector& srcList, std::vector& dstList) + { + CopyColumnList(srcList, dstList, 0); + } + + static ColumnIndex GetColumnIndex(const std::string& columnName) + { + return GetColumnIndex(columnName, 0); + } + +private: + static void CopyColumnList(const std::vector& srcList, std::vector& dstList, ColumnIndex index) + { + typedef CustomColumn Type; + Type* pColumn = new Type(((Type*)(srcList.at(index)))->GetColumnData()); + dstList.push_back(pColumn); + CustomRowUtil::CopyColumnList(srcList, dstList, index + 1); + } + + static ColumnIndex GetColumnIndex(const std::string& columnName, ColumnIndex index) + { + if (ColumnList::Head::GetColumnName() == columnName) + return index; + + return CustomRowUtil::GetColumnIndex(columnName, index + 1); + } + +template +friend class CustomRowUtil; +}; + +template<> +class CustomRowUtil { +public: + static void MakeColumnList(std::vector&) {} +private: + static void CopyColumnList(const std::vector&, std::vector&, ColumnIndex) {} + static ColumnIndex GetColumnIndex(const std::string&, ColumnIndex) { return -1; } + +template +friend class CustomRowUtil; +}; + +template +class CustomRow { +private: + std::vector m_columns; + +public: + CustomRow() + { + CustomRowUtil::MakeColumnList(m_columns); + } + + CustomRow(const CustomRow& r) + { + CustomRowUtil::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 + void SetColumnData(ColumnIndex columnIndex, ColumnType data) + { + typedef CustomColumn Type; + Assert(columnIndex >= 0 && columnIndex < m_columns.size()); + Type* pColumn = dynamic_cast(m_columns.at(columnIndex)); + Assert(pColumn); + pColumn->SetColumnData(data); + } + + template + typename ColumnData::ColumnType GetColumnData() + { + typedef CustomColumn Type; + ColumnIndex index = CustomRowUtil::GetColumnIndex(ColumnData::GetColumnName()); + Assert(index >= 0 && index < m_columns.size()); + Type* pColumn = dynamic_cast(m_columns.at(index)); + Assert(pColumn); + return pColumn->GetColumnData(); + } +}; + +template +void SetColumnData(CustomRow& row, ColumnType columnData, ColumnIndex columnIndex) +{ + row.SetColumnData(columnIndex, columnData); +} + +template +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(columnIndex, command); + SetColumnData(row, columnData, columnIndex); + FillCustomRowUtil::FillCustomRow(row, columnIndex + 1, command); + } + +template +friend class FillCustomRowUtil; +}; + +template +class FillCustomRowUtil { +private: + static void FillCustomRow(CustomRow&, ColumnIndex, DataCommand *) + { /* do nothing, we're past the last element of column list */ } + +template +friend class FillCustomRowUtil; +}; + template 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; @@ -184,13 +460,51 @@ public: ColumnList::Head::SetRowField(row, rowField); FillRowUtil::FillRow(row, columnIndex + 1, command); } + +template +friend class FillRowUtil; }; template class FillRowUtil { -public: +private: static void FillRow(Row&, ColumnIndex, DataCommand *) { /* do nothing, we're past the last element of column list */ } + +template +friend class FillRowUtil; +}; + +template +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::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::GetJoinTableName(tableName); + } +}; + +template<> +class JoinUtil { +public: + static std::string GetColumnNames() { return ""; } + static std::string GetJoinTableName(std::string) { return ""; } }; class Exception { @@ -448,6 +762,7 @@ public: typedef std::list RowList; protected: DPL::Optional m_orderBy; + std::string m_JoinClause; bool m_distinctResults; void Prepare(const char* selectColumnName) @@ -461,6 +776,8 @@ protected: this->m_commandString += " FROM "; this->m_commandString += TableDefinition::GetName(); + this->m_commandString += m_JoinClause; + QueryWithWhereClause::Prepare(); if ( !m_orderBy.IsNull() ) @@ -491,7 +808,15 @@ protected: Row GetRow() { Row row; - FillRowUtil::FillRow(row, 0, this->m_command); + FillRowUtil::FillRow(row, this->m_command); + return row; + } + + template + CustomRow GetCustomRow() + { + CustomRow row; + FillCustomRowUtil::FillCustomRow(row, this->m_command); return row; } @@ -513,6 +838,18 @@ public: m_orderBy = orderBy; } + template + 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::GetJoinTableName(usedTableNames); + this->m_JoinClause += " ON "; + this->m_JoinClause += expression.GetString(); + } + template typename ColumnData::ColumnType GetSingleValue() { @@ -569,6 +906,34 @@ public: this->m_command->Reset(); return resultList; } + + template + CustomRow GetCustomSingleRow() + { + Prepare(JoinUtil::GetColumnNames().c_str()); + Bind(); + this->m_command->Step(); + + CustomRow result = GetCustomRow(); + + this->m_command->Reset(); + return result; + } + + template + std::list GetCustomRowList() + { + Prepare(JoinUtil::GetColumnNames().c_str()); + Bind(); + + std::list resultList; + + while (this->m_command->Step()) + resultList.push_back(GetCustomRow()); + + this->m_command->Reset(); + return resultList; + } }; template diff --git a/modules/db/include/dpl/db/orm_generator.h b/modules/db/include/dpl/db/orm_generator.h index 61ff9ca..f374b8f 100644 --- a/modules/db/include/dpl/db/orm_generator.h +++ b/modules/db/include/dpl/db/orm_generator.h @@ -70,6 +70,7 @@ namespace ORM { #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);} \ }; @@ -269,7 +270,8 @@ namespace ORM { // 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() } diff --git a/modules/db/include/dpl/db/sql_connection.h b/modules/db/include/dpl/db/sql_connection.h index 7110ba8..963ee7e 100644 --- a/modules/db/include/dpl/db/sql_connection.h +++ b/modules/db/include/dpl/db/sql_connection.h @@ -381,8 +381,12 @@ public: 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, }; }; diff --git a/modules/db/src/orm.cpp b/modules/db/src/orm.cpp index 5c7c821..1a4fccf 100644 --- a/modules/db/src/orm.cpp +++ b/modules/db/src/orm.cpp @@ -32,6 +32,7 @@ const char LessThan[] = "<"; const char And[] = "AND"; const char Or[] = "OR"; const char Is[] = "IS"; +const char In[] = "IN"; } template<> @@ -99,4 +100,4 @@ void DataCommandUtils::BindArgument(DataCommand *command, } } -} \ No newline at end of file +} diff --git a/modules/db/src/sql_connection.cpp b/modules/db/src/sql_connection.cpp index ffff2da..f79eabe 100644 --- a/modules/db/src/sql_connection.cpp +++ b/modules/db/src/sql_connection.cpp @@ -598,12 +598,10 @@ void SqlConnection::Connect(const std::string &address, 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(), @@ -739,6 +737,12 @@ void SqlConnection::ExecCommand(const char *format, ...) return; } + if (format == NULL) + { + LogPedantic("Null query!"); + ThrowMsg(Exception::SyntaxError, "Null statement"); + } + char *rawBuffer; va_list args; diff --git a/modules/event/config.cmake b/modules/event/config.cmake index 7bbc84b..313b6a8 100644 --- a/modules/event/config.cmake +++ b/modules/event/config.cmake @@ -29,7 +29,6 @@ SET(DPL_EVENT_SOURCES ${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 ) @@ -43,7 +42,6 @@ SET(DPL_EVENT_HEADERS ${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 diff --git a/modules/event/include/dpl/event/nested_loop.h b/modules/event/include/dpl/event/nested_loop.h deleted file mode 100644 index 7138c8a..0000000 --- a/modules/event/include/dpl/event/nested_loop.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of 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 -#include -#include -#include -#include - -namespace DPL -{ -namespace Event -{ - -class LoopExitEvent -{ -}; - -typedef unsigned LoopHandle; -typedef std::list LoopHandleList; - -const LoopHandle UNDEFINED_LOOP_HANDLE = 0; - -class NestedLoopManager : - protected Controller::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 RunningLoopsList; - typedef RunningLoopsList::iterator RunningLoopsListIterator; - - bool m_eventGuard; // only one event is allowed - LoopHandle m_handle; - RunningLoopsList m_runningLoops; - - friend class Singleton; -}; - -typedef Singleton NestedLoopManagerSingleton; - -} -} // namespace DPL - -#endif // WRT_ENGINE_SRC_COMMON_NESTED_LOOP_H_ diff --git a/modules/event/include/dpl/event/property.h b/modules/event/include/dpl/event/property.h index 33da4df..7c87e50 100644 --- a/modules/event/include/dpl/event/property.h +++ b/modules/event/include/dpl/event/property.h @@ -514,6 +514,14 @@ public: EmitEvent(PropertyEvent(value, this->m_model), EmitMode::Auto); } + + void SetWithoutLock(const Type &value) + { + if (this->m_storage.Get() == value) + return; + + this->m_storage.Set(value); + } }; } diff --git a/modules/event/src/nested_loop.cpp b/modules/event/src/nested_loop.cpp deleted file mode 100644 index c142fd7..0000000 --- a/modules/event/src/nested_loop.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the 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 -#include -#include -#include -#include -#include - -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(); - } -} - -} -} diff --git a/modules/localization/include/dpl/localization/localization_utils.h b/modules/localization/include/dpl/localization/localization_utils.h index 6779fd5..8130838 100644 --- a/modules/localization/include/dpl/localization/localization_utils.h +++ b/modules/localization/include/dpl/localization/localization_utils.h @@ -80,11 +80,7 @@ namespace LocalizationUtils { 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 diff --git a/modules/localization/include/dpl/localization/w3c_file_localization.h b/modules/localization/include/dpl/localization/w3c_file_localization.h index d52bd6c..156923c 100644 --- a/modules/localization/include/dpl/localization/w3c_file_localization.h +++ b/modules/localization/include/dpl/localization/w3c_file_localization.h @@ -22,7 +22,7 @@ #ifndef W3C_FILE_LOCALIZATION_H #define W3C_FILE_LOCALIZATION_H -#include +#include #include #include #include diff --git a/modules/localization/src/localization_utils.cpp b/modules/localization/src/localization_utils.cpp index 9a63800..c463276 100644 --- a/modules/localization/src/localization_utils.cpp +++ b/modules/localization/src/localization_utils.cpp @@ -21,40 +21,11 @@ #include -#include -#include -#include - #include #include -#include - -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; @@ -92,13 +63,9 @@ void UpdateUserAgentLanguageTags() // 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; } @@ -118,15 +85,6 @@ void UpdateUserAgentLanguageTags() 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); @@ -141,15 +99,4 @@ LanguageTagsList GetUserAgentLanguageTags() 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 -} - } diff --git a/modules/localization/src/w3c_file_localization.cpp b/modules/localization/src/w3c_file_localization.cpp index bb41c5d..c0b4161 100644 --- a/modules/localization/src/w3c_file_localization.cpp +++ b/modules/localization/src/w3c_file_localization.cpp @@ -25,7 +25,7 @@ #include -#include +#include #include #include @@ -107,7 +107,7 @@ DPL::Optional getFilePathInWidgetPackageFromUrl( 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()); @@ -141,7 +141,7 @@ DPL::Optional getFilePathInWidgetPackage( const LanguageTagsList &languageTags, const DPL::String& file) { - WidgetDAO dao(widgetHandle); + WidgetDAOReadOnly dao(widgetHandle); return GetFilePathInWidgetPackageInternal(languageTags, dao.getPath(), file); } @@ -149,10 +149,10 @@ DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle widgetHandle) { 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(); @@ -181,10 +181,10 @@ DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle widgetHandle) 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(); @@ -219,8 +219,8 @@ WidgetIconList getValidIconsList( const LanguageTagsList &languageTags) { using namespace LocalizationUtils; - WidgetDAO dao(widgetHandle); - WidgetDAO::WidgetIconList list = dao.getIconList(); + WidgetDAOReadOnly dao(widgetHandle); + WidgetDAOReadOnly::WidgetIconList list = dao.getIconList(); WidgetIconList outlist; @@ -249,10 +249,10 @@ OptionalWidgetStartFileInfo getStartFileInfo( 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) { @@ -269,7 +269,7 @@ OptionalWidgetStartFileInfo getStartFileInfo( 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; @@ -286,7 +286,7 @@ WidgetLocalizedInfo getLocalizedInfo(const WrtDB::DbWidgetHandle handle) { LanguageTagList languages = LocalizationUtils::GetUserAgentLanguageTags(); - WidgetDAO dao(handle); + WidgetDAOReadOnly dao(handle); DPL::OptionalString dl = dao.getDefaultlocale(); if (!!dl) { languages.push_back(*dl); diff --git a/modules/popup/include/dpl/popup/popup.h b/modules/popup/include/dpl/popup/popup.h index 59fd854..e5c926c 100644 --- a/modules/popup/include/dpl/popup/popup.h +++ b/modules/popup/include/dpl/popup/popup.h @@ -30,7 +30,6 @@ #include #include #include -#include namespace DPL { namespace Popup { @@ -40,7 +39,6 @@ struct AnswerCallbackData int buttonAnswer; DPL::Optional password; bool chackState; - DPL::Event::LoopHandle loopHandle; }; class PopupManager; diff --git a/modules/popup/include/dpl/popup/popup_controller.h b/modules/popup/include/dpl/popup/popup_controller.h index 3550b3a..0b49201 100644 --- a/modules/popup/include/dpl/popup/popup_controller.h +++ b/modules/popup/include/dpl/popup/popup_controller.h @@ -75,7 +75,6 @@ #include #include #include -#include #include namespace DPL { @@ -106,10 +105,10 @@ DECLARE_GENERIC_EVENT_3(PopupAnswerEvent, 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, protected DPL::EnableSharedFromThis @@ -128,11 +127,10 @@ class CtrlPopup : public DPL::Event::EventSupport, IPopupPtr m_popup; PopupAnswerCallback m_callback; - DPL::Event::LoopHandle m_loopHandle; }; class PopupController : - public DPL::Event::Controller::Type> + public DPL::Event::Controller::Type> { public: CtrlPopupPtr CreatePopup() const; @@ -148,7 +146,7 @@ class PopupController : void* m_canvas; protected: - virtual void OnEventReceived(const ShowPopupEvent& event); + virtual void OnEventReceived(const ShowPopupEventShort& event); PopupController(); private: diff --git a/modules/popup/include/dpl/popup/popup_manager.h b/modules/popup/include/dpl/popup/popup_manager.h index 512ddd6..267cd14 100644 --- a/modules/popup/include/dpl/popup/popup_manager.h +++ b/modules/popup/include/dpl/popup/popup_manager.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace DPL { namespace Popup { @@ -46,7 +47,9 @@ class PopupManager : DPL::Noncopyable PopupManager() : m_initialized(false) {} ~PopupManager() { - Assert(!m_initialized); + if (m_initialized) { + LogError("Destroyed without Deinitialize"); + } } void Initialize (PopupRendererPtr creator); void Deinitialize(); diff --git a/modules/popup/src/popup_controller.cpp b/modules/popup/src/popup_controller.cpp index e8163be..9f5ac51 100644 --- a/modules/popup/src/popup_controller.cpp +++ b/modules/popup/src/popup_controller.cpp @@ -56,7 +56,6 @@ CtrlPopup::~CtrlPopup() 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::EmitEvent(event); } @@ -71,11 +70,10 @@ CtrlPopupPtr PopupController::CreatePopup() const 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 diff --git a/modules/popup/src/popup_renderer.cpp b/modules/popup/src/popup_renderer.cpp index 716676e..c96fc24 100644 --- a/modules/popup/src/popup_renderer.cpp +++ b/modules/popup/src/popup_renderer.cpp @@ -79,7 +79,9 @@ class PopupRenderer::Impl ~Impl() { - Assert(!m_initialized); + if (m_initialized) { + LogError("Destroyed without Deinitialize"); + } } void Initialize() diff --git a/modules/support/config.cmake b/modules/support/config.cmake new file mode 100644 index 0000000..e2865f6 --- /dev/null +++ b/modules/support/config.cmake @@ -0,0 +1,26 @@ +# 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 +) diff --git a/modules/support/wrt_plugin_export.h b/modules/support/wrt_plugin_export.h new file mode 100644 index 0000000..f57c59e --- /dev/null +++ b/modules/support/wrt_plugin_export.h @@ -0,0 +1,295 @@ +/* + * 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 + +/** + * 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 diff --git a/modules/test/src/test_results_collector.cpp b/modules/test/src/test_results_collector.cpp index 07a6a69..1e65877 100644 --- a/modules/test/src/test_results_collector.cpp +++ b/modules/test/src/test_results_collector.cpp @@ -28,6 +28,8 @@ #include #include +#include +#include namespace DPL { @@ -37,6 +39,7 @@ namespace Test namespace { const char *DEFAULT_HTML_FILE_NAME = "index.html"; +const char *DEFAULT_TAP_FILE_NAME = "results.tap"; class Statistic { @@ -472,6 +475,127 @@ TestResultsCollectorBase* CSVCollector::Constructor() } +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= - 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) @@ -519,6 +643,9 @@ int RegisterCollectorConstructors() TestResultsCollectorBase::RegisterCollectorConstructor( "csv", &CSVCollector::Constructor); + TestResultsCollectorBase::RegisterCollectorConstructor( + "tap", + &TAPCollector::Constructor); return 0; } diff --git a/modules/test/src/test_runner.cpp b/modules/test/src/test_runner.cpp index 8097c23..c53be69 100644 --- a/modules/test/src/test_runner.cpp +++ b/modules/test/src/test_runner.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include IMPLEMENT_SINGLETON(DPL::Test::TestRunner) diff --git a/modules/utils/config.cmake b/modules/utils/config.cmake index 96efba7..4c65949 100644 --- a/modules/utils/config.cmake +++ b/modules/utils/config.cmake @@ -25,7 +25,6 @@ SET(DPL_UTILS_SOURCES ${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 @@ -33,14 +32,13 @@ SET(DPL_UTILS_SOURCES 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 ) diff --git a/modules/utils/include/file_utils.h b/modules/utils/include/dpl/utils/file_utils.h similarity index 100% rename from modules/utils/include/file_utils.h rename to modules/utils/include/dpl/utils/file_utils.h diff --git a/modules/utils/include/folder_size.h b/modules/utils/include/dpl/utils/folder_size.h similarity index 100% rename from modules/utils/include/folder_size.h rename to modules/utils/include/dpl/utils/folder_size.h diff --git a/modules/utils/include/mime_type_utils.h b/modules/utils/include/dpl/utils/mime_type_utils.h similarity index 100% rename from modules/utils/include/mime_type_utils.h rename to modules/utils/include/dpl/utils/mime_type_utils.h diff --git a/modules/utils/include/warp_iri.h b/modules/utils/include/dpl/utils/warp_iri.h similarity index 100% rename from modules/utils/include/warp_iri.h rename to modules/utils/include/dpl/utils/warp_iri.h diff --git a/modules/utils/include/widget_version.h b/modules/utils/include/dpl/utils/widget_version.h similarity index 100% rename from modules/utils/include/widget_version.h rename to modules/utils/include/dpl/utils/widget_version.h diff --git a/modules/utils/include/wrt_global_settings.h b/modules/utils/include/dpl/utils/wrt_global_settings.h similarity index 90% rename from modules/utils/include/wrt_global_settings.h rename to modules/utils/include/dpl/utils/wrt_global_settings.h index 9a51cd1..f012542 100644 --- a/modules/utils/include/wrt_global_settings.h +++ b/modules/utils/include/dpl/utils/wrt_global_settings.h @@ -24,8 +24,11 @@ #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_ */ diff --git a/modules/utils/include/wrt_utility.h b/modules/utils/include/dpl/utils/wrt_utility.h similarity index 100% rename from modules/utils/include/wrt_utility.h rename to modules/utils/include/dpl/utils/wrt_utility.h diff --git a/modules/utils/include/wrt_global_settings_internal.h b/modules/utils/include/wrt_global_settings_internal.h deleted file mode 100644 index ac57956..0000000 --- a/modules/utils/include/wrt_global_settings_internal.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file 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_ diff --git a/modules/utils/src/file_utils.cpp b/modules/utils/src/file_utils.cpp index b7f360b..e5100df 100644 --- a/modules/utils/src/file_utils.cpp +++ b/modules/utils/src/file_utils.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include diff --git a/modules/utils/src/folder_size.cpp b/modules/utils/src/folder_size.cpp index 87646f7..47f8229 100644 --- a/modules/utils/src/folder_size.cpp +++ b/modules/utils/src/folder_size.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include namespace Utils { namespace { diff --git a/modules/utils/src/mime_type_utils.cpp b/modules/utils/src/mime_type_utils.cpp index 988c1a3..82dc544 100644 --- a/modules/utils/src/mime_type_utils.cpp +++ b/modules/utils/src/mime_type_utils.cpp @@ -19,7 +19,7 @@ #include -#include +#include const std::set& MimeTypeUtils::getMimeTypesSupportedForIcon() { diff --git a/modules/utils/src/warp_iri.cpp b/modules/utils/src/warp_iri.cpp index 54c320a..ba633bf 100644 --- a/modules/utils/src/warp_iri.cpp +++ b/modules/utils/src/warp_iri.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/modules/utils/src/widget_version.cpp b/modules/utils/src/widget_version.cpp index 0bf91c1..595f4c1 100644 --- a/modules/utils/src/widget_version.cpp +++ b/modules/utils/src/widget_version.cpp @@ -19,7 +19,7 @@ * @version 1.0 * @brief Implementation file for widget version */ -#include +#include #include #include #include diff --git a/modules/utils/src/wrt_global_settings.cpp b/modules/utils/src/wrt_global_settings.cpp index 8695e8a..a0877f6 100644 --- a/modules/utils/src/wrt_global_settings.cpp +++ b/modules/utils/src/wrt_global_settings.cpp @@ -20,35 +20,85 @@ * @author Lukasz Wrzosek (l.wrzosek@samsung.com) * @brief runtime */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +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 "_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 diff --git a/modules/utils/src/wrt_global_settings_internal.cpp b/modules/utils/src/wrt_global_settings_internal.cpp deleted file mode 100644 index 7940cd1..0000000 --- a/modules/utils/src/wrt_global_settings_internal.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file wrt_global_settings_internal.cpp - * @version 0.6 - * @author Lukasz Wrzosek (l.wrzosek@samsung.com) - */ - -#include -#include -#include -#include - -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 diff --git a/modules/utils/src/wrt_utility.cpp b/modules/utils/src/wrt_utility.cpp index f7ecd7d..756e00c 100644 --- a/modules/utils/src/wrt_utility.cpp +++ b/modules/utils/src/wrt_utility.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include using namespace std; diff --git a/modules/widget_dao/CMakeLists.txt b/modules/widget_dao/CMakeLists.txt index cf1e138..a509ff0 100644 --- a/modules/widget_dao/CMakeLists.txt +++ b/modules/widget_dao/CMakeLists.txt @@ -33,7 +33,6 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wrt_db.sql INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(WRT_DAO_DEPS - cert-svc ecore appcore-efl libxml-2.0 @@ -45,7 +44,6 @@ set(WRT_DAO_RO_SOURCES 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 @@ -62,8 +60,6 @@ set(WRT_DAO_RW_SOURCES 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 diff --git a/modules/widget_dao/dao/feature_dao.cpp b/modules/widget_dao/dao/feature_dao.cpp old mode 100644 new mode 100755 index 60c7151..31979e9 --- a/modules/widget_dao/dao/feature_dao.cpp +++ b/modules/widget_dao/dao/feature_dao.cpp @@ -32,8 +32,6 @@ namespace WrtDB { namespace FeatureDAO { -const int STRANGE_FEATURE_PROPERTIES_ID = 0; - FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature, const DbPluginHandle pluginHandle) { @@ -115,49 +113,5 @@ FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature, } } -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 diff --git a/modules/widget_dao/dao/feature_dao_read_only.cpp b/modules/widget_dao/dao/feature_dao_read_only.cpp index adf11e9..6ce4fd1 100644 --- a/modules/widget_dao/dao/feature_dao_read_only.cpp +++ b/modules/widget_dao/dao/feature_dao_read_only.cpp @@ -76,26 +76,6 @@ FeatureDAOReadOnly::FeatureDAOReadOnly(const std::string &featureName) 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) @@ -319,4 +299,61 @@ FeatureHandleListPtr FeatureDAOReadOnly::GetFeatureHandleListForPlugin( } } +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(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(Equal()); + + DeviceCapabilitiesMap devCap; + + std::list< CustomRow > rowList = select->GetCustomRowList< DevCapNameList, CustomRow >(); + FOREACH(rowIt, rowList) + { + FeatureHandle featureHandle = (*rowIt).GetColumnData(); + std::string devName = DPL::ToUTF8String((*rowIt).GetColumnData()); + devCap.insert(std::pair(featureHandle, devName)); + } + + return devCap; + } + Catch(DPL::DB::SqlConnection::Exception::Base){ + ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError, + "Failure during getting DeviceCapabilities names"); + } +} + } // namespace WrtDB diff --git a/modules/widget_dao/dao/global_config.cpp b/modules/widget_dao/dao/global_config.cpp deleted file mode 100644 index bf68cc4..0000000 --- a/modules/widget_dao/dao/global_config.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include -#include - -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 - diff --git a/modules/widget_dao/dao/global_dao.cpp b/modules/widget_dao/dao/global_dao.cpp index c36fbcc..11bd708 100644 --- a/modules/widget_dao/dao/global_dao.cpp +++ b/modules/widget_dao/dao/global_dao.cpp @@ -29,41 +29,6 @@ #include 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(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); @@ -232,4 +197,23 @@ void GlobalDAO::RemoveWhiteURI(const std::string &uri) } } +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 diff --git a/modules/widget_dao/dao/global_dao_read_only.cpp b/modules/widget_dao/dao/global_dao_read_only.cpp index 88ce51b..f44e8f7 100644 --- a/modules/widget_dao/dao/global_dao_read_only.cpp +++ b/modules/widget_dao/dao/global_dao_read_only.cpp @@ -48,21 +48,6 @@ bool GlobalDAOReadOnly::GetDeveloperMode() } } -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(); - } - 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; @@ -262,4 +247,19 @@ WidgetAccessInfoList GlobalDAOReadOnly::GetWhiteURIList() } } +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(); + } + Catch(DPL::DB::SqlConnection::Exception::Base){ + ReThrowMsg(GlobalDAOReadOnly::Exception::DatabaseError, + "Failed to get Cookie Sharing mode"); + } +} + } // namespace WrtDB diff --git a/modules/widget_dao/dao/plugin_dao.cpp b/modules/widget_dao/dao/plugin_dao.cpp index 7941efb..ea151f6 100644 --- a/modules/widget_dao/dao/plugin_dao.cpp +++ b/modules/widget_dao/dao/plugin_dao.cpp @@ -67,14 +67,6 @@ DbPluginHandle PluginDAO::registerPlugin(const PluginMetafileData& metafile, 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); diff --git a/modules/widget_dao/dao/plugin_dao_read_only.cpp b/modules/widget_dao/dao/plugin_dao_read_only.cpp index edb376d..feb8271 100644 --- a/modules/widget_dao/dao/plugin_dao_read_only.cpp +++ b/modules/widget_dao/dao/plugin_dao_read_only.cpp @@ -185,34 +185,6 @@ std::string PluginDAOReadOnly::getLibraryName() const 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 diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index bc7fcc6..84925ed 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -124,9 +124,10 @@ void WidgetDAO::setPkgName(const DPL::OptionalString& pkgName) 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 @@ -135,16 +136,12 @@ DbWidgetHandle WidgetDAO::registerWidget(const WidgetRegisterInfo &widgetRegInfo //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); @@ -168,8 +165,6 @@ DbWidgetHandle WidgetDAO::registerWidget(const WidgetRegisterInfo &widgetRegInfo registerAppService(widgetHandle, widgetRegInfo); transaction.Commit(); - - return widgetHandle; } SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget") } @@ -196,12 +191,16 @@ void WidgetDAO::registerWidgetExtendedInfo(DbWidgetHandle widgetHandle, 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; @@ -211,6 +210,7 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo(const WidgetRegisterInfo ®Info, // 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); @@ -227,20 +227,23 @@ DbWidgetHandle WidgetDAO::registerWidgetInfo(const WidgetRegisterInfo ®Info, 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, @@ -270,25 +273,6 @@ 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) { diff --git a/modules/widget_dao/dao/widget_dao_read_only.cpp b/modules/widget_dao/dao/widget_dao_read_only.cpp index 02ebd28..9e5f71e 100644 --- a/modules/widget_dao/dao/widget_dao_read_only.cpp +++ b/modules/widget_dao/dao/widget_dao_read_only.cpp @@ -99,6 +99,11 @@ WidgetDAOReadOnly::WidgetDAOReadOnly(DbWidgetHandle widgetHandle) : { } +WidgetDAOReadOnly::WidgetDAOReadOnly(DPL::OptionalString widgetGUID) : + m_widgetHandle(WidgetDAOReadOnly::getHandle(widgetGUID)) +{ +} + WidgetDAOReadOnly::~WidgetDAOReadOnly() { } @@ -630,6 +635,31 @@ time_t WidgetDAOReadOnly::getInstallTime() const 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(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?? @@ -835,10 +865,14 @@ FingerPrintList WidgetDAOReadOnly::getKeyFingerprints( FingerPrintList keys; FOREACH(it, rows) { - DPL::Optional md5 = it->Get_md5_fingerprint(); - keys.push_back(md5.IsNull() ? "" : DPL::ToUTF8String(*md5)); DPL::Optional sha1 = it->Get_sha1_fingerprint(); - keys.push_back(sha1.IsNull() ? "" : DPL::ToUTF8String(*sha1)); + if (!sha1.IsNull()) { + keys.push_back(DPL::ToUTF8String(*sha1)); + } + DPL::Optional md5 = it->Get_md5_fingerprint(); + if (!md5.IsNull()) { + keys.push_back(DPL::ToUTF8String(*md5)); + } } return keys; } @@ -1044,6 +1078,13 @@ void WidgetDAOReadOnly::getAppServiceList( 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(*result)); +} + #undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN #undef SQL_CONNECTION_EXCEPTION_HANDLER_END #undef CHECK_WIDGET_EXISTENCE diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h b/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h index 92adaa6..019953a 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/common_dao_types.h @@ -55,11 +55,6 @@ class PluginMetafileData } std::string m_libraryName; - std::string m_featuresInstallURI; - std::string m_featuresKeyCN; - std::string m_featuresRootCN; - std::string m_featuresRootFingerprint; - FeatureContainer m_featureContainer; }; @@ -87,6 +82,13 @@ class PluginObjectsDAO 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 @@ -217,7 +219,6 @@ typedef std::list DbWidgetHandleList; enum AppType { APP_TYPE_UNKNOWN = 0, // unknown - APP_TYPE_WAC10, // WAC 1.0 APP_TYPE_WAC20, // WAC 2.0 APP_TYPE_TIZENWEBAPP, // Tizen webapp }; @@ -242,7 +243,6 @@ class WidgetType 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 @@ -254,6 +254,49 @@ class WidgetType 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 diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h b/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h index 3cfbfff..9b9b74f 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/config_parser_data.h @@ -189,6 +189,7 @@ class ConfigParserData bool operator!=(const ServiceInfo&) const; }; typedef std::list ServiceInfoList; + typedef std::list DependsPkgList; StringsList nameSpaces; @@ -230,10 +231,16 @@ class ConfigParserData 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), diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h index 9bd8945..75f673e 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h @@ -48,6 +48,8 @@ class FeatureDAOReadOnly }; typedef std::set DeviceCapabilitiesList; + typedef std::multimap DeviceCapabilitiesMap; + typedef std::map NameMap; static bool isDeviceCapabilityInstalled(const std::string &deviceCapName); @@ -62,16 +64,15 @@ class FeatureDAOReadOnly 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; }; diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h index 13b959c..fc40c8a 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_model.h @@ -55,6 +55,13 @@ class FeatureModel : public DPL::Event::Model PHandle(this, -1) { } + + void SetData(const std::string& name, const std::set& deviceCapabilities, const DbPluginHandle& pluginHandle) + { + Name.SetWithoutLock(name); + DeviceCapabilities.SetWithoutLock(deviceCapabilities); + PHandle.SetWithoutLock(pluginHandle); + } }; typedef DPL::SharedPtr FeatureModelPtr; diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h b/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h index 633af64..e5f2fe7 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h @@ -73,7 +73,7 @@ inline const char* GetUserInstalledWidgetPath() */ inline const char* GetWidgetSrcPath() { - return "res/src"; + return "res/wgt"; } /** @@ -138,7 +138,7 @@ inline const char* GetWrtClientExec() */ inline const char* GetUserWidgetDesktopIconPath() { - return "res/icons/default/small"; + return "/opt/share/icons/default/small"; } /** @@ -193,6 +193,22 @@ inline const char* GetPluginMetafileName() } /** + * 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 @@ -220,8 +236,6 @@ inline const char* GetVCoreDatabaseFilePath() { return "/opt/dbspace/.vcore.db"; } -bool IsOCSPEnabled(); -bool IsCRLEnabled(); /** * widgets cookie database file name @@ -248,6 +262,21 @@ inline const char* GetWACVersion() { 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 diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/global_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/global_dao_read_only.h index 50516c5..8442218 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/global_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/global_dao_read_only.h @@ -58,13 +58,6 @@ class GlobalDAOReadOnly 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(); @@ -77,6 +70,8 @@ class GlobalDAOReadOnly static WidgetAccessInfoList GetWhiteURIList(); + static bool GetCookieSharingMode(); + enum NetworkAccessMode { NEVER_CONNECT, diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h index 2341316..33c83b1 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/plugin_dao_read_only.h @@ -104,10 +104,6 @@ class PluginDAOReadOnly 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: diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h index 7b220c1..62fbe6e 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h @@ -154,7 +154,8 @@ struct WidgetRegisterInfo signatureType(SIGNATURE_TYPE_UNIDENTIFIED), isFactoryWidget(0), isTestWidget(0), - configInfo() + configInfo(), + pType(PKG_TYPE_UNKNOWN) { } @@ -171,6 +172,7 @@ struct WidgetRegisterInfo LocalizationData localizationData; DPL::OptionalString pkgname; time_t installedTime; + PkgType pType; }; typedef std::list CertificateChainList; @@ -284,6 +286,7 @@ class WidgetDAOReadOnly * @param[in] widgetHandle application id of widget. */ WidgetDAOReadOnly(DbWidgetHandle widgetHandle); + WidgetDAOReadOnly(DPL::OptionalString widgetGUID); /** * Destructor @@ -685,6 +688,12 @@ class WidgetDAOReadOnly 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; @@ -697,6 +706,16 @@ class WidgetDAOReadOnly */ 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 diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h old mode 100644 new mode 100755 index 94b5cb7..dd98aaf --- a/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/feature_dao.h @@ -31,8 +31,6 @@ namespace WrtDB { namespace FeatureDAO { FeatureHandle RegisterFeature(const PluginMetafileData::Feature &feature, const DbPluginHandle pluginHandle); - - FeatureHandle RegisterStrangeFeature(const std::string& featureName); } // namespace FeatureDB } // namespace WrtDB diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/global_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/global_dao.h index 0beb0be..b624d21 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/global_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/global_dao.h @@ -30,16 +30,6 @@ 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); @@ -66,6 +56,8 @@ class GlobalDAO : public GlobalDAOReadOnly */ static void SetRoamingDataUsage(NetworkAccessMode newMode); + static void SetCookieSharingMode(bool mode); + private: GlobalDAO() { diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h index 356facf..0802046 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h @@ -29,6 +29,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -60,13 +63,31 @@ class WidgetDAO : public WidgetDAOReadOnly * * @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. @@ -99,7 +120,8 @@ class WidgetDAO : public WidgetDAOReadOnly private: //Methods used during widget registering - static DbWidgetHandle registerWidgetInfo( + static void registerWidgetInfo( + const DbWidgetHandle& widgetHandle, const WidgetRegisterInfo ®Info, const IWacSecurity &wacSecurity); static void registerWidgetExtendedInfo( @@ -108,10 +130,6 @@ class WidgetDAO : public WidgetDAOReadOnly 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); diff --git a/modules/widget_dao/orm/wrt_db b/modules/widget_dao/orm/wrt_db index 00b50cc..5ccae07 100644 --- a/modules/widget_dao/orm/wrt_db +++ b/modules/widget_dao/orm/wrt_db @@ -11,6 +11,7 @@ CREATE_TABLE(GlobalProperties) 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( @@ -18,7 +19,7 @@ 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 '') @@ -38,6 +39,7 @@ CREATE_TABLE(WidgetInfo) 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) @@ -56,15 +58,6 @@ CREATE_TABLE(WidgetWindowModes) ) 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,) @@ -92,6 +85,7 @@ CREATE_TABLE(WidgetExtendedInfo) 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 ) @@ -218,10 +212,6 @@ CREATE_TABLE(PluginProperties) 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) @@ -252,10 +242,6 @@ CREATE_TABLE(FeatureDeviceCapProxy) 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,) @@ -311,7 +297,35 @@ CREATE_TABLE(UserAgents) 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( diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec index f71d3ac..f599252 100644 --- a/packaging/wrt-commons.spec +++ b/packaging/wrt-commons.spec @@ -1,7 +1,7 @@ -#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 @@ -14,13 +14,13 @@ BuildRequires: pkgconfig(libssl) 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) @@ -40,9 +40,11 @@ Wrt common library development headers %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 @@ -52,6 +54,12 @@ make %{?jobs:-j%jobs} 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" diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt deleted file mode 100644 index b156962..0000000 --- a/tests/core/CMakeLists.txt +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file 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 -) diff --git a/tests/core/DESCRIPTION b/tests/core/DESCRIPTION deleted file mode 100644 index 48e5394..0000000 --- a/tests/core/DESCRIPTION +++ /dev/null @@ -1,2 +0,0 @@ -!!!options!!! stop -Test code diff --git a/tests/core/data/sample.zip b/tests/core/data/sample.zip deleted file mode 100644 index 02417d89316a2de5eb658decfa83dc60e366c8c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmWIWW@h1H0D-h9e>XlTKgobc3Fe?N{`GRn11vdjD z%L`_pLJ(1sT3iy~&B!FjjLRemkOd5kK)j?8#6mWg6=E)$nE~FcY#^14Ko|g|JwO}= E0Bw;T(f|Me diff --git a/tests/core/main.cpp b/tests/core/main.cpp deleted file mode 100644 index 42ffe3a..0000000 --- a/tests/core/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file main.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main - */ -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} - diff --git a/tests/core/test_address.cpp b/tests/core/test_address.cpp deleted file mode 100644 index 7aff2df..0000000 --- a/tests/core/test_address.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_address.cpp - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test address - */ -#include -#include - -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); -} diff --git a/tests/core/test_binary_queue.cpp b/tests/core/test_binary_queue.cpp deleted file mode 100644 index d955aab..0000000 --- a/tests/core/test_binary_queue.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include -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(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"); -} diff --git a/tests/core/test_fast_delegate.cpp b/tests/core/test_fast_delegate.cpp deleted file mode 100644 index 947cbe5..0000000 --- a/tests/core/test_fast_delegate.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include -#include - -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 MyDelegate; - - // If you want to have a non-void return value, put it at the end. - typedef DPL::FastDelegate2 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); - } - } -} diff --git a/tests/core/test_foreach.cpp b/tests/core/test_foreach.cpp deleted file mode 100644 index f698081..0000000 --- a/tests/core/test_foreach.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_foreach.cpp - * @author Bartosz Janiak (b.janiak@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of foreach tests. - */ - -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -static const size_t testContainerSize = 1024; - -template -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 temporaryList(); -std::list temporaryList() -{ - ++numberOfCallsToTemporaryList; - std::list list; - for (size_t i = 0 ; i < testContainerSize ; i++) - { - list.push_back(i); - } - return list; -} - -static size_t numberOfCallsToTemporaryVector = 0; -std::vector temporaryVector(); -std::vector temporaryVector() -{ - ++numberOfCallsToTemporaryVector; - std::vector vector; - for (size_t i = 0 ; i < testContainerSize ; i++) - { - vector.push_back(i); - } - return vector; -} - -static size_t numberOfCallsToTemporarySet = 0; -std::set temporarySet(); -std::set temporarySet() -{ - ++numberOfCallsToTemporarySet; - std::set set; - for (size_t i = 0 ; i < testContainerSize ; i++) - { - set.insert(i); - } - return set; -} - -RUNNER_TEST(Foreach_std_containers) -{ - std::vector vector; - std::list list; - std::set 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); -} diff --git a/tests/core/test_log_unhandled_exception.cpp b/tests/core/test_log_unhandled_exception.cpp deleted file mode 100644 index 0403c28..0000000 --- a/tests/core/test_log_unhandled_exception.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_log_unhandled_exception.cpp - * @author Pawel Sikorski (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief - */ -#include -#include -#include - -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); -} diff --git a/tests/core/test_once.cpp b/tests/core/test_once.cpp deleted file mode 100644 index e65ea9b..0000000 --- a/tests/core/test_once.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_once.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of once tests - */ -#include -#include -#include -#include -#include -#include -#include - -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 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); -} diff --git a/tests/core/test_scoped_array.cpp b/tests/core/test_scoped_array.cpp deleted file mode 100644 index 58b0603..0000000 --- a/tests/core/test_scoped_array.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ScopedArray_Zero) -{ - DPL::ScopedArray array; - - RUNNER_ASSERT(!array); - RUNNER_ASSERT(!!!array); -} - -RUNNER_TEST(ScopedArray_NonZero) -{ - DPL::ScopedArray array(new char[7]); - - RUNNER_ASSERT(array); - RUNNER_ASSERT(!!array); -} - -RUNNER_TEST(ScopedArray_Reset) -{ - DPL::ScopedArray array(new char[7]); - array.Reset(); - - RUNNER_ASSERT(!array); - - array.Reset(new char); - RUNNER_ASSERT(array); -} - -RUNNER_TEST(ScopedArray_ArrayOperator) -{ - DPL::ScopedArray array(new char[7]); - - array[1] = array[2] = 3; - - RUNNER_ASSERT(array[1] == 3); - RUNNER_ASSERT(array[2] == 3); -} diff --git a/tests/core/test_scoped_close.cpp b/tests/core/test_scoped_close.cpp deleted file mode 100644 index 3549fed..0000000 --- a/tests/core/test_scoped_close.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -// DUNNO diff --git a/tests/core/test_scoped_fclose.cpp b/tests/core/test_scoped_fclose.cpp deleted file mode 100644 index dbdff95..0000000 --- a/tests/core/test_scoped_fclose.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*! - * @file 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 -#include - -#include -#include - -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); -} - diff --git a/tests/core/test_scoped_free.cpp b/tests/core/test_scoped_free.cpp deleted file mode 100644 index bc41a5a..0000000 --- a/tests/core/test_scoped_free.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ScopedFree_Zero) -{ - DPL::ScopedFree free; - - RUNNER_ASSERT(!free); - RUNNER_ASSERT(!!!free); -} - -RUNNER_TEST(ScopedFree_NonZero) -{ - DPL::ScopedFree free(malloc(7)); - - RUNNER_ASSERT(free); - RUNNER_ASSERT(!!free); -} - -RUNNER_TEST(ScopedFree_Reset) -{ - DPL::ScopedFree free(malloc(7)); - free.Reset(); - - RUNNER_ASSERT(!free); - - free.Reset(malloc(8)); - RUNNER_ASSERT(free); -} diff --git a/tests/core/test_scoped_ptr.cpp b/tests/core/test_scoped_ptr.cpp deleted file mode 100644 index f3a7237..0000000 --- a/tests/core/test_scoped_ptr.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(ScopedPtr_Zero) -{ - DPL::ScopedPtr ptr; - - RUNNER_ASSERT(!ptr); - RUNNER_ASSERT(!!!ptr); -} - -RUNNER_TEST(ScopedPtr_NonZero) -{ - DPL::ScopedPtr ptr(new char(7)); - - RUNNER_ASSERT(ptr); - RUNNER_ASSERT(!!ptr); -} - -RUNNER_TEST(ScopedPtr_Reset) -{ - DPL::ScopedPtr ptr(new char(7)); - ptr.Reset(); - - RUNNER_ASSERT(!ptr); - - ptr.Reset(new char); - RUNNER_ASSERT(ptr); -} - -RUNNER_TEST(ScopedPtr_Operators) -{ - DPL::ScopedPtr ptr(new char(7)); - - RUNNER_ASSERT(*ptr == *ptr.Get()); -} diff --git a/tests/core/test_semaphore.cpp b/tests/core/test_semaphore.cpp deleted file mode 100644 index 854978e..0000000 --- a/tests/core/test_semaphore.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_semaphore.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of semaphore tests - */ -#include -#include -#include -#include -#include -#include -#include - -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::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); -} diff --git a/tests/core/test_serialization.cpp b/tests/core/test_serialization.cpp deleted file mode 100644 index 8776fc8..0000000 --- a/tests/core/test_serialization.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_address.cpp - * @author Tomasz Swierczek (t.swierczek@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of serialization tests - */ - -#include -#include -#include -#include - -#include -#include - -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 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 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 vec; - vec.push_back(134); - vec.push_back(265); - std::list list; - list.push_back(true); - list.push_back(false); - std::pair pair; - pair.first = -23; - pair.second = 1234; - std::map map; - map.insert(std::pair(45, "ALA MA CZARNEGO KOTA")); - map.insert(std::pair(-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 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 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 test_pair; - DPL::Deserialization::Deserialize(stream,test_pair); - RUNNER_ASSERT(test_pair.first == pair.first && - test_pair.second == pair.second); - std::map 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 > map; - std::vector 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 >("KEY1",vec)); - map.insert(std::pair >("KEY2",vec)); - BinaryStream stream; - - DPL::Serialization::Serialize(stream, map); - - std::map > test_map; - DPL::Deserialization::Deserialize(stream,test_map); - RUNNER_ASSERT(map.size() == test_map.size()); - std::vector 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])); - } -} - diff --git a/tests/core/test_shared_ptr.cpp b/tests/core/test_shared_ptr.cpp deleted file mode 100644 index 541a333..0000000 --- a/tests/core/test_shared_ptr.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(SharedPtr_Zero) -{ - DPL::SharedPtr ptr; - - RUNNER_ASSERT(!ptr); - RUNNER_ASSERT(!!!ptr); - RUNNER_ASSERT(ptr == DPL::SharedPtr()); -} - -RUNNER_TEST(SharedPtr_NonZero) -{ - DPL::SharedPtr ptr(new char(7)); - - RUNNER_ASSERT(ptr); - RUNNER_ASSERT(!!ptr); - RUNNER_ASSERT(ptr != DPL::SharedPtr()); -} - -RUNNER_TEST(SharedPtr_Copy) -{ - DPL::SharedPtr ptr1(new char(7)); - DPL::SharedPtr ptr2(new char(7)); - - RUNNER_ASSERT(ptr1 != ptr2); - - ptr2 = ptr1; - - RUNNER_ASSERT(ptr1 == ptr2); -} - -RUNNER_TEST(SharedPtr_Reset) -{ - DPL::SharedPtr ptr(new char(7)); - ptr.Reset(); - - RUNNER_ASSERT(!ptr); - - ptr.Reset(new char); - RUNNER_ASSERT(ptr); -} - -RUNNER_TEST(SharedPtr_RefCounting) -{ - DPL::SharedPtr ptr1(new char(7)); - DPL::SharedPtr ptr2; - - ptr2 = ptr1; - - RUNNER_ASSERT(ptr1 == ptr2); - RUNNER_ASSERT(ptr1.GetUseCount() == ptr2.GetUseCount()); - RUNNER_ASSERT(ptr1.GetUseCount() == 2); -} - -RUNNER_TEST(SharedPtr_Operators) -{ - DPL::SharedPtr ptr(new char(7)); - - RUNNER_ASSERT(*ptr == *ptr.Get()); -} diff --git a/tests/core/test_string.cpp b/tests/core/test_string.cpp deleted file mode 100644 index dea0a22..0000000 --- a/tests/core/test_string.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_string.cpp - * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of string tests - */ -#include -#include -#include -#include -#include -#include -#include - -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(&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 -void String_TokenizeReal(const DelimiterType& delimiter) -{ - DPL::String str(L".##..abc.#."); - std::vector tokens; - DPL::Tokenize(str, delimiter, std::back_inserter(tokens)); - - std::vector 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 tokens; - DPL::Tokenize(std::string("abc.def"), '.', std::back_inserter(tokens)); - std::vector expectedTokens; - expectedTokens.push_back("abc"); - expectedTokens.push_back("def"); - - RUNNER_ASSERT(tokens == expectedTokens); -} - -template -void TestInStreams( - std::basic_string argumentInString, - std::basic_string argumentResultString) -{ - typedef std::basic_string - String; - std::basic_istringstream - 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 -void TestOutStreams( - std::basic_string argumentInString, - std::basic_string argumentResultString) -{ - typedef std::basic_string - String; - - std::basic_ostringstream - 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 >("1 1.1 1.1 test", "test"); - TestInStreams >(L"1 1.1 1.1 test", L"test"); - TestInStreams(L"1 1.1 1.1 test", L"test"); - TestOutStreams >("test", "11.11.1test"); - TestOutStreams >(L"test", L"11.11.1test"); - TestOutStreams(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); -} - diff --git a/tests/core/test_task.cpp b/tests/core/test_task.cpp deleted file mode 100644 index 4ad00c3..0000000 --- a/tests/core/test_task.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_task.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of task tests - */ -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -class MySingleTask - : public DPL::TaskDecl -{ -protected: - void StepOne() - { - } - -public: - MySingleTask() - : DPL::TaskDecl(this) - { - AddStep(&MySingleTask::StepOne); - } -}; - -class MyMultiTask - : public DPL::MultiTaskDecl -{ -protected: - typedef DPL::MultiTaskDecl 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()); -} diff --git a/tests/core/test_thread.cpp b/tests/core/test_thread.cpp deleted file mode 100644 index 202d468..0000000 --- a/tests/core/test_thread.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_thread.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of thread tests - */ -#include -#include -#include - -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 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()); -} diff --git a/tests/core/test_type_list.cpp b/tests/core/test_type_list.cpp deleted file mode 100644 index 98167f3..0000000 --- a/tests/core/test_type_list.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file test_type_list.cpp - * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com) - * @version 0.1 - * @brief - */ - -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -RUNNER_TEST(TypeList_TypeCount) -{ - typedef DPL::TypeListDecl::Type TestTypeList1; - typedef DPL::TypeListDecl::Type TestTypeList2; - typedef DPL::TypeListDecl<>::Type TestTypeList3; - typedef DPL::TypeList 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); -} diff --git a/tests/core/test_zip_input.cpp b/tests/core/test_zip_input.cpp deleted file mode 100644 index 9498e76..0000000 --- a/tests/core/test_zip_input.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include -#include -#include -#include -#include -#include -#include -#include - -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 data(new char[buffer.Size() + 1]); - buffer.Flatten(data.Get(), buffer.Size()); - data[buffer.Size()] = '\0'; - - RUNNER_ASSERT(std::string(data.Get()) == "test"); -} diff --git a/tests/db/CMakeLists.txt b/tests/db/CMakeLists.txt deleted file mode 100644 index 3035f1d..0000000 --- a/tests/db/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file 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 -) diff --git a/tests/db/main.cpp b/tests/db/main.cpp deleted file mode 100644 index 4ed6191..0000000 --- a/tests/db/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file main.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main. - */ - -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} diff --git a/tests/db/orm/CMakeLists.txt b/tests/db/orm/CMakeLists.txt deleted file mode 100644 index 5526a76..0000000 --- a/tests/db/orm/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ - -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 ) diff --git a/tests/db/orm/dpl_orm_test.db b/tests/db/orm/dpl_orm_test.db deleted file mode 100644 index 6c3d768e1ce403afaa09a48ef6cafc1567e2c934..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI&!A`_*=d5wp z=B!?4eju4Y^1S8$tILk&H%%%o?!2hl=Z<|*Ijpkk)XikAT8+MH@wS@66LQgIxYUwc z42!96lqNRX@`qv|e_mI(%p^A&7E|8nY&KUzKLP>}fB*y_009U<00Izz00bZaffW{* z&HuXjM$9ks!+ci>0s;_#00bZa0SG_<0uX=z1Rwx`^avDnLw$} zY - -#include "dpl_orm_test_db_definitions" diff --git a/tests/db/orm/generator_dpl_orm_test.h b/tests/db/orm/generator_dpl_orm_test.h deleted file mode 100644 index 39bb1b7..0000000 --- a/tests/db/orm/generator_dpl_orm_test.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#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 -#undef ORM_GENERATOR_DATABASE_NAME - -#endif diff --git a/tests/db/test_orm.cpp b/tests/db/test_orm.cpp deleted file mode 100644 index ddcbe79..0000000 --- a/tests/db/test_orm.cpp +++ /dev/null @@ -1,712 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include - -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 -bool ContainerContentsEqual(const ContainerType1& container1, const ContainerType2& container2) -{ - using namespace DPL::DB::ORM::dpl_orm_test::TestTableInsert; - typedef std::set Set1; - typedef std::set 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 -std::list makeList(const T& a, const T& b) -{ - std::list 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(8)); - int result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - DPL::String result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == L"seven", "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 8, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 9, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - DPL::String result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == L"ten", "Got " << result); - } - - //Where on each column - { - TestTable::Select select(interface.get()); - select.Where(Equals(6)); - int result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(DPL::String(L"seven"))); - DPL::String result; - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == L"seven", "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(8)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 8, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(9)); - int result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 9, "Got " << result); - } - { - TestTable::Select select(interface.get()); - select.Where(Equals(L"ten")); - DPL::String result; - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 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(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(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(3)); - std::list 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(DPL::String(L"seven"))); - std::list 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(99)); - std::list 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(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(99, 99))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(11, 13))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(DPL::String(L"twelve"), DPL::String(L"fourteen")))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(DPL::Optional::Null,DPL::Optional::Null))); - } - - //Where on each column - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(11, 13))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(DPL::Optional::Null)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - makeList(11, 13))); - } - { - TestTable::Select select(interface.get()); - select.Where(Is(99)); - RUNNER_ASSERT(ContainerContentsEqual(select.GetValueList(), - 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 resultList = select1.GetValueList(); - RUNNER_ASSERT_MSG(resultList.size() == 0, "Returned list has wrong size: " << resultList.size()); - std::list 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 list = selectStart.GetRowList(); - std::list originalList = list; - - std::vector 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(1), Equals(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(6), Equals(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(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(6), Equals(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(DPL::Optional::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::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(8)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - - select.Where(Equals(3)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 1, "Got " << result); - - select.Where(Equals(8)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 6, "Got " << result); - - select.Where(Equals(3)); - RUNNER_ASSERT_MSG((result = *select.GetSingleValue()) == 1, "Got " << result); - } - - { - TestTable::Select select(interface.get()); - int result; - select.Where(And(Equals(99), - Equals(L"fourteen"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(99), - Equals(L"twelve"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - - select.Where(And(Equals(99), - Equals(L"fourteen"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(99), - Equals(L"twelve"))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - } - - { - TestTable::Select select(interface.get()); - int result; - select.Where(And(Equals(L"fourteen"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(L"twelve"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - - select.Where(And(Equals(L"fourteen"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 13, "Got " << result); - - select.Where(And(Equals(L"twelve"), - Equals(99))); - RUNNER_ASSERT_MSG((result = select.GetSingleValue()) == 11, "Got " << result); - - } - -} - -RUNNER_TEST(ORM_Update) -{ - SmartAttach interface; - using namespace DPL::DB::ORM; - using namespace DPL::DB::ORM::dpl_orm_test; - - std::list 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(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(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(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."); -} diff --git a/tests/db/test_sql_connection.cpp b/tests/db/test_sql_connection.cpp deleted file mode 100644 index c1e3302..0000000 --- a/tests/db/test_sql_connection.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include -#include -#include -#include -#include -#include -#include -#include - -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(m_prefix); - valueStream << "_"; - valueStream << static_cast(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 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); -} diff --git a/tests/dbus/CMakeLists.txt b/tests/dbus/CMakeLists.txt deleted file mode 100644 index ced6807..0000000 --- a/tests/dbus/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file 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 -) diff --git a/tests/dbus/data/org.tizen.DBusTestService.service b/tests/dbus/data/org.tizen.DBusTestService.service deleted file mode 100644 index f024543..0000000 --- a/tests/dbus/data/org.tizen.DBusTestService.service +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.tizen.DBusTestService -Exec=/usr/bin/dpl-dbus-test-service diff --git a/tests/dbus/dbus_test.cpp b/tests/dbus/dbus_test.cpp deleted file mode 100644 index 6071f9f..0000000 --- a/tests/dbus/dbus_test.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file dbus_test.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @brief Implementation file for DBusTest and DBusTestManager. - */ - -#include -#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::Touch(); - DPL::Event::ControllerEventHandler::Touch(); - - DPL::Event::ControllerEventHandler::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::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; -} diff --git a/tests/dbus/dbus_test.h b/tests/dbus/dbus_test.h deleted file mode 100644 index 9b5061e..0000000 --- a/tests/dbus/dbus_test.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file 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 -#include -#include - -DECLARE_GENERIC_EVENT_0(QuitEvent) -DECLARE_GENERIC_EVENT_0(TimeoutEvent) - -class DBusTest : - private DPL::Event::Controller::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 diff --git a/tests/dbus/loop_control.cpp b/tests/dbus/loop_control.cpp deleted file mode 100644 index c6c250e..0000000 --- a/tests/dbus/loop_control.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 - -#include - -#include -#include - - -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 diff --git a/tests/dbus/loop_control.h b/tests/dbus/loop_control.h deleted file mode 100644 index 30aa6e8..0000000 --- a/tests/dbus/loop_control.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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_ */ diff --git a/tests/dbus/main.cpp b/tests/dbus/main.cpp deleted file mode 100644 index b6bd681..0000000 --- a/tests/dbus/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file 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 -#include - -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; -} diff --git a/tests/dbus/test_cases.cpp b/tests/dbus/test_cases.cpp deleted file mode 100644 index fe0f9c1..0000000 --- a/tests/dbus/test_cases.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file TestCases.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief Implementation file for test cases for DBus internal tests. - */ - -#include -#include -#include -#include -#include -#include -#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 = - "" - "" - " " - " " - " " - " " - " " - " " - " " - " " - ""; - -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 - (dbusInterfaceName, dbusMethodGetId); - RUNNER_ASSERT(!getId().empty()); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} - -class RegisterServiceListener : - public DPL::Event::EventListener -{ -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::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 - (interfaceName, methodNameEcho); - auto response = echo(challenge); - - testService->createMethodProxy(interfaceName, methodNameQuit)(); - - RUNNER_ASSERT_MSG(response == challenge, - "[challenge = " << challenge << - ", response = " << response << "]"); - } - catch (const DPL::DBus::Exception& ex) - { - RUNNER_ASSERT_MSG(false, ex.DumpToString()); - } -} diff --git a/tests/dbus/test_service.cpp b/tests/dbus/test_service.cpp deleted file mode 100644 index 63e32fb..0000000 --- a/tests/dbus/test_service.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file test_service.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @brief Implementation file for wrt-dbus-test-service. - */ - -#include -#include -#include -#include -#include -#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 = - "" - "" - " " - " " - " " - " " - " " - " " - " " - " " - ""; -} - -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; -} diff --git a/tests/event/CMakeLists.txt b/tests/event/CMakeLists.txt deleted file mode 100644 index 3db8f9c..0000000 --- a/tests/event/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file 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) diff --git a/tests/event/main.cpp b/tests/event/main.cpp deleted file mode 100644 index 4ed6191..0000000 --- a/tests/event/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @file main.cpp - * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main. - */ - -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} diff --git a/tests/event/test_controller.cpp b/tests/event/test_controller.cpp deleted file mode 100644 index 33bb631..0000000 --- a/tests/event/test_controller.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_controller.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test controller - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -RUNNER_TEST_GROUP_INIT(DPL) - -class IntController - : public DPL::Event::Controller::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::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::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::Type>, - private DPL::Event::Controller::Type> -{ -public: - typedef DPL::Event::Controller::Type> PublicController; - typedef DPL::Event::Controller::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 ControllerPtr; -typedef DPL::SharedPtr ThreadPtr; -typedef std::vector ControllerList; -typedef std::list ThreadList; - -DECLARE_GENERIC_EVENT_0(QuitEvent) -class QuitController - : public DPL::Event::Controller::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 TestContextPtr; -TestContextPtr testContextPtr; - -DECLARE_GENERIC_EVENT_0(StartSendEvent) -DECLARE_GENERIC_EVENT_0(RandomEvent) -class TestController - : public DPL::Event::Controller::Type> -{ -public: - explicit TestController() { Touch(); } -protected: - virtual void OnEventReceived(const RandomEvent &) - { - ++testContextPtr->g_ReceivedCounter; - if(testContextPtr->g_ReceivedCounter == MaxEvents) - { - testContextPtr->quitter.DPL::Event::ControllerEventHandler::PostEvent(QuitEvent()); - return; - } - } - virtual void OnEventReceived(const StartSendEvent &) - { - for (int i=0 ; ig_SentCounter > MaxEvents) - { - return; - } - ++testContextPtr->g_SentCounter; - int id = rand() % static_cast(testContextPtr->controllers.size()); - testContextPtr->controllers.at(id)->DPL::Event::ControllerEventHandler::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::PostEvent(StartSendEvent()); - } - testContextPtr->quitter.Exec(); - RUNNER_ASSERT(testContextPtr->g_SentCounter == testContextPtr->g_ReceivedCounter); - testContextPtr.Reset(); -} diff --git a/tests/event/test_event_support.cpp b/tests/event/test_event_support.cpp deleted file mode 100644 index af303f0..0000000 --- a/tests/event/test_event_support.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include -#include -#include -#include -#include -#include -#include - -DECLARE_GENERIC_EVENT_0(TestEvent) - -class TestListener: public DPL::Event::EventListener -{ -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 -{ -public: - void TestEmitEvent() { EmitEvent(TestEvent()); } -}; - -DECLARE_GENERIC_EVENT_0(QuitEvent) - -class QuitController - : public DPL::Event::Controller::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 -{ -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); -} diff --git a/tests/event/test_ic_delegate.cpp b/tests/event/test_ic_delegate.cpp deleted file mode 100644 index 60a5686..0000000 --- a/tests/event/test_ic_delegate.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -RUNNER_TEST_GROUP_INIT(DPL) - -const int IntVal = 123; -const std::string StringVal = "someString"; - -typedef DPL::Event::ICDelegate<> GetNothingDlpType; -typedef DPL::Event::ICDelegate GetIntDlgType; -typedef DPL::Event::ICDelegate 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::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 -{ - 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::PostEvent( - getNothingEvent); - - GetIntEvent getIntEvent( - makeICDelegate( - &TestContextFreeClass::OnIntReceive)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntEvent); - - GetIntAndStringEvent getIntAndStringEvent( - makeICDelegate( - &TestContextFreeClass::OnIntAndStringReceive)); - m_controller->DPL::Event::ControllerEventHandler::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 ICTestControllerPtr; -typedef DPL::SharedPtr TestContextFreePtr; -typedef DPL::SharedPtr TestRunnerInThreadPtr; -typedef DPL::SharedPtr ThreadPtr; - -DPL::Mutex mutex; -std::list frees; -std::list ctrls; -std::list frees_threads; -std::list ctrls_threads; - -} - -class TestContextFree : public DPL::Event::ICDelegateSupport -{ - 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::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::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::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::PostEvent( - getNothingEvent); - } - - void StartTestOnInt() - { - GetIntEvent getIntEvent( - makeICDelegate( - &TestContextFree::OnIntReceive)); - m_controller->DPL::Event::ControllerEventHandler::PostEvent( - getIntEvent); - } - - void StartTestOnIntAndString() - { - GetIntAndStringEvent getIntAndStringEvent( - makeICDelegate( - &TestContextFree::OnIntAndStringReceive)); - m_controller->DPL::Event::ControllerEventHandler::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::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::PostEvent(event); - } - } - - int m_reuseCount; -}; - -class ReuseTestContextFreeClass : - protected DPL::Thread, - public DPL::Event::ICDelegateSupport -{ - 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::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 diff --git a/tests/event/test_property.cpp b/tests/event/test_property.cpp deleted file mode 100644 index c095e5b..0000000 --- a/tests/event/test_property.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file test_property.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of test property - */ -#include -#include -#include -#include - -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 - Caption; - - DPL::Event::Property - Testproperty0; - - DPL::Event::Property - Testproperty1; - - DPL::Event::Property - Testproperty2; - - DPL::Event::Property Testproperty3; - - DPL::Event::Property Testproperty4; - - DPL::Event::Property 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 &event); -void OnNameChanged(const DPL::Event::PropertyEvent &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); -} diff --git a/tests/localization/CMakeLists.txt b/tests/localization/CMakeLists.txt deleted file mode 100644 index 0cca069..0000000 --- a/tests/localization/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# @file 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) diff --git a/tests/localization/files/CMakeLists.txt b/tests/localization/files/CMakeLists.txt deleted file mode 100644 index c887914..0000000 --- a/tests/localization/files/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -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 - ) - diff --git a/tests/localization/files/one b/tests/localization/files/one deleted file mode 100644 index e69de29..0000000 diff --git a/tests/localization/files/two b/tests/localization/files/two deleted file mode 100644 index e69de29..0000000 diff --git a/tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h b/tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h deleted file mode 100644 index 9e49d0d..0000000 --- a/tests/localization/mockup_include/dpl/wrt-dao-ro/common_dao_types.h +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - * @file common_dao_types.h - * @author Michal Ciepielski (m.ciepielski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of common data types for wrtdb - */ - -#ifndef WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ -#define WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ - -#include -#include -#include -#include -#include -#include -#include - -namespace WrtDB { -namespace Powder { - -typedef std::set StringSet; -//! Widget description -struct Description -{ - //!Content level - typedef enum - { - Level0 = 0, - Level1, - Level2, - Level3, - Level4, - Level5, - LevelUnknown - } LevelEnum; - struct LevelEntry - { - LevelEnum level; //!< content level - - typedef StringSet Context; - - //! POWDER context - //! xa This material appears in an artistic context - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - Context context; - explicit LevelEntry(LevelEnum level = LevelUnknown); - //! Function checks if context is valid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isContextValid(LevelEnum level, - const DPL::OptionalString& context) const; - }; - - struct CategoryEntry - { - //! Levels entries for POWDER description - typedef std::vector LevelsContainer; - LevelsContainer levels; - //! Function checks if context is valid - //! \param[out] reason set if context invalid - //! \param[in] level POWDER content level - //! \param[in] context POWDER context - bool isCategoryValid(LevelEntry& reason, - LevelEnum level, - const DPL::OptionalString& context) const; - }; - - //! POWDER Category -> Category entry map for Widget - //! - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - typedef std::map CategoryEntries; - - CategoryEntries categories; - - //! Age rating for widget - //! If Null not set - DPL::OptionalInt ageRating; -}; -} // namespace Powder - -namespace ChildProtection { - -//! Blacklist with forbidden URLs -//! It should be stored in WidgetDAO -typedef std::vector BlackList; - -//! Widget Child protection record -//! Record should be stored in WingetDAO -struct Record -{ - //! Child protection enabled - bool enabled; - explicit Record(bool enabled) : - enabled(enabled) - { - } -}; - -//! Powder processing -struct PowderRules -{ - //! Rule set by parent about forbidden category - //! Powder category - //! nu Nudity - //! se Sex - //! vi Violence - //! la Potentially offensive language - //! dr Drug use - //! ga Gambling - //! ha Hate or harmful activities - //! ug Use of user-generated content - //! Powder context - //! xa This material appears in an artistic conteaxt - //! xb This material appears in an educational context - //! xc This material appears in a medical context - //! xd This material appears in a sports context - //! xe This material appears in a violent context - struct CategoryRule - { - DPL::String category; - Powder::Description::LevelEnum level; - DPL::OptionalString context; - explicit CategoryRule(const DPL::String& category = DPL::String(), - Powder::Description::LevelEnum level = - Powder::Description::LevelUnknown, - const DPL::OptionalString& context = DPL::OptionalString()); - }; - - struct PowderResult - { - //! Reasoning outcome: part of POWDER description used to invalidate - Powder::Description::LevelEntry invalidDescription; - //! Reasoning outcome: rule set by parent not full filed by description - CategoryRule invalidRule; - - //! Reasoning outcome: type of invalidity - enum InvalidReason - { - InvalidRule, //!< One of rules was not fulfilled - InvalidAge, //!< Age is invalid - AgeRatingNotSet, //!< Age rating for widget is not set - Valid //!< Description valid - }; - InvalidReason reason; - explicit PowderResult(InvalidReason reason = Valid, - const Powder::Description::LevelEntry& invalidDescription = - Powder::Description::LevelEntry(), - const CategoryRule& invalidRule = CategoryRule()); - }; - - typedef std::pair ResultPair; - - //! Function checks if rule is fulfilled by description - //! \param[in] rule checked rule - //! \param[in] description - //! \retval true rule is valid - //! \retval false rule is invalid - ResultPair isRuleValidForDescription(const CategoryRule& rule, - const Powder::Description& description) const; - //! Function checks if age limit is fulfilled by description - //! \param[in] description - //! \retval true age is valid - //! \retval false age is invalid - ResultPair isAgeValidForDescription( - const Powder::Description& description) const; - - //! It is the maximum age rating valid for child - //! Uniform age is stored in WidgetDAO - DPL::OptionalInt ageLimit; - - //! Set to true if age rating is required - //! If ageLimit is not set value is ignored - bool isAgeRatingRequired; - - //! Set of rules configured by parent - //! Rules are stored in WidgetDAO and are uniform for all widgets - typedef std::vector RulesContainer; - RulesContainer rules; - - //! Function check if Widget description is valid for ChildProtection - //! configuration - //! \param description widget description - //! \retval true widget is valid - //! \retval false widget is invalid - ResultPair isDescriptionValid(const Powder::Description& description) - const; - - PowderRules() : - isAgeRatingRequired(false) - { - } -}; -} // namespace ChildProtection - -class PluginMetafileData -{ - public: - struct Feature - { - std::string m_name; - std::set m_deviceCapabilities; - - bool operator< (const Feature& obj) const - { - return m_name < obj.m_name; - } - }; - typedef std::set FeatureContainer; - - public: - - PluginMetafileData() - { - } - - std::string m_libraryName; - std::string m_featuresInstallURI; - std::string m_featuresKeyCN; - std::string m_featuresRootCN; - std::string m_featuresRootFingerprint; - - FeatureContainer m_featureContainer; -}; - -class PluginObjectsDAO -{ - public: - typedef std::set Objects; - typedef DPL::SharedPtr ObjectsPtr; - - public: - explicit PluginObjectsDAO() {} - - protected: - ObjectsPtr m_implemented; - ObjectsPtr m_dependent; -}; - -/** - * @brief Widget id describes web-runtime global widget identifier. - * - * Notice that only up to one widget can exist at the same time. - * DbWidgetHandle can be translated into corresponding WidgetModel by invoking - * FindWidgetModel routine. - */ -typedef int DbWidgetHandle; - -/** - * @brief Structure to hold the information of widget's size - */ -struct DbWidgetSize -{ - DPL::OptionalInt width; - DPL::OptionalInt height; - - DbWidgetSize(DPL::OptionalInt w = DPL::OptionalInt::Null, - DPL::OptionalInt h = DPL::OptionalInt::Null) : - width(w), - height(h) - { - } -}; - -inline bool operator ==(const DbWidgetSize &objA, const DbWidgetSize &objB) -{ - if (!objA.height || !objA.width || !objB.width || !objB.height) { - return false; - } else { - return *objA.height == *objB.height && *objA.width == *objB.width; - } -} - -/** - * Widget [G]lobal [U]nique [ID]entifier - * Orginated from appstore ID - */ -typedef DPL::OptionalString WidgetGUID; - -struct WidgetAccessInfo -{ - DPL::String strIRI; /* origin iri */ - bool bSubDomains; /* do we want access to subdomains ? */ - - bool operator ==(const WidgetAccessInfo& info) const - { - return info.strIRI == strIRI && - info.bSubDomains == bSubDomains; - } -}; - -typedef std::list WidgetAccessInfoList; - -typedef std::list WindowModeList; - -/** - * @brief Widget configuration parameter key - */ -typedef DPL::String WidgetParamKey; - -/** - * @brief Widget configuration parameter value - */ -typedef DPL::String WidgetParamValue; - -/** - * @brief A map of widget configuration parameters. - * - * Widget configuration parameters are read from database and are stored - * along with feature that they describe. - */ -typedef std::multimap WidgetParamMap; - -/** - * @brief Widget feature host information about possible javascript extensions - * that widget may use - * - * Widget features are declared in configuration file in widget installation - * package. Each declared special feature is contained in some wrt-plugin that - * declares to implement it. After widget launch wrt searches for proper plugin - * libraries and load needed features. - * - * Widget features can be required or optional. It is possible to start widget - * without missing feature. When required feature cannot be loaded widget will - * not start. - */ - -enum { - INVALID_PLUGIN_HANDLE = -1 -}; -typedef int DbPluginHandle; - -struct DbWidgetFeature -{ - DPL::String name; /// Feature name - bool required; /// Whether feature is required - DbPluginHandle pluginId; /// Plugin id that implement this feature - WidgetParamMap params; /// Widget's params - - DbWidgetFeature() : - required(false), - pluginId(INVALID_PLUGIN_HANDLE) - { - } -}; - -inline bool operator < (const DbWidgetFeature &objA, - const DbWidgetFeature &objB) -{ - return objA.name.compare(objB.name) < 0; -} - -inline bool operator==(const DbWidgetFeature &featureA, - const DbWidgetFeature &featureB) -{ - return featureA.name == featureB.name && - featureA.required == featureB.required && - featureA.pluginId == featureB.pluginId; -} - -/** - * @brief Default container for features list - */ -typedef std::multiset DbWidgetFeatureSet; - -/** - * @brief Default container with DbWidgetHandle's - */ -typedef std::list DbWidgetHandleList; - -/** - * @brief Widget specific type - * - * Widget type describes belowed in WAC, TIZEN WebApp - */ -enum AppType -{ - APP_TYPE_UNKNOWN = 0, // unknown - APP_TYPE_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 WidgetSettings; - -/** - * @brief Widget Application Service - * - * Application sercvice describes details of behaviour - * when widget receives aul bundle data. - */ -struct WidgetApplicationService -{ - public: - DPL::String src; /* start uri */ - DPL::String operation; /* service name */ - DPL::String scheme; /* scheme type*/ - DPL::String mime; /* mime type */ - - bool operator== (const WidgetApplicationService& other) const - { - return src == other.src && - operation == other.operation && - scheme == other.scheme && - mime == other.mime; - } -}; - -typedef std::list WidgetApplicationServiceList; -#endif /* WRT_SRC_CONFIGURATION_COMMON_DAO_TYPES_H_ */ diff --git a/tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h b/tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h deleted file mode 100644 index 42b6c5b..0000000 --- a/tests/localization/mockup_include/dpl/wrt-dao-rw/widget_dao.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of widget dao class. - * - * @file widget_dao_read_only.h - * @author Yang Jie (jie2.yang@samsung.com) - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of widget dao - */ - -#ifndef _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ -#define _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -typedef DPL::OptionalString WidgetGUID; - -namespace ConfigParserData { - -struct Icon -{ - Icon(const DPL::String& src) : src(src) - { - } - DPL::String src; - DPL::OptionalInt width; - DPL::OptionalInt height; - bool operator==(const Icon&) const; - bool operator!=(const Icon&) const; - bool operator >(const Icon&) const; - bool operator>=(const Icon&) const; - bool operator <(const Icon&) const; - bool operator<=(const Icon&) const; -}; -} // namespace ConfigParserData -namespace WrtDB { - -typedef std::list StringList; - -struct WidgetLocalizedInfo -{ - DPL::OptionalString name; - DPL::OptionalString shortName; - DPL::OptionalString description; - DPL::OptionalString license; - DPL::OptionalString licenseHref; -}; - -typedef std::list LanguageTagList; - -class WidgetDAO -{ - public: - /** - * WidgetDAO Exception classes - */ - class Exception - { - public: - DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) - DECLARE_EXCEPTION_TYPE(Base, DatabaseError) - DECLARE_EXCEPTION_TYPE(Base, ReadOnlyProperty) - DECLARE_EXCEPTION_TYPE(Base, GUIDisNull) - DECLARE_EXCEPTION_TYPE(Base, UnexpectedEmptyResult) - DECLARE_EXCEPTION_TYPE(Base, WidgetNotExist) - DECLARE_EXCEPTION_TYPE(Base, AlreadyRegistered) - }; - - protected: - DbWidgetHandle m_widgetHandle; - - public: - struct WidgetLocalizedIconRow - { - int appId; - int iconId; - DPL::String widgetLocale; - }; - typedef std::list WidgetLocalizedIconList; - - struct WidgetIconRow - { - int iconId; - int appId; - DPL::String iconSrc; - DPL::OptionalInt iconWidth; - DPL::OptionalInt iconHeight; - }; - typedef std::list WidgetIconList; - - struct WidgetStartFileRow - { - int startFileId; - int appId; - DPL::String src; - }; - typedef std::list WidgetStartFileList; - - struct WidgetLocalizedStartFileRow - { - int startFileId; - int appId; - DPL::String widgetLocale; - DPL::String type; - DPL::String encoding; - }; - typedef std::list LocalizedStartFileList; - - - /** - * This is a constructor. - * - * @param[in] widgetHandle application id of widget. - */ - WidgetDAO(DbWidgetHandle widgetHandle) - : m_widgetHandle(widgetHandle) - {} - - /** - * Destructor - */ - virtual ~WidgetDAO(){} - - /** - * This method returns widget handle(m_widgetHandle). - * - * @return widget handle(m_widgetHandle). - * @exception WRT_CONF_ERR_EMDB_FAILURE - Fail to query DB table. - * @exception WRT_CONF_ERR_EMDB_NO_RECORD - Can not find matching records in DB table. - */ - DbWidgetHandle getHandle() const { return m_widgetHandle; } - DbWidgetHandle getHandle(const WidgetGUID GUID) const; - static DbWidgetHandle getHandle(const DPL::String 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 s_startFileMap; - static std::map s_localizedStartFileMap; - static std::map s_pathMap; -}; - -} // namespace WrtDB - -#endif // _WRT_SRC_CONFIGURATION_WIDGET_DAO_READ_ONLY_H_ - diff --git a/tests/localization/mockup_src/widget_dao.cpp b/tests/localization/mockup_src/widget_dao.cpp deleted file mode 100644 index 3fe877b..0000000 --- a/tests/localization/mockup_src/widget_dao.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This file contains the declaration of widget dao class. - * - * @file widget_dao_read_only.cpp - * @author Yang Jie (jie2.yang@samsung.com) - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @author Pawel Sikorski (p.sikorski@samsung.com) - * @version 1.0 - * @brief This file contains the declaration of widget dao - */ - -#include - -#include -#include -#include -#include - -namespace WrtDB { - -std::map WidgetDAO::s_startFileMap; -std::map WidgetDAO::s_localizedStartFileMap; -std::map WidgetDAO::s_pathMap; - -DbWidgetHandle WidgetDAO::getHandle(const WidgetGUID /* GUID */) const -{ - LogError("Not impleneted!"); - return 0; -} - -DbWidgetHandle WidgetDAO::getHandle(const DPL::String /* 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 diff --git a/tests/localization/test_localization.cpp b/tests/localization/test_localization.cpp deleted file mode 100644 index 42ffe3a..0000000 --- a/tests/localization/test_localization.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file main.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of main - */ -#include - -int main(int argc, char *argv[]) -{ - return DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv); -} - diff --git a/tests/localization/test_suite01.cpp b/tests/localization/test_suite01.cpp deleted file mode 100644 index 83f53f5..0000000 --- a/tests/localization/test_suite01.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include -#include - -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"); -} - -- 2.7.4