修复异常

Signed-off-by: 师皓杰 <shihaojie10@huawei.com>
This commit is contained in:
师皓杰 2024-11-14 16:30:03 +08:00
parent 50586f078b
commit fa2db294e1
13 changed files with 666 additions and 283 deletions

View File

@ -162,6 +162,9 @@ ohos_unittest("distributedschedservicetest") {
"unittest/distributed_sched_service_second_test.cpp",
"unittest/mock_distributed_sched.cpp",
]
if (dmsfwk_ces_listener) {
sources += [ "unittest/common_event_listener_test.cpp" ]
}
sources += dtbschedmgr_sources
configs = [
@ -203,8 +206,13 @@ ohos_unittest("distributedschedstubtest") {
public_deps = dsched_public_deps
}
defines = []
if (dmsfwk_report_memmgr || dmsfwk_report_memmgr_plugins) {
defines = [ "SUPPORT_DISTRIBUTEDCOMPONENT_TO_MEMMGR" ]
defines += [ "SUPPORT_DISTRIBUTEDCOMPONENT_TO_MEMMGR" ]
}
if (!dmsfwk_softbus_adapter_common) {
defines += [ "DMSFWK_INTERACTIVE_ADAPTER" ]
}
part_name = "dmsfwk"

View File

@ -31,11 +31,38 @@ using namespace testing::ext;
namespace OHOS {
namespace DistributedSchedule {
static std::string g_mockString = "";
static bool g_mockBool = false;
namespace {
const string GROUP_ID = "TEST_GROUP_ID";
constexpr int32_t SLEEP_TIME = 1000;
}
bool DmsBmStorage::GetBundleNameId(const std::string& bundleName, uint16_t &bundleNameId)
{
return g_mockBool;
}
std::string DmsBmStorage::GetContinueType(const std::string &networkId, std::string &bundleName,
uint8_t continueTypeId)
{
return g_mockString;
}
bool DmsBmStorage::GetContinueTypeId(const std::string &bundleName, const std::string &abilityName,
uint8_t &continueTypeId)
{
return g_mockBool;
}
bool DmsBmStorage::GetDistributedBundleName(const std::string &networkId, const uint16_t& bundleNameId,
std::string &bundleName)
{
return g_mockBool;
}
void BundleManagerInternalTest::SetUpTestCase()
{
DTEST_LOG << "BundleManagerInternalTest::SetUpTestCase" << std::endl;
@ -646,5 +673,73 @@ HWTEST_F(BundleManagerInternalTest, GetBundleNameById_001, TestSize.Level3)
EXPECT_EQ(ret, CAN_NOT_FOUND_ABILITY_ERR);
DTEST_LOG << "BundleManagerInternalTest GetBundleNameById_001 end "<< std::endl;
}
/**
* @tc.name: GetBundleNameId_003
* @tc.desc: test get bundleNameId from bms
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetBundleNameId_003, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetBundleNameId_003 begin" << std::endl;
const std::string bundleName = "com.ohos.mms";
uint16_t bundleNameId = 0;
g_mockBool = true;
int32_t ret = BundleManagerInternal::GetBundleNameId(bundleName, bundleNameId);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "BundleManagerInternalTest GetBundleNameId_003 end "<< std::endl;
}
/**
* @tc.name: GetContinueType_002
* @tc.desc: GetContinueType
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetContinueType_002, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetContinueType_002 begin" << std::endl;
std::string networkId = "networkId";
std::string bundleName;
uint8_t continueTypeId = 0;
g_mockString = "continueType";
std::string str = BundleManagerInternal::GetContinueType(networkId, bundleName, continueTypeId);
EXPECT_NE(str, "");
DTEST_LOG << "BundleManagerInternalTest GetContinueType_002 end "<< std::endl;
}
/**
* @tc.name: GetContinueTypeId_002
* @tc.desc: GetContinueTypeId
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetContinueTypeId_002, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetContinueTypeId_002 begin" << std::endl;
std::string networkId = "networkId";
std::string abilityName;
uint8_t continueTypeId = 0;
g_mockBool = true;
int32_t ret = BundleManagerInternal::GetContinueTypeId(networkId, abilityName, continueTypeId);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "BundleManagerInternalTest GetContinueTypeId_002 end "<< std::endl;
}
/**
* @tc.name: GetBundleNameById_002
* @tc.desc: GetBundleNameById
* @tc.type: FUNC
*/
HWTEST_F(BundleManagerInternalTest, GetBundleNameById_002, TestSize.Level3)
{
DTEST_LOG << "BundleManagerInternalTest GetBundleNameById_002 begin" << std::endl;
std::string networkId = "networkId";
std::string bundleName;
uint16_t bundleNameId = 0;
g_mockBool = true;
int32_t ret = BundleManagerInternal::GetBundleNameById(networkId, bundleNameId, bundleName);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "BundleManagerInternalTest GetBundleNameById_002 end "<< std::endl;
}
}
}

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common_event_listener.h"
#include "gtest/gtest.h"
#include "test_log.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace DistributedSchedule {
class CommonEventListenerTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
std::shared_ptr<CommonEventListener> applyMonitor = nullptr;
};
void CommonEventListenerTest::SetUpTestCase()
{
}
void CommonEventListenerTest::TearDownTestCase()
{
}
void CommonEventListenerTest::SetUp()
{
EventFwk::MatchingSkills matchingSkills;
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_LOCKED);
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED);
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF);
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON);
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED);
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED);
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED);
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
applyMonitor = std::make_shared<CommonEventListener>(subscribeInfo);
}
void CommonEventListenerTest::TearDown()
{
}
/**
* @tc.name: OnReceiveEvent001
* @tc.desc: call OnReceiveEvent
* @tc.type: FUNC
*/
HWTEST_F(CommonEventListenerTest, OnReceiveEvent001, TestSize.Level3)
{
DTEST_LOG << "CommonEventListenerTest OnReceiveEvent001 start" << std::endl;
AAFwk::Want want;
EventFwk::CommonEventData eventData;
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_LOCKED);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED);
eventData.SetWant(want);
EXPECT_NO_FATAL_FAILURE(applyMonitor->OnReceiveEvent(eventData));
DTEST_LOG << "CommonEventListenerTest OnReceiveEvent001 end" << std::endl;
}
/**
* @tc.name: OnReceiveEvent002
* @tc.desc: call OnReceiveEvent
* @tc.type: FUNC
*/
HWTEST_F(CommonEventListenerTest, OnReceiveEvent002, TestSize.Level3)
{
DTEST_LOG << "CommonEventListenerTest OnReceiveEvent002 start" << std::endl;
AAFwk::Want want;
EventFwk::CommonEventData eventData;
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_USER_REMOVED);
eventData.SetWant(want);
applyMonitor->OnReceiveEvent(eventData);
want.SetAction("receiveEvent");
eventData.SetWant(want);
EXPECT_NO_FATAL_FAILURE(applyMonitor->OnReceiveEvent(eventData));
DTEST_LOG << "CommonEventListenerTest OnReceiveEvent002 end" << std::endl;
}
}
}

View File

