• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #define private public
17 #include "app_mgr_client.h"
18 #undef private
19 #include <gtest/gtest.h>
20 #include "ability_info.h"
21 #include "application_info.h"
22 #include "hilog_tag_wrapper.h"
23 #include "iapp_state_callback.h"
24 #include "mock_ability_token.h"
25 #include "mock_ams_mgr_scheduler.h"
26 #include "mock_app_mgr_service.h"
27 #include "mock_app_service_mgr.h"
28 #include "mock_iapp_state_callback.h"
29 #include "mock_native_token.h"
30 #include "param.h"
31 #include "running_process_info.h"
32 
33 using namespace testing::ext;
34 using testing::_;
35 using testing::Invoke;
36 using testing::InvokeWithoutArgs;
37 using testing::Return;
38 using testing::SetArgReferee;
39 
40 namespace OHOS {
41 namespace AppExecFwk {
42 namespace {
43 const int32_t USER_ID = 100;
44 }  // namespace
45 
46 class AmsAppMgrClientTest : public testing::Test {
47 public:
48     static void SetUpTestCase();
49     static void TearDownTestCase();
50     void SetUp();
51     void TearDown();
52 
53 protected:
54     sptr<MockAbilityToken> token_;
55     sptr<MockAbilityToken> preToken_;
56     std::unique_ptr<AppMgrClient> client_;
57 };
58 
SetUpTestCase()59 void AmsAppMgrClientTest::SetUpTestCase()
60 {
61     MockNativeToken::SetNativeToken();
62 }
63 
TearDownTestCase()64 void AmsAppMgrClientTest::TearDownTestCase()
65 {}
66 
SetUp()67 void AmsAppMgrClientTest::SetUp()
68 {
69     client_.reset(new (std::nothrow) AppMgrClient());
70     client_->SetServiceManager(std::make_unique<MockAppServiceMgr>());
71     token_ = new (std::nothrow) MockAbilityToken();
72 }
73 
TearDown()74 void AmsAppMgrClientTest::TearDown()
75 {}
76 
77 /**
78  * @tc.name: AppMgrClient_GetProcessRunningInfosByUserId_0100
79  * @tc.desc: GetProcessRunningInfosByUserId
80  * @tc.type: FUNC
81  * @tc.require: SR000GH1GO
82  */
83 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_GetProcessRunningInfosByUserId_0100, TestSize.Level1)
84 {
85     TAG_LOGI(AAFwkTag::TEST, "AppMgrClient_GetProcessRunningInfosByUserId_0100 start");
86 
87     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
88 
89     EXPECT_CALL(
90         *(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
91         GetProcessRunningInfosByUserId(_, _))
92         .Times(1)
93         .WillOnce(Return(AppMgrResultCode::RESULT_OK));
94 
95     std::vector<RunningProcessInfo> info;
96     int32_t userId = USER_ID;
97     auto result = client_->GetProcessRunningInfosByUserId(info, userId);
98     TAG_LOGI(AAFwkTag::TEST, "result = %{public}d", result);
99 
100     EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
101 
102     TAG_LOGI(AAFwkTag::TEST, "AppMgrClient_GetProcessRunningInfosByUserId_0100 end");
103 }
104 
105 /*
106  * Feature: AppMgrService
107  * Function: AppMgrClient
108  * SubFunction: LoadAbility Function
109  * FunctionPoints: AppMgrClient LoadAbility interface
110  * EnvConditions: Mobile that can run ohos test framework
111  * CaseDescription: Verify if AppMgrClient invoke LoadAbility works.
112  */
113 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_001, TestSize.Level1)
114 {
115     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_001 start");
116     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
117 
118     AbilityInfo abilityInfo;
119     ApplicationInfo appInfo;
120     Want want;
121 
122     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
123 
124     EXPECT_CALL(*(static_cast<MockAmsMgrScheduler*>(amsMgrScheduler.GetRefPtr())),
125         LoadAbility(_, _, _, _)).Times(1);
126 
127     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
128         GetAmsMgr())
129         .Times(1)
130         .WillOnce(Return(amsMgrScheduler));
131     AbilityRuntime::LoadParam loadParam;
132     loadParam.token = token_;
133     loadParam.preToken = preToken_;
134     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->LoadAbility(abilityInfo, appInfo, want, loadParam));
135     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_001 end");
136 }
137 
138 /*
139  * Feature: AppMgrService
140  * Function: AppMgrClient
141  * SubFunction: LoadAbility Function
142  * FunctionPoints: AppMgrClient LoadAbility interface
143  * EnvConditions: Mobile that can run ohos test framework
144  * CaseDescription: Verify if AppMgrClient invoke LoadAbility act normal without connect to service.
145  */
146 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_002, TestSize.Level1)
147 {
148     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_002 start");
149     AbilityInfo abilityInfo;
150     ApplicationInfo appInfo;
151     Want want;
152     AbilityRuntime::LoadParam loadParam;
153     loadParam.token = token_;
154     loadParam.preToken = preToken_;
155     EXPECT_EQ(
156         AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED, client_->LoadAbility(abilityInfo, appInfo, want, loadParam));
157     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_002 end");
158 }
159 
160 /*
161  * Feature: AppMgrService
162  * Function: AppMgrClient
163  * SubFunction: TerminateAbility Function
164  * FunctionPoints: AppMgrClient TerminateAbility interface
165  * EnvConditions: Mobile that can run ohos test framework
166  * CaseDescription: Verify if AppMgrClient invoke TerminateAbility works.
167  */
168 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_003, TestSize.Level1)
169 {
170     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_003 start");
171     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
172 
173     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
174     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
175         GetAmsMgr())
176         .Times(1)
177         .WillOnce(Return(amsMgrScheduler));
178     EXPECT_CALL(*(static_cast<MockAmsMgrScheduler*>(amsMgrScheduler.GetRefPtr())), TerminateAbility(_, _)).Times(1);
179 
180     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->TerminateAbility(token_, false));
181     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_003 end");
182 }
183 
184 /*
185  * Feature: AppMgrService
186  * Function: AppMgrClient
187  * SubFunction: TerminateAbility Function
188  * FunctionPoints: AppMgrClient TerminateAbility interface
189  * EnvConditions: Mobile that can run ohos test framework
190  * CaseDescription: Verify if AppMgrClient invoke TerminateAbility act normal without connect to service.
191  */
192 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_004, TestSize.Level1)
193 {
194     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_004 start");
195     EXPECT_EQ(AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED, client_->TerminateAbility(token_, false));
196     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_004 end");
197 }
198 
199 /*
200  * Feature: AppMgrService
201  * Function: AppMgrClient
202  * SubFunction: UpdateAbilityState Function
203  * FunctionPoints: AppMgrClient UpdateAbilityState interface
204  * EnvConditions: Mobile that can run ohos test framework
205  * CaseDescription: Verify if AppMgrClient invoke UpdateAbilityState works.
206  */
207 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_005, TestSize.Level1)
208 {
209     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_005 start");
210     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
211 
212     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
213     EXPECT_CALL(*(static_cast<MockAmsMgrScheduler*>(amsMgrScheduler.GetRefPtr())), UpdateAbilityState(_, _)).Times(1);
214     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
215         GetAmsMgr())
216         .Times(1)
217         .WillOnce(Return(amsMgrScheduler));
218 
219     AbilityState state = AbilityState::ABILITY_STATE_CREATE;
220     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->UpdateAbilityState(token_, state));
221     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_005 end");
222 }
223 
224 /*
225  * Feature: AppMgrService
226  * Function: AppMgrClient
227  * SubFunction: UpdateAbilityState Function
228  * FunctionPoints: AppMgrClient UpdateAbilityState interface
229  * EnvConditions: Mobile that can run ohos test framework
230  * CaseDescription: Verify if AppMgrClient invoke UpdateAbilityState act normal without connect to service.
231  */
232 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_006, TestSize.Level1)
233 {
234     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_006 start");
235     AbilityState state = AbilityState::ABILITY_STATE_CREATE;
236     EXPECT_EQ(AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED, client_->UpdateAbilityState(token_, state));
237     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_006 end");
238 }
239 
240 /*
241  * Feature: AppMgrService
242  * Function: AppMgrClient
243  * SubFunction: RegisterAppStateCallback Function
244  * FunctionPoints: AppMgrClient RegisterAppStateCallback interface
245  * EnvConditions: Mobile that can run ohos test framework
246  * CaseDescription: Verify if AppMgrClient invoke RegisterAppStateCallback works.
247  */
248 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_007, TestSize.Level1)
249 {
250     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_007 start");
251     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
252     sptr<MockAppStateCallback> mockCallback(new MockAppStateCallback());
253     sptr<IAppStateCallback> callback = iface_cast<IAppStateCallback>(mockCallback);
254 
255     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
256     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
257         GetAmsMgr())
258         .Times(1)
259         .WillOnce(Return(amsMgrScheduler));
260 
261     EXPECT_CALL(*mockCallback, OnAbilityRequestDone(_, _)).Times(1);
262     EXPECT_CALL(*mockCallback, OnAppStateChanged(_)).Times(1);
263 
264     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->RegisterAppStateCallback(callback));
265     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_007 end");
266 }
267 
268 /*
269  * Feature: AppMgrService
270  * Function: AppMgrClient
271  * SubFunction: RegisterAppStateCallback Function
272  * FunctionPoints: AppMgrClient RegisterAppStateCallback interface
273  * EnvConditions: Mobile that can run ohos test framework
274  * CaseDescription: Verify if AppMgrClient invoke RegisterAppStateCallback act normal without connect to service.
275  */
276 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_008, TestSize.Level1)
277 {
278     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_008 start");
279     sptr<IAppStateCallback> callback;
280     EXPECT_EQ(AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED, client_->RegisterAppStateCallback(callback));
281     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_008 end");
282 }
283 
284 /*
285  * Feature: AppMgrService
286  * Function: AppMgrClient::KillApplication
287  * SubFunction: RegisterAppStateCallback Function
288  * FunctionPoints: AppMgrClient KillApplication interface
289  * EnvConditions: Mobile that can run ohos test framework
290  * CaseDescription: Notify app of death
291  */
292 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_010, TestSize.Level1)
293 {
294     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_008 start");
295     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
296     sptr<IRemoteObject> token;
297     sptr<IRemoteObject> preToken;
298 
299     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
300     EXPECT_CALL(*(static_cast<MockAmsMgrScheduler*>(amsMgrScheduler.GetRefPtr())), KillApplication(_, _, _))
301         .Times(1)
302         .WillOnce(Return(ERR_OK));
303     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
304         GetAmsMgr())
305         .Times(1)
306         .WillOnce(Return(amsMgrScheduler));
307 
308     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->KillApplication(""));
309     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_008 end");
310 }
311 
312 /*
313  * Feature: AppMgrService
314  * Function: AppMgrClient::KillApplication
315  * SubFunction: RegisterAppStateCallback Function
316  * FunctionPoints: AppMgrClient KillApplication interface
317  * EnvConditions: Mobile that can run ohos test framework
318  * CaseDescription: Notify app of death
319  */
320 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_011, TestSize.Level1)
321 {
322     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_011 start");
323     sptr<IRemoteObject> token;
324     sptr<IRemoteObject> preToken;
325     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
326     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
327     EXPECT_CALL(*(static_cast<MockAmsMgrScheduler*>(amsMgrScheduler.GetRefPtr())), KillApplication(_, _, _))
328         .Times(1)
329         .WillOnce(Return(ERR_NO_MEMORY));
330     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
331         GetAmsMgr())
332         .Times(1)
333         .WillOnce(Return(amsMgrScheduler));
334 
335     EXPECT_EQ(AppMgrResultCode::ERROR_SERVICE_NOT_READY, client_->KillApplication(""));
336     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_011 end");
337 }
338 
339 /*
340  * Feature: AppMgrService
341  * Function: AppMgrClient::KillProcessByAbilityToken
342  * SubFunction: RegisterAppStateCallback Function
343  * FunctionPoints: AppMgrClient KillApplication interface
344  * EnvConditions: Mobile that can run ohos test framework
345  * CaseDescription: Notify app of death
346  */
347 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_012, TestSize.Level1)
348 {
349     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_012 start");
350     sptr<IRemoteObject> token;
351     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
352     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
353     EXPECT_CALL(*(static_cast<MockAmsMgrScheduler*>(amsMgrScheduler.GetRefPtr())), KillProcessByAbilityToken(_))
354         .Times(1);
355 
356     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
357         GetAmsMgr())
358         .Times(1)
359         .WillOnce(Return(amsMgrScheduler));
360 
361     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->KillProcessByAbilityToken(token));
362     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_012 end");
363 }
364 
365 /*
366  * Feature: AppMgrService
367  * Function: AppMgrClient::KillProcessByAbilityToken
368  * SubFunction: RegisterAppStateCallback Function
369  * FunctionPoints: AppMgrClient KillApplication interface
370  * EnvConditions: Mobile that can run ohos test framework
371  * CaseDescription: Notify app of death
372  */
373 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_013, TestSize.Level1)
374 {
375     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_013 start");
376     sptr<IRemoteObject> token;
377     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
378     sptr<IAmsMgr> amsMgrScheduler(new MockAmsMgrScheduler());
379     EXPECT_CALL(*(static_cast<MockAmsMgrScheduler*>(amsMgrScheduler.GetRefPtr())), KillProcessByAbilityToken(_))
380         .Times(0);
381 
382     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
383         GetAmsMgr())
384         .Times(1)
385         .WillOnce(Return(nullptr));
386 
387     EXPECT_EQ(AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED, client_->KillProcessByAbilityToken(token));
388     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_013 end");
389 }
390 
391 /*
392  * Feature: AppMgrService
393  * Function: AppMgrClient::ClearUpApplicationData
394  * SubFunction: ClearUpApplicationData
395  * FunctionPoints: AppMgrClient ClearUpApplicationData interface
396  * EnvConditions: Mobile that can run ohos test framework
397  * CaseDescription: clear the application data.
398  */
399 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_014, TestSize.Level1)
400 {
401     sptr<IRemoteObject> token;
402     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
403     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
404         ClearUpApplicationData(_, _, _))
405         .Times(1)
406         .WillOnce(Return(ERR_NO_MEMORY));
407     EXPECT_EQ(AppMgrResultCode::ERROR_SERVICE_NOT_READY, client_->ClearUpApplicationData("com.test", 0));
408 }
409 
410 /*
411  * Feature: AppMgrService
412  * Function: AppMgrClient::ClearUpApplicationData
413  * SubFunction: ClearUpApplicationData
414  * FunctionPoints: AppMgrClient ClearUpApplicationData interface
415  * EnvConditions: Mobile that can run ohos test framework
416  * CaseDescription: clear the application data.
417  */
418 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_015, TestSize.Level1)
419 {
420     sptr<IRemoteObject> token;
421     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
422     sptr<IAppMgr> appMgr(new MockAppMgrService());
423     EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
424         ClearUpApplicationData(_, _, _))
425         .Times(1)
426         .WillOnce(Return(ERR_OK));
427     EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ClearUpApplicationData("com.test", 0));
428 }
429 
430 /**
431  * @tc.name: AppMgrClient_016
432  * @tc.desc: Verify the function when parameter is 2
433  * @tc.type: FUNC
434  * @tc.require: issueI5823X
435  */
436 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_016, TestSize.Level1)
437 {
438     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_016 start");
439     AppMgrClient* ret = new AppMgrClient();
440     auto ans = ret->NotifyMemoryLevel(MemoryLevel::MEMORY_LEVEL_CRITICAL);
441     EXPECT_EQ(ans, ERR_INVALID_VALUE);
442     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_016 end");
443 }
444 
445 /**
446  * @tc.name: AppMgrClient_017
447  * @tc.desc: Verify the function when parameter is 1
448  * @tc.type: FUNC
449  * @tc.require: issueI5823X
450  */
451 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_017, TestSize.Level1)
452 {
453     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_017 start");
454     AppMgrClient* ret = new AppMgrClient();
455     auto ans = ret->NotifyMemoryLevel(MemoryLevel::MEMORY_LEVEL_LOW);
456     EXPECT_EQ(ans, ERR_INVALID_VALUE);
457     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_017 end");
458 }
459 
460 /**
461  * @tc.name: AppMgrClient_018
462  * @tc.desc: Verify the function when parameter is 0
463  * @tc.type: FUNC
464  * @tc.require: issueI5823X
465  */
466 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_018, TestSize.Level1)
467 {
468     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_018 start");
469     AppMgrClient* ret = new AppMgrClient();
470     auto ans = ret->NotifyMemoryLevel(MemoryLevel::MEMORY_LEVEL_MODERATE);
471     EXPECT_EQ(ans, ERR_INVALID_VALUE);
472     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_018 end");
473 }
474 
475 /**
476  * @tc.name: AppMgrClient_019
477  * @tc.desc: Verify the function when parameter is 2
478  * @tc.type: FUNC
479  * @tc.require: issueI581UZ
480  */
481 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_019, TestSize.Level1)
482 {
483     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_019 start");
484     AppMgrClient* ret = new AppMgrClient();
485     auto ans = ret->NotifyMemoryLevel(MemoryLevel::MEMORY_LEVEL_CRITICAL);
486     EXPECT_EQ(ans, ERR_INVALID_VALUE);
487     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_019 end");
488 }
489 
490 /**
491  * @tc.name: AppMgrClient_020
492  * @tc.desc: Verify the function when parameter is 1
493  * @tc.type: FUNC
494  * @tc.require: issueI581UZ
495  */
496 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_020, TestSize.Level1)
497 {
498     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_020 start");
499     AppMgrClient* ret = new AppMgrClient();
500     auto ans = ret->NotifyMemoryLevel(MemoryLevel::MEMORY_LEVEL_LOW);
501     EXPECT_EQ(ans, ERR_INVALID_VALUE);
502     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_020 end");
503 }
504 
505 /**
506  * @tc.name: AppMgrClient_021
507  * @tc.desc: Verify the function when parameter is 0
508  * @tc.type: FUNC
509  * @tc.require: issueI581UZ
510  */
511 HWTEST_F(AmsAppMgrClientTest, AppMgrClient_021, TestSize.Level1)
512 {
513     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_021 start");
514     AppMgrClient* ret = new AppMgrClient();
515     auto ans = ret->NotifyMemoryLevel(MemoryLevel::MEMORY_LEVEL_MODERATE);
516     EXPECT_EQ(ans, ERR_INVALID_VALUE);
517     TAG_LOGI(AAFwkTag::TEST, "ams_app_mgr_client_test_021 end");
518 }
519 }  // namespace AppExecFwk
520 }  // namespace OHOS
521