1 /*
2 * Copyright (c) 2022 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 "event_trance_test.h"
17
18 using namespace testing::ext;
19
20 namespace OHOS {
21 namespace DistributedHardware {
SetUpTestCase(void)22 void EventTraceTest::SetUpTestCase(void)
23 {
24 }
25
TearDownTestCase(void)26 void EventTraceTest::TearDownTestCase(void)
27 {
28 }
29
SetUp()30 void EventTraceTest::SetUp()
31 {
32 }
33
TearDown()34 void EventTraceTest::TearDown()
35 {
36 }
37
38 /**
39 * @tc.name: HiSysEventWriteReleaseMsg_001
40 * @tc.desc: Verify the HiSysEventWriteReleaseMsg function
41 * @tc.type: FUNC
42 * @tc.require: AR000GHSK0
43 */
44 HWTEST_F(EventTraceTest, HiSysEventWriteReleaseMsg_001, TestSize.Level0)
45 {
46 std::string status;
47 int32_t errCode = 0;
48 std::string msg;
49 HiSysEventWriteErrCodeMsg(status, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, errCode, msg);
50 EXPECT_EQ(true, msg.empty());
51 }
52
53 /**
54 * @tc.name: DHCompMgrTraceStart_001
55 * @tc.desc: Verify the DHCompMgrTraceStart function
56 * @tc.type: FUNC
57 * @tc.require: AR000GHSK0
58 */
59 HWTEST_F(EventTraceTest, DHCompMgrTraceStart_001, TestSize.Level0)
60 {
61 std::string anonyNetworkId;
62 std::string anonyDHId;
63 std::string msg;
64 DHCompMgrTraceStart(anonyNetworkId, anonyDHId, msg);
65 EXPECT_EQ(true, msg.empty());
66 }
67
68 /**
69 * @tc.name: GetDeviceInfo_001
70 * @tc.desc: Verify the GetDeviceInfo function
71 * @tc.type: FUNC
72 * @tc.require: AR000GHSK0
73 */
74 HWTEST_F(EventTraceTest, GetDeviceInfo_001, TestSize.Level0)
75 {
76 std::string uuid;
77 std::string networkId;
78 DHContext::GetInstance().devInfo_.uuid = "uuid";
79 DHContext::GetInstance().GetDeviceInfo();
80 uint32_t MAX_ONLINE_DEVICE_SIZE = 10002;
81 for (uint32_t i = 0; i <= MAX_ONLINE_DEVICE_SIZE; ++i) {
82 DHContext::GetInstance().onlineDeviceMap_.insert(std::make_pair(std::to_string(i), std::to_string(i)));
83 DHContext::GetInstance().deviceIdUUIDMap_.insert(std::make_pair(std::to_string(i), std::to_string(i)));
84 }
85 DHContext::GetInstance().AddOnlineDevice(uuid, networkId);
86 DHContext::GetInstance().onlineDeviceMap_.clear();
87 DHContext::GetInstance().AddOnlineDevice(uuid, networkId);
88 EXPECT_EQ(true, uuid.empty());
89 }
90 } // namespace DistributedHardware
91 } // namespace OHOS
92