Add unit test for unified installer 03/231103/4
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 13 Apr 2020 08:01:12 +0000 (17:01 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Tue, 19 May 2020 07:05:24 +0000 (16:05 +0900)
[Added test list]
-InstallAndROUpdate : test Install and ReadonlyUpdateInstall case
-Uninstall_Single : test Uninstall single package case
-Uninstall_Double : test Uninstall double package case
-Uninstall_Triple : test Uninstall triple package case
-UninstallAndROUpdateUninstall : test Uninstall and ReadonlyUpdateUninstall case
-InstallAndROUpdate_Rollback : test rollback Install and ReadonlyUpdateInstall case

Change-Id: Id1f4120776c9d02a0bce8a37b5c2cc0f7ac7f472
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
16 files changed:
src/unit_tests/smoke_test.cc
src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackTpk.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt.wgt [new file with mode: 0644]
src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt_2.wgt [new file with mode: 0644]
src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk_2.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/InstallAndROUpdate_Wgt.wgt [new file with mode: 0644]
src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk_2.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Wgt.wgt [new file with mode: 0644]
src/unit_tests/test_samples/smoke/Uninstall_DoubleTpk.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/Uninstall_DoubleWgt.wgt [new file with mode: 0644]
src/unit_tests/test_samples/smoke/Uninstall_SingleTpk.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/Uninstall_TripleHybrid.wgt [new file with mode: 0644]
src/unit_tests/test_samples/smoke/Uninstall_TripleTpk.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/Uninstall_TripleWgt.wgt [new file with mode: 0644]

index 7100513aba1319f9325301297ebe691fcadd4ed9..8aec51a050ca173da4efcea3af72585c25e18b93 100644 (file)
@@ -264,6 +264,147 @@ TEST_F(SmokeTest, InstallAndUpdate) {
       ValidateFileContentInPackage(pkgid1, "res/VERSION", "2", params));
 }
 
