• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 <cstdio>
17 #include <gtest/gtest.h>
18 
19 #include "volume/volume_manager_service_ext.h"
20 #include "disk/disk_manager_service.h"
21 #include "volume_core.h"
22 #include "storage_service_errno.h"
23 
24 namespace {
25 using namespace std;
26 using namespace OHOS;
27 using namespace StorageManager;
28 class VolumeManagerServiceExtTest : public testing::Test {
29 public:
SetUpTestCase(void)30     static void SetUpTestCase(void) {};
TearDownTestCase()31     static void TearDownTestCase() {};
SetUp()32     void SetUp() {};
TearDown()33     void TearDown() {};
34 };
35 
36 /**
37  * @tc.number: SUB_STORAGE_Volume_manager_service_ext_Init_0000
38  * @tc.name: Volume_manager_service_ext_Init_0000
39  * @tc.desc: Test function of Init for SUCCESS.
40  * @tc.size: MEDIUM
41  * @tc.type: FUNC
42  * @tc.level Level 1
43  * @tc.require: SR000GGUPF
44  */
45 HWTEST_F(VolumeManagerServiceExtTest, Volume_manager_service_ext_Init_0000, testing::ext::TestSize.Level1)
46 {
47     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-begin Volume_manager_service_ext_Init_0000";
48     auto &vmServiceExt =VolumeManagerServiceExt::GetInstance();
49     vmServiceExt.Init();
50     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-end Volume_manager_service_ext_Init_0000";
51 }
52 
53 /**
54  * @tc.number: SUB_STORAGE_Volume_manager_service_ext_UnInit_0000
55  * @tc.name: Volume_manager_service_ext_UnInit_0000
56  * @tc.desc: Test function of UnInit for SUCCESS.
57  * @tc.size: MEDIUM
58  * @tc.type: FUNC
59  * @tc.level Level 1
60  * @tc.require: SR000GGUPF
61  */
62 HWTEST_F(VolumeManagerServiceExtTest, Volume_manager_service_ext_UnInit_0000, testing::ext::TestSize.Level1)
63 {
64     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-begin Volume_manager_service_ext_UnInit_0000";
65     auto &vmServiceExt =VolumeManagerServiceExt::GetInstance();
66     int32_t num = 0;
67     vmServiceExt.handler_ = (void *)&num;
68     vmServiceExt.UnInit();
69     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-end Volume_manager_service_ext_UnInit_0000";
70 }
71 
72 /**
73  * @tc.number: SUB_STORAGE_Volume_manager_service_ext_UnInit_0001
74  * @tc.name: Volume_manager_service_ext_UnInit_0001
75  * @tc.desc: Test function of UnInit for UNSUCCESS.
76  * @tc.size: MEDIUM
77  * @tc.type: FUNC
78  * @tc.level Level 1
79  * @tc.require: SR000GGUPF
80  */
81 HWTEST_F(VolumeManagerServiceExtTest, Volume_manager_service_ext_UnInit_0001, testing::ext::TestSize.Level1)
82 {
83     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-begin Volume_manager_service_ext_UnInit_0001";
84     auto &vmServiceExt =VolumeManagerServiceExt::GetInstance();
85     vmServiceExt.UnInit();
86     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-end Volume_manager_service_ext_UnInit_0001";
87 }
88 
89 /**
90  * @tc.number: SUB_STORAGE_Volume_manager_service_ext_NotifyUsbFuseMount_0000
91  * @tc.name: Volume_manager_service_ext_NotifyUsbFuseMount_0000
92  * @tc.desc: Test function of NotifyUsbFuseMount for UNSUCCESS.
93  * @tc.size: MEDIUM
94  * @tc.type: FUNC
95  * @tc.level Level 1
96  * @tc.require: SR000GGUPF
97  */
98 HWTEST_F(VolumeManagerServiceExtTest, Volume_manager_service_ext_NotifyUsbFuseMount_0000,
99     testing::ext::TestSize.Level1)
100 {
101     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-begin Volume_manager_service_ext_NotifyUsbFuseMount_0000";
102     auto &vmServiceExt =VolumeManagerServiceExt::GetInstance();
103     int32_t num = 0;
104     vmServiceExt.handler_ = (void *)&num;
105     int fuseFd = 0;
106     std::string volumeId = {};
107     std::string fsUuid = {};
108     int32_t result = vmServiceExt.NotifyUsbFuseMount(fuseFd, volumeId, fsUuid);
109     EXPECT_NE(result, E_OK);
110     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-end Volume_manager_service_ext_NotifyUsbFuseMount_0000";
111 }
112 
113 /**
114  * @tc.number: SUB_STORAGE_Volume_manager_service_ext_NotifyUsbFuseMount_0001
115  * @tc.name: Volume_manager_service_ext_NotifyUsbFuseMount_0001
116  * @tc.desc: Test function of NotifyUsbFuseMount for UNSUCCESS.
117  * @tc.size: MEDIUM
118  * @tc.type: FUNC
119  * @tc.level Level 1
120  * @tc.require: SR000GGUPF
121  */
122 HWTEST_F(VolumeManagerServiceExtTest, Volume_manager_service_ext_NotifyUsbFuseMount_0001,
123     testing::ext::TestSize.Level1)
124 {
125     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-begin Volume_manager_service_ext_NotifyUsbFuseMount_0001";
126     auto &vmServiceExt =VolumeManagerServiceExt::GetInstance();
127     int fuseFd = 0;
128     std::string volumeId = {};
129     std::string fsUuid = {};
130     vmServiceExt.handler_ = nullptr;
131     int32_t result = vmServiceExt.NotifyUsbFuseMount(fuseFd, volumeId, fsUuid);
132     EXPECT_NE(result, E_OK);
133     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-end Volume_manager_service_ext_NotifyUsbFuseMount_0001";
134 }
135 
136 /**
137  * @tc.number: SUB_STORAGE_Volume_manager_service_ext_NotifyUsbFuseUmount_0000
138  * @tc.name: Volume_manager_service_ext_NotifyUsbFuseUmount_0000
139  * @tc.desc: Test function of NNotifyUsbFuseUmount for UNSUCCESS.
140  * @tc.size: MEDIUM
141  * @tc.type: FUNC
142  * @tc.level Level 1
143  * @tc.require: SR000GGUPF
144  */
145 HWTEST_F(VolumeManagerServiceExtTest, Volume_manager_service_ext_NotifyUsbFuseUmount_0000,
146     testing::ext::TestSize.Level1)
147 {
148     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-begin Volume_manager_service_ext_NotifyUsbFuseUmount_0000";
149     auto &vmServiceExt =VolumeManagerServiceExt::GetInstance();
150     int32_t num = 0;
151     vmServiceExt.handler_ = (void *)&num;
152     std::string volumeId = {};
153     int32_t result = vmServiceExt.NotifyUsbFuseUmount(volumeId);
154     EXPECT_NE(result, E_OK);
155     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-end Volume_manager_service_ext_NotifyUsbFuseUmount_0000";
156 }
157 
158 /**
159  * @tc.number: SUB_STORAGE_Volume_manager_service_ext_NotifyUsbFuseUmount_0001
160  * @tc.name: Volume_manager_service_ext_NotifyUsbFuseUmount_0001
161  * @tc.desc: Test function of NotifyUsbFuseUmount for UNSUCCESS.
162  * @tc.size: MEDIUM
163  * @tc.type: FUNC
164  * @tc.level Level 1
165  * @tc.require: SR000GGUPF
166  */
167 HWTEST_F(VolumeManagerServiceExtTest, Volume_manager_service_ext_NotifyUsbFuseUmount_0001,
168     testing::ext::TestSize.Level1)
169 {
170     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-begin Volume_manager_service_ext_NotifyUsbFuseUmount_0001";
171     auto &vmServiceExt =VolumeManagerServiceExt::GetInstance();
172     std::string volumeId = {};
173     vmServiceExt.handler_ = nullptr;
174     int32_t result = vmServiceExt.NotifyUsbFuseUmount(volumeId);
175     EXPECT_NE(result, E_OK);
176     GTEST_LOG_(INFO) << "VolumeManagerServiceExtTest-end Volume_manager_service_ext_NotifyUsbFuseUmount_0001";
177 }
178 } // namespace