Add smoke test for extended storage installation 72/155472/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 13 Oct 2017 07:54:21 +0000 (16:54 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 17 Oct 2017 06:40:11 +0000 (06:40 +0000)
Change-Id: I4a222b770cffe7a70b69143a4893beb7a38317e3
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/unit_tests/smoke_test.cc
src/unit_tests/smoke_utils.cc
src/unit_tests/smoke_utils.h
src/unit_tests/test_samples/smoke/InstallExtendedMode.wgt [new file with mode: 0644]

index b55392a..bf44401 100644 (file)
@@ -571,7 +571,7 @@ TEST_F(SmokeTest, InstallExternalMode) {
   bf::path path = kSmokePackagesDirectory / "InstallExternalMode.wgt";
   std::string pkgid = "smokewgt35";
   std::string appid = "smokewgt35.web";
-  ASSERT_EQ(InstallExternal(path, PackageType::WGT),
+  ASSERT_EQ(InstallWithStorage(path, PackageType::WGT, StorageType::EXTERNAL),
       ci::AppInstaller::Result::OK);
   ValidateExternalPackage(pkgid, {appid});
 }
@@ -794,6 +794,16 @@ TEST_F(SmokeTest, SharedRes30HybridDelta) {
   ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "SHARED-WGT-1"));  // NOLINT
 }
 
+TEST_F(SmokeTest, InstallExtendedMode) {
+  ASSERT_TRUE(CheckAvailableExtendedStorage());
+  bf::path path = kSmokePackagesDirectory / "InstallExtendedMode.wgt";
+  std::string pkgid = "smokewgt44";
+  std::string appid = "smokewgt44.web";
+  ASSERT_EQ(InstallWithStorage(path, PackageType::WGT, StorageType::EXTENDED),
+      ci::AppInstaller::Result::OK);
+  ValidatePackage(pkgid, {appid});
+}
+
 }  // namespace common_installer
 
 int main(int argc,  char** argv) {
index 41c777d..3730ad0 100644 (file)
@@ -585,13 +585,37 @@ bool CheckAvailableExternalPath() {
   return true;
 }
 
-ci::AppInstaller::Result InstallExternal(const bf::path& path,
+bool CheckAvailableExtendedStorage() {
+  bf::path extended_path = bf::path(tzplatform_getenv(TZ_SYS_EXTENDEDSD));
+  LOG(DEBUG) << "extended_path :" << extended_path;
+  // TODO(jeremy.jang): It should be checked by libstorage API.
+  if (!bf::exists(extended_path)) {
+    LOG(ERROR) << "Extended storage not exists!";
+    return false;
+  }
+  return true;
+}
+
+ci::AppInstaller::Result InstallWithStorage(const bf::path& path,
                                  PackageType type,
+                                 StorageType storage_type,
                                  RequestResult mode) {
   int default_storage = 0;
+  int storage = 0;
+  switch (storage_type) {
+    case StorageType::EXTERNAL:
+      storage = 1;
+      break;
+    case StorageType::EXTENDED:
+      storage = 2;
+      break;
+    default:
+      LOG(ERROR) << "Unknown storage type";
+      break;
+  }
   vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT,
                 &default_storage);
-  vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, 1);
+  vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, storage);
 
   const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()};
   ci::AppInstaller::Result result =
@@ -607,7 +631,8 @@ ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid,
                                  const bf::path& legacy_path,
                                  PackageType type,
                                  RequestResult mode) {
-  if (InstallExternal(path, type) != ci::AppInstaller::Result::OK) {
+  if (InstallWithStorage(path, type, StorageType::EXTERNAL) !=
+      ci::AppInstaller::Result::OK) {
     LOG(ERROR) << "Failed to install application. Cannot perform Migrate";
     return ci::AppInstaller::Result::ERROR;
   }
index b709b19..b87da34 100644 (file)
@@ -143,6 +143,12 @@ enum class PackageType {
   HYBRID
 };
 
+enum class StorageType {
+  INTERNAL,
+  EXTERNAL,
+  EXTENDED
+};
+
 ci::RequestMode ParseRequestMode(int argc,  char** argv);
 
 bool TouchFile(const bf::path& path);
@@ -226,8 +232,11 @@ ci::AppInstaller::Result InstallPreload(const bf::path& path, PackageType type,
 
 bool CheckAvailableExternalPath();
 
-ci::AppInstaller::Result InstallExternal(const bf::path& path,
+bool CheckAvailableExtendedStorage();
+
+ci::AppInstaller::Result InstallWithStorage(const bf::path& path,
                                  PackageType type,
+                                 StorageType storage = StorageType::INTERNAL,
                                  RequestResult mode = RequestResult::NORMAL);
 
 ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid,
diff --git a/src/unit_tests/test_samples/smoke/InstallExtendedMode.wgt b/src/unit_tests/test_samples/smoke/InstallExtendedMode.wgt
new file mode 100644 (file)
index 0000000..677b337
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/InstallExtendedMode.wgt differ