+TEST_F(SmokeTest, InstallAndROUpdate) {
+  bf::path path1_old =
+      kUnifiedSmokePackagesDirectory / "InstallAndROUpdate_Tpk.tpk";
+  bf::path path1_new =
+      kUnifiedSmokePackagesDirectory / "InstallAndROUpdate_Tpk_2.tpk";
+  std::string pkgid1 = "smokeuni25";
+  std::string appid1 = "smokeuni25.InstallAndROUpdateModeTpk";
+  std::string exec1 = "smokeunified";
+  bf::path path2 =
+      kUnifiedSmokePackagesDirectory / "InstallAndROUpdate_Wgt.wgt";
+  std::string pkgid2 = "smokeuni26";
+  std::string appid2 = "smokeuni26.InstallAndROUpdateWgt";
+  std::string exec2 = "smokeuni26.InstallAndROUpdateWgt";
+
+  // install tpk version 1
+  ASSERT_EQ(backend.InstallPreload(path1_old), ci::AppInstaller::Result::OK);
+  // update tpk version 2, install wgt version 1
+  std::vector<bf::path> paths = { path1_new, path2 };
+  ASSERT_EQ(backend.Install(paths), ci::AppInstaller::Result::OK);
+  params.pkg_type = PackageType::TPK;
+  ASSERT_TRUE(ValidatePackage(pkgid1, {appid1, exec1}, params));
+  params.pkg_type = PackageType::WGT;
+  ASSERT_TRUE(ValidatePackage(pkgid2, {appid2, exec2}, params));
+  ASSERT_TRUE(
+      ValidateFileContentInPackage(pkgid1, "res/VERSION", "2", params));
+}
+
+TEST_F(SmokeTest, Uninstall_Single) {
+  bf::path path =
+      kUnifiedSmokePackagesDirectory / "Uninstall_SingleTpk.tpk";
+  std::string pkgid = "smokeuni29";
+  std::string appid = "smokeuni29.UninstallSingleTpk";
+  std::string exec = "smokeunified";
+
+  std::vector<bf::path> paths = { path };
+  ASSERT_EQ(backend.Install(paths), ci::AppInstaller::Result::OK);
+  params.pkg_type = PackageType::TPK;
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+  std::vector<std::string> pkgids = { pkgid };
+  ASSERT_EQ(backend.Uninstall(pkgids), ci::AppInstaller::Result::OK);
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
+}
+
+TEST_F(SmokeTest, Uninstall_Double) {
+  bf::path path1 =
+      kUnifiedSmokePackagesDirectory / "Uninstall_DoubleTpk.tpk";
+  std::string pkgid1 = "smokeuni30";
+  std::string appid1 = "smokeuni30.UninstallDoubleTpk";
+  std::string exec1 = "smokeunified";
+  bf::path path2 =
+      kUnifiedSmokePackagesDirectory / "Uninstall_DoubleWgt.wgt";
+  std::string pkgid2 = "smokeuni31";
+  std::string appid2 = "smokeuni31.UninstallDoubleWgt";
+  std::string exec2 = "smokeuni31.UninstallDoubleWgt";
+
+  std::vector<bf::path> paths = { path1, path2 };
+  ASSERT_EQ(backend.Install(paths), ci::AppInstaller::Result::OK);
+  params.pkg_type = PackageType::TPK;
+  ASSERT_TRUE(ValidatePackage(pkgid1, {appid1, exec1}, params));
+  params.pkg_type = PackageType::WGT;
+  ASSERT_TRUE(ValidatePackage(pkgid2, {appid2, exec2}, params));
+  std::vector<std::string> pkgids = { pkgid1, pkgid2 };
+  ASSERT_EQ(backend.Uninstall(pkgids), ci::AppInstaller::Result::OK);
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid1, params));
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid2, params));
+}
+
+TEST_F(SmokeTest, Uninstall_Triple) {
+  bf::path path1 =
+      kUnifiedSmokePackagesDirectory / "Uninstall_TripleTpk.tpk";
+  std::string pkgid1 = "smokeuni32";
+  std::string appid1 = "smokeuni32.UninstallTripleTpk";
+  std::string exec1 = "smokeunified";
+  bf::path path2 =
+      kUnifiedSmokePackagesDirectory / "Uninstall_TripleWgt.wgt";
+  std::string pkgid2 = "smokeuni33";
+  std::string appid2 = "smokeuni33.UninstallTripleWgt";
+  std::string exec2 = "smokeuni33.UninstallTripleWgt";
+  bf::path path3 =
+      kUnifiedSmokePackagesDirectory / "Uninstall_TripleHybrid.wgt";
+  std::string pkgid3 = "smokeuni34";
+  std::string appid3 = "smokeuni34.UninstallTripleHybrid";
+  std::string exec3 = "smokeuni34.UninstallTripleHybrid";
+
+  std::vector<bf::path> paths = { path1, path2, path3 };
+  ASSERT_EQ(backend.Install(paths), ci::AppInstaller::Result::OK);
+  params.pkg_type = PackageType::TPK;
+  ASSERT_TRUE(ValidatePackage(pkgid1, {appid1, exec1}, params));
+  params.pkg_type = PackageType::WGT;
+  ASSERT_TRUE(ValidatePackage(pkgid2, {appid2, exec2}, params));
+  params.pkg_type = PackageType::HYBRID;
+  ASSERT_TRUE(ValidatePackage(pkgid3, {appid3, exec3}, params));
+  std::vector<std::string> pkgids = { pkgid1, pkgid2, pkgid3 };
+  ASSERT_EQ(backend.Uninstall(pkgids), ci::AppInstaller::Result::OK);
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid1, params));
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid2, params));
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid3, params));
+}
+
+TEST_F(SmokeTest, UninstallAndROUpdateUninstall) {
+  bf::path path1_old =
+      kUnifiedSmokePackagesDirectory / "UninstallAndROUpdateUninstall_Tpk.tpk";
+  bf::path path1_new =
+      kUnifiedSmokePackagesDirectory /
+      "UninstallAndROUpdateUninstall_Tpk_2.tpk";
+  std::string pkgid1 = "smokeuni35";
+  std::string appid1 = "smokeuni35.UninstallAndROUpdateUninstallTpk";
+  std::string exec1 = "smokeunified";
+  bf::path path2 =
+      kUnifiedSmokePackagesDirectory / "UninstallAndROUpdateUninstall_Wgt.wgt";
+  std::string pkgid2 = "smokeuni36";
+  std::string appid2 = "smokeuni36.UninstallAndROUpdateUninstallWgt";
+  std::string exec2 = "smokeuni36.UninstallAndROUpdateUninstallWgt";
+
+  // install tpk version 1
+  ASSERT_EQ(backend.InstallPreload(path1_old), ci::AppInstaller::Result::OK);
+  ci::PkgQueryInterface pkg_query1(pkgid1, params.test_user.uid);
+  PackageAttributes original(pkg_query1);
+  // update tpk version 2, install wgt version 1
+  std::vector<bf::path> paths = { path1_new, path2 };
+  ASSERT_EQ(backend.Install(paths), ci::AppInstaller::Result::OK);
+  params.pkg_type = PackageType::TPK;
+  ASSERT_TRUE(ValidatePackage(pkgid1, {appid1, exec1}, params));
+  params.pkg_type = PackageType::WGT;
+  ASSERT_TRUE(ValidatePackage(pkgid2, {appid2, exec2}, params));
+  ASSERT_TRUE(
+      ValidateFileContentInPackage(pkgid1, "res/VERSION", "2", params));
+  // uninstall
+  std::vector<std::string> pkgids = { pkgid1, pkgid2 };
+  ASSERT_EQ(backend.Uninstall(pkgids), ci::AppInstaller::Result::OK);
+  ci::PkgQueryInterface pkg_query2(pkgid1, params.test_user.uid, true);
+  PackageAttributes restored(pkg_query2);
+  ASSERT_EQ(original, restored);
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid2, params));
+  params.pkg_type = PackageType::TPK;
+  params.is_readonly = true;
+  ASSERT_TRUE(ValidatePackage(pkgid1, {appid1, exec1}, params));
+  ASSERT_TRUE(
+      ValidateFileContentInPackage(pkgid1, "res/VERSION", "1", params));
+}
+
 class RollbackSmokeTest : public testing::Test {
  public:
   RollbackSmokeTest()
@@ -359,6 +500,34 @@ TEST_F(RollbackSmokeTest, InstallAndUpdate_Rollback) {
       ValidateFileContentInPackage(pkgid2, "res/wgt/VERSION", "1", params));
 }
 
