测试用例codecheck修复

Signed-off-by: du-zhihai <duzhihai@huawei.com>
Change-Id: Ibd66961fcb86d9c8b3b76ee7a2cd6d7ec1b56b23
This commit is contained in:
du-zhihai 2022-11-23 11:32:53 +08:00
parent 30df3f9580
commit fe0f2178d8
5 changed files with 50 additions and 20 deletions

View File

@ -333,7 +333,7 @@ HWTEST_F(DMSNetworkAdapterTest, AddDeviceChangeListener_006, TestSize.Level3)
DnetworkAdapter::GetInstance()->stateCallback_ = nullptr;
bool res = DnetworkAdapter::GetInstance()->AddDeviceChangeListener(deviceNodeListener);
EXPECT_EQ(res, true);
DnetworkAdapter::GetInstance()->stateCallback_ =
DnetworkAdapter::GetInstance()->stateCallback_ =
std::make_shared<DnetworkAdapter::DmsDeviceStateCallback>();
}

View File

@ -1736,7 +1736,6 @@ HWTEST_F(ContinuationManagerTest, OnRemoteRequest_005, TestSize.Level3)
DeviceSelectionNotifierTest deviceSelectionNotifierTest;
int32_t result = deviceSelectionNotifierTest.OnRemoteRequest(IDeviceSelectionNotifier::EVENT_DEVICE_DISCONNECT,
data, reply, option);
EXPECT_EQ(ERR_OK, result);
}

View File

@ -136,6 +136,7 @@ ohos_unittest("distributedschedsvrtest") {
"unittest/dms_callback_task_test.cpp",
"unittest/dms_token_callback_test.cpp",
"unittest/mock_distributed_sched.cpp",
"unittest/mock_remote_stub.cpp",
]
sources += dtbschedmgr_sources
configs = [
@ -177,7 +178,10 @@ ohos_unittest("distributedcalltest") {
ohos_unittest("dmsfreeinstallcbtest") {
module_out_path = module_output_path
sources = [ "unittest/dms_free_install_callback_test.cpp" ]
sources = [
"unittest/dms_free_install_callback_test.cpp",
"unittest/mock_remote_stub.cpp",
]
sources += dtbschedmgr_sources
configs = [
":test_config",
@ -199,6 +203,7 @@ ohos_unittest("dschedcontinuetest") {
"unittest/distributed_sched_continuation_test.cpp",
"unittest/dms_version_manager_test.cpp",
"unittest/mock_distributed_sched.cpp",
"unittest/mock_remote_stub.cpp",
]
sources += dtbschedmgr_sources
configs = [
@ -229,6 +234,7 @@ ohos_unittest("dschedconnecttest") {
sources = [
"unittest/app_connection_stub_test.cpp",
"unittest/distributed_sched_connect_test.cpp",
"unittest/mock_remote_stub.cpp",
]
sources += dtbschedmgr_sources
configs = [
@ -273,6 +279,7 @@ ohos_unittest("dschedmissionmanagertest") {
"unittest/mission/dms_mission_manager_test.cpp",
"unittest/mission/mission_info_converter_test.cpp",
"unittest/mission/snapshot_test.cpp",
"unittest/mock_remote_stub.cpp",
]
sources += dtbschedmgr_sources
configs = [

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2021-2022 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 "mock_remote_stub.h"
namespace OHOS {
namespace DistributedSchedule {
namespace {
constexpr int32_t CODE_NOTIFY_MISSION = 0;
constexpr int32_t NOTIFY_SNAP_SHOT = 1;
constexpr int32_t NOTIFY_NET_DISCONNECT = 2;
const std::string MOCK_DEVICEID_TO_RETURN_FALSE = "deviceId to return false";
}
int32_t MockRemoteStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
MessageOption& option)
{
if (code == CODE_NOTIFY_MISSION || code == NOTIFY_SNAP_SHOT || code == NOTIFY_NET_DISCONNECT) {
data.ReadInterfaceToken();
std::string deviceId = data.ReadString();
if (deviceId == MOCK_DEVICEID_TO_RETURN_FALSE) {
return -1;
}
}
return 0;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -21,12 +21,6 @@
namespace OHOS {
namespace DistributedSchedule {
namespace {
constexpr int32_t CODE_NOTIFY_MISSION = 0;
constexpr int32_t NOTIFY_SNAP_SHOT = 1;
constexpr int32_t NOTIFY_NET_DISCONNECT = 2;
const std::string MOCK_DEVICEID_TO_RETURN_FALSE = "deviceId to return false";
}
class MockRemoteInterface : public OHOS::IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.test.mock");
@ -36,17 +30,7 @@ class MockRemoteStub : public IRemoteStub<MockRemoteInterface> {
public:
~MockRemoteStub() = default;
virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
MessageOption& option) override
{
if (code == CODE_NOTIFY_MISSION || code == NOTIFY_SNAP_SHOT || code == NOTIFY_NET_DISCONNECT) {
data.ReadInterfaceToken();
std::string deviceId = data.ReadString();
if (deviceId == MOCK_DEVICEID_TO_RETURN_FALSE) {
return -1;
}
}
return 0;
}
MessageOption& option) override;
};
}
}