1 /*
2 * Copyright (c) 2024 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_dm_distributed_hardware_load.h"
17
18 #include <iostream>
19
20 #include "dm_log.h"
21 #include "dm_constants.h"
22
23 namespace OHOS {
24 namespace DistributedHardware {
SetUp()25 void DmDistributedHardwareLoadTest::SetUp()
26 {
27 }
28
TearDown()29 void DmDistributedHardwareLoadTest::TearDown()
30 {
31 }
32
SetUpTestCase()33 void DmDistributedHardwareLoadTest::SetUpTestCase()
34 {
35 }
36
TearDownTestCase()37 void DmDistributedHardwareLoadTest::TearDownTestCase()
38 {
39 }
40
41 HWTEST_F(DmDistributedHardwareLoadTest, LoadDistributedHardwareFwk_001, testing::ext::TestSize.Level0)
42 {
43 DmDistributedHardwareLoad::GetInstance().LoadDistributedHardwareFwk();
44 uint32_t ret = DmDistributedHardwareLoad::GetInstance().distributedHardwareLoadCount_;
45 EXPECT_NE(ret, DM_OK);
46 }
47
48 HWTEST_F(DmDistributedHardwareLoadTest, InitDistributedHardwareLoadCount_001, testing::ext::TestSize.Level0)
49 {
50 DmDistributedHardwareLoad::GetInstance().InitDistributedHardwareLoadCount();
51 uint32_t ret = DmDistributedHardwareLoad::GetInstance().distributedHardwareLoadCount_;
52 EXPECT_EQ(ret, DM_OK);
53 }
54
55 HWTEST_F(DmDistributedHardwareLoadTest, GetDistributedHardwareLoadCount_001, testing::ext::TestSize.Level0)
56 {
57 DmDistributedHardwareLoad::GetInstance().GetDistributedHardwareLoadCount();
58 uint32_t ret = DmDistributedHardwareLoad::GetInstance().distributedHardwareLoadCount_;
59 EXPECT_EQ(ret, DM_OK);
60 }
61
62 HWTEST_F(DmDistributedHardwareLoadTest, OnLoadSystemAbilitySuccess_001, testing::ext::TestSize.Level0)
63 {
64 int32_t systemAbilityId = 4800;
65 sptr<IRemoteObject> remoteObject = nullptr;
66 sptr<DistributedHardwareLoadCallback> distributedHardwareLoadCallback_(new DistributedHardwareLoadCallback());
67 distributedHardwareLoadCallback_->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject);
68 uint32_t ret = DmDistributedHardwareLoad::GetInstance().distributedHardwareLoadCount_;
69 EXPECT_EQ(ret, DM_OK);
70 }
71
72 HWTEST_F(DmDistributedHardwareLoadTest, Sha256_001, testing::ext::TestSize.Level0)
73 {
74 std::shared_ptr<Crypto> crypto = std::make_shared<Crypto>();
75 std::string text;
76 bool isUpper = false;
77 std::string ret = crypto->Sha256(text, isUpper);
78 EXPECT_NE(ret.empty(), true);
79 }
80
81 HWTEST_F(DmDistributedHardwareLoadTest, GetCryptoAdapter_001, testing::ext::TestSize.Level0)
82 {
83 std::string soName = "soName";
84 auto ret = DmAdapterManager::GetInstance().GetCryptoAdapter(soName);
85 EXPECT_EQ(ret, nullptr);
86 }
87
88 } // namespace DistributedHardware
89 } // namespace OHOS
90