• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 <gtest/gtest.h>
17 
18 #include "ability_manager_errors.h"
19 #define private public
20 #define protected public
21 #include "ability_record.h"
22 #include "ability_start_setting.h"
23 #include "scene_board/ui_ability_lifecycle_manager.h"
24 #undef protected
25 #undef private
26 #include "mock_ability_info_callback_stub.h"
27 #include "session/host/include/session.h"
28 
29 using namespace testing;
30 using namespace testing::ext;
31 
32 namespace OHOS {
33 namespace AAFwk {
34 class UIAbilityLifecycleManagerTest : public testing::Test {
35 public:
36     static void SetUpTestCase();
37     static void TearDownTestCase();
38     void SetUp() override;
39     void TearDown() override;
40     std::shared_ptr<AbilityRecord> InitAbilityRecord();
41 };
42 
SetUpTestCase()43 void UIAbilityLifecycleManagerTest::SetUpTestCase() {}
44 
TearDownTestCase()45 void UIAbilityLifecycleManagerTest::TearDownTestCase() {}
46 
SetUp()47 void UIAbilityLifecycleManagerTest::SetUp() {}
48 
TearDown()49 void UIAbilityLifecycleManagerTest::TearDown() {}
50 
51 class UIAbilityLifcecycleManagerTestStub : public IRemoteStub<IAbilityConnection> {
52 public:
UIAbilityLifcecycleManagerTestStub()53     UIAbilityLifcecycleManagerTestStub() {};
~UIAbilityLifcecycleManagerTestStub()54     virtual ~UIAbilityLifcecycleManagerTestStub() {};
55 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)56     virtual int OnRemoteRequest(
57         uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
58     {
59         return 0;
60     };
61 
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)62     virtual void OnAbilityConnectDone(
63         const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) {};
64 
65     /**
66      * OnAbilityDisconnectDone, AbilityMs notify caller ability the result of disconnect.
67      *
68      * @param element, service ability's ElementName.
69      * @param resultCode, ERR_OK on success, others on failure.
70      */
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int resultCode)71     virtual void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) {};
72 };
73 
InitAbilityRecord()74 std::shared_ptr<AbilityRecord> UIAbilityLifecycleManagerTest::InitAbilityRecord()
75 {
76     AbilityRequest abilityRequest;
77     abilityRequest.appInfo.bundleName = "com.example.unittest";
78     abilityRequest.abilityInfo.name = "MainAbility";
79     abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::PAGE;
80     std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
81     return abilityRecord;
82 }
83 
84 /**
85  * @tc.name: UIAbilityLifecycleManager_StartUIAbility_0100
86  * @tc.desc: StartUIAbility
87  * @tc.type: FUNC
88  */
89 HWTEST_F(UIAbilityLifecycleManagerTest, StartUIAbility_001, TestSize.Level1)
90 {
91     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
92     AbilityRequest abilityRequest;
93     EXPECT_EQ(mgr->StartUIAbility(abilityRequest, nullptr), ERR_INVALID_VALUE);
94 }
95 
96 /**
97  * @tc.name: UIAbilityLifecycleManager_StartUIAbility_0200
98  * @tc.desc: StartUIAbility
99  * @tc.type: FUNC
100  */
101 HWTEST_F(UIAbilityLifecycleManagerTest, StartUIAbility_002, TestSize.Level1)
102 {
103     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
104     AbilityRequest abilityRequest;
105     Rosen::SessionInfo info;
106     sptr<SessionInfo> sessionInfo(new SessionInfo());
107     sessionInfo->sessionToken = new Rosen::Session(info);
108     EXPECT_EQ(mgr->StartUIAbility(abilityRequest, sessionInfo), ERR_OK);
109 }
110 
111 /**
112  * @tc.name: UIAbilityLifecycleManager_StartUIAbility_0300
113  * @tc.desc: StartUIAbility
114  * @tc.type: FUNC
115  */
116 HWTEST_F(UIAbilityLifecycleManagerTest, StartUIAbility_003, TestSize.Level1)
117 {
118     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
119     AbilityRequest abilityRequest;
120     Rosen::SessionInfo info;
121     sptr<SessionInfo> sessionInfo(new SessionInfo());
122     sessionInfo->sessionToken = new Rosen::Session(info);
123     sessionInfo->persistentId = 1;
124     abilityRequest.sessionInfo = sessionInfo;
125     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
126     mgr->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
127     EXPECT_EQ(mgr->StartUIAbility(abilityRequest, sessionInfo), ERR_OK);
128 }
129 
130 /**
131  * @tc.name: UIAbilityLifecycleManager_StartUIAbility_0400
132  * @tc.desc: StartUIAbility
133  * @tc.type: FUNC
134  */
135 HWTEST_F(UIAbilityLifecycleManagerTest, StartUIAbility_004, TestSize.Level1)
136 {
137     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
138     AbilityRequest abilityRequest;
139     Rosen::SessionInfo info;
140     sptr<SessionInfo> sessionInfo(new SessionInfo());
141     sessionInfo->sessionToken = new Rosen::Session(info);
142     sessionInfo->startSetting = std::make_shared<AbilityStartSetting>();
143     sessionInfo->persistentId = 1;
144     abilityRequest.sessionInfo = sessionInfo;
145     EXPECT_EQ(mgr->StartUIAbility(abilityRequest, sessionInfo), ERR_OK);
146 }
147 
148 /**
149  * @tc.name: UIAbilityLifecycleManager_StartUIAbility_0500
150  * @tc.desc: StartUIAbility
151  * @tc.type: FUNC
152  */
153 HWTEST_F(UIAbilityLifecycleManagerTest, StartUIAbility_005, TestSize.Level1)
154 {
155     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
156     AbilityRequest abilityRequest;
157     Rosen::SessionInfo info;
158     sptr<SessionInfo> sessionInfo(new SessionInfo());
159     sessionInfo->sessionToken = new Rosen::Session(info);
160     sessionInfo->persistentId = 1;
161     abilityRequest.sessionInfo = sessionInfo;
162     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
163     abilityRecord->SetPendingState(AbilityState::FOREGROUND);
164     mgr->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
165     EXPECT_EQ(mgr->StartUIAbility(abilityRequest, sessionInfo), ERR_OK);
166 }
167 
168 /**
169  * @tc.name: UIAbilityLifecycleManager_StartUIAbility_0600
170  * @tc.desc: StartUIAbility
171  * @tc.type: FUNC
172  */
173 HWTEST_F(UIAbilityLifecycleManagerTest, StartUIAbility_006, TestSize.Level1)
174 {
175     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
176     AbilityRequest abilityRequest;
177     abilityRequest.abilityInfoCallback = new MockAbilityInfoCallbackStub();
178     Rosen::SessionInfo info;
179     sptr<SessionInfo> sessionInfo(new SessionInfo());
180     sessionInfo->sessionToken = new Rosen::Session(info);
181     EXPECT_EQ(mgr->StartUIAbility(abilityRequest, sessionInfo), ERR_OK);
182 }
183 
184 /**
185  * @tc.name: UIAbilityLifecycleManager_CreateSessionInfo_0100
186  * @tc.desc: CreateSessionInfo
187  * @tc.type: FUNC
188  */
189 HWTEST_F(UIAbilityLifecycleManagerTest, CreateSessionInfo_001, TestSize.Level1)
190 {
191     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
192     EXPECT_NE(mgr, nullptr);
193     AbilityRequest abilityRequest;
194     abilityRequest.startSetting = std::make_shared<AbilityStartSetting>();
195     EXPECT_NE(mgr->CreateSessionInfo(abilityRequest), nullptr);
196 }
197 
198 /**
199  * @tc.name: UIAbilityLifecycleManager_AbilityTransactionDone_0100
200  * @tc.desc: AbilityTransactionDone
201  * @tc.type: FUNC
202  */
203 HWTEST_F(UIAbilityLifecycleManagerTest, AbilityTransactionDone_001, TestSize.Level1)
204 {
205     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
206     AbilityRequest abilityRequest;
207     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
208     auto token = abilityRecord->GetToken()->AsObject();
209     int state = 6;
210     PacMap saveData;
211     EXPECT_EQ(mgr->AbilityTransactionDone(token, state, saveData), ERR_INVALID_VALUE);
212 }
213 
214 /**
215  * @tc.name: UIAbilityLifecycleManager_AbilityTransactionDone_0200
216  * @tc.desc: AbilityTransactionDone
217  * @tc.type: FUNC
218  */
219 HWTEST_F(UIAbilityLifecycleManagerTest, AbilityTransactionDone_002, TestSize.Level1)
220 {
221     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
222     AbilityRequest abilityRequest;
223     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
224     mgr->terminateAbilityList_.emplace_back(abilityRecord);
225     auto token = abilityRecord->GetToken()->AsObject();
226     int state = 6;
227     PacMap saveData;
228     EXPECT_EQ(mgr->AbilityTransactionDone(token, state, saveData), ERR_INVALID_VALUE);
229 }
230 
231 /**
232  * @tc.name: UIAbilityLifecycleManager_AttachAbilityThread_0100
233  * @tc.desc: AttachAbilityThread
234  * @tc.type: FUNC
235  */
236 HWTEST_F(UIAbilityLifecycleManagerTest, AttachAbilityThread_001, TestSize.Level1)
237 {
238     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
239     sptr<IAbilityScheduler> scheduler = nullptr;
240     sptr<IRemoteObject> token = nullptr;
241     EXPECT_EQ(mgr->AttachAbilityThread(scheduler, token), ERR_INVALID_VALUE);
242 }
243 
244 /**
245  * @tc.name: UIAbilityLifecycleManager_AttachAbilityThread_0200
246  * @tc.desc: AttachAbilityThread
247  * @tc.type: FUNC
248  */
249 HWTEST_F(UIAbilityLifecycleManagerTest, AttachAbilityThread_002, TestSize.Level1)
250 {
251     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
252     AbilityRequest abilityRequest;
253     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
254     mgr->sessionAbilityMap_.emplace(1, abilityRecord);
255     sptr<IAbilityScheduler> scheduler = nullptr;
256     auto&& token = abilityRecord->GetToken()->AsObject();
257     EXPECT_EQ(mgr->AttachAbilityThread(scheduler, token), ERR_INVALID_VALUE);
258 }
259 
260 /**
261  * @tc.name: UIAbilityLifecycleManager_AttachAbilityThread_0300
262  * @tc.desc: AttachAbilityThread
263  * @tc.type: FUNC
264  */
265 HWTEST_F(UIAbilityLifecycleManagerTest, AttachAbilityThread_003, TestSize.Level1)
266 {
267     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
268     AbilityRequest abilityRequest;
269     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
270     abilityRecord->SetStartedByCall(true);
271 
272     mgr->sessionAbilityMap_.emplace(1, abilityRecord);
273     sptr<IAbilityScheduler> scheduler = nullptr;
274     auto&& token = abilityRecord->GetToken()->AsObject();
275     EXPECT_EQ(mgr->AttachAbilityThread(scheduler, token), ERR_INVALID_VALUE);
276 }
277 
278 /**
279  * @tc.name: UIAbilityLifecycleManager_AttachAbilityThread_0400
280  * @tc.desc: AttachAbilityThread
281  * @tc.type: FUNC
282  */
283 HWTEST_F(UIAbilityLifecycleManagerTest, AttachAbilityThread_004, TestSize.Level1)
284 {
285     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
286     AbilityRequest abilityRequest;
287     Want want;
288     want.SetParam(Want::PARAM_RESV_CALL_TO_FOREGROUND, true);
289     abilityRequest.want = want;
290     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
291     abilityRecord->SetStartedByCall(true);
292 
293     mgr->sessionAbilityMap_.emplace(1, abilityRecord);
294     sptr<IAbilityScheduler> scheduler = nullptr;
295     auto&& token = abilityRecord->GetToken()->AsObject();
296     EXPECT_EQ(mgr->AttachAbilityThread(scheduler, token), ERR_INVALID_VALUE);
297 }
298 
299 /**
300  * @tc.name: UIAbilityLifecycleManager_OnAbilityRequestDone_0100
301  * @tc.desc: OnAbilityRequestDone
302  * @tc.type: FUNC
303  */
304 HWTEST_F(UIAbilityLifecycleManagerTest, OnAbilityRequestDone_001, TestSize.Level1)
305 {
306     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
307     EXPECT_NE(mgr, nullptr);
308     sptr<IRemoteObject> token = nullptr;
309     mgr->OnAbilityRequestDone(token, 1);
310     EXPECT_NE(mgr, nullptr);
311 }
312 
313 /**
314  * @tc.name: UIAbilityLifecycleManager_OnAbilityRequestDone_0200
315  * @tc.desc: OnAbilityRequestDone
316  * @tc.type: FUNC
317  */
318 HWTEST_F(UIAbilityLifecycleManagerTest, OnAbilityRequestDone_002, TestSize.Level1)
319 {
320     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
321     EXPECT_NE(mgr, nullptr);
322     AbilityRequest abilityRequest;
323     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
324     auto&& token = abilityRecord->GetToken()->AsObject();
325     mgr->OnAbilityRequestDone(token, 1);
326     EXPECT_NE(mgr, nullptr);
327 }
328 
329 /**
330  * @tc.name: UIAbilityLifecycleManager_GetAbilityRecordByToken_0100
331  * @tc.desc: GetAbilityRecordByToken
332  * @tc.type: FUNC
333  */
334 HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordByToken_001, TestSize.Level1)
335 {
336     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
337     sptr<IRemoteObject> token = nullptr;
338     EXPECT_EQ(mgr->GetAbilityRecordByToken(token), nullptr);
339 }
340 
341 /**
342  * @tc.name: UIAbilityLifecycleManager_GetAbilityRecordByToken_0200
343  * @tc.desc: GetAbilityRecordByToken
344  * @tc.type: FUNC
345  */
346 HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordByToken_002, TestSize.Level1)
347 {
348     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
349     AbilityRequest abilityRequest;
350     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
351     auto&& token = abilityRecord->GetToken()->AsObject();
352     EXPECT_EQ(mgr->GetAbilityRecordByToken(token), nullptr);
353 }
354 
355 /**
356  * @tc.name: UIAbilityLifecycleManager_GetAbilityRecordByToken_0300
357  * @tc.desc: GetAbilityRecordByToken
358  * @tc.type: FUNC
359  */
360 HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordByToken_003, TestSize.Level1)
361 {
362     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
363     AbilityRequest abilityRequest;
364     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
365     mgr->sessionAbilityMap_.emplace(1, abilityRecord);
366     auto&& token = abilityRecord->GetToken()->AsObject();
367     EXPECT_NE(mgr->GetAbilityRecordByToken(token), nullptr);
368 }
369 
370 /**
371  * @tc.name: UIAbilityLifecycleManager_UpdateAbilityRecordLaunchReason_0100
372  * @tc.desc: UpdateAbilityRecordLaunchReason
373  * @tc.type: FUNC
374  */
375 HWTEST_F(UIAbilityLifecycleManagerTest, UpdateAbilityRecordLaunchReason_001, TestSize.Level1)
376 {
377     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
378     EXPECT_NE(mgr, nullptr);
379     AbilityRequest abilityRequest;
380     std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
381     mgr->UpdateAbilityRecordLaunchReason(abilityRequest, abilityRecord);
382     EXPECT_NE(mgr, nullptr);
383 }
384 
385 /**
386  * @tc.name: UIAbilityLifecycleManager_UpdateAbilityRecordLaunchReason_0200
387  * @tc.desc: UpdateAbilityRecordLaunchReason
388  * @tc.type: FUNC
389  */
390 HWTEST_F(UIAbilityLifecycleManagerTest, UpdateAbilityRecordLaunchReason_002, TestSize.Level1)
391 {
392     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
393     EXPECT_NE(mgr, nullptr);
394     Want want;
395     want.SetFlags(Want::FLAG_ABILITY_CONTINUATION);
396     AbilityRequest abilityRequest;
397     abilityRequest.want = want;
398     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
399     mgr->UpdateAbilityRecordLaunchReason(abilityRequest, abilityRecord);
400     EXPECT_NE(mgr, nullptr);
401 }
402 
403 /**
404  * @tc.name: UIAbilityLifecycleManager_UpdateAbilityRecordLaunchReason_0300
405  * @tc.desc: UpdateAbilityRecordLaunchReason
406  * @tc.type: FUNC
407  */
408 HWTEST_F(UIAbilityLifecycleManagerTest, UpdateAbilityRecordLaunchReason_003, TestSize.Level1)
409 {
410     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
411     EXPECT_NE(mgr, nullptr);
412     Want want;
413     want.SetParam(Want::PARAM_ABILITY_RECOVERY_RESTART, true);
414     AbilityRequest abilityRequest;
415     abilityRequest.want = want;
416     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
417     mgr->UpdateAbilityRecordLaunchReason(abilityRequest, abilityRecord);
418     EXPECT_NE(mgr, nullptr);
419 }
420 
421 /**
422  * @tc.name: UIAbilityLifecycleManager_UpdateAbilityRecordLaunchReason_0400
423  * @tc.desc: UpdateAbilityRecordLaunchReason
424  * @tc.type: FUNC
425  */
426 HWTEST_F(UIAbilityLifecycleManagerTest, UpdateAbilityRecordLaunchReason_004, TestSize.Level1)
427 {
428     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
429     EXPECT_NE(mgr, nullptr);
430     Want want;
431     want.SetParam(Want::PARAM_ABILITY_RECOVERY_RESTART, true);
432     AbilityRequest abilityRequest;
433     abilityRequest.want = want;
434     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
435     mgr->UpdateAbilityRecordLaunchReason(abilityRequest, abilityRecord);
436     EXPECT_NE(mgr, nullptr);
437 }
438 
439 /**
440  * @tc.name: UIAbilityLifecycleManager_EraseAbilityRecord_0100
441  * @tc.desc: EraseAbilityRecord
442  * @tc.type: FUNC
443  */
444 HWTEST_F(UIAbilityLifecycleManagerTest, EraseAbilityRecord_001, TestSize.Level1)
445 {
446     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
447     EXPECT_NE(mgr, nullptr);
448     std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
449     mgr->EraseAbilityRecord(abilityRecord);
450     EXPECT_NE(mgr, nullptr);
451 }
452 
453 /**
454  * @tc.name: UIAbilityLifecycleManager_EraseAbilityRecord_0200
455  * @tc.desc: EraseAbilityRecord
456  * @tc.type: FUNC
457  */
458 HWTEST_F(UIAbilityLifecycleManagerTest, EraseAbilityRecord_002, TestSize.Level1)
459 {
460     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
461     EXPECT_NE(mgr, nullptr);
462     AbilityRequest abilityRequest;
463     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
464     mgr->sessionAbilityMap_.emplace(1, abilityRecord);
465     mgr->EraseAbilityRecord(abilityRecord);
466     EXPECT_NE(mgr, nullptr);
467 }
468 
469 /**
470  * @tc.name: UIAbilityLifecycleManager_DispatchState_0100
471  * @tc.desc: DispatchState
472  * @tc.type: FUNC
473  */
474 HWTEST_F(UIAbilityLifecycleManagerTest, DispatchState_001, TestSize.Level1)
475 {
476     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
477     std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
478     EXPECT_EQ(mgr->DispatchState(abilityRecord, AbilityState::INITIAL), ERR_INVALID_VALUE);
479 }
480 
481 /**
482  * @tc.name: UIAbilityLifecycleManager_DispatchState_0200
483  * @tc.desc: DispatchState
484  * @tc.type: FUNC
485  */
486 HWTEST_F(UIAbilityLifecycleManagerTest, DispatchState_002, TestSize.Level1)
487 {
488     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
489     std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
490     EXPECT_EQ(mgr->DispatchState(abilityRecord, AbilityState::FOREGROUND), ERR_INVALID_VALUE);
491 }
492 
493 /**
494  * @tc.name: UIAbilityLifecycleManager_DispatchState_0300
495  * @tc.desc: DispatchState
496  * @tc.type: FUNC
497  */
498 HWTEST_F(UIAbilityLifecycleManagerTest, DispatchState_003, TestSize.Level1)
499 {
500     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
501     std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
502     EXPECT_EQ(mgr->DispatchState(abilityRecord, AbilityState::FOREGROUND_FAILED), ERR_INVALID_VALUE);
503 }
504 
505 /**
506  * @tc.name: UIAbilityLifecycleManager_DispatchState_0400
507  * @tc.desc: DispatchState
508  * @tc.type: FUNC
509  */
510 HWTEST_F(UIAbilityLifecycleManagerTest, DispatchState_004, TestSize.Level1)
511 {
512     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
513     std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
514     int state = 130;
515     EXPECT_EQ(mgr->DispatchState(abilityRecord, state), ERR_INVALID_VALUE);
516 }
517 
518 /**
519  * @tc.name: UIAbilityLifecycleManager_DispatchForeground_0100
520  * @tc.desc: DispatchForeground
521  * @tc.type: FUNC
522  */
523 HWTEST_F(UIAbilityLifecycleManagerTest, DispatchForeground_001, TestSize.Level1)
524 {
525     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
526     AbilityRequest abilityRequest;
527     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
528     EXPECT_EQ(mgr->DispatchForeground(abilityRecord, true, AbilityState::FOREGROUND), ERR_INVALID_VALUE);
529 }
530 
531 /**
532  * @tc.name: UIAbilityLifecycleManager_CompleteForegroundSuccess_0100
533  * @tc.desc: CompleteForegroundSuccess
534  * @tc.type: FUNC
535  */
536 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteForegroundSuccess_001, TestSize.Level1)
537 {
538     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
539     EXPECT_NE(mgr, nullptr);
540     AbilityRequest abilityRequest;
541     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
542     abilityRecord->SetPendingState(AbilityState::BACKGROUND);
543     mgr->CompleteForegroundSuccess(abilityRecord);
544     EXPECT_NE(mgr, nullptr);
545 }
546 
547 /**
548  * @tc.name: UIAbilityLifecycleManager_CompleteForegroundSuccess_0200
549  * @tc.desc: CompleteForegroundSuccess
550  * @tc.type: FUNC
551  */
552 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteForegroundSuccess_002, TestSize.Level1)
553 {
554     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
555     EXPECT_NE(mgr, nullptr);
556     AbilityRequest abilityRequest;
557     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
558     abilityRecord->SetPendingState(AbilityState::FOREGROUND);
559     mgr->CompleteForegroundSuccess(abilityRecord);
560     EXPECT_NE(mgr, nullptr);
561 }
562 
563 /**
564  * @tc.name: UIAbilityLifecycleManager_CompleteForegroundSuccess_0300
565  * @tc.desc: CompleteForegroundSuccess
566  * @tc.type: FUNC
567  */
568 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteForegroundSuccess_003, TestSize.Level1)
569 {
570     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
571     EXPECT_NE(mgr, nullptr);
572     AbilityRequest abilityRequest;
573     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
574     abilityRecord->SetStartedByCall(true);
575     abilityRecord->SetStartToForeground(true);
576     abilityRecord->isReady_ = true;
577     mgr->CompleteForegroundSuccess(abilityRecord);
578     EXPECT_NE(mgr, nullptr);
579 }
580 
581 /**
582  * @tc.name: UIAbilityLifecycleManager_HandleForegroundFailed_0100
583  * @tc.desc: HandleForegroundOrFailed
584  * @tc.type: FUNC
585  */
586 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundFailed_001, TestSize.Level1)
587 {
588     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
589     EXPECT_NE(mgr, nullptr);
590     std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
591     mgr->HandleForegroundFailed(abilityRecord, AbilityState::FOREGROUND_FAILED);
592     EXPECT_NE(mgr, nullptr);
593 }
594 
595 /**
596  * @tc.name: UIAbilityLifecycleManager_HandleForegroundFailed_0200
597  * @tc.desc: HandleForegroundFailed
598  * @tc.type: FUNC
599  */
600 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundFailed_002, TestSize.Level1)
601 {
602     auto mgr = std::make_unique<UIAbilityLifecycleManager>();
603     EXPECT_NE(mgr, nullptr);
604     AbilityRequest abilityRequest;
605     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
606     abilityRecord->currentState_ = AbilityState::FOREGROUNDING;
607     mgr->HandleForegroundFailed(abilityRecord, AbilityState::FOREGROUND_FAILED);
608     EXPECT_NE(mgr, nullptr);
609 }
610 
611 /**
612  * @tc.name: UIAbilityLifecycleManager_MinimizeUIAbility_0100
613  * @tc.desc: MinimizeUIAbility
614  * @tc.type: FUNC
615  */
616 HWTEST_F(UIAbilityLifecycleManagerTest, MinimizeUIAbility_001, TestSize.Level1)
617 {
618     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
619     EXPECT_EQ(uiAbilityLifecycleManager->MinimizeUIAbility(nullptr), ERR_INVALID_VALUE);
620     uiAbilityLifecycleManager.reset();
621 }
622 
623 /**
624  * @tc.name: UIAbilityLifecycleManager_MinimizeUIAbility_0200
625  * @tc.desc: MinimizeUIAbility
626  * @tc.type: FUNC
627  */
628 HWTEST_F(UIAbilityLifecycleManagerTest, MinimizeUIAbility_002, TestSize.Level1)
629 {
630     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
631     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
632     abilityRecord->currentState_ = AbilityState::BACKGROUND;
633     EXPECT_EQ(uiAbilityLifecycleManager->MinimizeUIAbility(abilityRecord), ERR_OK);
634     uiAbilityLifecycleManager.reset();
635 }
636 
637 /**
638  * @tc.name: UIAbilityLifecycleManager_MinimizeUIAbility_0300
639  * @tc.desc: MinimizeUIAbility
640  * @tc.type: FUNC
641  */
642 HWTEST_F(UIAbilityLifecycleManagerTest, MinimizeUIAbility_003, TestSize.Level1)
643 {
644     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
645     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
646     abilityRecord->currentState_ = AbilityState::FOREGROUND;
647     EXPECT_EQ(uiAbilityLifecycleManager->MinimizeUIAbility(abilityRecord), ERR_OK);
648     uiAbilityLifecycleManager.reset();
649 }
650 
651 /**
652  * @tc.name: UIAbilityLifecycleManager_MoveToBackground_0100
653  * @tc.desc: MoveToBackground
654  * @tc.type: FUNC
655  */
656 HWTEST_F(UIAbilityLifecycleManagerTest, MoveToBackground_001, TestSize.Level1)
657 {
658     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
659     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
660     uiAbilityLifecycleManager->MoveToBackground(nullptr);
661     uiAbilityLifecycleManager.reset();
662 }
663 
664 /**
665  * @tc.name: UIAbilityLifecycleManager_MoveToBackground_0200
666  * @tc.desc: MoveToBackground
667  * @tc.type: FUNC
668  */
669 HWTEST_F(UIAbilityLifecycleManagerTest, MoveToBackground_002, TestSize.Level1)
670 {
671     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
672     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
673     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
674     uiAbilityLifecycleManager->MoveToBackground(abilityRecord);
675     uiAbilityLifecycleManager.reset();
676 }
677 
678 /**
679  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0100
680  * @tc.desc: PrintTimeOutLog
681  * @tc.type: FUNC
682  */
683 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_001, TestSize.Level1)
684 {
685     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
686     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
687     uint32_t msgId = 0;
688     uiAbilityLifecycleManager->PrintTimeOutLog(nullptr, msgId);
689     uiAbilityLifecycleManager.reset();
690 }
691 
692 /**
693  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0200
694  * @tc.desc: PrintTimeOutLog
695  * @tc.type: FUNC
696  */
697 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_002, TestSize.Level1)
698 {
699     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
700     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
701     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
702     uint32_t msgId = 0;
703     uiAbilityLifecycleManager->PrintTimeOutLog(abilityRecord, msgId);
704     uiAbilityLifecycleManager.reset();
705 }
706 
707 /**
708  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0300
709  * @tc.desc: PrintTimeOutLog
710  * @tc.type: FUNC
711  */
712 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_003, TestSize.Level1)
713 {
714     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
715     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
716     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
717     uint32_t msgId = 1;
718     uiAbilityLifecycleManager->PrintTimeOutLog(abilityRecord, msgId);
719     uiAbilityLifecycleManager.reset();
720 }
721 
722 /**
723  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0400
724  * @tc.desc: PrintTimeOutLog
725  * @tc.type: FUNC
726  */
727 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_004, TestSize.Level1)
728 {
729     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
730     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
731     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
732     uint32_t msgId = 2;
733     uiAbilityLifecycleManager->PrintTimeOutLog(abilityRecord, msgId);
734     uiAbilityLifecycleManager.reset();
735 }
736 
737 /**
738  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0500
739  * @tc.desc: PrintTimeOutLog
740  * @tc.type: FUNC
741  */
742 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_005, TestSize.Level1)
743 {
744     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
745     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
746     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
747     uint32_t msgId = 3;
748     uiAbilityLifecycleManager->PrintTimeOutLog(abilityRecord, msgId);
749     uiAbilityLifecycleManager.reset();
750 }
751 
752 /**
753  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0600
754  * @tc.desc: PrintTimeOutLog
755  * @tc.type: FUNC
756  */
757 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_006, TestSize.Level1)
758 {
759     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
760     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
761     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
762     uint32_t msgId = 4;
763     uiAbilityLifecycleManager->PrintTimeOutLog(abilityRecord, msgId);
764     uiAbilityLifecycleManager.reset();
765 }
766 
767 /**
768  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0700
769  * @tc.desc: PrintTimeOutLog
770  * @tc.type: FUNC
771  */
772 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_007, TestSize.Level1)
773 {
774     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
775     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
776     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
777     uint32_t msgId = 5;
778     uiAbilityLifecycleManager->PrintTimeOutLog(abilityRecord, msgId);
779     uiAbilityLifecycleManager.reset();
780 }
781 
782 /**
783  * @tc.name: UIAbilityLifecycleManager_PrintTimeOutLog_0800
784  * @tc.desc: PrintTimeOutLog
785  * @tc.type: FUNC
786  */
787 HWTEST_F(UIAbilityLifecycleManagerTest, PrintTimeOutLog_008, TestSize.Level1)
788 {
789     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
790     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
791     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
792     uint32_t msgId = 6;
793     uiAbilityLifecycleManager->PrintTimeOutLog(abilityRecord, msgId);
794     uiAbilityLifecycleManager.reset();
795 }
796 
797 /**
798  * @tc.name: UIAbilityLifecycleManager_CompleteBackground_0100
799  * @tc.desc: CompleteBackground
800  * @tc.type: FUNC
801  */
802 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteBackground_001, TestSize.Level1)
803 {
804     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
805     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
806     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
807     abilityRecord->currentState_ = AbilityState::FOREGROUND;
808     uiAbilityLifecycleManager->CompleteBackground(abilityRecord);
809     uiAbilityLifecycleManager.reset();
810 }
811 
812 /**
813  * @tc.name: UIAbilityLifecycleManager_CompleteBackground_0200
814  * @tc.desc: CompleteBackground
815  * @tc.type: FUNC
816  */
817 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteBackground_002, TestSize.Level1)
818 {
819     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
820     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
821     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
822     abilityRecord->currentState_ = AbilityState::BACKGROUNDING;
823     abilityRecord->SetPendingState(AbilityState::FOREGROUND);
824     uiAbilityLifecycleManager->CompleteBackground(abilityRecord);
825     uiAbilityLifecycleManager.reset();
826 }
827 
828 /**
829  * @tc.name: UIAbilityLifecycleManager_CompleteBackground_0300
830  * @tc.desc: CompleteBackground
831  * @tc.type: FUNC
832  */
833 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteBackground_003, TestSize.Level1)
834 {
835     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
836     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
837     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
838     abilityRecord->currentState_ = AbilityState::BACKGROUNDING;
839     abilityRecord->SetPendingState(AbilityState::BACKGROUND);
840     uiAbilityLifecycleManager->CompleteBackground(abilityRecord);
841     uiAbilityLifecycleManager.reset();
842 }
843 
844 /**
845  * @tc.name: UIAbilityLifecycleManager_CompleteBackground_0400
846  * @tc.desc: CompleteBackground
847  * @tc.type: FUNC
848  */
849 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteBackground_004, TestSize.Level1)
850 {
851     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
852     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
853     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
854     abilityRecord->currentState_ = AbilityState::BACKGROUNDING;
855     abilityRecord->SetPendingState(AbilityState::FOREGROUND);
856     uiAbilityLifecycleManager->CompleteBackground(abilityRecord);
857     uiAbilityLifecycleManager.reset();
858 }
859 
860 /**
861  * @tc.name: UIAbilityLifecycleManager_CompleteBackground_0500
862  * @tc.desc: CompleteBackground
863  * @tc.type: FUNC
864  */
865 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteBackground_005, TestSize.Level1)
866 {
867     auto mgr = std::make_shared<UIAbilityLifecycleManager>();
868     EXPECT_NE(mgr, nullptr);
869     AbilityRequest abilityRequest;
870     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
871     abilityRecord->currentState_ = AbilityState::BACKGROUNDING;
872     abilityRecord->SetStartedByCall(true);
873     abilityRecord->SetStartToBackground(true);
874     abilityRecord->isReady_ = true;
875     mgr->CompleteBackground(abilityRecord);
876     EXPECT_NE(mgr, nullptr);
877 }
878 
879 /**
880  * @tc.name: UIAbilityLifecycleManager_CompleteBackground_0600
881  * @tc.desc: CompleteBackground
882  * @tc.type: FUNC
883  */
884 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteBackground_006, TestSize.Level1)
885 {
886     auto mgr = std::make_shared<UIAbilityLifecycleManager>();
887     EXPECT_NE(mgr, nullptr);
888     AbilityRequest abilityRequest;
889     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
890     abilityRecord->currentState_ = AbilityState::BACKGROUNDING;
891     mgr->terminateAbilityList_.push_back(abilityRecord);
892     mgr->CompleteBackground(abilityRecord);
893     EXPECT_NE(mgr, nullptr);
894 }
895 
896 /**
897  * @tc.name: UIAbilityLifecycleManager_CloseUIAbility_0100
898  * @tc.desc: CloseUIAbility
899  * @tc.type: FUNC
900  */
901 HWTEST_F(UIAbilityLifecycleManagerTest, CloseUIAbility_001, TestSize.Level1)
902 {
903     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
904     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
905     abilityRecord->SetTerminatingState();
906     abilityRecord->currentState_ = AbilityState::BACKGROUND;
907     EXPECT_EQ(uiAbilityLifecycleManager->CloseUIAbility(abilityRecord, -1, nullptr), ERR_OK);
908     uiAbilityLifecycleManager.reset();
909 }
910 
911 /**
912  * @tc.name: UIAbilityLifecycleManager_CloseUIAbility_0200
913  * @tc.desc: CloseUIAbility
914  * @tc.type: FUNC
915  */
916 HWTEST_F(UIAbilityLifecycleManagerTest, CloseUIAbility_002, TestSize.Level1)
917 {
918     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
919     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
920     EXPECT_EQ(uiAbilityLifecycleManager->CloseUIAbility(abilityRecord, -1, nullptr), ERR_INVALID_VALUE);
921     uiAbilityLifecycleManager.reset();
922 }
923 
924 /**
925  * @tc.name: UIAbilityLifecycleManager_CloseUIAbility_0300
926  * @tc.desc: CloseUIAbility
927  * @tc.type: FUNC
928  */
929 HWTEST_F(UIAbilityLifecycleManagerTest, CloseUIAbility_003, TestSize.Level1)
930 {
931     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
932     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
933     Want want;
934     EXPECT_EQ(uiAbilityLifecycleManager->CloseUIAbility(abilityRecord, -1, &want), ERR_INVALID_VALUE);
935     uiAbilityLifecycleManager.reset();
936 }
937 
938 /**
939  * @tc.name: UIAbilityLifecycleManager_CloseUIAbility_0400
940  * @tc.desc: CloseUIAbility
941  * @tc.type: FUNC
942  */
943 HWTEST_F(UIAbilityLifecycleManagerTest, CloseUIAbility_004, TestSize.Level1)
944 {
945     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
946     auto abilityRecord = InitAbilityRecord();
947     abilityRecord->currentState_ = AbilityState::FOREGROUND;
948     Want want;
949     EXPECT_EQ(uiAbilityLifecycleManager->CloseUIAbility(abilityRecord, -1, &want), ERR_OK);
950     uiAbilityLifecycleManager.reset();
951 }
952 
953 /**
954  * @tc.name: UIAbilityLifecycleManager_CloseUIAbility_0500
955  * @tc.desc: CloseUIAbility
956  * @tc.type: FUNC
957  */
958 HWTEST_F(UIAbilityLifecycleManagerTest, CloseUIAbility_005, TestSize.Level1)
959 {
960     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
961     auto abilityRecord = InitAbilityRecord();
962     abilityRecord->currentState_ = AbilityState::FOREGROUNDING;
963     Want want;
964     EXPECT_EQ(uiAbilityLifecycleManager->CloseUIAbility(abilityRecord, -1, &want), ERR_OK);
965     uiAbilityLifecycleManager.reset();
966 }
967 
968 /**
969  * @tc.name: UIAbilityLifecycleManager_CloseUIAbility_0600
970  * @tc.desc: CloseUIAbility
971  * @tc.type: FUNC
972  */
973 HWTEST_F(UIAbilityLifecycleManagerTest, CloseUIAbility_006, TestSize.Level1)
974 {
975     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
976     auto abilityRecord = InitAbilityRecord();
977     abilityRecord->currentState_ = AbilityState::BACKGROUND;
978     Want want;
979     EXPECT_EQ(uiAbilityLifecycleManager->CloseUIAbility(abilityRecord, -1, &want), ERR_OK);
980     uiAbilityLifecycleManager.reset();
981 }
982 
983 /**
984  * @tc.name: UIAbilityLifecycleManager_DelayCompleteTerminate_0100
985  * @tc.desc: DelayCompleteTerminate
986  * @tc.type: FUNC
987  */
988 HWTEST_F(UIAbilityLifecycleManagerTest, DelayCompleteTerminate_001, TestSize.Level1)
989 {
990     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
991     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
992     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
993     uiAbilityLifecycleManager->DelayCompleteTerminate(abilityRecord);
994     uiAbilityLifecycleManager.reset();
995 }
996 
997 /**
998  * @tc.name: UIAbilityLifecycleManager_CompleteTerminate_0100
999  * @tc.desc: CompleteTerminate
1000  * @tc.type: FUNC
1001  */
1002 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteTerminate_001, TestSize.Level1)
1003 {
1004     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1005     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1006     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1007     abilityRecord->currentState_ = AbilityState::BACKGROUND;
1008     uiAbilityLifecycleManager->CompleteTerminate(abilityRecord);
1009     uiAbilityLifecycleManager.reset();
1010 }
1011 
1012 /**
1013  * @tc.name: UIAbilityLifecycleManager_CompleteTerminate_0200
1014  * @tc.desc: CompleteTerminate
1015  * @tc.type: FUNC
1016  */
1017 HWTEST_F(UIAbilityLifecycleManagerTest, CompleteTerminate_002, TestSize.Level1)
1018 {
1019     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1020     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1021     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1022     abilityRecord->currentState_ = AbilityState::TERMINATING;
1023     uiAbilityLifecycleManager->CompleteTerminate(abilityRecord);
1024     uiAbilityLifecycleManager.reset();
1025 }
1026 
1027 /**
1028  * @tc.name: UIAbilityLifecycleManager_OnTimeOut_0100
1029  * @tc.desc: OnTimeOut
1030  * @tc.type: FUNC
1031  */
1032 HWTEST_F(UIAbilityLifecycleManagerTest, OnTimeOut_001, TestSize.Level1)
1033 {
1034     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1035     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1036     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1037     uint32_t msgId = 0;
1038     int64_t abilityRecordId = 0;
1039     uiAbilityLifecycleManager->OnTimeOut(msgId, abilityRecordId);
1040     uiAbilityLifecycleManager.reset();
1041 }
1042 
1043 /**
1044  * @tc.name: UIAbilityLifecycleManager_OnTimeOut_0200
1045  * @tc.desc: OnTimeOut
1046  * @tc.type: FUNC
1047  */
1048 HWTEST_F(UIAbilityLifecycleManagerTest, OnTimeOut_002, TestSize.Level1)
1049 {
1050     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1051     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1052     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1053     uint32_t msgId = 0;
1054     int64_t abilityRecordId = 0;
1055     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
1056     uiAbilityLifecycleManager->OnTimeOut(msgId, abilityRecordId);
1057     uiAbilityLifecycleManager.reset();
1058 }
1059 
1060 /**
1061  * @tc.name: UIAbilityLifecycleManager_OnTimeOut_0300
1062  * @tc.desc: OnTimeOut
1063  * @tc.type: FUNC
1064  */
1065 HWTEST_F(UIAbilityLifecycleManagerTest, OnTimeOut_003, TestSize.Level1)
1066 {
1067     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1068     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1069     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1070     uint32_t msgId = 5;
1071     int64_t abilityRecordId = 0;
1072     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
1073     uiAbilityLifecycleManager->OnTimeOut(msgId, abilityRecordId);
1074     uiAbilityLifecycleManager.reset();
1075 }
1076 
1077 /**
1078  * @tc.name: UIAbilityLifecycleManager_OnTimeOut_0400
1079  * @tc.desc: OnTimeOut
1080  * @tc.type: FUNC
1081  */
1082 HWTEST_F(UIAbilityLifecycleManagerTest, OnTimeOut_004, TestSize.Level1)
1083 {
1084     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1085     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1086     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1087     uint32_t msgId = 6;
1088     int64_t abilityRecordId = 0;
1089     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(msgId, abilityRecord);
1090     uiAbilityLifecycleManager->OnTimeOut(msgId, abilityRecordId);
1091     uiAbilityLifecycleManager.reset();
1092 }
1093 
1094 /**
1095  * @tc.name: UIAbilityLifecycleManager_NotifySCBToHandleException_0100
1096  * @tc.desc: NotifySCBToHandleException
1097  * @tc.type: FUNC
1098  */
1099 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToHandleException_001, TestSize.Level1)
1100 {
1101     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1102     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1103     uiAbilityLifecycleManager->NotifySCBToHandleException(nullptr,
1104         static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT), "handleLoadTimeout");
1105     uiAbilityLifecycleManager.reset();
1106 }
1107 
1108 /**
1109  * @tc.name: UIAbilityLifecycleManager_NotifySCBToHandleException_0200
1110  * @tc.desc: NotifySCBToHandleException
1111  * @tc.type: FUNC
1112  */
1113 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToHandleException_002, TestSize.Level1)
1114 {
1115     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1116     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1117     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1118     uiAbilityLifecycleManager->NotifySCBToHandleException(abilityRecord,
1119         static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT), "handleLoadTimeout");
1120     uiAbilityLifecycleManager.reset();
1121 }
1122 
1123 /**
1124  * @tc.name: UIAbilityLifecycleManager_NotifySCBToHandleException_0300
1125  * @tc.desc: NotifySCBToHandleException
1126  * @tc.type: FUNC
1127  */
1128 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToHandleException_003, TestSize.Level1)
1129 {
1130     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1131     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1132     AbilityRequest abilityRequest;
1133     sptr<SessionInfo> sessionInfo(new SessionInfo());
1134     abilityRequest.sessionInfo = sessionInfo;
1135     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1136     uiAbilityLifecycleManager->NotifySCBToHandleException(abilityRecord,
1137         static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT), "handleLoadTimeout");
1138     uiAbilityLifecycleManager.reset();
1139 }
1140 
1141 /**
1142  * @tc.name: UIAbilityLifecycleManager_NotifySCBToHandleException_0400
1143  * @tc.desc: NotifySCBToHandleException
1144  * @tc.type: FUNC
1145  */
1146 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToHandleException_004, TestSize.Level1)
1147 {
1148     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1149     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1150     AbilityRequest abilityRequest;
1151     Rosen::SessionInfo info;
1152     sptr<SessionInfo> sessionInfo(new SessionInfo());
1153     sessionInfo->sessionToken = new Rosen::Session(info);
1154     abilityRequest.sessionInfo = sessionInfo;
1155     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1156     uiAbilityLifecycleManager->NotifySCBToHandleException(abilityRecord,
1157         static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT), "handleLoadTimeout");
1158     uiAbilityLifecycleManager.reset();
1159 }
1160 
1161 /**
1162  * @tc.name: UIAbilityLifecycleManager_NotifySCBToHandleException_0500
1163  * @tc.desc: NotifySCBToHandleException
1164  * @tc.type: FUNC
1165  */
1166 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToHandleException_005, TestSize.Level1)
1167 {
1168     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1169     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1170     AbilityRequest abilityRequest;
1171     Rosen::SessionInfo info;
1172     sptr<SessionInfo> sessionInfo(new SessionInfo());
1173     sessionInfo->sessionToken = new Rosen::Session(info);
1174     abilityRequest.sessionInfo = sessionInfo;
1175     sessionInfo->persistentId = 0;
1176     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1177     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1178     uiAbilityLifecycleManager->NotifySCBToHandleException(abilityRecord,
1179         static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT), "handleLoadTimeout");
1180     uiAbilityLifecycleManager.reset();
1181 }
1182 
1183 /**
1184  * @tc.name: UIAbilityLifecycleManager_NotifySCBToHandleException_0600
1185  * @tc.desc: NotifySCBToHandleException
1186  * @tc.type: FUNC
1187  */
1188 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToHandleException_006, TestSize.Level1)
1189 {
1190     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1191     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1192     AbilityRequest abilityRequest;
1193     Rosen::SessionInfo info;
1194     sptr<SessionInfo> sessionInfo(new SessionInfo());
1195     sessionInfo->sessionToken = new Rosen::Session(info);
1196     abilityRequest.sessionInfo = sessionInfo;
1197     sessionInfo->persistentId = 0;
1198     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1199     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1200     uiAbilityLifecycleManager->NotifySCBToHandleException(abilityRecord,
1201         static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_FOREGROUND_TIMEOUT), "handleForegroundTimeout");
1202     uiAbilityLifecycleManager.reset();
1203 }
1204 
1205 /**
1206  * @tc.name: UIAbilityLifecycleManager_NotifySCBToHandleException_0700
1207  * @tc.desc: NotifySCBToHandleException
1208  * @tc.type: FUNC
1209  */
1210 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToHandleException_007, TestSize.Level1)
1211 {
1212     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1213     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1214     AbilityRequest abilityRequest;
1215     Rosen::SessionInfo info;
1216     sptr<SessionInfo> sessionInfo(new SessionInfo());
1217     sessionInfo->sessionToken = new Rosen::Session(info);
1218     abilityRequest.sessionInfo = sessionInfo;
1219     sessionInfo->persistentId = 0;
1220     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1221     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1222     uiAbilityLifecycleManager->NotifySCBToHandleException(abilityRecord,
1223         static_cast<int32_t>(ErrorLifecycleState::ABILITY_STATE_DIED), "onAbilityDied");
1224     uiAbilityLifecycleManager.reset();
1225 }
1226 
1227 /**
1228  * @tc.name: UIAbilityLifecycleManager_HandleLoadTimeout_0100
1229  * @tc.desc: HandleLoadTimeout
1230  * @tc.type: FUNC
1231  */
1232 HWTEST_F(UIAbilityLifecycleManagerTest, HandleLoadTimeout_001, TestSize.Level1)
1233 {
1234     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1235     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1236     uiAbilityLifecycleManager->HandleLoadTimeout(nullptr);
1237     uiAbilityLifecycleManager.reset();
1238 }
1239 
1240 /**
1241  * @tc.name: UIAbilityLifecycleManager_HandleLoadTimeout_0200
1242  * @tc.desc: HandleLoadTimeout
1243  * @tc.type: FUNC
1244  */
1245 HWTEST_F(UIAbilityLifecycleManagerTest, HandleLoadTimeout_002, TestSize.Level1)
1246 {
1247     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1248     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1249     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1250     uiAbilityLifecycleManager->HandleLoadTimeout(abilityRecord);
1251     uiAbilityLifecycleManager.reset();
1252 }
1253 
1254 /**
1255  * @tc.name: UIAbilityLifecycleManager_HandleLoadTimeout_0300
1256  * @tc.desc: HandleLoadTimeout
1257  * @tc.type: FUNC
1258  */
1259 HWTEST_F(UIAbilityLifecycleManagerTest, HandleLoadTimeout_003, TestSize.Level1)
1260 {
1261     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1262     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1263     AbilityRequest abilityRequest;
1264     sptr<SessionInfo> sessionInfo(new SessionInfo());
1265     abilityRequest.sessionInfo = sessionInfo;
1266     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1267     uiAbilityLifecycleManager->HandleLoadTimeout(abilityRecord);
1268     uiAbilityLifecycleManager.reset();
1269 }
1270 
1271 /**
1272  * @tc.name: UIAbilityLifecycleManager_HandleLoadTimeout_0400
1273  * @tc.desc: HandleLoadTimeout
1274  * @tc.type: FUNC
1275  */
1276 HWTEST_F(UIAbilityLifecycleManagerTest, HandleLoadTimeout_004, TestSize.Level1)
1277 {
1278     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1279     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1280     AbilityRequest abilityRequest;
1281     Rosen::SessionInfo info;
1282     sptr<SessionInfo> sessionInfo(new SessionInfo());
1283     sessionInfo->sessionToken = new Rosen::Session(info);
1284     abilityRequest.sessionInfo = sessionInfo;
1285     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1286     uiAbilityLifecycleManager->HandleLoadTimeout(abilityRecord);
1287     uiAbilityLifecycleManager.reset();
1288 }
1289 
1290 /**
1291  * @tc.name: UIAbilityLifecycleManager_HandleLoadTimeout_0500
1292  * @tc.desc: HandleLoadTimeout
1293  * @tc.type: FUNC
1294  */
1295 HWTEST_F(UIAbilityLifecycleManagerTest, HandleLoadTimeout_005, TestSize.Level1)
1296 {
1297     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1298     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1299     AbilityRequest abilityRequest;
1300     Rosen::SessionInfo info;
1301     sptr<SessionInfo> sessionInfo(new SessionInfo());
1302     sessionInfo->sessionToken = new Rosen::Session(info);
1303     abilityRequest.sessionInfo = sessionInfo;
1304     sessionInfo->persistentId = 0;
1305     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1306     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1307     uiAbilityLifecycleManager->HandleLoadTimeout(abilityRecord);
1308     uiAbilityLifecycleManager.reset();
1309 }
1310 
1311 /**
1312  * @tc.name: UIAbilityLifecycleManager_HandleForegroundTimeout_0100
1313  * @tc.desc: HandleForegroundTimeout
1314  * @tc.type: FUNC
1315  */
1316 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundTimeout_001, TestSize.Level1)
1317 {
1318     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1319     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1320     uiAbilityLifecycleManager->HandleForegroundTimeout(nullptr);
1321     uiAbilityLifecycleManager.reset();
1322 }
1323 
1324 /**
1325  * @tc.name: UIAbilityLifecycleManager_HandleForegroundTimeout_0200
1326  * @tc.desc: HandleForegroundTimeout
1327  * @tc.type: FUNC
1328  */
1329 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundTimeout_002, TestSize.Level1)
1330 {
1331     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1332     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1333     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1334     abilityRecord->currentState_ = AbilityState::TERMINATING;
1335     uiAbilityLifecycleManager->HandleForegroundTimeout(abilityRecord);
1336     uiAbilityLifecycleManager.reset();
1337 }
1338 
1339 /**
1340  * @tc.name: UIAbilityLifecycleManager_HandleForegroundTimeout_0300
1341  * @tc.desc: HandleForegroundTimeout
1342  * @tc.type: FUNC
1343  */
1344 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundTimeout_003, TestSize.Level1)
1345 {
1346     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1347     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1348     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1349     abilityRecord->currentState_ = AbilityState::FOREGROUNDING;
1350     uiAbilityLifecycleManager->HandleForegroundTimeout(abilityRecord);
1351     uiAbilityLifecycleManager.reset();
1352 }
1353 
1354 /**
1355  * @tc.name: UIAbilityLifecycleManager_HandleForegroundTimeout_0400
1356  * @tc.desc: HandleForegroundTimeout
1357  * @tc.type: FUNC
1358  */
1359 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundTimeout_004, TestSize.Level1)
1360 {
1361     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1362     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1363     AbilityRequest abilityRequest;
1364     sptr<SessionInfo> sessionInfo(new SessionInfo());
1365     abilityRequest.sessionInfo = sessionInfo;
1366     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1367     abilityRecord->currentState_ = AbilityState::FOREGROUNDING;
1368     uiAbilityLifecycleManager->HandleForegroundTimeout(abilityRecord);
1369     uiAbilityLifecycleManager.reset();
1370 }
1371 
1372 /**
1373  * @tc.name: UIAbilityLifecycleManager_HandleForegroundTimeout_0500
1374  * @tc.desc: HandleForegroundTimeout
1375  * @tc.type: FUNC
1376  */
1377 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundTimeout_005, TestSize.Level1)
1378 {
1379     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1380     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1381     AbilityRequest abilityRequest;
1382     Rosen::SessionInfo info;
1383     sptr<SessionInfo> sessionInfo(new SessionInfo());
1384     sessionInfo->sessionToken = new Rosen::Session(info);
1385     abilityRequest.sessionInfo = sessionInfo;
1386     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1387     abilityRecord->currentState_ = AbilityState::FOREGROUNDING;
1388     uiAbilityLifecycleManager->HandleForegroundTimeout(abilityRecord);
1389     uiAbilityLifecycleManager.reset();
1390 }
1391 
1392 /**
1393  * @tc.name: UIAbilityLifecycleManager_HandleForegroundTimeout_0600
1394  * @tc.desc: HandleForegroundTimeout
1395  * @tc.type: FUNC
1396  */
1397 HWTEST_F(UIAbilityLifecycleManagerTest, HandleForegroundTimeout_006, TestSize.Level1)
1398 {
1399     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1400     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1401     AbilityRequest abilityRequest;
1402     Rosen::SessionInfo info;
1403     sptr<SessionInfo> sessionInfo(new SessionInfo());
1404     sessionInfo->sessionToken = new Rosen::Session(info);
1405     abilityRequest.sessionInfo = sessionInfo;
1406     sessionInfo->persistentId = 0;
1407     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1408     abilityRecord->currentState_ = AbilityState::FOREGROUNDING;
1409     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1410     uiAbilityLifecycleManager->HandleForegroundTimeout(abilityRecord);
1411     uiAbilityLifecycleManager.reset();
1412 }
1413 
1414 /**
1415  * @tc.name: UIAbilityLifecycleManager_OnAbilityDied_0100
1416  * @tc.desc: OnAbilityDied
1417  * @tc.type: FUNC
1418  */
1419 HWTEST_F(UIAbilityLifecycleManagerTest, OnAbilityDied_001, TestSize.Level1)
1420 {
1421     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1422     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1423     uiAbilityLifecycleManager->OnAbilityDied(nullptr);
1424     uiAbilityLifecycleManager.reset();
1425 }
1426 
1427 /**
1428  * @tc.name: UIAbilityLifecycleManager_OnAbilityDied_0200
1429  * @tc.desc: OnAbilityDied
1430  * @tc.type: FUNC
1431  */
1432 HWTEST_F(UIAbilityLifecycleManagerTest, OnAbilityDied_002, TestSize.Level1)
1433 {
1434     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1435     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1436     std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
1437     uiAbilityLifecycleManager->OnAbilityDied(abilityRecord);
1438     uiAbilityLifecycleManager.reset();
1439 }
1440 
1441 /**
1442  * @tc.name: UIAbilityLifecycleManager_OnAbilityDied_0300
1443  * @tc.desc: OnAbilityDied
1444  * @tc.type: FUNC
1445  */
1446 HWTEST_F(UIAbilityLifecycleManagerTest, OnAbilityDied_003, TestSize.Level1)
1447 {
1448     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1449     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1450     AbilityRequest abilityRequest;
1451     sptr<SessionInfo> sessionInfo(new SessionInfo());
1452     abilityRequest.sessionInfo = sessionInfo;
1453     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1454     uiAbilityLifecycleManager->OnAbilityDied(abilityRecord);
1455     uiAbilityLifecycleManager.reset();
1456 }
1457 
1458 /**
1459  * @tc.name: UIAbilityLifecycleManager_OnAbilityDied_0400
1460  * @tc.desc: OnAbilityDied
1461  * @tc.type: FUNC
1462  */
1463 HWTEST_F(UIAbilityLifecycleManagerTest, OnAbilityDied_004, TestSize.Level1)
1464 {
1465     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1466     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1467     AbilityRequest abilityRequest;
1468     Rosen::SessionInfo info;
1469     sptr<SessionInfo> sessionInfo(new SessionInfo());
1470     sessionInfo->sessionToken = new Rosen::Session(info);
1471     abilityRequest.sessionInfo = sessionInfo;
1472     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1473     uiAbilityLifecycleManager->OnAbilityDied(abilityRecord);
1474     uiAbilityLifecycleManager.reset();
1475 }
1476 
1477 /**
1478  * @tc.name: UIAbilityLifecycleManager_OnAbilityDied_0500
1479  * @tc.desc: OnAbilityDied
1480  * @tc.type: FUNC
1481  */
1482 HWTEST_F(UIAbilityLifecycleManagerTest, OnAbilityDied_005, TestSize.Level1)
1483 {
1484     auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
1485     ASSERT_NE(uiAbilityLifecycleManager, nullptr);
1486     AbilityRequest abilityRequest;
1487     Rosen::SessionInfo info;
1488     sptr<SessionInfo> sessionInfo(new SessionInfo());
1489     sessionInfo->sessionToken = new Rosen::Session(info);
1490     abilityRequest.sessionInfo = sessionInfo;
1491     sessionInfo->persistentId = 0;
1492     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1493     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1494     uiAbilityLifecycleManager->OnAbilityDied(abilityRecord);
1495     uiAbilityLifecycleManager.reset();
1496 }
1497 
1498 /**
1499  * @tc.name: UIAbilityLifecycleManager_SetRootSceneSession_0100
1500  * @tc.desc: SetRootSceneSession
1501  * @tc.type: FUNC
1502  */
1503 HWTEST_F(UIAbilityLifecycleManagerTest, SetRootSceneSession_001, TestSize.Level1)
1504 {
1505     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1506     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1507     sptr<IRemoteObject> object = nullptr;
1508     uiAbilityLifecycleManager->SetRootSceneSession(object);
1509     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1510 }
1511 
1512 /**
1513  * @tc.name: UIAbilityLifecycleManager_SetRootSceneSession_0200
1514  * @tc.desc: SetRootSceneSession
1515  * @tc.type: FUNC
1516  */
1517 HWTEST_F(UIAbilityLifecycleManagerTest, SetRootSceneSession_002, TestSize.Level1)
1518 {
1519     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1520     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1521     auto abilityRecord = InitAbilityRecord();
1522     EXPECT_NE(abilityRecord, nullptr);
1523     auto token = abilityRecord->GetToken();
1524     EXPECT_NE(token, nullptr);
1525     auto object = token->AsObject();
1526     uiAbilityLifecycleManager->SetRootSceneSession(object);
1527     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1528 }
1529 
1530 /**
1531  * @tc.name: UIAbilityLifecycleManager_SetRootSceneSession_0300
1532  * @tc.desc: SetRootSceneSession
1533  * @tc.type: FUNC
1534  */
1535 HWTEST_F(UIAbilityLifecycleManagerTest, SetRootSceneSession_003, TestSize.Level1)
1536 {
1537     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1538     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1539     Rosen::SessionInfo info;
1540     sptr<Rosen::ISession> session = new Rosen::Session(info);
1541     EXPECT_NE(session, nullptr);
1542     sptr<IRemoteObject> rootSceneSession = session->AsObject();
1543     uiAbilityLifecycleManager->SetRootSceneSession(rootSceneSession);
1544     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1545 }
1546 
1547 /**
1548  * @tc.name: UIAbilityLifecycleManager_NotifySCBToStartUIAbility_0100
1549  * @tc.desc: NotifySCBToStartUIAbility
1550  * @tc.type: FUNC
1551  */
1552 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToStartUIAbility_001, TestSize.Level1)
1553 {
1554     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1555     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1556     AbilityRequest abilityRequest;
1557     int32_t userId = 100;
1558     uiAbilityLifecycleManager->NotifySCBToStartUIAbility(abilityRequest, userId);
1559     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1560 }
1561 
1562 /**
1563  * @tc.name: UIAbilityLifecycleManager_GetPersistentIdByAbilityRequest_0100
1564  * @tc.desc: GetPersistentIdByAbilityRequest
1565  * @tc.type: FUNC
1566  */
1567 HWTEST_F(UIAbilityLifecycleManagerTest, GetPersistentIdByAbilityRequest_001, TestSize.Level1)
1568 {
1569     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1570     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1571     AbilityRequest abilityRequest;
1572     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SPECIFIED;
1573     bool reuse = false;
1574     int32_t userId = 100;
1575     EXPECT_EQ(uiAbilityLifecycleManager->GetPersistentIdByAbilityRequest(abilityRequest, reuse, userId), 0);
1576 }
1577 
1578 /**
1579  * @tc.name: UIAbilityLifecycleManager_GetPersistentIdByAbilityRequest_0200
1580  * @tc.desc: GetPersistentIdByAbilityRequest
1581  * @tc.type: FUNC
1582  */
1583 HWTEST_F(UIAbilityLifecycleManagerTest, GetPersistentIdByAbilityRequest_002, TestSize.Level1)
1584 {
1585     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1586     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1587     AbilityRequest abilityRequest;
1588     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::STANDARD;
1589     bool reuse = false;
1590     int32_t userId = 100;
1591     EXPECT_EQ(uiAbilityLifecycleManager->GetPersistentIdByAbilityRequest(abilityRequest, reuse, userId), 0);
1592 }
1593 
1594 /**
1595  * @tc.name: UIAbilityLifecycleManager_GetPersistentIdByAbilityRequest_0300
1596  * @tc.desc: GetPersistentIdByAbilityRequest
1597  * @tc.type: FUNC
1598  */
1599 HWTEST_F(UIAbilityLifecycleManagerTest, GetPersistentIdByAbilityRequest_003, TestSize.Level1)
1600 {
1601     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1602     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1603     AbilityRequest abilityRequest;
1604     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SINGLETON;
1605     abilityRequest.abilityInfo.name = "testAbility";
1606     abilityRequest.abilityInfo.moduleName = "testModule";
1607     abilityRequest.abilityInfo.bundleName = "com.test.ut";
1608 
1609     Rosen::SessionInfo info;
1610     sptr<SessionInfo> sessionInfo(new SessionInfo());
1611     sessionInfo->sessionToken = new Rosen::Session(info);
1612     sessionInfo->persistentId = 1;
1613     abilityRequest.sessionInfo = sessionInfo;
1614     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1615     int32_t userId = 100;
1616     abilityRecord->SetOwnerMissionUserId(userId);
1617     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1618     bool reuse = false;
1619     EXPECT_EQ(uiAbilityLifecycleManager->GetPersistentIdByAbilityRequest(abilityRequest, reuse, userId),
1620         sessionInfo->persistentId);
1621 }
1622 
1623 /**
1624  * @tc.name: UIAbilityLifecycleManager_GetPersistentIdByAbilityRequest_0400
1625  * @tc.desc: GetPersistentIdByAbilityRequest
1626  * @tc.type: FUNC
1627  */
1628 HWTEST_F(UIAbilityLifecycleManagerTest, GetPersistentIdByAbilityRequest_004, TestSize.Level1)
1629 {
1630     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1631     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1632     AbilityRequest abilityRequest1;
1633     abilityRequest1.abilityInfo.launchMode = AppExecFwk::LaunchMode::SINGLETON;
1634 
1635     Rosen::SessionInfo info;
1636     sptr<SessionInfo> sessionInfo(new SessionInfo());
1637     sessionInfo->sessionToken = new Rosen::Session(info);
1638     sessionInfo->persistentId = 1;
1639     AbilityRequest abilityRequest;
1640     abilityRequest.sessionInfo = sessionInfo;
1641     abilityRequest.abilityInfo.name = "testAbility";
1642     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1643     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1644     bool reuse = false;
1645     int32_t userId = 100;
1646     EXPECT_EQ(uiAbilityLifecycleManager->GetPersistentIdByAbilityRequest(abilityRequest1, reuse, userId), 0);
1647 }
1648 
1649 /**
1650  * @tc.name: UIAbilityLifecycleManager_GetReusedSpecifiedPersistentId_0100
1651  * @tc.desc: GetReusedSpecifiedPersistentId
1652  * @tc.type: FUNC
1653  */
1654 HWTEST_F(UIAbilityLifecycleManagerTest, GetReusedSpecifiedPersistentId_001, TestSize.Level1)
1655 {
1656     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1657     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1658     AbilityRequest abilityRequest;
1659     bool reuse = false;
1660     int32_t userId = 100;
1661     EXPECT_EQ(uiAbilityLifecycleManager->GetReusedSpecifiedPersistentId(abilityRequest, reuse, userId), 0);
1662 }
1663 
1664 /**
1665  * @tc.name: UIAbilityLifecycleManager_GetReusedSpecifiedPersistentId_0200
1666  * @tc.desc: GetReusedSpecifiedPersistentId
1667  * @tc.type: FUNC
1668  */
1669 HWTEST_F(UIAbilityLifecycleManagerTest, GetReusedSpecifiedPersistentId_002, TestSize.Level1)
1670 {
1671     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1672     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1673     AbilityRequest abilityRequest;
1674     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SPECIFIED;
1675     abilityRequest.abilityInfo.name = "testAbility";
1676     abilityRequest.abilityInfo.moduleName = "testModule";
1677     abilityRequest.abilityInfo.bundleName = "com.test.ut";
1678     abilityRequest.startRecent = true;
1679     std::string flag = "specified";
1680     abilityRequest.specifiedFlag = flag;
1681 
1682     Rosen::SessionInfo info;
1683     sptr<SessionInfo> sessionInfo(new SessionInfo());
1684     sessionInfo->sessionToken = new Rosen::Session(info);
1685     sessionInfo->persistentId = 1;
1686     abilityRequest.sessionInfo = sessionInfo;
1687     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1688     abilityRecord->SetSpecifiedFlag(flag);
1689     int32_t userId = 100;
1690     abilityRecord->SetOwnerMissionUserId(userId);
1691     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1692     bool reuse = false;
1693     EXPECT_EQ(uiAbilityLifecycleManager->GetReusedSpecifiedPersistentId(abilityRequest, reuse, userId),
1694         sessionInfo->persistentId);
1695 }
1696 
1697 /**
1698  * @tc.name: UIAbilityLifecycleManager_GetReusedSpecifiedPersistentId_0300
1699  * @tc.desc: GetReusedSpecifiedPersistentId
1700  * @tc.type: FUNC
1701  */
1702 HWTEST_F(UIAbilityLifecycleManagerTest, GetReusedSpecifiedPersistentId_003, TestSize.Level1)
1703 {
1704     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1705     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1706     AbilityRequest abilityRequest;
1707     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SPECIFIED;
1708     abilityRequest.startRecent = true;
1709     std::string flag = "specified";
1710 
1711     Rosen::SessionInfo info;
1712     sptr<SessionInfo> sessionInfo(new SessionInfo());
1713     sessionInfo->sessionToken = new Rosen::Session(info);
1714     sessionInfo->persistentId = 1;
1715     abilityRequest.sessionInfo = sessionInfo;
1716     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1717     abilityRecord->SetSpecifiedFlag(flag);
1718     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1719     bool reuse = false;
1720     int32_t userId = 100;
1721     EXPECT_EQ(uiAbilityLifecycleManager->GetReusedSpecifiedPersistentId(abilityRequest, reuse, userId), 0);
1722 }
1723 
1724 /**
1725  * @tc.name: UIAbilityLifecycleManager_GetReusedStandardPersistentId_0100
1726  * @tc.desc: GetReusedStandardPersistentId
1727  * @tc.type: FUNC
1728  */
1729 HWTEST_F(UIAbilityLifecycleManagerTest, GetReusedStandardPersistentId_001, TestSize.Level1)
1730 {
1731     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1732     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1733     AbilityRequest abilityRequest;
1734     bool reuse = false;
1735     int32_t userId = 100;
1736     EXPECT_EQ(uiAbilityLifecycleManager->GetReusedStandardPersistentId(abilityRequest, reuse, userId), 0);
1737 }
1738 
1739 /**
1740  * @tc.name: UIAbilityLifecycleManager_GetReusedStandardPersistentId_0200
1741  * @tc.desc: GetReusedStandardPersistentId
1742  * @tc.type: FUNC
1743  */
1744 HWTEST_F(UIAbilityLifecycleManagerTest, GetReusedStandardPersistentId_002, TestSize.Level1)
1745 {
1746     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1747     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1748     AbilityRequest abilityRequest;
1749     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::STANDARD;
1750     abilityRequest.abilityInfo.name = "testAbility";
1751     abilityRequest.abilityInfo.moduleName = "testModule";
1752     abilityRequest.abilityInfo.bundleName = "com.test.ut";
1753     abilityRequest.startRecent = true;
1754 
1755     Rosen::SessionInfo info;
1756     sptr<SessionInfo> sessionInfo(new SessionInfo());
1757     sessionInfo->sessionToken = new Rosen::Session(info);
1758     sessionInfo->persistentId = 1;
1759     abilityRequest.sessionInfo = sessionInfo;
1760     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1761     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1762     bool reuse = false;
1763     int32_t userId = 100;
1764     abilityRecord->SetOwnerMissionUserId(userId);
1765     EXPECT_EQ(uiAbilityLifecycleManager->GetReusedStandardPersistentId(abilityRequest, reuse, userId),
1766         sessionInfo->persistentId);
1767 }
1768 
1769 /**
1770  * @tc.name: UIAbilityLifecycleManager_NotifySCBPendingActivation_0100
1771  * @tc.desc: NotifySCBPendingActivation
1772  * @tc.type: FUNC
1773  */
1774 HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBPendingActivation_001, TestSize.Level1)
1775 {
1776     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1777     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1778     AbilityRequest abilityRequest;
1779     Rosen::SessionInfo info;
1780     sptr<SessionInfo> sessionInfo(new SessionInfo());
1781     sessionInfo->sessionToken = new Rosen::Session(info);
1782     sessionInfo->persistentId = 1;
1783     abilityRequest.sessionInfo = sessionInfo;
1784     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1785     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1786     auto token = abilityRecord->GetToken();
1787     EXPECT_NE(token, nullptr);
1788     abilityRequest.callerToken = token->AsObject();
1789     uiAbilityLifecycleManager->NotifySCBPendingActivation(sessionInfo, abilityRequest);
1790     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1791 }
1792 
1793 /**
1794  * @tc.name: UIAbilityLifecycleManager_ResolveLocked_0100
1795  * @tc.desc: ResolveLocked
1796  * @tc.type: FUNC
1797  */
1798 HWTEST_F(UIAbilityLifecycleManagerTest, ResolveLocked_001, TestSize.Level1)
1799 {
1800     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1801     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1802     AbilityRequest abilityRequest;
1803     int32_t userId = 100;
1804     EXPECT_EQ(uiAbilityLifecycleManager->ResolveLocked(abilityRequest, userId), RESOLVE_CALL_ABILITY_INNER_ERR);
1805 }
1806 
1807 /**
1808  * @tc.name: UIAbilityLifecycleManager_ResolveLocked_0200
1809  * @tc.desc: ResolveLocked
1810  * @tc.type: FUNC
1811  */
1812 HWTEST_F(UIAbilityLifecycleManagerTest, ResolveLocked_002, TestSize.Level1)
1813 {
1814     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1815     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1816     AbilityRequest abilityRequest;
1817     abilityRequest.callType = AbilityCallType::CALL_REQUEST_TYPE;
1818     int32_t userId = 100;
1819     EXPECT_EQ(uiAbilityLifecycleManager->ResolveLocked(abilityRequest, userId), RESOLVE_CALL_ABILITY_INNER_ERR);
1820 }
1821 
1822 /**
1823  * @tc.name: UIAbilityLifecycleManager_CallAbilityLocked_0100
1824  * @tc.desc: CallAbilityLocked
1825  * @tc.type: FUNC
1826  */
1827 HWTEST_F(UIAbilityLifecycleManagerTest, CallAbilityLocked_001, TestSize.Level1)
1828 {
1829     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1830     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1831 
1832     AbilityRequest abilityRequest;
1833     Rosen::SessionInfo info;
1834     sptr<SessionInfo> sessionInfo(new SessionInfo());
1835     sessionInfo->sessionToken = new Rosen::Session(info);
1836     sessionInfo->persistentId = 1;
1837     Want want;
1838     want.SetParam(Want::PARAM_RESV_CALL_TO_FOREGROUND, true);
1839     abilityRequest.sessionInfo = sessionInfo;
1840     abilityRequest.want = want;
1841     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SINGLETON;
1842     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1843     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
1844     abilityRecord->isReady_ = true;
1845 
1846     int32_t userId = 100;
1847     uiAbilityLifecycleManager->CallAbilityLocked(abilityRequest, userId);
1848     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1849 }
1850 
1851 /**
1852  * @tc.name: UIAbilityLifecycleManager_CallAbilityLocked_0200
1853  * @tc.desc: CallAbilityLocked
1854  * @tc.type: FUNC
1855  */
1856 HWTEST_F(UIAbilityLifecycleManagerTest, CallAbilityLocked_002, TestSize.Level1)
1857 {
1858     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1859     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1860     AbilityRequest abilityRequest;
1861     abilityRequest.callType = AbilityCallType::CALL_REQUEST_TYPE;
1862     Want want;
1863     want.SetParam(Want::PARAM_RESV_CALL_TO_FOREGROUND, true);
1864     abilityRequest.want = want;
1865     int32_t userId = 100;
1866     uiAbilityLifecycleManager->CallAbilityLocked(abilityRequest, userId);
1867     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1868 }
1869 
1870 /**
1871  * @tc.name: UIAbilityLifecycleManager_CallUIAbilityBySCB_0100
1872  * @tc.desc: CallUIAbilityBySCB
1873  * @tc.type: FUNC
1874  */
1875 HWTEST_F(UIAbilityLifecycleManagerTest, CallUIAbilityBySCB_001, TestSize.Level1)
1876 {
1877     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1878     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1879     sptr<SessionInfo> sessionInfo;
1880     uiAbilityLifecycleManager->CallUIAbilityBySCB(sessionInfo);
1881     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1882 }
1883 
1884 /**
1885  * @tc.name: UIAbilityLifecycleManager_CallUIAbilityBySCB_0200
1886  * @tc.desc: CallUIAbilityBySCB
1887  * @tc.type: FUNC
1888  */
1889 HWTEST_F(UIAbilityLifecycleManagerTest, CallUIAbilityBySCB_002, TestSize.Level1)
1890 {
1891     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1892     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1893     sptr<SessionInfo> sessionInfo(new SessionInfo());
1894     sessionInfo->sessionToken = nullptr;
1895     uiAbilityLifecycleManager->CallUIAbilityBySCB(sessionInfo);
1896     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1897 }
1898 
1899 /**
1900  * @tc.name: UIAbilityLifecycleManager_CallUIAbilityBySCB_0300
1901  * @tc.desc: CallUIAbilityBySCB
1902  * @tc.type: FUNC
1903  */
1904 HWTEST_F(UIAbilityLifecycleManagerTest, CallUIAbilityBySCB_003, TestSize.Level1)
1905 {
1906     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1907     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1908     sptr<SessionInfo> sessionInfo(new SessionInfo());
1909     AbilityRequest abilityRequest;
1910     abilityRequest.sessionInfo = sessionInfo;
1911     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1912     auto token = abilityRecord->GetToken();
1913     EXPECT_NE(token, nullptr);
1914     sessionInfo->sessionToken = token->AsObject();
1915     uiAbilityLifecycleManager->CallUIAbilityBySCB(sessionInfo);
1916     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1917 }
1918 
1919 /**
1920  * @tc.name: UIAbilityLifecycleManager_CallUIAbilityBySCB_0400
1921  * @tc.desc: CallUIAbilityBySCB
1922  * @tc.type: FUNC
1923  */
1924 HWTEST_F(UIAbilityLifecycleManagerTest, CallUIAbilityBySCB_004, TestSize.Level1)
1925 {
1926     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1927     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1928     Rosen::SessionInfo info;
1929     sptr<SessionInfo> sessionInfo(new SessionInfo());
1930     sessionInfo->sessionToken = new Rosen::Session(info);
1931 
1932     uiAbilityLifecycleManager->CallUIAbilityBySCB(sessionInfo);
1933     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1934 }
1935 
1936 /**
1937  * @tc.name: UIAbilityLifecycleManager_CallUIAbilityBySCB_0500
1938  * @tc.desc: CallUIAbilityBySCB
1939  * @tc.type: FUNC
1940  */
1941 HWTEST_F(UIAbilityLifecycleManagerTest, CallUIAbilityBySCB_005, TestSize.Level1)
1942 {
1943     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1944     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1945     Rosen::SessionInfo info;
1946     sptr<SessionInfo> sessionInfo(new SessionInfo());
1947     sessionInfo->sessionToken = new Rosen::Session(info);
1948     sessionInfo->uiAbilityId = 1;
1949 
1950     uiAbilityLifecycleManager->tmpAbilityMap_.emplace(1, nullptr);
1951     uiAbilityLifecycleManager->CallUIAbilityBySCB(sessionInfo);
1952     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1953 }
1954 
1955 /**
1956  * @tc.name: UIAbilityLifecycleManager_CallUIAbilityBySCB_0600
1957  * @tc.desc: CallUIAbilityBySCB
1958  * @tc.type: FUNC
1959  */
1960 HWTEST_F(UIAbilityLifecycleManagerTest, CallUIAbilityBySCB_006, TestSize.Level1)
1961 {
1962     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1963     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1964     Rosen::SessionInfo info;
1965     sptr<SessionInfo> sessionInfo(new SessionInfo());
1966     sessionInfo->sessionToken = new Rosen::Session(info);
1967     sessionInfo->uiAbilityId = 1;
1968 
1969     AbilityRequest abilityRequest;
1970     abilityRequest.sessionInfo = sessionInfo;
1971     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1972     uiAbilityLifecycleManager->tmpAbilityMap_.emplace(1, abilityRecord);
1973 
1974     uiAbilityLifecycleManager->CallUIAbilityBySCB(sessionInfo);
1975     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1976 }
1977 
1978 /**
1979  * @tc.name: UIAbilityLifecycleManager_CallUIAbilityBySCB_0700
1980  * @tc.desc: CallUIAbilityBySCB
1981  * @tc.type: FUNC
1982  */
1983 HWTEST_F(UIAbilityLifecycleManagerTest, CallUIAbilityBySCB_007, TestSize.Level1)
1984 {
1985     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
1986     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
1987     Rosen::SessionInfo info;
1988     sptr<SessionInfo> sessionInfo(new SessionInfo());
1989     sessionInfo->sessionToken = new Rosen::Session(info);
1990     sessionInfo->uiAbilityId = 1;
1991     sessionInfo->persistentId = 1;
1992 
1993     AbilityRequest abilityRequest;
1994     abilityRequest.sessionInfo = sessionInfo;
1995     abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SINGLETON;
1996     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1997 
1998     uiAbilityLifecycleManager->tmpAbilityMap_.emplace(1, abilityRecord);
1999     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
2000     uiAbilityLifecycleManager->CallUIAbilityBySCB(sessionInfo);
2001     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2002 }
2003 
2004 /**
2005  * @tc.name: UIAbilityLifecycleManager_CallRequestDone_0100
2006  * @tc.desc: CallRequestDone
2007  * @tc.type: FUNC
2008  */
2009 HWTEST_F(UIAbilityLifecycleManagerTest, CallRequestDone_001, TestSize.Level1)
2010 {
2011     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
2012     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2013     uiAbilityLifecycleManager->CallRequestDone(nullptr, nullptr);
2014     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2015 }
2016 
2017 /**
2018  * @tc.name: UIAbilityLifecycleManager_CallRequestDone_0200
2019  * @tc.desc: CallRequestDone
2020  * @tc.type: FUNC
2021  */
2022 HWTEST_F(UIAbilityLifecycleManagerTest, CallRequestDone_002, TestSize.Level1)
2023 {
2024     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
2025     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2026     AbilityRequest abilityRequest;
2027     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
2028     uiAbilityLifecycleManager->CallRequestDone(abilityRecord, nullptr);
2029     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2030 }
2031 
2032 /**
2033  * @tc.name: UIAbilityLifecycleManager_CallRequestDone_0300
2034  * @tc.desc: CallRequestDone
2035  * @tc.type: FUNC
2036  */
2037 HWTEST_F(UIAbilityLifecycleManagerTest, CallRequestDone_003, TestSize.Level1)
2038 {
2039     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
2040     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2041     AbilityRequest abilityRequest;
2042     auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
2043     auto token = abilityRecord->GetToken();
2044     EXPECT_NE(token, nullptr);
2045     uiAbilityLifecycleManager->CallRequestDone(abilityRecord, token->AsObject());
2046     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2047 }
2048 
2049 /**
2050  * @tc.name: UIAbilityLifecycleManager_ReleaseCallLocked_0100
2051  * @tc.desc: ReleaseCallLocked
2052  * @tc.type: FUNC
2053  */
2054 HWTEST_F(UIAbilityLifecycleManagerTest, ReleaseCallLocked_001, TestSize.Level1)
2055 {
2056     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
2057     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2058     sptr<IAbilityConnection> connect = new UIAbilityLifcecycleManagerTestStub();
2059     AppExecFwk::ElementName element;
2060     auto ret = uiAbilityLifecycleManager->ReleaseCallLocked(connect, element);
2061     EXPECT_EQ(ret, RELEASE_CALL_ABILITY_INNER_ERR);
2062 }
2063 
2064 /**
2065  * @tc.name: UIAbilityLifecycleManager_ReleaseCallLocked_0200
2066  * @tc.desc: ReleaseCallLocked
2067  * @tc.type: FUNC
2068  */
2069 HWTEST_F(UIAbilityLifecycleManagerTest, ReleaseCallLocked_002, TestSize.Level1)
2070 {
2071     auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
2072     EXPECT_NE(uiAbilityLifecycleManager, nullptr);
2073     auto abilityRecord = InitAbilityRecord();
2074     uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord);
2075     sptr<IAbilityConnection> connect = new UIAbilityLifcecycleManagerTestStub();
2076     AppExecFwk::ElementName element("", "com.example.unittest", "MainAbility");
2077     auto ret = uiAbilityLifecycleManager->ReleaseCallLocked(connect, element);
2078     EXPECT_EQ(ret, RELEASE_CALL_ABILITY_INNER_ERR);
2079 }
2080 }  // namespace AAFwk
2081 }  // namespace OHOS
2082