1 /*
2 * Copyright (c) 2022 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 <gmock/gmock.h>
17 #include "os_account_constants.h"
18 #include "os_account_manager.h"
19
20 namespace OHOS {
21 namespace AccountTest {
22 namespace {
23 const std::int32_t TEST_USER_ID = 101;
24 const std::int32_t MAIN_ACCOUNT_ID = 100;
25 const std::string STRING_NAME = "name";
26 const std::string STRING_TEST_NAME = "test_account_name";
27 const std::string STRING_DOMAIN_VALID = "TestDomainMT";
28 const std::string STRING_DOMAIN_ACCOUNT_NAME_VALID = "TestDomainAccountNameMT";
29 const std::string CONSTANT_PRINT = "constraint.print";
30 const std::vector<std::string> CONSTANTS_VECTOR {
31 "constraint.print",
32 "constraint.screen.timeout.set",
33 "constraint.share.into.profile"
34 };
35 const std::vector<std::string> CONSTANTS_VECTOR_TEST {
36 "constraint.private.dns.set",
37 };
38 const std::string PHOTO_IMG =
39 "data:image/"
40 "png;base64,"
41 "iVBORw0KGgoAAAANSUhEUgAAABUAAAAXCAIAAABrvZPKAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAEXRFWHRTb2Z0d2FyZQBTbmlwYXN0ZV0Xzt0AAA"
42 "FBSURBVDiN7ZQ/S8NQFMVPxU/QCx06GBzrkqUZ42rBbHWUBDqYxSnUoTxXydCSycVsgltfBiFDR8HNdHGxY4nQQAPvMzwHsWn+KMWsPdN7h/"
43 "vj3He5vIaUEjV0UAfe85X83KMBT7N75JEXVdSlfEAVfPRyZ5yfIrBoUkVlMU82Hkp8wu9ddt1vFew4sIiIiKwgzcXIvN7GTZOvpZRrbja3tDG/"
44 "D3I1NZvmdCXz+XOv5wJANKHOVYjRTAghxIyh0FHKb+0QQH5+kXf2zkYGAG0oFr5RfnK8DAGkwY19wliRT2L448vjv0YGQFVa8VKdDXUU+"
45 "faFUxpblhxYRNRzmd6FNnS0H3/X/VH6j0IIIRxMLJ5k/j/2L/"
46 "zchW8pKj7iFAA0R2wajl5d46idlR3+GtPV2XOvQ3bBNvyFs8U39v9PLX0Bp0CN+yY0OAEAAAAASUVORK5CYII=";
47 }
48
49 using namespace testing;
50 using namespace testing::ext;
51 using namespace OHOS::AccountSA;
52
53 class TestOsAccountSubscriber : public OsAccountSubscriber {
54 public:
OnAccountsChanged(const int & id)55 void OnAccountsChanged(const int& id) {}
56 };
57
58 class AccountOsProxyMockTest : public testing::Test {
59 public:
60 static void SetUpTestCase(void);
61 static void TearDownTestCase(void);
62 void SetUp(void) override;
63 void TearDown(void) override;
64 };
65
SetUpTestCase(void)66 void AccountOsProxyMockTest::SetUpTestCase(void)
67 {}
68
TearDownTestCase(void)69 void AccountOsProxyMockTest::TearDownTestCase(void)
70 {}
71
SetUp(void)72 void AccountOsProxyMockTest::SetUp(void)
73 {}
74
TearDown(void)75 void AccountOsProxyMockTest::TearDown(void)
76 {}
77
78 /**
79 * @tc.name: OsAccountTest001
80 * @tc.desc: Test func with proxy is nullptr.
81 * @tc.type: FUNC
82 * @tc.require:
83 */
84 HWTEST_F(AccountOsProxyMockTest, OsAccountTest001, TestSize.Level1)
85 {
86 OsAccountInfo osAccountInfo;
87 ErrCode errCode = OsAccountManager::CreateOsAccount(STRING_TEST_NAME, OsAccountType::ADMIN, osAccountInfo);
88 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
89 }
90
91 /**
92 * @tc.name: CreateOsAccountForDomainTest001
93 * @tc.desc: Test func with proxy is nullptr.
94 * @tc.type: FUNC
95 * @tc.require:
96 */
97 HWTEST_F(AccountOsProxyMockTest, CreateOsAccountForDomainTest001, TestSize.Level1)
98 {
99 DomainAccountInfo domainInfo(STRING_DOMAIN_VALID, STRING_DOMAIN_ACCOUNT_NAME_VALID);
100 OsAccountType type = NORMAL;
101 OsAccountInfo osAccountInfo;
102 ErrCode errCode = OsAccountManager::CreateOsAccountForDomain(type, domainInfo, osAccountInfo);
103 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
104 }
105
106 /**
107 * @tc.name: RemoveOsAccountTest001
108 * @tc.desc: Test func with proxy is nullptr.
109 * @tc.type: FUNC
110 * @tc.require:
111 */
112 HWTEST_F(AccountOsProxyMockTest, RemoveOsAccountTest001, TestSize.Level1)
113 {
114 ErrCode errCode = OsAccountManager::OsAccountManager::RemoveOsAccount(TEST_USER_ID);
115 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
116 }
117
118 /**
119 * @tc.name: IsOsAccountExistsTest001
120 * @tc.desc: Test func with proxy is nullptr.
121 * @tc.type: FUNC
122 * @tc.require:
123 */
124 HWTEST_F(AccountOsProxyMockTest, IsOsAccountExistsTest001, TestSize.Level1)
125 {
126 bool isOsAccountExists = false;
127 ErrCode errCode = OsAccountManager::IsOsAccountExists(TEST_USER_ID, isOsAccountExists);
128 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
129 ASSERT_EQ(isOsAccountExists, false);
130 }
131
132 /**
133 * @tc.name: IsOsAccountActivedTest001
134 * @tc.desc: Test func with proxy is nullptr.
135 * @tc.type: FUNC
136 * @tc.require:
137 */
138 HWTEST_F(AccountOsProxyMockTest, IsOsAccountActivedTest001, TestSize.Level1)
139 {
140 bool isOsAccountActived = false;
141 ErrCode errCode = OsAccountManager::IsOsAccountActived(TEST_USER_ID, isOsAccountActived);
142 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
143 ASSERT_EQ(isOsAccountActived, false);
144 }
145
146 /**
147 * @tc.name: IsOsAccountConstraintEnableTest001
148 * @tc.desc: Test func with proxy is nullptr.
149 * @tc.type: FUNC
150 * @tc.require:
151 */
152 HWTEST_F(AccountOsProxyMockTest, IsOsAccountConstraintEnableTest001, TestSize.Level1)
153 {
154 bool isEnable = true;
155 ErrCode errCode =
156 OsAccountManager::IsOsAccountConstraintEnable(TEST_USER_ID, CONSTANT_PRINT, isEnable);
157 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
158 ASSERT_EQ(isEnable, false);
159 }
160
161 /**
162 * @tc.name: IsOsAccountVerifiedTest001
163 * @tc.desc: Test func with proxy is nullptr.
164 * @tc.type: FUNC
165 * @tc.require:
166 */
167 HWTEST_F(AccountOsProxyMockTest, IsOsAccountVerifiedTest001, TestSize.Level1)
168 {
169 bool isVerified = true;
170 ErrCode errCode = OsAccountManager::IsOsAccountVerified(TEST_USER_ID, isVerified);
171 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
172 ASSERT_EQ(isVerified, false);
173 }
174
175 /**
176 * @tc.name: GetCreatedOsAccountsCountTest001
177 * @tc.desc: Test func with proxy is nullptr.
178 * @tc.type: FUNC
179 * @tc.require:
180 */
181 HWTEST_F(AccountOsProxyMockTest, GetCreatedOsAccountsCountTest001, TestSize.Level1)
182 {
183 uint32_t osAccountsCount = 0;
184 ErrCode errCode = OsAccountManager::GetCreatedOsAccountsCount(osAccountsCount);
185 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
186 }
187
188 /**
189 * @tc.name: GetOsAccountLocalIdFromProcessTest001
190 * @tc.desc: Test func with proxy is nullptr.
191 * @tc.type: FUNC
192 * @tc.require:
193 */
194 HWTEST_F(AccountOsProxyMockTest, GetOsAccountLocalIdFromProcessTest001, TestSize.Level1)
195 {
196 int32_t id = -1;
197 ErrCode errCode = OsAccountManager::GetOsAccountLocalIdFromProcess(id);
198 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
199 }
200
201 /**
202 * @tc.name: IsMainOsAccountTest001
203 * @tc.desc: Test func with proxy is nullptr.
204 * @tc.type: FUNC
205 * @tc.require:
206 */
207 HWTEST_F(AccountOsProxyMockTest, IsMainOsAccountTest001, TestSize.Level1)
208 {
209 bool isMainOsAccount = false;
210 ErrCode errCode = OsAccountManager::IsMainOsAccount(isMainOsAccount);
211 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
212 }
213
214 /**
215 * @tc.name: GetOsAccountLocalIdFromDomainTest001
216 * @tc.desc: Test func with proxy is nullptr.
217 * @tc.type: FUNC
218 * @tc.require:
219 */
220 HWTEST_F(AccountOsProxyMockTest, GetOsAccountLocalIdFromDomainTest001, TestSize.Level1)
221 {
222 std::string testDomainName = "test_domain_name";
223 std::string testDomain = "test_domain";
224 DomainAccountInfo domainInfo(testDomainName, testDomain);
225 int32_t resID = -1;
226 ErrCode errCode = OsAccountManager::GetOsAccountLocalIdFromDomain(domainInfo, resID);
227 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
228 }
229
230 /**
231 * @tc.name: QueryMaxOsAccountNumberTest001
232 * @tc.desc: Test func with proxy is nullptr.
233 * @tc.type: FUNC
234 * @tc.require:
235 */
236 HWTEST_F(AccountOsProxyMockTest, QueryMaxOsAccountNumberTest001, TestSize.Level1)
237 {
238 int32_t maxOsAccountNumber = 0;
239 ErrCode errCode = OsAccountManager::QueryMaxOsAccountNumber(maxOsAccountNumber);
240 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
241 }
242
243 /**
244 * @tc.name: GetOsAccountAllConstraintsTest001
245 * @tc.desc: Test func with proxy is nullptr.
246 * @tc.type: FUNC
247 * @tc.require:
248 */
249 HWTEST_F(AccountOsProxyMockTest, GetOsAccountAllConstraintsTest001, TestSize.Level1)
250 {
251 std::vector<std::string> constraints;
252 ErrCode errCode = OsAccountManager::GetOsAccountAllConstraints(TEST_USER_ID, constraints);
253 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
254 }
255
256 /**
257 * @tc.name: QueryAllCreatedOsAccountsTest001
258 * @tc.desc: Test func with proxy is nullptr.
259 * @tc.type: FUNC
260 * @tc.require:
261 */
262 HWTEST_F(AccountOsProxyMockTest, QueryAllCreatedOsAccountsTest001, TestSize.Level1)
263 {
264 std::vector<std::string> constraints;
265 ErrCode errCode = OsAccountManager::GetOsAccountAllConstraints(TEST_USER_ID, constraints);
266 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
267 }
268
269 /**
270 * @tc.name: QueryCurrentOsAccountTest001
271 * @tc.desc: Test func with proxy is nullptr.
272 * @tc.type: FUNC
273 * @tc.require:
274 */
275 HWTEST_F(AccountOsProxyMockTest, QueryCurrentOsAccountTest001, TestSize.Level1)
276 {
277 OsAccountInfo osAccountInfo;
278 ErrCode errCode = OsAccountManager::QueryCurrentOsAccount(osAccountInfo);
279 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
280 }
281
282 /**
283 * @tc.name: QueryOsAccountByIdTest001
284 * @tc.desc: Test func with proxy is nullptr.
285 * @tc.type: FUNC
286 * @tc.require:
287 */
288 HWTEST_F(AccountOsProxyMockTest, QueryOsAccountByIdTest001, TestSize.Level1)
289 {
290 OsAccountInfo osAccountInfo;
291 ErrCode errCode = OsAccountManager::QueryOsAccountById(TEST_USER_ID, osAccountInfo);
292 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
293 }
294
295 /**
296 * @tc.name: GetOsAccountTypeFromProcessTest001
297 * @tc.desc: Test func with proxy is nullptr.
298 * @tc.type: FUNC
299 * @tc.require:
300 */
301 HWTEST_F(AccountOsProxyMockTest, GetOsAccountTypeFromProcessTest001, TestSize.Level1)
302 {
303 OsAccountType type = OsAccountType::ADMIN;
304 ErrCode errCode = OsAccountManager::GetOsAccountTypeFromProcess(type);
305 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
306 }
307
308 /**
309 * @tc.name: GetOsAccountProfilePhotoTest001
310 * @tc.desc: Test func with proxy is nullptr.
311 * @tc.type: FUNC
312 * @tc.require:
313 */
314 HWTEST_F(AccountOsProxyMockTest, GetOsAccountProfilePhotoTest001, TestSize.Level1)
315 {
316 std::string photo;
317 ErrCode errCode = OsAccountManager::GetOsAccountProfilePhoto(TEST_USER_ID, photo);
318 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
319 }
320
321 /**
322 * @tc.name: IsMultiOsAccountEnableTest001
323 * @tc.desc: Test func with proxy is nullptr.
324 * @tc.type: FUNC
325 * @tc.require:
326 */
327 HWTEST_F(AccountOsProxyMockTest, IsMultiOsAccountEnableTest001, TestSize.Level1)
328 {
329 bool isMultiOsAccountEnable = false;
330 ErrCode errCode = OsAccountManager::IsMultiOsAccountEnable(isMultiOsAccountEnable);
331 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
332 }
333
334 /**
335 * @tc.name: SetOsAccountNameTest001
336 * @tc.desc: Test func with proxy is nullptr.
337 * @tc.type: FUNC
338 * @tc.require:
339 */
340 HWTEST_F(AccountOsProxyMockTest, SetOsAccountNameTest001, TestSize.Level1)
341 {
342 ErrCode errCode = OsAccountManager::SetOsAccountName(TEST_USER_ID, STRING_NAME);
343 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
344 }
345
346 /**
347 * @tc.name: SetOsAccountConstraintsTest001
348 * @tc.desc: Test func with proxy is nullptr.
349 * @tc.type: FUNC
350 * @tc.require:
351 */
352 HWTEST_F(AccountOsProxyMockTest, SetOsAccountConstraintsTest001, TestSize.Level1)
353 {
354 bool enable = false;
355 ErrCode errCode = OsAccountManager::SetOsAccountConstraints(TEST_USER_ID, CONSTANTS_VECTOR, enable);
356 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
357 }
358
359 /**
360 * @tc.name: SetOsAccountProfilePhotoTest001
361 * @tc.desc: Test func with proxy is nullptr.
362 * @tc.type: FUNC
363 * @tc.require:
364 */
365 HWTEST_F(AccountOsProxyMockTest, SetOsAccountProfilePhotoTest001, TestSize.Level1)
366 {
367 ErrCode errCode = OsAccountManager::SetOsAccountProfilePhoto(TEST_USER_ID, PHOTO_IMG);
368 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
369 }
370
371 /**
372 * @tc.name: GetDistributedVirtualDeviceIdTest001
373 * @tc.desc: Test func with proxy is nullptr.
374 * @tc.type: FUNC
375 * @tc.require:
376 */
377 HWTEST_F(AccountOsProxyMockTest, GetDistributedVirtualDeviceIdTest001, TestSize.Level1)
378 {
379 std::string deviceId;
380 ErrCode errCode = OsAccountManager::GetDistributedVirtualDeviceId(deviceId);
381 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_DISTRIBUTED_VIRTUAL_DEVICE_ID_ERROR, errCode);
382 }
383
384 /**
385 * @tc.name: ActivateOsAccountTest001
386 * @tc.desc: Test func with proxy is nullptr.
387 * @tc.type: FUNC
388 * @tc.require:
389 */
390 HWTEST_F(AccountOsProxyMockTest, ActivateOsAccountTest001, TestSize.Level1)
391 {
392 ErrCode errCode = OsAccountManager::ActivateOsAccount(TEST_USER_ID);
393 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
394 }
395
396 /**
397 * @tc.name: StartOsAccountTest001
398 * @tc.desc: Test func with proxy is nullptr.
399 * @tc.type: FUNC
400 * @tc.require:
401 */
402 HWTEST_F(AccountOsProxyMockTest, StartOsAccountTest001, TestSize.Level1)
403 {
404 ErrCode errCode = OsAccountManager::StartOsAccount(TEST_USER_ID);
405 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
406 }
407
408 /**
409 * @tc.name: StopOsAccountTest001
410 * @tc.desc: Test func with proxy is nullptr.
411 * @tc.type: FUNC
412 * @tc.require:
413 */
414 HWTEST_F(AccountOsProxyMockTest, StopOsAccountTest001, TestSize.Level1)
415 {
416 ErrCode errCode = OsAccountManager::StopOsAccount(TEST_USER_ID);
417 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
418 }
419
420 /**
421 * @tc.name: GetOsAccountLocalIdBySerialNumberTest001
422 * @tc.desc: Test func with proxy is nullptr.
423 * @tc.type: FUNC
424 * @tc.require:
425 */
426 HWTEST_F(AccountOsProxyMockTest, GetOsAccountLocalIdBySerialNumberTest001, TestSize.Level1)
427 {
428 int32_t id = 0;
429 ErrCode errCode = OsAccountManager::GetOsAccountLocalIdBySerialNumber(
430 Constants::CARRY_NUM * Constants::SERIAL_NUMBER_NUM_START_FOR_ADMIN + 1, id);
431 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
432 }
433
434 /**
435 * @tc.name: GetSerialNumberByOsAccountLocalIdTest001
436 * @tc.desc: Test func with proxy is nullptr.
437 * @tc.type: FUNC
438 * @tc.require:
439 */
440 HWTEST_F(AccountOsProxyMockTest, GetSerialNumberByOsAccountLocalIdTest001, TestSize.Level1)
441 {
442 int64_t serialNumber;
443 ErrCode errCode = OsAccountManager::GetSerialNumberByOsAccountLocalId(TEST_USER_ID, serialNumber);
444 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
445 }
446
447 /**
448 * @tc.name: SubscribeOsAccountTest001
449 * @tc.desc: Test func with proxy is nullptr.
450 * @tc.type: FUNC
451 * @tc.require:
452 */
453 HWTEST_F(AccountOsProxyMockTest, SubscribeOsAccountTest001, TestSize.Level1)
454 {
455 auto subscriber = std::make_shared<TestOsAccountSubscriber>();
456 ASSERT_NE(nullptr, subscriber);
457 ErrCode errCode = OsAccountManager::SubscribeOsAccount(subscriber);
458 ASSERT_EQ(ERR_APPACCOUNT_KIT_APP_ACCOUNT_PROXY_IS_NULLPTR, errCode);
459 }
460
461 /**
462 * @tc.name: UnsubscribeOsAccountTest001
463 * @tc.desc: Test func with proxy is nullptr.
464 * @tc.type: FUNC
465 * @tc.require:
466 */
467 HWTEST_F(AccountOsProxyMockTest, UnsubscribeOsAccountTest001, TestSize.Level1)
468 {
469 auto subscriber = std::make_shared<TestOsAccountSubscriber>();
470 ASSERT_NE(nullptr, subscriber);
471 ErrCode errCode = OsAccountManager::UnsubscribeOsAccount(subscriber);
472 ASSERT_EQ(ERR_APPACCOUNT_KIT_APP_ACCOUNT_PROXY_IS_NULLPTR, errCode);
473 }
474
475 /**
476 * @tc.name: GetOsAccountSwitchModTest001
477 * @tc.desc: Test func with proxy is nullptr.
478 * @tc.type: FUNC
479 * @tc.require:
480 */
481 HWTEST_F(AccountOsProxyMockTest, GetOsAccountSwitchModTest001, TestSize.Level1)
482 {
483 ASSERT_EQ(OS_ACCOUNT_SWITCH_MOD::ERROR_MOD, OsAccountManager::GetOsAccountSwitchMod());
484 }
485
486 /**
487 * @tc.name: IsCurrentOsAccountVerifiedTest001
488 * @tc.desc: Test func with proxy is nullptr.
489 * @tc.type: FUNC
490 * @tc.require:
491 */
492 HWTEST_F(AccountOsProxyMockTest, IsCurrentOsAccountVerifiedTest001, TestSize.Level1)
493 {
494 bool isVerified = true;
495 ErrCode errCode = OsAccountManager::IsCurrentOsAccountVerified(isVerified);
496 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
497 }
498
499 /**
500 * @tc.name: IsOsAccountCompletedTest001
501 * @tc.desc: Test func with proxy is nullptr.
502 * @tc.type: FUNC
503 * @tc.require:
504 */
505 HWTEST_F(AccountOsProxyMockTest, IsOsAccountCompletedTest001, TestSize.Level1)
506 {
507 bool isOsAccountCompleted = true;
508 ErrCode errCode = OsAccountManager::IsOsAccountCompleted(MAIN_ACCOUNT_ID, isOsAccountCompleted);
509 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
510 }
511
512 /**
513 * @tc.name: SetCurrentOsAccountIsVerifiedTest001
514 * @tc.desc: Test func with proxy is nullptr.
515 * @tc.type: FUNC
516 * @tc.require:
517 */
518 HWTEST_F(AccountOsProxyMockTest, SetCurrentOsAccountIsVerifiedTest001, TestSize.Level1)
519 {
520 ErrCode errCode = OsAccountManager::SetCurrentOsAccountIsVerified(false);
521 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
522 }
523
524 /**
525 * @tc.name: SetOsAccountIsVerifiedTest001
526 * @tc.desc: Test func with proxy is nullptr.
527 * @tc.type: FUNC
528 * @tc.require:
529 */
530 HWTEST_F(AccountOsProxyMockTest, SetOsAccountIsVerifiedTest001, TestSize.Level1)
531 {
532 ErrCode errCode = OsAccountManager::SetOsAccountIsVerified(TEST_USER_ID, true);
533 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
534 }
535
536 /**
537 * @tc.name: GetCreatedOsAccountNumFromDatabaseTest001
538 * @tc.desc: Test func with proxy is nullptr.
539 * @tc.type: FUNC
540 * @tc.require:
541 */
542 HWTEST_F(AccountOsProxyMockTest, GetCreatedOsAccountNumFromDatabaseTest001, TestSize.Level1)
543 {
544 int32_t createdOsAccountNum = -1;
545 ErrCode errCode = OsAccountManager::GetCreatedOsAccountNumFromDatabase("", createdOsAccountNum);
546 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
547 }
548
549 /**
550 * @tc.name: GetSerialNumberFromDatabaseTest001
551 * @tc.desc: Test func with proxy is nullptr.
552 * @tc.type: FUNC
553 * @tc.require:
554 */
555 HWTEST_F(AccountOsProxyMockTest, GetSerialNumberFromDatabaseTest001, TestSize.Level1)
556 {
557 int64_t serialNumber = -1;
558 ErrCode errCode = OsAccountManager::GetSerialNumberFromDatabase("", serialNumber);
559 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
560 }
561
562 /**
563 * @tc.name: GetMaxAllowCreateIdFromDatabaseTest001
564 * @tc.desc: Test func with proxy is nullptr.
565 * @tc.type: FUNC
566 * @tc.require:
567 */
568 HWTEST_F(AccountOsProxyMockTest, GetMaxAllowCreateIdFromDatabaseTest001, TestSize.Level1)
569 {
570 int32_t maxAllowCreateId = -1;
571 ErrCode errCode = OsAccountManager::GetMaxAllowCreateIdFromDatabase("", maxAllowCreateId);
572 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
573 }
574
575 /**
576 * @tc.name: GetOsAccountFromDatabaseTest001
577 * @tc.desc: Test func with proxy is nullptr.
578 * @tc.type: FUNC
579 * @tc.require:
580 */
581 HWTEST_F(AccountOsProxyMockTest, GetOsAccountFromDatabaseTest001, TestSize.Level1)
582 {
583 OsAccountInfo osAccountInfo;
584 ErrCode errCode = OsAccountManager::GetOsAccountFromDatabase("", MAIN_ACCOUNT_ID, osAccountInfo);
585 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
586 }
587
588 /**
589 * @tc.name: GetOsAccountListFromDatabaseTest001
590 * @tc.desc: Test func with proxy is nullptr.
591 * @tc.type: FUNC
592 * @tc.require:
593 */
594 HWTEST_F(AccountOsProxyMockTest, GetOsAccountListFromDatabaseTest001, TestSize.Level1)
595 {
596 std::vector<OsAccountInfo> osAccountList;
597 ErrCode errCode = OsAccountManager::GetOsAccountListFromDatabase("", osAccountList);
598 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
599 }
600
601 /**
602 * @tc.name: QueryActiveOsAccountIdsTest001
603 * @tc.desc: Test func with proxy is nullptr.
604 * @tc.type: FUNC
605 * @tc.require:
606 */
607 HWTEST_F(AccountOsProxyMockTest, QueryActiveOsAccountIdsTest001, TestSize.Level1)
608 {
609 std::vector<int32_t> ids;
610 ErrCode errCode = OsAccountManager::QueryActiveOsAccountIds(ids);
611 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
612 }
613
614 /**
615 * @tc.name: QueryOsAccountConstraintSourceTypesTest001
616 * @tc.desc: Test func with proxy is nullptr.
617 * @tc.type: FUNC
618 * @tc.require:
619 */
620 HWTEST_F(AccountOsProxyMockTest, QueryOsAccountConstraintSourceTypesTest001, TestSize.Level1)
621 {
622 std::vector<ConstraintSourceTypeInfo> constraintSourceTypeInfos;
623 ErrCode errCode = OsAccountManager::QueryOsAccountConstraintSourceTypes(
624 MAIN_ACCOUNT_ID, CONSTANT_PRINT, constraintSourceTypeInfos);
625 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
626 }
627
628 /**
629 * @tc.name: SetGlobalOsAccountConstraintsTest001
630 * @tc.desc: Test func with proxy is nullptr.
631 * @tc.type: FUNC
632 * @tc.require:
633 */
634 HWTEST_F(AccountOsProxyMockTest, SetGlobalOsAccountConstraintsTest001, TestSize.Level1)
635 {
636 ErrCode errCode = OsAccountManager::SetGlobalOsAccountConstraints(
637 CONSTANTS_VECTOR_TEST, true, TEST_USER_ID, true);
638 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
639 }
640
641 /**
642 * @tc.name: SetSpecificOsAccountConstraintsTest001
643 * @tc.desc: Test func with proxy is nullptr.
644 * @tc.type: FUNC
645 * @tc.require:
646 */
647 HWTEST_F(AccountOsProxyMockTest, SetSpecificOsAccountConstraintsTest001, TestSize.Level1)
648 {
649 ErrCode errCode = OsAccountManager::SetSpecificOsAccountConstraints(
650 CONSTANTS_VECTOR, true, MAIN_ACCOUNT_ID, TEST_USER_ID, true);
651 ASSERT_EQ(ERR_OSACCOUNT_KIT_GET_SYSTEM_ABILITY_MANAGER_ERROR, errCode);
652 }
653 } // namespace AccountTest
654 } // namespace OHOS