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 <gtest/gtest.h>
17 #include <iostream>
18 #include <memory>
19 #include <string>
20 #include <vector>
21
22 #include "distributed_device_profile_constants.h"
23 #include "distributed_device_profile_errors.h"
24 #include "distributed_device_profile_log.h"
25 #include "event_handler_factory.h"
26 #include "switch_profile_manager.h"
27 using namespace testing::ext;
28 namespace OHOS {
29 namespace DistributedDeviceProfile {
30 using namespace std;
31 namespace {
32 const std::string TAG = "SwitchProfileManagerTest";
33 }
34 class SwitchProfileManagerTest : public testing::Test {
35 public:
36 static void SetUpTestCase();
37 static void TearDownTestCase();
38 void SetUp();
39 void TearDown();
40 };
41
SetUpTestCase()42 void SwitchProfileManagerTest::SetUpTestCase()
43 {
44 }
45
TearDownTestCase()46 void SwitchProfileManagerTest::TearDownTestCase()
47 {
48 }
49
SetUp()50 void SwitchProfileManagerTest::SetUp()
51 {
52 }
53
TearDown()54 void SwitchProfileManagerTest::TearDown()
55 {
56 }
57
58 #ifdef DEVICE_PROFILE_SWITCH_STATIC_ENABLE
59 /*
60 * @tc.name: Init_001
61 * @tc.desc: Init
62 * @tc.type: FUNC
63 * @tc.require: I4NY1T
64 */
65 HWTEST_F(SwitchProfileManagerTest, Init_001, TestSize.Level1)
66 {
67 int32_t errCode = SwitchProfileManager::GetInstance().Init();
68 EXPECT_EQ(errCode, DP_SUCCESS);
69 }
70
71 /*
72 * @tc.name: UnInit_001
73 * @tc.desc: UnInit
74 * @tc.type: FUNC
75 * @tc.require: I4NY1T
76 */
77 HWTEST_F(SwitchProfileManagerTest, UnInit_001, TestSize.Level1)
78 {
79 SwitchProfileManager::GetInstance().Init();
80 int32_t errCode = SwitchProfileManager::GetInstance().UnInit();
81 EXPECT_EQ(errCode, DP_SUCCESS);
82 }
83
84 /*
85 * @tc.name: ReInit_001
86 * @tc.desc: ReInit
87 * @tc.type: FUNC
88 * @tc.require: I4NY1T
89 */
90 HWTEST_F(SwitchProfileManagerTest, ReInit_001, TestSize.Level1)
91 {
92 SwitchProfileManager::GetInstance().Init();
93 int32_t errCode = SwitchProfileManager::GetInstance().ReInit();
94 EXPECT_EQ(errCode, DP_SUCCESS);
95 }
96 #endif // DEVICE_PROFILE_SWITCH_STATIC_ENABLE
97
98 /*
99 * @tc.name: PutCharacteristicProfile_001
100 * @tc.desc: PutCharacteristicProfile
101 * @tc.type: FUNC
102 * @tc.require: I4NY1T
103 */
104 HWTEST_F(SwitchProfileManagerTest, PutCharacteristicProfile_001, TestSize.Level1)
105 {
106 CharacteristicProfile charProfile;
107 int32_t errCode = SwitchProfileManager::GetInstance().PutCharacteristicProfile(charProfile);
108 EXPECT_EQ(errCode, DP_INVALID_PARAMS);
109 }
110
111 /*
112 * @tc.name: PutCharacteristicProfileBatch_001
113 * @tc.desc: PutCharacteristicProfileBatch
114 * @tc.type: FUNC
115 * @tc.require: I4NY1T
116 */
117 HWTEST_F(SwitchProfileManagerTest, PutCharacteristicProfileBatch_001, TestSize.Level1)
118 {
119 std::vector<CharacteristicProfile> charProfiles;
120 int32_t errCode = SwitchProfileManager::GetInstance().PutCharacteristicProfileBatch(charProfiles);
121 EXPECT_EQ(errCode, DP_INVALID_PARAMS);
122 }
123
124 /*
125 * @tc.name: GetCharacteristicProfile_001
126 * @tc.desc: GetCharacteristicProfile
127 * @tc.type: FUNC
128 * @tc.require: I4NY1T
129 */
130 HWTEST_F(SwitchProfileManagerTest, GetCharacteristicProfile_001, TestSize.Level1)
131 {
132 std::string deviceId;
133 std::string serviceName;
134 std::string characteristicKey;
135 CharacteristicProfile charProfile;
136 int32_t errCode = SwitchProfileManager::GetInstance().GetCharacteristicProfile(deviceId, serviceName,
137 characteristicKey, charProfile);
138 EXPECT_EQ(errCode, DP_INVALID_PARAMS);
139 }
140
141 /*
142 * @tc.name: RefreshLocalSwitchProfile_001
143 * @tc.desc: RefreshLocalSwitchProfile
144 * @tc.type: FUNC
145 * @tc.require: I4NY1T
146 */
147 HWTEST_F(SwitchProfileManagerTest, RefreshLocalSwitchProfile_001, TestSize.Level1)
148 {
149 int32_t errCode = SwitchProfileManager::GetInstance().RefreshLocalSwitchProfile();
150 EXPECT_EQ(errCode, DP_INVALID_PARAMS);
151 }
152 } // namespace DistributedDeviceProfile
153 } // namespace OHOS
154