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 "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->NotifyVolumeStateChanged(volumeId, VolumeState::BAD_REMOVAL);
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 int32_t result = proxy->NotifyDiskCreated(disk);
607 EXPECT_EQ(result, E_PERMISSION_DENIED);
608 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyDiskCreated_0000";
609 }
610
611 /**
612 * @tc.number: SUB_STORAGE_Storage_manager_proxy_NotifyDiskDestroyed_0000
613 * @tc.name: Storage_manager_proxy_NotifyDiskDestroyed_0001
614 * @tc.desc: Test function of NotifyDiskDestroyed interface for SUCCESS.
615 * @tc.size: MEDIUM
616 * @tc.type: FUNC
617 * @tc.level Level 1
618 * @tc.require: SR000GGUPG
619 */
620 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyDiskDestroyed_0000, testing::ext::TestSize.Level1)
621 {
622 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_NotifyDiskDestroyed_0000";
623 std::string diskId = "disk-1-24";
624 auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
625 auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
626 auto proxy = iface_cast<IStorageManager>(remote);
627 int32_t result = proxy->NotifyDiskDestroyed(diskId);
628 EXPECT_EQ(result, E_PERMISSION_DENIED);
629 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyDiskDestroyed_0000";
630 }
631
632 /**
633 * @tc.number: SUB_STORAGE_Storage_manager_proxy_Partition_0000
634 * @tc.name: Storage_manager_proxy_Partition_0000
635 * @tc.desc: Test function of Partition interface for SUCCESS.
636 * @tc.size: MEDIUM
637 * @tc.type: FUNC
638 * @tc.level Level 1
639 * @tc.require: SR000GGUOT
640 */
641 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Partition_0000, testing::ext::TestSize.Level1)
642 {
643 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Partition_0000";
644 std::string volumeId = "vol-1-25";
645 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
646 .Times(1)
647 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
648 std::string diskId = "disk-1-25";
649 int32_t type = 1;
650 int32_t result = proxy_->Partition(diskId, type);
651 EXPECT_EQ(result, E_OK);
652 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Partition_0000";
653 }
654
655 /**
656 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetAllDisks_0000
657 * @tc.name: Storage_manager_proxy_GetAllDisks_0000
658 * @tc.desc: Test function of GetAllDisks interface for SUCCESS.
659 * @tc.size: MEDIUM
660 * @tc.type: FUNC
661 * @tc.level Level 1
662 * @tc.require: SR000GGUPG
663 */
664 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetAllDisks_0000, testing::ext::TestSize.Level1)
665 {
666 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetAllDisks_0000";
667 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
668 .Times(1)
669 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
670 std::vector<Disk> vecOfDisk;
671 int32_t result = proxy_->GetAllDisks(vecOfDisk);
672 EXPECT_EQ(result, E_OK);
673 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetAllDisks_0000";
674 }
675
676 /**
677 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetSystemSize_0000
678 * @tc.name: Storage_manager_proxy_GetSystemSize_0000
679 * @tc.desc: Test function of GetSystemSize interface for SUCCESS.
680 * @tc.size: MEDIUM
681 * @tc.type: FUNC
682 * @tc.level Level 1
683 * @tc.require: SR000H0372
684 */
685 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetSystemSize_0000, testing::ext::TestSize.Level1)
686 {
687 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetSystemSize_0000";
688 int64_t systemSize;
689 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
690 .Times(1)
691 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
692 int32_t result = proxy_->GetSystemSize(systemSize);
693 EXPECT_GE(result, E_OK);
694 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetSystemSize_0000";
695 }
696
697 /**
698 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetTotalSize_0000
699 * @tc.name: Storage_manager_proxy_GetTotalSize_0000
700 * @tc.desc: Test function of GetTotalSize interface for SUCCESS.
701 * @tc.size: MEDIUM
702 * @tc.type: FUNC
703 * @tc.level Level 1
704 * @tc.require: SR000H0371
705 */
706 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetTotalSize_0000, testing::ext::TestSize.Level1)
707 {
708 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetTotalSize_0000";
709 int64_t totalSize;
710 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
711 .Times(1)
712 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
713 int32_t result = proxy_->GetTotalSize(totalSize);
714 EXPECT_GE(result, E_OK);
715 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetTotalSize_0000";
716 }
717
718 /**
719 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetFreeSize_0000
720 * @tc.name: Storage_manager_proxy_GetFreeSize_0000
721 * @tc.desc: Test function of GetFreeSize interface for SUCCESS.
722 * @tc.size: MEDIUM
723 * @tc.type: FUNC
724 * @tc.level Level 1
725 * @tc.require: SR000H0371
726 */
727 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetFreeSize_0000, testing::ext::TestSize.Level1)
728 {
729 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetFreeSize_0000";
730 int64_t FreeSize;
731 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
732 .Times(1)
733 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
734 int32_t result = proxy_->GetFreeSize(FreeSize);
735 EXPECT_GE(result, E_OK);
736 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetFreeSize_0000";
737 }
738
739 /**
740 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetUserStorageStats_0000
741 * @tc.name: Storage_manager_proxy_GetUserStorageStats_0000
742 * @tc.desc: Test function of GetUserStorageStats interface for SUCCESS.
743 * @tc.size: MEDIUM
744 * @tc.type: FUNC
745 * @tc.level Level 1
746 * @tc.require: SR000H0373
747 */
748 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetUserStorageStats_0000, testing::ext::TestSize.Level1)
749 {
750 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetUserStorageStats_0000";
751 StorageStats storageStats;
752 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
753 .Times(1)
754 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
755 int32_t result = proxy_->GetUserStorageStats(storageStats);
756 EXPECT_GE(result, E_OK);
757 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetUserStorageStats_0000";
758 }
759
760 /**
761 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetUserStorageStats_0001
762 * @tc.name: Storage_manager_proxy_GetUserStorageStats_0001
763 * @tc.desc: Test function of GetUserStorageStats interface for SUCCESS.
764 * @tc.size: MEDIUM
765 * @tc.type: FUNC
766 * @tc.level Level 1
767 * @tc.require: SR000H0373
768 */
769 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetUserStorageStats_0001, testing::ext::TestSize.Level1)
770 {
771 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetUserStorageStats_0001";
772 StorageStats storageStats;
773 int32_t userId = 111;
774 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
775 .Times(1)
776 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
777 int32_t result = proxy_->GetUserStorageStats(userId, storageStats);
778 EXPECT_GE(result, E_OK);
779 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetUserStorageStats_0001";
780 }
781
782 /**
783 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetVolumeByUuid_0000
784 * @tc.name: Storage_manager_proxy_GetVolumeByUuid_0000
785 * @tc.desc: Test function of GetVolumeByUuid interface for SUCCESS.
786 * @tc.size: MEDIUM
787 * @tc.type: FUNC
788 * @tc.level Level 1
789 * @tc.require: AR000H09L6
790 */
791 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetVolumeByUuid_0000, testing::ext::TestSize.Level1)
792 {
793 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetVolumeByUuid_0000";
794 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
795 .Times(1)
796 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
797 std::string fsUuid = "uuid-4";
798 VolumeExternal ve;
799 int64_t result = proxy_->GetVolumeByUuid(fsUuid, ve);
800 EXPECT_EQ(result, E_OK);
801 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetVolumeByUuid_0000";
802 }
803
804 /**
805 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetVolumeById_0000
806 * @tc.name: Storage_manager_proxy_GetVolumeById_0000
807 * @tc.desc: Test function of GetVolumeById interface for SUCCESS.
808 * @tc.size: MEDIUM
809 * @tc.type: FUNC
810 * @tc.level Level 1
811 * @tc.require: AR000H09L6
812 */
813 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetVolumeById_0000, testing::ext::TestSize.Level1)
814 {
815 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetVolumeById_0000";
816 auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
817 auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
818 auto proxy = iface_cast<IStorageManager>(remote);
819 std::string volumeId = "vol-1-27";
820 int32_t fsType = 1;
821 std::string fsUuid = "uuid-5";
822 std::string diskId = "disk-1-27";
823 VolumeCore vc(volumeId, fsType, diskId);
824 proxy->NotifyVolumeCreated(vc);
825 VolumeExternal ve;
826 int64_t result = proxy->GetVolumeById(volumeId, ve);
827 EXPECT_EQ(result, E_PERMISSION_DENIED);
828 proxy->NotifyVolumeStateChanged(volumeId, VolumeState::BAD_REMOVAL);
829 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetVolumeById_0000";
830 }
831
832 /**
833 * @tc.number: SUB_STORAGE_Storage_manager_proxy_SetVolumeDescription_0000
834 * @tc.name: Storage_manager_proxy_SetVolumeDescription_0000
835 * @tc.desc: Test function of SetVolumeDescription interface for SUCCESS.
836 * @tc.size: MEDIUM
837 * @tc.type: FUNC
838 * @tc.level Level 1
839 * @tc.require: AR000H09L6
840 */
841 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_SetVolumeDescription_0000, testing::ext::TestSize.Level1)
842 {
843 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_SetVolumeDescription_0000";
844 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
845 .Times(1)
846 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
847 std::string fsUuid = "uuid-6";
848 string description = "description-1";
849 int64_t result = proxy_->SetVolumeDescription(fsUuid, description);
850 EXPECT_EQ(result, E_OK);
851 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_SetVolumeDescription_0000";
852 }
853
854 /**
855 * @tc.number: SUB_STORAGE_Storage_manager_proxy_Format_0000
856 * @tc.name: Storage_manager_proxy_Format_0000
857 * @tc.desc: Test function of Format interface for SUCCESS.
858 * @tc.size: MEDIUM
859 * @tc.type: FUNC
860 * @tc.level Level 1
861 * @tc.require: AR000H09L6
862 */
863 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_Format_0000, testing::ext::TestSize.Level1)
864 {
865 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_Format_0000";
866 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
867 .Times(1)
868 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
869 std::string volumeId = "vol-1-29";
870 string fsTypes = "1";
871 int64_t result = proxy_->Format(volumeId, fsTypes);
872 EXPECT_EQ(result, E_OK);
873 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_Format_0000";
874 }
875
876 /**
877 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetDiskById_0000
878 * @tc.name: Storage_manager_proxy_GetDiskById_0000
879 * @tc.desc: Test function of GetDiskById interface for SUCCESS.
880 * @tc.size: MEDIUM
881 * @tc.type: FUNC
882 * @tc.level Level 1
883 * @tc.require: AR000H09L6
884 */
885 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetDiskById_0000, testing::ext::TestSize.Level1)
886 {
887 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetDiskById_0000";
888 auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
889 auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
890 auto proxy = iface_cast<IStorageManager>(remote);
891 std::string diskId = "disk-1-30";
892 int64_t sizeBytes = 1024;
893 std::string sysPath = "/";
894 std::string vendor = "vendor-1";
895 int32_t flag = 1; // disk type
896 Disk disk(diskId, sizeBytes, sysPath, vendor, flag);
897 proxy->NotifyDiskCreated(disk);
898 int64_t result = proxy->GetDiskById(diskId, disk);
899 EXPECT_EQ(result, E_PERMISSION_DENIED);
900 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetDiskById_0000";
901 }
902
903 /**
904 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GenerateUserKeys_0000
905 * @tc.name: Storage_manager_proxy_GenerateUserKeys_0000
906 * @tc.desc: Test function of GenerateUserKeys interface for SUCCESS.
907 * @tc.size: MEDIUM
908 * @tc.type: FUNC
909 * @tc.level Level 1
910 * @tc.require: AR000H0F7I
911 */
912 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GenerateUserKeys_0000, testing::ext::TestSize.Level1)
913 {
914 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GenerateUserKeys_0000";
915 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
916 .Times(1)
917 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
918 uint32_t userId = 112;
919 uint32_t flags = 2; // UserKeys type
920 uint32_t result = proxy_->GenerateUserKeys(userId, flags);
921 EXPECT_EQ(result, E_OK);
922 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GenerateUserKeys_0000";
923 }
924
925 /**
926 * @tc.number: SUB_STORAGE_Storage_manager_proxy_DeleteUserKeys_0000
927 * @tc.name: Storage_manager_proxy_DeleteUserKeys_0000
928 * @tc.desc: Test function of DeleteUserKeys interface for SUCCESS.
929 * @tc.size: MEDIUM
930 * @tc.type: FUNC
931 * @tc.level Level 1
932 * @tc.require: AR000H0F7I
933 */
934 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_DeleteUserKeys_0000, testing::ext::TestSize.Level1)
935 {
936 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_DeleteUserKeys_0000";
937 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
938 .Times(1)
939 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
940 uint32_t userId = 113;
941 uint32_t result = proxy_->DeleteUserKeys(userId);
942 EXPECT_EQ(result, E_OK);
943 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_DeleteUserKeys_0000";
944 }
945
946 /**
947 * @tc.number: SUB_STORAGE_Storage_manager_proxy_UpdateUserAuth_0000
948 * @tc.name: Storage_manager_proxy_UpdateUserAuth_0000
949 * @tc.desc: Test function of UpdateUserAuth interface for SUCCESS.
950 * @tc.size: MEDIUM
951 * @tc.type: FUNC
952 * @tc.level Level 1
953 * @tc.require: AR000H0FG3
954 */
955 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_UpdateUserAuth_0000, testing::ext::TestSize.Level1)
956 {
957 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_UpdateUserAuth_0000";
958 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
959 .Times(1)
960 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
961 uint32_t userId = 114;
962 uint32_t result = proxy_->UpdateUserAuth(userId, 0, {}, {}, {});
963 EXPECT_EQ(result, E_OK);
964 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_UpdateUserAuth_0000";
965 }
966
967 /**
968 * @tc.number: SUB_STORAGE_Storage_manager_proxy_ActiveUserKey_0000
969 * @tc.name: Storage_manager_proxy_ActiveUserKey_0000
970 * @tc.desc: Test function of ActiveUserKey interface for SUCCESS.
971 * @tc.size: MEDIUM
972 * @tc.type: FUNC
973 * @tc.level Level 1
974 * @tc.require: AR000H0FG3
975 */
976 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_ActiveUserKey_0000, testing::ext::TestSize.Level1)
977 {
978 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_ActiveUserKey_0000";
979 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
980 .Times(1)
981 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
982 uint32_t userId = 115;
983 uint32_t result = proxy_->ActiveUserKey(userId, {}, {});
984 EXPECT_EQ(result, E_OK);
985 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_ActiveUserKey_0000";
986 }
987
988 /**
989 * @tc.number: SUB_STORAGE_Storage_manager_proxy_InactiveUserKey_0000
990 * @tc.name: Storage_manager_proxy_InactiveUserKey_0000
991 * @tc.desc: Test function of InactiveUserKey interface for SUCCESS.
992 * @tc.size: MEDIUM
993 * @tc.type: FUNC
994 * @tc.level Level 1
995 * @tc.require: AR000H0F7I
996 */
997 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_InactiveUserKey_0000, testing::ext::TestSize.Level1)
998 {
999 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_InactiveUserKey_0000";
1000 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
1001 .Times(1)
1002 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
1003 uint32_t userId = 116;
1004 uint32_t result = proxy_->InactiveUserKey(userId);
1005 EXPECT_EQ(result, E_OK);
1006 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_InactiveUserKey_0000";
1007 }
1008
1009 /**
1010 * @tc.number: SUB_STORAGE_Storage_manager_proxy_UpdateKeyContext_0000
1011 * @tc.name: Storage_manager_proxy_UpdateKeyContext_0000
1012 * @tc.desc: Test function of UpdateKeyContext interface for SUCCESS.
1013 * @tc.size: MEDIUM
1014 * @tc.type: FUNC
1015 * @tc.level Level 1
1016 * @tc.require: AR000H0F7I
1017 */
1018 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_UpdateKeyContext_0000, testing::ext::TestSize.Level1)
1019 {
1020 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_UpdateKeyContext_0000";
1021 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
1022 .Times(1)
1023 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
1024 uint32_t userId = 117;
1025 uint32_t result = proxy_->UpdateKeyContext(userId);
1026 EXPECT_EQ(result, E_OK);
1027 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_UpdateKeyContext_0000";
1028 }
1029
1030 /**
1031 * @tc.number: SUB_STORAGE_Storage_manager_proxy_GetCurrentBundleStats_0000
1032 * @tc.name: Storage_manager_proxy_GetCurrentBundleStats_0000
1033 * @tc.desc: Test function of GetCurrentBundleStats interface for SUCCESS.
1034 * @tc.size: MEDIUM
1035 * @tc.type: FUNC
1036 * @tc.level Level 1
1037 * @tc.require: AR000H0F7I
1038 */
1039 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetCurrentBundleStats_0000, testing::ext::TestSize.Level1)
1040 {
1041 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_GetCurrentBundleStats_0000";
1042 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
1043 .Times(1)
1044 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
1045 BundleStats bundleStats;
1046 int32_t result = proxy_->GetCurrentBundleStats(bundleStats);
1047 EXPECT_EQ(result, E_OK);
1048 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetCurrentBundleStats_0000";
1049 }
1050
1051 /**
1052 * @tc.number: SUB_STORAGE_Storage_manager_proxy_SetBundleQuota_0000
1053 * @tc.name: Storage_manager_proxy_SetBundleQuota_0000
1054 * @tc.desc: Test function of SetBundleQuota interface for SUCCESS.
1055 * @tc.size: MEDIUM
1056 * @tc.type: FUNC
1057 * @tc.level Level 1
1058 * @tc.require: AR000HSKSO
1059 */
1060 HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_SetBundleQuota_0000, testing::ext::TestSize.Level1)
1061 {
1062 GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_SetBundleQuota_0000";
1063 EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
1064 .Times(1)
1065 .WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
1066 std::string bundleName = "com.ohos.bundleName-0-1";
1067 std::string bundleDataDirPath = "/data/app/el2/100/base/" + bundleName;
1068 int32_t uid = 20000000;
1069 int32_t limitSizeMb = 1000;
1070 int32_t result = proxy_->SetBundleQuota(bundleName, uid, bundleDataDirPath, limitSizeMb);
1071 EXPECT_EQ(result, E_OK);
1072 GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_SetBundleQuota_0000";
1073 }
1074
1075 } // namespace