1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "UTTest_ipc_get_device_info_rsp.h"
17 
18 namespace OHOS {
19 namespace DistributedHardware {
SetUp()20 void IpcGetDeviceInfoRspTest::SetUp()
21 {
22 }
23 
TearDown()24 void IpcGetDeviceInfoRspTest::TearDown()
25 {
26 }
27 
SetUpTestCase()28 void IpcGetDeviceInfoRspTest::SetUpTestCase()
29 {
30 }
31 
TearDownTestCase()32 void IpcGetDeviceInfoRspTest::TearDownTestCase()
33 {
34 }
35 
36 namespace {
37 
38 /**
39  * @tc.name: GetDeviceInfo_001
40  * @tc.type: FUNC
41  * @tc.require: AR000GHSJK
42  */
43 HWTEST_F(IpcGetDeviceInfoRspTest, GetDeviceInfo_001, testing::ext::TestSize.Level0)
44 {
45     DmDeviceInfo deviceInfo = {
46         .deviceId = "deviceIdTest",
47         .deviceName = "deviceNameTest",
48         .deviceTypeId = 1,
49     };
50     std::shared_ptr<IpcGetDeviceInfoRsp> rsp = std::make_shared<IpcGetDeviceInfoRsp>();
51     rsp->SetDeviceInfo(deviceInfo);
52     DmDeviceInfo info = rsp->GetDeviceInfo();
53     int32_t ret = strcmp(info.deviceId, deviceInfo.deviceId);
54     EXPECT_EQ(ret, 0);
55     strcmp(info.deviceName, deviceInfo.deviceName);
56     EXPECT_EQ(ret, 0);
57     EXPECT_EQ(info.deviceTypeId, deviceInfo.deviceTypeId);
58 }
59 
60 /**
61  * @tc.name: GetDeviceInfo_002
62  * @tc.type: FUNC
63  * @tc.require: AR000GHSJK
64  */
65 HWTEST_F(IpcGetDeviceInfoRspTest, GetDeviceInfo_002, testing::ext::TestSize.Level0)
66 {
67     DmDeviceInfo deviceInfo;
68     std::shared_ptr<IpcGetDeviceInfoRsp> rsp = std::make_shared<IpcGetDeviceInfoRsp>();
69     rsp->SetDeviceInfo(deviceInfo);
70     DmDeviceInfo info = rsp->GetDeviceInfo();
71     std::string deviceName = std::string(info.deviceName);
72     ASSERT_TRUE(deviceName.empty());
73 }
74 } // namespace
75 } // namespace DistributedHardware
76 } // namespace OHOS