mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
commit
fff6d2033f
@ -809,15 +809,15 @@ std::string JsContinuationManager::ErrorMessageReturn(int32_t code)
|
||||
case PARAMETER_CHECK_FAILED:
|
||||
return "The parameter check failed.";
|
||||
case SYSTEM_WORK_ABNORMALLY:
|
||||
return "The system ability work abnormally.";
|
||||
return "The system ability works abnormally.";
|
||||
case CALLBACK_TOKEN_UNREGISTERED:
|
||||
return "The specified token or callback has not registered.";
|
||||
return "The specified token or callback is not registered.";
|
||||
case OVER_MAX_REGISTERED_TIMES:
|
||||
return "The number of token registration times has reached the upper limit.";
|
||||
case REPEATED_REGISTRATION:
|
||||
return "The specified callback has been registered.";
|
||||
default:
|
||||
return "The system ability work abnormally.";
|
||||
return "The system ability works abnormally.";
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "distributed_ability_manager_client.h"
|
||||
#include "distributed_sched_util.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "mock_remote_stub.h"
|
||||
#include "test_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -56,6 +57,7 @@ const std::string TEST_FILTER = "test filter";
|
||||
const std::string TEST_AUTHINFO = "test authInfo";
|
||||
const std::u16string TEST_INPUT1 = u"test input1";
|
||||
const std::u16string TEST_INPUT2 = u"test input2";
|
||||
const std::u16string TEST_INVALID_REMOTEDESCRIPTOR = u"invalid remoteDescriptor";
|
||||
const std::string TEST_INPUT3 = "test input1";
|
||||
const std::string TEST_INPUT4 = "test input2";
|
||||
const std::uint32_t INVALID_EVENT_DEVICE_CODE = 0;
|
||||
@ -87,6 +89,38 @@ void DeviceSelectionNotifierTest::OnDeviceDisconnect(const std::vector<Continuat
|
||||
}
|
||||
}
|
||||
|
||||
void MockDmsNotifier::DeviceOnlineNotify(const std::string& deviceId)
|
||||
{
|
||||
}
|
||||
|
||||
void MockDmsNotifier::DeviceOfflineNotify(const std::string& deviceId)
|
||||
{
|
||||
}
|
||||
|
||||
void MockDmsNotifier::ProcessNotifierDied(const sptr<IRemoteObject>& notifier)
|
||||
{
|
||||
}
|
||||
|
||||
void MockDmsNotifier::ScheduleStartDeviceManager(const sptr<IRemoteObject>& appProxy, int32_t token,
|
||||
const std::shared_ptr<ContinuationExtraParams>& continuationExtraParams)
|
||||
{
|
||||
}
|
||||
|
||||
int32_t MockDmsNotifier::OnDeviceConnect(int32_t token, const std::vector<ContinuationResult>& continuationResults)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t MockDmsNotifier::OnDeviceDisconnect(int32_t token, const std::vector<ContinuationResult>& continuationResults)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t MockDmsNotifier::OnDeviceCancel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ContinuationManagerTest::SetUpTestCase()
|
||||
{
|
||||
DTEST_LOG << "ContinuationManagerTest::SetUpTestCase" << std::endl;
|
||||
@ -1679,5 +1713,56 @@ HWTEST_F(ContinuationManagerTest, OnRemoteRequest_005, TestSize.Level3)
|
||||
|
||||
EXPECT_EQ(ERR_OK, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnRemoteRequest_006
|
||||
* @tc.desc: test OnRemoteRequest when descriptor != remoteDescriptor.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5M4CD
|
||||
*/
|
||||
HWTEST_F(ContinuationManagerTest, OnRemoteRequest_006, TestSize.Level3)
|
||||
{
|
||||
sptr<DmsNotifier> dmsNotifier = new MockDmsNotifier();
|
||||
AppDeviceCallbackStub appDeviceCallbackStub(dmsNotifier);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
data.WriteInterfaceToken(TEST_INVALID_REMOTEDESCRIPTOR);
|
||||
/**
|
||||
* @tc.steps: step1. AppDeviceCallbackStub::OnRemoteRequest
|
||||
*/
|
||||
int32_t ret = appDeviceCallbackStub.OnRemoteRequest(1, data, reply, option);
|
||||
EXPECT_EQ(ERR_INVALID_STATE, ret);
|
||||
/**
|
||||
* @tc.steps: step2. DeviceSelectionNotifierProxy::OnDeviceConnect when continuationResults is nullptr.
|
||||
*/
|
||||
sptr<IRemoteObject> impl = new MockRemoteStub();
|
||||
DeviceSelectionNotifierProxy deviceSelectionNotifierProxy(impl);
|
||||
std::vector<ContinuationResult> continuationResults;
|
||||
deviceSelectionNotifierProxy.OnDeviceConnect(continuationResults);
|
||||
/**
|
||||
* @tc.steps: step3. DeviceSelectionNotifierProxy::OnDeviceDisconnect when continuationResults is nullptr.
|
||||
*/
|
||||
deviceSelectionNotifierProxy.OnDeviceDisconnect(continuationResults);
|
||||
|
||||
ContinuationResult continuationResult1;
|
||||
continuationResult1.SetDeviceId(SELECTED_DEVICE_ID1);
|
||||
continuationResult1.SetDeviceType(SELECTED_DEVICE_TYPE1);
|
||||
continuationResult1.SetDeviceName(SELECTED_DEVICE_NAME1);
|
||||
ContinuationResult continuationResult2;
|
||||
continuationResult2.SetDeviceId(SELECTED_DEVICE_ID2);
|
||||
continuationResult2.SetDeviceType(SELECTED_DEVICE_TYPE2);
|
||||
continuationResult2.SetDeviceName(SELECTED_DEVICE_NAME2);
|
||||
continuationResults.emplace_back(continuationResult1);
|
||||
continuationResults.emplace_back(continuationResult2);
|
||||
/**
|
||||
* @tc.steps: step4. DeviceSelectionNotifierProxy::OnDeviceConnect.
|
||||
*/
|
||||
deviceSelectionNotifierProxy.OnDeviceConnect(continuationResults);
|
||||
/**
|
||||
* @tc.steps: step5. DeviceSelectionNotifierProxy::OnDeviceDisconnect.
|
||||
*/
|
||||
deviceSelectionNotifierProxy.OnDeviceDisconnect(continuationResults);
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "device_selection_notifier_stub.h"
|
||||
#define private public
|
||||
#include "continuation_manager/app_device_callback_stub.h"
|
||||
#include "continuation_manager/device_selection_notifier_proxy.h"
|
||||
#include "distributed_ability_manager_service.h"
|
||||
#undef private
|
||||
|
||||
@ -43,6 +45,22 @@ public:
|
||||
void OnDeviceConnect(const std::vector<ContinuationResult>& continuationResults) override;
|
||||
void OnDeviceDisconnect(const std::vector<ContinuationResult>& continuationResults) override;
|
||||
};
|
||||
|
||||
class MockDmsNotifier : public DmsNotifier {
|
||||
public:
|
||||
MockDmsNotifier() = default;
|
||||
~MockDmsNotifier() = default;
|
||||
|
||||
void DeviceOnlineNotify(const std::string& deviceId) override;
|
||||
void DeviceOfflineNotify(const std::string& deviceId) override;
|
||||
void ProcessNotifierDied(const sptr<IRemoteObject>& notifier) override;
|
||||
void ScheduleStartDeviceManager(const sptr<IRemoteObject>& appProxy, int32_t token,
|
||||
const std::shared_ptr<ContinuationExtraParams>& continuationExtraParams = nullptr) override;
|
||||
int32_t OnDeviceConnect(int32_t token, const std::vector<ContinuationResult>& continuationResults) override;
|
||||
int32_t OnDeviceDisconnect(int32_t token, const std::vector<ContinuationResult>& continuationResults) override;
|
||||
int32_t OnDeviceCancel() override;
|
||||
};
|
||||
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DISTRIBUTED_ABILITY_MANAGER_CONTINUATION_MANAGER_TEST_H
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#ifndef MOCK_REMOTE_STUB_H
|
||||
#define MOCK_REMOTE_STUB_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
class MockRemoteInterface : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.test.mock");
|
||||
};
|
||||
|
||||
class MockRemoteStub : public IRemoteStub<MockRemoteInterface> {
|
||||
public:
|
||||
~MockRemoteStub() = default;
|
||||
virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
|
||||
MessageOption& option) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
@ -14,14 +14,23 @@
|
||||
*/
|
||||
|
||||
#include "distributed_mission_info_test.h"
|
||||
#include <memory>
|
||||
#define private public
|
||||
#include "mission/distributed_mission_info.h"
|
||||
#undef private
|
||||
#include "parcel_helper.h"
|
||||
#include "test_log.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
constexpr int32_t TEST_INVALID_VALUE = -1;
|
||||
constexpr int32_t TEST_PARCEL_WRITE_VALUE = 1;
|
||||
constexpr size_t TEST_PARCEL_WRITE_LEN = 5;
|
||||
}
|
||||
void DistributedMissionInfoTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
@ -38,13 +47,87 @@ void DistributedMissionInfoTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadFromParcel001
|
||||
* @tc.desc: test ReadFromParcel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadFromParcel001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadFromParcel001 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
bool ret = dstbMissionInfo.Marshalling(parcel);
|
||||
EXPECT_TRUE(ret);
|
||||
ret = dstbMissionInfo.ReadFromParcel(parcel);
|
||||
EXPECT_TRUE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadFromParcel001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadFromParcel002
|
||||
* @tc.desc: test ReadFromParcel when combinedMissionIds read failed
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadFromParcel002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadFromParcel002 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
for (size_t i = 0; i < TEST_PARCEL_WRITE_LEN; i++) {
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
}
|
||||
bool ret = dstbMissionInfo.ReadFromParcel(parcel);
|
||||
EXPECT_FALSE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadFromParcel002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testUnmarshalling001
|
||||
* @tc.desc: test Unmarshalling
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testUnmarshalling001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testUnmarshalling001 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
bool ret = dstbMissionInfo.Marshalling(parcel);
|
||||
EXPECT_TRUE(ret);
|
||||
DstbMissionInfo* dstbMissionInfoReturn = dstbMissionInfo.Unmarshalling(parcel);
|
||||
EXPECT_NE(nullptr, dstbMissionInfoReturn);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testUnmarshalling001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testUnmarshalling002
|
||||
* @tc.desc: test Unmarshalling when combinedMissionIds read failed
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testUnmarshalling002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testUnmarshalling002 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
for (size_t i = 0; i < TEST_PARCEL_WRITE_LEN; i++) {
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
}
|
||||
DstbMissionInfo* dstbMissionInfoReturn = dstbMissionInfo.Unmarshalling(parcel);
|
||||
EXPECT_EQ(nullptr, dstbMissionInfoReturn);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testUnmarshalling002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testMarshalling001
|
||||
* @tc.desc: write data to parcel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testMarshalling001, TestSize.Level1)
|
||||
HWTEST_F(DistributedMissionInfoTest, testMarshalling001, TestSize.Level3)
|
||||
{
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel data;
|
||||
@ -52,17 +135,206 @@ HWTEST_F(DistributedMissionInfoTest, testMarshalling001, TestSize.Level1)
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadDstbMissionInfosFromParcel001
|
||||
* @tc.desc: test ReadDstbMissionInfosFromParcel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel001 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(0, missionInfos.size());
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadDstbMissionInfosFromParcel002
|
||||
* @tc.desc: test ReadDstbMissionInfosFromParcel when len < 0
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel002 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteInt32(TEST_INVALID_VALUE);
|
||||
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
|
||||
EXPECT_FALSE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadDstbMissionInfosFromParcel003
|
||||
* @tc.desc: test ReadDstbMissionInfosFromParcel when size > parcel.GetReadableBytes()
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel003, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel003 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteInt32(parcel.GetReadableBytes() + 1);
|
||||
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
|
||||
EXPECT_FALSE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel003 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadDstbMissionInfosFromParcel004
|
||||
* @tc.desc: test ReadDstbMissionInfosFromParcel when missionInfos.max_size() < size
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel004, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel004 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteInt32(missionInfos.max_size() + 1);
|
||||
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
|
||||
EXPECT_FALSE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel004 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadDstbMissionInfosFromParcel005
|
||||
* @tc.desc: test ReadDstbMissionInfosFromParcel when size = missionInfos.max_size() - 1
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel005, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel005 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteInt32(missionInfos.max_size() - 1);
|
||||
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
|
||||
EXPECT_FALSE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel005 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadDstbMissionInfosFromParcel006
|
||||
* @tc.desc: test ReadDstbMissionInfosFromParcel when ptr is nullptr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel006, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel006 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteParcelable(nullptr);
|
||||
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
|
||||
EXPECT_FALSE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel006 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testReadDstbMissionInfosFromParcel007
|
||||
* @tc.desc: test ReadDstbMissionInfosFromParcel when ptr is not nullptr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testReadDstbMissionInfosFromParcel007, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel007 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteInt32(TEST_PARCEL_WRITE_VALUE);
|
||||
parcel.WriteParcelable(&dstbMissionInfo);
|
||||
bool ret = dstbMissionInfo.ReadDstbMissionInfosFromParcel(parcel, missionInfos);
|
||||
EXPECT_TRUE(ret);
|
||||
EXPECT_EQ(1, missionInfos.size());
|
||||
DTEST_LOG << "DistributedMissionInfoTest testReadDstbMissionInfosFromParcel007 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testWriteDstbMissionInfosToParcel001
|
||||
* @tc.desc: test WriteDstbMissionInfosToParcel when missionInfos is empty
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testWriteDstbMissionInfosToParcel001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testWriteDstbMissionInfosToParcel001 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
bool ret = dstbMissionInfo.WriteDstbMissionInfosToParcel(parcel, missionInfos);
|
||||
EXPECT_TRUE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testWriteDstbMissionInfosToParcel001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testWriteDstbMissionInfosToParcel002
|
||||
* @tc.desc: test WriteDstbMissionInfosToParcel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testWriteDstbMissionInfosToParcel002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testWriteDstbMissionInfosToParcel002 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
Parcel parcel;
|
||||
std::vector<DstbMissionInfo> missionInfos;
|
||||
missionInfos.emplace_back(dstbMissionInfo);
|
||||
bool ret = dstbMissionInfo.WriteDstbMissionInfosToParcel(parcel, missionInfos);
|
||||
EXPECT_TRUE(ret);
|
||||
DTEST_LOG << "DistributedMissionInfoTest testWriteDstbMissionInfosToParcel002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testToString001
|
||||
* @tc.desc: print a missionInfo
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testToString001, TestSize.Level1)
|
||||
HWTEST_F(DistributedMissionInfoTest, testToString001, TestSize.Level3)
|
||||
{
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
auto ret = dstbMissionInfo.ToString();
|
||||
EXPECT_NE(ret, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testToString002
|
||||
* @tc.desc: test ToString
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5O2P9
|
||||
*/
|
||||
HWTEST_F(DistributedMissionInfoTest, testToString002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "DistributedMissionInfoTest testToString002 start" << std::endl;
|
||||
DstbMissionInfo dstbMissionInfo;
|
||||
dstbMissionInfo.baseWant = std::make_shared<AAFwk::Want>();
|
||||
dstbMissionInfo.topAbility = std::make_shared<AppExecFwk::ElementName>();
|
||||
dstbMissionInfo.baseAbility = std::make_shared<AppExecFwk::ElementName>();
|
||||
dstbMissionInfo.reservedAbility = std::make_shared<AppExecFwk::ElementName>();
|
||||
std::string ret = dstbMissionInfo.ToString();
|
||||
EXPECT_FALSE(ret.empty());
|
||||
DTEST_LOG << "DistributedMissionInfoTest testToString002 end" << std::endl;
|
||||
}
|
||||
} // DistributedSchedule
|
||||
} // namespace OHOS
|
@ -14,14 +14,23 @@
|
||||
*/
|
||||
|
||||
#include "snapshot_test.h"
|
||||
|
||||
#include <exception>
|
||||
#define private public
|
||||
#include "mission/snapshot.h"
|
||||
#undef private
|
||||
#include "parcel_helper.h"
|
||||
#include "test_log.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
const std::string TAG = "Snapshot";
|
||||
constexpr size_t TEST_PARCEL_WRITE_VALUE = 1;
|
||||
}
|
||||
void SnapshotTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
@ -52,6 +61,69 @@ HWTEST_F(SnapshotTest, testWriteToParcel001, TestSize.Level1)
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testWriteToParcel002
|
||||
* @tc.desc: test WriteToParcel when rect_ is not nullptr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5Y2VH
|
||||
*/
|
||||
HWTEST_F(SnapshotTest, testWriteToParcel002, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SnapshotTest testWriteToParcel002 start" << std::endl;
|
||||
Snapshot snapshot;
|
||||
MessageParcel data;
|
||||
snapshot.rect_ = std::make_unique<Rect>(0, 0, 0, 0);
|
||||
bool ret = snapshot.WriteToParcel(data);
|
||||
EXPECT_TRUE(ret);
|
||||
DTEST_LOG << "SnapshotTest testWriteToParcel002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testWriteToParcel003
|
||||
* @tc.desc: test WriteToParcel when windowBounds_ is not nullptr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5Y2VH
|
||||
*/
|
||||
HWTEST_F(SnapshotTest, testWriteToParcel003, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SnapshotTest testWriteToParcel003 start" << std::endl;
|
||||
Snapshot snapshot;
|
||||
MessageParcel data;
|
||||
snapshot.rect_ = std::make_unique<Rect>(0, 0, 0, 0);
|
||||
snapshot.windowBounds_ = std::make_unique<Rect>(0, 0, 0, 0);
|
||||
bool ret = snapshot.WriteToParcel(data);
|
||||
EXPECT_TRUE(ret);
|
||||
DTEST_LOG << "SnapshotTest testWriteToParcel003 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testWriteToParcel004
|
||||
* @tc.desc: test WriteToParcel when pixelMap_ is not nullptr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5Y2VH
|
||||
*/
|
||||
HWTEST_F(SnapshotTest, testWriteToParcel004, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SnapshotTest testWriteToParcel004 start" << std::endl;
|
||||
Snapshot snapshot;
|
||||
MessageParcel data;
|
||||
snapshot.rect_ = std::make_unique<Rect>(0, 0, 0, 0);
|
||||
snapshot.windowBounds_ = std::make_unique<Rect>(0, 0, 0, 0);
|
||||
uint8_t buffer = (uint8_t)TEST_PARCEL_WRITE_VALUE;
|
||||
snapshot.pixelMap_ = snapshot.CreatePixelMap(&buffer, TEST_PARCEL_WRITE_VALUE);
|
||||
/**
|
||||
* @tc.steps: step1. WriteToParcel when pixelMap_ is not nullptr
|
||||
*/
|
||||
bool ret = snapshot.WriteToParcel(data);
|
||||
EXPECT_TRUE(ret);
|
||||
/**
|
||||
* @tc.steps: step2. FillSnapShot
|
||||
*/
|
||||
std::unique_ptr<Snapshot> snapShotReturn = snapshot.FillSnapShot(data);
|
||||
EXPECT_NE(nullptr, snapShotReturn);
|
||||
DTEST_LOG << "SnapshotTest testWriteToParcel004 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testFillSnapShot001
|
||||
* @tc.desc: fill up a snapshot
|
||||
@ -79,5 +151,74 @@ HWTEST_F(SnapshotTest, testWriteSnapshotInfo001, TestSize.Level1)
|
||||
auto ret = snapshot.WriteSnapshotInfo(data);
|
||||
EXPECT_EQ(ret, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testCreate001
|
||||
* @tc.desc: test Create when buffer is nullptr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5Y2VH
|
||||
*/
|
||||
HWTEST_F(SnapshotTest, testCreate001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SnapshotTest testCreate001 start" << std::endl;
|
||||
Snapshot snapshot;
|
||||
std::vector<uint8_t> data;
|
||||
/**
|
||||
* @tc.steps: step1. Create when data is empty;
|
||||
*/
|
||||
std::unique_ptr<Snapshot> ret = snapshot.Create(data);
|
||||
EXPECT_EQ(nullptr, ret);
|
||||
/**
|
||||
* @tc.steps: step2. Create when data is not empty;
|
||||
*/
|
||||
data.emplace_back(1);
|
||||
EXPECT_EQ(nullptr, ret);
|
||||
DTEST_LOG << "SnapshotTest testCreate001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testGetCreatedTime001
|
||||
* @tc.desc: test GetCreatedTime
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5Y2VH
|
||||
*/
|
||||
HWTEST_F(SnapshotTest, testGetCreatedTime001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SnapshotTest testGetCreatedTime001 start" << std::endl;
|
||||
Snapshot snapshot;
|
||||
int64_t ret = snapshot.GetCreatedTime();
|
||||
EXPECT_EQ(0, ret);
|
||||
DTEST_LOG << "SnapshotTest testGetCreatedTime001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testGetLastAccessTime001
|
||||
* @tc.desc: test GetLastAccessTime
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5Y2VH
|
||||
*/
|
||||
HWTEST_F(SnapshotTest, testGetLastAccessTime001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SnapshotTest testGetCreatedTime001 start" << std::endl;
|
||||
Snapshot snapshot;
|
||||
int64_t ret = snapshot.GetLastAccessTime();
|
||||
EXPECT_EQ(0, ret);
|
||||
DTEST_LOG << "SnapshotTest testGetLastAccessTime001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: testUpdateLastAccessTime001
|
||||
* @tc.desc: test UpdateLastAccessTime
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: I5Y2VH
|
||||
*/
|
||||
HWTEST_F(SnapshotTest, testUpdateLastAccessTime001, TestSize.Level3)
|
||||
{
|
||||
DTEST_LOG << "SnapshotTest testUpdateLastAccessTime001 start" << std::endl;
|
||||
Snapshot snapshot;
|
||||
snapshot.UpdateLastAccessTime(TEST_PARCEL_WRITE_VALUE);
|
||||
EXPECT_EQ((int64_t)TEST_PARCEL_WRITE_VALUE, snapshot.lastAccessTime_);
|
||||
DTEST_LOG << "SnapshotTest testUpdateLastAccessTime001 end" << std::endl;
|
||||
}
|
||||
} // DistributedSchedule
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user