• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /*
59  * @tc.name: Init_001
60  * @tc.desc: Init
61  * @tc.type: FUNC
62  * @tc.require: I4NY1T
63  */
64 HWTEST_F(SwitchProfileManagerTest, Init_001, TestSize.Level1)
65 {
66     int32_t errCode = SwitchProfileManager::GetInstance().Init();
67     EXPECT_EQ(errCode, DP_SUCCESS);
68 }
69 
70 /*
71  * @tc.name: UnInit_001
72  * @tc.desc: UnInit
73  * @tc.type: FUNC
74  * @tc.require: I4NY1T
75  */
76 HWTEST_F(SwitchProfileManagerTest, UnInit_001, TestSize.Level1)
77 {
78     SwitchProfileManager::GetInstance().Init();
79     int32_t errCode = SwitchProfileManager::GetInstance().UnInit();
80     EXPECT_EQ(errCode, DP_SUCCESS);
81 }
82 
83 /*
84  * @tc.name: ReInit_001
85  * @tc.desc: ReInit
86  * @tc.type: FUNC
87  * @tc.require: I4NY1T
88  */
89 HWTEST_F(SwitchProfileManagerTest, ReInit_001, TestSize.Level1)
90 {
91     SwitchProfileManager::GetInstance().Init();
92     int32_t errCode = SwitchProfileManager::GetInstance().ReInit();
93     EXPECT_EQ(errCode, DP_SUCCESS);
94 }
95 
96 /*
97  * @tc.name: PutCharacteristicProfile_001
98  * @tc.desc: PutCharacteristicProfile
99  * @tc.type: FUNC
100  * @tc.require: I4NY1T
101  */
102 HWTEST_F(SwitchProfileManagerTest, PutCharacteristicProfile_001, TestSize.Level1)
103 {
104     CharacteristicProfile charProfile;
105     int32_t errCode = SwitchProfileManager::GetInstance().PutCharacteristicProfile(charProfile);
106     EXPECT_EQ(errCode, DP_INVALID_PARAMS);
107 }
108 
109 /*
110  * @tc.name: PutCharacteristicProfileBatch_001
111  * @tc.desc: PutCharacteristicProfileBatch
112  * @tc.type: FUNC
113  * @tc.require: I4NY1T
114  */
115 HWTEST_F(SwitchProfileManagerTest, PutCharacteristicProfileBatch_001, TestSize.Level1)
116 {
117     std::vector<CharacteristicProfile> charProfiles;
118     int32_t errCode = SwitchProfileManager::GetInstance().PutCharacteristicProfileBatch(charProfiles);
119     EXPECT_EQ(errCode, DP_INVALID_PARAMS);
120 }
121 
122 /*
123  * @tc.name: GetCharacteristicProfile_001
124  * @tc.desc: GetCharacteristicProfile
125  * @tc.type: FUNC
126  * @tc.require: I4NY1T
127  */
128 HWTEST_F(SwitchProfileManagerTest, GetCharacteristicProfile_001, TestSize.Level1)
129 {
130     std::string deviceId;
131     std::string serviceName;
132     std::string characteristicKey;
133     CharacteristicProfile charProfile;
134     int32_t errCode = SwitchProfileManager::GetInstance().GetCharacteristicProfile(deviceId, serviceName,
135         characteristicKey, charProfile);
136     EXPECT_EQ(errCode, DP_INVALID_PARAMS);
137 }
138 
139 /*
140  * @tc.name: RefreshLocalSwitchProfile_001
141  * @tc.desc: RefreshLocalSwitchProfile
142  * @tc.type: FUNC
143  * @tc.require: I4NY1T
144  */
145 HWTEST_F(SwitchProfileManagerTest, RefreshLocalSwitchProfile_001, TestSize.Level1)
146 {
147     int32_t errCode = SwitchProfileManager::GetInstance().RefreshLocalSwitchProfile();
148     EXPECT_EQ(errCode, DP_INVALID_PARAMS);
149 }
150 } // namespace DistributedDeviceProfile
151 } // namespace OHOS
152