Merge pull request !1116 from 师皓杰/master
This commit is contained in:
openharmony_ci 2024-10-10 11:19:22 +00:00 committed by Gitee
commit c56b26f805
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 222 additions and 2 deletions

View File

@ -656,5 +656,21 @@ HWTEST_F(DistributedRadarTest, SaveDataDmsRemoteWant_002, TestSize.Level3)
EXPECT_EQ(ret, true);
DTEST_LOG << "DistributedRadarTest SaveDataDmsRemoteWant_002 end" << std::endl;
}
/**
* @tc.name: NormalFocusedGetAccessTokenIdRes_001
* @tc.desc: check NormalFocusedGetAccessTokenIdRes
* @tc.type: FUNC
*/
HWTEST_F(DistributedRadarTest, NormalFocusedGetAccessTokenIdRes_001, TestSize.Level3)
{
DTEST_LOG << "DistributedRadarTest NormalFocusedGetAccessTokenIdRes_001 begin" << std::endl;
bool ret = DmsRadar::GetInstance().NormalFocusedGetAccessTokenIdRes(FUNC, ERR_NO);
EXPECT_EQ(ret, true);
ret = DmsRadar::GetInstance().NormalFocusedGetAccessTokenIdRes(FUNC, ERR_OK);
EXPECT_EQ(ret, true);
DTEST_LOG << "DistributedRadarTest NormalFocusedGetAccessTokenIdRes_001 end" << std::endl;
}
}
}

View File

