From d635ea27e46f4d05e2f9369216079aa90ec6c19b Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 17 Feb 2016 10:35:29 +0100 Subject: [PATCH 01/16] Rework smoke tests Reimplement smoke tests so that they don't use gtest's EXPECT_DEATH. This will fix problems that are sourced in forking test binary. "smoke-test-helper" binary is introduced purely for recovery tests to provide crash test scenario. Verification: - /usr/bin/wgt-backend-ut/smoke-test Change-Id: I76cb751ce13d88528de2da6e20ea3dd848e492a8 --- CMakeLists.txt | 4 +++- packaging/wgt-backend-tests.manifest | 1 + src/unit_tests/CMakeLists.txt | 16 +++++++++---- src/unit_tests/smoke_test.cc | 33 ++++++++++---------------- src/unit_tests/smoke_test_helper.cc | 45 ++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 src/unit_tests/smoke_test_helper.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 10b8412..d520638 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,11 @@ SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++11 -g --coverage") # Targets SET(TARGET_LIBNAME_WGT "wgt-installer") SET(TARGET_WGT_BACKEND "wgt-backend") -SET(TARGET_SMOKE_TEST "smoke_test") SET(TARGET_LIBNAME_HYBRID "hybrid-installer") +SET(TARGET_SMOKE_TEST "smoke-test") +SET(TARGET_SMOKE_TEST_HELPER "smoke-test-helper") + ADD_DEFINITIONS("-Wall") ADD_DEFINITIONS("-Wextra") ADD_DEFINITIONS("-fPIE") diff --git a/packaging/wgt-backend-tests.manifest b/packaging/wgt-backend-tests.manifest index 6c0eb4f..9e728be 100644 --- a/packaging/wgt-backend-tests.manifest +++ b/packaging/wgt-backend-tests.manifest @@ -4,5 +4,6 @@ + diff --git a/src/unit_tests/CMakeLists.txt b/src/unit_tests/CMakeLists.txt index f482f8f..e09827f 100644 --- a/src/unit_tests/CMakeLists.txt +++ b/src/unit_tests/CMakeLists.txt @@ -1,15 +1,19 @@ SET(DESTINATION_DIR wgt-backend-ut) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) - # Executables ADD_EXECUTABLE(${TARGET_SMOKE_TEST} smoke_test.cc ) +ADD_EXECUTABLE(${TARGET_SMOKE_TEST_HELPER} + smoke_test_helper.cc +) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) +TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST_HELPER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) INSTALL(DIRECTORY test_samples/ DESTINATION ${SHAREDIR}/${DESTINATION_DIR}/test_samples) -APPLY_PKG_CONFIG(smoke_test PUBLIC +APPLY_PKG_CONFIG(${TARGET_SMOKE_TEST} PUBLIC Boost GTEST ) @@ -17,6 +21,8 @@ APPLY_PKG_CONFIG(smoke_test PUBLIC # FindGTest module do not sets all needed libraries in GTEST_LIBRARIES and # GTest main libraries is still missing, so additional linking of # GTEST_MAIN_LIBRARIES is needed. -target_link_libraries(smoke_test PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES}) +target_link_libraries(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES}) +target_link_libraries(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT}) -INSTALL(TARGETS smoke_test DESTINATION ${BINDIR}/${DESTINATION_DIR}) +INSTALL(TARGETS ${TARGET_SMOKE_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR}) +INSTALL(TARGETS ${TARGET_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR}) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 5749361..551313c 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -46,15 +47,14 @@ const char KUserAppsDirBackup[] = "apps_rw.bck"; enum class RequestResult { NORMAL, - FAIL, - CRASH + FAIL }; class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface { public: bool CreatePkgMgrInstaller(pkgmgr_installer** installer, ci::InstallationMode* mode) { - *installer = pkgmgr_installer_new(); + *installer = pkgmgr_installer_offline_new(); if (!*installer) return false; *mode = ci::InstallationMode::ONLINE; @@ -71,19 +71,6 @@ enum class PackageType { HYBRID }; -class StepCrash : public ci::Step { - public: - using Step::Step; - - ci::Step::Status process() override { - raise(SIGSEGV); - return Status::OK; - } - ci::Step::Status clean() override { return ci::Step::Status::OK; } - ci::Step::Status undo() override { return ci::Step::Status::OK; } - ci::Step::Status precheck() override { return ci::Step::Status::OK; } -}; - void RemoveAllRecoveryFiles() { bf::path root_path = ci::GetRootAppPath(false); if (!bf::exists(root_path)) @@ -240,8 +227,6 @@ ci::AppInstaller::Result RunInstallerWithPkgrmgr(ci::PkgMgrPtr pkgmgr, case RequestResult::FAIL: installer->AddStep(); break; - case RequestResult::CRASH: - installer->AddStep(); default: break; } @@ -454,7 +439,9 @@ TEST_F(SmokeTest, DeltaMode) { TEST_F(SmokeTest, RecoveryMode_ForInstallation) { bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt"; - ASSERT_DEATH(Install(path, PackageType::WGT, RequestResult::CRASH), ".*"); + Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + backend_crash.Run("-i", path.string()); + ASSERT_NE(backend_crash.Wait(), 0); std::string pkgid = "smokeapp09"; std::string appid = "smokeapp09.RecoveryModeForInstallation"; @@ -469,8 +456,12 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) { bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt"; bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt"; RemoveAllRecoveryFiles(); - ASSERT_DEATH(Update(path_old, path_new, PackageType::WGT, - RequestResult::CRASH), ".*"); + Subprocess backend_test("/usr/bin/wgt-backend"); + backend_test.Run("-i", path_old.string()); + ASSERT_EQ(backend_test.Wait(), 0); + Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + backend_crash.Run("-i", path_new.string()); + ASSERT_NE(backend_crash.Wait(), 0); std::string pkgid = "smokeapp10"; std::string appid = "smokeapp10.RecoveryModeForUpdate"; diff --git a/src/unit_tests/smoke_test_helper.cc b/src/unit_tests/smoke_test_helper.cc new file mode 100644 index 0000000..c3988d6 --- /dev/null +++ b/src/unit_tests/smoke_test_helper.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#include +#include + +#include "wgt/wgt_app_query_interface.h" +#include "wgt/wgt_installer.h" + +namespace ci = common_installer; + +namespace { + +class StepCrash : public ci::Step { + public: + using Step::Step; + + ci::Step::Status process() override { + raise(SIGSEGV); + return Status::OK; + } + ci::Step::Status clean() override { return ci::Step::Status::OK; } + ci::Step::Status undo() override { return ci::Step::Status::OK; } + ci::Step::Status precheck() override { return ci::Step::Status::OK; } +}; + +} // namespace + +// this main of test binay in done purely for recovery smoke test. +int main(int argc, char** argv) { + ci::PkgmgrInstaller pkgmgr_installer; + wgt::WgtAppQueryInterface query_interface; + auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer, + &query_interface); + if (!pkgmgr) { + LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; + return EINVAL; + } + + wgt::WgtInstaller installer(pkgmgr); + installer.AddStep(); + return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; +} + -- 2.7.4 From 8978cfd34fd288d402178cbf79c0bb9434aed135 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Tue, 16 Feb 2016 10:07:24 +0100 Subject: [PATCH 02/16] Add StepCreatePerUserStorageDirectories to installation step Change-Id: If0a11756e3cafdc7aa8805c675b0e07f571625ff --- src/hybrid/hybrid_installer.cc | 2 ++ src/wgt/wgt_installer.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 534a980..7f875b3 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) ci::PluginsLauncher::ActionType::Install); AddStep(); AddStep(); + AddStep(); break; case ci::RequestType::Update: AddStep(pkgmgr_); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index d3ca732..4d3d84a 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -92,6 +93,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep( ci::PluginsLauncher::ActionType::Install); + AddStep(); AddStep(); break; } -- 2.7.4 From 8530e1915a2f4039b4664573c35dd9db258c279c Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Tue, 16 Feb 2016 10:12:14 +0100 Subject: [PATCH 03/16] Add StepRemovePerUserStorageDirectories to uninstall step Change-Id: If257ec6319f69c04e7fe6c6f6610d300398eb822 --- src/hybrid/hybrid_installer.cc | 2 ++ src/wgt/wgt_installer.cc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 7f875b3..8a7f0c9 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -141,6 +142,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep( ci::PluginsLauncher::ActionType::Uninstall); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 4d3d84a..1135fac 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -135,6 +136,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep( ci::PluginsLauncher::ActionType::Uninstall); + AddStep(); + AddStep(); AddStep(); AddStep(); -- 2.7.4 From 2917551657b81111aa69e111ff42d7abf473f2e3 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 24 Feb 2016 15:33:19 +0900 Subject: [PATCH 04/16] modification for seperation of RO/RW location Requires: https://review.tizen.org/gerrit/#/c/60194/ https://review.tizen.org/gerrit/#/c/60200/ Change-Id: I03e256854ffa6812952b7fb1e3f1e029f6c030ea Signed-off-by: jongmyeongko --- src/unit_tests/smoke_test.cc | 8 ++++---- src/wgt/step/step_generate_xml.cc | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 551313c..5f3c772 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -136,13 +136,13 @@ void ValidatePackageFS(const std::string& pkgid, ASSERT_TRUE(bf::exists(cache_path)); bf::path manifest_path = - bf::path(getUserManifestPath(getuid())) / (pkgid + ".xml"); + bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml"); ASSERT_TRUE(bf::exists(manifest_path)); for (auto& appid : appids) { bf::path binary_path = package_path / "bin" / appid; ASSERT_TRUE(bf::exists(binary_path)); - bf::path icon_path = bf::path(getIconPath(getuid())) / (appid + ".png"); + bf::path icon_path = bf::path(getIconPath(getuid(), false)) / (appid + ".png"); ASSERT_TRUE(bf::exists(icon_path)); bf::path icon_backup = ci::GetBackupPathForIconFile(icon_path); ASSERT_FALSE(bf::exists(icon_backup)); @@ -170,11 +170,11 @@ void PackageCheckCleanup(const std::string& pkgid, ASSERT_FALSE(bf::exists(package_path)); bf::path manifest_path = - bf::path(getUserManifestPath(getuid())) / (pkgid + ".xml"); + bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml"); ASSERT_FALSE(bf::exists(manifest_path)); for (auto& appid : appids) { - bf::path icon_path = bf::path(getIconPath(getuid())) / (appid + ".png"); + bf::path icon_path = bf::path(getIconPath(getuid(), false)) / (appid + ".png"); ASSERT_FALSE(bf::exists(icon_path)); bf::path icon_backup = ci::GetBackupPathForIconFile(icon_path); ASSERT_FALSE(bf::exists(icon_backup)); diff --git a/src/wgt/step/step_generate_xml.cc b/src/wgt/step/step_generate_xml.cc index dd82f5e..71d956f 100644 --- a/src/wgt/step/step_generate_xml.cc +++ b/src/wgt/step/step_generate_xml.cc @@ -245,7 +245,8 @@ common_installer::Step::Status StepGenerateXml::precheck() { } common_installer::Step::Status StepGenerateXml::process() { - bf::path xml_path = bf::path(getUserManifestPath(context_->uid.get())) + bf::path xml_path = + bf::path(getUserManifestPath(context_->uid.get(), false)) / bf::path(context_->pkgid.get()); xml_path += ".xml"; context_->xml_path.set(xml_path.string()); -- 2.7.4 From 8bc6db16d10d4a88a7775dfdd60d087656500b47 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Thu, 11 Feb 2016 12:51:14 +0100 Subject: [PATCH 05/16] Manifest testcase skeleton Testcase skeleton for tests which parse manifest and set fields in manifest_x structure. Verification: /usr/bin/wgt-backend-ut/manifest-test Change-Id: I4fde4bdcdcf38b2fb23979d3c8eef67d40f92d9d --- CMakeLists.txt | 1 + src/unit_tests/CMakeLists.txt | 10 +++ src/unit_tests/manifest_test.cc | 97 ++++++++++++++++++++++ .../config.xml | 4 + .../ManifestTest.WidgetElement_Valid/config.xml | 4 + 5 files changed, 116 insertions(+) create mode 100644 src/unit_tests/manifest_test.cc create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_InvalidNamespace/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_Valid/config.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index d520638..c7359f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ SET(TARGET_LIBNAME_HYBRID "hybrid-installer") SET(TARGET_SMOKE_TEST "smoke-test") SET(TARGET_SMOKE_TEST_HELPER "smoke-test-helper") +SET(TARGET_MANIFEST_TEST "manifest-test") ADD_DEFINITIONS("-Wall") ADD_DEFINITIONS("-Wextra") diff --git a/src/unit_tests/CMakeLists.txt b/src/unit_tests/CMakeLists.txt index e09827f..7222f1e 100644 --- a/src/unit_tests/CMakeLists.txt +++ b/src/unit_tests/CMakeLists.txt @@ -7,9 +7,13 @@ ADD_EXECUTABLE(${TARGET_SMOKE_TEST} ADD_EXECUTABLE(${TARGET_SMOKE_TEST_HELPER} smoke_test_helper.cc ) +ADD_EXECUTABLE(${TARGET_MANIFEST_TEST} + manifest_test.cc +) TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST_HELPER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) +TARGET_INCLUDE_DIRECTORIES(${TARGET_MANIFEST_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) INSTALL(DIRECTORY test_samples/ DESTINATION ${SHAREDIR}/${DESTINATION_DIR}/test_samples) @@ -17,12 +21,18 @@ APPLY_PKG_CONFIG(${TARGET_SMOKE_TEST} PUBLIC Boost GTEST ) +APPLY_PKG_CONFIG(${TARGET_MANIFEST_TEST} PUBLIC + Boost + GTEST +) # FindGTest module do not sets all needed libraries in GTEST_LIBRARIES and # GTest main libraries is still missing, so additional linking of # GTEST_MAIN_LIBRARIES is needed. target_link_libraries(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES}) target_link_libraries(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT}) +target_link_libraries(${TARGET_MANIFEST_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${GTEST_MAIN_LIBRARIES}) INSTALL(TARGETS ${TARGET_SMOKE_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR}) INSTALL(TARGETS ${TARGET_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR}) +INSTALL(TARGETS ${TARGET_MANIFEST_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR}) diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc new file mode 100644 index 0000000..fb74852 --- /dev/null +++ b/src/unit_tests/manifest_test.cc @@ -0,0 +1,97 @@ +// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache-2.0 license that can be +// found in the LICENSE file. + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include "wgt/step/step_parse.h" +#include "wgt/wgt_backend_data.h" + +#define ASSERT_CSTR_EQ(STR1, STR2) \ + ASSERT_EQ(strcmp(STR1, STR2), 0) \ + +namespace bf = boost::filesystem; +namespace ci = common_installer; + +namespace { + +const char kManifestTestcaseData[] = + "/usr/share/wgt-backend-ut/test_samples/manifest/"; + +template +gint Size(GListRange* range) { + return std::distance(range->begin(), range->end()); +} + +class StepParseRunner { + public: + explicit StepParseRunner(const std::string& dir_suffix, + bool ignore_start_files = true) + : dir_suffix_(dir_suffix), + ignore_start_files_(ignore_start_files), + context_(nullptr) { + } + + bool Run() { + PrepareContext(); + wgt::parse::StepParse step(context_.get(), !ignore_start_files_); + return step.process() == ci::Step::Status::OK; + } + + manifest_x* GetManifest() const { + return context_->manifest_data.get(); + } + + private: + void PrepareContext() { + context_.reset(new ci::InstallerContext()); + context_->root_application_path.set(ci::GetRootAppPath(false)); + context_->unpacked_dir_path.set( + bf::path(kManifestTestcaseData) / dir_suffix_); + context_->backend_data.set(new wgt::WgtBackendData()); + } + + std::string dir_suffix_; + bool ignore_start_files_; + std::unique_ptr context_; +}; + +} // namespace + +class ManifestTest : public testing::Test { + public: + std::string GetMyName() const { + std::string suite = + testing::UnitTest::GetInstance()->current_test_info()->test_case_name(); + std::string case_name = + testing::UnitTest::GetInstance()->current_test_info()->name(); + return suite + '.' + case_name; + } +}; + +TEST_F(ManifestTest, WidgetElement_Valid) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + ASSERT_CSTR_EQ(m->package, "package0id"); + auto apps = GListRange(m->application); + ASSERT_EQ(Size(&apps), 1); + application_x* app = *apps.begin(); + ASSERT_CSTR_EQ(app->appid, "package0id.appid"); +} + +TEST_F(ManifestTest, WidgetElement_InvalidNamespace) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_InvalidNamespace/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_InvalidNamespace/config.xml new file mode 100644 index 0000000..d4c2eef --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_InvalidNamespace/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_Valid/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_Valid/config.xml new file mode 100644 index 0000000..14d024a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_Valid/config.xml @@ -0,0 +1,4 @@ + + + + -- 2.7.4 From ab9feb2999de787c3b641c95622feaf1159333c0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Tue, 1 Mar 2016 12:04:03 +0100 Subject: [PATCH 06/16] Add tests for Widget element in config.xml Change-Id: I27e3ad033c00a1169e37d3010695b55fe1369486 --- src/unit_tests/manifest_test.cc | 12 ++++++++++++ .../ManifestTest.WidgetElement_ManyNamespaces/config.xml | 4 ++++ .../ManifestTest.WidgetElement_MissingNamespace/config.xml | 4 ++++ 3 files changed, 20 insertions(+) create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_ManyNamespaces/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_MissingNamespace/config.xml diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index fb74852..81358bd 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -95,3 +95,15 @@ TEST_F(ManifestTest, WidgetElement_InvalidNamespace) { StepParseRunner runner(GetMyName()); ASSERT_FALSE(runner.Run()); } + +TEST_F(ManifestTest, WidgetElement_MissingNamespace) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, WidgetElement_ManyNamespaces) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_ManyNamespaces/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_ManyNamespaces/config.xml new file mode 100644 index 0000000..0e1033a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_ManyNamespaces/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_MissingNamespace/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_MissingNamespace/config.xml new file mode 100644 index 0000000..862d3cb --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.WidgetElement_MissingNamespace/config.xml @@ -0,0 +1,4 @@ + + + + -- 2.7.4 From 67ce999e6a24c025fb7c8b695cb884aa0057c809 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 2 Mar 2016 16:13:41 +0100 Subject: [PATCH 07/16] Fix GetPackageVersion() Version of widget (defined in w3c spec) is less strict than tizen package number. This commit fixes GetPackageVersion() to set default version if conversion of version number is not possible. To verify, install/update wgt package which version is "1.2.3 Beta". "Beta" keyword should be trucated so that manifest contains valid version of tizen package -> "1.2.3". Change-Id: Iab5eed29f8cb7c8a0a52cb515c16ce0ab5d1ac91 --- src/wgt/step/step_parse.cc | 22 ++++++++++++++++++---- src/wgt/step/step_parse.h | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/wgt/step/step_parse.cc b/src/wgt/step/step_parse.cc index 705dc95..cb77e28 100644 --- a/src/wgt/step/step_parse.cc +++ b/src/wgt/step/step_parse.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -95,11 +96,24 @@ std::set StepParse::ExtractPrivileges( return perm_info->GetAPIPermissions(); } -const std::string& StepParse::GetPackageVersion( +std::string StepParse::GetPackageVersion( const std::string& manifest_version) { - if (!manifest_version.empty()) - return manifest_version; - return kManifestVersion; + if (manifest_version.empty()) { + return kManifestVersion; + } + std::string version = manifest_version.substr(0, + manifest_version.find_first_not_of("1234567890.")); + + utils::VersionNumber version_number(version); + + if (!version_number.IsValidTizenPackageVersion()) { + LOG(WARNING) << "Version number: " << manifest_version + << " is not valid version number for tizen package. " + << "Default value will be used."; + return kManifestVersion; + } + + return version_number.ToString(); } bool StepParse::FillInstallationInfo(manifest_x* manifest) { diff --git a/src/wgt/step/step_parse.h b/src/wgt/step/step_parse.h index 0737b9d..06956b0 100644 --- a/src/wgt/step/step_parse.h +++ b/src/wgt/step/step_parse.h @@ -45,7 +45,7 @@ class StepParse : public common_installer::Step { std::set ExtractPrivileges( std::shared_ptr perm_info) const; - const std::string& GetPackageVersion(const std::string& manifest_version); + std::string GetPackageVersion(const std::string& manifest_version); bool FillInstallationInfo(manifest_x* manifest); bool FillIconPaths(manifest_x* manifest); -- 2.7.4 From 9fcb4684a329faa451abaa3dd6566c492eb1257c Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Mon, 8 Feb 2016 10:40:47 +0100 Subject: [PATCH 08/16] Adjust wgt-backend to plugin changes Following changes should be submitted together: - https://review.tizen.org/gerrit/#/c/59029/ - https://review.tizen.org/gerrit/#/c/59028/ - https://review.tizen.org/gerrit/#/c/59030/ - https://review.tizen.org/gerrit/#/c/59031/ Change-Id: Ic9811af492e2f15bc1fb24e5a69b0aa0530fc02f --- src/hybrid/hybrid_installer.cc | 8 ++++---- src/wgt/wgt_installer.cc | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 8a7f0c9..8e60fc2 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -94,7 +94,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep( - ci::PluginsLauncher::ActionType::Install); + ci::Plugin::ActionType::Install); AddStep(); AddStep(); AddStep(); @@ -132,7 +132,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep( - ci::PluginsLauncher::ActionType::Upgrade); + ci::Plugin::ActionType::Upgrade); break; case ci::RequestType::Uninstall: AddStep(pkgmgr_); @@ -140,7 +140,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) ci::parse::StepParseManifest::ManifestLocation::INSTALLED, ci::parse::StepParseManifest::StoreLocation::NORMAL); AddStep( - ci::PluginsLauncher::ActionType::Uninstall); + ci::Plugin::ActionType::Uninstall); AddStep(); AddStep(); AddStep(); @@ -189,7 +189,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep( - ci::PluginsLauncher::ActionType::Upgrade); + ci::Plugin::ActionType::Upgrade); break; case ci::RequestType::Recovery: AddStep(pkgmgr_); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 1135fac..c1c4e7f 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -93,7 +93,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep( - ci::PluginsLauncher::ActionType::Install); + ci::Plugin::ActionType::Install); AddStep(); AddStep(); break; @@ -124,7 +124,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep( - ci::PluginsLauncher::ActionType::Upgrade); + ci::Plugin::ActionType::Upgrade); AddStep(); break; } @@ -135,9 +135,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) ci::parse::StepParseManifest::StoreLocation::NORMAL); AddStep(); AddStep( - ci::PluginsLauncher::ActionType::Uninstall); + ci::Plugin::ActionType::Uninstall); AddStep(); - AddStep(); AddStep(); AddStep(); @@ -189,7 +188,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep( - ci::PluginsLauncher::ActionType::Upgrade); + ci::Plugin::ActionType::Upgrade); AddStep(); break; } -- 2.7.4 From ed92a8de6b4dbcede652a881201001b65d2103d3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Tue, 1 Mar 2016 13:17:17 +0100 Subject: [PATCH 09/16] Add tests for Application element in config.xml Change-Id: I195ed3e15dff2655327ec0a12064c701427f2220 --- src/unit_tests/manifest_test.cc | 65 ++++++++++++++++++++++ .../config.xml | 4 ++ .../config.xml | 4 ++ .../config.xml | 4 ++ .../config.xml | 5 ++ .../config.xml | 4 ++ .../config.xml | 4 ++ .../config.xml | 4 ++ .../config.xml | 4 ++ .../config.xml | 4 ++ .../config.xml | 4 ++ 11 files changed, 106 insertions(+) create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidAppId/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidPackage/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidVersion/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ManyElements/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingAppId/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingPackage/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingVersion/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidAppId/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidPackage/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidVersion/config.xml diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 81358bd..ec3e1c2 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -106,4 +106,69 @@ TEST_F(ManifestTest, WidgetElement_ManyNamespaces) { ASSERT_FALSE(runner.Run()); } +TEST_F(ManifestTest, ApplicationElement_ManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ApplicationElement_ValidAppId) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto apps = GListRange(m->application); + application_x* app = *apps.begin(); + ASSERT_NE(app, nullptr); + ASSERT_CSTR_EQ(app->appid, "package0id.appid"); +} + +TEST_F(ManifestTest, ApplicationElement_MissingAppId) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ApplicationElement_InvalidAppId) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ApplicationElement_ValidPackage) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + ASSERT_CSTR_EQ(m->package, "package0id"); +} + +TEST_F(ManifestTest, ApplicationElement_InvalidPackage) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ApplicationElement_MissingPackage) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ApplicationElement_ValidVersion) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + ASSERT_CSTR_EQ(m->api_version, "3.0"); +} + +TEST_F(ManifestTest, ApplicationElement_InvalidVersion) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ApplicationElement_MissingVersion) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidAppId/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidAppId/config.xml new file mode 100644 index 0000000..e0a53e1 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidAppId/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidPackage/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidPackage/config.xml new file mode 100644 index 0000000..671c8e0 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidPackage/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidVersion/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidVersion/config.xml new file mode 100644 index 0000000..0edbe47 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_InvalidVersion/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ManyElements/config.xml new file mode 100644 index 0000000..c4cd426 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ManyElements/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingAppId/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingAppId/config.xml new file mode 100644 index 0000000..80a23d3 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingAppId/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingPackage/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingPackage/config.xml new file mode 100644 index 0000000..2e8076c --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingPackage/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingVersion/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingVersion/config.xml new file mode 100644 index 0000000..8e328b7 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_MissingVersion/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidAppId/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidAppId/config.xml new file mode 100644 index 0000000..14d024a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidAppId/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidPackage/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidPackage/config.xml new file mode 100644 index 0000000..14d024a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidPackage/config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidVersion/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidVersion/config.xml new file mode 100644 index 0000000..14d024a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ApplicationElement_ValidVersion/config.xml @@ -0,0 +1,4 @@ + + + + -- 2.7.4 From 251d33933637501b858da5ce0726588fc32834d2 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Thu, 25 Feb 2016 10:26:51 +0100 Subject: [PATCH 10/16] Adjust moving storage directories - 'shared/' -> 'shared/res/' Requirement changed. We need to copy only 'shared/res/'. To verify install, update, uninstall wgt package that contains files in /shared/res/ and check if they were moved properly to install location's shared/res/. Change-Id: I20b8fcc174423ce74dcba5c9f6c116b1443f452e --- src/wgt/step/step_wgt_patch_storage_directories.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/wgt/step/step_wgt_patch_storage_directories.cc b/src/wgt/step/step_wgt_patch_storage_directories.cc index c6a7a94..e6f976e 100644 --- a/src/wgt/step/step_wgt_patch_storage_directories.cc +++ b/src/wgt/step/step_wgt_patch_storage_directories.cc @@ -16,6 +16,7 @@ namespace bs = boost::system; namespace { const char kSharedLocation[] = "shared"; +const char kSharedResLocation[] = "shared/res"; const char kResWgtSubPath[] = "res/wgt"; const char kTemporaryData[] = "tmp"; @@ -39,8 +40,19 @@ common_installer::Step::Status StepWgtPatchStorageDirectories::process() { } bool StepWgtPatchStorageDirectories::ShareDirFor3x() { - bf::path src = context_->pkg_path.get() / kResWgtSubPath / kSharedLocation; - bf::path dst = context_->pkg_path.get() / kSharedLocation; + bf::path shared_dir = context_->pkg_path.get() / kSharedLocation; + if (!bf::exists(shared_dir)) { + bs::error_code error; + bf::create_directory(shared_dir); + if (error) { + LOG(ERROR) << "Failed to create directory: " << shared_dir; + return false; + } + } + bf::path src = context_->pkg_path.get() / kResWgtSubPath / kSharedResLocation; + if (!bf::exists(src)) + return true; + bf::path dst = context_->pkg_path.get() / kSharedResLocation; if (!common_installer::MoveDir(src, dst, common_installer::FS_MERGE_DIRECTORIES)) { LOG(ERROR) << "Failed to move shared data from res/wgt to shared"; -- 2.7.4 From a6026597c314561e39ff7b94f928e4559628a8cc Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Tue, 1 Mar 2016 14:39:21 +0100 Subject: [PATCH 11/16] Add tests for Privilege element in config.xml Change-Id: Ic0bd88aa5fa8c7024d2756cea9ec84dfd6d0c9fd --- src/unit_tests/manifest_test.cc | 42 ++++++++++++++++++++++ .../config.xml | 5 +++ .../config.xml | 6 ++++ .../config.xml | 5 +++ .../config.xml | 5 +++ 5 files changed, 63 insertions(+) create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_InvalidName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ManyElements/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_MissingName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ValidName/config.xml diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index ec3e1c2..e705cac 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -13,6 +13,7 @@ #include #include +#include #include "wgt/step/step_parse.h" #include "wgt/wgt_backend_data.h" @@ -168,7 +169,48 @@ TEST_F(ManifestTest, ApplicationElement_MissingVersion) { ASSERT_FALSE(runner.Run()); } +TEST_F(ManifestTest, PrivilegeElement_ValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto apps = GListRange(m->application); + application_x* app = *apps.begin(); + std::vector priv_vec; + for (const char* priv : GListRange(m->privileges)) { + priv_vec.push_back(priv); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://tizen.org/privilege/application.launch"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); +} +TEST_F(ManifestTest, PrivilegeElement_ManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto apps = GListRange(m->application); + application_x* app = *apps.begin(); + std::vector priv_vec; + for (const char* priv : GListRange(m->privileges)) { + priv_vec.push_back(priv); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://tizen.org/privilege/application.close"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://tizen.org/privilege/application.launch"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); +} +TEST_F(ManifestTest, PrivilegeElement_InvalidName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, PrivilegeElement_MissingName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_InvalidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_InvalidName/config.xml new file mode 100644 index 0000000..6fb0b33 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_InvalidName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ManyElements/config.xml new file mode 100644 index 0000000..94fbcc1 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ManyElements/config.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_MissingName/config.xml new file mode 100644 index 0000000..a9defae --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_MissingName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ValidName/config.xml new file mode 100644 index 0000000..f4ff663 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ValidName/config.xml @@ -0,0 +1,5 @@ + + + + + -- 2.7.4 From 879048abb2f7c3c643905d13908703850fe368e0 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 24 Feb 2016 09:33:50 +0100 Subject: [PATCH 12/16] Processing watch application from config.xml Writes information about wgt's watch application to manifest_x and adds it to generated platform xml in wgt-backend. In tizen 2.x watch-application was not registered by wgt-installer AT ALL. This was done libwatch-application.so pkgmgr plugin parser. This behaviour should be probably removed so that only app-installer insert data into pkgmgr database. After this commit data of all applications (including watch-application) is added to pkgmgr_parser.db. Note that update installation of watch-application will work only when tizen-manifest.xml parsing changes will be introduced. Requires: - https://review.tizen.org/gerrit/#/c/60241/ Change-Id: I67f9cf1c04ecf435cfc90f5ab83d2ccebbc45a4a --- src/wgt/step/step_generate_xml.cc | 13 +++++++++++++ src/wgt/step/step_generate_xml.h | 3 ++- src/wgt/step/step_parse.cc | 31 +++++++++++++++++++++++++++---- src/wgt/step/step_parse.h | 2 +- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/wgt/step/step_generate_xml.cc b/src/wgt/step/step_generate_xml.cc index 71d956f..176c908 100644 --- a/src/wgt/step/step_generate_xml.cc +++ b/src/wgt/step/step_generate_xml.cc @@ -87,6 +87,13 @@ void WriteWidgetApplicationAttributes( BAD_CAST app->multiple); } +void WriteWatchApplicationAttributes( + xmlTextWriterPtr writer, application_x *app) { + if (app->ambient_support) + xmlTextWriterWriteAttribute(writer, BAD_CAST "ambient-support", + BAD_CAST app->ambient_support); +} + } // namespace namespace wgt { @@ -120,6 +127,9 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml( case AppCompType::WIDGETAPP: WriteWidgetApplicationAttributes(writer, app); break; + case AppCompType::WATCHAPP: + WriteWatchApplicationAttributes(writer, app); + break; } for (label_x* label : GListRange(app->label)) { @@ -338,6 +348,9 @@ common_installer::Step::Status StepGenerateXml::process() { } else if (strcmp(app->component_type, "widgetapp") == 0) { type = AppCompType::WIDGETAPP; xmlTextWriterStartElement(writer, BAD_CAST "widget-application"); + } else if (strcmp(app->component_type, "watchapp") == 0) { + type = AppCompType::WATCHAPP; + xmlTextWriterStartElement(writer, BAD_CAST "watch-application"); } else { LOG(ERROR) << "Unknown application component_type"; xmlFreeTextWriter(writer); diff --git a/src/wgt/step/step_generate_xml.h b/src/wgt/step/step_generate_xml.h index 5351991..0f62498 100644 --- a/src/wgt/step/step_generate_xml.h +++ b/src/wgt/step/step_generate_xml.h @@ -29,7 +29,8 @@ class StepGenerateXml : public common_installer::Step { enum class AppCompType { UIAPP, SVCAPP, - WIDGETAPP + WIDGETAPP, + WATCHAPP }; Step::Status GenerateApplicationCommonXml(application_x* app, diff --git a/src/wgt/step/step_parse.cc b/src/wgt/step/step_parse.cc index cb77e28..935b303 100644 --- a/src/wgt/step/step_parse.cc +++ b/src/wgt/step/step_parse.cc @@ -43,6 +43,10 @@ namespace bf = boost::filesystem; namespace { +const char kCategoryWearableClock[] = + "http://tizen.org/category/wearable_clock"; +const char kCategoryWatchClock[] = "com.samsung.wmanager.WATCH_CLOCK"; + const std::string kManifestVersion = "1.0.0"; const char kTizenPackageXmlNamespace[] = "http://tizen.org/ns/packages"; @@ -60,7 +64,6 @@ GList* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info) { } void SetApplicationXDefaults(application_x* application) { - application->ambient_support = strdup("false"); application->effectimage_type = strdup("image"); application->enabled = strdup("true"); application->guestmode_visibility = strdup("true"); @@ -234,7 +237,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { return true; } -bool StepParse::FillUIApplicationInfo(manifest_x* manifest) { +bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { std::shared_ptr app_info = std::static_pointer_cast( parser_->GetManifestData(app_keys::kTizenApplicationKey)); @@ -242,15 +245,34 @@ bool StepParse::FillUIApplicationInfo(manifest_x* manifest) { LOG(ERROR) << "Application info manifest data has not been found."; return false; } + bool has_watch_catergory = false; + std::shared_ptr category_info = + std::static_pointer_cast(parser_->GetManifestData( + app_keys::kTizenCategoryKey)); + if (category_info) { + has_watch_catergory = std::find_if(category_info->categories.begin(), + category_info->categories.end(), + [](const std::string& category) { + return category == kCategoryWearableClock || + category == kCategoryWatchClock; + }) != category_info->categories.end(); + } + // application data application_x* application = reinterpret_cast( calloc(1, sizeof(application_x))); - application->component_type = strdup("uiapp"); + application->component_type = + has_watch_catergory ? strdup("watchapp") : strdup("uiapp"); application->mainapp = strdup("true"); application->nodisplay = strdup("false"); application->multiple = strdup("false"); application->appid = strdup(app_info->id().c_str()); SetApplicationXDefaults(application); + if (has_watch_catergory) + application->ambient_support = + strdup(app_info->ambient_support() ? "true" : "false"); + else + application->ambient_support = strdup("false"); application->package = strdup(app_info->package().c_str()); application->exec = @@ -298,6 +320,7 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { application->autorestart = service_info.auto_restart() ? strdup("true") : strdup("false"); SetApplicationXDefaults(application); + application->ambient_support = strdup("false"); application->package = strdup(manifest->package); for (auto& pair : service_info.names()) { @@ -449,7 +472,7 @@ bool StepParse::FillExtraManifestInfo(manifest_x* manifest) { bool StepParse::FillManifestX(manifest_x* manifest) { if (!FillIconPaths(manifest)) return false; - if (!FillUIApplicationInfo(manifest)) + if (!FillMainApplicationInfo(manifest)) return false; if (!FillWidgetInfo(manifest)) return false; diff --git a/src/wgt/step/step_parse.h b/src/wgt/step/step_parse.h index 06956b0..dc723cb 100644 --- a/src/wgt/step/step_parse.h +++ b/src/wgt/step/step_parse.h @@ -50,7 +50,7 @@ class StepParse : public common_installer::Step { bool FillInstallationInfo(manifest_x* manifest); bool FillIconPaths(manifest_x* manifest); bool FillWidgetInfo(manifest_x* manifest); - bool FillUIApplicationInfo(manifest_x* manifest); + bool FillMainApplicationInfo(manifest_x* manifest); bool FillServiceApplicationInfo(manifest_x* manifest); bool FillAppControl(manifest_x* manifest); bool FillPrivileges(manifest_x* manifest); -- 2.7.4 From 5ab4cba32c7d7e18a841f335983e9c8faa1ac58f Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Tue, 1 Mar 2016 15:05:08 +0100 Subject: [PATCH 13/16] Add tests for AppControl element in config.xml Change-Id: I87f8c009e0ba9074e2e7bfd0947393856fdc8bd8 --- src/unit_tests/manifest_test.cc | 60 ++++++++++++++++++++++ .../config.xml | 9 ++++ .../config.xml | 9 ++++ .../config.xml | 9 ++++ .../config.xml | 9 ++++ .../config.xml | 10 ++++ 6 files changed, 106 insertions(+) create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingMIME/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingOperation/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingSrc/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingURI/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_Valid/config.xml diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index e705cac..9e827f5 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -213,4 +213,64 @@ TEST_F(ManifestTest, PrivilegeElement_MissingName) { ASSERT_FALSE(runner.Run()); } +TEST_F(ManifestTest, AppControlElement_Valid) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto apps = GListRange(m->application); + application_x* app = *apps.begin(); + ASSERT_NE(app, nullptr); + std::vector app_controls; + for (appcontrol_x* app_control : GListRange(app->appcontrol)) { + app_controls.push_back(app_control); + } + ASSERT_EQ(app_controls.size(), 1); + ASSERT_CSTR_EQ(app_controls[0]->mime, "image/jpg"); + ASSERT_CSTR_EQ(app_controls[0]->operation, + "http://tizen.org/appcontrol/operation/edit"); + ASSERT_CSTR_EQ(app_controls[0]->uri, "myapp"); +} + +TEST_F(ManifestTest, AppControlElement_MissingMIME) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto apps = GListRange(m->application); + application_x* app = *apps.begin(); + ASSERT_NE(app, nullptr); + std::vector app_controls; + for (appcontrol_x* app_control : GListRange(app->appcontrol)) { + app_controls.push_back(app_control); + } + ASSERT_CSTR_EQ(app_controls[0]->mime, ""); +} + +TEST_F(ManifestTest, AppControlElement_MissingOperation) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppControlElement_MissingSrc) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppControlElement_MissingURI) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto apps = GListRange(m->application); + application_x* app = *apps.begin(); + ASSERT_NE(app, nullptr); + std::vector app_controls; + for (appcontrol_x* app_control : GListRange(app->appcontrol)) { + app_controls.push_back(app_control); + } + ASSERT_CSTR_EQ(app_controls[0]->uri, ""); +} + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingMIME/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingMIME/config.xml new file mode 100644 index 0000000..a0f5c94 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingMIME/config.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingOperation/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingOperation/config.xml new file mode 100644 index 0000000..6e9f364 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingOperation/config.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingSrc/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingSrc/config.xml new file mode 100644 index 0000000..4aa7ace --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingSrc/config.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingURI/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingURI/config.xml new file mode 100644 index 0000000..8101514 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingURI/config.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_Valid/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_Valid/config.xml new file mode 100644 index 0000000..cdbd2eb --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_Valid/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + -- 2.7.4 From 0d803c7d23bd414c428250d31ad79fabe1b79060 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szulakiewicz Date: Fri, 4 Mar 2016 10:03:02 +0100 Subject: [PATCH 14/16] Add tests for Setting element in config.xml Change-Id: I5611261dc271b305191526e4e774e48f16d02e36 --- src/unit_tests/manifest_test.cc | 194 +++++++++++++++++++++ .../config.xml | 12 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 11 ++ .../config.xml | 10 ++ .../config.xml | 10 ++ .../config.xml | 10 ++ .../config.xml | 10 ++ .../config.xml | 10 ++ .../config.xml | 10 ++ .../config.xml | 10 ++ .../ManifestTest.SettingsElement_Valid/config.xml | 11 ++ 19 files changed, 386 insertions(+) create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportDisabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportEnabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationDisabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationEnabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuDisabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuEnabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionDisabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionEnabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyDisabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyEnabled/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundSupport/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundVibration/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingContextMenu/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingEncryption/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingHwKeyEvent/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingInstallLocation/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingScreenOrientation/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_Valid/config.xml diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 9e827f5..4bc380a 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -8,6 +8,8 @@ #include #include +#include + #include #include @@ -49,6 +51,10 @@ class StepParseRunner { return step.process() == ci::Step::Status::OK; } + wgt::WgtBackendData* GetBackendData() const { + return static_cast(context_->backend_data.get()); + } + manifest_x* GetManifest() const { return context_->manifest_data.get(); } @@ -272,5 +278,193 @@ TEST_F(ManifestTest, AppControlElement_MissingURI) { ASSERT_CSTR_EQ(app_controls[0]->uri, ""); } +TEST_F(ManifestTest, SettingsElement_Valid) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + + ASSERT_EQ(settings.background_support_enabled(), true); + ASSERT_EQ(settings.context_menu_enabled(), false); + ASSERT_EQ(settings.encryption_enabled(), true); + ASSERT_EQ(settings.screen_orientation(), + wgt::parse::SettingInfo::ScreenOrientation::LANDSCAPE); + ASSERT_EQ(settings.install_location(), + wgt::parse::SettingInfo::InstallLocation::INTERNAL); + ASSERT_EQ(settings.hwkey_enabled(), true); + ASSERT_EQ(settings.background_vibration(), true); +} + +TEST_F(ManifestTest, SettingsElement_BackgroundSupportEnabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.background_support_enabled(), true); +} + +TEST_F(ManifestTest, SettingsElement_BackgroundSupportDisabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.background_support_enabled(), false); +} + +TEST_F(ManifestTest, SettingsElement_MissingBackgroundSupport) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.background_support_enabled(), false); +} + +TEST_F(ManifestTest, SettingsElement_BackgroundVibrationEnabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.background_vibration(), true); +} + +TEST_F(ManifestTest, SettingsElement_BackgroundVibrationDisabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.background_vibration(), false); +} + +TEST_F(ManifestTest, SettingsElement_MissingBackgroundVibration) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.background_vibration(), false); +} + +TEST_F(ManifestTest, SettingsElement_ContextMenuEnabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.context_menu_enabled(), true); +} + +TEST_F(ManifestTest, SettingsElement_ContextMenuDisabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.context_menu_enabled(), false); +} + +TEST_F(ManifestTest, SettingsElement_MissingContextMenu) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.context_menu_enabled(), true); +} + +TEST_F(ManifestTest, SettingsElement_EncryptionEnabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.encryption_enabled(), true); +} + +TEST_F(ManifestTest, SettingsElement_EncryptionDisabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.encryption_enabled(), false); +} + +TEST_F(ManifestTest, SettingsElement_MissingEncryption) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.encryption_enabled(), false); +} + +TEST_F(ManifestTest, SettingsElement_HwKeyEnabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.hwkey_enabled(), true); +} +TEST_F(ManifestTest, SettingsElement_HwKeyDisabled) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.hwkey_enabled(), false); +} +TEST_F(ManifestTest, SettingsElement_MissingHwKeyEvent) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.hwkey_enabled(), true); +} + +TEST_F(ManifestTest, SettingsElement_MissingInstallLocation) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.install_location(), + wgt::parse::SettingInfo::InstallLocation::AUTO); +} + +TEST_F(ManifestTest, SettingsElement_MissingScreenOrientation) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + auto backend_data = runner.GetBackendData(); + auto settings = backend_data->settings.get(); + ASSERT_EQ(settings.screen_orientation(), + wgt::parse::SettingInfo::ScreenOrientation::AUTO); +} diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportDisabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportDisabled/config.xml new file mode 100644 index 0000000..ef25267 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportDisabled/config.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportEnabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportEnabled/config.xml new file mode 100644 index 0000000..90a4aea --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundSupportEnabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationDisabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationDisabled/config.xml new file mode 100644 index 0000000..421c7b1 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationDisabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationEnabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationEnabled/config.xml new file mode 100644 index 0000000..90a4aea --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_BackgroundVibrationEnabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuDisabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuDisabled/config.xml new file mode 100644 index 0000000..90a4aea --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuDisabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuEnabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuEnabled/config.xml new file mode 100644 index 0000000..1f688a2 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_ContextMenuEnabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionDisabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionDisabled/config.xml new file mode 100644 index 0000000..441d232 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionDisabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionEnabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionEnabled/config.xml new file mode 100644 index 0000000..90a4aea --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_EncryptionEnabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyDisabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyDisabled/config.xml new file mode 100644 index 0000000..3b10bc5 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyDisabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyEnabled/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyEnabled/config.xml new file mode 100644 index 0000000..90a4aea --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_HwKeyEnabled/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundSupport/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundSupport/config.xml new file mode 100644 index 0000000..ed8fc2a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundSupport/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundVibration/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundVibration/config.xml new file mode 100644 index 0000000..798ae31 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingBackgroundVibration/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingContextMenu/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingContextMenu/config.xml new file mode 100644 index 0000000..bd72968 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingContextMenu/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingEncryption/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingEncryption/config.xml new file mode 100644 index 0000000..699bdcd --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingEncryption/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingHwKeyEvent/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingHwKeyEvent/config.xml new file mode 100644 index 0000000..5ec89c9 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingHwKeyEvent/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingInstallLocation/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingInstallLocation/config.xml new file mode 100644 index 0000000..523fde8 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingInstallLocation/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingScreenOrientation/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingScreenOrientation/config.xml new file mode 100644 index 0000000..b2b92f3 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_MissingScreenOrientation/config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_Valid/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_Valid/config.xml new file mode 100644 index 0000000..90a4aea --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.SettingsElement_Valid/config.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + -- 2.7.4 From 67b2b7d92685e86d5614e0d2d06b0d5b3e3fa42b Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 11 Mar 2016 14:16:14 +0900 Subject: [PATCH 15/16] Remove unused variable at unit test Change-Id: I78dfb119eeb9b45ef0133631b481191a08996aa8 Signed-off-by: Sangyoon Jang --- src/unit_tests/manifest_test.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 4bc380a..9eee758 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -180,8 +180,6 @@ TEST_F(ManifestTest, PrivilegeElement_ValidName) { ASSERT_TRUE(runner.Run()); manifest_x* m = runner.GetManifest(); ASSERT_NE(m, nullptr); - auto apps = GListRange(m->application); - application_x* app = *apps.begin(); std::vector priv_vec; for (const char* priv : GListRange(m->privileges)) { priv_vec.push_back(priv); @@ -196,8 +194,6 @@ TEST_F(ManifestTest, PrivilegeElement_ManyElements) { ASSERT_TRUE(runner.Run()); manifest_x* m = runner.GetManifest(); ASSERT_NE(m, nullptr); - auto apps = GListRange(m->application); - application_x* app = *apps.begin(); std::vector priv_vec; for (const char* priv : GListRange(m->privileges)) { priv_vec.push_back(priv); -- 2.7.4 From ccf2c1dc2a33d638f75f320410146919d991b896 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 11 Mar 2016 15:28:32 +0900 Subject: [PATCH 16/16] Check removable when uninstall package Requires: - https://review.tizen.org/gerrit/61899 Change-Id: I02ad18a259206b8923825590a16045b9fd489b12 Signed-off-by: Sangyoon Jang --- src/hybrid/hybrid_installer.cc | 2 ++ src/wgt/wgt_installer.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 8e60fc2..834db03 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -136,6 +137,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) break; case ci::RequestType::Uninstall: AddStep(pkgmgr_); + AddStep(); AddStep( ci::parse::StepParseManifest::ManifestLocation::INSTALLED, ci::parse::StepParseManifest::StoreLocation::NORMAL); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index c1c4e7f..fa66402 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -130,6 +131,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) } case ci::RequestType::Uninstall: { AddStep(pkgmgr_); + AddStep(); AddStep( ci::parse::StepParseManifest::ManifestLocation::INSTALLED, ci::parse::StepParseManifest::StoreLocation::NORMAL); -- 2.7.4