bf::path path = kSmokePackagesDirectory / "InstallExternal_Tpk.tpk";
std::string pkgid = "smokeapp29";
std::string appid = "smokeapp29.InstallExternalTpk";
- ASSERT_EQ(InstallExternal(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(InstallWithStorage(path, StorageType::EXTERNAL),
+ ci::AppInstaller::Result::OK);
ASSERT_TRUE(ValidateExternalPackage(pkgid, appid));
}
ValidatePackage(pkgid, {appid}, true);
}
+TEST_F(SmokeTest, InstallExtended_Tpk) {
+ ASSERT_TRUE(CheckAvailableExtendedStorage());
+ bf::path path = kSmokePackagesDirectory / "InstallExtended_Tpk.tpk";
+ std::string pkgid = "smoketpk45";
+ std::string appid = "smoketpk45.InstallExtendedTpk";
+ ASSERT_EQ(InstallWithStorage(path, StorageType::EXTENDED),
+ ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidateExtendedPackage(pkgid, appid));
+}
+
} // namespace common_installer
int main(int argc, char** argv) {
return true;
}
+bool ValidateExtendedPackage(const std::string& pkgid,
+ const std::string& appid) {
+ ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
+ std::string storage = pkg_query.StorageForPkgId();
+ bf::path extended_path =
+ bf::path(ci::GetExtendedRootAppPath(kTestUserId)) / pkgid;
+ if (!bf::exists(extended_path)) {
+ LOG(INFO) << "Extended storage not exists!";
+ EXTENDED_ASSERT_EQ(storage, "installed_internal");
+ } else {
+ EXTENDED_ASSERT_EQ(storage, "installed_extended");
+ }
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, appid));
+ return true;
+}
+
bool CheckPackageNonExistance(const std::string& pkgid,
const std::string& appid,
bool is_readonly) {
return true;
}
-ci::AppInstaller::Result InstallExternal(const bf::path& path,
- RequestResult mode) {
+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,
+ StorageType type,
+ RequestResult mode) {
int default_storage = 0;
+ int storage = 0;
+ switch (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 = CallBackend(SIZEOFARRAY(argv), argv, mode);
const bf::path& path,
const bf::path& legacy_path,
RequestResult mode) {
- if (InstallExternal(path) != ci::AppInstaller::Result::OK) {
+ if (InstallWithStorage(path, StorageType::EXTERNAL) !=
+ ci::AppInstaller::Result::OK) {
LOG(ERROR) << "Failed to install application. Cannot perform Migrate";
return ci::AppInstaller::Result::ERROR;
}
}
};
+enum class StorageType {
+ INTERNAL,
+ EXTERNAL,
+ EXTENDED
+};
+
ci::RequestMode ParseRequestMode(int argc, char** argv);
bool AddTestUser(const char *user_name);
bool ValidateExternalPackage(const std::string& pkgid,
const std::string& appid);
+bool ValidateExtendedPackage(const std::string& pkgid,
+ const std::string& appid);
+
bool CheckPackageNonExistance(const std::string& pkgid,
const std::string& appid,
bool is_readonly = false);
bool CheckAvailableExternalPath();
+bool CheckAvailableExtendedStorage();
+
std::unique_ptr<ci::AppQueryInterface> CreateQueryInterface();
std::unique_ptr<ci::AppInstaller> CreateInstaller(ci::PkgMgrPtr pkgmgr);
ci::AppInstaller::Result InstallPreload(const bf::path& path,
RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result InstallExternal(const bf::path& path,
+ci::AppInstaller::Result InstallWithStorage(const bf::path& path,
+ StorageType type = StorageType::INTERNAL,
RequestResult mode = RequestResult::NORMAL);
ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid,