!524 补充测试用例

Merge pull request !524 from 杜智海/master
This commit is contained in:
openharmony_ci 2022-12-06 11:59:42 +00:00 committed by Gitee
commit 530c594ca9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 86 additions and 2 deletions

View File

@ -226,6 +226,16 @@ HWTEST_F(DtbschedmgrDeviceInfoStorageTest, GetDeviceIdSetTest_001, TestSize.Leve
set<std::string> deviceIdSet;
DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceIdSet(deviceIdSet);
EXPECT_TRUE(deviceIdSet.empty());
/**
* @tc.steps: step2. test GetDeviceIdSet when remoteDevices_ is not empty;
*/
std::string deviceId = "invalid deviceId for DeviceOnlineNotify";
std::string deviceName = "invalid deviceName for DeviceOnlineNotify";
int32_t deviceType = 0;
std::shared_ptr<DmsDeviceInfo> devInfo = make_shared<DmsDeviceInfo>(deviceName, deviceType, deviceId);
DtbschedmgrDeviceInfoStorage::GetInstance().remoteDevices_[deviceId] = devInfo;
DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceIdSet(deviceIdSet);
EXPECT_FALSE(deviceIdSet.empty());
DTEST_LOG << "DtbschedmgrDeviceInfoStorageTest GetDeviceIdSetTest_001 end" << std::endl;
}

View File

@ -2026,6 +2026,22 @@ HWTEST_F(ContinuationManagerTest, OnDeviceEvent_001, TestSize.Level3)
*/
ret = appDeviceCallbackStub.OnDeviceCancel();
EXPECT_EQ(ERR_NONE, ret);
appDeviceCallbackStub.dmsNotifier_ = nullptr;
/**
* @tc.steps: step4. test OnDeviceConnect when dmsNotifier_ == nullptr
*/
ret = appDeviceCallbackStub.OnDeviceConnect(TEST_TOKEN, continuationResults);
EXPECT_EQ(ERR_NULL_OBJECT, ret);
/**
* @tc.steps: step5. test OnDeviceDisconnect when dmsNotifier_ == nullptr
*/
ret = appDeviceCallbackStub.OnDeviceDisconnect(TEST_TOKEN, continuationResults);
EXPECT_EQ(ERR_NULL_OBJECT, ret);
/**
* @tc.steps: step6. test OnDeviceCancel when dmsNotifier_ == nullptr
*/
ret = appDeviceCallbackStub.OnDeviceCancel();
EXPECT_EQ(ERR_NULL_OBJECT, ret);
}
/**

View File

@ -137,10 +137,43 @@ HWTEST_F(DistributedMissionInfoTest, testUnmarshalling002, TestSize.Level3)
*/
HWTEST_F(DistributedMissionInfoTest, testMarshalling001, TestSize.Level3)
{
/**
* @tc.steps: step1. test Marshalling.
*/
DstbMissionInfo dstbMissionInfo;
Parcel data;
auto ret = dstbMissionInfo.Marshalling(data);
EXPECT_EQ(ret, true);
/**
* @tc.steps: step2. test OnChange when insertEntries is not empty.
*/
std::vector<DistributedKv::Entry> insertEntries;
std::vector<DistributedKv::Entry> updateEntries;
std::vector<DistributedKv::Entry> deleteEntries;
DistributedKv::Entry entry;
entry.key = "key";
entry.value = "value";
insertEntries.emplace_back(entry);
updateEntries.emplace_back(entry);
deleteEntries.emplace_back(entry);
std::string deviceId = "device";
DistributedKv::ChangeNotification changeNotification(std::move(insertEntries), std::move(updateEntries),
std::move(deleteEntries), deviceId, false);
DistributedDataChangeListener distributedDataChangeListener;
distributedDataChangeListener.OnChange(changeNotification);
/**
* @tc.steps: step3. test KeyInfo when strVector.size() == MAX_SPLIT_VARS.
*/
insertEntries.clear();
updateEntries.clear();
deleteEntries.clear();
entry.key = "key_0";
insertEntries.emplace_back(entry);
updateEntries.emplace_back(entry);
deleteEntries.emplace_back(entry);
DistributedKv::ChangeNotification changeNotification1(std::move(insertEntries), std::move(updateEntries),
std::move(deleteEntries), deviceId, false);
distributedDataChangeListener.OnChange(changeNotification);
}
/**
@ -152,12 +185,32 @@ HWTEST_F(DistributedMissionInfoTest, testMarshalling001, TestSize.Level3)
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel001, TestSize.Level3)
{
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel001 start" << std::endl;
/**
* @tc.steps: step1. test ReadDstbMissionInfosFromParcel.
*/
DstbMissionInfo dstbMissionInfo;
Parcel parcel;
std::vector<DstbMissionInfo> missionInfos;
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
EXPECT_TRUE(ret);
EXPECT_EQ(0, missionInfos.size());
/**
* @tc.steps: step2. test KeyInfo when StrToInt failed.
*/
std::vector<DistributedKv::Entry> insertEntries;
std::vector<DistributedKv::Entry> updateEntries;
std::vector<DistributedKv::Entry> deleteEntries;
DistributedKv::Entry entry;
entry.key = "invalid_key";
entry.value = "value";
insertEntries.emplace_back(entry);
updateEntries.emplace_back(entry);
deleteEntries.emplace_back(entry);
std::string deviceId = "device";
DistributedKv::ChangeNotification changeNotification(std::move(insertEntries), std::move(updateEntries),
std::move(deleteEntries), deviceId, false);
DistributedDataChangeListener distributedDataChangeListener;
distributedDataChangeListener.OnChange(changeNotification);
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel001 end" << std::endl;
}

View File

@ -137,11 +137,11 @@ HWTEST_F(MissionInfoConverterTest, testWriteMissionInfosToParcel_001, TestSize.L
result = MissionInfoConverter::ReadMissionInfosFromParcel(parcel, missionInfos);
EXPECT_TRUE(result);
/**
* @tc.steps: step3. test ReadMissionInfosFromParcel when missionInfos is not empty;
* @tc.steps: step3. test WriteMissionInfosToParcel when missionInfos is not empty;
*/
AAFwk::MissionInfo missionInfo;
missionInfos.emplace_back(missionInfo);
result = MissionInfoConverter::ReadMissionInfosFromParcel(parcel, missionInfos);
result = MissionInfoConverter::WriteMissionInfosToParcel(parcel, missionInfos);
EXPECT_TRUE(result);
}

View File

@ -120,6 +120,11 @@ HWTEST_F(SnapshotTest, testWriteToParcel004, TestSize.Level3)
*/
std::unique_ptr<Snapshot> snapShotReturn = snapshot.FillSnapShot(data);
EXPECT_NE(nullptr, snapShotReturn);
/**
* @tc.steps: step3. CreatePixelMap when buffer == nullptr
*/
std::unique_ptr<Media::PixelMap> pixelMap = snapshot.CreatePixelMap(nullptr, TEST_PARCEL_WRITE_VALUE);
EXPECT_EQ(nullptr, pixelMap);
DTEST_LOG << "SnapshotTest testWriteToParcel004 end" << std::endl;
}