1 /*
2 * Copyright (c) 2021 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 "distributed_hardware_manager_test.h"
17
18 #include "constants.h"
19 #include "component_loader.h"
20 #include "distributed_hardware_errno.h"
21 #include "distributed_hardware_log.h"
22 #include "distributed_hardware_manager.h"
23
24 using namespace testing::ext;
25
26 namespace OHOS {
27 namespace DistributedHardware {
SetUpTestCase(void)28 void DistributedHardwareManagerTest::SetUpTestCase(void) {}
29
TearDownTestCase(void)30 void DistributedHardwareManagerTest::TearDownTestCase(void) {}
31
SetUp()32 void DistributedHardwareManagerTest::SetUp() {}
33
TearDown()34 void DistributedHardwareManagerTest::TearDown() {}
35
36 /**
37 * @tc.name: Initialize_001
38 * @tc.desc: Verify the Initialize success
39 * @tc.type: FUNC
40 * @tc.require: AR000GHSJM
41 */
42 HWTEST_F(DistributedHardwareManagerTest, Initialize_001, TestSize.Level0)
43 {
44 auto ret = DistributedHardwareManager::GetInstance().Initialize();
45 EXPECT_EQ(DH_FWK_SUCCESS, ret);
46
47 ret = DistributedHardwareManager::GetInstance().Initialize();
48 EXPECT_EQ(DH_FWK_SUCCESS, ret);
49 }
50
51 /**
52 * @tc.name: LocalInit_001
53 * @tc.desc: Verify the LocalInit function
54 * @tc.type: FUNC
55 * @tc.require: AR000GHSJM
56 */
57 HWTEST_F(DistributedHardwareManagerTest, LocalInit_001, TestSize.Level0)
58 {
59 int32_t ret = DistributedHardwareManager::GetInstance().LocalInit();
60 EXPECT_EQ(DH_FWK_SUCCESS, ret);
61 }
62
63 /**
64 * @tc.name: GetComponentVersion_001
65 * @tc.desc: Verify the GetComponentVersion function
66 * @tc.type: FUNC
67 * @tc.require: AR000GHSJM
68 */
69 HWTEST_F(DistributedHardwareManagerTest, GetComponentVersion_001, TestSize.Level0)
70 {
71 ComponentLoader::GetInstance().isLocalVersionInit_.store(false);
72 std::unordered_map<DHType, std::string> versionMap;
73 int32_t ret = DistributedHardwareManager::GetInstance().GetComponentVersion(versionMap);
74 EXPECT_EQ(ERR_DH_FWK_LOADER_GET_LOCAL_VERSION_FAIL, ret);
75
76 ComponentLoader::GetInstance().isLocalVersionInit_.store(true);
77 ret = DistributedHardwareManager::GetInstance().GetComponentVersion(versionMap);
78 EXPECT_EQ(DH_FWK_SUCCESS, ret);
79 }
80 } // namespace DistributedHardware
81 } // namespace OHOS
82