+TEST_F(RollbackSmokeTest, InstallAndROUpdate_Rollback) {
+  bf::path path1 =
+      kUnifiedSmokePackagesDirectory / "InstallAndROUpdate_RollbackTpk.tpk";
+  std::string pkgid1 = "smokeuni27";
+  std::string appid1 = "smokeuni27.InstallAndROUpdateRollbackTpk";
+  std::string exec1 = "smokeunified";
+  bf::path path2_old =
+      kUnifiedSmokePackagesDirectory / "InstallAndROUpdate_RollbackWgt.wgt";
+  bf::path path2_new =
+      kUnifiedSmokePackagesDirectory / "InstallAndROUpdate_RollbackWgt_2.wgt";
+  std::string pkgid2 = "smokeuni28";
+  std::string appid2 = "smokeuni28.InstallAndROUpdateRollbackWgt";
+  std::string exec2 = "smokeuni28.InstallAndROUpdateRollbackWgt";
+
+  ASSERT_EQ(backend.InstallPreloadSuccess(path2_old),
+        ci::AppInstaller::Result::OK);
+  // pkgid1: install, pkgid2: update
+  std::vector<bf::path> paths = { path1, path2_new };
+  ASSERT_EQ(backend.Install(paths), ci::AppInstaller::Result::ERROR);
+  params.pkg_type = PackageType::TPK;
+  ASSERT_TRUE(CheckPackageNonExistance(pkgid1, params));
+  params.pkg_type = PackageType::WGT;
+  params.is_readonly = true;
+  ASSERT_TRUE(ValidatePackage(pkgid2, {appid2, exec2}, params));
+  ASSERT_TRUE(
+      ValidateFileContentInPackage(pkgid2, "res/wgt/VERSION", "1", params));
+}
+
 TEST_F(SmokeTest, Recovery_Install) {
   bf::path path1 =
       kUnifiedSmokePackagesDirectory / "Recovery_InstallTpk.tpk";
diff --git a/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackTpk.tpk b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackTpk.tpk
new file mode 100644 (file)
index 0000000..b9342ca
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackTpk.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt.wgt b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt.wgt
new file mode 100644 (file)
index 0000000..bad3112
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt.wgt differ
diff --git a/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt_2.wgt b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt_2.wgt
new file mode 100644 (file)
index 0000000..8d0f6fc
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_RollbackWgt_2.wgt differ
diff --git a/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk.tpk b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk.tpk
new file mode 100644 (file)
index 0000000..df5f2f2
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk_2.tpk b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk_2.tpk
new file mode 100644 (file)
index 0000000..9fb1f4d
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Tpk_2.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Wgt.wgt b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Wgt.wgt
new file mode 100644 (file)
index 0000000..08cdb5c
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallAndROUpdate_Wgt.wgt differ
diff --git a/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk.tpk b/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk.tpk
new file mode 100644 (file)
index 0000000..01c4902
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk_2.tpk b/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk_2.tpk
new file mode 100644 (file)
index 0000000..67043eb
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Tpk_2.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Wgt.wgt b/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Wgt.wgt
new file mode 100644 (file)
index 0000000..becb791
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/UninstallAndROUpdateUninstall_Wgt.wgt differ
diff --git a/src/unit_tests/test_samples/smoke/Uninstall_DoubleTpk.tpk b/src/unit_tests/test_samples/smoke/Uninstall_DoubleTpk.tpk
new file mode 100644 (file)
index 0000000..fcd6a1a
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/Uninstall_DoubleTpk.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/Uninstall_DoubleWgt.wgt b/src/unit_tests/test_samples/smoke/Uninstall_DoubleWgt.wgt
new file mode 100644 (file)
index 0000000..ac9d7fb
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/Uninstall_DoubleWgt.wgt differ
diff --git a/src/unit_tests/test_samples/smoke/Uninstall_SingleTpk.tpk b/src/unit_tests/test_samples/smoke/Uninstall_SingleTpk.tpk
new file mode 100644 (file)
index 0000000..6b59e8d
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/Uninstall_SingleTpk.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/Uninstall_TripleHybrid.wgt b/src/unit_tests/test_samples/smoke/Uninstall_TripleHybrid.wgt
new file mode 100644 (file)
index 0000000..5a4fa88
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/Uninstall_TripleHybrid.wgt differ
diff --git a/src/unit_tests/test_samples/smoke/Uninstall_TripleTpk.tpk b/src/unit_tests/test_samples/smoke/Uninstall_TripleTpk.tpk
new file mode 100644 (file)
index 0000000..1d348c4
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/Uninstall_TripleTpk.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/Uninstall_TripleWgt.wgt b/src/unit_tests/test_samples/smoke/Uninstall_TripleWgt.wgt
new file mode 100644 (file)
index 0000000..9b9f867
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/Uninstall_TripleWgt.wgt differ