1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #include <boost/filesystem/operations.hpp>
6 #include <boost/filesystem/path.hpp>
7 #include <boost/range/iterator_range.hpp>
8 #include <boost/system/error_code.hpp>
9 #include <common/backup_paths.h>
10 #include <common/pkgmgr_interface.h>
11 #include <common/pkgmgr_registration.h>
12 #include <common/request.h>
13 #include <common/step/configuration/step_fail.h>
14 #include <common/utils/subprocess.h>
15 #include <gtest/gtest.h>
16 #include <gtest/gtest-death-test.h>
17 #include <pkgmgr-info.h>
20 #include <tzplatform_config.h>
27 #include "hybrid/hybrid_installer.h"
28 #include "wgt/wgt_app_query_interface.h"
29 #include "wgt/wgt_installer.h"
31 #define SIZEOFARRAY(ARR) \
32 sizeof(ARR) / sizeof(ARR[0]) \
34 namespace bf = boost::filesystem;
35 namespace bs = boost::system;
36 namespace ci = common_installer;
40 const bf::path kSmokePackagesDirectory =
41 "/usr/share/wgt-backend-ut/test_samples/smoke/";
43 const char kApplicationDir[] = ".applications";
44 const char kApplicationDirBackup[] = ".applications.bck";
45 const char KUserAppsDir[] = "apps_rw";
46 const char KUserAppsDirBackup[] = "apps_rw.bck";
48 enum class RequestResult {
53 class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface {
55 bool CreatePkgMgrInstaller(pkgmgr_installer** installer,
56 ci::InstallationMode* mode) {
57 *installer = pkgmgr_installer_offline_new();
60 *mode = ci::InstallationMode::ONLINE;
64 bool ShouldCreateSignal() const {
69 enum class PackageType {
74 bool TouchFile(const bf::path& path) {
75 FILE* f = fopen(path.c_str(), "w+");
82 void RemoveAllRecoveryFiles() {
83 bf::path root_path = ci::GetRootAppPath(false);
84 if (!bf::exists(root_path))
86 for (auto& dir_entry : boost::make_iterator_range(
87 bf::directory_iterator(root_path), bf::directory_iterator())) {
88 if (bf::is_regular_file(dir_entry)) {
89 if (dir_entry.path().string().find("/recovery") != std::string::npos) {
91 bf::remove(dir_entry.path(), error);
97 bf::path FindRecoveryFile() {
98 bf::path root_path = ci::GetRootAppPath(false);
99 for (auto& dir_entry : boost::make_iterator_range(
100 bf::directory_iterator(root_path), bf::directory_iterator())) {
101 if (bf::is_regular_file(dir_entry)) {
102 if (dir_entry.path().string().find("/recovery") != std::string::npos) {
103 return dir_entry.path();
110 bool ValidateFileContentInPackage(const std::string& pkgid,
111 const std::string& relative,
112 const std::string& expected) {
113 bf::path root_path = ci::GetRootAppPath(false);
114 bf::path file_path = root_path / pkgid / relative;
115 if (!bf::exists(file_path)) {
116 LOG(ERROR) << file_path << " doesn't exist";
119 FILE* handle = fopen(file_path.c_str(), "r");
121 LOG(ERROR) << file_path << " cannot be open";
125 std::array<char, 200> buffer;
126 while (fgets(buffer.data(), buffer.size(), handle)) {
127 content += buffer.data();
130 return content == expected;
133 void ValidatePackageFS(const std::string& pkgid,
134 const std::vector<std::string>& appids) {
135 bf::path root_path = ci::GetRootAppPath(false);
136 bf::path package_path = root_path / pkgid;
137 bf::path data_path = package_path / "data";
138 bf::path shared_path = package_path / "shared";
139 bf::path cache_path = package_path / "cache";
140 ASSERT_TRUE(bf::exists(root_path));
141 ASSERT_TRUE(bf::exists(package_path));
142 ASSERT_TRUE(bf::exists(data_path));
143 ASSERT_TRUE(bf::exists(shared_path));
144 ASSERT_TRUE(bf::exists(cache_path));
146 bf::path manifest_path =
147 bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
148 ASSERT_TRUE(bf::exists(manifest_path));
150 for (auto& appid : appids) {
151 bf::path binary_path = package_path / "bin" / appid;
152 ASSERT_TRUE(bf::exists(binary_path));
154 bf::path(getIconPath(getuid(), false)) / (appid + ".png");
155 ASSERT_TRUE(bf::exists(icon_path));
156 bf::path icon_backup = ci::GetBackupPathForIconFile(icon_path);
157 ASSERT_FALSE(bf::exists(icon_backup));
160 bf::path widget_root_path = package_path / "res" / "wgt";
161 bf::path config_path = widget_root_path / "config.xml";
162 ASSERT_TRUE(bf::exists(widget_root_path));
163 ASSERT_TRUE(bf::exists(config_path));
165 bf::path private_tmp_path = package_path / "tmp";
166 ASSERT_TRUE(bf::exists(private_tmp_path));
168 // backups should not exist
169 bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
170 bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
171 ASSERT_FALSE(bf::exists(package_backup));
172 ASSERT_FALSE(bf::exists(manifest_backup));
175 void PackageCheckCleanup(const std::string& pkgid,
176 const std::vector<std::string>& appids) {
177 bf::path root_path = ci::GetRootAppPath(false);
178 bf::path package_path = root_path / pkgid;
179 ASSERT_FALSE(bf::exists(package_path));
181 bf::path manifest_path =
182 bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
183 ASSERT_FALSE(bf::exists(manifest_path));
185 for (auto& appid : appids) {
187 bf::path(getIconPath(getuid(), false)) / (appid + ".png");
188 ASSERT_FALSE(bf::exists(icon_path));
189 bf::path icon_backup = ci::GetBackupPathForIconFile(icon_path);
190 ASSERT_FALSE(bf::exists(icon_backup));
193 // backups should not exist
194 bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
195 bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
196 ASSERT_FALSE(bf::exists(package_backup));
197 ASSERT_FALSE(bf::exists(manifest_backup));
200 void ValidatePackage(const std::string& pkgid,
201 const std::vector<std::string>& appids) {
202 ASSERT_TRUE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode()));
203 ValidatePackageFS(pkgid, appids);
206 void CheckPackageNonExistance(const std::string& pkgid,
207 const std::vector<std::string>& appids) {
208 ASSERT_FALSE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode()));
209 PackageCheckCleanup(pkgid, appids);
212 std::unique_ptr<ci::AppQueryInterface> CreateQueryInterface() {
213 std::unique_ptr<ci::AppQueryInterface> query_interface(
214 new wgt::WgtAppQueryInterface());
215 return query_interface;
218 std::unique_ptr<ci::AppInstaller> CreateInstaller(ci::PkgMgrPtr pkgmgr,
221 case PackageType::WGT:
222 return std::unique_ptr<ci::AppInstaller>(new wgt::WgtInstaller(pkgmgr));
223 case PackageType::HYBRID:
224 return std::unique_ptr<ci::AppInstaller>(
225 new hybrid::HybridInstaller(pkgmgr));
227 LOG(ERROR) << "Unknown installer type";
232 ci::AppInstaller::Result RunInstallerWithPkgrmgr(ci::PkgMgrPtr pkgmgr,
234 RequestResult mode) {
235 std::unique_ptr<ci::AppInstaller> installer = CreateInstaller(pkgmgr, type);
237 case RequestResult::FAIL:
238 installer->AddStep<ci::configuration::StepFail>();
243 return installer->Run();
246 ci::AppInstaller::Result Install(const bf::path& path,
248 RequestResult mode = RequestResult::NORMAL) {
249 const char* argv[] = {"", "-i", path.c_str()};
250 TestPkgmgrInstaller pkgmgr_installer;
251 std::unique_ptr<ci::AppQueryInterface> query_interface =
252 CreateQueryInterface();
254 ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
255 &pkgmgr_installer, query_interface.get());
257 LOG(ERROR) << "Failed to initialize pkgmgr interface";
258 return ci::AppInstaller::Result::UNKNOWN;
260 return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
263 ci::AppInstaller::Result Update(const bf::path& path_old,
264 const bf::path& path_new,
266 RequestResult mode = RequestResult::NORMAL) {
267 if (Install(path_old, type) != ci::AppInstaller::Result::OK) {
268 LOG(ERROR) << "Failed to install application. Cannot update";
269 return ci::AppInstaller::Result::UNKNOWN;
271 return Install(path_new, type, mode);
274 ci::AppInstaller::Result Uninstall(const std::string& pkgid,
276 RequestResult mode = RequestResult::NORMAL) {
277 const char* argv[] = {"", "-d", pkgid.c_str()};
278 TestPkgmgrInstaller pkgmgr_installer;
279 std::unique_ptr<ci::AppQueryInterface> query_interface =
280 CreateQueryInterface();
282 ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
283 &pkgmgr_installer, query_interface.get());
285 LOG(ERROR) << "Failed to initialize pkgmgr interface";
286 return ci::AppInstaller::Result::UNKNOWN;
288 return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
291 ci::AppInstaller::Result Reinstall(const bf::path& path,
292 const bf::path& delta_dir,
294 RequestResult mode = RequestResult::NORMAL) {
295 if (Install(path, type) != ci::AppInstaller::Result::OK) {
296 LOG(ERROR) << "Failed to install application. Cannot perform RDS";
297 return ci::AppInstaller::Result::UNKNOWN;
299 const char* argv[] = {"", "-r", delta_dir.c_str()};
300 TestPkgmgrInstaller pkgmgr_installer;
301 std::unique_ptr<ci::AppQueryInterface> query_interface =
302 CreateQueryInterface();
304 ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
305 &pkgmgr_installer, query_interface.get());
307 LOG(ERROR) << "Failed to initialize pkgmgr interface";
308 return ci::AppInstaller::Result::UNKNOWN;
310 return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
313 ci::AppInstaller::Result DeltaInstall(const bf::path& path,
314 const bf::path& delta_package, PackageType type) {
315 if (Install(path, type) != ci::AppInstaller::Result::OK) {
316 LOG(ERROR) << "Failed to install application. Cannot perform delta update";
317 return ci::AppInstaller::Result::UNKNOWN;
319 return Install(delta_package, type);
322 ci::AppInstaller::Result Clear(const std::string& pkgid,
324 RequestResult mode = RequestResult::NORMAL) {
325 const char* argv[] = {"", "-c", pkgid.c_str()};
326 TestPkgmgrInstaller pkgmgr_installer;
327 std::unique_ptr<ci::AppQueryInterface> query_interface =
328 CreateQueryInterface();
330 ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
331 &pkgmgr_installer, query_interface.get());
333 LOG(ERROR) << "Failed to initialize pkgmgr interface";
334 return ci::AppInstaller::Result::UNKNOWN;
336 return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
339 ci::AppInstaller::Result Recover(const bf::path& recovery_file,
341 RequestResult mode = RequestResult::NORMAL) {
342 const char* argv[] = {"", "-b", recovery_file.c_str()};
343 TestPkgmgrInstaller pkgmgr_installer;
344 std::unique_ptr<ci::AppQueryInterface> query_interface =
345 CreateQueryInterface();
347 ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
348 &pkgmgr_installer, query_interface.get());
350 LOG(ERROR) << "Failed to initialize pkgmgr interface";
351 return ci::AppInstaller::Result::UNKNOWN;
353 return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
358 namespace common_installer {
360 class SmokeEnvironment : public testing::Environment {
362 explicit SmokeEnvironment(const bf::path& home) : home_(home) {
364 void SetUp() override {
365 bs::error_code error;
366 bf::remove_all(home_ / kApplicationDirBackup, error);
367 bf::remove_all(home_ / KUserAppsDirBackup, error);
368 if (bf::exists(home_ / KUserAppsDir)) {
369 bf::rename(home_ / KUserAppsDir, home_ / KUserAppsDirBackup, error);
371 LOG(ERROR) << "Failed to setup test environment. Does some previous"
372 << " test crashed? Directory: "
373 << (home_ / KUserAppsDirBackup) << " should not exist.";
376 if (bf::exists(home_ / kApplicationDir)) {
377 bf::rename(home_ / kApplicationDir, home_ / kApplicationDirBackup, error);
379 LOG(ERROR) << "Failed to setup test environment. Does some previous"
380 << " test crashed? Directory: "
381 << (home_ / kApplicationDirBackup) << " should not exist.";
385 void TearDown() override {
386 bs::error_code error;
387 bf::remove_all(home_ / kApplicationDir, error);
388 bf::remove_all(home_ / KUserAppsDir, error);
389 if (bf::exists(home_ / KUserAppsDirBackup))
390 bf::rename(home_ / KUserAppsDirBackup, home_ / KUserAppsDir, error);
391 if (bf::exists(home_ / kApplicationDirBackup))
392 bf::rename(home_ / kApplicationDirBackup, home_ / kApplicationDir, error);
399 class SmokeTest : public testing::Test {
402 TEST_F(SmokeTest, InstallationMode) {
403 bf::path path = kSmokePackagesDirectory / "InstallationMode.wgt";
404 std::string pkgid = "smokeapp03";
405 std::string appid = "smokeapp03.InstallationMode";
406 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
407 ValidatePackage(pkgid, {appid});
410 TEST_F(SmokeTest, UpdateMode) {
411 bf::path path_old = kSmokePackagesDirectory / "UpdateMode.wgt";
412 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_2.wgt";
413 std::string pkgid = "smokeapp04";
414 std::string appid = "smokeapp04.UpdateMode";
415 ASSERT_EQ(Update(path_old, path_new, PackageType::WGT),
416 ci::AppInstaller::Result::OK);
417 ValidatePackage(pkgid, {appid});
419 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
422 TEST_F(SmokeTest, DeinstallationMode) {
423 bf::path path = kSmokePackagesDirectory / "DeinstallationMode.wgt";
424 std::string pkgid = "smokeapp05";
425 std::string appid = "smokeapp05.DeinstallationMode";
426 ASSERT_EQ(Install(path, PackageType::WGT),
427 ci::AppInstaller::Result::OK);
428 ASSERT_EQ(Uninstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
429 CheckPackageNonExistance(pkgid, {appid});
432 TEST_F(SmokeTest, RDSMode) {
433 bf::path path = kSmokePackagesDirectory / "RDSMode.wgt";
434 bf::path delta_directory = kSmokePackagesDirectory / "delta_dir/";
435 std::string pkgid = "smokeapp11";
436 std::string appid = "smokeapp11.RDSMode";
437 ASSERT_EQ(Reinstall(path, delta_directory, PackageType::WGT),
438 ci::AppInstaller::Result::OK);
439 ValidatePackage(pkgid, {appid});
441 // Check delta modifications
442 bf::path root_path = ci::GetRootAppPath(false);
443 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
444 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
445 ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n");
448 TEST_F(SmokeTest, ClearMode) {
449 bf::path path = kSmokePackagesDirectory / "ClearMode.wgt";
450 std::string pkgid = "smokeapp20";
451 std::string appid = "smokeapp20.ClearMode";
452 ASSERT_EQ(Install(path, PackageType::WGT),
453 ci::AppInstaller::Result::OK);
454 bf::path root_path = ci::GetRootAppPath(false);
455 bs::error_code error;
456 bf::create_directory(root_path / pkgid / "data" / "dir", error);
458 ASSERT_TRUE(TouchFile(root_path / pkgid / "data" / "dir" / "file"));
459 ASSERT_TRUE(TouchFile(root_path / pkgid / "data" / "file"));
460 ASSERT_EQ(Clear(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
461 ValidatePackage(pkgid, {appid});
462 ASSERT_FALSE(bf::exists(root_path / pkgid / "data" / "dir" / "file"));
463 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "file"));
466 TEST_F(SmokeTest, DeltaMode) {
467 bf::path path = kSmokePackagesDirectory / "DeltaMode.wgt";
468 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode.delta";
469 std::string pkgid = "smokeapp17";
470 std::string appid = "smokeapp17.DeltaMode";
471 ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::WGT),
472 ci::AppInstaller::Result::OK);
473 ValidatePackage(pkgid, {appid});
475 // Check delta modifications
476 bf::path root_path = ci::GetRootAppPath(false);
477 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
478 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
479 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "css" / "style.css")); // NOLINT
480 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "images" / "tizen_32.png")); // NOLINT
481 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "js" / "main.js"));
482 ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n");
485 TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
486 bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt";
487 Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
488 backend_crash.Run("-i", path.string());
489 ASSERT_NE(backend_crash.Wait(), 0);
491 std::string pkgid = "smokeapp09";
492 std::string appid = "smokeapp09.RecoveryModeForInstallation";
493 bf::path recovery_file = FindRecoveryFile();
494 ASSERT_FALSE(recovery_file.empty());
495 ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
496 ci::AppInstaller::Result::OK);
497 CheckPackageNonExistance(pkgid, {appid});
500 TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
501 bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt";
502 bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
503 RemoveAllRecoveryFiles();
504 Subprocess backend_test("/usr/bin/wgt-backend");
505 backend_test.Run("-i", path_old.string());
506 ASSERT_EQ(backend_test.Wait(), 0);
507 Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
508 backend_crash.Run("-i", path_new.string());
509 ASSERT_NE(backend_crash.Wait(), 0);
511 std::string pkgid = "smokeapp10";
512 std::string appid = "smokeapp10.RecoveryModeForUpdate";
513 bf::path recovery_file = FindRecoveryFile();
514 ASSERT_FALSE(recovery_file.empty());
515 ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
516 ci::AppInstaller::Result::OK);
517 ValidatePackage(pkgid, {appid});
519 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
522 TEST_F(SmokeTest, InstallationMode_GoodSignature) {
523 bf::path path = kSmokePackagesDirectory / "InstallationMode_GoodSignature.wgt"; // NOLINT
524 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
527 TEST_F(SmokeTest, InstallationMode_WrongSignature) {
528 bf::path path = kSmokePackagesDirectory / "InstallationMode_WrongSignature.wgt"; // NOLINT
529 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::ERROR);
532 TEST_F(SmokeTest, InstallationMode_Rollback) {
533 bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.wgt";
534 std::string pkgid = "smokeapp06";
535 std::string appid = "smokeapp06.InstallationModeRollback";
536 ASSERT_EQ(Install(path, PackageType::WGT, RequestResult::FAIL),
537 ci::AppInstaller::Result::ERROR);
538 CheckPackageNonExistance(pkgid, {appid});
541 TEST_F(SmokeTest, UpdateMode_Rollback) {
542 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Rollback.wgt";
543 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt";
544 std::string pkgid = "smokeapp07";
545 std::string appid = "smokeapp07.UpdateModeRollback";
546 ASSERT_EQ(Update(path_old, path_new, PackageType::WGT, RequestResult::FAIL),
547 ci::AppInstaller::Result::ERROR);
548 ValidatePackage(pkgid, {appid});
550 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
553 TEST_F(SmokeTest, InstallationMode_Hybrid) {
554 bf::path path = kSmokePackagesDirectory / "InstallationMode_Hybrid.wgt";
555 std::string pkgid = "smokehyb01";
556 std::string appid1 = "smokehyb01.Web";
557 std::string appid2 = "smokehyb01.Native";
558 ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
559 ValidatePackage(pkgid, {appid1, appid2});
562 TEST_F(SmokeTest, UpdateMode_Hybrid) {
563 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Hybrid.wgt";
564 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Hybrid_2.wgt";
565 std::string pkgid = "smokehyb02";
566 std::string appid1 = "smokehyb02.Web";
567 std::string appid2 = "smokehyb02.Native";
568 ASSERT_EQ(Update(path_old, path_new, PackageType::HYBRID),
569 ci::AppInstaller::Result::OK);
570 ValidatePackage(pkgid, {appid1, appid2});
572 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
573 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n"));
576 TEST_F(SmokeTest, DeinstallationMode_Hybrid) {
577 bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Hybrid.wgt";
578 std::string pkgid = "smokehyb03";
579 std::string appid1 = "smokehyb03.Web";
580 std::string appid2 = "smokehyb03.Native";
581 ASSERT_EQ(Install(path, PackageType::HYBRID),
582 ci::AppInstaller::Result::OK);
583 ASSERT_EQ(Uninstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
584 CheckPackageNonExistance(pkgid, {appid1, appid2});
587 TEST_F(SmokeTest, DeltaMode_Hybrid) {
588 bf::path path = kSmokePackagesDirectory / "DeltaMode_Hybrid.wgt";
589 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Hybrid.delta";
590 std::string pkgid = "smokehyb04";
591 std::string appid1 = "smokehyb04.Web";
592 std::string appid2 = "smokehyb04.Native";
593 ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::HYBRID),
594 ci::AppInstaller::Result::OK);
595 ValidatePackage(pkgid, {appid1, appid2});
597 // Check delta modifications
598 bf::path root_path = ci::GetRootAppPath(false);
599 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
600 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
601 ASSERT_FALSE(bf::exists(root_path / pkgid / "lib" / "DELETED"));
602 ASSERT_TRUE(bf::exists(root_path / pkgid / "lib" / "ADDED"));
603 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "css" / "style.css")); // NOLINT
604 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "images" / "tizen_32.png")); // NOLINT
605 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "js" / "main.js"));
606 ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n");
607 ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n");
610 } // namespace common_installer
612 int main(int argc, char** argv) {
613 testing::InitGoogleTest(&argc, argv);
614 const char* directory = getenv("HOME");
616 LOG(ERROR) << "Cannot get $HOME value";
619 testing::AddGlobalTestEnvironment(
620 new common_installer::SmokeEnvironment(directory));
621 return RUN_ALL_TESTS();