include_directories(
${dpl_INCLUDE_DIRS}
-)
-
-
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/modules/API
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/Commons
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/CommonsJavaScript
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-loading
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/js-overlay
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/wrt-popup/ace/popup-runner)
##############################################################################
# Build type
####
OPTION(DPL_LOG "DPL logs status" ON)
+OPTION(WITH_TESTS "Build tests" OFF)
+
IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
MESSAGE(STATUS "Logging enabled for DPL")
ADD_DEFINITIONS("-DDPL_LOGS_ENABLED")
MESSAGE(STATUS "Logging disabled for DPL")
ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling")
+MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
+
ADD_DEFINITIONS("-fPIC")
ADD_DEFINITIONS("-fvisibility=default") # mark all exported symbols as visible
ADD_DEFINITIONS("-fPIC") # If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding
add_subdirectory(src)
+IF(WITH_TESTS)
+ add_subdirectory(tests)
+ENDIF(WITH_TESTS)
+
################################################################################
# PKGCONFIG
%prep
%setup -q
+%define with_tests 0
+%if "%{WITH_TESTS}" == "ON" || "%{WITH_TESTS}" == "Y" || "%{WITH_TESTS}" == "YES" || "%{WITH_TESTS}" == "TRUE" || "%{WITH_TESTS}" == "1"
+ %define with_tests 1
+%endif
+
%build
export LDFLAGS+="-Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--hash-style=both"
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DDPL_LOG="ON" \
-DCMAKE_PROJECT_VERSION=%{version} \
- -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+ -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+ %{?WITH_TESTS:-DWITH_TESTS=%WITH_TESTS}
make %{?jobs:-j%jobs}
%install
%attr(755,root,root) %{_bindir}/wrt-plugins-installer
%{_datadir}/license/%{name}
+%if %{with_tests}
+ %attr(755,root,root) %{_bindir}/widgetdb_tests_prepare_db.sh
+ %attr(755,root,root) %{_bindir}/plugins-tests-widgetdb
+%endif
+
%files devel
%{_includedir}/*
%{_libdir}/pkgconfig/*
set(HOST_ARCH "armel")
endif()
-#include directories
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/modules/API
- ${CMAKE_CURRENT_SOURCE_DIR}/Commons
- ${CMAKE_CURRENT_SOURCE_DIR}/CommonsJavaScript
- ${CMAKE_CURRENT_SOURCE_DIR}/plugin-loading
- ${CMAKE_CURRENT_SOURCE_DIR}/js-overlay
- ${CMAKE_CURRENT_SOURCE_DIR}/wrt-popup/ace/popup-runner
- )
-
#target names
set(TARGET_PLUGIN_LOADING_LIB "wrt-plugin-loading")
set(TARGET_COMMONS "wrt-plugins-commons")
--- /dev/null
+# Copyright (c) 2012 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)
+#
+
+INCLUDE(CMakeUtils.txt)
+
+ADD_SUBDIRECTORY(dao)
--- /dev/null
+# @file CMakeUtils.txt
+# @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+# @author Pawel Sikorski (p.sikorski@samsung.com)
+# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version 1.0
+# @brief
+#
+
+#
+# Replacement functions for standard (w/o "WRT_" prefix) CMake functions.
+# They store supplied arguments in global properties to assign them to tests.
+FUNCTION(WRT_INCLUDE_DIRECTORIES)
+ SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_INCLUDE_DIRS ${ARGV})
+ENDFUNCTION(WRT_INCLUDE_DIRECTORIES)
+
+FUNCTION(WRT_LINK_DIRECTORIES)
+ SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARY_DIRS ${ARGV})
+ENDFUNCTION(WRT_LINK_DIRECTORIES)
+
+FUNCTION(WRT_TARGET_LINK_LIBRARIES)
+ SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARIES ${ARGV})
+ENDFUNCTION(WRT_TARGET_LINK_LIBRARIES)
+
+FUNCTION(WRT_TEST_LIBRARY)
+ SET_PROPERTY(GLOBAL APPEND PROPERTY COMMON_TESTS_LIBRARY ${ARGV})
+ENDFUNCTION(WRT_TEST_LIBRARY)
+
+# Functions used to build test targets (proper sources, includes, libs are
+# added automatically)
+FUNCTION(WRT_TEST_BUILD TARGET_NAME)
+ SET(SOURCES "${ARGN}")
+ ADD_EXECUTABLE("${TARGET_NAME}"
+ ${SOURCES}
+ )
+ # get include dirs global property
+ GET_PROPERTY(INCLUDE_DIRS GLOBAL PROPERTY TESTS_INCLUDE_DIRS)
+ INCLUDE_DIRECTORIES(
+ ${INCLUDE_DIRS}
+ )
+ # get library dirs global property
+ GET_PROPERTY(LIBRARY_DIRS GLOBAL PROPERTY TESTS_LIBRARY_DIRS)
+ LINK_DIRECTORIES(
+ ${LIBRARY_DIRS}
+ )
+ # get link libraries global property
+ GET_PROPERTY(LINK_LIBRARIES GLOBAL PROPERTY TESTS_LIBRARIES)
+ GET_PROPERTY(TEST_LIBRARY GLOBAL PROPERTY COMMON_TESTS_LIBRARY)
+ TARGET_LINK_LIBRARIES("${TARGET_NAME}"
+ ${TEST_LIBRARY}
+ ${LINK_LIBRARIES}
+ )
+ENDFUNCTION(WRT_TEST_BUILD)
+
+FUNCTION(WRT_TEST_INSTALL)
+ SET_TARGET_PROPERTIES(${ARGV} PROPERTIES
+ BUILD_WITH_INSTALL_RPATH ON
+ INSTALL_RPATH_USE_LINK_PATH ON
+ )
+ INSTALL(TARGETS ${ARGV}
+ DESTINATION bin
+ PERMISSIONS OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ GROUP_READ
+ GROUP_EXECUTE
+ WORLD_READ
+ WORLD_EXECUTE
+ )
+ENDFUNCTION(WRT_TEST_INSTALL)
--- /dev/null
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @file CMakeLists.txt
+# @author Andrzej Surdej (a.surdej@sasmung.com)
+# @version 1.0
+# @brief
+#
+
+SET(TARGET_WIDGETDB_TEST "plugins-tests-widgetdb")
+
+pkg_search_module(dpl REQUIRED dpl-efl)
+pkg_search_module(dpl-test REQUIRED dpl-test-efl)
+
+include_directories(
+ ${dpl_INCLUDE_DIRS}
+ ${dpl-test_INCLUDE_DIRS}
+)
+
+# Set widgetdb tests sources
+SET(WIDGETDB_TESTS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/TestInit.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/WidgetDBTest.cpp")
+
+WRT_TEST_BUILD(${TARGET_WIDGETDB_TEST} ${WIDGETDB_TESTS_SOURCES})
+WRT_TEST_INSTALL(${TARGET_WIDGETDB_TEST})
+
+target_link_libraries(${TARGET_WIDGETDB_TEST}
+ "wrt-plugins-widgetdb"
+ ${dpl_LIBRARIES}
+ ${dpl-test_LIBRARIES}
+)
+
+INSTALL(PROGRAMS
+ ${CMAKE_CURRENT_SOURCE_DIR}/widgetdb_tests_prepare_db.sh
+ DESTINATION bin
+ )
--- /dev/null
+Plugins DAO
+System tests. Tests widget's private database data access object.
+Binary file: plugins-tests-widgetdb. Uses our test framework. Allows to use
+different types of output. Text output shows results on console - green passed.
+To run:
+1. Install wrt-extra on target
+2. Run plugins-tests-widgetdb --output=text
+
+Automatic: YES
+Included in Daily Build: YES (http://build01.sprc.samsung.pl/browse/LINUXNGWAP-INT)
+Included in Gerrit Builds: YES (http://build01.sprc.samsung.pl/browse/LINUXNGWAP-GERRIT)
+Number of test cases: 22
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file TestInit.cpp
+ * @author Pawel Sikorski (p.sikorski@samsung.com)
+ * @author Andrzej Surdej (a.surdej@samsung.com)
+ * @version 1.0
+ * @brief Init widgetDB module test
+ */
+
+#include <sys/wait.h>
+#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+
+int main (int argc, char *argv[])
+{
+ int ret = system("/usr/bin/widgetdb_tests_prepare_db.sh start");
+
+ if (!WIFEXITED(ret)) { //unexpected termiate
+ LogDebug("Fail while preparing database. Restoring");
+ system("/usr/bin/widgetdb_tests_prepare_db.sh stop");
+ return -1;
+ } else if (WEXITSTATUS(ret)) { //wrong script command, nothing done
+ LogError("Preparation script has return error: " << ret
+ << ". Quitting");
+ return -1;
+ }
+
+ LogInfo("Starting tests");
+
+ WrtDB::WrtDatabase::attachToThreadRW();
+
+ int status =
+ DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+
+ WrtDB::WrtDatabase::detachFromThread();
+
+ system("/usr/bin/widgetdb_tests_prepare_db.sh stop");
+ return status;
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file WidgetDBTest.cpp
+ * @author Andrzej Surdej (a.surdej@samsung.com)
+ * @version 1.0
+ * @brief This file contains tests for widgetDB commons module
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <WidgetDB/IWidgetDB.h>
+#include <WidgetDB/WidgetDBMgr.h>
+#include <Commons/Exception.h>
+
+using namespace WrtDeviceApis::WidgetDB::Api;
+
+#define RUNNER_ASSERT_WHAT_EQUALS(in, test) \
+ do \
+ { \
+ std::string temp(in); \
+ RUNNER_ASSERT_MSG(temp == (test), "Equals: [" << temp << "]"); \
+ } \
+ while(0)
+
+RUNNER_TEST_GROUP_INIT(WidgetDB)
+
+/*
+Name: widgetDB_test_get_language1
+Description: check default widget language
+Expected: default should be "en"
+*/
+RUNNER_TEST(widgetDB_test_get_language1)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string lang = widget->getLanguage();
+
+ LogDebug("language is: " << lang);
+ RUNNER_ASSERT_WHAT_EQUALS(lang, "en");
+
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_language2
+Description: check language returned by WidgetDB if widget does nto exists
+Expected: result should be ""
+*/
+RUNNER_TEST(widgetDB_test_get_language2)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(1000); //widget not exist
+ std::string lang = widget->getLanguage();
+
+ LogDebug("language is: " << lang);
+ RUNNER_ASSERT_WHAT_EQUALS(lang, "");
+
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_id
+Description: check GUID returned by WidgetDB
+Expected: GUID should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_id)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::ID);
+
+ LogDebug("id is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_id_2000");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_version
+Description: check version returned by WidgetDB
+Expected: version should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_version)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::VERSION);
+
+ LogDebug("version is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "1.0.0");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_description
+Description: check description returned by WidgetDB
+Expected: description should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_description)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::DESCRIPTION);
+
+ LogDebug("description is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_desc_2000_en");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_license
+Description: check license returned by WidgetDB
+Expected: license should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_license)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::LICENSE);
+
+ LogDebug("licence is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_lic_2000_en");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_license_href
+Description: check license href returned by WidgetDB
+Expected: license href should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_license_href)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::LICENSE_HREF);
+
+ LogDebug("license href is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_lic_href_2000_en");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_author_name
+Description: check author name href returned by WidgetDB
+Expected: author name should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_author_name)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_NAME);
+
+ LogDebug("author name is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_name_2000");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_author_href
+Description: check author href returned by WidgetDB
+Expected: author href should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_author_href)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_HREF);
+
+ LogDebug("author href is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_href_2000");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_author_email
+Description: check author email returned by WidgetDB
+Expected: author email should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_author_email)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_EMAIL);
+
+ LogDebug("author email is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_email_2000");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_name
+Description: check localized widget name returned by WidgetDB
+Expected: localized widget name should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_name)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::NAME);
+
+ LogDebug("name is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_name_2000_en");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_short_name
+Description: check localized widget short name returned by WidgetDB
+Expected: localized widget short name should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_short_name)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::SHORT_NAME);
+
+ LogDebug("short name is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_shortname_2000_en");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_access_network
+Description: check network access returned by WidgetDB
+Expected: network access should be set to "yes"
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_access_network)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(
+ ConfigAttribute::ACCESS_NETWORK);
+
+ LogDebug("acces network is always true: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "yes");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_width
+Description: check widget prefered width returned by WidgetDB
+Expected: widget prefered width should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_width)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::WIDTH);
+
+ LogDebug("width is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "100");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_height
+Description: check widget prefered height returned by WidgetDB
+Expected: widget prefered height should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_height)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::HEIGHT);
+
+ LogDebug("height is: " << tmp);
+ RUNNER_ASSERT_WHAT_EQUALS(tmp, "200");
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_paths
+Description: check widget installation path returned by WidgetDB
+Expected: widget installation path should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_paths)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::INSTALL_PATH);
+
+ LogDebug("install path is: " << tmp);
+
+ tmp = widget->getConfigValue(
+ ConfigAttribute::PUBLIC_STORAGE_PATH);
+
+ LogDebug("public storage path is: " << tmp);
+
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogDebug("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_get_config_value_empty
+Description: check if requesting GUID from WidgetDB throw excpetion if widget does not exists
+Expected: accessing GUID should throw WrtDeviceApis::Commons::SecurityException
+*/
+RUNNER_TEST(widgetDB_test_get_config_value_empty)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2005);
+ std::string tmp = widget->getConfigValue(ConfigAttribute::ID);
+
+ //exception should be thrown
+ RUNNER_ASSERT(false);
+
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogDebug("OK. Exception thrown." << e.DumpToString());
+ }
+}
+
+/*
+Name: widgetDB_test_check_installation_status_installed
+Description: check if widget is installed by WidgetDB
+Expected: plugin should be notified that widget is installed
+*/
+RUNNER_TEST(widgetDB_test_check_installation_status_installed)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ InstallationStatus tmp = widget->checkInstallationStatus(
+ "w_id_2000", "w_name_2000_en", "2.0.0");
+
+ RUNNER_ASSERT(tmp == InstallationStatus::STATUS_INSTALLED);
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_check_installation_status_uninstalled
+Description: check if widget is not installed by WidgetDB
+Expected: plugin should be notified that widget is not installed
+*/
+RUNNER_TEST(widgetDB_test_check_installation_status_uninstalled)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ InstallationStatus tmp = widget->checkInstallationStatus(
+ "w_id_2011", "w_name_2000_en", "2.0.0");
+
+ RUNNER_ASSERT(tmp == InstallationStatus::STATUS_UNINSTALLED);
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_check_installation_status_latest
+Description: check if widget installation information is taken from latest version
+Expected: plugin installation status should be same is both calls of WidgetDB
+*/
+RUNNER_TEST(widgetDB_test_check_installation_status_latest)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ InstallationStatus tmp1 = widget->checkInstallationStatus(
+ "w_id_2000", "w_name_2000_en", "0.1.0");
+ InstallationStatus tmp2 = widget->checkInstallationStatus(
+ "w_id_2000", "w_name_2000_en", "1.0.0");
+
+ RUNNER_ASSERT(tmp1 == InstallationStatus::STATUS_LATEST);
+ RUNNER_ASSERT(tmp2 == InstallationStatus::STATUS_LATEST);
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_widget_feature
+Description: check accessiblity of widget features and their values by WidgetDB
+Expected: feature names and values should match this, which was inserted into widget database
+*/
+RUNNER_TEST(widgetDB_test_widget_feature)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2000);
+ Features features = widget->getWidgetFeatures();
+
+ RUNNER_ASSERT(features.size() == 5);
+
+ FOREACH(it, features)
+ {
+ std::string name = (*it)->getName();
+ if ("first_2000" == name)
+ {
+ RUNNER_ASSERT((*it)->getParams().size() == 4);
+
+ RUNNER_ASSERT((*it)->isRequired());
+ }
+ else if ("second_2000" == name)
+ {
+ RUNNER_ASSERT((*it)->getParams().size() == 1);
+ }
+ else if ("third_2000" == name)
+ {
+ IWidgetFeature::Params params = (*it)->getParams();
+
+ RUNNER_ASSERT(params.size() == 1);
+ RUNNER_ASSERT_WHAT_EQUALS("third_2000", params.begin()->first);
+ RUNNER_ASSERT_WHAT_EQUALS("thirdValue1", params.begin()->second);
+ RUNNER_ASSERT(!(*it)->isRequired());
+ }
+ else if ("fourth_2000" == name)
+ {
+ RUNNER_ASSERT((*it)->getParams().size() == 0);
+ }
+ else if ("fifth_2000" == name)
+ {
+ RUNNER_ASSERT((*it)->getParams().size() == 0);
+ }
+ else
+ RUNNER_ASSERT(false);
+ }
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogError("Exception thrown." << e.DumpToString());
+ RUNNER_ASSERT(false);
+ }
+}
+
+/*
+Name: widgetDB_test_widget_feature2
+Description: check if requesting features from WidgetDB throw excpetion if widget does not exists
+Expected: exception should be raise if widget does not exists
+*/
+RUNNER_TEST(widgetDB_test_widget_feature2)
+{
+ try
+ {
+ IWidgetDBPtr widget = getWidgetDB(2011); //no such widget
+ Features features = widget->getWidgetFeatures();
+
+ RUNNER_ASSERT(false);
+ }
+ catch(const WrtDeviceApis::Commons::SecurityException &e)
+ {
+ LogDebug("OK. Exception thrown." << e.DumpToString());
+ }
+}
+
+#undef RUNNER_ASSERT_WHAT_EQUALS
--- /dev/null
+#!/bin/sh
+#
+# 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.
+#
+#
+
+WRT_DB=/opt/dbspace/.wrt.db
+WRT_DB_BCK=/tmp/wrt.db_backup
+
+if [ "x$1" == "xstart" ]; then
+ echo start;
+ cp $WRT_DB $WRT_DB_BCK
+ wrt_commons_create_clean_db.sh;
+
+ #simple plugins
+ INS_MIN_PLUGINPROP="insert into PluginProperties(PluginPropertiesId, InstallationState, PluginLibraryName"
+ INS_ALL_PLUGINPROP="insert into PluginProperties(PluginPropertiesId, InstallationState, PluginLibraryName, PluginLibraryPath)"
+
+ sqlite3 $WRT_DB "${INS_MIN_PLUGINPROP}) VALUES(1, 1, 'plugin1')";
+ sqlite3 $WRT_DB "${INS_MIN_PLUGINPROP}, PluginLibraryPath) VALUES(2, 1, 'plugin2', 'path_to_plugin2')";
+ sqlite3 $WRT_DB "${INS_MIN_PLUGINPROP}) VALUES(3, 1, 'plugin3')";
+ sqlite3 $WRT_DB "${INS_ALL_PLUGINPROP} VALUES(4, 1, 'p4', 'path_to_p4')";
+ sqlite3 $WRT_DB "${INS_ALL_PLUGINPROP} VALUES(5, 1, 'p5', 'path_to_p5')";
+
+ #simple features
+ INS_ALL_FEATURESLIST="insert into FeaturesList(FeatureUUID, FeatureName, PluginPropertiesId)"
+ sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(1, 'feature1', 1)";
+ sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(2, 'feature2', 4)";
+ sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(3, 'feature3', 4)";
+ sqlite3 $WRT_DB "${INS_ALL_FEATURESLIST} VALUES(4, 'feature4', 4)";
+
+ #Device capab
+ #TODO
+
+ #Widgets
+ INS_ALL_WIDGETEXT="insert into WidgetExtendedInfo(app_id, share_href, signature_type)"
+ INS_ALL_WIDGET="insert into WidgetInfo(app_id, widget_id, widget_version, widget_width, widget_height, author_name, author_email, author_href, base_folder, webkit_plugins_required, recognized, wac_signed, distributor_signed, min_version, back_supported, access_network, defaultlocale, pkgname)"
+ INS_ALL_WIDGET_LOC="insert into LocalizedWidgetInfo(app_id, widget_locale, widget_name, widget_shortname, widget_description, widget_license, widget_license_file, widget_license_href)"
+ INS_ALL_WIDGET_ICONS="insert into WidgetIcon(app_id, icon_src, icon_width, icon_height)"
+ INS_ALL_WIDGET_LOC_ICONS="insert into WidgetLocalizedIcon(app_id, icon_id, widget_locale)"
+ INS_ALL_WIDGET_STARTFILE="insert into WidgetStartFile(app_id, src)"
+ INS_ALL_WIDGET_LOC_STARTFILE="insert into WidgetLocalizedStartFile(app_id, start_file_id, widget_locale, type, encoding)"
+ INS_ALL_WIDGET_DEFPREF="insert into WidgetDefaultPreference(app_id, key_name, key_value, readonly)"
+ INS_ALL_WIDGET_PREF="insert into WidgetPreference(pkgname, key_name, key_value, readonly)"
+ INS_ALL_WIDGET_FEATURE="insert into WidgetFeature(widget_feature_id, app_id, name, required, rejected)"
+ INS_ALL_WIDGET_FEATURE_PARAM="insert into FeatureParam(widget_feature_id, name, value)"
+ INS_ALL_WIDGET_WINMODES="insert into WidgetWindowModes(app_id, window_mode)"
+ INS_ALL_WIDGET_WARP="insert into WidgetWARPInfo(app_id, iri, subdomain_access)"
+ INS_ALL_WIDGET_CERT="insert into WidgetCertificateFingerprint(app_id, owner, chainid, type, md5_fingerprint, sha1_fingerprint, common_name)"
+ INS_ALL_WIDGET_POWDERLEV="insert into PowderLevels(app_id, category, level)"
+ INS_ALL_WIDGET_POWDERLEV_CONT="insert into PowderLevelContexts(levelid, context)"
+
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2000, 'w_id_2000', '1.0.0', 100, 200, 'a_name_2000', 'a_email_2000', 'a_href_2000', 'basef_2000', 1, 1, 1, 1, '1.0', 0, 0, 'en', 'tid2000')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2001, 'w_id_2001', '2.0.0', 100, 200, 'a_name_2001', 'a_email_2001', 'a_href_2001', 'basef_2001', 1, 1, 1, 1, '0.5', 0, 0, 'en', 'tid2001')";
+ sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, pkgname) VALUES(2002, 0, 'tid2002')";
+ sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, pkgname) VALUES(2003, 0, 'NOTUSEDPKGNAME3')"; # for properties tests
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2000, 'share_href_2000', 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2001, 'share_href_2001', 0)";
+ sqlite3 $WRT_DB "insert into WidgetExtendedInfo(app_id) VALUES(2002)";
+ sqlite3 $WRT_DB "insert into WidgetExtendedInfo(app_id) VALUES(2003)";
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC} VALUES(2000, 'en', 'w_name_2000_en', 'w_shortname_2000_en', 'w_desc_2000_en', 'w_lic_2000_en', 'w_licf_2000_en', 'w_lic_href_2000_en')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC} VALUES(2000, 'pl', 'w_name_2000_pl', 'w_shortname_2000_pl', 'w_desc_2000_pl', 'w_lic_2000_pl', 'w_licf_2000_pl', 'w_lic_href_2000_pl')";
+ sqlite3 $WRT_DB "insert into LocalizedWidgetInfo(app_id, widget_locale) VALUES(2002, 'en')";
+ sqlite3 $WRT_DB "insert into LocalizedWidgetInfo(app_id, widget_locale) VALUES(2003, 'en')";
+
+#Widget features
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(1,2000, 'first_2000', 1, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(2,2000, 'second_2000', 1, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(3,2000, 'third_2000', 0, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(8,2000, 'fourth_2000', 1, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(9,2000, 'fifth_2000', 0, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(4,2001, 'first_2001', 1, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(5,2001, 'second_2001', 1, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(6,2001, 'third_2001', 0, 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE} VALUES(7,2001, 'fourth_2001', 1, 0)";
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(1, 'first_2000_first', 'firstValue1')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(1, 'first_2000_second', 'firstValue2')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(1, 'first_2000_third', 'firstValue3')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(1, 'first_2000_fourth', 'firstValue4')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(2, 'second_2000', 'secondValue1')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(3, 'third_2000', 'thirdValue1')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(4, 'first_2001', 'firstValue_2001')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(5, 'second_2001', 'secondValue_2001')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_FEATURE_PARAM} VALUES(6, 'third_2001', 'thirdValue_2001')";
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_ICONS} VALUES(2000, 'icon_src_2000', 50, 50)";
+ sqlite3 $WRT_DB "insert into WidgetIcon(app_id, icon_src) VALUES(2002, 'icon_src_2002')";
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_ICONS} VALUES(2000, 1, 'en')";
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2000, 'start_file_2000')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2001, 'start_file_2001')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2002, 'start_file_2002')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_STARTFILE} VALUES(2003, 'start_file_2003')";
+
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2000, 1, 'en', '', '')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2001, 2, 'en', '', '')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2002, 3, 'en', '', '')";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_LOC_STARTFILE} VALUES(2003, 4, 'en', '', '')";
+
+ #widget properties
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tid2000', 'key1_for_2000', 'value_for_key1_2000', 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tid2000', 'key2_for_2000', 'value_for_key2_2000', 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tid2001', 'key1_for_2001', 'value1_for_key_2001', 1)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tid2002', 'key1_for_2002', 'value1_for_key_2002', 0)";
+ sqlite3 $WRT_DB "${INS_ALL_WIDGET_PREF} VALUES('tid2002', 'key2_for_2002', 'value2_for_key_2002', 1)";
+
+
+ exit $?
+
+elif [ "x$1" == "xstop" ]; then
+ echo stop;
+ cp $WRT_DB_BCK $WRT_DB
+ exit $?
+else
+ exit 1
+fi