修改 CheckDPermission 方法的单元测试

Signed-off-by: wangyang2022 <wangyang412@huawei.com>
This commit is contained in:
wangyang2022
2022-04-30 08:47:55 +08:00
parent 49493eef4e
commit 18ed2dedd6
@@ -61,11 +61,10 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_001, TestSize.Level0)
CallerInfo callerInfo;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
AppExecFwk::AbilityInfo abilityInfo;
abilityInfo.visible = true;
bool needQueryExtension = false;
std::string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
callerInfo, accountInfo, abilityInfo, localDeviceId);
callerInfo, accountInfo, needQueryExtension, localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_001 end ret:" << ret << std::endl;
}
@@ -82,7 +81,7 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_002, TestSize.Level0)
CallerInfo callerInfo;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
bool needQueryExtension = false;
bool needQueryExtension = true;
std::string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
callerInfo, accountInfo, needQueryExtension, localDeviceId);
@@ -102,11 +101,10 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_003, TestSize.Level0)
CallerInfo callerInfo;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
AppExecFwk::AbilityInfo abilityInfo;
abilityInfo.visible = true;
bool needQueryExtension = false;
std::string localDeviceId = "";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
callerInfo, accountInfo, abilityInfo, localDeviceId);
callerInfo, accountInfo, needQueryExtension, localDeviceId);
EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_003 end ret:" << ret << std::endl;
}
@@ -123,11 +121,10 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_004, TestSize.Level0)
CallerInfo callerInfo;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
AppExecFwk::AbilityInfo abilityInfo;
abilityInfo.visible = false;
bool needQueryExtension = true;
std::string localDeviceId = "";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
callerInfo, accountInfo, abilityInfo, localDeviceId);
callerInfo, accountInfo, needQueryExtension, localDeviceId);
EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_004 end ret:" << ret << std::endl;
}
@@ -145,9 +142,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_005, TestSize.Level0)
CallerInfo callerInfo;
callerInfo.accessToken = 0;
IDistributedSched::AccountInfo accountInfo;
AppExecFwk::AbilityInfo abilityInfo;
bool needQueryExtension = false;
std::string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, needQueryExtension,
localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_005 end result:" << ret << std::endl;
@@ -167,9 +164,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_006, TestSize.Level1)
callerInfo.accessToken = 0;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
AppExecFwk::AbilityInfo abilityInfo;
bool needQueryExtension = false;
string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, needQueryExtension,
localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_006 end result:" << ret << std::endl;
@@ -188,10 +185,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_007, TestSize.Level1)
CallerInfo callerInfo;
callerInfo.accessToken = 0;
IDistributedSched::AccountInfo accountInfo;
AppExecFwk::AbilityInfo abilityInfo;
abilityInfo.visible = true;
bool needQueryExtension = false;
string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, needQueryExtension,
localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_007 end result:" << ret << std::endl;
@@ -211,9 +207,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_008, TestSize.Level0)
callerInfo.accessToken = 0;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
AppExecFwk::AbilityInfo abilityInfo;
bool needQueryExtension = false;
string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, needQueryExtension,
localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_008 end result:" << ret << std::endl;
@@ -235,10 +231,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_009, TestSize.Level1)
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
std::string groupId = GROUP_ID;
accountInfo.groupIdList.push_back(groupId);
AppExecFwk::AbilityInfo abilityInfo;
abilityInfo.visible = true;
bool needQueryExtension = false;
string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, needQueryExtension,
localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_009 end result:" << ret << std::endl;