@ -101,7 +101,7 @@ HWTEST_F(DistributedBmStorageTest, DeleteStorageDistributeInfoTest_001, TestSize
EXPECT_NE(distributedDataStorage, nullptr);
if (distributedDataStorage != nullptr) {
const std::string bundleName = "NonexistentName";
bool ret = dmsBmStorage_->GetInstance()->SaveStorageDistributeInfo(bundleName);
bool ret = dmsBmStorage_->GetInstance()->DeleteStorageDistributeInfo(bundleName);
EXPECT_EQ(ret, false);
}
DTEST_LOG << "DistributedBmStorageTest DeleteStorageDistributeInfoTest_001 end" << std::endl;

View File

@ -45,6 +45,7 @@ constexpr int32_t ACTIVE = 0;
constexpr int32_t INACTIVE = 1;
constexpr int32_t CANCEL_FOCUSED_DELAYED = 10000;
constexpr int32_t DBMS_RETRY_MAX_TIME = 5;
constexpr uint8_t DMS_FOCUSED_TYPE = 0x00;
}
void DMSContinueManagerTest::SetUpTestCase()
@ -609,6 +610,21 @@ HWTEST_F(DMSContinueManagerTest, testDealSetMissionContinueStateBusiness001, Tes
DTEST_LOG << "DMSContinueManagerTest testDealSetMissionContinueStateBusiness001 end" << std::endl;
}
/**
* @tc.name: testDealSetMissionContinueStateBusiness002
* @tc.desc: test DealSetMissionContinueStateBusiness.
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, testDealSetMissionContinueStateBusiness002, TestSize.Level3)
{
DTEST_LOG << "DMSContinueManagerTest testDealSetMissionContinueStateBusiness002 start" << std::endl;
DMSContinueSendMgr::GetInstance().info_.currentIsContinuable = true;
OHOS::AAFwk::ContinueState state = OHOS::AAFwk::ContinueState::CONTINUESTATE_ACTIVE;
int32_t ret = DMSContinueSendMgr::GetInstance().DealSetMissionContinueStateBusiness(MISSIONID_01, state);
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DMSContinueManagerTest testDealSetMissionContinueStateBusiness002 end" << std::endl;
}
#ifdef SUPPORT_COMMON_EVENT_SERVICE
/**
* @tc.name: testOnDeviceScreenOff001
@ -954,5 +970,107 @@ HWTEST_F(DMSContinueManagerTest, testGetFinalBundleName_001, TestSize.Level1)
EXPECT_EQ(ret, false);
DTEST_LOG << "DMSContinueManagerTest testGetFinalBundleName_001 end" << std::endl;
}
/**
* @tc.name: GetBundleNameByScreenOffInfo_001
* @tc.desc: test GetBundleNameByScreenOffInfo
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, GetBundleNameByScreenOffInfo_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest GetBundleNameByScreenOffInfo_001 start" << std::endl;
DMSContinueSendMgr::GetInstance().screenOffHandler_ = nullptr;
int32_t missionId = 0;
std::string bundleName;
int32_t ret = DMSContinueSendMgr::GetInstance().GetBundleNameByScreenOffInfo(missionId, bundleName);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DMSContinueSendMgr::GetInstance().screenOffHandler_ = std::make_shared<DMSContinueSendMgr::ScreenOffHandler>();
ret = DMSContinueSendMgr::GetInstance().GetBundleNameByScreenOffInfo(missionId, bundleName);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DMSContinueSendMgr::GetInstance().screenOffHandler_->SetScreenOffInfo(0, "", 0, "");
ret = DMSContinueSendMgr::GetInstance().GetBundleNameByScreenOffInfo(missionId, bundleName);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DMSContinueSendMgr::GetInstance().screenOffHandler_->SetScreenOffInfo(0, "bundleName", 0, "");
ret = DMSContinueSendMgr::GetInstance().GetBundleNameByScreenOffInfo(missionId, bundleName);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DMSContinueManagerTest GetBundleNameByScreenOffInfo_001 end" << std::endl;
}
/**
* @tc.name: SendScreenOffEvent_001
* @tc.desc: test SendScreenOffEvent
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, SendScreenOffEvent_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest SendScreenOffEvent_001 start" << std::endl;
DMSContinueSendMgr::GetInstance().screenOffHandler_ = nullptr;
int32_t ret = DMSContinueSendMgr::GetInstance().SendScreenOffEvent(DMS_FOCUSED_TYPE);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DMSContinueSendMgr::GetInstance().screenOffHandler_ = std::make_shared<DMSContinueSendMgr::ScreenOffHandler>();
ret = DMSContinueSendMgr::GetInstance().SendScreenOffEvent(DMS_FOCUSED_TYPE);
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DMSContinueManagerTest SendScreenOffEvent_001 end" << std::endl;
}
/**
* @tc.name: DeleteContinueLaunchMissionInfo_001
* @tc.desc: test DeleteContinueLaunchMissionInfo
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, DeleteContinueLaunchMissionInfo_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest DeleteContinueLaunchMissionInfo_001 start" << std::endl;
int32_t missionId = 0;
DMSContinueSendMgr::GetInstance().continueLaunchMission_.clear();
DMSContinueSendMgr::GetInstance().DeleteContinueLaunchMissionInfo(missionId);
ContinueLaunchMissionInfo info { "bundleName", "abilityName" };
DMSContinueSendMgr::GetInstance().continueLaunchMission_[info] = 0;
DMSContinueSendMgr::GetInstance().DeleteContinueLaunchMissionInfo(missionId);
EXPECT_EQ(DMSContinueSendMgr::GetInstance().continueLaunchMission_.empty(), true);
DTEST_LOG << "DMSContinueManagerTest DeleteContinueLaunchMissionInfo_001 end" << std::endl;
}
/**
* @tc.name: CheckContinueState_001
* @tc.desc: test CheckContinueState
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, CheckContinueState_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest CheckContinueState_001 start" << std::endl;
int32_t missionId = 0;
int32_t ret = DMSContinueSendMgr::GetInstance().CheckContinueState(missionId);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DMSContinueManagerTest CheckContinueState_001 end" << std::endl;
}
/**
* @tc.name: OnContinueSwitchOff_001
* @tc.desc: test OnContinueSwitchOff
* @tc.type: FUNC
*/
HWTEST_F(DMSContinueManagerTest, OnContinueSwitchOff_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest OnContinueSwitchOff_001 start" << std::endl;
DMSContinueRecvMgr::GetInstance().iconInfo_.senderNetworkId = "";
DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName = "";
DMSContinueRecvMgr::GetInstance().iconInfo_.continueType = "";
DMSContinueRecvMgr::GetInstance().OnContinueSwitchOff();
EXPECT_EQ(DMSContinueRecvMgr::GetInstance().iconInfo_.isEmpty(), true);
DMSContinueRecvMgr::GetInstance().iconInfo_.senderNetworkId = "senderNetworkId";
DMSContinueRecvMgr::GetInstance().iconInfo_.bundleName = "bundleName";
DMSContinueRecvMgr::GetInstance().iconInfo_.continueType = "continueType";
DMSContinueRecvMgr::GetInstance().registerOnListener_.clear();
DMSContinueRecvMgr::GetInstance().OnContinueSwitchOff();
EXPECT_EQ(DMSContinueRecvMgr::GetInstance().registerOnListener_.empty(), true);
DTEST_LOG << "DMSContinueManagerTest OnContinueSwitchOff_001 end" << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -212,6 +212,33 @@ HWTEST_F(DmsKvSyncE2ETest, CheckCtrlRuleTest_001, TestSize.Level1)
DTEST_LOG << "DmsKvSyncE2ETest CheckCtrlRuleTest_001 end" << std::endl;
}
/**
* @tc.name: CheckCtrlRuleTest_002
* @tc.desc: test insert DmsKvSyncE2E
* @tc.type: FUNC
*/
HWTEST_F(DmsKvSyncE2ETest, CheckCtrlRuleTest_002, TestSize.Level1)
{
DTEST_LOG << "DmsKvSyncE2ETest CheckCtrlRuleTest_002 start" << std::endl;
ASSERT_NE(dmsKvSyncE2E_, nullptr);
auto dmsKvSyncE2E = GetDmsKvSyncE2E();
EXPECT_NE(dmsKvSyncE2E, nullptr);
if (dmsKvSyncE2E != nullptr) {
dmsKvSyncE2E_->GetInstance()->isForbidSendAndRecv_ = true;
bool ret = dmsKvSyncE2E_->GetInstance()->CheckCtrlRule();
EXPECT_EQ(ret, true);
dmsKvSyncE2E_->GetInstance()->isCfgDevices_ = true;
ret = dmsKvSyncE2E_->GetInstance()->CheckCtrlRule();
EXPECT_EQ(ret, false);
dmsKvSyncE2E_->GetInstance()->isForbidSendAndRecv_ = false;
ret = dmsKvSyncE2E_->GetInstance()->CheckCtrlRule();
EXPECT_EQ(ret, true);
}
DTEST_LOG << "DmsKvSyncE2ETest CheckCtrlRuleTest_002 end" << std::endl;
}
/**
* @tc.name: CheckBundleContinueConfigTest_001
* @tc.desc: test insert DmsKvSyncE2E
@ -225,11 +252,35 @@ HWTEST_F(DmsKvSyncE2ETest, CheckBundleContinueConfigTest_001, TestSize.Level1)
EXPECT_NE(dmsKvSyncE2E, nullptr);
if (dmsKvSyncE2E != nullptr) {
const std::string bundleName = "123";
dmsKvSyncE2E_->GetInstance()->isCfgDevices_ = false;
bool ret = dmsKvSyncE2E_->GetInstance()->CheckBundleContinueConfig(bundleName);
EXPECT_EQ(ret, true);
}
DTEST_LOG << "DmsKvSyncE2ETest CheckBundleContinueConfigTest_001 end" << std::endl;
}
/**
* @tc.name: IsValidPath_001
* @tc.desc: test IsValidPath
* @tc.type: FUNC
*/
HWTEST_F(DmsKvSyncE2ETest, IsValidPath_001, TestSize.Level1)
{
DTEST_LOG << "DmsKvSyncE2ETest CheckCtrlRuleTest_001 start" << std::endl;
ASSERT_NE(dmsKvSyncE2E_, nullptr);
auto dmsKvSyncE2E = GetDmsKvSyncE2E();
EXPECT_NE(dmsKvSyncE2E, nullptr);
if (dmsKvSyncE2E != nullptr) {
std::string inFilePath = "";
std::string realFilePath;
bool ret = dmsKvSyncE2E_->GetInstance()->IsValidPath(inFilePath, realFilePath);
EXPECT_EQ(ret, false);
inFilePath = "inFilePath";
ret = dmsKvSyncE2E_->GetInstance()->IsValidPath(inFilePath, realFilePath);
EXPECT_EQ(ret, false);
}
DTEST_LOG << "DmsKvSyncE2ETest IsValidPath_001 end" << std::endl;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -244,6 +244,9 @@ HWTEST_F(DSchedSoftbusSessionTest, OnBytesReceived_001, TestSize.Level3)
ASSERT_NE(buffer, nullptr);
int32_t ret = softbusSessionTest_->OnBytesReceived(buffer);
EXPECT_EQ(ret, ERR_OK);
ret = softbusSessionTest_->OnBytesReceived(nullptr);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
softbusSessionTest_ = nullptr;
DTEST_LOG << "DSchedSoftbusSessionTest OnBytesReceived_001 end" << std::endl;
}
@ -263,6 +266,9 @@ HWTEST_F(DSchedSoftbusSessionTest, SendData_001, TestSize.Level3)
int32_t dataType = COUNT;
int32_t ret = softbusSessionTest_->SendData(buffer, dataType);
EXPECT_EQ(ret, ERR_OK);
ret = softbusSessionTest_->SendData(nullptr, dataType);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
softbusSessionTest_ = nullptr;
DTEST_LOG << "DSchedSoftbusSessionTest SendData_001 end" << std::endl;
}
@ -486,8 +492,37 @@ HWTEST_F(DSchedTransportSoftbusAdapterTest, ReleaseChannel_001, TestSize.Level3)
DSchedTransportSoftbusAdapter::GetInstance().NotifyListenersSessionShutdown(sessionId, isSelfcalled);
DSchedTransportSoftbusAdapter::GetInstance().OnBytes(sessionId, nullptr, 0);
int32_t ret = DSchedTransportSoftbusAdapter::GetInstance().ReleaseChannel();
EXPECT_EQ(ret, -ERR_OK);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedTransportSoftbusAdapterTest ReleaseChannel_001 end" << std::endl;
}
/**
* @tc.name: SendBytesBySoftbus_001
* @tc.desc: call SendBytesBySoftbus
* @tc.type: FUNC
*/
HWTEST_F(DSchedTransportSoftbusAdapterTest, SendBytesBySoftbus_001, TestSize.Level3)
{
DTEST_LOG << "DSchedTransportSoftbusAdapterTest SendBytesBySoftbus_001 begin" << std::endl;
int32_t sessionId = 0;
int32_t ret = DSchedTransportSoftbusAdapter::GetInstance().SendBytesBySoftbus(sessionId, nullptr);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedTransportSoftbusAdapterTest SendBytesBySoftbus_001 end" << std::endl;
}
/**
* @tc.name: AddNewPeerSession_001
* @tc.desc: call AddNewPeerSession
* @tc.type: FUNC
*/
HWTEST_F(DSchedTransportSoftbusAdapterTest, AddNewPeerSession_001, TestSize.Level3)
{
DTEST_LOG << "DSchedTransportSoftbusAdapterTest AddNewPeerSession_001 begin" << std::endl;
std::string peerDeviceId = "peerDeviceId";
int32_t sessionId = 0;
int32_t ret = DSchedTransportSoftbusAdapter::GetInstance().AddNewPeerSession(peerDeviceId, sessionId);
EXPECT_EQ(ret, REMOTE_DEVICE_BIND_ABILITY_ERR);
DTEST_LOG << "DSchedTransportSoftbusAdapterTest AddNewPeerSession_001 end" << std::endl;
}
}
}