@ -316,6 +316,7 @@ HWTEST_F(DSchedContinueManagerTest, GetContinueInfo_002, TestSize.Level3)
DSchedContinueInfo info;
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
std::string localDeviceId = "localdeviceid";
std::string remoteDeviceId = "remotedeviceid";
DSchedContinueManager::GetInstance().continues_[info] = dContinue;
@ -546,6 +547,7 @@ HWTEST_F(DSchedContinueManagerTest, GetDSchedContinueByWant_002, TestSize.Level3
EXPECT_EQ(ret, nullptr);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
DSchedContinueManager::GetInstance().continues_[info] = nullptr;
DSchedContinueManager::GetInstance().continues_[info] = dContinue;

View File

@ -483,6 +483,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueDataTask001, TestSize.Level3
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = dataStateTest_->DoContinueDataTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueDataTask001 end" << std::endl;
@ -500,6 +501,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueDataTask002, TestSize.Level3
auto data = std::make_shared<DSchedContinueDataCmd>();
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_DATA_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
EXPECT_CALL(*mockStateTest_, GetLocalDeviceId(_)).WillOnce(Return(true));
int32_t ret = dataStateTest_->DoContinueDataTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
@ -530,6 +532,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueEndTask001, TestSize.Level3)
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = dataStateTest_->DoContinueEndTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueEndTask001 end" << std::endl;
@ -547,6 +550,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueEndTask002, TestSize.Level3)
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_END_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = dataStateTest_->DoContinueEndTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueEndTask002 end" << std::endl;
@ -576,6 +580,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueErrorTask001, TestSize.Level
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = dataStateTest_->DoContinueErrorTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueErrorTask001 end" << std::endl;
@ -593,6 +598,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueErrorTask002, TestSize.Level
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_COMPLETE_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = dataStateTest_->DoContinueErrorTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueErrorTask002 end" << std::endl;
@ -683,6 +689,7 @@ HWTEST_F(DSchedContinueSinkEndStateTest, TestSinkDoContinueEndTask001, TestSize.
EXPECT_NE(ret, ERR_OK);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
sinkEndStateTest_->DoContinueEndTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSinkEndStateTest TestSinkDoContinueEndTask001 end" << std::endl;
@ -700,6 +707,7 @@ HWTEST_F(DSchedContinueSinkEndStateTest, TestSinkDoContinueEndTask002, TestSize.
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_END_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = sinkEndStateTest_->DoContinueEndTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSinkEndStateTest TestSinkDoContinueEndTask002 end" << std::endl;
@ -792,6 +800,7 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinuePullReqTaskTest_001, Te
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = sinkStartStateTest_->DoContinuePullReqTask(dContinue,
AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -824,6 +833,7 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinueAbilityTaskTest_001, Te
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = sinkStartStateTest_->DoContinueAbilityTask(dContinue,
AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -856,6 +866,7 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinueEndTaskTest_001, TestSi
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = sinkStartStateTest_->DoContinueEndTask(dContinue,
AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -887,6 +898,7 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinueErrorTask001, TestSize.
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = sinkStartStateTest_->DoContinueErrorTask(dContinue,
AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -980,6 +992,7 @@ HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkDoNotifyCompleteTask001, TestSi
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = sinkWaitEndTest_->DoNotifyCompleteTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSinkWaitEndStateTest SinkDoNotifyCompleteTask001 end" << std::endl;
@ -997,6 +1010,7 @@ HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkDoNotifyCompleteTask002, TestSi
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_COMPLETE_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = sinkWaitEndTest_->DoNotifyCompleteTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSinkWaitEndStateTest SinkDoNotifyCompleteTask002 end" << std::endl;
@ -1027,6 +1041,7 @@ HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkDoContinueEndTask001, TestSize.
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = sinkWaitEndTest_->DoContinueEndTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSinkWaitEndStateTest SinkDoContinueEndTask001 end" << std::endl;
@ -1044,6 +1059,7 @@ HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkDoContinueEndTask002, TestSize.
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_END_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = sinkWaitEndTest_->DoContinueEndTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSinkWaitEndStateTest SinkDoContinueEndTask002 end" << std::endl;
@ -1134,6 +1150,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueSendTask001, TestSize.Leve
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = abilityStateTest_->DoContinueSendTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueSendTask001 end" << std::endl;
@ -1151,6 +1168,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueSendTask002, TestSize.Leve
auto data = std::make_shared<ContinueAbilityData>();
auto event = AppExecFwk::InnerEvent::Get(DSHCED_CONTINUE_SEND_DATA_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = abilityStateTest_->DoContinueSendTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueSendTask002 end" << std::endl;
@ -1180,6 +1198,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueEndTask001, TestSize.Level
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = abilityStateTest_->DoContinueEndTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueEndTask001 end" << std::endl;
@ -1197,6 +1216,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueErrorTask002, TestSize.Lev
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_COMPLETE_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = abilityStateTest_->DoContinueErrorTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueErrorTask002 end" << std::endl;
@ -1226,6 +1246,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueErrorTask001, TestSize.Lev
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = abilityStateTest_->DoContinueErrorTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueErrorTask001 end" << std::endl;
@ -1243,6 +1264,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueEndTask002, TestSize.Level
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_END_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = abilityStateTest_->DoContinueEndTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueEndTask002 end" << std::endl;
@ -1333,6 +1355,7 @@ HWTEST_F(DSchedContinueEndStateTest, SrcDoContinueEndTaskTest001, TestSize.Level
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = srcEndStateTest_->DoContinueEndTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueEndStateTest SrcDoContinueEndTaskTest001 end" << std::endl;
@ -1350,6 +1373,7 @@ HWTEST_F(DSchedContinueEndStateTest, SrcDoContinueEndTaskTest002, TestSize.Level
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_END_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcEndStateTest_->DoContinueEndTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueEndStateTest SrcDoContinueEndTaskTest002 end" << std::endl;
@ -1460,6 +1484,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinuePushReqTaskTest_002, T
}
};
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcStartStateTest_->DoContinuePushReqTask(dContinue,
AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -1491,6 +1516,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinuePushReqTaskTest_003, T
auto wantParamsPtr = std::make_shared<OHOS::AAFwk::WantParams>(wantParams);
auto event = AppExecFwk::InnerEvent::Get(DSHCED_CONTINUE_REQ_PUSH_EVENT, wantParamsPtr, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcStartStateTest_->DoContinuePushReqTask(dContinue, event);
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcDoContinuePushReqTaskTest_003 end" << std::endl;
@ -1534,6 +1560,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinueAbilityTaskTest_002, T
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSHCED_CONTINUE_ABILITY_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcStartStateTest_->DoContinueAbilityTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcDoContinueAbilityTaskTest_002 end" << std::endl;
@ -1577,6 +1604,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinueEndTaskTest_002, TestS
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_END_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcStartStateTest_->DoContinueEndTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcDoContinueEndTaskTest_002 end" << std::endl;
@ -1619,6 +1647,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinueErrorTaskTest_002, Tes
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_COMPLETE_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcStartStateTest_->DoContinueErrorTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcDoContinueErrorTaskTest_002 end" << std::endl;
@ -1710,6 +1739,7 @@ HWTEST_F(DSchedContinueWaitEndStateTest, SrcDoNotifyCompleteTask_001, TestSize.L
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = srcWaitEndTest_->DoNotifyCompleteTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueWaitEndStateTest SrcDoNotifyCompleteTask_001 end" << std::endl;
@ -1727,6 +1757,7 @@ HWTEST_F(DSchedContinueWaitEndStateTest, SrcDoNotifyCompleteTask_002, TestSize.L
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_COMPLETE_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcWaitEndTest_->DoNotifyCompleteTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueWaitEndStateTest SrcDoNotifyCompleteTask_002 end" << std::endl;
@ -1757,6 +1788,7 @@ HWTEST_F(DSchedContinueWaitEndStateTest, SrcDoContinueEndTask_001, TestSize.Leve
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
ret = srcWaitEndTest_->DoContinueEndTask(dContinue, AppExecFwk::InnerEvent::Pointer(nullptr, nullptr));
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueWaitEndStateTest SrcDoContinueEndTask_001 end" << std::endl;
@ -1774,6 +1806,7 @@ HWTEST_F(DSchedContinueWaitEndStateTest, SrcDoContinueEndTask_002, TestSize.Leve
auto data = std::make_shared<int32_t>(1);
auto event = AppExecFwk::InnerEvent::Get(DSCHED_CONTINUE_END_EVENT, data, 0);
std::shared_ptr<DSchedContinue> dContinue = CreateObject();
usleep(WAITTIME);
int32_t ret = srcWaitEndTest_->DoContinueEndTask(dContinue, event);
EXPECT_NE(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DSchedContinueWaitEndStateTest SrcDoContinueEndTask_002 end" << std::endl;

View File

@ -88,6 +88,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_001_1, TestSize.Level0)
// eventHandler_ not null
conti->Init();
usleep(WAITTIME);
ret = conti->PostStartTask(wantParams);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_001_1 end ret:" << ret << std::endl;
@ -120,6 +121,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_002_1, TestSize.Level0)
// eventHandler_ not null
conti->Init();
usleep(WAITTIME);
ret = conti->PostCotinueAbilityTask(appVersion);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_002_1 end ret:" << ret << std::endl;
@ -153,6 +155,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_003_1, TestSize.Level0)
// eventHandler_ not null
conti->Init();
usleep(WAITTIME);
cmd->replyCmd_ = DSCHED_CONTINUE_END_EVENT;
ret = conti->OnReplyCmd(cmd);
@ -202,6 +205,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_004_1, TestSize.Level0)
// eventHandler_ not null
conti->Init();
usleep(WAITTIME);
ret = conti->OnStartContinuation(want, callerUid, status, accessToken);
EXPECT_EQ(ret, ERR_OK);
@ -242,6 +246,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_005_1, TestSize.Level0)
// eventHandler_ not null
conti->Init();
usleep(WAITTIME);
ret = conti->OnContinueDataCmd(cmd);
EXPECT_EQ(ret, ERR_OK);
@ -292,6 +297,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_006_1, TestSize.Level0)
// eventHandler_ not null
conti->Init();
usleep(WAITTIME);
ret = conti->PostNotifyCompleteTask(ERR_OK);
EXPECT_EQ(ret, ERR_OK);
@ -328,6 +334,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_007_1, TestSize.Level0)
// eventHandler_ not null
conti->Init();
usleep(WAITTIME);
ret = conti->PostContinueEndTask(result);
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DSchedContinueTest DSchedContinueTest_007_1 end ret:" << ret << std::endl;
@ -350,6 +357,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_008_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto wantParams = std::make_shared<DistributedWantParams>();
int32_t ret = conti->ExecuteContinueReq(wantParams);
@ -375,6 +383,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_009_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto cmd = std::make_shared<DSchedContinueStartCmd>();
auto wantParams = std::make_shared<DistributedWantParams>();
@ -410,6 +419,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0010_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, deviceId, missionId);
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t appVersion = 0;
int32_t ret = conti->ExecuteContinueAbility(appVersion);
@ -434,6 +444,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0011_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, deviceId, missionId);
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t ret = conti->GetMissionIdByBundleName();
EXPECT_EQ(ret, ERR_OK);
@ -457,6 +468,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0012_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t ret = conti->CheckContinueAbilityPermission();
EXPECT_EQ(ret, NO_MISSION_INFO_FOR_MISSION_ID);
@ -480,6 +492,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0013_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t ret = conti->ExecuteContinueReply();
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -503,6 +516,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0014_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto data = std::make_shared<ContinueAbilityData>();
int32_t ret = conti->ExecuteContinueSend(data);
@ -531,6 +545,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0015_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
AAFwk::Want want;
int32_t ret = conti->SetWantForContinuation(want);
@ -555,6 +570,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0016_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto cmd = std::make_shared<DSchedContinueDataCmd>();
OHOS::AAFwk::Want want;
@ -588,6 +604,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0017_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto cmd = std::make_shared<DSchedContinueDataCmd>();
@ -618,6 +635,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0018_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t result = ERR_OK;
int32_t ret = conti->ExecuteNotifyComplete(result);
@ -646,6 +664,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0019_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto cmd = std::make_shared<DSchedContinueReplyCmd>();
int32_t replyCmd = 0;
@ -678,6 +697,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0020_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t result = 0;
@ -703,6 +723,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0021_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t result = 0;
int32_t ret = conti->ExecuteContinueError(result);
@ -731,6 +752,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0022_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto cmd = std::make_shared<DSchedContinueEndCmd>();
int32_t result = 0;
@ -761,6 +783,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0023_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
auto cmd = std::make_shared<DSchedContinueCmdBase>();
int32_t ret = conti->SendCommand(cmd);
@ -785,6 +808,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0024_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
std::string localDeviceId;
EXPECT_CALL(*dmsStoreMock, GetLocalDeviceId(_)).WillOnce(Return(true));
@ -810,6 +834,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_0025_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
bool ret = conti->CheckDeviceIdFromRemote("", "", "");
EXPECT_FALSE(ret);
@ -853,6 +878,7 @@ HWTEST_F(DSchedContinueTest, WaitAbilityStateInitialTest_0026_1, TestSize.Level0
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t persistentId = 100;
bool ret = conti->WaitAbilityStateInitial(persistentId);
@ -877,6 +903,7 @@ HWTEST_F(DSchedContinueTest, StartAbilityTest_0027_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
AAFwk::Want want;
AppExecFwk::ElementName element("devicdId", "com.ohos.distributedmusicplayer",
@ -905,6 +932,7 @@ HWTEST_F(DSchedContinueTest, QuerySinkAbilityNameTest_0028_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, continueType);
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
std::string sinkBundleName = conti->QuerySinkAbilityName();
EXPECT_TRUE(sinkBundleName.empty());
@ -928,6 +956,7 @@ HWTEST_F(DSchedContinueTest, QuickStartAbilityTest_0029_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t ret = conti->QuickStartAbility();
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -951,6 +980,7 @@ HWTEST_F(DSchedContinueTest, UpdateWantForContinueTypeTest_0030_1, TestSize.Leve
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
AAFwk::Want want;
AppExecFwk::ElementName element("devicdId", "com.ohos.distributedmusicplayer",
@ -978,6 +1008,7 @@ HWTEST_F(DSchedContinueTest, DSchedContinueTest_031_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
AppExecFwk::InnerEvent *event = nullptr;
auto destructor = [](AppExecFwk::InnerEvent *event) {
@ -1011,6 +1042,7 @@ HWTEST_F(DSchedContinueTest, OnDataRecvTest_032_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t command = 0;
std::shared_ptr<DSchedDataBuffer> dataBuffer = nullptr;
@ -1052,6 +1084,7 @@ HWTEST_F(DSchedContinueTest, UpdateStateTest_033_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
DSchedContinueStateType stateType = DSCHED_CONTINUE_SINK_START_STATE;
conti->UpdateState(stateType);
@ -1079,6 +1112,7 @@ HWTEST_F(DSchedContinueTest, CheckStartPermission_034_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t ret = conti->CheckStartPermission(cmd);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -1108,6 +1142,7 @@ HWTEST_F(DSchedContinueTest, ConvertToDmsSdkErr_035_1, TestSize.Level0)
auto info = DSchedContinueInfo(deviceId, bundleName, deviceId, bundleName, "");
auto conti = std::make_shared<DSchedContinue>(subType, direction, callback, info);
conti->Init();
usleep(WAITTIME);
int32_t ret = conti->ConvertToDmsSdkErr(0);
EXPECT_EQ(ret, ERR_OK);

View File

@ -1155,3 +1155,29 @@ HWTEST_F(DistributedWantParamsBaseTest, DistributedWantParams_ReadFromParcelPara
EXPECT_TRUE(result);
DTEST_LOG << "DistributedWantParamsBaseTest DistributedWantParams_ReadFromParcelParam_1000 end" << std::endl;
}
/**
* @tc.number: ReadFromParcelWantParamWrapper_1000
* @tc.name: ReadFromParcelWantParamWrapper
* @tc.desc: Test ReadFromParcelWantParamWrapper.
* @tc.require: I77HFZ
*/
HWTEST_F(DistributedWantParamsBaseTest, ReadFromParcelWantParamWrapper_1000, Function | MediumTest | Level3)
{
DTEST_LOG << "DistributedWantParamsBaseTest ReadFromParcelWantParamWrapper_1000 begin" << std::endl;
DistributedWantParams wantParams;
Parcel parcel;
std::string key = "this is key";
int type = DistributedWantParams::VALUE_TYPE_FD;
int bufferSize = 1;
parcel.WriteInt32(bufferSize);
parcel.WriteInt32(0);
bool result = wantParams.ReadFromParcelWantParamWrapper(parcel, key, type);
EXPECT_TRUE(result);
type = DistributedWantParams::VALUE_TYPE_REMOTE_OBJECT;
result = wantParams.ReadFromParcelWantParamWrapper(parcel, key, type);
EXPECT_TRUE(result);
DTEST_LOG << "DistributedWantParamsBaseTest ReadFromParcelWantParamWrapper_1000 end" << std::endl;
}

View File

@ -3758,5 +3758,176 @@ HWTEST_F(DistributedWantBaseTest, GetLowerCaseScheme_test_003, TestSize.Level3)
EXPECT_FALSE(strUri.empty());
GTEST_LOG_(INFO) << "GetLowerCaseScheme_test_003 end";
}
/**
* @tc.number: GetLowerCaseScheme_test_004
* @tc.name: GetLowerCaseScheme
* @tc.desc: Test GetLowerCaseScheme.
*/
HWTEST_F(DistributedWantBaseTest, GetLowerCaseScheme_test_004, TestSize.Level3)
{
GTEST_LOG_(INFO) << "GetLowerCaseScheme_test_004 start";
DistributedWant want;
Uri lowerCaseUri("http://TEST.COM");
Uri result = want.GetLowerCaseScheme(lowerCaseUri);
EXPECT_EQ(result, lowerCaseUri);
GTEST_LOG_(INFO) << "GetLowerCaseScheme_test_004 end";
}
/**
* @tc.number: ReadUriFromParcel_test_001
* @tc.name: ReadUriFromParcel
* @tc.desc: Test ReadUriFromParcel.
*/
HWTEST_F(DistributedWantBaseTest, ReadUriFromParcel_test_001, TestSize.Level3)
{
GTEST_LOG_(INFO) << "ReadUriFromParcel_test_001 start";
DistributedWant want;
Parcel parcel;
parcel.WriteInt32(DistributedOperation::VALUE_OBJECT);
bool result = want.ReadUriFromParcel(parcel);
EXPECT_EQ(result, true);
GTEST_LOG_(INFO) << "ReadUriFromParcel_test_001 end";
}
/**
* @tc.number: CanReadFromJson_test_001
* @tc.name: CanReadFromJson
* @tc.desc: Test CanReadFromJson.
*/
HWTEST_F(DistributedWantBaseTest, CanReadFromJson_test_001, TestSize.Level3)
{
GTEST_LOG_(INFO) << "CanReadFromJson_test_001 start";
DistributedWant want;
nlohmann::json wantJson;
wantJson["deviceId"] = "device1";
wantJson["bundleName"] = "bundle1";
wantJson["abilityName"] = "ability1";
wantJson["uri"] = "uri1";
wantJson["type"] = "type1";
wantJson["flags"] = 1;
wantJson["action"] = "action1";
wantJson["parameters"] = "parameters1";
bool result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
wantJson["deviceId"] = 1;
wantJson["entities"] = "entities1";
result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
wantJson["deviceId"] = "device1";
wantJson["bundleName"] = 1;
result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
GTEST_LOG_(INFO) << "CanReadFromJson_test_001 end";
}
/**
* @tc.number: CanReadFromJson_test_002
* @tc.name: CanReadFromJson
* @tc.desc: Test CanReadFromJson.
*/
HWTEST_F(DistributedWantBaseTest, CanReadFromJson_test_002, TestSize.Level3)
{
GTEST_LOG_(INFO) << "CanReadFromJson_test_002 start";
DistributedWant want;
nlohmann::json wantJson;
wantJson["deviceId"] = "device1";
wantJson["bundleName"] = "bundle1";
wantJson["abilityName"] = 1;
wantJson["uri"] = "uri1";
wantJson["type"] = "type1";
wantJson["flags"] = 1;
wantJson["action"] = "action1";
wantJson["parameters"] = "parameters1";
wantJson["entities"] = "entities1";
bool result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
wantJson["abilityName"] = "ability1";
wantJson["uri"] = 1;
result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
wantJson["uri"] = "uri1";
wantJson["type"] = 1;
result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
GTEST_LOG_(INFO) << "CanReadFromJson_test_002 end";
}
/**
* @tc.number: CanReadFromJson_test_003
* @tc.name: CanReadFromJson
* @tc.desc: Test CanReadFromJson.
*/
HWTEST_F(DistributedWantBaseTest, CanReadFromJson_test_003, TestSize.Level3)
{
GTEST_LOG_(INFO) << "CanReadFromJson_test_003 start";
DistributedWant want;
nlohmann::json wantJson;
wantJson["deviceId"] = "device1";
wantJson["bundleName"] = "bundle1";
wantJson["abilityName"] = "ability1";
wantJson["uri"] = "uri1";
wantJson["type"] = "type1";
wantJson["flags"] = "flags1";
wantJson["action"] = "action1";
wantJson["parameters"] = "parameters1";
wantJson["entities"] = "entities1";
bool result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
wantJson["flags"] = 1;
wantJson["action"] = 1;
result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
wantJson["action"] = "action1";
wantJson["parameters"] = 1;
result = want.CanReadFromJson(wantJson);
EXPECT_EQ(result, false);
GTEST_LOG_(INFO) << "CanReadFromJson_test_003 end";
}
/**
* @tc.number: ReadFromJson_test_001
* @tc.name: ReadFromJson
* @tc.desc: Test ReadFromJson.
*/
HWTEST_F(DistributedWantBaseTest, ReadFromJson_test_001, TestSize.Level3)
{
GTEST_LOG_(INFO) << "ReadFromJson_test_001 start";
DistributedWant want;
nlohmann::json wantJson;
wantJson["deviceId"] = "device1";
wantJson["bundleName"] = "bundle1";
wantJson["abilityName"] = "ability1";
wantJson["uri"] = "uri1";
wantJson["type"] = "type1";
wantJson["flags"] = 1;
wantJson["action"] = "action1";
wantJson["parameters"] = "parameters1";
wantJson["entities"] = "entities1";
bool result = want.ReadFromJson(wantJson);
EXPECT_EQ(result, false);
GTEST_LOG_(INFO) << "ReadFromJson_test_001 end";
}
/**
* @tc.number: ReadFromJson_test_002
* @tc.name: ReadFromJson
* @tc.desc: Test ReadFromJson.
*/
HWTEST_F(DistributedWantBaseTest, ReadFromJson_test_002, TestSize.Level3)
{
GTEST_LOG_(INFO) << "ReadFromJson_test_002 start";
DistributedWant want;
std::string str = "";
EXPECT_EQ(want.FromString(str), nullptr);
GTEST_LOG_(INFO) << "ReadFromJson_test_002 end";
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -2292,5 +2292,83 @@ HWTEST_F(DistributedSchedStubTest, NotifyDSchedEventResultFromRemoteInner_001, T
EXPECT_NE(result, ERR_NULL_OBJECT);
DTEST_LOG << "DistributedSchedStubTest NotifyDSchedEventResultFromRemoteInner_001 end" << std::endl;
}
#ifdef DMSFWK_INTERACTIVE_ADAPTER
/**
* @tc.name: StartAbilityFromRemoteAdapterInner_001
* @tc.desc: check StartAbilityFromRemoteAdapterInner
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedStubTest, StartAbilityFromRemoteAdapterInner_001, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteAdapterInner_001 begin" << std::endl;
MessageParcel data;
MessageParcel reply;
int32_t result = DistributedSchedService::GetInstance().StartAbilityFromRemoteAdapterInner(data, reply);
EXPECT_NE(result, DMS_PERMISSION_DENIED);
DTEST_LOG << "DistributedSchedStubTest StartAbilityFromRemoteAdapterInner_001 end" << std::endl;
}
/**
* @tc.name: StopAbilityFromRemoteAdapterInner_001
* @tc.desc: check StopAbilityFromRemoteAdapterInner
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedStubTest, StopAbilityFromRemoteAdapterInner_001, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedStubTest StopAbilityFromRemoteAdapterInner_001 begin" << std::endl;
MessageParcel data;
MessageParcel reply;
int32_t result = DistributedSchedService::GetInstance().StopAbilityFromRemoteAdapterInner(data, reply);
EXPECT_NE(result, DMS_PERMISSION_DENIED);
DTEST_LOG << "DistributedSchedStubTest StopAbilityFromRemoteAdapterInner_001 end" << std::endl;
}
/**
* @tc.name: ConnectAbilityFromRemoteAdapterInner_001
* @tc.desc: check ConnectAbilityFromRemoteAdapterInner
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedStubTest, ConnectAbilityFromRemoteAdapterInner_001, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteAdapterInner_001 begin" << std::endl;
MessageParcel data;
MessageParcel reply;
int32_t result = DistributedSchedService::GetInstance().ConnectAbilityFromRemoteAdapterInner(data, reply);
EXPECT_NE(result, DMS_PERMISSION_DENIED);
DTEST_LOG << "DistributedSchedStubTest ConnectAbilityFromRemoteAdapterInner_001 end" << std::endl;
}
/**
* @tc.name: DisconnectAbilityFromRemoteAdapterInner_001
* @tc.desc: check DisconnectAbilityFromRemoteAdapterInner
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedStubTest, DisconnectAbilityFromRemoteAdapterInner_001, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedStubTest DisconnectAbilityFromRemoteAdapterInner_001 begin" << std::endl;
MessageParcel data;
MessageParcel reply;
int32_t result = DistributedSchedService::GetInstance().DisconnectAbilityFromRemoteAdapterInner(data, reply);
EXPECT_NE(result, DMS_PERMISSION_DENIED);
DTEST_LOG << "DistributedSchedStubTest DisconnectAbilityFromRemoteAdapterInner_001 end" << std::endl;
}
/**
* @tc.name: NotifyAbilityLifecycleChangedFromRemoteAdapterInner_001
* @tc.desc: check NotifyAbilityLifecycleChangedFromRemoteAdapterInner
* @tc.type: FUNC
*/
HWTEST_F(DistributedSchedStubTest, NotifyAbilityLifecycleChangedFromRemoteAdapterInner_001, TestSize.Level1)
{
DTEST_LOG << "DistributedSchedStubTest NotifyAbilityLifecycleChangedFromRemoteAdapterInner_001 begin" << std::endl;
MessageParcel data;
MessageParcel reply;
int32_t result = DistributedSchedService::GetInstance().NotifyAbilityLifecycleChangedFromRemoteAdapterInner(
data, reply);
EXPECT_NE(result, DMS_PERMISSION_DENIED);
DTEST_LOG << "DistributedSchedStubTest NotifyAbilityLifecycleChangedFromRemoteAdapterInner_001 end" << std::endl;
}
#endif
}
}

View File

@ -432,5 +432,34 @@ HWTEST_F(DMSNetworkAdapterTest, UpdateDeviceInfoStorage_001, TestSize.Level3)
bool result = DnetworkAdapter::GetInstance()->UpdateDeviceInfoStorage();
EXPECT_EQ(result, true);
}
/**
* @tc.name: OnDeviceTrustChange_001
* @tc.desc: test OnDeviceTrustChange
* @tc.type: FUNC
*/
HWTEST_F(DMSNetworkAdapterTest, OnDeviceTrustChange_001, TestSize.Level3)
{
std::string udid = "";
std::string uuid = "";
DnetworkAdapter::GetInstance()->Init();
DnetworkAdapter::GetInstance()->devTrustChangeCallback_->OnDeviceTrustChange(
udid, uuid, DistributedHardware::DmAuthForm::IDENTICAL_ACCOUNT);
udid = "udid";
DnetworkAdapter::GetInstance()->devTrustChangeCallback_->OnDeviceTrustChange(
udid, uuid, DistributedHardware::DmAuthForm::IDENTICAL_ACCOUNT);
udid = "";
uuid = "uuid";
DnetworkAdapter::GetInstance()->devTrustChangeCallback_->OnDeviceTrustChange(
udid, uuid, DistributedHardware::DmAuthForm::IDENTICAL_ACCOUNT);
udid = "udid";
uuid = "uuid";
DnetworkAdapter::GetInstance()->devTrustChangeCallback_->OnDeviceTrustChange(
udid, uuid, DistributedHardware::DmAuthForm::IDENTICAL_ACCOUNT);
EXPECT_EQ(udid.empty(), false);
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -15,10 +15,6 @@
#include "dms_continue_manager_test.h"
#ifdef DMSFWK_INTERACTIVE_ADAPTER
#include "broadcast.h"
#endif
#include "datetime_ex.h"
#include "distributed_sched_test_util.h"
#include "dtbschedmgr_log.h"
@ -32,13 +28,6 @@
using namespace testing;
using namespace testing::ext;
#ifdef DMSFWK_INTERACTIVE_ADAPTER
int32_t SendEvent(const char* pkgName, BroadCastAddr target, EventData *event)
{
return 1;
}
#endif
namespace OHOS {
namespace DistributedSchedule {
namespace {
@ -70,6 +59,7 @@ void DMSContinueManagerTest::TearDownTestCase()
void DMSContinueManagerTest::SetUp()
{
MultiUserManager::GetInstance().Init();
}
void DMSContinueManagerTest::TearDown()
@ -92,12 +82,8 @@ HWTEST_F(DMSContinueManagerTest, testUnInit001, TestSize.Level3)
DTEST_LOG << "DMSContinueManagerTest testUnInit001 begin" << std::endl;
DistributedSchedUtil::MockManageMissions();
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
EXPECT_NE(sendMgr->eventHandler_, nullptr);
@ -127,12 +113,8 @@ HWTEST_F(DMSContinueManagerTest, testUnInit002, TestSize.Level3)
DTEST_LOG << "DMSContinueManagerTest testUnInit002 begin" << std::endl;
DistributedSchedUtil::MockManageMissions();
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
EXPECT_NE(sendMgr->eventHandler_, nullptr);
@ -151,12 +133,8 @@ HWTEST_F(DMSContinueManagerTest, testPostUnfocusedTaskWithDelay001, TestSize.Lev
DTEST_LOG << "DMSContinueManagerTest testPostUnfocusedTaskWithDelay001 begin" << std::endl;
DistributedSchedUtil::MockManageMissions();
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
/**
@ -186,12 +164,8 @@ HWTEST_F(DMSContinueManagerTest, testNotifyMissionFocused001, TestSize.Level3)
DTEST_LOG << "DMSContinueManagerTest testNotifyMissionFocused001 begin" << std::endl;
DistributedSchedUtil::MockManageMissions();
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
/**
@ -221,12 +195,8 @@ HWTEST_F(DMSContinueManagerTest, testNotifyMissionUnfocused001, TestSize.Level3)
DTEST_LOG << "DMSContinueManagerTest testNotifyMissionUnfocused001 begin" << std::endl;
DistributedSchedUtil::MockManageMissions();
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
/**
* @tc.steps: step1. test NotifyMissionUnfocused when eventHandler is not nullptr;
@ -252,10 +222,7 @@ HWTEST_F(DMSContinueManagerTest, testRegisterOnListener001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testRegisterOnListener001 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->Init();
sptr<IRemoteObject> obj01(new RemoteOnListenerStubTest());
int32_t ret = recvMgr->RegisterOnListener(TYPE, obj01);
@ -281,10 +248,7 @@ HWTEST_F(DMSContinueManagerTest, testRegisterOffListener001, TestSize.Level1)
DTEST_LOG << "DMSContinueManagerTest testRegisterOffListener001 start" << std::endl;
sptr<IRemoteObject> obj01(new RemoteOnListenerStubTest());
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
int32_t ret = recvMgr->RegisterOnListener(TYPE, obj01);
ret = recvMgr->RegisterOffListener(TYPE, obj01);
EXPECT_EQ(ret, ERR_OK);
@ -305,10 +269,7 @@ HWTEST_F(DMSContinueManagerTest, testRegisterOffListener002, TestSize.Level3)
DTEST_LOG << "DMSContinueManagerTest testRegisterOffListener002 start" << std::endl;
sptr<IRemoteObject> obj01(new RemoteOnListenerStubTest());
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
int32_t ret = recvMgr->RegisterOnListener(TYPE, obj01);
EXPECT_EQ(ret, ERR_OK);
@ -330,10 +291,7 @@ HWTEST_F(DMSContinueManagerTest, testGetMissionId001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testGetMissionId001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->focusedMission_[BUNDLENAME_01] = MISSIONID_01;
int32_t missionId;
int32_t ret = sendMgr->GetMissionIdByBundleName(BUNDLENAME_01, missionId);
@ -359,10 +317,7 @@ HWTEST_F(DMSContinueManagerTest, testDealFocusedBusiness001, TestSize.Level3)
* @tc.steps: step1. test DealFocusedBusiness when missionId is invalid;
*/
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
int32_t ret = sendMgr->DealFocusedBusiness(-1, FocusedReason::MIN);
EXPECT_NE(ret, ERR_OK);
@ -383,10 +338,7 @@ HWTEST_F(DMSContinueManagerTest, testDealUnfocusedBusiness001, TestSize.Level3)
* @tc.steps: step1. test DealUnfocusedBusiness when missionId is invalid;
*/
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
int32_t ret = sendMgr->DealUnfocusedBusiness(-1, UnfocusedReason::NORMAL);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -403,10 +355,7 @@ HWTEST_F(DMSContinueManagerTest, testDealUnfocusedBusiness001, TestSize.Level3)
*/
sptr<IRemoteObject> obj01 = nullptr;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->NotifyDied(obj01);
/**
@ -438,10 +387,7 @@ HWTEST_F(DMSContinueManagerTest, testVerifyBroadcastSource001, TestSize.Level3)
std::string sinkBundleName = "test sinkBundleName";
std::string continueType = "test continueType";
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
int32_t ret = recvMgr->VerifyBroadcastSource(networkId,
sourceBundleName, sinkBundleName, continueType, state);
EXPECT_EQ(ret, ERR_OK);
@ -466,10 +412,7 @@ HWTEST_F(DMSContinueManagerTest, testVerifyBroadcastSource002, TestSize.Level3)
std::string sinkBundleName = "test sinkBundleName";
std::string continueType = "test continueType";
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
int32_t ret = recvMgr->VerifyBroadcastSource(networkId, sourceBundleName, sinkBundleName, continueType, state);
EXPECT_EQ(ret, ERR_OK);
@ -494,10 +437,7 @@ HWTEST_F(DMSContinueManagerTest, testVerifyBroadcastSource003, TestSize.Level3)
std::string sinkBundleName = "test sinkBundleName";
std::string continueType = "test continueType";
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
int32_t ret = recvMgr->VerifyBroadcastSource(networkId, sourceBundleName, sinkBundleName, continueType, state);
EXPECT_EQ(ret, ERR_OK);
@ -527,10 +467,7 @@ HWTEST_F(DMSContinueManagerTest, testDealOnBroadcastBusiness001, TestSize.Level3
int32_t state = 0;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->PostOnBroadcastBusiness(senderNetworkId, bundleNameId, continueTypeId, state);
int32_t ret = recvMgr->DealOnBroadcastBusiness(senderNetworkId, bundleNameId, continueTypeId, state, 0);
@ -569,10 +506,7 @@ HWTEST_F(DMSContinueManagerTest, testGetBundleName001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testGetBundleName001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->focusedMission_[BUNDLENAME_01] = MISSIONID_01;
std::string bundleName;
int32_t ret = sendMgr->GetBundleNameByMissionId(MISSIONID_01, bundleName);
@ -593,10 +527,7 @@ HWTEST_F(DMSContinueManagerTest, testIsContinue001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testIsContinue001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->focusedMission_[BUNDLENAME_02] = MISSIONID_02;
sendMgr->info_.currentMissionId = MISSIONID_01;
sendMgr->info_.currentIsContinuable = true;
@ -622,10 +553,7 @@ HWTEST_F(DMSContinueManagerTest, testNotifyDied001, TestSize.Level1)
DTEST_LOG << "DMSContinueManagerTest testNotifyDied001 start" << std::endl;
sptr<IRemoteObject> obj01(new RemoteOnListenerStubTest());
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
int32_t ret = recvMgr->RegisterOnListener(TYPE, obj01);
EXPECT_EQ(false, recvMgr->registerOnListener_.empty());
recvMgr->NotifyDied(obj01);
@ -641,12 +569,8 @@ HWTEST_F(DMSContinueManagerTest, testSetMissionContinueState001, TestSize.Level3
{
DTEST_LOG << "DMSContinueManagerTest testSetMissionContinueState001 start" << std::endl;
DistributedSchedUtil::MockManageMissions();
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
OHOS::AAFwk::ContinueState state = OHOS::AAFwk::ContinueState::CONTINUESTATE_ACTIVE;
@ -674,12 +598,8 @@ HWTEST_F(DMSContinueManagerTest, testSetMissionContinueState002, TestSize.Level3
{
DTEST_LOG << "DMSContinueManagerTest testSetMissionContinueState002 start" << std::endl;
DistributedSchedUtil::MockManageMissions();
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
OHOS::AAFwk::ContinueState state = OHOS::AAFwk::ContinueState::CONTINUESTATE_INACTIVE;
@ -708,10 +628,7 @@ HWTEST_F(DMSContinueManagerTest, testDealSetMissionContinueStateBusiness001, Tes
DTEST_LOG << "DMSContinueManagerTest testDealSetMissionContinueStateBusiness001 start" << std::endl;
OHOS::AAFwk::ContinueState state = OHOS::AAFwk::ContinueState::CONTINUESTATE_ACTIVE;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->info_.currentMissionId = MISSIONID_01;
/**
@ -739,10 +656,7 @@ HWTEST_F(DMSContinueManagerTest, testDealSetMissionContinueStateBusiness002, Tes
{
DTEST_LOG << "DMSContinueManagerTest testDealSetMissionContinueStateBusiness002 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->info_.currentIsContinuable = true;
OHOS::AAFwk::ContinueState state = OHOS::AAFwk::ContinueState::CONTINUESTATE_ACTIVE;
int32_t ret = sendMgr->DealSetMissionContinueStateBusiness(MISSIONID_01, state);
@ -764,12 +678,8 @@ HWTEST_F(DMSContinueManagerTest, testOnDeviceScreenOff001, TestSize.Level1)
/**
* @tc.steps: step1. test OnDeviceScreenOff when eventHandler is not nullptr;
*/
MultiUserManager::GetInstance().Init();
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->Init();
sendMgr->OnDeviceScreenOff();
EXPECT_NE(sendMgr->eventHandler_, nullptr);
@ -793,10 +703,7 @@ HWTEST_F(DMSContinueManagerTest, testNotifyDeviceOffline001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOffline001 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->iconInfo_.senderNetworkId = NETWORKID_01;
recvMgr->NotifyDeviceOffline(NETWORKID_01);
@ -815,10 +722,7 @@ HWTEST_F(DMSContinueManagerTest, testNotifyDeviceOffline002, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOffline002 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->iconInfo_.senderNetworkId = NETWORKID_01;
recvMgr->NotifyDeviceOffline("");
EXPECT_EQ(recvMgr->iconInfo_.senderNetworkId, NETWORKID_01);
@ -835,10 +739,7 @@ HWTEST_F(DMSContinueManagerTest, testNotifyDeviceOffline003, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOffline003 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->iconInfo_.senderNetworkId = NETWORKID_01;
recvMgr->NotifyDeviceOffline(NETWORKID_02);
EXPECT_EQ(recvMgr->iconInfo_.senderNetworkId, NETWORKID_01);
@ -856,10 +757,7 @@ HWTEST_F(DMSContinueManagerTest, notifyPackageRemoved001, TestSize.Level1)
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved001 start" << std::endl;
sptr<IRemoteObject> obj01(new RemoteOnListenerStubTest());
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->RegisterOnListener(TYPE, obj01);
EXPECT_NE(recvMgr->registerOnListener_.size(), 0);
@ -879,10 +777,7 @@ HWTEST_F(DMSContinueManagerTest, notifyPackageRemoved002, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved002 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->iconInfo_.bundleName = BUNDLENAME_01;
recvMgr->NotifyPackageRemoved("");
EXPECT_EQ(recvMgr->iconInfo_.bundleName, BUNDLENAME_01);
@ -899,10 +794,7 @@ HWTEST_F(DMSContinueManagerTest, notifyPackageRemoved003, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest notifyPackageRemoved003 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->iconInfo_.bundleName = BUNDLENAME_01;
recvMgr->NotifyPackageRemoved(BUNDLENAME_02);
EXPECT_EQ(recvMgr->iconInfo_.bundleName, BUNDLENAME_01);
@ -922,10 +814,7 @@ HWTEST_F(DMSContinueManagerTest, testNotifyDataRecv001, TestSize.Level1)
uint8_t payload[] = {0xf0};
uint32_t dataLen1 = DMS_SEND_LEN - 1;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->NotifyDataRecv(senderNetworkId, payload, dataLen1);
uint32_t dataLen2 = DMS_SEND_LEN;
@ -946,10 +835,7 @@ HWTEST_F(DMSContinueManagerTest, testSendSoftbusEvent001, TestSize.Level1)
uint8_t continueType = 1;
uint8_t type = 0;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
bool ret = sendMgr->SendSoftbusEvent(bundleNameId, continueType, type);
EXPECT_NE(ret, CAN_NOT_FOUND_ABILITY_ERR);
DTEST_LOG << "DMSContinueManagerTest testSendSoftbusEvent001 end" << std::endl;
@ -964,10 +850,7 @@ HWTEST_F(DMSContinueManagerTest, testNotifyDeviceOnline001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOnline001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
int32_t ret = sendMgr->NotifyDeviceOnline();
EXPECT_EQ(ret, ERR_OK);
DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOnline001 end" << std::endl;
@ -982,10 +865,7 @@ HWTEST_F(DMSContinueManagerTest, testGetAbilityNameByMissionId_001, TestSize.Lev
{
DTEST_LOG << "DMSContinueManagerTest testGetAbilityNameByMissionId_001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->focusedMissionAbility_[MISSIONID_01] = ABILITY_NAME_01;
std::string abilityName;
int32_t ret = sendMgr->GetAbilityNameByMissionId(MISSIONID_01, abilityName);
@ -1003,10 +883,7 @@ HWTEST_F(DMSContinueManagerTest, testFocusedBusinessSendEvent_001, TestSize.Leve
{
DTEST_LOG << "DMSContinueManagerTest testFocusedBusinessSendEvent_001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
int32_t ret = sendMgr->FocusedBusinessSendEvent(BUNDLENAME_01, ABILITY_NAME_01);
EXPECT_EQ(ret, CAN_NOT_FOUND_ABILITY_ERR);
@ -1022,10 +899,7 @@ HWTEST_F(DMSContinueManagerTest, testGetBundleNameIdAndContinueTypeId_001, TestS
{
DTEST_LOG << "DMSContinueManagerTest testGetBundleNameIdAndContinueTypeId_001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->focusedMission_[BUNDLENAME_01] = MISSIONID_01;
sendMgr->focusedMissionAbility_[MISSIONID_01] = ABILITY_NAME_01;
uint16_t bundleNameId = 0;
@ -1051,10 +925,7 @@ HWTEST_F(DMSContinueManagerTest, testGetContinueType_001, TestSize.Level1)
std::string sinkBundleName = "test sinkBundleName";
std::string continueType = "test continueType";
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
int32_t ret = recvMgr->VerifyBroadcastSource(networkId, sourceBundleName, sinkBundleName, continueType, state);
EXPECT_EQ(ret, ERR_OK);
@ -1075,10 +946,7 @@ HWTEST_F(DMSContinueManagerTest, testSetScreenOffInfo_001, TestSize.Level1)
uint16_t bundleNameId = 0;
std::string abilityName = "abilityName";
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->screenOffHandler_ =
std::make_shared<DMSContinueSendMgr::ScreenOffHandler>();
sendMgr->screenOffHandler_->SetScreenOffInfo(missionId, bundleName,
@ -1099,10 +967,7 @@ HWTEST_F(DMSContinueManagerTest, testSetStateSendEvent_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest testSetStateSendEvent_001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
int32_t ret = sendMgr->SetStateSendEvent(0, 0, AAFwk::ContinueState::CONTINUESTATE_INACTIVE);
EXPECT_NE(ret, DMS_PERMISSION_DENIED);
@ -1121,10 +986,7 @@ HWTEST_F(DMSContinueManagerTest, testGetContinueLaunchMissionInfo_001, TestSize.
DTEST_LOG << "DMSContinueManagerTest testGetContinueLaunchMissionInfo_001 start" << std::endl;
ContinueLaunchMissionInfo missionInfo = {"com.test.missionInfo", "MainAbility"};
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->continueLaunchMission_.clear();
int32_t ret = sendMgr->GetContinueLaunchMissionInfo(MISSIONID_01, missionInfo);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -1151,10 +1013,7 @@ HWTEST_F(DMSContinueManagerTest, testUpdateContinueLaunchMission_001, TestSize.L
info.id = MISSIONID_01;
info.want = want;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
EXPECT_FALSE(sendMgr->UpdateContinueLaunchMission(info));
info.want.SetFlags(AAFwk::Want::FLAG_ABILITY_CONTINUATION);
@ -1178,10 +1037,7 @@ HWTEST_F(DMSContinueManagerTest, testGetFinalBundleName_001, TestSize.Level1)
AppExecFwk::BundleInfo localBundleInfo;
std::string continueType;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
bool ret = recvMgr->GetFinalBundleName(info, finalBundleName, localBundleInfo, continueType);
EXPECT_EQ(ret, false);
DTEST_LOG << "DMSContinueManagerTest testGetFinalBundleName_001 end" << std::endl;
@ -1211,10 +1067,7 @@ HWTEST_F(DMSContinueManagerTest, testIsBundleContinuable_001, TestSize.Level1)
localBundleInfo.abilityInfos = abilityInfos;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
bool ret = recvMgr->IsBundleContinuable(localBundleInfo, srcAbilityName,
srcContinueType, isSameBundle);
EXPECT_EQ(ret, false);
@ -1250,10 +1103,7 @@ HWTEST_F(DMSContinueManagerTest, testIsBundleContinuable_002, TestSize.Level1)
localBundleInfo.abilityInfos = abilityInfos;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
bool ret = recvMgr->IsBundleContinuable(localBundleInfo, srcAbilityName,
srcContinueType, isSameBundle);
EXPECT_EQ(ret, true);
@ -1291,10 +1141,7 @@ HWTEST_F(DMSContinueManagerTest, testIsBundleContinuable_003, TestSize.Level1)
localBundleInfo.abilityInfos = abilityInfos;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
bool ret = recvMgr->IsBundleContinuable(localBundleInfo, srcAbilityName,
srcContinueType, isSameBundle);
EXPECT_EQ(ret, false);
@ -1327,10 +1174,7 @@ HWTEST_F(DMSContinueManagerTest, testIsBundleContinuable_004, TestSize.Level1)
localBundleInfo.abilityInfos = abilityInfos;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
bool ret = recvMgr->IsBundleContinuable(localBundleInfo, srcAbilityName,
srcContinueType, isSameBundle);
EXPECT_EQ(ret, false);
@ -1363,10 +1207,7 @@ HWTEST_F(DMSContinueManagerTest, testIsBundleContinuable_005, TestSize.Level1)
localBundleInfo.abilityInfos = abilityInfos;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
bool ret = recvMgr->IsBundleContinuable(localBundleInfo, srcAbilityName,
srcContinueType, isSameBundle);
EXPECT_EQ(ret, true);
@ -1382,10 +1223,7 @@ HWTEST_F(DMSContinueManagerTest, GetBundleNameByScreenOffInfo_001, TestSize.Leve
{
DTEST_LOG << "DMSContinueManagerTest GetBundleNameByScreenOffInfo_001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->screenOffHandler_ = nullptr;
int32_t missionId = 0;
std::string bundleName;
@ -1415,10 +1253,7 @@ HWTEST_F(DMSContinueManagerTest, SendScreenOffEvent_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest SendScreenOffEvent_001 start" << std::endl;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->screenOffHandler_ = nullptr;
int32_t ret = sendMgr->SendScreenOffEvent(DMS_FOCUSED_TYPE);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
@ -1439,10 +1274,7 @@ HWTEST_F(DMSContinueManagerTest, DeleteContinueLaunchMissionInfo_001, TestSize.L
DTEST_LOG << "DMSContinueManagerTest DeleteContinueLaunchMissionInfo_001 start" << std::endl;
int32_t missionId = 0;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
sendMgr->continueLaunchMission_.clear();
sendMgr->DeleteContinueLaunchMissionInfo(missionId);
@ -1463,10 +1295,7 @@ HWTEST_F(DMSContinueManagerTest, CheckContinueState_001, TestSize.Level1)
DTEST_LOG << "DMSContinueManagerTest CheckContinueState_001 start" << std::endl;
int32_t missionId = 0;
auto sendMgr = MultiUserManager::GetInstance().GetCurrentSendMgr();
if (sendMgr == nullptr) {
DTEST_LOG << "GetSendMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, sendMgr);
int32_t ret = sendMgr->CheckContinueState(missionId);
EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);
DTEST_LOG << "DMSContinueManagerTest CheckContinueState_001 end" << std::endl;
@ -1481,10 +1310,7 @@ HWTEST_F(DMSContinueManagerTest, OnContinueSwitchOff_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest OnContinueSwitchOff_001 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->iconInfo_.senderNetworkId = "";
recvMgr->iconInfo_.bundleName = "";
recvMgr->iconInfo_.continueType = "";
@ -1509,10 +1335,7 @@ HWTEST_F(DMSContinueManagerTest, OnUserSwitch_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest OnUserSwitch_001 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
recvMgr->iconInfo_.senderNetworkId = "";
recvMgr->iconInfo_.bundleName = "";
recvMgr->iconInfo_.continueType = "";
@ -1537,10 +1360,7 @@ HWTEST_F(DMSContinueManagerTest, FindToNotifyRecvBroadcast_001, TestSize.Level1)
{
DTEST_LOG << "DMSContinueManagerTest FindToNotifyRecvBroadcast_001 start" << std::endl;
auto recvMgr = MultiUserManager::GetInstance().GetCurrentRecvMgr();
if (recvMgr == nullptr) {
DTEST_LOG << "GetRecvMgr failed." << std::endl;
return;
}
ASSERT_NE(nullptr, recvMgr);
std::string senderNetworkId = "senderNetworkId";
std::string bundleName = "bundleName";
std::string continueType = "senderNetworkId";

View File

@ -253,34 +253,6 @@ HWTEST_F(MultiUserManagerTest, MultiUserManager_GetCurrentRecvMgr_001, TestSize.
DTEST_LOG << "MultiUserManager_GetCurrentRecvMgr_001 end" << std::endl;
}
/**
* @tc.name: MultiUserManager_GetCurrentRecvMgr_002
* @tc.desc: test GetCurrentRecvMgr
* @tc.type: FUNC
*/
HWTEST_F(MultiUserManagerTest, MultiUserManager_GetCurrentRecvMgr_002, TestSize.Level3)
{
DTEST_LOG << "MultiUserManager_GetCurrentRecvMgr_002 start" << std::endl;
/**
* @tc.steps: step1. test OnUserRemoved with create current user recvMgr;
*/
int32_t accountId = 100;
MultiUserManager::GetInstance().Init();
auto recvMgr = MultiUserManager::GetInstance().recvMgrMap_.find(accountId)->second;
MultiUserManager::GetInstance().hasRegSoftbusEventListener_ = false;
auto ret = MultiUserManager::GetInstance().GetCurrentRecvMgr();
EXPECT_EQ(ret, recvMgr);
EXPECT_TRUE(MultiUserManager::GetInstance().hasRegSoftbusEventListener_);
MultiUserManager::GetInstance().recvMgrMap_.insert({accountId, nullptr});
ret = MultiUserManager::GetInstance().GetCurrentRecvMgr();
EXPECT_NE(ret, nullptr);
MultiUserManager::GetInstance().UnInit();
DTEST_LOG << "MultiUserManager_GetCurrentRecvMgr_002 end" << std::endl;
}
/**
* @tc.name: MultiUserManager_CheckRegSoftbusListener_001
* @tc.desc: test CheckRegSoftbusListener

View File

@ -465,12 +465,10 @@ HWTEST_F(DSchedSoftbusSessionTest, GetFragDataHeader_001, TestSize.Level3)
HWTEST_F(DSchedSoftbusSessionTest, PackRecvData_001, TestSize.Level3)
{
DTEST_LOG << "DSchedSoftbusSessionTest PackRecvData_001 begin" << std::endl;
int32_t sessionId = 0;
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(DSCHED_BUFFER_SIZE_100);
softbusSessionTest_ = std::make_shared<DSchedSoftbusSession>();
ASSERT_NE(softbusSessionTest_, nullptr);
softbusSessionTest_->PackRecvData(buffer);
EXPECT_EQ(0, sessionId);
EXPECT_NO_FATAL_FAILURE(softbusSessionTest_->PackRecvData(buffer));
DTEST_LOG << "DSchedSoftbusSessionTest PackRecvData_001 end" << std::endl;
}
@ -483,7 +481,6 @@ HWTEST_F(DSchedSoftbusSessionTest, PackRecvData_001, TestSize.Level3)
HWTEST_F(DSchedSoftbusSessionTest, AssembleNoFrag_001, TestSize.Level3)
{
DTEST_LOG << "DSchedSoftbusSessionTest AssembleFrag_001 begin" << std::endl;
int32_t sessionId = 0;
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(SIZE_1);
DSchedSoftbusSession::SessionDataHeader headerPara = {0, 0, 0, SEQ_1, 0, SEQ_2, TOTALLEN_1};
softbusSessionTest_ = std::make_shared<DSchedSoftbusSession>();
@ -491,8 +488,7 @@ HWTEST_F(DSchedSoftbusSessionTest, AssembleNoFrag_001, TestSize.Level3)
softbusSessionTest_->AssembleNoFrag(buffer, headerPara);
headerPara.totalLen = TOTALLEN_1;
softbusSessionTest_->AssembleNoFrag(buffer, headerPara);
EXPECT_EQ(0, sessionId);
EXPECT_NO_FATAL_FAILURE(softbusSessionTest_->AssembleNoFrag(buffer, headerPara));
DTEST_LOG << "DSchedSoftbusSessionTest AssembleNoFrag_001 end" << std::endl;
}
@ -504,7 +500,6 @@ HWTEST_F(DSchedSoftbusSessionTest, AssembleNoFrag_001, TestSize.Level3)
HWTEST_F(DSchedSoftbusSessionTest, AssembleFrag_001, TestSize.Level3)
{
DTEST_LOG << "DSchedSoftbusSessionTest AssembleFrag_001 begin" << std::endl;
int32_t sessionId = 0;
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(SIZE_1);
DSchedSoftbusSession::SessionDataHeader headerPara =
{0, DSchedSoftbusSession::FRAG_START, 0, SEQ_1, 0, SEQ_2, TOTALLEN_1};
@ -514,8 +509,7 @@ HWTEST_F(DSchedSoftbusSessionTest, AssembleFrag_001, TestSize.Level3)
headerPara.fragFlag = DSchedSoftbusSession::FRAG_MID;
softbusSessionTest_->AssembleFrag(buffer, headerPara);
headerPara.fragFlag = DSchedSoftbusSession::FRAG_END;
softbusSessionTest_->AssembleFrag(buffer, headerPara);
EXPECT_EQ(0, sessionId);
EXPECT_NO_FATAL_FAILURE(softbusSessionTest_->AssembleFrag(buffer, headerPara));
DTEST_LOG << "DSchedSoftbusSessionTest AssembleFrag_001 end" << std::endl;
}
@ -527,7 +521,6 @@ HWTEST_F(DSchedSoftbusSessionTest, AssembleFrag_001, TestSize.Level3)
HWTEST_F(DSchedSoftbusSessionTest, SetHeadParaDataLen_001, TestSize.Level3)
{
DTEST_LOG << "DSchedSoftbusSessionTest SetHeadParaDataLen_001 begin" << std::endl;
int32_t sessionId = 0;
DSchedSoftbusSession::SessionDataHeader headerPara = {0, 0, 0, SEQ_1, 0, SEQ_2, TOTALLEN_1};
uint32_t totalLen = TOTALLEN;
uint32_t offset = OFFSET_1;
@ -537,8 +530,7 @@ HWTEST_F(DSchedSoftbusSessionTest, SetHeadParaDataLen_001, TestSize.Level3)
softbusSessionTest_->SetHeadParaDataLen(headerPara, totalLen, offset, maxSendSize);
offset = DSCHED_BUFFER_SIZE_100;
softbusSessionTest_->SetHeadParaDataLen(headerPara, totalLen, offset, maxSendSize);
softbusSessionTest_->GetNowTimeStampUs();
EXPECT_EQ(0, sessionId);
EXPECT_NO_FATAL_FAILURE(softbusSessionTest_->GetNowTimeStampUs());
DTEST_LOG << "DSchedSoftbusSessionTest SetHeadParaDataLen_001 end" << std::endl;
}
@ -550,7 +542,6 @@ HWTEST_F(DSchedSoftbusSessionTest, SetHeadParaDataLen_001, TestSize.Level3)
HWTEST_F(DSchedSoftbusSessionTest, MakeFragDataHeader_001, TestSize.Level3)
{
DTEST_LOG << "DSchedSoftbusSessionTest MakeFragDataHeader_001 begin" << std::endl;
int32_t sessionId = 0;
DSchedSoftbusSession::SessionDataHeader headerPara = {0};
uint8_t *header = new uint8_t[DSCHED_BUFFER_SIZE_100] {0};
uint32_t len = HEADERLEN;
@ -558,8 +549,7 @@ HWTEST_F(DSchedSoftbusSessionTest, MakeFragDataHeader_001, TestSize.Level3)
ASSERT_NE(softbusSessionTest_, nullptr);
softbusSessionTest_->MakeFragDataHeader(headerPara, header, len);
uint8_t *header1 = new uint8_t[HEADERLEN] {0};
softbusSessionTest_->MakeFragDataHeader(headerPara, header1, len);
EXPECT_EQ(0, sessionId);
EXPECT_NO_FATAL_FAILURE(softbusSessionTest_->MakeFragDataHeader(headerPara, header1, len));
delete[] header;
delete[] header1;
DTEST_LOG << "DSchedSoftbusSessionTest MakeFragDataHeader_001 end" << std::endl;
@ -573,7 +563,6 @@ HWTEST_F(DSchedSoftbusSessionTest, MakeFragDataHeader_001, TestSize.Level3)
HWTEST_F(DSchedSoftbusSessionTest, WriteTlvToBuffer_001, TestSize.Level3)
{
DTEST_LOG << "DSchedSoftbusSessionTest WriteTlvToBuffer_001 begin" << std::endl;
int32_t sessionId = 0;
DSchedSoftbusSession::TlvItem tlvItem = {SIZE_4, SIZE_4, SEQ_2};
uint8_t *buffer = new uint8_t[SIZE_50] {0};
uint32_t bufLen = SIZE_50;
@ -582,8 +571,7 @@ HWTEST_F(DSchedSoftbusSessionTest, WriteTlvToBuffer_001, TestSize.Level3)
softbusSessionTest_->WriteTlvToBuffer(tlvItem, buffer, bufLen);
uint8_t * buffer1 = new uint8_t[SEQ_1] {0};
uint32_t bufLen1 = SIZE_1;
softbusSessionTest_->WriteTlvToBuffer(tlvItem, buffer1, bufLen1);
EXPECT_EQ(0, sessionId);
EXPECT_NO_FATAL_FAILURE(softbusSessionTest_->WriteTlvToBuffer(tlvItem, buffer1, bufLen1));
delete[] buffer;
delete[] buffer1;
DTEST_LOG << "DSchedSoftbusSessionTest WriteTlvToBuffer_001 end" << std::endl;