pkgmgrinfo_pkginfo_h handle1 = calloc(1, sizeof(manifest_x));
pkgmgrinfo_pkginfo_h handle2 = calloc(1, sizeof(manifest_x));
+ if (handle1 == nullptr || handle2 == nullptr) {
+ EXPECT_TRUE(false) << "Out of memory";
+ }
EXPECT_CALL(GetMock<PkgmgrInfoMock>(),
pkgmgrinfo_pkginfo_get_usr_all_pkginfo(
for (int idx = 0; idx < 2; idx++) {
std::unique_ptr<common_installer::AppInstaller> installer =
factory->CreateInstaller(pkgmgr, idx);
- // TODO(jungh.yeon): Need to add ways about validating instance.
EXPECT_NE(installer, nullptr);
}
}
+TEST_F(UnifiedInstallerFactoryTest, CreateInstaller_WrongRecoveryFile) {
+ std::vector<std::string> arguments =
+ {"unified-backend", "-b", "test_samples/kkk-recovery-123456",
+ "test_samples/tgt-recovery-123456"};
+ std::vector<char*> argv;
+ for (const auto& arg : arguments)
+ argv.push_back(const_cast<char*>(
+ reinterpret_cast<const char*>(arg.data())));
+ argv.push_back(nullptr);
+
+ pkgmgrinfo_pkginfo_h handle1 = calloc(1, sizeof(manifest_x));
+ pkgmgrinfo_pkginfo_h handle2 = calloc(1, sizeof(manifest_x));
+ if (handle1 == nullptr || handle2 == nullptr) {
+ EXPECT_TRUE(false) << "Out of memory";
+ }
+
+ EXPECT_CALL(GetMock<PkgmgrInfoMock>(),
+ pkgmgrinfo_pkginfo_get_usr_all_pkginfo(
+ StrEq("test_samples/kkk-recovery-123456"), _, _)).
+ WillOnce(DoAll(
+ SetArgPointee<2>(
+ reinterpret_cast<pkgmgrinfo_pkginfo_h>(handle1)),
+ Return(PMINFO_R_OK)));
+ EXPECT_CALL(GetMock<PkgmgrInfoMock>(),
+ pkgmgrinfo_pkginfo_get_usr_all_pkginfo(
+ StrEq("test_samples/tgt-recovery-123456"), _, _)).
+ WillOnce(DoAll(
+ SetArgPointee<2>(
+ reinterpret_cast<pkgmgrinfo_pkginfo_h>(handle2)),
+ Return(PMINFO_R_OK)));
+
+ TestPkgmgrInstaller pkgmgr_installer;
+ EXPECT_CALL(GetMock<GumMock>(),
+ gum_user_get_sync(_, _)).
+ WillRepeatedly(Invoke(__gum_user_get_sync_fake));
+
+ auto pkgmgr = common_installer::PkgMgrInterface::Create(
+ argv.size() - 1,
+ argv.data(),
+ &pkgmgr_installer,
+ nullptr);
+ if (!pkgmgr) {
+ ASSERT_TRUE(false);
+ }
+
+ EXPECT_EQ(pkgmgr->GetRequestInfoCount(), 2);
+
+ std::unique_ptr<common_installer::UnifiedInstallerFactory>factory(
+ new common_installer::UnifiedInstallerFactory());
+
+ for (int idx = 0; idx < 2; idx++) {
+ std::unique_ptr<common_installer::AppInstaller> installer =
+ factory->CreateInstaller(pkgmgr, idx);
+ // TODO(jungh.yeon): Need to add ways about validating instance.
+ EXPECT_EQ(installer, nullptr);
+ }
+}
+
TEST_F(UnifiedInstallerFactoryTest, CreateInstaller_GetPkgTypeFromPkgFile) {
std::vector<std::string> arguments =
{"unified-backend", "-i", "test_samples/test-tpk-pkg.tpk",
EXPECT_NE(installer, nullptr);
}
}
+