!205 add group check unittest

Merge pull request !205 from zhangmingxiang/0412
This commit is contained in:
openharmony_ci 2022-04-12 06:18:08 +00:00 committed by Gitee
commit 8cb44c66e7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 54 additions and 1 deletions

View File

@ -167,6 +167,7 @@ ohos_unittest("dschedpermissiontest") {
ohos_unittest("dschedmissionmanagertest") {
module_out_path = module_output_path
sources = [ "unittest/mission/dms_mission_manager_test.cpp" ]
sources += dtbschedmgr_sources
configs = [ ":test_config" ]
configs += dsched_configs
deps = dsched_deps
@ -182,6 +183,7 @@ ohos_unittest("dschedmissionmanagertest") {
ohos_unittest("dscheddatastoragetest") {
module_out_path = module_output_path
sources = [ "unittest/mission/distributed_data_storage_test.cpp" ]
sources += dtbschedmgr_sources
configs = [ ":test_config" ]
configs += dsched_configs
deps = dsched_deps

View File

@ -25,6 +25,10 @@ using namespace testing::ext;
namespace OHOS {
namespace DistributedSchedule {
namespace {
const string GROUP_ID = "TEST_GROUP_ID";
}
void DistributedSchedPermissionTest::SetUpTestCase()
{
DTEST_LOG << "DistributedSchedPermissionTest::SetUpTestCase" << std::endl;
@ -193,5 +197,52 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_007, TestSize.Level1)
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_007 end result:" << ret << std::endl;
}
/**
* @tc.name: CheckDPermission_008
* @tc.desc: call CheckDPermission with same account type
* @tc.type: FUNC
* @tc.require: SR000H1FJV
*/
HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_008, TestSize.Level0)
{
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_008 begin" << std::endl;
AAFwk::Want want;
CallerInfo callerInfo;
callerInfo.accessToken = 0;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
AppExecFwk::AbilityInfo abilityInfo;
string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_008 end result:" << ret << std::endl;
}
/**
* @tc.name: CheckDPermission_009
* @tc.desc: call CheckDPermission with illegal account info
* @tc.type: FUNC
* @tc.require: AR000H23VS
*/
HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_009, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_009 begin" << std::endl;
AAFwk::Want want;
CallerInfo callerInfo;
callerInfo.accessToken = 0;
IDistributedSched::AccountInfo accountInfo;
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
std::string groupId = GROUP_ID;
accountInfo.groupIdList.push_back(groupId);
AppExecFwk::AbilityInfo abilityInfo;
abilityInfo.visible = true;
string localDeviceId = "255.255.255.255";
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
localDeviceId);
EXPECT_TRUE(ret != ERR_OK);
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_009 end result:" << ret << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -297,7 +297,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener002, TestSize.Level1)
EXPECT_TRUE(ret != ERR_NONE);
ret = proxy->UnRegisterMissionListener(U16DEVICE_ID, listener);
EXPECT_TRUE(ret == ERR_NONE);
EXPECT_TRUE(ret != ERR_NONE);
ret = proxy->UnRegisterMissionListener(u16localDeviceId_, listener);
EXPECT_TRUE(ret != ERR_NONE);