• 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_skeleton.h"
20 #include "iservice_registry.h"
21 #include "system_ability_definition.h"
22 
23 #include "volume/volume_manager_service.h"
24 #include "ipc/storage_manager_proxy.h"
25 #include "storage_manager_service_mock.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 = 3;
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<StorageManager::IStorageManager>(remote);
66     ASSERT_TRUE(proxy != nullptr) << "fail to get proxy";
67     int32_t result = proxy->PrepareAddUser(userId, flag);
68     EXPECT_EQ(result, 0);
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 = 3;
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<StorageManager::IStorageManager>(remote);
92     ASSERT_TRUE(proxy != nullptr) << "fail to get proxy";
93     int32_t result = proxy->PrepareAddUser(userId, flag);
94     EXPECT_NE(result, 0);
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 = 3;
112     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
113     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
114     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
115     int32_t result = proxy->PrepareAddUser(userId, flag);
116     EXPECT_NE(result, 0);
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 = 3;
134     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
135     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
136     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
137     proxy->PrepareAddUser(userId, flag);
138     int32_t result = proxy->PrepareAddUser(userId, flag);
139     EXPECT_EQ(result, 0);
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 = 3;
158     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
159     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
160     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
161     proxy->PrepareAddUser(userId, flag);
162     int32_t result = proxy->RemoveUser(userId, flag);
163     EXPECT_EQ(result, 0);
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 = 3;
181     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
182     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
183     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
184     int32_t result = proxy->RemoveUser(userId, flag);
185     EXPECT_EQ(result, 0);
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 = 3;
203     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
204     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
205     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
206     proxy->PrepareAddUser(userId, flag);
207     int32_t result = proxy->RemoveUser(userId, flag);
208     EXPECT_NE(result, 0);
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 = 3;
226     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
227     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
228     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
229     proxy->PrepareAddUser(userId, flag);
230     int32_t result = proxy->PrepareStartUser(userId);
231     EXPECT_EQ(result, 0);
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<StorageManager::IStorageManager>(remote);
253     int32_t result = proxy->PrepareStartUser(userId);
254     EXPECT_NE(result, 0);
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 = 3;
272     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
273     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
274     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
275     proxy->PrepareAddUser(userId, flag);
276     int32_t result = proxy->PrepareStartUser(userId);
277     EXPECT_NE(result, 0);
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 = 3;
295     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
296     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
297     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
298     proxy->PrepareAddUser(userId, flag);
299     proxy->PrepareStartUser(userId);
300     int32_t result = proxy->StopUser(userId);
301     EXPECT_EQ(result, 0);
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<StorageManager::IStorageManager>(remote);
322     int32_t result = proxy->StopUser(userId);
323     EXPECT_NE(result, 0);
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 = 3;
341     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
342     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
343     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
344     proxy->PrepareAddUser(userId, flag);
345     int32_t result = proxy->StopUser(userId);
346     EXPECT_NE(result, 0);
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 = 3;
365     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
366     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
367     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
368     proxy->PrepareAddUser(userId, flag);
369     proxy->PrepareStartUser(userId);
370     int32_t result = proxy->StopUser(userId);
371     EXPECT_NE(result, 0);
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 = "111";
389     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
390     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
391     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
392     int64_t result = proxy->GetFreeSizeOfVolume(volumeUuid);
393     EXPECT_NE(result, 0);
394     GTEST_LOG_(INFO) << result;
395     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetFreeSizeOfVolume_0000";
396 }
397 
398 /**
399  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetTotalSizeOfVolume_0000
400  * @tc.name: Storage_manager_proxy_GetTotalSizeOfVolume_0000
401  * @tc.desc: Test function of GetTotalSizeOfVolume interface for SUCCESS.
402  * @tc.size: MEDIUM
403  * @tc.type: FUNC
404  * @tc.level Level 1
405  * @tc.require: AR000GK100
406  */
407 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetTotalSizeOfVolume_0000, testing::ext::TestSize.Level1)
408 {
409     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetTotalSizeOfVolume_0000";
410     std::string volumeUuid = "112";
411     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
412     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
413     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
414     int64_t result = proxy->GetTotalSizeOfVolume(volumeUuid);
415     EXPECT_NE(result, 0);
416     GTEST_LOG_(INFO) << result;
417     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetTotalSizeOfVolume_0000";
418 }
419 
420 /**
421  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetBundleStats_0000
422  * @tc.name: Storage_manager_proxy_GetBundleStats_0000
423  * @tc.desc: Test function of GetBundleStats interface for SUCCESS.
424  * @tc.size: MEDIUM
425  * @tc.type: FUNC
426  * @tc.level Level 1
427  * @tc.require: AR000GK101
428  */
429 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetBundleStats_0000, testing::ext::TestSize.Level1)
430 {
431     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetBundleStats_0000";
432     std::string pkgName = "ohos.acts.storage.volume";
433     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
434     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
435     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
436     std::vector<int64_t> result = proxy->GetBundleStats(pkgName);
437     GTEST_LOG_(INFO) << result[0];
438     GTEST_LOG_(INFO) << result[1];
439     GTEST_LOG_(INFO) << result[2];
440     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetBundleStats_0000";
441 }
442 
443 /**
444  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetBundleStats_0001
445  * @tc.name: Storage_manager_proxy_GetBundleStats_0001
446  * @tc.desc: Test function of GetBundleStats interface for Parameters ERROR which pkgName is not exist.
447  * @tc.size: MEDIUM
448  * @tc.type: FUNC
449  * @tc.level Level 1
450  * @tc.require: AR000GK101
451  */
452 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetBundleStats_0001, testing::ext::TestSize.Level1)
453 {
454     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetBundleStats_0001";
455     std::string pkgName = "ohos.acts.storage.zzzz";
456     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
457     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
458     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
459     std::vector<int64_t> result = proxy->GetBundleStats(pkgName);
460     GTEST_LOG_(INFO) << result[0];
461     GTEST_LOG_(INFO) << result[1];
462     GTEST_LOG_(INFO) << result[2];
463     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetBundleStats_0001";
464 }
465 
466 /**
467  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyVolumeCreated_0000
468  * @tc.name: Storage_manager_proxy_NotifyVolumeCreated_0001
469  * @tc.desc: Test function of NotifyVolumeCreated interface for SUCCESS.
470  * @tc.size: MEDIUM
471  * @tc.type: FUNC
472  * @tc.level Level 1
473  * @tc.require: SR000GGUPF
474  */
475 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyVolumeCreated_0000, testing::ext::TestSize.Level1)
476 {
477     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyVolumeCreated_0000";
478     VolumeCore vc;
479     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
480     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
481     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
482     proxy->NotifyVolumeCreated(vc);
483     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyVolumeCreated_0000";
484 }
485 
486 /**
487  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyVolumeMounted_0000
488  * @tc.name: Storage_manager_proxy_NotifyVolumeMounted_0001
489  * @tc.desc: Test function of NotifyVolumeMounted interface for SUCCESS.
490  * @tc.size: MEDIUM
491  * @tc.type: FUNC
492  * @tc.level Level 1
493  * @tc.require: SR000GGUPF
494  */
495 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyVolumeMounted_0000, testing::ext::TestSize.Level1)
496 {
497     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyVolumeMounted_0000";
498     std::string volumeId = "118";
499     int32_t fsType = 1;
500     std::string fsUuid = "119";
501     std::string path = "/";
502     std::string description = "130";
503     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
504     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
505     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
506     proxy->NotifyVolumeMounted(volumeId, fsType, fsUuid, path, description);
507     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyVolumeMounted_0000";
508 }
509 
510 /**
511  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyVolumeDestroyed_0000
512  * @tc.name: Storage_manager_proxy_NotifyVolumeDestroyed_0001
513  * @tc.desc: Test function of NotifyVolumeDestroyed interface for SUCCESS.
514  * @tc.size: MEDIUM
515  * @tc.type: FUNC
516  * @tc.level Level 1
517  * @tc.require: SR000GGUPF
518  */
519 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyVolumeDestroyed_0000, testing::ext::TestSize.Level1)
520 {
521     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyVolumeDestroyed_0000";
522     std::string volumeId = "120";
523     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
524     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
525     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
526     proxy->NotifyVolumeDestroyed(volumeId);
527     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyVolumeDestroyed_0000";
528 }
529 
530 /**
531  * @tc.number: SUB_STORAGE_Storage_manager_proxy_Mount_0000
532  * @tc.name: Storage_manager_proxy_Mount_0000
533  * @tc.desc: Test function of Mount interface for SUCCESS.
534  * @tc.size: MEDIUM
535  * @tc.type: FUNC
536  * @tc.level Level 1
537  * @tc.require: SR000GGUOT
538  */
539 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Mount_0000, testing::ext::TestSize.Level1)
540 {
541     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Mount_0000";
542     std::string volumeId = "121";
543     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
544         .Times(1)
545         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
546 
547     int32_t result = proxy_->Mount(volumeId);
548     EXPECT_EQ(result, 0);
549     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Mount_0000";
550 }
551 
552 /**
553  * @tc.number: SUB_STORAGE_Storage_manager_proxy_Unmount_0000
554  * @tc.name: Storage_manager_proxy_Unmount_0000
555  * @tc.desc: Test function of Unmount interface for SUCCESS.
556  * @tc.size: MEDIUM
557  * @tc.type: FUNC
558  * @tc.level Level 1
559  * @tc.require: SR000GGUOT
560  */
561 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Unmount_0000, testing::ext::TestSize.Level1)
562 {
563     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Unmount_0000";
564     std::string volumeId = "122";
565     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
566         .Times(1)
567         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
568 
569     int32_t result = proxy_->Unmount(volumeId);
570     EXPECT_EQ(result, 0);
571     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Unmount_0000";
572 }
573 
574 /**
575  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetAllVolumes_0000
576  * @tc.name: Storage_manager_proxy_GetAllVolumes_0000
577  * @tc.desc: Test function of GetAllVolumes interface for SUCCESS.
578  * @tc.size: MEDIUM
579  * @tc.type: FUNC
580  * @tc.level Level 1
581  * @tc.require: SR000GGUPF
582  */
583 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetAllVolumes_0000, testing::ext::TestSize.Level1)
584 {
585     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetAllVolumes_0000";
586     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
587     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
588     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
589     std::vector<VolumeExternal> result = proxy->GetAllVolumes();
590     EXPECT_NE(result.size(), 0);
591     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetAllVolumes_0000";
592 }
593 
594 /**
595  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyDiskCreated_0000
596  * @tc.name: Storage_manager_proxy_NotifyDiskCreated_0001
597  * @tc.desc: Test function of NotifyDiskCreated interface for SUCCESS.
598  * @tc.size: MEDIUM
599  * @tc.type: FUNC
600  * @tc.level Level 1
601  * @tc.require: SR000GGUPG
602  */
603 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyDiskCreated_0000, testing::ext::TestSize.Level1)
604 {
605     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyDiskCreated_0000";
606     std::string diskId = "124";
607     int64_t sizeBytes = 1024;
608     std::string sysPath = "/";
609     std::string vendor = "124";
610     int32_t flag = 1;
611     Disk disk(diskId, sizeBytes, sysPath, vendor, flag);
612     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
613     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
614     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
615     proxy->NotifyDiskCreated(disk);
616     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyDiskCreated_0000";
617 }
618 
619 /**
620  * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyDiskDestroyed_0000
621  * @tc.name: Storage_manager_proxy_NotifyDiskDestroyed_0001
622  * @tc.desc: Test function of NotifyDiskDestroyed interface for SUCCESS.
623  * @tc.size: MEDIUM
624  * @tc.type: FUNC
625  * @tc.level Level 1
626  * @tc.require: SR000GGUPG
627  */
628 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyDiskDestroyed_0000, testing::ext::TestSize.Level1)
629 {
630     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyDiskDestroyed_0000";
631     std::string diskId = "123";
632     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
633     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
634     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
635     proxy->NotifyDiskDestroyed(diskId);
636     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyDiskDestroyed_0000";
637 }
638 
639 /**
640  * @tc.number: SUB_STORAGE_Storage_manager_proxy_Partition_0000
641  * @tc.name: Storage_manager_proxy_Partition_0000
642  * @tc.desc: Test function of Partition interface for SUCCESS.
643  * @tc.size: MEDIUM
644  * @tc.type: FUNC
645  * @tc.level Level 1
646  * @tc.require: SR000GGUOT
647  */
648 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Partition_0000, testing::ext::TestSize.Level1)
649 {
650     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Partition_0000";
651     std::string volumeId = "121";
652     EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
653         .Times(1)
654         .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
655 
656     std::string diskId = "124";
657     int32_t type = 1;
658     int32_t result = proxy_->Partition(diskId, type);
659     EXPECT_EQ(result, 0);
660     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Partition_0000";
661 }
662 
663 /**
664  * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetAllDisks_0000
665  * @tc.name: Storage_manager_proxy_GetAllDisks_0000
666  * @tc.desc: Test function of GetAllDisks interface for SUCCESS.
667  * @tc.size: MEDIUM
668  * @tc.type: FUNC
669  * @tc.level Level 1
670  * @tc.require: SR000GGUPG
671  */
672 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetAllDisks_0000, testing::ext::TestSize.Level1)
673 {
674     GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetAllDisks_0000";
675     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
676     auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
677     auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
678     std::vector<Disk> result = proxy->GetAllDisks();
679     EXPECT_NE(result.size(), 0);
680     GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetAllDisks_0000";
681 }
682 } // namespace