• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstdio>
17 #include <gtest/gtest.h>
18 
19 #include "ipc/storage_manager_proxy.h"
20 #include "ipc/storage_manager.h"
21 #include "ipc_skeleton.h"
22 #include "iservice_registry.h"
23 #include "storage_manager_service_mock.h"
24 #include "system_ability_definition.h"
25 #include "volume/volume_manager_service.h"
26 
27 namespace {
28 using namespace std;
29 using namespace OHOS;
30 using namespace StorageManager;
31 class StorageManagerProxyTest : public testing::Test {
32 public:
SetUpTestCase(void)33     static void SetUpTestCase(void) {};
TearDownTestCase()34     static void TearDownTestCase() {};
35     void SetUp();
TearDown()36     void TearDown() {};
37     std::shared_ptr<StorageManagerProxy> proxy_ = nullptr;
38     sptr<StorageManagerServiceMock> mock_ = nullptr;
39 };
40 
SetUp()41 void StorageManagerProxyTest::SetUp()
42 {
43     mock_ = new StorageManagerServiceMock();
44     proxy_ = std::make_shared<StorageManagerProxy>(mock_);
45 }
46 
47 /**
48  * @tc.number: SUB_STORAGE_Storage_manager_proxy_PrepareAddUser_0000
49  * @tc.name: Storage_manager_proxy_PrepareAddUser_0000
50  * @tc.desc: Test function of PrepareAddUser interface for SUCCESS.
51  * @tc.size: MEDIUM
52  * @tc.type: FUNC
53  * @tc.level Level 1
54  * @tc.require: AR000GK4HB
55  */
56 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_PrepareAddUser_0000, testing::ext::TestSize.Level1)
57 {
58     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_PrepareAddUser_0000";
59     int32_t userId = 101;
60     uint32_t flag = CRYPTO_FLAG_EL1;
61     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
62     ASSERT_TRUE(samgr != nullptr) << "Storage_manager_proxy_PrepareAddUser_0000 fail to get GetSystemAbilityManager";
63     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
64     ASSERT_TRUE(remote != nullptr) << "GetSystemAbility failed";
65     auto proxy = iface_cast<IStorageManager>(remote);
66     ASSERT_TRUE(proxy != nullptr) << "fail to get proxy";
67     int32_t result = proxy->PrepareAddUser(userId, flag);
68     EXPECT_EQ(result, E_PERMISSION_DENIED);
69     proxy->RemoveUser(userId, flag);
70     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_PrepareAddUser_0000";
71 }
72 
73 /**
74  * @tc.number: SUB_STORAGE_Storage_manager_proxy_PrepareAddUser_0001
75  * @tc.name: Storage_manager_proxy_PrepareAddUser_0001
76  * @tc.desc: Test function of PrepareAddUser interface for Parameters ERROR which userId<0.
77  * @tc.size: MEDIUM
78  * @tc.type: FUNC
79  * @tc.level Level 1
80  * @tc.require: AR000GK4HB
81  */
82 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_PrepareAddUser_0001, testing::ext::TestSize.Level1)
83 {
84     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_PrepareAddUser_0001";
85     int32_t userId = -1;
86     uint32_t flag = CRYPTO_FLAG_EL1;
87     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
88     ASSERT_TRUE(samgr != nullptr) << "Storage_manager_proxy_PrepareAddUser_0001 fail to get GetSystemAbilityManager";
89     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
90     ASSERT_TRUE(remote != nullptr) << "GetSystemAbility failed";
91     auto proxy = iface_cast<IStorageManager>(remote);
92     ASSERT_TRUE(proxy != nullptr) << "fail to get proxy";
93     int32_t result = proxy->PrepareAddUser(userId, flag);
94     EXPECT_NE(result, E_OK);
95     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_PrepareAddUser_0001";
96 }
97 
98 /**
99  * @tc.number: SUB_STORAGE_Storage_manager_proxy_PrepareAddUser_0002
100  * @tc.name: Storage_manager_proxy_PrepareAddUser_0002
101  * @tc.desc: Test function of PrepareAddUser interface for Parameters ERROR which userId not in [101, 1099].
102  * @tc.size: MEDIUM
103  * @tc.type: FUNC
104  * @tc.level Level 1
105  * @tc.require: AR000GK4HB
106  */
107 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_PrepareAddUser_0002, testing::ext::TestSize.Level1)
108 {
109     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_PrepareAddUser_0002";
110     int32_t userId = 10000;
111     uint32_t flag = CRYPTO_FLAG_EL1;
112     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
113     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
114     auto proxy = iface_cast<IStorageManager>(remote);
115     int32_t result = proxy->PrepareAddUser(userId, flag);
116     EXPECT_NE(result, E_OK);
117     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_PrepareAddUser_0002";
118 }
119 
120 /**
121  * @tc.number: SUB_STORAGE_Storage_manager_proxy_PrepareAddUser_0003
122  * @tc.name: Storage_manager_proxy_PrepareAddUser_0003
123  * @tc.desc: Test function of PrepareAddUser interface for SUCCESS which Repeated add.
124  * @tc.size: MEDIUM
125  * @tc.type: FUNC
126  * @tc.level Level 1
127  * @tc.require: AR000GK4HB
128  */
129 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_PrepareAddUser_0003, testing::ext::TestSize.Level1)
130 {
131     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_PrepareAddUser_0003";
132     int32_t userId = 102;
133     uint32_t flag = CRYPTO_FLAG_EL1;
134     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
135     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
136     auto proxy = iface_cast<IStorageManager>(remote);
137     proxy->PrepareAddUser(userId, flag);
138     int32_t result = proxy->PrepareAddUser(userId, flag);
139     EXPECT_EQ(result, E_PERMISSION_DENIED);
140     proxy->RemoveUser(userId, flag);
141     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_PrepareAddUser_0003";
142 }
143 
144 /**
145  * @tc.number: SUB_STORAGE_Storage_manager_proxy_RemoveUser_0000
146  * @tc.name: Storage_manager_proxy_RemoveUser_0000
147  * @tc.desc: Test function of RemoveUser interface for SUCCESS.
148  * @tc.size: MEDIUM
149  * @tc.type: FUNC
150  * @tc.level Level 1
151  * @tc.require: AR000GK4HB
152  */
153 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_RemoveUser_0000, testing::ext::TestSize.Level1)
154 {
155     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_RemoveUser_0000";
156     int32_t userId = 103;
157     uint32_t flag = CRYPTO_FLAG_EL1;
158     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
159     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
160     auto proxy = iface_cast<IStorageManager>(remote);
161     proxy->PrepareAddUser(userId, flag);
162     int32_t result = proxy->RemoveUser(userId, flag);
163     EXPECT_EQ(result, E_PERMISSION_DENIED);
164     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_RemoveUser_0000";
165 }
166 
167 /**
168  * @tc.number: SUB_STORAGE_Storage_manager_proxy_RemoveUser_0001
169  * @tc.name: Storage_manager_proxy_RemoveUser_0001
170  * @tc.desc: Test function of RemoveUser interface for SUCCESS which remove userId not exist.
171  * @tc.size: MEDIUM
172  * @tc.type: FUNC
173  * @tc.level Level 1
174  * @tc.require: AR000GK4HB
175  */
176 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_RemoveUser_0001, testing::ext::TestSize.Level1)
177 {
178     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_RemoveUser_0001";
179     int32_t userId = 104;
180     uint32_t flag = CRYPTO_FLAG_EL1;
181     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
182     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
183     auto proxy = iface_cast<IStorageManager>(remote);
184     int32_t result = proxy->RemoveUser(userId, flag);
185     EXPECT_EQ(result, E_PERMISSION_DENIED);
186     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_RemoveUser_0001";
187 }
188 
189 /**
190  * @tc.number: SUB_STORAGE_Storage_manager_proxy_RemoveUser_0002
191  * @tc.name: Storage_manager_proxy_RemoveUser_0002
192  * @tc.desc: Test function of RemoveUser interface for Logic ERROR which userId<0.
193  * @tc.size: MEDIUM
194  * @tc.type: FUNC
195  * @tc.level Level 1
196  * @tc.require: AR000GK4HB
197  */
198 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_RemoveUser_0002, testing::ext::TestSize.Level1)
199 {
200     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_RemoveUser_0002";
201     int32_t userId = -2;
202     uint32_t flag = CRYPTO_FLAG_EL1;
203     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
204     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
205     auto proxy = iface_cast<IStorageManager>(remote);
206     proxy->PrepareAddUser(userId, flag);
207     int32_t result = proxy->RemoveUser(userId, flag);
208     EXPECT_NE(result, E_OK);
209     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_RemoveUser_0002";
210 }
211 
212 /**
213  * @tc.number: SUB_STORAGE_Storage_manager_proxy_PrepareStartUser_0000
214  * @tc.name: Storage_manager_proxy_PrepareStartUser_0000
215  * @tc.desc: Test function of PrepareStartUser interface for SUCCESS.
216  * @tc.size: MEDIUM
217  * @tc.type: FUNC
218  * @tc.level Level 1
219  * @tc.require: AR000GK4HB
220  */
221 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_PrepareStartUser_0000, testing::ext::TestSize.Level1)
222 {
223     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_PrepareStartUser_0000";
224     int32_t userId = 105;
225     uint32_t flag = CRYPTO_FLAG_EL2;
226     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
227     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
228     auto proxy = iface_cast<IStorageManager>(remote);
229     proxy->PrepareAddUser(userId, flag);
230     int32_t result = proxy->PrepareStartUser(userId);
231     EXPECT_EQ(result, E_PERMISSION_DENIED);
232     proxy->StopUser(userId);
233     proxy->RemoveUser(userId, flag);
234     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_PrepareStartUser_0000";
235 }
236 
237 /**
238  * @tc.number: SUB_STORAGE_Storage_manager_proxy_PrepareStartUser_0002
239  * @tc.name: Storage_manager_proxy_PrepareStartUser_0002
240  * @tc.desc: Test function of PrepareStartUser interface for Logic ERROR which start userId not exist.
241  * @tc.size: MEDIUM
242  * @tc.type: FUNC
243  * @tc.level Level 1
244  * @tc.require: AR000GK4HB
245  */
246 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_PrepareStartUser_0002, testing::ext::TestSize.Level1)
247 {
248     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_PrepareStartUser_0001";
249     int32_t userId = 107;
250     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
251     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
252     auto proxy = iface_cast<IStorageManager>(remote);
253     int32_t result = proxy->PrepareStartUser(userId);
254     EXPECT_NE(result, E_OK);
255     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_PrepareStartUser_0002";
256 }
257 
258 /**
259  * @tc.number: SUB_STORAGE_Storage_manager_proxy_PrepareStartUser_0003
260  * @tc.name: Storage_manager_proxy_PrepareStartUser_0003
261  * @tc.desc: Test function of PrepareStartUser interface for Logic ERROR which  userId<0.
262  * @tc.size: MEDIUM
263  * @tc.type: FUNC
264  * @tc.level Level 1
265  * @tc.require: AR000GK4HB
266  */
267 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_PrepareStartUser_0003, testing::ext::TestSize.Level1)
268 {
269     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_PrepareStartUser_0001";
270     int32_t userId = -3;
271     uint32_t flag = CRYPTO_FLAG_EL1;
272     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
273     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
274     auto proxy = iface_cast<IStorageManager>(remote);
275     proxy->PrepareAddUser(userId, flag);
276     int32_t result = proxy->PrepareStartUser(userId);
277     EXPECT_NE(result, E_OK);
278     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_PrepareStartUser_0003";
279 }
280 
281 /**
282  * @tc.number: SUB_STORAGE_Storage_manager_proxy_StopUser_0000
283  * @tc.name: Storage_manager_proxy_StopUser_0000
284  * @tc.desc: Test function of StopUser interface for SUCCESS.
285  * @tc.size: MEDIUM
286  * @tc.type: FUNC
287  * @tc.level Level 1
288  * @tc.require: AR000GK4HB
289  */
290 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_StopUser_0000, testing::ext::TestSize.Level1)
291 {
292     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_StopUser_0000";
293     int32_t userId = 108;
294     uint32_t flag = CRYPTO_FLAG_EL2;
295     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
296     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
297     auto proxy = iface_cast<IStorageManager>(remote);
298     proxy->PrepareAddUser(userId, flag);
299     proxy->PrepareStartUser(userId);
300     int32_t result = proxy->StopUser(userId);
301     EXPECT_EQ(result, E_PERMISSION_DENIED);
302     proxy->RemoveUser(userId, flag);
303     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_StopUser_0000";
304 }
305 
306 /**
307  * @tc.number: SUB_STORAGE_Storage_manager_proxy_StopUser_0001
308  * @tc.name: Storage_manager_proxy_StopUser_0001
309  * @tc.desc: Test function of StopUser interface for Logic ERROR which stop userId not exist.
310  * @tc.size: MEDIUM
311  * @tc.type: FUNC
312  * @tc.level Level 1
313  * @tc.require: AR000GK4HB
314  */
315 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_StopUser_0001, testing::ext::TestSize.Level1)
316 {
317     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_StopUser_0001";
318     int32_t userId = 109;
319     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
320     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
321     auto proxy = iface_cast<IStorageManager>(remote);
322     int32_t result = proxy->StopUser(userId);
323     EXPECT_NE(result, E_OK);
324     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_StopUser_0001";
325 }
326 
327 /**
328  * @tc.number: SUB_STORAGE_Storage_manager_proxy_StopUser_0002
329  * @tc.name: Storage_manager_proxy_StopUser_0002
330  * @tc.desc: Test function of StopUser interface for Logic ERROR which stop userId not start.
331  * @tc.size: MEDIUM
332  * @tc.type: FUNC
333  * @tc.level Level 1
334  * @tc.require: AR000GK4HB
335  */
336 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_StopUser_0002, testing::ext::TestSize.Level1)
337 {
338     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_StopUser_0002";
339     int32_t userId = 110;
340     uint32_t flag = CRYPTO_FLAG_EL1;
341     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
342     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
343     auto proxy = iface_cast<IStorageManager>(remote);
344     proxy->PrepareAddUser(userId, flag);
345     int32_t result = proxy->StopUser(userId);
346     EXPECT_NE(result, E_OK);
347     proxy->RemoveUser(userId, flag);
348     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_StopUser_0002";
349 }
350 
351 /**
352  * @tc.number: SUB_STORAGE_Storage_manager_proxy_StopUser_0003
353  * @tc.name: Storage_manager_proxy_StopUser_0003
354  * @tc.desc: Test function of StopUser interface for Logic ERROR which userId<0.
355  * @tc.size: MEDIUM
356  * @tc.type: FUNC
357  * @tc.level Level 1
358  * @tc.require: AR000GK4HB
359  */
360 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_StopUser_0003, testing::ext::TestSize.Level1)
361 {
362     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_StopUser_0003";
363     int32_t userId = -4;
364     uint32_t flag = CRYPTO_FLAG_EL1;
365     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
366     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
367     auto proxy = iface_cast<IStorageManager>(remote);
368     proxy->PrepareAddUser(userId, flag);
369     proxy->PrepareStartUser(userId);
370     int32_t result = proxy->StopUser(userId);
371     EXPECT_NE(result, E_OK);
372     proxy->RemoveUser(userId, flag);
373     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_StopUser_0003";
374 }
375 
376 /**
377  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetFreeSizeOfVolume_0000
378  * @tc.name: Storage_manager_proxy_GetFreeSizeOfVolume_0000
379  * @tc.desc: Test function of GetFreeSizeOfVolume interface for SUCCESS.
380  * @tc.size: MEDIUM
381  * @tc.type: FUNC
382  * @tc.level Level 1
383  * @tc.require: AR000GK100
384  */
385 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetFreeSizeOfVolume_0000, testing::ext::TestSize.Level1)
386 {
387     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetFreeSizeOfVolume_0000";
388     std::string volumeUuid = "uuid-1";
389     int64_t freeSize;
390     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
391         .Times(1)
392         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
393     int32_t result = proxy_->GetFreeSizeOfVolume(volumeUuid, freeSize);
394     EXPECT_EQ(result, E_OK);
395     GTEST_LOG_(INFO) << result;
396     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetFreeSizeOfVolume_0000";
397 }
398 
399 /**
400  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetTotalSizeOfVolume_0000
401  * @tc.name: Storage_manager_proxy_GetTotalSizeOfVolume_0000
402  * @tc.desc: Test function of GetTotalSizeOfVolume interface for SUCCESS.
403  * @tc.size: MEDIUM
404  * @tc.type: FUNC
405  * @tc.level Level 1
406  * @tc.require: AR000GK100
407  */
408 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetTotalSizeOfVolume_0000, testing::ext::TestSize.Level1)
409 {
410     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetTotalSizeOfVolume_0000";
411     std::string volumeUuid = "uuid-2";
412     int64_t totalSize;
413     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
414         .Times(1)
415         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
416     int32_t result = proxy_->GetTotalSizeOfVolume(volumeUuid, totalSize);
417     EXPECT_EQ(result, E_OK);
418     GTEST_LOG_(INFO) << result;
419     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetTotalSizeOfVolume_0000";
420 }
421 
422 /**
423  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetBundleStats_0000
424  * @tc.name: Storage_manager_proxy_GetBundleStats_0000
425  * @tc.desc: Test function of GetBundleStats interface for SUCCESS.
426  * @tc.size: MEDIUM
427  * @tc.type: FUNC
428  * @tc.level Level 1
429  * @tc.require: AR000GK101
430  */
431 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetBundleStats_0000, testing::ext::TestSize.Level1)
432 {
433     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetBundleStats_0000";
434     std::string pkgName = "ohos.acts.storage.volume";
435     BundleStats bundleStats;
436     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
437         .Times(1)
438         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
439     int32_t result = proxy_->GetBundleStats(pkgName, bundleStats);
440     EXPECT_EQ(result, E_OK);
441     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetBundleStats_0000";
442 }
443 
444 /**
445  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyVolumeCreated_0000
446  * @tc.name: Storage_manager_proxy_NotifyVolumeCreated_0001
447  * @tc.desc: Test function of NotifyVolumeCreated interface for SUCCESS.
448  * @tc.size: MEDIUM
449  * @tc.type: FUNC
450  * @tc.level Level 1
451  * @tc.require: SR000GGUPF
452  */
453 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyVolumeCreated_0000, testing::ext::TestSize.Level1)
454 {
455     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyVolumeCreated_0000";
456     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
457     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
458     auto proxy = iface_cast<IStorageManager>(remote);
459     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
460         .Times(1)
461         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
462     std::string volumeId = "vol-1-16";
463     int32_t fsType = 1;
464     std::string diskId = "disk-1-17";
465     VolumeCore vc(volumeId, fsType, diskId);
466     int64_t result = proxy_->NotifyVolumeCreated(vc);
467     EXPECT_EQ(result, E_OK);
468     GTEST_LOG_(INFO) << result;
469     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyVolumeCreated_0000";
470 }
471 
472 /**
473  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyVolumeMounted_0000
474  * @tc.name: Storage_manager_proxy_NotifyVolumeMounted_0001
475  * @tc.desc: Test function of NotifyVolumeMounted interface for SUCCESS.
476  * @tc.size: MEDIUM
477  * @tc.type: FUNC
478  * @tc.level Level 1
479  * @tc.require: SR000GGUPF
480  */
481 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyVolumeMounted_0000, testing::ext::TestSize.Level1)
482 {
483     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyVolumeMounted_0000";
484     std::string volumeId = "vol-1-18";
485     int32_t fsType = 1;
486     std::string fsUuid = "uuid-3";
487     std::string path = "/";
488     std::string description = "description-1";
489     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
490     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
491     auto proxy = iface_cast<IStorageManager>(remote);
492     int64_t result = proxy->NotifyVolumeMounted(volumeId, fsType, fsUuid, path, description);
493     EXPECT_EQ(result, E_PERMISSION_DENIED);
494     GTEST_LOG_(INFO) << result;
495     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyVolumeMounted_0000";
496 }
497 
498 /**
499  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyVolumeDestroyed_0000
500  * @tc.name: Storage_manager_proxy_NotifyVolumeDestroyed_0001
501  * @tc.desc: Test function of NotifyVolumeDestroyed interface for SUCCESS.
502  * @tc.size: MEDIUM
503  * @tc.type: FUNC
504  * @tc.level Level 1
505  * @tc.require: SR000GGUPF
506  */
507 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyVolumeDestroyed_0000, testing::ext::TestSize.Level1)
508 {
509     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyVolumeDestroyed_0000";
510     std::string volumeId = "vol-1-20";
511     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
512     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
513     auto proxy = iface_cast<IStorageManager>(remote);
514     int64_t result = proxy->NotifyVolumeDestroyed(volumeId);
515     EXPECT_EQ(result, E_PERMISSION_DENIED);
516     GTEST_LOG_(INFO) << result;
517     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyVolumeDestroyed_0000";
518 }
519 
520 /**
521  * @tc.number: SUB_STORAGE_Storage_manager_proxy_Mount_0000
522  * @tc.name: Storage_manager_proxy_Mount_0000
523  * @tc.desc: Test function of Mount interface for SUCCESS.
524  * @tc.size: MEDIUM
525  * @tc.type: FUNC
526  * @tc.level Level 1
527  * @tc.require: SR000GGUOT
528  */
529 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Mount_0000, testing::ext::TestSize.Level1)
530 {
531     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Mount_0000";
532     std::string volumeId = "vol-1-21";
533     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
534         .Times(1)
535         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
536 
537     int32_t result = proxy_->Mount(volumeId);
538     EXPECT_EQ(result, E_OK);
539     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Mount_0000";
540 }
541 
542 /**
543  * @tc.number: SUB_STORAGE_Storage_manager_proxy_Unmount_0000
544  * @tc.name: Storage_manager_proxy_Unmount_0000
545  * @tc.desc: Test function of Unmount interface for SUCCESS.
546  * @tc.size: MEDIUM
547  * @tc.type: FUNC
548  * @tc.level Level 1
549  * @tc.require: SR000GGUOT
550  */
551 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Unmount_0000, testing::ext::TestSize.Level1)
552 {
553     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Unmount_0000";
554     std::string volumeId = "vol-1-22";
555     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
556         .Times(1)
557         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
558 
559     int32_t result = proxy_->Unmount(volumeId);
560     EXPECT_EQ(result, E_OK);
561     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Unmount_0000";
562 }
563 
564 /**
565  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetAllVolumes_0000
566  * @tc.name: Storage_manager_proxy_GetAllVolumes_0000
567  * @tc.desc: Test function of GetAllVolumes interface for SUCCESS.
568  * @tc.size: MEDIUM
569  * @tc.type: FUNC
570  * @tc.level Level 1
571  * @tc.require: SR000GGUPF
572  */
573 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetAllVolumes_0000, testing::ext::TestSize.Level1)
574 {
575     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetAllVolumes_0000";
576     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
577         .Times(1)
578         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
579     std::vector<VolumeExternal> vecOfVol;
580     int32_t result = proxy_->GetAllVolumes(vecOfVol);
581     EXPECT_EQ(result, E_OK);
582     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetAllVolumes_0000";
583 }
584 
585 /**
586  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyDiskCreated_0000
587  * @tc.name: Storage_manager_proxy_NotifyDiskCreated_0001
588  * @tc.desc: Test function of NotifyDiskCreated interface for SUCCESS.
589  * @tc.size: MEDIUM
590  * @tc.type: FUNC
591  * @tc.level Level 1
592  * @tc.require: SR000GGUPG
593  */
594 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyDiskCreated_0000, testing::ext::TestSize.Level1)
595 {
596     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyDiskCreated_0000";
597     std::string diskId = "disk-1-23";
598     int64_t sizeBytes = 1024;
599     std::string sysPath = "/";
600     std::string vendor = "vendor-1";
601     int32_t flag = 1; // disk type
602     Disk disk(diskId, sizeBytes, sysPath, vendor, flag);
603     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
604     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
605     auto proxy = iface_cast<IStorageManager>(remote);
606     proxy->NotifyDiskCreated(disk);
607     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyDiskCreated_0000";
608 }
609 
610 /**
611  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyDiskDestroyed_0000
612  * @tc.name: Storage_manager_proxy_NotifyDiskDestroyed_0001
613  * @tc.desc: Test function of NotifyDiskDestroyed interface for SUCCESS.
614  * @tc.size: MEDIUM
615  * @tc.type: FUNC
616  * @tc.level Level 1
617  * @tc.require: SR000GGUPG
618  */
619 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyDiskDestroyed_0000, testing::ext::TestSize.Level1)
620 {
621     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyDiskDestroyed_0000";
622     std::string diskId = "disk-1-24";
623     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
624     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
625     auto proxy = iface_cast<IStorageManager>(remote);
626     proxy->NotifyDiskDestroyed(diskId);
627     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyDiskDestroyed_0000";
628 }
629 
630 /**
631  * @tc.number: SUB_STORAGE_Storage_manager_proxy_Partition_0000
632  * @tc.name: Storage_manager_proxy_Partition_0000
633  * @tc.desc: Test function of Partition interface for SUCCESS.
634  * @tc.size: MEDIUM
635  * @tc.type: FUNC
636  * @tc.level Level 1
637  * @tc.require: SR000GGUOT
638  */
639 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Partition_0000, testing::ext::TestSize.Level1)
640 {
641     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Partition_0000";
642     std::string volumeId = "vol-1-25";
643     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
644         .Times(1)
645         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
646     std::string diskId = "disk-1-25";
647     int32_t type = 1;
648     int32_t result = proxy_->Partition(diskId, type);
649     EXPECT_EQ(result, E_OK);
650     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Partition_0000";
651 }
652 
653 /**
654  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetAllDisks_0000
655  * @tc.name: Storage_manager_proxy_GetAllDisks_0000
656  * @tc.desc: Test function of GetAllDisks interface for SUCCESS.
657  * @tc.size: MEDIUM
658  * @tc.type: FUNC
659  * @tc.level Level 1
660  * @tc.require: SR000GGUPG
661  */
662 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetAllDisks_0000, testing::ext::TestSize.Level1)
663 {
664     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetAllDisks_0000";
665     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
666         .Times(1)
667         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
668     std::vector<Disk> vecOfDisk;
669     int32_t result = proxy_->GetAllDisks(vecOfDisk);
670     EXPECT_EQ(result, E_OK);
671     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetAllDisks_0000";
672 }
673 
674 /**
675  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetSystemSize_0000
676  * @tc.name: Storage_manager_proxy_GetSystemSize_0000
677  * @tc.desc: Test function of GetSystemSize interface for SUCCESS.
678  * @tc.size: MEDIUM
679  * @tc.type: FUNC
680  * @tc.level Level 1
681  * @tc.require: SR000H0372
682  */
683 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetSystemSize_0000, testing::ext::TestSize.Level1)
684 {
685     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetSystemSize_0000";
686     int64_t systemSize;
687     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
688         .Times(1)
689         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
690     int32_t result = proxy_->GetSystemSize(systemSize);
691     EXPECT_GE(result, E_OK);
692     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetSystemSize_0000";
693 }
694 
695 /**
696  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetTotalSize_0000
697  * @tc.name: Storage_manager_proxy_GetTotalSize_0000
698  * @tc.desc: Test function of GetTotalSize interface for SUCCESS.
699  * @tc.size: MEDIUM
700  * @tc.type: FUNC
701  * @tc.level Level 1
702  * @tc.require: SR000H0371
703  */
704 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetTotalSize_0000, testing::ext::TestSize.Level1)
705 {
706     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetTotalSize_0000";
707     int64_t totalSize;
708     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
709         .Times(1)
710         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
711     int32_t result = proxy_->GetTotalSize(totalSize);
712     EXPECT_GE(result, E_OK);
713     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetTotalSize_0000";
714 }
715 
716 /**
717  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetFreeSize_0000
718  * @tc.name: Storage_manager_proxy_GetFreeSize_0000
719  * @tc.desc: Test function of GetFreeSize interface for SUCCESS.
720  * @tc.size: MEDIUM
721  * @tc.type: FUNC
722  * @tc.level Level 1
723  * @tc.require: SR000H0371
724  */
725 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetFreeSize_0000, testing::ext::TestSize.Level1)
726 {
727     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetFreeSize_0000";
728     int64_t FreeSize;
729     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
730         .Times(1)
731         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
732     int32_t result = proxy_->GetFreeSize(FreeSize);
733     EXPECT_GE(result, E_OK);
734     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetFreeSize_0000";
735 }
736 
737 /**
738  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetUserStorageStats_0000
739  * @tc.name: Storage_manager_proxy_GetUserStorageStats_0000
740  * @tc.desc: Test function of GetUserStorageStats interface for SUCCESS.
741  * @tc.size: MEDIUM
742  * @tc.type: FUNC
743  * @tc.level Level 1
744  * @tc.require: SR000H0373
745  */
746 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetUserStorageStats_0000, testing::ext::TestSize.Level1)
747 {
748     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetUserStorageStats_0000";
749     StorageStats storageStats;
750     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
751         .Times(1)
752         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
753     int32_t result = proxy_->GetUserStorageStats(storageStats);
754     EXPECT_GE(result, E_OK);
755     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetUserStorageStats_0000";
756 }
757 
758 /**
759  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetUserStorageStats_0001
760  * @tc.name: Storage_manager_proxy_GetUserStorageStats_0001
761  * @tc.desc: Test function of GetUserStorageStats interface for SUCCESS.
762  * @tc.size: MEDIUM
763  * @tc.type: FUNC
764  * @tc.level Level 1
765  * @tc.require: SR000H0373
766  */
767 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetUserStorageStats_0001, testing::ext::TestSize.Level1)
768 {
769     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetUserStorageStats_0001";
770     StorageStats storageStats;
771     int32_t userId = 111;
772     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
773         .Times(1)
774         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
775     int32_t result = proxy_->GetUserStorageStats(userId, storageStats);
776     EXPECT_GE(result, E_OK);
777     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetUserStorageStats_0001";
778 }
779 
780 /**
781  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetVolumeByUuid_0000
782  * @tc.name: Storage_manager_proxy_GetVolumeByUuid_0000
783  * @tc.desc: Test function of GetVolumeByUuid interface for SUCCESS.
784  * @tc.size: MEDIUM
785  * @tc.type: FUNC
786  * @tc.level Level 1
787  * @tc.require: AR000H09L6
788  */
789 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetVolumeByUuid_0000, testing::ext::TestSize.Level1)
790 {
791     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetVolumeByUuid_0000";
792     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
793         .Times(1)
794         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
795     std::string fsUuid = "uuid-4";
796     VolumeExternal ve;
797     int64_t result = proxy_->GetVolumeByUuid(fsUuid, ve);
798     EXPECT_EQ(result, E_OK);
799     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetVolumeByUuid_0000";
800 }
801 
802 /**
803  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetVolumeById_0000
804  * @tc.name: Storage_manager_proxy_GetVolumeById_0000
805  * @tc.desc: Test function of GetVolumeById interface for SUCCESS.
806  * @tc.size: MEDIUM
807  * @tc.type: FUNC
808  * @tc.level Level 1
809  * @tc.require: AR000H09L6
810  */
811 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetVolumeById_0000, testing::ext::TestSize.Level1)
812 {
813     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetVolumeById_0000";
814     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
815     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
816     auto proxy = iface_cast<IStorageManager>(remote);
817     std::string volumeId = "vol-1-27";
818     int32_t fsType = 1;
819     std::string fsUuid = "uuid-5";
820     std::string diskId = "disk-1-27";
821     VolumeCore vc(volumeId, fsType, diskId);
822     proxy->NotifyVolumeCreated(vc);
823     VolumeExternal ve;
824     int64_t result = proxy->GetVolumeById(volumeId, ve);
825     EXPECT_EQ(result, E_PERMISSION_DENIED);
826     proxy->NotifyVolumeDestroyed(volumeId);
827     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetVolumeById_0000";
828 }
829 
830 /**
831  * @tc.number: SUB_STORAGE_Storage_manager_proxy_SetVolumeDescription_0000
832  * @tc.name: Storage_manager_proxy_SetVolumeDescription_0000
833  * @tc.desc: Test function of SetVolumeDescription interface for SUCCESS.
834  * @tc.size: MEDIUM
835  * @tc.type: FUNC
836  * @tc.level Level 1
837  * @tc.require: AR000H09L6
838  */
839 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_SetVolumeDescription_0000, testing::ext::TestSize.Level1)
840 {
841     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_SetVolumeDescription_0000";
842     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
843         .Times(1)
844         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
845     std::string fsUuid = "uuid-6";
846     string description = "description-1";
847     int64_t result = proxy_->SetVolumeDescription(fsUuid, description);
848     EXPECT_EQ(result, E_OK);
849     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_SetVolumeDescription_0000";
850 }
851 
852 /**
853  * @tc.number: SUB_STORAGE_Storage_manager_proxy_Format_0000
854  * @tc.name: Storage_manager_proxy_Format_0000
855  * @tc.desc: Test function of Format interface for SUCCESS.
856  * @tc.size: MEDIUM
857  * @tc.type: FUNC
858  * @tc.level Level 1
859  * @tc.require: AR000H09L6
860  */
861 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Format_0000, testing::ext::TestSize.Level1)
862 {
863     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Format_0000";
864     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
865         .Times(1)
866         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
867     std::string volumeId = "vol-1-29";
868     string fsTypes = "1";
869     int64_t result = proxy_->Format(volumeId, fsTypes);
870     EXPECT_EQ(result, E_OK);
871     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Format_0000";
872 }
873 
874 /**
875  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetDiskById_0000
876  * @tc.name: Storage_manager_proxy_GetDiskById_0000
877  * @tc.desc: Test function of GetDiskById interface for SUCCESS.
878  * @tc.size: MEDIUM
879  * @tc.type: FUNC
880  * @tc.level Level 1
881  * @tc.require: AR000H09L6
882  */
883 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetDiskById_0000, testing::ext::TestSize.Level1)
884 {
885     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetDiskById_0000";
886     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
887     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
888     auto proxy = iface_cast<IStorageManager>(remote);
889     std::string diskId = "disk-1-30";
890     int64_t sizeBytes = 1024;
891     std::string sysPath = "/";
892     std::string vendor = "vendor-1";
893     int32_t flag = 1; // disk type
894     Disk disk(diskId, sizeBytes, sysPath, vendor, flag);
895     proxy->NotifyDiskCreated(disk);
896     int64_t result = proxy->GetDiskById(diskId, disk);
897     EXPECT_EQ(result, E_PERMISSION_DENIED);
898     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetDiskById_0000";
899 }
900 
901 /**
902  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GenerateUserKeys_0000
903  * @tc.name: Storage_manager_proxy_GenerateUserKeys_0000
904  * @tc.desc: Test function of GenerateUserKeys interface for SUCCESS.
905  * @tc.size: MEDIUM
906  * @tc.type: FUNC
907  * @tc.level Level 1
908  * @tc.require: AR000H0F7I
909  */
910 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GenerateUserKeys_0000, testing::ext::TestSize.Level1)
911 {
912     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GenerateUserKeys_0000";
913     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
914         .Times(1)
915         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
916     uint32_t userId = 112;
917     uint32_t flags = 2; // UserKeys type
918     uint32_t result = proxy_->GenerateUserKeys(userId, flags);
919     EXPECT_EQ(result, E_OK);
920     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GenerateUserKeys_0000";
921 }
922 
923 /**
924  * @tc.number: SUB_STORAGE_Storage_manager_proxy_DeleteUserKeys_0000
925  * @tc.name: Storage_manager_proxy_DeleteUserKeys_0000
926  * @tc.desc: Test function of DeleteUserKeys interface for SUCCESS.
927  * @tc.size: MEDIUM
928  * @tc.type: FUNC
929  * @tc.level Level 1
930  * @tc.require: AR000H0F7I
931  */
932 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_DeleteUserKeys_0000, testing::ext::TestSize.Level1)
933 {
934     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_DeleteUserKeys_0000";
935     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
936         .Times(1)
937         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
938     uint32_t userId = 113;
939     uint32_t result = proxy_->DeleteUserKeys(userId);
940     EXPECT_EQ(result, E_OK);
941     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_DeleteUserKeys_0000";
942 }
943 
944 /**
945  * @tc.number: SUB_STORAGE_Storage_manager_proxy_UpdateUserAuth_0000
946  * @tc.name: Storage_manager_proxy_UpdateUserAuth_0000
947  * @tc.desc: Test function of UpdateUserAuth interface for SUCCESS.
948  * @tc.size: MEDIUM
949  * @tc.type: FUNC
950  * @tc.level Level 1
951  * @tc.require: AR000H0FG3
952  */
953 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_UpdateUserAuth_0000, testing::ext::TestSize.Level1)
954 {
955     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_UpdateUserAuth_0000";
956     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
957         .Times(1)
958         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
959     uint32_t userId = 114;
960     uint32_t result = proxy_->UpdateUserAuth(userId, {}, {}, {});
961     EXPECT_EQ(result, E_OK);
962     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_UpdateUserAuth_0000";
963 }
964 
965 /**
966  * @tc.number: SUB_STORAGE_Storage_manager_proxy_ActiveUserKey_0000
967  * @tc.name: Storage_manager_proxy_ActiveUserKey_0000
968  * @tc.desc: Test function of ActiveUserKey interface for SUCCESS.
969  * @tc.size: MEDIUM
970  * @tc.type: FUNC
971  * @tc.level Level 1
972  * @tc.require: AR000H0FG3
973  */
974 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_ActiveUserKey_0000, testing::ext::TestSize.Level1)
975 {
976     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_ActiveUserKey_0000";
977     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
978         .Times(1)
979         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
980     uint32_t userId = 115;
981     uint32_t result = proxy_->ActiveUserKey(userId, {}, {});
982     EXPECT_EQ(result, E_OK);
983     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_ActiveUserKey_0000";
984 }
985 
986 /**
987  * @tc.number: SUB_STORAGE_Storage_manager_proxy_InactiveUserKey_0000
988  * @tc.name: Storage_manager_proxy_InactiveUserKey_0000
989  * @tc.desc: Test function of InactiveUserKey interface for SUCCESS.
990  * @tc.size: MEDIUM
991  * @tc.type: FUNC
992  * @tc.level Level 1
993  * @tc.require: AR000H0F7I
994  */
995 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_InactiveUserKey_0000, testing::ext::TestSize.Level1)
996 {
997     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_InactiveUserKey_0000";
998     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
999         .Times(1)
1000         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
1001     uint32_t userId = 116;
1002     uint32_t result = proxy_->InactiveUserKey(userId);
1003     EXPECT_EQ(result, E_OK);
1004     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_InactiveUserKey_0000";
1005 }
1006 
1007 /**
1008  * @tc.number: SUB_STORAGE_Storage_manager_proxy_UpdateKeyContext_0000
1009  * @tc.name: Storage_manager_proxy_UpdateKeyContext_0000
1010  * @tc.desc: Test function of UpdateKeyContext interface for SUCCESS.
1011  * @tc.size: MEDIUM
1012  * @tc.type: FUNC
1013  * @tc.level Level 1
1014  * @tc.require: AR000H0F7I
1015  */
1016 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_UpdateKeyContext_0000, testing::ext::TestSize.Level1)
1017 {
1018     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_UpdateKeyContext_0000";
1019     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
1020         .Times(1)
1021         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
1022     uint32_t userId = 117;
1023     uint32_t result = proxy_->UpdateKeyContext(userId);
1024     EXPECT_EQ(result, E_OK);
1025     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_UpdateKeyContext_0000";
1026 }
1027 
1028 /**
1029  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetCurrentBundleStats_0000
1030  * @tc.name: Storage_manager_proxy_GetCurrentBundleStats_0000
1031  * @tc.desc: Test function of GetCurrentBundleStats interface for SUCCESS.
1032  * @tc.size: MEDIUM
1033  * @tc.type: FUNC
1034  * @tc.level Level 1
1035  * @tc.require: AR000H0F7I
1036  */
1037 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetCurrentBundleStats_0000, testing::ext::TestSize.Level1)
1038 {
1039     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetCurrentBundleStats_0000";
1040     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
1041         .Times(1)
1042         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
1043     BundleStats bundleStats;
1044     int32_t result = proxy_->GetCurrentBundleStats(bundleStats);
1045     EXPECT_EQ(result, E_OK);
1046     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetCurrentBundleStats_0000";
1047 }
1048 } // namespace