• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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 #define private public
19 #include "app_mgr_service_inner.h"
20 #include "app_running_record.h"
21 #include "remote_client_manager.h"
22 #undef private
23 #include "ability_manager_errors.h"
24 #include "accesstoken_kit.h"
25 #include "app_scheduler.h"
26 #include "appspawn_util.h"
27 #include "app_spawn_client.h"
28 #include "event_handler.h"
29 #include "hilog_tag_wrapper.h"
30 #include "ipc_skeleton.h"
31 #include "mock_ability_token.h"
32 #include "mock_app_scheduler.h"
33 #include "mock_bundle_manager.h"
34 #include "mock_configuration_observer.h"
35 #include "mock_iapp_state_callback.h"
36 #include "mock_kia_interceptor.h"
37 #include "mock_native_token.h"
38 #include "mock_render_scheduler.h"
39 #include "mock_sa_call.h"
40 #include "mock_task_handler_wrap.h"
41 #include "param.h"
42 #include "parameters.h"
43 #include "render_state_observer_stub.h"
44 #include "window_manager.h"
45 
46 using namespace testing;
47 using namespace testing::ext;
48 
49 namespace OHOS {
50 namespace AppExecFwk {
51 class WindowFocusChangedListener : public OHOS::Rosen::IFocusChangedListener {
52 public:
53     WindowFocusChangedListener(const std::shared_ptr<AppMgrServiceInner>& owner,
54         const std::shared_ptr<AAFwk::TaskHandlerWrap>& handler);
55     virtual ~WindowFocusChangedListener();
56 
57     void OnFocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo) override;
58     void OnUnfocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo) override;
59 
60 private:
61     std::weak_ptr<AppMgrServiceInner> owner_;
62     std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler_;
63 };
64 namespace {
65 constexpr int32_t RECORD_ID = 1;
66 constexpr int32_t APP_DEBUG_INFO_PID = 0;
67 constexpr int32_t APP_DEBUG_INFO_UID = 0;
68 constexpr const char* PERMISSION_PROTECT_SCREEN_LOCK_DATA_TEST = "ohos.permission.PROTECT_SCREEN_LOCK_DATA";
69 constexpr int32_t FUN_TEST_PID = 0;
70 }
71 static int recordId_ = 0;
72 class AppMgrServiceInnerTest : public testing::Test {
73 public:
74     static void SetUpTestCase();
75     static void TearDownTestCase();
76     void SetUp() override;
77     void TearDown() override;
78 
79     void InitAppInfo(const std::string& deviceName, const std::string& abilityName,
80         const std::string& appName, const std::string& bundleName, const std::string& moduleName);
81 
82 public:
83     std::shared_ptr<AbilityInfo> abilityInfo_;
84     std::shared_ptr<ApplicationInfo> applicationInfo_;
85 };
86 
87 class RenderStateObserverMock : public RenderStateObserverStub {
88 public:
89     RenderStateObserverMock() = default;
90     virtual ~RenderStateObserverMock() = default;
OnRenderStateChanged(const RenderStateData & renderStateData)91     void OnRenderStateChanged(const RenderStateData &renderStateData) override
92     {}
93 };
94 
InitAppInfo(const std::string & deviceName,const std::string & abilityName,const std::string & appName,const std::string & bundleName,const std::string & moduleName)95 void AppMgrServiceInnerTest::InitAppInfo(const std::string& deviceName,
96     const std::string& abilityName, const std::string& appName, const std::string& bundleName,
97     const std::string& moduleName)
98 {
99     ApplicationInfo applicationInfo;
100     applicationInfo.name = appName;
101     applicationInfo.bundleName = bundleName;
102     applicationInfo_ = std::make_shared<ApplicationInfo>(applicationInfo);
103 
104     AbilityInfo abilityInfo;
105     abilityInfo.visible = true;
106     abilityInfo.applicationName = appName;
107     abilityInfo.type = AbilityType::EXTENSION;
108     abilityInfo.name = abilityName;
109     abilityInfo.bundleName = bundleName;
110     abilityInfo.moduleName = moduleName;
111     abilityInfo.deviceId = deviceName;
112     abilityInfo_ = std::make_shared<AbilityInfo>(abilityInfo);
113 }
114 
115 class MockIUserCallback : public AAFwk::IUserCallback {
116 public:
117     MockIUserCallback() = default;
118     virtual ~MockIUserCallback() = default;
119 
OnStopUserDone(int userId,int errcode)120     void OnStopUserDone(int userId, int errcode) override
121     {}
OnStartUserDone(int userId,int errcode)122     void OnStartUserDone(int userId, int errcode) override
123     {}
124 
OnLogoutUserDone(int userId,int errcode)125     void OnLogoutUserDone(int userId, int errcode)  override
126     {}
127 
AsObject()128     sptr<IRemoteObject> AsObject() override
129     {
130         return {};
131     }
132 };
133 
SetUpTestCase(void)134 void AppMgrServiceInnerTest::SetUpTestCase(void)
135 {
136     MockNativeToken::SetNativeToken();
137 }
138 
TearDownTestCase(void)139 void AppMgrServiceInnerTest::TearDownTestCase(void)
140 {}
141 
SetUp()142 void AppMgrServiceInnerTest::SetUp()
143 {
144     // init test app info
145     std::string deviceName = "device";
146     std::string abilityName = "ServiceAbility";
147     std::string appName = "hiservcie";
148     std::string bundleName = "com.ix.hiservcie";
149     std::string moduleName = "entry";
150     InitAppInfo(deviceName, abilityName, appName, bundleName, moduleName);
151 }
152 
TearDown()153 void AppMgrServiceInnerTest::TearDown()
154 {}
155 
156 /**
157  * @tc.name: PointerDeviceCallback_0100
158  * @tc.desc: set parameter, expect config update
159  * @tc.type: FUNC
160  */
161 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceCallback_0100, TestSize.Level1)
162 {
163     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0100 start");
164 
165     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
166     EXPECT_NE(appMgrServiceInner, nullptr);
167     std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
168     auto context = new (std::nothrow) std::weak_ptr<AppMgrServiceInner>(appMgrServiceInner);
169     std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
170     std::string value;
171 
172     // invalid parameter value
173     appMgrServiceInner->PointerDeviceEventCallback(key.c_str(), "false", context);
174     config = appMgrServiceInner->GetConfiguration();
175     EXPECT_NE(config, nullptr);
176 
177     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0100 end");
178 }
179 
180 /**
181  * @tc.name: PointerDeviceCallback_0200
182  * @tc.desc: set parameter, expect config update
183  * @tc.type: FUNC
184  */
185 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceCallback_0200, TestSize.Level1)
186 {
187     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0200 start");
188 
189     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
190     EXPECT_NE(appMgrServiceInner, nullptr);
191     std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
192     auto context = new (std::nothrow) std::weak_ptr<AppMgrServiceInner>(appMgrServiceInner);
193     std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
194     std::string value;
195 
196     // invalid parameter value
197     appMgrServiceInner->PointerDeviceEventCallback(key.c_str(), "true", context);
198     config = appMgrServiceInner->GetConfiguration();
199     EXPECT_NE(config, nullptr);
200 
201     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0200 end");
202 }
203 
204 /**
205  * @tc.name: PointerDeviceCallback_0300
206  * @tc.desc: set parameter, expect config update
207  * @tc.type: FUNC
208  */
209 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceCallback_0300, TestSize.Level1)
210 {
211     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0300 start");
212 
213     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
214     EXPECT_NE(appMgrServiceInner, nullptr);
215     std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
216     auto context = new (std::nothrow) std::weak_ptr<AppMgrServiceInner>(appMgrServiceInner);
217     std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
218     std::string value;
219 
220     // invalid parameter value
221     appMgrServiceInner->PointerDeviceEventCallback("invalid_key", "false", context);
222     config = appMgrServiceInner->GetConfiguration();
223     EXPECT_NE(config, nullptr);
224 
225     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0300 end");
226 }
227 
228 /**
229  * @tc.name: PointerDeviceCallback_0400
230  * @tc.desc: set parameter, expect config update
231  * @tc.type: FUNC
232  */
233 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceCallback_0400, TestSize.Level1)
234 {
235     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0400 start");
236 
237     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
238     EXPECT_NE(appMgrServiceInner, nullptr);
239     std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
240     auto context = new (std::nothrow) std::weak_ptr<AppMgrServiceInner>(appMgrServiceInner);
241     std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
242     std::string value;
243 
244     // invalid parameter value
245     appMgrServiceInner->PointerDeviceEventCallback(key.c_str(), "invalid", context);
246     config = appMgrServiceInner->GetConfiguration();
247     EXPECT_NE(config, nullptr);
248 
249     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceCallback_0400 end");
250 }
251 
252 /**
253  * @tc.name: PointerDeviceWatchParameter_0100
254  * @tc.desc: set parameter, expect config update
255  * @tc.type: FUNC
256  */
257 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceWatchParameter_0100, TestSize.Level1)
258 {
259     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceWatchParameter_0100 start");
260 
261     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
262     EXPECT_NE(appMgrServiceInner, nullptr);
263     std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
264     std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
265     std::string value;
266 
267     appMgrServiceInner->AddWatchParameter();
268     sleep(1);
269 
270     // invalid parameter value
271     system::SetParameter(key.c_str(), "invalid");
272     sleep(1);
273     config = appMgrServiceInner->GetConfiguration();
274     EXPECT_NE(config, nullptr);
275 
276     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceWatchParameter_0100 end");
277 }
278 
279 /**
280  * @tc.name: PointerDeviceWatchParameter_0200
281  * @tc.desc: set parameter, expect config update
282  * @tc.type: FUNC
283  */
284 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceWatchParameter_0200, TestSize.Level1)
285 {
286     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceWatchParameter_0200 start");
287 
288     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
289     EXPECT_NE(appMgrServiceInner, nullptr);
290     std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
291     std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
292     std::string value;
293 
294     appMgrServiceInner->AddWatchParameter();
295     sleep(1);
296 
297     // set "input.pointer.device" to false
298     system::SetParameter(key.c_str(), "false");
299     sleep(1);
300     config = appMgrServiceInner->GetConfiguration();
301     EXPECT_NE(config, nullptr);
302 
303     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceWatchParameter_0200 end");
304 }
305 
306 /**
307  * @tc.name: PointerDeviceWatchParameter_0300
308  * @tc.desc: set parameter, expect config update
309  * @tc.type: FUNC
310  */
311 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceWatchParameter_0300, TestSize.Level1)
312 {
313     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceWatchParameter_0300 start");
314 
315     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
316     EXPECT_NE(appMgrServiceInner, nullptr);
317     std::string key = AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE;
318     std::shared_ptr<AppExecFwk::Configuration> config = nullptr;
319     std::string value;
320 
321     appMgrServiceInner->AddWatchParameter();
322     sleep(1);
323 
324     // set "input.pointer.device" to true
325     system::SetParameter(key.c_str(), "true");
326     sleep(1);
327     config = appMgrServiceInner->GetConfiguration();
328     EXPECT_NE(config, nullptr);
329 
330     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceWatchParameter_0300 end");
331 }
332 
333 /**
334  * @tc.name: PointerDeviceUpdateConfig_0100
335  * @tc.desc: set parameter, expect config update
336  * @tc.type: FUNC
337  * @tc.require: I581UL
338  */
339 HWTEST_F(AppMgrServiceInnerTest, PointerDeviceUpdateConfig_0100, TestSize.Level1)
340 {
341     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceUpdateConfig_0100 start");
342 
343     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
344     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
345     EXPECT_NE(appMgrServiceInner, nullptr);
346     std::shared_ptr<AppExecFwk::Configuration> config;
347     std::string value;
348     int32_t result;
349 
350     appMgrServiceInner->InitGlobalConfiguration();
351     config = appMgrServiceInner->GetConfiguration();
352     EXPECT_NE(config, nullptr);
353     value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
354     EXPECT_TRUE((value == "true") || (value == "false"));
355 
356     // config didn't change
357     result = appMgrServiceInner->UpdateConfiguration(*config);
358     EXPECT_EQ(result, ERR_INVALID_VALUE);
359 
360     Configuration changeConfig;
361     if (value == "true") {
362         changeConfig.AddItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE, "false");
363         result = appMgrServiceInner->UpdateConfiguration(changeConfig);
364         EXPECT_EQ(result, ERR_OK);
365         config = appMgrServiceInner->GetConfiguration();
366         EXPECT_NE(config, nullptr);
367         value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
368         EXPECT_EQ(value, "false");
369     } else {
370         changeConfig.AddItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE, "true");
371         result = appMgrServiceInner->UpdateConfiguration(changeConfig);
372         EXPECT_EQ(result, ERR_PERMISSION_DENIED);
373         config = appMgrServiceInner->GetConfiguration();
374         EXPECT_NE(config, nullptr);
375         value = config->GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
376         EXPECT_EQ(value, "true");
377     }
378 
379     TAG_LOGI(AAFwkTag::TEST, "PointerDeviceUpdateConfig_0100 end");
380 }
381 
382 /**
383  * @tc.name: PreStartNWebSpawnProcess_001
384  * @tc.desc: prestart nwebspawn process.
385  * @tc.type: FUNC
386  * @tc.require: issueI5W4S7
387  */
388 HWTEST_F(AppMgrServiceInnerTest, PreStartNWebSpawnProcess_001, TestSize.Level2)
389 {
390     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
391     EXPECT_NE(appMgrServiceInner, nullptr);
392 
393     int callingPid = IPCSkeleton::GetCallingPid();
394     int ret = appMgrServiceInner->PreStartNWebSpawnProcess(callingPid);
395     EXPECT_NE(ret, ERR_OK);
396 }
397 
398 /**
399  * @tc.name: PreStartNWebSpawnProcess_002
400  * @tc.desc: prestart nwebspawn process.
401  * @tc.type: FUNC
402  * @tc.require: issueI5W4S7
403  */
404 HWTEST_F(AppMgrServiceInnerTest, PreStartNWebSpawnProcess_002, TestSize.Level2)
405 {
406     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
407     EXPECT_NE(appMgrServiceInner, nullptr);
408 
409     int callingPid = 0;
410     int ret = appMgrServiceInner->PreStartNWebSpawnProcess(callingPid);
411     EXPECT_EQ(ret, ERR_INVALID_VALUE);
412 }
413 
414 /**
415  * @tc.name: LoadAbility_001
416  * @tc.desc: load ability.
417  * @tc.type: FUNC
418  * @tc.require: issueI5W4S7
419  */
420 HWTEST_F(AppMgrServiceInnerTest, LoadAbility_001, TestSize.Level0)
421 {
422     TAG_LOGI(AAFwkTag::TEST, "LoadAbility_001 start");
423     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
424     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
425     EXPECT_NE(appMgrServiceInner, nullptr);
426 
427     appMgrServiceInner->appRunningManager_ = nullptr;
428     AbilityRuntime::LoadParam loadParam;
429     loadParam.token = token;
430     auto loadParamPtr = std::make_shared<AbilityRuntime::LoadParam>(loadParam);
431     appMgrServiceInner->LoadAbility(abilityInfo_, applicationInfo_, nullptr, loadParamPtr);
432 
433     auto appMgrServiceInner1 = std::make_shared<AppMgrServiceInner>();
434     EXPECT_NE(appMgrServiceInner1, nullptr);
435 
436     appMgrServiceInner1->remoteClientManager_->SetBundleManagerHelper(nullptr);
437     appMgrServiceInner1->LoadAbility(abilityInfo_, applicationInfo_, nullptr, loadParamPtr);
438 
439     auto appMgrServiceInner2 = std::make_shared<AppMgrServiceInner>();
440     EXPECT_NE(appMgrServiceInner2, nullptr);
441 
442     appMgrServiceInner2->LoadAbility(abilityInfo_, applicationInfo_, nullptr, loadParamPtr);
443     TAG_LOGI(AAFwkTag::TEST, "LoadAbility_001 end");
444 }
445 
446 /**
447  * @tc.name: CheckLoadAbilityConditions_001
448  * @tc.desc: check load ability conditions.
449  * @tc.type: FUNC
450  * @tc.require: issueI5W4S7
451  */
452 HWTEST_F(AppMgrServiceInnerTest, CheckLoadAbilityConditions_001, TestSize.Level2)
453 {
454     TAG_LOGI(AAFwkTag::TEST, "CheckLoadAbilityConditions_001 start");
455     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
456     EXPECT_NE(appMgrServiceInner, nullptr);
457 
458     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
459 
460     appMgrServiceInner->CheckLoadAbilityConditions(nullptr, nullptr, nullptr);
461 
462     appMgrServiceInner->CheckLoadAbilityConditions(nullptr, abilityInfo_, nullptr);
463 
464     appMgrServiceInner->CheckLoadAbilityConditions(nullptr, nullptr, applicationInfo_);
465 
466     appMgrServiceInner->CheckLoadAbilityConditions(token, nullptr, nullptr);
467 
468     appMgrServiceInner->CheckLoadAbilityConditions(token, abilityInfo_, nullptr);
469 
470     appMgrServiceInner->CheckLoadAbilityConditions(nullptr, abilityInfo_, applicationInfo_);
471 
472     appMgrServiceInner->CheckLoadAbilityConditions(token, nullptr, applicationInfo_);
473 
474     appMgrServiceInner->CheckLoadAbilityConditions(token, abilityInfo_, applicationInfo_);
475 
476     EXPECT_NE(appMgrServiceInner, nullptr);
477     TAG_LOGI(AAFwkTag::TEST, "CheckLoadAbilityConditions_001 end");
478 }
479 
480 /**
481  * @tc.name: MakeProcessName_001
482  * @tc.desc: make process name.
483  * @tc.type: FUNC
484  * @tc.require: issueI5W4S7
485  */
486 HWTEST_F(AppMgrServiceInnerTest, MakeProcessName_001, TestSize.Level0)
487 {
488     TAG_LOGI(AAFwkTag::TEST, "MakeProcessName_001 start");
489     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
490     EXPECT_NE(appMgrServiceInner, nullptr);
491 
492     HapModuleInfo hapModuleInfo;
493     hapModuleInfo.moduleName = "module789";
494     std::string processName = "test_processName";
495     appMgrServiceInner->MakeProcessName(nullptr, nullptr, hapModuleInfo, 1, "", processName, false);
496     appMgrServiceInner->MakeProcessName(nullptr, applicationInfo_, hapModuleInfo, 1, "", processName, false);
497     appMgrServiceInner->MakeProcessName(abilityInfo_, nullptr, hapModuleInfo, 1, "", processName, false);
498     appMgrServiceInner->MakeProcessName(abilityInfo_, applicationInfo_, hapModuleInfo, 1, "", processName, false);
499 
500     EXPECT_NE(appMgrServiceInner, nullptr);
501     TAG_LOGI(AAFwkTag::TEST, "MakeProcessName_001 end");
502 }
503 
504 /**
505  * @tc.name: MakeProcessName_002
506  * @tc.desc: make process name.
507  * @tc.type: FUNC
508  * @tc.require: issueI5W4S7
509  */
510 HWTEST_F(AppMgrServiceInnerTest, MakeProcessName_002, TestSize.Level2)
511 {
512     TAG_LOGI(AAFwkTag::TEST, "MakeProcessName_002 start");
513     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
514     EXPECT_NE(appMgrServiceInner, nullptr);
515 
516     HapModuleInfo hapModuleInfo;
517     hapModuleInfo.moduleName = "module789";
518     std::string processName = "test_processName";
519     appMgrServiceInner->MakeProcessName(nullptr, hapModuleInfo, processName);
520     appMgrServiceInner->MakeProcessName(applicationInfo_, hapModuleInfo, processName);
521     hapModuleInfo.isStageBasedModel = false;
522     hapModuleInfo.process = "";
523     appMgrServiceInner->MakeProcessName(applicationInfo_, hapModuleInfo, processName);
524 
525     hapModuleInfo.isStageBasedModel = true;
526     hapModuleInfo.process = "";
527     appMgrServiceInner->MakeProcessName(applicationInfo_, hapModuleInfo, processName);
528 
529     hapModuleInfo.isStageBasedModel = false;
530     hapModuleInfo.process = "test_process";
531     appMgrServiceInner->MakeProcessName(applicationInfo_, hapModuleInfo, processName);
532 
533     hapModuleInfo.isStageBasedModel = true;
534     hapModuleInfo.process = "test_process";
535     appMgrServiceInner->MakeProcessName(applicationInfo_, hapModuleInfo, processName);
536 
537     hapModuleInfo.isStageBasedModel = false;
538     applicationInfo_->process = "";
539     appMgrServiceInner->MakeProcessName(applicationInfo_, hapModuleInfo, processName);
540 
541     hapModuleInfo.isStageBasedModel = false;
542     applicationInfo_->process = "test_process";
543     appMgrServiceInner->MakeProcessName(applicationInfo_, hapModuleInfo, processName);
544 
545     EXPECT_NE(appMgrServiceInner, nullptr);
546     TAG_LOGI(AAFwkTag::TEST, "MakeProcessName_002 end");
547 }
548 
549 /**
550  * @tc.name: QueryExtensionSandBox_001
551  * @tc.desc: query extension sandBox without permission.
552  * @tc.type: FUNC
553  */
554 HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_001, TestSize.Level1)
555 {
556     TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_001 start");
557     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
558     ASSERT_NE(appMgrServiceInner, nullptr);
559     const string moduleName = "entry";
560     const string abilityName = "abilityName";
561     BundleInfo bundleInfo;
562     AppSpawnStartMsg startMsg;
563     DataGroupInfoList dataGroupInfoList;
564     appMgrServiceInner->QueryExtensionSandBox(moduleName, abilityName, bundleInfo, startMsg, dataGroupInfoList,
565         nullptr);
566     EXPECT_FALSE(startMsg.isScreenLockDataProtect);
567     TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_001 end");
568 }
569 
570 /**
571  * @tc.name: QueryExtensionSandBox_002
572  * @tc.desc: query extension sandBox with permission.
573  * @tc.type: FUNC
574  */
575 HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_002, TestSize.Level1)
576 {
577     TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_002 start");
578     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
579     ASSERT_NE(appMgrServiceInner, nullptr);
580     const string moduleName = "entry";
581     const string abilityName = "abilityName";
582     BundleInfo bundleInfo;
583     bundleInfo.reqPermissions.push_back(PERMISSION_PROTECT_SCREEN_LOCK_DATA_TEST);
584     AppSpawnStartMsg startMsg;
585     DataGroupInfoList dataGroupInfoList;
586     appMgrServiceInner->QueryExtensionSandBox(moduleName, abilityName, bundleInfo, startMsg, dataGroupInfoList,
587         nullptr);
588     EXPECT_TRUE(startMsg.isScreenLockDataProtect);
589     TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_002 end");
590 }
591 
592 /**
593  * @tc.name: GetBundleAndHapInfo_001
594  * @tc.desc: get bundle and hapInfo.
595  * @tc.type: FUNC
596  * @tc.require: issueI5W4S7
597  */
598 HWTEST_F(AppMgrServiceInnerTest, GetBundleAndHapInfo_001, TestSize.Level2)
599 {
600     TAG_LOGI(AAFwkTag::TEST, "GetBundleAndHapInfo_001 start");
601     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
602     EXPECT_NE(appMgrServiceInner, nullptr);
603 
604     BundleInfo bundleInfo;
605     HapModuleInfo hapModuleInfo;
606     appMgrServiceInner->GetBundleAndHapInfo(*abilityInfo_, applicationInfo_, bundleInfo, hapModuleInfo, 1);
607 
608     appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(nullptr);
609     appMgrServiceInner->GetBundleAndHapInfo(*abilityInfo_, applicationInfo_, bundleInfo, hapModuleInfo, 1);
610     TAG_LOGI(AAFwkTag::TEST, "GetBundleAndHapInfo_001 end");
611 }
612 
613 /**
614  * @tc.name: AttachApplication_001
615  * @tc.desc: attach application.
616  * @tc.type: FUNC
617  * @tc.require: issueI5W4S7
618  */
619 HWTEST_F(AppMgrServiceInnerTest, AttachApplication_001, TestSize.Level1)
620 {
621     TAG_LOGI(AAFwkTag::TEST, "AttachApplication_001 start");
622     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
623     EXPECT_NE(appMgrServiceInner, nullptr);
624 
625     appMgrServiceInner->AttachApplication(0, nullptr);
626 
627     appMgrServiceInner->AttachApplication(1, nullptr);
628 
629     sptr<MockAppScheduler> mockAppScheduler = new (std::nothrow) MockAppScheduler();
630     sptr<IAppScheduler> client = iface_cast<IAppScheduler>(mockAppScheduler.GetRefPtr());
631     appMgrServiceInner->AttachApplication(1, client);
632     TAG_LOGI(AAFwkTag::TEST, "AttachApplication_001 end");
633 }
634 
635 /**
636  * @tc.name: LaunchApplication_001
637  * @tc.desc: launch application.
638  * @tc.type: FUNC
639  * @tc.require: issueI5W4S7
640  */
641 HWTEST_F(AppMgrServiceInnerTest, LaunchApplication_001, TestSize.Level1)
642 {
643     TAG_LOGI(AAFwkTag::TEST, "LaunchApplication_001 start");
644     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
645     EXPECT_NE(appMgrServiceInner, nullptr);
646 
647     appMgrServiceInner->LaunchApplication(nullptr);
648 
649     BundleInfo info;
650     std::string processName = "test_processName";
651     std::shared_ptr<AppRunningRecord> appRecord =
652         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
653     recordId_ += 1;
654     appMgrServiceInner->LaunchApplication(appRecord);
655 
656     appRecord->SetState(ApplicationState::APP_STATE_FOREGROUND);
657     appMgrServiceInner->LaunchApplication(appRecord);
658 
659     appRecord->SetState(ApplicationState::APP_STATE_CREATE);
660     appMgrServiceInner->LaunchApplication(appRecord);
661 
662     appRecord->SetEmptyKeepAliveAppState(true);
663     appRecord->SetKeepAliveEnableState(false);
664     appRecord->SetKeepAliveDkv(false);
665     appMgrServiceInner->LaunchApplication(appRecord);
666 
667     appRecord->SetKeepAliveEnableState(true);
668     appRecord->SetKeepAliveDkv(true);
669     appRecord->SetEmptyKeepAliveAppState(false);
670     appMgrServiceInner->LaunchApplication(appRecord);
671 
672     appRecord->SetKeepAliveEnableState(true);
673     appRecord->SetKeepAliveDkv(true);
674     appRecord->SetEmptyKeepAliveAppState(true);
675     appMgrServiceInner->LaunchApplication(appRecord);
676 
677     appRecord->SetKeepAliveEnableState(false);
678     appRecord->SetKeepAliveDkv(false);
679     appRecord->SetEmptyKeepAliveAppState(false);
680     appMgrServiceInner->LaunchApplication(appRecord);
681 
682     Want want;
683     appRecord->SetSpecifiedAbilityFlagAndWant(-1, want, "");
684     appMgrServiceInner->LaunchApplication(appRecord);
685 
686     appRecord->SetSpecifiedAbilityFlagAndWant(1, want, "");
687     appMgrServiceInner->LaunchApplication(appRecord);
688 
689     appMgrServiceInner->LaunchApplication(appRecord);
690     TAG_LOGI(AAFwkTag::TEST, "LaunchApplication_001 end");
691 }
692 
693 /**
694  * @tc.name: AddAbilityStageDone_001
695  * @tc.desc: add ability stage done.
696  * @tc.type: FUNC
697  * @tc.require: issueI5W4S7
698  */
699 HWTEST_F(AppMgrServiceInnerTest, AddAbilityStageDone_001, TestSize.Level2)
700 {
701     TAG_LOGI(AAFwkTag::TEST, "AddAbilityStageDone_001 start");
702     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
703     EXPECT_NE(appMgrServiceInner, nullptr);
704 
705     appMgrServiceInner->AddAbilityStageDone(99);
706 
707     BundleInfo info;
708     std::string processName = "test_processName";
709     appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
710     recordId_ += 1;
711 
712     appMgrServiceInner->AddAbilityStageDone(recordId_);
713     TAG_LOGI(AAFwkTag::TEST, "AddAbilityStageDone_001 end");
714 }
715 
716 /**
717  * @tc.name: ApplicationForegrounded_001
718  * @tc.desc: application foregrounded.
719  * @tc.type: FUNC
720  * @tc.require: issueI5W4S7
721  */
722 HWTEST_F(AppMgrServiceInnerTest, ApplicationForegrounded_001, TestSize.Level1)
723 {
724     TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_001 start");
725     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
726     EXPECT_NE(appMgrServiceInner, nullptr);
727 
728     appMgrServiceInner->ApplicationForegrounded(99);
729 
730     BundleInfo info;
731     std::string processName = "test_processName";
732     appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
733     recordId_ += 1;
734 
735     appMgrServiceInner->ApplicationForegrounded(recordId_);
736     TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_001 end");
737 }
738 
739 /**
740  * @tc.name: ApplicationForegrounded_002
741  * @tc.desc: application foregrounded.
742  * @tc.type: FUNC
743  * @tc.require: issueI5W4S7
744  */
745 HWTEST_F(AppMgrServiceInnerTest, ApplicationForegrounded_002, TestSize.Level1)
746 {
747     TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_002 start");
748     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
749     EXPECT_NE(appMgrServiceInner, nullptr);
750 
751     BundleInfo info;
752     std::string processName = "test_processName";
753     auto record =
754         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
755     recordId_ += 1;
756 
757     appMgrServiceInner->ApplicationForegrounded(recordId_);
758     TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_002 end");
759 }
760 
761 /**
762  * @tc.name: ApplicationForegrounded_003
763  * @tc.desc: application foregrounded.
764  * @tc.type: FUNC
765  * @tc.require: issueI5W4S7
766  */
767 HWTEST_F(AppMgrServiceInnerTest, ApplicationForegrounded_003, TestSize.Level1)
768 {
769     TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_003 start");
770     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
771     EXPECT_NE(appMgrServiceInner, nullptr);
772 
773     BundleInfo info;
774     std::string processName = "test_processName";
775     auto record =
776         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
777     recordId_ += 1;
778     auto record2 =
779         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
780     recordId_ += 1;
781     std::shared_ptr<PriorityObject> priorityObject = std::make_shared<PriorityObject>();
782     std::string callerBundleName = "callerBundleName";
783     priorityObject->SetPid(1);
784     record2->priorityObject_ = priorityObject;
785     record2->mainBundleName_ = callerBundleName;
786     record->SetCallerPid(1);
787 
788     appMgrServiceInner->ApplicationForegrounded(--recordId_);
789     TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_003 end");
790 }
791 
792 /**
793  * @tc.name: ApplicationBackgrounded_001
794  * @tc.desc: application backgrounded.
795  * @tc.type: FUNC
796  * @tc.require: issueI5W4S7
797  */
798 HWTEST_F(AppMgrServiceInnerTest, ApplicationBackgrounded_001, TestSize.Level1)
799 {
800     TAG_LOGI(AAFwkTag::TEST, "ApplicationBackgrounded_001 start");
801     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
802     EXPECT_NE(appMgrServiceInner, nullptr);
803     appMgrServiceInner->Init();
804 
805     appMgrServiceInner->ApplicationBackgrounded(99);
806 
807     BundleInfo info;
808     std::string processName = "test_processName";
809     auto appRecord =
810         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
811     EXPECT_NE(appRecord, nullptr);
812     recordId_ += 1;
813 
814     appMgrServiceInner->ApplicationBackgrounded(recordId_);
815 
816     appRecord->SetState(ApplicationState::APP_STATE_FOREGROUND);
817     appMgrServiceInner->ApplicationBackgrounded(recordId_);
818 
819     TAG_LOGI(AAFwkTag::TEST, "ApplicationBackgrounded_001 end");
820 }
821 
822 /**
823  * @tc.name: ApplicationTerminated_001
824  * @tc.desc: application terminated.
825  * @tc.type: FUNC
826  * @tc.require: issueI5W4S7
827  */
828 HWTEST_F(AppMgrServiceInnerTest, ApplicationTerminated_001, TestSize.Level1)
829 {
830     TAG_LOGI(AAFwkTag::TEST, "ApplicationTerminated_001 start");
831     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
832     EXPECT_NE(appMgrServiceInner, nullptr);
833 
834     appMgrServiceInner->ApplicationTerminated(99);
835 
836     BundleInfo info;
837     std::string processName = "test_processName";
838     auto appRecord =
839         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
840     EXPECT_NE(appRecord, nullptr);
841     recordId_ += 1;
842 
843     appMgrServiceInner->ApplicationTerminated(recordId_);
844 
845     appRecord->SetKeepAliveEnableState(false);
846     appRecord->SetKeepAliveDkv(false);
847     appRecord->SetEmptyKeepAliveAppState(true);
848     appMgrServiceInner->ApplicationTerminated(recordId_);
849 
850     appRecord->SetKeepAliveEnableState(true);
851     appRecord->SetKeepAliveDkv(true);
852     appRecord->SetEmptyKeepAliveAppState(false);
853     appMgrServiceInner->ApplicationTerminated(recordId_);
854 
855     appRecord->SetKeepAliveEnableState(true);
856     appRecord->SetKeepAliveDkv(true);
857     appRecord->SetEmptyKeepAliveAppState(true);
858     appMgrServiceInner->ApplicationTerminated(recordId_);
859 
860     appRecord->SetKeepAliveEnableState(false);
861     appRecord->SetKeepAliveDkv(false);
862     appRecord->SetEmptyKeepAliveAppState(false);
863     appMgrServiceInner->ApplicationTerminated(recordId_);
864 
865     appRecord->SetState(ApplicationState::APP_STATE_FOREGROUND);
866     appMgrServiceInner->ApplicationTerminated(recordId_);
867 
868     appRecord->SetState(ApplicationState::APP_STATE_BACKGROUND);
869     appMgrServiceInner->ApplicationTerminated(recordId_);
870 
871     appMgrServiceInner->appRunningManager_ = nullptr;
872     appMgrServiceInner->ApplicationTerminated(recordId_);
873 
874     TAG_LOGI(AAFwkTag::TEST, "ApplicationTerminated_001 end");
875 }
876 
877 /**
878  * @tc.name: KillApplication_001
879  * @tc.desc: kill application.
880  * @tc.type: FUNC
881  * @tc.require: issueI5W4S7
882  */
883 HWTEST_F(AppMgrServiceInnerTest, KillApplication_001, TestSize.Level0)
884 {
885     TAG_LOGI(AAFwkTag::TEST, "KillApplication_001 start");
886     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
887     EXPECT_NE(appMgrServiceInner, nullptr);
888 
889     std::string bundleName = "test_bundleName";
890     appMgrServiceInner->KillApplication(bundleName);
891 
892     appMgrServiceInner->appRunningManager_ = nullptr;
893     appMgrServiceInner->KillApplication(bundleName);
894 
895     TAG_LOGI(AAFwkTag::TEST, "KillApplication_001 end");
896 }
897 
898 /**
899  * @tc.name: KillApplicationByUid_001
900  * @tc.desc: kill application by uid.
901  * @tc.type: FUNC
902  * @tc.require: issueI5W4S7
903  */
904 HWTEST_F(AppMgrServiceInnerTest, KillApplicationByUid_001, TestSize.Level1)
905 {
906     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByUid_001 start");
907     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
908     EXPECT_NE(appMgrServiceInner, nullptr);
909 
910     std::string bundleName = "test_bundleName";
911     appMgrServiceInner->KillApplicationByUid(bundleName, 0);
912 
913     appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(nullptr);
914     appMgrServiceInner->KillApplicationByUid(bundleName, 0);
915 
916     appMgrServiceInner->remoteClientManager_ = nullptr;
917     appMgrServiceInner->KillApplicationByUid(bundleName, 0);
918 
919     appMgrServiceInner->appRunningManager_ = nullptr;
920     appMgrServiceInner->KillApplicationByUid(bundleName, 0);
921 
922     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByUid_001 end");
923 }
924 
925 /**
926  * @tc.name: KillApplicationSelf_001
927  * @tc.desc: kill application self.
928  * @tc.type: FUNC
929  * @tc.require: issueI5W4S7
930  */
931 HWTEST_F(AppMgrServiceInnerTest, KillApplicationSelf_001, TestSize.Level1)
932 {
933     TAG_LOGI(AAFwkTag::TEST, "KillApplicationSelf_001 start");
934     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
935     EXPECT_NE(appMgrServiceInner, nullptr);
936 
937     EXPECT_EQ(appMgrServiceInner->KillApplicationSelf(), ERR_INVALID_VALUE);
938 
939     appMgrServiceInner->appRunningManager_ = nullptr;
940     EXPECT_EQ(appMgrServiceInner->KillApplicationSelf(), ERR_NO_INIT);
941 
942     TAG_LOGI(AAFwkTag::TEST, "KillApplicationSelf_001 end");
943 }
944 
945 /**
946  * @tc.name: KillApplicationByUserId_001
947  * @tc.desc: kill application by user id.
948  * @tc.type: FUNC
949  * @tc.require: issueI5W4S7
950  */
951 HWTEST_F(AppMgrServiceInnerTest, KillApplicationByUserId_001, TestSize.Level1)
952 {
953     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByUserId_001 start");
954     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
955     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
956     EXPECT_NE(appMgrServiceInner, nullptr);
957 
958     std::string bundleName = "test_bundleName";
959     int result = appMgrServiceInner->KillApplicationByUserId(bundleName, 0, 0);
960     EXPECT_NE(result, 0);
961 
962     appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(nullptr);
963     appMgrServiceInner->KillApplicationByUserId(bundleName, 0, 0);
964     EXPECT_NE(result, 0);
965 
966     appMgrServiceInner->remoteClientManager_ = nullptr;
967     appMgrServiceInner->KillApplicationByUserId(bundleName, 0, 0);
968     EXPECT_NE(result, 0);
969 
970     appMgrServiceInner->appRunningManager_ = nullptr;
971     appMgrServiceInner->KillApplicationByUserId(bundleName, 0, 0);
972     EXPECT_NE(result, 0);
973 
974     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByUserId_001 end");
975 }
976 
977 /**
978  * @tc.name: KillApplicationByUserIdLocked_001
979  * @tc.desc: kill application by user id locked.
980  * @tc.type: FUNC
981  * @tc.require: issueI5W4S7
982  */
983 HWTEST_F(AppMgrServiceInnerTest, KillApplicationByUserIdLocked_001, TestSize.Level1)
984 {
985     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByUserIdLocked_001 start");
986     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
987     EXPECT_NE(appMgrServiceInner, nullptr);
988 
989     std::string bundleName = "test_bundleName";
990     int result = appMgrServiceInner->KillApplicationByUserIdLocked(bundleName, 0, 0);
991     EXPECT_EQ(result, 0);
992 
993     appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(nullptr);
994     appMgrServiceInner->KillApplicationByUserIdLocked(bundleName, 0, 0);
995     EXPECT_EQ(result, 0);
996 
997     appMgrServiceInner->remoteClientManager_ = nullptr;
998     appMgrServiceInner->KillApplicationByUserIdLocked(bundleName, 0, 0);
999     EXPECT_EQ(result, 0);
1000 
1001     appMgrServiceInner->appRunningManager_ = nullptr;
1002     appMgrServiceInner->KillApplicationByUserIdLocked(bundleName, 0, 0);
1003     EXPECT_EQ(result, 0);
1004 
1005     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByUserIdLocked_001 end");
1006 }
1007 
1008 /**
1009  * @tc.name: ClearUpApplicationData_001
1010  * @tc.desc: clear up application data.
1011  * @tc.type: FUNC
1012  * @tc.require: issueI5W4S7
1013  */
1014 HWTEST_F(AppMgrServiceInnerTest, ClearUpApplicationData_001, TestSize.Level1)
1015 {
1016     TAG_LOGI(AAFwkTag::TEST, "ClearUpApplicationData_001 start");
1017     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1018     EXPECT_NE(appMgrServiceInner, nullptr);
1019 
1020     std::string bundleName = "test_bundleName";
1021     appMgrServiceInner->ClearUpApplicationData(bundleName, 0, 0, 0);
1022 
1023     TAG_LOGI(AAFwkTag::TEST, "ClearUpApplicationData_001 end");
1024 }
1025 
1026 /**
1027  * @tc.name: ClearUpApplicationDataByUserId_001
1028  * @tc.desc: clear up application data by user id.
1029  * @tc.type: FUNC
1030  * @tc.require: issueI5W4S7
1031  */
1032 HWTEST_F(AppMgrServiceInnerTest, ClearUpApplicationDataByUserId_001, TestSize.Level1)
1033 {
1034     TAG_LOGI(AAFwkTag::TEST, "ClearUpApplicationDataByUserId_001 start");
1035     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1036     EXPECT_NE(appMgrServiceInner, nullptr);
1037 
1038     std::string bundleName = "test_bundleName";
1039     appMgrServiceInner->ClearUpApplicationDataByUserId(bundleName, 0, 0, 0, 0);
1040     appMgrServiceInner->ClearUpApplicationDataByUserId(bundleName, 1, 0, 0, 0);
1041     appMgrServiceInner->ClearUpApplicationDataByUserId(bundleName, 1, 1, 0, 0);
1042 
1043     appMgrServiceInner->appRunningManager_ = nullptr;
1044     appMgrServiceInner->ClearUpApplicationDataByUserId(bundleName, 1, 1, 0, 0);
1045 
1046     appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(nullptr);
1047     appMgrServiceInner->ClearUpApplicationDataByUserId(bundleName, 1, 1, 0, 0);
1048 
1049     TAG_LOGI(AAFwkTag::TEST, "ClearUpApplicationDataByUserId_001 end");
1050 }
1051 
1052 /**
1053  * @tc.name: GetAllRunningProcesses_001
1054  * @tc.desc: get all running processes.
1055  * @tc.type: FUNC
1056  * @tc.require: issueI5W4S7
1057  */
1058 HWTEST_F(AppMgrServiceInnerTest, GetAllRunningProcesses_001, TestSize.Level0)
1059 {
1060     TAG_LOGI(AAFwkTag::TEST, "GetAllRunningProcesses_001 start");
1061     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1062     EXPECT_NE(appMgrServiceInner, nullptr);
1063 
1064     std::vector<RunningProcessInfo> info;
1065     appMgrServiceInner->GetAllRunningProcesses(info);
1066 
1067     TAG_LOGI(AAFwkTag::TEST, "GetAllRunningProcesses_001 end");
1068 }
1069 
1070 /**
1071  * @tc.name: GetProcessRunningInfosByUserId_001
1072  * @tc.desc: get process running infos by user id.
1073  * @tc.type: FUNC
1074  * @tc.require: issueI5W4S7
1075  */
1076 HWTEST_F(AppMgrServiceInnerTest, GetProcessRunningInfosByUserId_001, TestSize.Level1)
1077 {
1078     TAG_LOGI(AAFwkTag::TEST, "GetProcessRunningInfosByUserId_001 start");
1079     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1080     EXPECT_NE(appMgrServiceInner, nullptr);
1081 
1082     std::vector<RunningProcessInfo> info;
1083     appMgrServiceInner->GetProcessRunningInfosByUserId(info, 0);
1084 
1085     TAG_LOGI(AAFwkTag::TEST, "GetProcessRunningInfosByUserId_001 end");
1086 }
1087 
1088 /**
1089  * @tc.name: GetAllRenderProcesses_001
1090  * @tc.desc: get all render processes.
1091  * @tc.type: FUNC
1092  */
1093 HWTEST_F(AppMgrServiceInnerTest, GetAllRenderProcesses_001, TestSize.Level1)
1094 {
1095     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1096     EXPECT_NE(appMgrServiceInner, nullptr);
1097 
1098     std::vector<RenderProcessInfo> info;
1099     appMgrServiceInner->GetAllRenderProcesses(info);
1100 }
1101 
1102 #ifdef SUPPORT_CHILD_PROCESS
1103 /**
1104  * @tc.name: GetAllChildrenProcesses_001
1105  * @tc.desc: get all children processes.
1106  * @tc.type: FUNC
1107  */
1108 HWTEST_F(AppMgrServiceInnerTest, GetAllChildrenProcesses_001, TestSize.Level1)
1109 {
1110     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1111     EXPECT_NE(appMgrServiceInner, nullptr);
1112 
1113     std::vector<ChildProcessInfo> info;
1114     auto result = appMgrServiceInner->GetAllChildrenProcesses(info);
1115     EXPECT_EQ(result, ERR_OK);
1116 }
1117 #endif // SUPPORT_CHILD_PROCESS
1118 
1119 /**
1120  * @tc.name: NotifyMemoryLevel_001
1121  * @tc.desc: notify memory level.
1122  * @tc.type: FUNC
1123  * @tc.require: issueI5W4S7
1124  */
1125 HWTEST_F(AppMgrServiceInnerTest, NotifyMemoryLevel_001, TestSize.Level2)
1126 {
1127     TAG_LOGI(AAFwkTag::TEST, "NotifyMemoryLevel_001 start");
1128     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1129     EXPECT_NE(appMgrServiceInner, nullptr);
1130 
1131     std::vector<RunningProcessInfo> info;
1132     int result = appMgrServiceInner->NotifyMemoryLevel(0);
1133     EXPECT_EQ(result, ERR_INVALID_VALUE);
1134 
1135     result = appMgrServiceInner->NotifyMemoryLevel(1);
1136     EXPECT_EQ(result, ERR_INVALID_VALUE);
1137 
1138     result = appMgrServiceInner->NotifyMemoryLevel(2);
1139     EXPECT_EQ(result, ERR_INVALID_VALUE);
1140 
1141     result = appMgrServiceInner->NotifyMemoryLevel(3);
1142     EXPECT_EQ(result, ERR_INVALID_VALUE);
1143 
1144     appMgrServiceInner->appRunningManager_ = nullptr;
1145     result = appMgrServiceInner->NotifyMemoryLevel(3);
1146     EXPECT_EQ(result, ERR_INVALID_VALUE);
1147 
1148     TAG_LOGI(AAFwkTag::TEST, "NotifyMemoryLevel_001 end");
1149 }
1150 
1151 /**
1152  * @tc.name: KillProcessByPid_001
1153  * @tc.desc: kill process by pid.
1154  * @tc.type: FUNC
1155  * @tc.require: issueI5W4S7
1156  */
1157 HWTEST_F(AppMgrServiceInnerTest, KillProcessByPid_001, TestSize.Level2)
1158 {
1159     TAG_LOGI(AAFwkTag::TEST, "KillProcessByPid_001 start");
1160     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1161     EXPECT_NE(appMgrServiceInner, nullptr);
1162 
1163     int result = appMgrServiceInner->KillProcessByPid(0, "KillProcessByPid_001");
1164     EXPECT_EQ(result, AAFwk::ERR_KILL_PROCESS_NOT_EXIST);
1165 
1166     result = appMgrServiceInner->KillProcessByPid(1, "KillProcessByPid_001");
1167     EXPECT_EQ(result, 0);
1168 
1169     TAG_LOGI(AAFwkTag::TEST, "KillProcessByPid_001 end");
1170 }
1171 
1172 /**
1173  * @tc.name: KillProcessByPid_002
1174  * @tc.desc: kill process by pid.
1175  * @tc.type: FUNC
1176  * @tc.require: issueI5W4S7
1177  */
1178 HWTEST_F(AppMgrServiceInnerTest, KillProcessByPid_002, TestSize.Level2)
1179 {
1180     TAG_LOGI(AAFwkTag::TEST, "KillProcessByPid_002 start");
1181     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1182     EXPECT_NE(appMgrServiceInner, nullptr);
1183     int pid = 0;
1184     std::string processName = "test_processName";
1185     std::shared_ptr<AppRunningRecord> appRecord =
1186         std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
1187     auto appRunningManager = std::make_shared<AppRunningManager>();
1188     auto priorityObject = std::make_shared<PriorityObject>();
1189     priorityObject->SetPid(0);
1190     appRecord->priorityObject_ = priorityObject;
1191     appRunningManager->appRunningRecordMap_.emplace(recordId_, appRecord);
1192 
1193     int result = appMgrServiceInner->KillProcessByPid(pid, "KillProcessByPid_002");
1194     EXPECT_EQ(result, AAFwk::ERR_KILL_PROCESS_NOT_EXIST);
1195 
1196     TAG_LOGI(AAFwkTag::TEST, "KillProcessByPid_002 end");
1197 }
1198 
1199 /**
1200  * @tc.name: KillProcessByPidInner_001
1201  * @tc.desc: kill process by pid.
1202  * @tc.type: FUNC
1203  * @tc.require: issueI5W4S7
1204  */
1205 HWTEST_F(AppMgrServiceInnerTest, KillProcessByPidInner_001, TestSize.Level2)
1206 {
1207     TAG_LOGI(AAFwkTag::TEST, "KillProcessByPidInner_001 start");
1208     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1209     ASSERT_NE(appMgrServiceInner, nullptr);
1210 
1211     pid_t pid = 99999999;
1212     auto ret = appMgrServiceInner->KillProcessByPidInner(pid, "ReasonTdd", "KillReasonTdd", nullptr, false);
1213     EXPECT_EQ(ret, AAFwk::ERR_KILL_PROCESS_NOT_EXIST);
1214     TAG_LOGI(AAFwkTag::TEST, "KillProcessByPidInner_001 end");
1215 }
1216 
1217 /**
1218  * @tc.name: AddToKillProcessMap_001
1219  * @tc.desc: add to kill process map.
1220  * @tc.type: FUNC
1221  * @tc.require: issueI5W4S7
1222  */
1223 HWTEST_F(AppMgrServiceInnerTest, AddToKillProcessMap_001, TestSize.Level2)
1224 {
1225     TAG_LOGI(AAFwkTag::TEST, "AddToKillProcessMap_001 start");
1226     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1227     ASSERT_NE(appMgrServiceInner, nullptr);
1228 
1229     appMgrServiceInner->killedProcessMap_.clear();
1230     appMgrServiceInner->AddToKillProcessMap("com.test.demo");
1231     EXPECT_EQ(appMgrServiceInner->killedProcessMap_.size(), 1);
1232     TAG_LOGI(AAFwkTag::TEST, "AddToKillProcessMap_001 end");
1233 }
1234 
1235 /**
1236  * @tc.name: ProcessExist_001
1237  * @tc.desc: process exist.
1238  * @tc.type: FUNC
1239  * @tc.require: issueI5W4S7
1240  */
1241 HWTEST_F(AppMgrServiceInnerTest, ProcessExist_001, TestSize.Level1)
1242 {
1243     TAG_LOGI(AAFwkTag::TEST, "ProcessExist_001 start");
1244     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1245     EXPECT_NE(appMgrServiceInner, nullptr);
1246 
1247     pid_t pid = 0;
1248     bool result = ProcessUtil::ProcessExist(pid);
1249     EXPECT_FALSE(result);
1250 
1251     TAG_LOGI(AAFwkTag::TEST, "ProcessExist_001 end");
1252 }
1253 
1254 /**
1255  * @tc.name: CreateAppRunningRecord_001
1256  * @tc.desc: create app running record.
1257  * @tc.type: FUNC
1258  * @tc.require: issueI5W4S7
1259  */
1260 HWTEST_F(AppMgrServiceInnerTest, CreateAppRunningRecord_001, TestSize.Level1)
1261 {
1262     TAG_LOGI(AAFwkTag::TEST, "CreateAppRunningRecord_001 start");
1263     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1264     EXPECT_NE(appMgrServiceInner, nullptr);
1265 
1266     BundleInfo bundleInfo;
1267     HapModuleInfo hapModuleInfo;
1268     std::shared_ptr<AAFwk::Want> want;
1269     std::string processName = "test_processName";
1270 
1271     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
1272     std::shared_ptr<AppRunningRecord> appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1273         nullptr, nullptr, "", bundleInfo, hapModuleInfo, nullptr);
1274     EXPECT_EQ(appRecord, nullptr);
1275 
1276     loadParam->token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1277     appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1278         nullptr, nullptr, "", bundleInfo, hapModuleInfo, nullptr);
1279     EXPECT_EQ(appRecord, nullptr);
1280 
1281     appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1282         applicationInfo_, nullptr, "", bundleInfo, hapModuleInfo, nullptr);
1283     EXPECT_EQ(appRecord, nullptr);
1284 
1285     appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1286         applicationInfo_, abilityInfo_, "", bundleInfo, hapModuleInfo, nullptr);
1287     EXPECT_EQ(appRecord, nullptr);
1288 
1289     appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1290         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, nullptr);
1291     EXPECT_NE(appRecord, nullptr);
1292 
1293     appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1294         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, nullptr);
1295     EXPECT_NE(appRecord, nullptr);
1296 
1297     appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1298         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, nullptr);
1299     EXPECT_NE(appRecord, nullptr);
1300 
1301     std::shared_ptr<AppRunningRecord> appRecord1 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1302         nullptr, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1303     EXPECT_EQ(appRecord1, nullptr);
1304 
1305     std::shared_ptr<AppRunningRecord> appRecord2 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1306         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1307     EXPECT_NE(appRecord2, nullptr);
1308 
1309     want = std::make_shared<Want>();
1310     const std::string COLD_START = "coldStart";
1311     want->SetParam(COLD_START, true);
1312     std::shared_ptr<AppRunningRecord> appRecord3 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1313         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1314     EXPECT_NE(appRecord3, nullptr);
1315 
1316     want->SetParam(COLD_START, false);
1317     std::shared_ptr<AppRunningRecord> appRecord4 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1318         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1319     EXPECT_NE(appRecord4, nullptr);
1320 
1321     appMgrServiceInner->appRunningManager_ = nullptr;
1322     std::shared_ptr<AppRunningRecord> appRecord5 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1323         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1324     EXPECT_EQ(appRecord5, nullptr);
1325 
1326     appMgrServiceInner->appRunningManager_ = nullptr;
1327     want->SetParam("multiThread", false);
1328     std::shared_ptr<AppRunningRecord> appRecord6 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1329         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1330     EXPECT_EQ(appRecord6, nullptr);
1331 
1332     TAG_LOGI(AAFwkTag::TEST, "CreateAppRunningRecord_001 end");
1333 }
1334 
1335 /**
1336  * @tc.name: TerminateAbility_001
1337  * @tc.desc: terminate ability.
1338  * @tc.type: FUNC
1339  * @tc.require: issueI5W4S7
1340  */
1341 HWTEST_F(AppMgrServiceInnerTest, TerminateAbility_001, TestSize.Level1)
1342 {
1343     TAG_LOGI(AAFwkTag::TEST, "TerminateAbility_001 start");
1344     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1345     EXPECT_NE(appMgrServiceInner, nullptr);
1346 
1347     appMgrServiceInner->TerminateAbility(nullptr, true);
1348     appMgrServiceInner->TerminateAbility(nullptr, false);
1349 
1350     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1351     appMgrServiceInner->TerminateAbility(token, true);
1352     appMgrServiceInner->TerminateAbility(token, false);
1353 
1354     appMgrServiceInner->appRunningManager_ = nullptr;
1355     appMgrServiceInner->TerminateAbility(token, true);
1356 
1357     TAG_LOGI(AAFwkTag::TEST, "TerminateAbility_001 end");
1358 }
1359 
1360 /**
1361  * @tc.name: UpdateAbilityState_001
1362  * @tc.desc: update ability state.
1363  * @tc.type: FUNC
1364  * @tc.require: issueI5W4S7
1365  */
1366 HWTEST_F(AppMgrServiceInnerTest, UpdateAbilityState_001, TestSize.Level1)
1367 {
1368     TAG_LOGI(AAFwkTag::TEST, "UpdateAbilityState_001 start");
1369     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1370     EXPECT_NE(appMgrServiceInner, nullptr);
1371 
1372     appMgrServiceInner->UpdateAbilityState(nullptr, AbilityState::ABILITY_STATE_CREATE);
1373 
1374     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1375     appMgrServiceInner->UpdateAbilityState(token, AbilityState::ABILITY_STATE_CREATE);
1376 
1377     BundleInfo bundleInfo;
1378     HapModuleInfo hapModuleInfo;
1379     std::shared_ptr<AAFwk::Want> want;
1380     std::string processName = "test_processName";
1381     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
1382     loadParam->token = token;
1383     std::shared_ptr<AppRunningRecord> appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1384         applicationInfo_, nullptr, processName, bundleInfo, hapModuleInfo, want);
1385     EXPECT_NE(appRecord, nullptr);
1386     appMgrServiceInner->UpdateAbilityState(token, AbilityState::ABILITY_STATE_CREATE);
1387 
1388     OHOS::sptr<IRemoteObject> token1 = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1389     loadParam->token = token1;
1390     std::shared_ptr<AppRunningRecord> appRecord1 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1391         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1392     EXPECT_NE(appRecord1, nullptr);
1393 
1394     appMgrServiceInner->UpdateAbilityState(token1, AbilityState::ABILITY_STATE_READY);
1395     appMgrServiceInner->UpdateAbilityState(token1, AbilityState::ABILITY_STATE_CREATE);
1396 
1397     auto abilityRecord1 =
1398         appMgrServiceInner->GetAppRunningRecordByAbilityToken(token1)->GetAbilityRunningRecordByToken(token1);
1399     abilityRecord1->SetState(AbilityState::ABILITY_STATE_TERMINATED);
1400     appMgrServiceInner->UpdateAbilityState(token1, AbilityState::ABILITY_STATE_TERMINATED);
1401 
1402     abilityRecord1->SetState(AbilityState::ABILITY_STATE_CONNECTED);
1403     appMgrServiceInner->UpdateAbilityState(token1, AbilityState::ABILITY_STATE_CONNECTED);
1404 
1405     abilityRecord1->SetState(AbilityState::ABILITY_STATE_DISCONNECTED);
1406     appMgrServiceInner->UpdateAbilityState(token1, AbilityState::ABILITY_STATE_DISCONNECTED);
1407 
1408     abilityRecord1->SetState(AbilityState::ABILITY_STATE_END);
1409     appMgrServiceInner->UpdateAbilityState(token1, AbilityState::ABILITY_STATE_END);
1410 
1411     abilityRecord1->SetState(AbilityState::ABILITY_STATE_BACKGROUND);
1412     appMgrServiceInner->UpdateAbilityState(token1, AbilityState::ABILITY_STATE_BACKGROUND);
1413 
1414     OHOS::sptr<IRemoteObject> token2 = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1415     abilityInfo_->type = AbilityType::SERVICE;
1416     loadParam->token = token2;
1417     std::shared_ptr<AppRunningRecord> appRecord2 = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1418         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1419     EXPECT_NE(appRecord2, nullptr);
1420     appMgrServiceInner->UpdateAbilityState(token2, AbilityState::ABILITY_STATE_CREATE);
1421 
1422     auto abilityRecord2 =
1423         appMgrServiceInner->GetAppRunningRecordByAbilityToken(token2)->GetAbilityRunningRecordByToken(token2);
1424     abilityRecord2->SetState(AbilityState::ABILITY_STATE_TERMINATED);
1425     appMgrServiceInner->UpdateAbilityState(token2, AbilityState::ABILITY_STATE_TERMINATED);
1426 
1427     abilityRecord2->SetState(AbilityState::ABILITY_STATE_CONNECTED);
1428     appMgrServiceInner->UpdateAbilityState(token2, AbilityState::ABILITY_STATE_CONNECTED);
1429 
1430     abilityRecord2->SetState(AbilityState::ABILITY_STATE_DISCONNECTED);
1431     appMgrServiceInner->UpdateAbilityState(token2, AbilityState::ABILITY_STATE_DISCONNECTED);
1432 
1433     abilityRecord2->SetState(AbilityState::ABILITY_STATE_END);
1434     appMgrServiceInner->UpdateAbilityState(token2, AbilityState::ABILITY_STATE_END);
1435 
1436     abilityRecord2->SetState(AbilityState::ABILITY_STATE_BACKGROUND);
1437     appMgrServiceInner->UpdateAbilityState(token2, AbilityState::ABILITY_STATE_BACKGROUND);
1438 
1439     TAG_LOGI(AAFwkTag::TEST, "UpdateAbilityState_001 end");
1440 }
1441 
1442 /**
1443  * @tc.name: UpdateExtensionState_001
1444  * @tc.desc: update extension state.
1445  * @tc.type: FUNC
1446  * @tc.require: issueI5W4S7
1447  */
1448 HWTEST_F(AppMgrServiceInnerTest, UpdateExtensionState_001, TestSize.Level2)
1449 {
1450     TAG_LOGI(AAFwkTag::TEST, "UpdateExtensionState_001 start");
1451     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1452     EXPECT_NE(appMgrServiceInner, nullptr);
1453 
1454     appMgrServiceInner->UpdateExtensionState(nullptr, ExtensionState::EXTENSION_STATE_CREATE);
1455 
1456     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1457     appMgrServiceInner->UpdateExtensionState(token, ExtensionState::EXTENSION_STATE_CREATE);
1458 
1459     BundleInfo bundleInfo;
1460     HapModuleInfo hapModuleInfo;
1461     std::shared_ptr<AAFwk::Want> want;
1462     std::string processName = "test_processName";
1463     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
1464     loadParam->token = token;
1465     std::shared_ptr<AppRunningRecord> appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1466         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1467     EXPECT_NE(appRecord, nullptr);
1468     appMgrServiceInner->UpdateExtensionState(token, ExtensionState::EXTENSION_STATE_CREATE);
1469 
1470     TAG_LOGI(AAFwkTag::TEST, "UpdateExtensionState_001 end");
1471 }
1472 
1473 /**
1474  * @tc.name: OpenAppSpawnConnection_001
1475  * @tc.desc: open app spawn connection.
1476  * @tc.type: FUNC
1477  * @tc.require: issueI5W4S7
1478  */
1479 HWTEST_F(AppMgrServiceInnerTest, OpenAppSpawnConnection_001, TestSize.Level2)
1480 {
1481     TAG_LOGI(AAFwkTag::TEST, "OpenAppSpawnConnection_001 start");
1482     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1483     EXPECT_NE(appMgrServiceInner, nullptr);
1484 
1485     appMgrServiceInner->remoteClientManager_->SetSpawnClient(nullptr);
1486     auto errorCode = appMgrServiceInner->OpenAppSpawnConnection();
1487     EXPECT_EQ(errorCode, ERR_APPEXECFWK_BAD_APPSPAWN_CLIENT);
1488 
1489     appMgrServiceInner->remoteClientManager_ = nullptr;
1490     auto errorCode1 = appMgrServiceInner->OpenAppSpawnConnection();
1491     EXPECT_EQ(errorCode1, ERR_INVALID_VALUE);
1492 
1493     TAG_LOGI(AAFwkTag::TEST, "OpenAppSpawnConnection_001 end");
1494 }
1495 
1496 /**
1497  * @tc.name: CloseAppSpawnConnection_001
1498  * @tc.desc: close app spawn connection.
1499  * @tc.type: FUNC
1500  * @tc.require: issueI5W4S7
1501  */
1502 HWTEST_F(AppMgrServiceInnerTest, CloseAppSpawnConnection_001, TestSize.Level2)
1503 {
1504     TAG_LOGI(AAFwkTag::TEST, "CloseAppSpawnConnection_001 start");
1505     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1506     EXPECT_NE(appMgrServiceInner, nullptr);
1507 
1508     appMgrServiceInner->CloseAppSpawnConnection();
1509 
1510     appMgrServiceInner->remoteClientManager_ = nullptr;
1511     appMgrServiceInner->CloseAppSpawnConnection();
1512 
1513     TAG_LOGI(AAFwkTag::TEST, "CloseAppSpawnConnection_001 end");
1514 }
1515 
1516 /**
1517  * @tc.name: QueryAppSpawnConnectionState_001
1518  * @tc.desc: query app spawn connection.
1519  * @tc.type: FUNC
1520  * @tc.require: issueI5W4S7
1521  */
1522 HWTEST_F(AppMgrServiceInnerTest, QueryAppSpawnConnectionState_001, TestSize.Level2)
1523 {
1524     TAG_LOGI(AAFwkTag::TEST, "QueryAppSpawnConnectionState_001 start");
1525     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1526     EXPECT_NE(appMgrServiceInner, nullptr);
1527 
1528     auto connectionState = appMgrServiceInner->QueryAppSpawnConnectionState();
1529     EXPECT_EQ(connectionState, SpawnConnectionState::STATE_NOT_CONNECT);
1530 
1531     appMgrServiceInner->remoteClientManager_->SetSpawnClient(nullptr);
1532     connectionState = appMgrServiceInner->QueryAppSpawnConnectionState();
1533     EXPECT_EQ(connectionState, SpawnConnectionState::STATE_NOT_CONNECT);
1534 
1535 
1536     appMgrServiceInner->remoteClientManager_ = nullptr;
1537     connectionState = appMgrServiceInner->QueryAppSpawnConnectionState();
1538     EXPECT_EQ(connectionState, SpawnConnectionState::STATE_NOT_CONNECT);
1539 
1540     TAG_LOGI(AAFwkTag::TEST, "QueryAppSpawnConnectionState_001 end");
1541 }
1542 
1543 /**
1544  * @tc.name: SetAppSpawnClient_001
1545  * @tc.desc: set app spawn client.
1546  * @tc.type: FUNC
1547  * @tc.require: issueI5W4S7
1548  */
1549 HWTEST_F(AppMgrServiceInnerTest, SetAppSpawnClient_001, TestSize.Level1)
1550 {
1551     TAG_LOGI(AAFwkTag::TEST, "SetAppSpawnClient_001 start");
1552     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1553     EXPECT_NE(appMgrServiceInner, nullptr);
1554 
1555     std::shared_ptr<AppSpawnClient> spawnClient;
1556     appMgrServiceInner->SetAppSpawnClient(spawnClient);
1557 
1558     appMgrServiceInner->remoteClientManager_ = nullptr;
1559     appMgrServiceInner->SetAppSpawnClient(spawnClient);
1560 
1561     TAG_LOGI(AAFwkTag::TEST, "SetAppSpawnClient_001 end");
1562 }
1563 
1564 /**
1565  * @tc.name: SetBundleManager_001
1566  * @tc.desc: set bundle manager.
1567  * @tc.type: FUNC
1568  * @tc.require: issueI5W4S7
1569  */
1570 HWTEST_F(AppMgrServiceInnerTest, SetBundleManager_001, TestSize.Level2)
1571 {
1572     TAG_LOGI(AAFwkTag::TEST, "SetBundleManager_001 start");
1573     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1574     EXPECT_NE(appMgrServiceInner, nullptr);
1575 
1576     std::shared_ptr<BundleMgrHelper> bundleManager;
1577     appMgrServiceInner->SetBundleManagerHelper(bundleManager);
1578 
1579     appMgrServiceInner->remoteClientManager_ = nullptr;
1580     appMgrServiceInner->SetBundleManagerHelper(bundleManager);
1581 
1582     TAG_LOGI(AAFwkTag::TEST, "SetBundleManager_001 end");
1583 }
1584 
1585 /**
1586  * @tc.name: RegisterAppStateCallback_001
1587  * @tc.desc: register app state call back.
1588  * @tc.type: FUNC
1589  * @tc.require: issueI5W4S7
1590  */
1591 HWTEST_F(AppMgrServiceInnerTest, RegisterAppStateCallback_001, TestSize.Level1)
1592 {
1593     TAG_LOGI(AAFwkTag::TEST, "RegisterAppStateCallback_001 start");
1594     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1595     EXPECT_NE(appMgrServiceInner, nullptr);
1596 
1597     appMgrServiceInner->RegisterAppStateCallback(nullptr);
1598 
1599     sptr<IAppStateCallback> callback;
1600     appMgrServiceInner->RegisterAppStateCallback(callback);
1601 
1602     TAG_LOGI(AAFwkTag::TEST, "RegisterAppStateCallback_001 end");
1603 }
1604 
1605 /**
1606  * @tc.name: KillProcessByAbilityToken_001
1607  * @tc.desc: kill process by ability token.
1608  * @tc.type: FUNC
1609  * @tc.require: issueI5W4S7
1610  */
1611 HWTEST_F(AppMgrServiceInnerTest, KillProcessByAbilityToken_001, TestSize.Level1)
1612 {
1613     TAG_LOGI(AAFwkTag::TEST, "KillProcessByAbilityToken_001 start");
1614     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1615     EXPECT_NE(appMgrServiceInner, nullptr);
1616 
1617     appMgrServiceInner->KillProcessByAbilityToken(nullptr);
1618 
1619     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1620     appMgrServiceInner->KillProcessByAbilityToken(token);
1621 
1622     BundleInfo bundleInfo;
1623     HapModuleInfo hapModuleInfo;
1624     std::shared_ptr<AAFwk::Want> want;
1625     std::string processName = "test_processName";
1626     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
1627     loadParam->token = token;
1628     std::shared_ptr<AppRunningRecord> appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1629         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1630     EXPECT_NE(appRecord, nullptr);
1631     appMgrServiceInner->KillProcessByAbilityToken(token);
1632 
1633     appRecord->SetKeepAliveEnableState(true);
1634     appRecord->SetKeepAliveDkv(true);
1635     appRecord->SetEmptyKeepAliveAppState(true);
1636     appMgrServiceInner->KillProcessByAbilityToken(token);
1637 
1638     TAG_LOGI(AAFwkTag::TEST, "KillProcessByAbilityToken_001 end");
1639 }
1640 
1641 /**
1642  * @tc.name: KillProcessesByUserId_001
1643  * @tc.desc: kill process by user id.
1644  * @tc.type: FUNC
1645  * @tc.require: issueI5W4S7
1646  */
1647 HWTEST_F(AppMgrServiceInnerTest, KillProcessesByUserId_001, TestSize.Level1)
1648 {
1649     TAG_LOGI(AAFwkTag::TEST, "KillProcessesByUserId_001 start");
1650     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1651     EXPECT_NE(appMgrServiceInner, nullptr);
1652 
1653     appMgrServiceInner->KillProcessesByUserId(0, false, nullptr);
1654 
1655     appMgrServiceInner->appRunningManager_ = nullptr;
1656     appMgrServiceInner->KillProcessesByUserId(0, false, nullptr);
1657 
1658     appMgrServiceInner->KillProcessesByUserId(0, true, nullptr);
1659 
1660     TAG_LOGI(AAFwkTag::TEST, "KillProcessesByUserId_001 end");
1661 }
1662 
1663 /**
1664  * @tc.name: WaitProcessesExitAndKill_001
1665  * @tc.desc: kill process by user id.
1666  * @tc.type: FUNC
1667  * @tc.require: issueI5W4S7
1668  */
1669  HWTEST_F(AppMgrServiceInnerTest, WaitProcessesExitAndKill_001, TestSize.Level1)
1670  {
1671      TAG_LOGI(AAFwkTag::TEST, "WaitProcessesExitAndKill_001 start");
1672      auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1673      EXPECT_NE(appMgrServiceInner, nullptr);
1674      sptr<AAFwk::IUserCallback> callback = new MockIUserCallback();
1675      std::list<SimpleProcessInfo> processInfos;
1676      int64_t startTime = 0;
1677      std::string reason = "KillProcessesByUserId";
1678      int32_t userId = 0;
1679      int ret = appMgrServiceInner->WaitProcessesExitAndKill(processInfos, startTime, reason, userId, callback);
1680      EXPECT_EQ(ret, ERR_OK);
1681      TAG_LOGI(AAFwkTag::TEST, "WaitProcessesExitAndKill_001 end");
1682  }
1683 
1684  /**
1685  * @tc.name: WaitProcessesExitAndKill_002
1686  * @tc.desc: kill process by user id.
1687  * @tc.type: FUNC
1688  * @tc.require: issueI5W4S7
1689  */
1690  HWTEST_F(AppMgrServiceInnerTest, WaitProcessesExitAndKill_002, TestSize.Level1)
1691  {
1692      TAG_LOGI(AAFwkTag::TEST, "WaitProcessesExitAndKill_002 start");
1693      auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1694      EXPECT_NE(appMgrServiceInner, nullptr);
1695      std::list<SimpleProcessInfo> processInfos;
1696      int64_t startTime = 0;
1697      std::string reason = "KillProcessesByUserId";
1698      int32_t userId = 0;
1699      int ret = appMgrServiceInner->WaitProcessesExitAndKill(processInfos, startTime, reason, userId, nullptr);
1700      EXPECT_EQ(ret, ERR_OK);
1701      TAG_LOGI(AAFwkTag::TEST, "WaitProcessesExitAndKill_001 end");
1702  }
1703 
1704 /**
1705  * @tc.name: StartAbility_001
1706  * @tc.desc: start ability.
1707  * @tc.type: FUNC
1708  * @tc.require: issueI5W4S7
1709  */
1710 HWTEST_F(AppMgrServiceInnerTest, StartAbility_001, TestSize.Level1)
1711 {
1712     TAG_LOGI(AAFwkTag::TEST, "StartAbility_001 start");
1713     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1714     EXPECT_NE(appMgrServiceInner, nullptr);
1715 
1716     HapModuleInfo hapModuleInfo;
1717     std::shared_ptr<AAFwk::Want> want;
1718     std::shared_ptr<AppRunningRecord> appRecord;
1719     appMgrServiceInner->StartAbility(nullptr, nullptr, abilityInfo_, nullptr, hapModuleInfo, nullptr, 0);
1720     appMgrServiceInner->StartAbility(nullptr, nullptr, abilityInfo_, appRecord, hapModuleInfo, nullptr, 0);
1721     appMgrServiceInner->StartAbility(nullptr, nullptr, abilityInfo_, appRecord, hapModuleInfo, want, 0);
1722 
1723     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1724     OHOS::sptr<IRemoteObject> preToken = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1725     appMgrServiceInner->StartAbility(token, nullptr, abilityInfo_, appRecord, hapModuleInfo, want, 0);
1726     appMgrServiceInner->StartAbility(nullptr, preToken, abilityInfo_, appRecord, hapModuleInfo, want, 0);
1727     appMgrServiceInner->StartAbility(token, preToken, abilityInfo_, appRecord, hapModuleInfo, want, 0);
1728 
1729     BundleInfo bundleInfo;
1730     std::string processName = "test_processName";
1731     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
1732     loadParam->token = token;
1733     appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1734         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1735     EXPECT_NE(appRecord, nullptr);
1736     appMgrServiceInner->StartAbility(token, nullptr, abilityInfo_, appRecord, hapModuleInfo, want, 0);
1737     appMgrServiceInner->StartAbility(token, preToken, abilityInfo_, appRecord, hapModuleInfo, want, 0);
1738 
1739     abilityInfo_->applicationInfo.name = "hiservcie";
1740     abilityInfo_->applicationInfo.bundleName = "com.ix.hiservcie";
1741     appMgrServiceInner->StartAbility(token, preToken, abilityInfo_, appRecord, hapModuleInfo, want, 0);
1742 
1743     TAG_LOGI(AAFwkTag::TEST, "StartAbility_001 end");
1744 }
1745 
1746 /**
1747  * @tc.name: GetAppRunningRecordByAbilityToken_001
1748  * @tc.desc: get app running record by ability token.
1749  * @tc.type: FUNC
1750  * @tc.require: issueI5W4S7
1751  */
1752 HWTEST_F(AppMgrServiceInnerTest, GetAppRunningRecordByAbilityToken_001, TestSize.Level2)
1753 {
1754     TAG_LOGI(AAFwkTag::TEST, "GetAppRunningRecordByAbilityToken_001 start");
1755     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1756     EXPECT_NE(appMgrServiceInner, nullptr);
1757 
1758     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1759     appMgrServiceInner->GetAppRunningRecordByAbilityToken(token);
1760 
1761     appMgrServiceInner->appRunningManager_ = nullptr;
1762     appMgrServiceInner->GetAppRunningRecordByAbilityToken(token);
1763 
1764     TAG_LOGI(AAFwkTag::TEST, "GetAppRunningRecordByAbilityToken_001 end");
1765 }
1766 
1767 /**
1768  * @tc.name: AbilityTerminated_001
1769  * @tc.desc: ability terminated.
1770  * @tc.type: FUNC
1771  * @tc.require: issueI5W4S7
1772  */
1773 HWTEST_F(AppMgrServiceInnerTest, AbilityTerminated_001, TestSize.Level1)
1774 {
1775     TAG_LOGI(AAFwkTag::TEST, "AbilityTerminated_001 start");
1776     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1777     EXPECT_NE(appMgrServiceInner, nullptr);
1778 
1779     appMgrServiceInner->AbilityTerminated(nullptr);
1780 
1781     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
1782     appMgrServiceInner->AbilityTerminated(token);
1783 
1784     BundleInfo bundleInfo;
1785     HapModuleInfo hapModuleInfo;
1786     std::shared_ptr<AAFwk::Want> want;
1787     std::string processName = "test_processName";
1788     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
1789     loadParam->token = token;
1790     std::shared_ptr<AppRunningRecord> appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
1791         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
1792     EXPECT_NE(appRecord, nullptr);
1793     appMgrServiceInner->AbilityTerminated(token);
1794 
1795     TAG_LOGI(AAFwkTag::TEST, "AbilityTerminated_001 end");
1796 }
1797 
1798 /**
1799  * @tc.name: GetAppRunningRecordByAppRecordId_001
1800  * @tc.desc: get app running record by app record id.
1801  * @tc.type: FUNC
1802  * @tc.require: issueI5W4S7
1803  */
1804 HWTEST_F(AppMgrServiceInnerTest, GetAppRunningRecordByAppRecordId_001, TestSize.Level2)
1805 {
1806     TAG_LOGI(AAFwkTag::TEST, "GetAppRunningRecordByAppRecordId_001 start");
1807     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1808     EXPECT_NE(appMgrServiceInner, nullptr);
1809 
1810     appMgrServiceInner->GetAppRunningRecordByAppRecordId(0);
1811 
1812     appMgrServiceInner->appRunningManager_ = nullptr;
1813     appMgrServiceInner->GetAppRunningRecordByAppRecordId(0);
1814 
1815     TAG_LOGI(AAFwkTag::TEST, "GetAppRunningRecordByAppRecordId_001 end");
1816 }
1817 
1818 /**
1819  * @tc.name: OnAppStateChanged_001
1820  * @tc.desc: on app state changed.
1821  * @tc.type: FUNC
1822  * @tc.require: issueI5W4S7
1823  */
1824 HWTEST_F(AppMgrServiceInnerTest, OnAppStateChanged_001, TestSize.Level2)
1825 {
1826     TAG_LOGI(AAFwkTag::TEST, "OnAppStateChanged_001 start");
1827     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1828     EXPECT_NE(appMgrServiceInner, nullptr);
1829 
1830     appMgrServiceInner->OnAppStateChanged(nullptr, ApplicationState::APP_STATE_CREATE, true, false);
1831     appMgrServiceInner->OnAppStateChanged(nullptr, ApplicationState::APP_STATE_CREATE, false, false);
1832 
1833     BundleInfo bundleInfo;
1834     std::string processName = "test_processName";
1835     std::shared_ptr<AppRunningRecord> appRecord =
1836         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
1837     EXPECT_NE(appRecord, nullptr);
1838     appMgrServiceInner->OnAppStateChanged(appRecord, ApplicationState::APP_STATE_CREATE, true, false);
1839 
1840     sptr<MockAppStateCallback> mockCallback(new MockAppStateCallback());
1841     EXPECT_CALL(*mockCallback, OnAppStateChanged(_)).Times(2);
1842     sptr<IAppStateCallback> callback1 = iface_cast<IAppStateCallback>(mockCallback);
1843     appMgrServiceInner->appStateCallbacks_.push_back({ callback1, 100 });
1844     appMgrServiceInner->OnAppStateChanged(appRecord, ApplicationState::APP_STATE_CREATE, true, false);
1845 
1846     sptr<IAppStateCallback> callback;
1847     appMgrServiceInner->appStateCallbacks_.push_back({ callback, 100 });
1848     appMgrServiceInner->OnAppStateChanged(appRecord, ApplicationState::APP_STATE_CREATE, true, false);
1849 
1850     TAG_LOGI(AAFwkTag::TEST, "OnAppStateChanged_001 end");
1851 }
1852 
1853 /**
1854  * @tc.name: OnAbilityStateChanged_001
1855  * @tc.desc: on ability state changed.
1856  * @tc.type: FUNC
1857  * @tc.require: issueI5W4S7
1858  */
1859 HWTEST_F(AppMgrServiceInnerTest, OnAbilityStateChanged_001, TestSize.Level2)
1860 {
1861     TAG_LOGI(AAFwkTag::TEST, "OnAbilityStateChanged_001 start");
1862     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1863     EXPECT_NE(appMgrServiceInner, nullptr);
1864 
1865     appMgrServiceInner->OnAbilityStateChanged(nullptr, AbilityState::ABILITY_STATE_CREATE);
1866 
1867     sptr<IRemoteObject> token = new MockAbilityToken();
1868     std::shared_ptr<AbilityRunningRecord> abilityRunningRecord =
1869         std::make_shared<AbilityRunningRecord>(abilityInfo_, token, 0);
1870     appMgrServiceInner->OnAbilityStateChanged(abilityRunningRecord, AbilityState::ABILITY_STATE_CREATE);
1871 
1872     sptr<MockAppStateCallback> mockCallback(new MockAppStateCallback());
1873     EXPECT_CALL(*mockCallback, OnAbilityRequestDone(_, _)).Times(2);
1874     sptr<IAppStateCallback> callback1 = iface_cast<IAppStateCallback>(mockCallback);
1875     appMgrServiceInner->appStateCallbacks_.push_back({ callback1, 100 });
1876     appMgrServiceInner->OnAbilityStateChanged(abilityRunningRecord, AbilityState::ABILITY_STATE_CREATE);
1877 
1878     sptr<IAppStateCallback> callback;
1879     appMgrServiceInner->appStateCallbacks_.push_back({ callback, 100 });
1880     appMgrServiceInner->OnAbilityStateChanged(abilityRunningRecord, AbilityState::ABILITY_STATE_CREATE);
1881 
1882     TAG_LOGI(AAFwkTag::TEST, "OnAbilityStateChanged_001 end");
1883 }
1884 
1885 /**
1886  * @tc.name: StartProcess_001
1887  * @tc.desc: start process.
1888  * @tc.type: FUNC
1889  * @tc.require: issueI5W4S7
1890  */
1891 HWTEST_F(AppMgrServiceInnerTest, StartProcess_001, TestSize.Level1)
1892 {
1893     TAG_LOGI(AAFwkTag::TEST, "StartProcess_001 start");
1894     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1895     EXPECT_NE(appMgrServiceInner, nullptr);
1896 
1897     BundleInfo bundleInfo;
1898     std::string appName = "test_appName";
1899     std::string processName = "test_processName";
1900     std::string bundleName = "test_bundleName";
1901     sptr<IRemoteObject> token = new MockAbilityToken();
1902     std::shared_ptr<AppRunningRecord> appRecord =
1903         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
1904     EXPECT_NE(appRecord, nullptr);
1905     appMgrServiceInner->StartProcess(appName, processName, 0, nullptr, 0, bundleInfo, bundleName, 0);
1906     appMgrServiceInner->StartProcess(appName, processName, 0, appRecord, 0, bundleInfo, bundleName, 0);
1907 
1908     TAG_LOGI(AAFwkTag::TEST, "StartProcess_001 end");
1909 }
1910 
1911 /**
1912  * @tc.name: StartProcess_null_spawnclient_001
1913  * @tc.desc: start process.
1914  * @tc.type: FUNC
1915  * @tc.require: issueI5W4S7
1916  */
1917 HWTEST_F(AppMgrServiceInnerTest, StartProcess_null_spawnclient_001, TestSize.Level1)
1918 {
1919     TAG_LOGI(AAFwkTag::TEST, "StartProcess_null_spawnclient_001 start");
1920     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1921     EXPECT_NE(appMgrServiceInner, nullptr);
1922 
1923     BundleInfo bundleInfo;
1924     std::string appName = "test_appName";
1925     std::string processName = "test_processName";
1926     std::string bundleName = "test_bundleName";
1927     sptr<IRemoteObject> token = new MockAbilityToken();
1928     std::shared_ptr<AppRunningRecord> appRecord =
1929         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
1930     EXPECT_NE(appRecord, nullptr);
1931     appMgrServiceInner->remoteClientManager_ = nullptr;
1932     appMgrServiceInner->StartProcess(appName, processName, 0, nullptr, 0, bundleInfo, bundleName, 0);
1933     uint32_t ret = appMgrServiceInner->StartProcess(appName, processName, 0, appRecord, 0, bundleInfo, bundleName, 0);
1934     EXPECT_EQ(ret, AAFwk::ERR_GET_SPAWN_CLIENT_FAILED);
1935     TAG_LOGI(AAFwkTag::TEST, "StartProcess_null_spawnclient_001 end");
1936 }
1937 
1938 /**
1939  * @tc.name: OnRemoteDied_001
1940  * @tc.desc: on remote died.
1941  * @tc.type: FUNC
1942  * @tc.require: issueI5W4S7
1943  */
1944 HWTEST_F(AppMgrServiceInnerTest, OnRemoteDied_001, TestSize.Level2)
1945 {
1946     TAG_LOGI(AAFwkTag::TEST, "OnRemoteDied_001 start");
1947     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1948     EXPECT_NE(appMgrServiceInner, nullptr);
1949 
1950     sptr<IRemoteObject> remoteObject;
1951     appMgrServiceInner->OnRemoteDied(remoteObject, true);
1952     appMgrServiceInner->OnRemoteDied(remoteObject, false);
1953 
1954     TAG_LOGI(AAFwkTag::TEST, "OnRemoteDied_001 end");
1955 }
1956 
1957 /**
1958  * @tc.name: ClearAppRunningData_001
1959  * @tc.desc: clear app running data.
1960  * @tc.type: FUNC
1961  */
1962 HWTEST_F(AppMgrServiceInnerTest, ClearAppRunningData_001, TestSize.Level2)
1963 {
1964     TAG_LOGI(AAFwkTag::TEST, "ClearAppRunningData_001 start");
1965     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1966     EXPECT_NE(appMgrServiceInner, nullptr);
1967 
1968     appMgrServiceInner->ClearAppRunningData(nullptr);
1969     TAG_LOGI(AAFwkTag::TEST, "ClearAppRunningData_001 end");
1970 }
1971 
1972 /**
1973  * @tc.name: ClearAppRunningData_002
1974  * @tc.desc: clear app running data.
1975  * @tc.type: FUNC
1976  */
1977 HWTEST_F(AppMgrServiceInnerTest, ClearAppRunningData_002, TestSize.Level2)
1978 {
1979     TAG_LOGI(AAFwkTag::TEST, "ClearAppRunningData_002 start");
1980     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
1981     EXPECT_NE(appMgrServiceInner, nullptr);
1982     BundleInfo info;
1983     std::string processName = "test_processName";
1984     std::shared_ptr<AppRunningRecord> appRecord =
1985         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
1986     appMgrServiceInner->ClearAppRunningData(appRecord);
1987     TAG_LOGI(AAFwkTag::TEST, "ClearAppRunningData_002 end");
1988 }
1989 
1990 /**
1991  * @tc.name: HandleTimeOut_001
1992  * @tc.desc: handle time out.
1993  * @tc.type: FUNC
1994  * @tc.require: issueI5W4S7
1995  */
1996 HWTEST_F(AppMgrServiceInnerTest, HandleTimeOut_001, TestSize.Level2)
1997 {
1998     TAG_LOGI(AAFwkTag::TEST, "HandleTimeOut_001 start");
1999     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2000     EXPECT_NE(appMgrServiceInner, nullptr);
2001 
2002     AAFwk::EventWrap innerEvent(0);
2003     appMgrServiceInner->HandleTimeOut(innerEvent);
2004 
2005     appMgrServiceInner->appRunningManager_ = nullptr;
2006     appMgrServiceInner->HandleTimeOut(innerEvent);
2007 
2008     TAG_LOGI(AAFwkTag::TEST, "HandleTimeOut_001 end");
2009 }
2010 
2011 /**
2012  * @tc.name: HandleAbilityAttachTimeOut_001
2013  * @tc.desc: handle ability attach time out.
2014  * @tc.type: FUNC
2015  * @tc.require: issueI5W4S7
2016  */
2017 HWTEST_F(AppMgrServiceInnerTest, HandleAbilityAttachTimeOut_001, TestSize.Level2)
2018 {
2019     TAG_LOGI(AAFwkTag::TEST, "HandleAbilityAttachTimeOut_001 start");
2020     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2021     EXPECT_NE(appMgrServiceInner, nullptr);
2022 
2023     appMgrServiceInner->HandleAbilityAttachTimeOut(nullptr);
2024 
2025     appMgrServiceInner->appRunningManager_ = nullptr;
2026     appMgrServiceInner->HandleAbilityAttachTimeOut(nullptr);
2027 
2028     TAG_LOGI(AAFwkTag::TEST, "HandleAbilityAttachTimeOut_001 end");
2029 }
2030 
2031 /**
2032  * @tc.name: PrepareTerminate_001
2033  * @tc.desc: prepare terminate.
2034  * @tc.type: FUNC
2035  * @tc.require: issueI5W4S7
2036  */
2037 HWTEST_F(AppMgrServiceInnerTest, PrepareTerminate_001, TestSize.Level2)
2038 {
2039     TAG_LOGI(AAFwkTag::TEST, "PrepareTerminate_001 start");
2040     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2041     EXPECT_NE(appMgrServiceInner, nullptr);
2042 
2043     appMgrServiceInner->PrepareTerminate(nullptr);
2044 
2045     appMgrServiceInner->appRunningManager_ = nullptr;
2046     appMgrServiceInner->PrepareTerminate(nullptr);
2047 
2048     TAG_LOGI(AAFwkTag::TEST, "PrepareTerminate_001 end");
2049 }
2050 
2051 /**
2052  * @tc.name: HandleTerminateApplicationTimeOut_001
2053  * @tc.desc: handle terminate application time out.
2054  * @tc.type: FUNC
2055  * @tc.require: issueI5W4S7
2056  */
2057 HWTEST_F(AppMgrServiceInnerTest, HandleTerminateApplicationTimeOut_001, TestSize.Level2)
2058 {
2059     TAG_LOGI(AAFwkTag::TEST, "HandleTerminateApplicationTimeOut_001 start");
2060     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2061     EXPECT_NE(appMgrServiceInner, nullptr);
2062 
2063     appMgrServiceInner->HandleTerminateApplicationTimeOut(nullptr);
2064 
2065     BundleInfo bundleInfo;
2066     std::string appName = "test_appName";
2067     std::string processName = "test_processName";
2068     std::string bundleName = "test_bundleName";
2069     sptr<IRemoteObject> token = new MockAbilityToken();
2070     std::shared_ptr<AppRunningRecord> appRecord =
2071         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2072     EXPECT_NE(appRecord, nullptr);
2073 
2074     pid_t pid = 1;
2075     appRecord->GetPriorityObject()->SetPid(pid);
2076     appMgrServiceInner->HandleTerminateApplicationTimeOut(appRecord);
2077 
2078     appMgrServiceInner->taskHandler_ = nullptr;
2079     appMgrServiceInner->HandleTerminateApplicationTimeOut(appRecord);
2080 
2081     TAG_LOGI(AAFwkTag::TEST, "HandleTerminateApplicationTimeOut_001 end");
2082 }
2083 
2084 /**
2085  * @tc.name: HandleAddAbilityStageTimeOut_001
2086  * @tc.desc: handle add ability stage time out.
2087  * @tc.type: FUNC
2088  * @tc.require: issueI5W4S7
2089  */
2090 HWTEST_F(AppMgrServiceInnerTest, HandleAddAbilityStageTimeOut_001, TestSize.Level2)
2091 {
2092     TAG_LOGI(AAFwkTag::TEST, "HandleAddAbilityStageTimeOut_001 start");
2093     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2094     EXPECT_NE(appMgrServiceInner, nullptr);
2095 
2096     appMgrServiceInner->HandleAddAbilityStageTimeOut(nullptr);
2097 
2098     BundleInfo bundleInfo;
2099     std::string appName = "test_appName";
2100     std::string processName = "test_processName";
2101     std::string bundleName = "test_bundleName";
2102     sptr<IRemoteObject> token = new MockAbilityToken();
2103     std::shared_ptr<AppRunningRecord> appRecord =
2104         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2105     EXPECT_NE(appRecord, nullptr);
2106 
2107     appRecord->specifiedAbilityRequest_ = std::make_shared<SpecifiedRequest>();
2108     appRecord->specifiedAbilityRequest_->requestId = 1;
2109     appMgrServiceInner->HandleAddAbilityStageTimeOut(appRecord);
2110 
2111     sptr<IStartSpecifiedAbilityResponse> response;
2112     appMgrServiceInner->startSpecifiedAbilityResponse_ = response;
2113     appMgrServiceInner->HandleAddAbilityStageTimeOut(appRecord);
2114 
2115     TAG_LOGI(AAFwkTag::TEST, "HandleAddAbilityStageTimeOut_001 end");
2116 }
2117 
2118 /**
2119  * @tc.name: GetRunningProcessInfoByToken_001
2120  * @tc.desc: get running process info by token.
2121  * @tc.type: FUNC
2122  * @tc.require: issueI5W4S7
2123  */
2124 HWTEST_F(AppMgrServiceInnerTest, GetRunningProcessInfoByToken_001, TestSize.Level2)
2125 {
2126     TAG_LOGI(AAFwkTag::TEST, "GetRunningProcessInfoByToken_001 start");
2127     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2128     EXPECT_NE(appMgrServiceInner, nullptr);
2129 
2130     AppExecFwk::RunningProcessInfo info;
2131     appMgrServiceInner->GetRunningProcessInfoByToken(nullptr, info);
2132 
2133     appMgrServiceInner->appRunningManager_ = nullptr;
2134     appMgrServiceInner->GetRunningProcessInfoByToken(nullptr, info);
2135 
2136     TAG_LOGI(AAFwkTag::TEST, "GetRunningProcessInfoByToken_001 end");
2137 }
2138 
2139 /**
2140  * @tc.name: GetRunningProcessInfoByPid_001
2141  * @tc.desc: get running process info by pid.
2142  * @tc.type: FUNC
2143  * @tc.require: issueI5W4S7
2144  */
2145 HWTEST_F(AppMgrServiceInnerTest, GetRunningProcessInfoByPid_001, TestSize.Level2)
2146 {
2147     TAG_LOGI(AAFwkTag::TEST, "GetRunningProcessInfoByPid_001 start");
2148     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2149     EXPECT_NE(appMgrServiceInner, nullptr);
2150 
2151     AppExecFwk::RunningProcessInfo info;
2152     appMgrServiceInner->GetRunningProcessInfoByPid(0, info);
2153 
2154     appMgrServiceInner->appRunningManager_ = nullptr;
2155     appMgrServiceInner->GetRunningProcessInfoByPid(0, info);
2156 
2157     TAG_LOGI(AAFwkTag::TEST, "GetRunningProcessInfoByPid_001 end");
2158 }
2159 
2160 /**
2161  * @tc.name: CheckGetRunningInfoPermission_001
2162  * @tc.desc: check get running info permission.
2163  * @tc.type: FUNC
2164  * @tc.require: issueI5W4S7
2165  */
2166 HWTEST_F(AppMgrServiceInnerTest, CheckGetRunningInfoPermission_001, TestSize.Level2)
2167 {
2168     TAG_LOGI(AAFwkTag::TEST, "CheckGetRunningInfoPermission_001 start");
2169     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2170     EXPECT_NE(appMgrServiceInner, nullptr);
2171 
2172     appMgrServiceInner->CheckGetRunningInfoPermission();
2173 
2174     appMgrServiceInner->appRunningManager_ = nullptr;
2175     appMgrServiceInner->CheckGetRunningInfoPermission();
2176 
2177     TAG_LOGI(AAFwkTag::TEST, "CheckGetRunningInfoPermission_001 end");
2178 }
2179 
2180 /**
2181  * @tc.name: IsMemorySizeSufficent_001
2182  * @tc.desc: check get running info permission.
2183  * @tc.type: FUNC
2184  * @tc.require: issueI5W4S7
2185  */
2186 HWTEST_F(AppMgrServiceInnerTest, IsMemorySizeSufficent_001, TestSize.Level2)
2187 {
2188     TAG_LOGI(AAFwkTag::TEST, "IsMemorySizeSufficient start");
2189     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2190     EXPECT_NE(appMgrServiceInner, nullptr);
2191 
2192     appMgrServiceInner->IsMemorySizeSufficient();
2193 
2194     appMgrServiceInner->appRunningManager_ = nullptr;
2195     appMgrServiceInner->IsMemorySizeSufficient();
2196 
2197     TAG_LOGI(AAFwkTag::TEST, "IsMemorySizeSufficent_001 end");
2198 }
2199 
2200 /**
2201  * @tc.name: LoadResidentProcess_001
2202  * @tc.desc: load resident process.
2203  * @tc.type: FUNC
2204  * @tc.require: issueI5W4S7
2205  */
2206 HWTEST_F(AppMgrServiceInnerTest, LoadResidentProcess_001, TestSize.Level2)
2207 {
2208     TAG_LOGI(AAFwkTag::TEST, "LoadResidentProcess_001 start");
2209     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2210     EXPECT_NE(appMgrServiceInner, nullptr);
2211 
2212     std::vector<BundleInfo> infos;
2213     appMgrServiceInner->LoadResidentProcess(infos);
2214 
2215     TAG_LOGI(AAFwkTag::TEST, "LoadResidentProcess_001 end");
2216 }
2217 
2218 /**
2219  * @tc.name: StartResidentProcess_001
2220  * @tc.desc: start resident process.
2221  * @tc.type: FUNC
2222  * @tc.require: issueI5W4S7
2223  */
2224 HWTEST_F(AppMgrServiceInnerTest, StartResidentProcess_001, TestSize.Level2)
2225 {
2226     TAG_LOGI(AAFwkTag::TEST, "StartResidentProcess_001 start");
2227     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2228     EXPECT_NE(appMgrServiceInner, nullptr);
2229 
2230     std::vector<BundleInfo> infos;
2231     appMgrServiceInner->StartResidentProcess(infos, 0, true);
2232 
2233     BundleInfo info;
2234     infos.push_back(info);
2235 
2236     BundleInfo info1;
2237     info1.applicationInfo.process = "";
2238     infos.push_back(info1);
2239 
2240     BundleInfo info2;
2241     info2.applicationInfo.process = "test_process";
2242     infos.push_back(info2);
2243     appMgrServiceInner->StartResidentProcess(infos, 0, true);
2244 
2245     appMgrServiceInner->appRunningManager_ = nullptr;
2246     appMgrServiceInner->StartResidentProcess(infos, 0, true);
2247 
2248     TAG_LOGI(AAFwkTag::TEST, "StartResidentProcess_001 end");
2249 }
2250 
2251 /**
2252  * @tc.name: StartEmptyResidentProcess_001
2253  * @tc.desc: start empty resident process.
2254  * @tc.type: FUNC
2255  * @tc.require: issueI5W4S7
2256  */
2257 HWTEST_F(AppMgrServiceInnerTest, StartEmptyResidentProcess_001, TestSize.Level2)
2258 {
2259     TAG_LOGI(AAFwkTag::TEST, "StartEmptyResidentProcess_001 start");
2260     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2261     EXPECT_NE(appMgrServiceInner, nullptr);
2262 
2263     BundleInfo info;
2264     info.applicationInfo = *applicationInfo_;
2265     std::string processName = "test_process";
2266     appMgrServiceInner->StartEmptyResidentProcess(info, processName, 0, true);
2267 
2268     appMgrServiceInner->StartEmptyResidentProcess(info, processName, 1, true);
2269 
2270     appMgrServiceInner->StartEmptyResidentProcess(info, "", 0, true);
2271 
2272     appMgrServiceInner->appRunningManager_ = nullptr;
2273     appMgrServiceInner->StartEmptyResidentProcess(info, processName, 0, true);
2274 
2275     appMgrServiceInner->remoteClientManager_ = nullptr;
2276     appMgrServiceInner->StartEmptyResidentProcess(info, processName, 0, true);
2277 
2278     TAG_LOGI(AAFwkTag::TEST, "StartEmptyResidentProcess_001 end");
2279 }
2280 
2281 /**
2282  * @tc.name: CheckRemoteClient_001
2283  * @tc.desc: check remote client.
2284  * @tc.type: FUNC
2285  * @tc.require: issueI5W4S7
2286  */
2287 HWTEST_F(AppMgrServiceInnerTest, CheckRemoteClient_001, TestSize.Level2)
2288 {
2289     TAG_LOGI(AAFwkTag::TEST, "CheckRemoteClient_001 start");
2290     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2291     EXPECT_NE(appMgrServiceInner, nullptr);
2292 
2293     appMgrServiceInner->CheckRemoteClient();
2294 
2295     appMgrServiceInner->remoteClientManager_->SetSpawnClient(nullptr);
2296     appMgrServiceInner->CheckRemoteClient();
2297 
2298     appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(nullptr);
2299     appMgrServiceInner->CheckRemoteClient();
2300 
2301     appMgrServiceInner->remoteClientManager_ = nullptr;
2302     appMgrServiceInner->CheckRemoteClient();
2303 
2304     TAG_LOGI(AAFwkTag::TEST, "CheckRemoteClient_001 end");
2305 }
2306 
2307 /**
2308  * @tc.name: RestartResidentProcess_001
2309  * @tc.desc: restart resident process.
2310  * @tc.type: FUNC
2311  * @tc.require: issueI5W4S7
2312  */
2313 HWTEST_F(AppMgrServiceInnerTest, RestartResidentProcess_001, TestSize.Level2)
2314 {
2315     TAG_LOGI(AAFwkTag::TEST, "RestartResidentProcess_001 start");
2316     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2317     EXPECT_NE(appMgrServiceInner, nullptr);
2318 
2319     appMgrServiceInner->RestartResidentProcess(nullptr);
2320 
2321     std::shared_ptr<AppRunningRecord> appRecord;
2322     appMgrServiceInner->RestartResidentProcess(appRecord);
2323 
2324     BundleInfo bundleInfo;
2325     std::string processName = "test_processName";
2326     appRecord =
2327         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2328     EXPECT_NE(appRecord, nullptr);
2329     appRecord->mainBundleName_ = "com.ohos.settings";
2330     appMgrServiceInner->RestartResidentProcess(appRecord);
2331 
2332     appMgrServiceInner->appRunningManager_ = nullptr;
2333     appMgrServiceInner->RestartResidentProcess(appRecord);
2334 
2335     appMgrServiceInner->remoteClientManager_ = nullptr;
2336     appMgrServiceInner->RestartResidentProcess(appRecord);
2337 
2338     TAG_LOGI(AAFwkTag::TEST, "RestartResidentProcess_001 end");
2339 }
2340 
2341 /**
2342  * @tc.name: NotifyAppStatusByCallerUid_001
2343  * @tc.desc: notify app status by caller uid.
2344  * @tc.type: FUNC
2345  * @tc.require: issueI5W4S7
2346  */
2347 HWTEST_F(AppMgrServiceInnerTest, NotifyAppStatusByCallerUid_001, TestSize.Level2)
2348 {
2349     TAG_LOGI(AAFwkTag::TEST, "NotifyAppStatusByCallerUid_001 start");
2350     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2351     EXPECT_NE(appMgrServiceInner, nullptr);
2352 
2353     std::string bundleName = "test_bundle_name";
2354     std::string eventData = "test_event_data";
2355     appMgrServiceInner->NotifyAppStatusByCallerUid(bundleName, 0, 0, 0, 0, eventData);
2356 
2357     TAG_LOGI(AAFwkTag::TEST, "NotifyAppStatusByCallerUid_001 end");
2358 }
2359 
2360 /**
2361  * @tc.name: NotifyAppStatusByCommonEventName_001
2362  * @tc.desc: notify app status by special common event.
2363  * @tc.type: FUNC
2364  */
2365 HWTEST_F(AppMgrServiceInnerTest, NotifyAppStatusByCommonEventName_001, TestSize.Level2)
2366 {
2367     TAG_LOGI(AAFwkTag::TEST, "NotifyAppStatusByCommonEventName_001 start");
2368     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2369     EXPECT_NE(appMgrServiceInner, nullptr);
2370 
2371     std::string bundleName = "test_bundle_name";
2372     std::string eventData = "usual.event.PACKAGE_DATA_CLEARED";
2373     AAFwk::Want want;
2374     int32_t ret = appMgrServiceInner->NotifyAppStatusByCommonEventName(bundleName, eventData, want);
2375     EXPECT_EQ(ret, 1);
2376 
2377     eventData = "test_event_name";
2378     ret = appMgrServiceInner->NotifyAppStatusByCommonEventName(bundleName, eventData, want);
2379     EXPECT_EQ(ret, 0);
2380 
2381     eventData = "usual.event.PACKAGE_RESTARTED";
2382     ret = appMgrServiceInner->NotifyAppStatusByCommonEventName(bundleName, eventData, want);
2383     EXPECT_EQ(ret, 1);
2384     TAG_LOGI(AAFwkTag::TEST, "NotifyAppStatusByCommonEventName_001 end");
2385 }
2386 
2387 /**
2388  * @tc.name: RegisterApplicationStateObserver_001
2389  * @tc.desc: register application state observer.
2390  * @tc.type: FUNC
2391  * @tc.require: issueI5W4S7
2392  */
2393 HWTEST_F(AppMgrServiceInnerTest, RegisterApplicationStateObserver_001, TestSize.Level2)
2394 {
2395     TAG_LOGI(AAFwkTag::TEST, "RegisterApplicationStateObserver_001 start");
2396     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2397     EXPECT_NE(appMgrServiceInner, nullptr);
2398 
2399     sptr<IApplicationStateObserver> observer;
2400     std::vector<std::string> bundleNameList;
2401     appMgrServiceInner->RegisterApplicationStateObserver(observer, bundleNameList);
2402 
2403     TAG_LOGI(AAFwkTag::TEST, "RegisterApplicationStateObserver_001 end");
2404 }
2405 
2406 /**
2407  * @tc.name: UnregisterApplicationStateObserver_001
2408  * @tc.desc: unregister application state observer.
2409  * @tc.type: FUNC
2410  * @tc.require: issueI5W4S7
2411  */
2412 HWTEST_F(AppMgrServiceInnerTest, UnregisterApplicationStateObserver_001, TestSize.Level2)
2413 {
2414     TAG_LOGI(AAFwkTag::TEST, "UnregisterApplicationStateObserver_001 start");
2415     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2416     EXPECT_NE(appMgrServiceInner, nullptr);
2417 
2418     sptr<IApplicationStateObserver> observer;
2419     appMgrServiceInner->UnregisterApplicationStateObserver(observer);
2420 
2421     TAG_LOGI(AAFwkTag::TEST, "UnregisterApplicationStateObserver_001 end");
2422 }
2423 
2424 /**
2425  * @tc.name: RegisterNativeChildExitNotify_001
2426  * @tc.desc: register native chlid exit notify.
2427  * @tc.type: FUNC
2428  * @tc.require: issueI5W4S7
2429  */
2430 HWTEST_F(AppMgrServiceInnerTest, RegisterNativeChildExitNotify_001, TestSize.Level0)
2431 {
2432     TAG_LOGI(AAFwkTag::TEST, "RegisterNativeChildExitNotify_001 start");
2433     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2434     EXPECT_NE(appMgrServiceInner, nullptr);
2435 
2436     sptr<INativeChildNotify> notify;
2437     auto ret = appMgrServiceInner->RegisterNativeChildExitNotify(notify);
2438     EXPECT_NE(ret, ERR_OK);
2439 
2440     TAG_LOGI(AAFwkTag::TEST, "RegisterNativeChildExitNotify_001 end");
2441 }
2442 
2443 /**
2444  * @tc.name: UnregisterNativeChildExitNotify_001
2445  * @tc.desc: unregister native chlid exit notify.
2446  * @tc.type: FUNC
2447  * @tc.require: issueI5W4S7
2448  */
2449 HWTEST_F(AppMgrServiceInnerTest, UnregisterNativeChildExitNotify_001, TestSize.Level0)
2450 {
2451     TAG_LOGI(AAFwkTag::TEST, "UnregisterNativeChildExitNotify_001 start");
2452     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2453     EXPECT_NE(appMgrServiceInner, nullptr);
2454 
2455     sptr<INativeChildNotify> notify;
2456     auto ret = appMgrServiceInner->UnregisterNativeChildExitNotify(notify);
2457     EXPECT_NE(ret, ERR_OK);
2458 
2459     TAG_LOGI(AAFwkTag::TEST, "UnregisterNativeChildExitNotify_001 end");
2460 }
2461 
2462 /**
2463  * @tc.name: GetForegroundApplications_001
2464  * @tc.desc: get foreground applications.
2465  * @tc.type: FUNC
2466  * @tc.require: issueI5W4S7
2467  */
2468 HWTEST_F(AppMgrServiceInnerTest, GetForegroundApplications_001, TestSize.Level2)
2469 {
2470     TAG_LOGI(AAFwkTag::TEST, "GetForegroundApplications_001 start");
2471     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2472     EXPECT_NE(appMgrServiceInner, nullptr);
2473 
2474     std::vector<AppStateData> list;
2475     appMgrServiceInner->GetForegroundApplications(list);
2476 
2477     TAG_LOGI(AAFwkTag::TEST, "GetForegroundApplications_001 end");
2478 }
2479 
2480 /**
2481  * @tc.name: StartUserTestProcess_001
2482  * @tc.desc: start user test process.
2483  * @tc.type: FUNC
2484  * @tc.require: issueI5W4S7
2485  */
2486 HWTEST_F(AppMgrServiceInnerTest, StartUserTestProcess_001, TestSize.Level2)
2487 {
2488     TAG_LOGI(AAFwkTag::TEST, "StartUserTestProcess_001 start");
2489     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2490     EXPECT_NE(appMgrServiceInner, nullptr);
2491 
2492     AAFwk::Want want;
2493     sptr<IRemoteObject> observer;
2494     BundleInfo bundleInfo;
2495     appMgrServiceInner->StartUserTestProcess(want, nullptr, bundleInfo, 0);
2496 
2497     appMgrServiceInner->StartUserTestProcess(want, observer, bundleInfo, 0);
2498 
2499     std::string bundle_name = "test_bundle_name";
2500     want.SetParam("-b", bundle_name);
2501     appMgrServiceInner->StartUserTestProcess(want, observer, bundleInfo, 0);
2502 
2503     std::string moduleName = "test_module_name";
2504     want.SetParam("-m", moduleName);
2505     HapModuleInfo hapModuleInfo;
2506     hapModuleInfo.moduleName = moduleName;
2507     bundleInfo.hapModuleInfos.push_back(hapModuleInfo);
2508     appMgrServiceInner->StartUserTestProcess(want, observer, bundleInfo, 0);
2509 
2510     appMgrServiceInner->remoteClientManager_ = nullptr;
2511     appMgrServiceInner->StartUserTestProcess(want, observer, bundleInfo, 0);
2512 
2513     appMgrServiceInner->appRunningManager_ = nullptr;
2514     appMgrServiceInner->StartUserTestProcess(want, observer, bundleInfo, 0);
2515 
2516     TAG_LOGI(AAFwkTag::TEST, "StartUserTestProcess_001 end");
2517 }
2518 
2519 /**
2520  * @tc.name: GetHapModuleInfoForTestRunner_001
2521  * @tc.desc: get hap module info for test runner.
2522  * @tc.type: FUNC
2523  * @tc.require: issueI5W4S7
2524  */
2525 HWTEST_F(AppMgrServiceInnerTest, GetHapModuleInfoForTestRunner_001, TestSize.Level2)
2526 {
2527     TAG_LOGI(AAFwkTag::TEST, "GetHapModuleInfoForTestRunner_001 start");
2528     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2529     EXPECT_NE(appMgrServiceInner, nullptr);
2530 
2531     AAFwk::Want want;
2532     sptr<IRemoteObject> observer;
2533     BundleInfo bundleInfo;
2534     HapModuleInfo hapModuleInfo;
2535     appMgrServiceInner->GetHapModuleInfoForTestRunner(want, nullptr, bundleInfo, hapModuleInfo);
2536 
2537     appMgrServiceInner->GetHapModuleInfoForTestRunner(want, observer, bundleInfo, hapModuleInfo);
2538 
2539     hapModuleInfo.moduleName = "test_module_name";
2540     bundleInfo.hapModuleInfos.push_back(hapModuleInfo);
2541     appMgrServiceInner->GetHapModuleInfoForTestRunner(want, observer, bundleInfo, hapModuleInfo);
2542 
2543     bundleInfo.hapModuleInfos.back().isModuleJson = true;
2544     appMgrServiceInner->GetHapModuleInfoForTestRunner(want, observer, bundleInfo, hapModuleInfo);
2545 
2546     std::string testmoduleName = "test_XXX";
2547     want.SetParam("-m", testmoduleName);
2548     appMgrServiceInner->GetHapModuleInfoForTestRunner(want, observer, bundleInfo, hapModuleInfo);
2549 
2550     std::string moduleName = "test_module_name";
2551     want.SetParam("-m", moduleName);
2552     appMgrServiceInner->GetHapModuleInfoForTestRunner(want, observer, bundleInfo, hapModuleInfo);
2553 
2554     TAG_LOGI(AAFwkTag::TEST, "GetHapModuleInfoForTestRunner_001 end");
2555 }
2556 
2557 /**
2558  * @tc.name: UserTestAbnormalFinish_001
2559  * @tc.desc: user test abnormal finish.
2560  * @tc.type: FUNC
2561  * @tc.require: issueI5W4S7
2562  */
2563 HWTEST_F(AppMgrServiceInnerTest, UserTestAbnormalFinish_001, TestSize.Level2)
2564 {
2565     TAG_LOGI(AAFwkTag::TEST, "UserTestAbnormalFinish_001 start");
2566     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2567     EXPECT_NE(appMgrServiceInner, nullptr);
2568 
2569     sptr<IRemoteObject> observer;
2570     std::string msg = "testmsg";
2571     appMgrServiceInner->UserTestAbnormalFinish(nullptr, "");
2572     appMgrServiceInner->UserTestAbnormalFinish(nullptr, msg);
2573     appMgrServiceInner->UserTestAbnormalFinish(observer, "");
2574     appMgrServiceInner->UserTestAbnormalFinish(observer, msg);
2575 
2576     TAG_LOGI(AAFwkTag::TEST, "UserTestAbnormalFinish_001 end");
2577 }
2578 
2579 /**
2580  * @tc.name: StartEmptyProcess_001
2581  * @tc.desc: start empty process.
2582  * @tc.type: FUNC
2583  * @tc.require: issueI5W4S7
2584  */
2585 HWTEST_F(AppMgrServiceInnerTest, StartEmptyProcess_001, TestSize.Level2)
2586 {
2587     TAG_LOGI(AAFwkTag::TEST, "StartEmptyProcess_001 start");
2588     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2589     EXPECT_NE(appMgrServiceInner, nullptr);
2590 
2591     AAFwk::Want want;
2592     sptr<IRemoteObject> observer;
2593     BundleInfo info;
2594     HapModuleInfo hapModuleInfo;
2595     std::string processName = "test_processName";
2596     appMgrServiceInner->StartEmptyProcess(want, nullptr, info, "", 0);
2597     appMgrServiceInner->StartEmptyProcess(want, observer, info, "", 0);
2598     appMgrServiceInner->StartEmptyProcess(want, observer, info, processName, 0);
2599 
2600     info.applicationInfo = *applicationInfo_;
2601     appMgrServiceInner->StartEmptyProcess(want, observer, info, processName, 0);
2602 
2603     want.SetParam("coldStart", true);
2604     appMgrServiceInner->StartEmptyProcess(want, observer, info, processName, 0);
2605 
2606     appMgrServiceInner->remoteClientManager_ = nullptr;
2607     appMgrServiceInner->StartEmptyProcess(want, observer, info, processName, 0);
2608 
2609     appMgrServiceInner->appRunningManager_ = nullptr;
2610     appMgrServiceInner->StartEmptyProcess(want, observer, info, processName, 0);
2611 
2612     TAG_LOGI(AAFwkTag::TEST, "StartEmptyProcess_001 end");
2613 }
2614 
2615 /**
2616  * @tc.name: FinishUserTest_001
2617  * @tc.desc: finish user test.
2618  * @tc.type: FUNC
2619  * @tc.require: issueI5W4S7
2620  */
2621 HWTEST_F(AppMgrServiceInnerTest, FinishUserTest_001, TestSize.Level2)
2622 {
2623     TAG_LOGI(AAFwkTag::TEST, "FinishUserTest_001 start");
2624     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2625     EXPECT_NE(appMgrServiceInner, nullptr);
2626 
2627     pid_t pid = 0;
2628     appMgrServiceInner->FinishUserTest("", 0, "", pid);
2629 
2630     std::string msg = "testmsg";
2631     std::string bundleName = "test_bundle_name";
2632     appMgrServiceInner->FinishUserTest("", 0, bundleName, pid);
2633     appMgrServiceInner->FinishUserTest(msg, 0, "", pid);
2634     appMgrServiceInner->FinishUserTest(msg, 0, bundleName, pid);
2635 
2636     BundleInfo bundleInfo;
2637     HapModuleInfo hapModuleInfo;
2638     std::shared_ptr<AAFwk::Want> want;
2639     std::string processName = "test_processName";
2640     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
2641     loadParam->token = new MockAbilityToken();
2642     std::shared_ptr<AppRunningRecord> appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
2643         applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
2644     EXPECT_NE(appRecord, nullptr);
2645     pid = appRecord->GetPriorityObject()->GetPid();
2646     appMgrServiceInner->FinishUserTest(msg, 0, bundleName, pid);
2647 
2648     std::shared_ptr<UserTestRecord> record = std::make_shared<UserTestRecord>();
2649     appRecord->SetUserTestInfo(record);
2650     appMgrServiceInner->FinishUserTest(msg, 0, bundleName, pid);
2651 
2652     appMgrServiceInner->appRunningManager_ = nullptr;
2653     appMgrServiceInner->FinishUserTest(msg, 0, bundleName, pid);
2654 
2655     TAG_LOGI(AAFwkTag::TEST, "FinishUserTest_001 end");
2656 }
2657 
2658 /**
2659  * @tc.name: FinishUserTestLocked_001
2660  * @tc.desc: finish user test locked.
2661  * @tc.type: FUNC
2662  * @tc.require: issueI5W4S7
2663  */
2664 HWTEST_F(AppMgrServiceInnerTest, FinishUserTestLocked_001, TestSize.Level2)
2665 {
2666     TAG_LOGI(AAFwkTag::TEST, "FinishUserTestLocked_001 start");
2667     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2668     EXPECT_NE(appMgrServiceInner, nullptr);
2669 
2670     appMgrServiceInner->FinishUserTestLocked("", 0, nullptr);
2671 
2672     std::shared_ptr<AppRunningRecord> appRecord;
2673     appMgrServiceInner->FinishUserTestLocked("", 0, appRecord);
2674 
2675     std::string msg = "testmsg";
2676     appMgrServiceInner->FinishUserTestLocked(msg, 0, nullptr);
2677     appMgrServiceInner->FinishUserTestLocked(msg, 0, appRecord);
2678 
2679     BundleInfo bundleInfo;
2680     std::string processName = "test_processName";
2681     appRecord =
2682         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2683     EXPECT_NE(appRecord, nullptr);
2684     std::shared_ptr<UserTestRecord> record = std::make_shared<UserTestRecord>();
2685     appRecord->SetUserTestInfo(record);
2686     appMgrServiceInner->FinishUserTestLocked(msg, 0, appRecord);
2687 
2688     record->isFinished = true;
2689     appRecord->SetUserTestInfo(record);
2690     appMgrServiceInner->FinishUserTestLocked(msg, 0, appRecord);
2691 
2692     record->observer = nullptr;
2693     appRecord->SetUserTestInfo(record);
2694     appMgrServiceInner->FinishUserTestLocked(msg, 0, appRecord);
2695 
2696     TAG_LOGI(AAFwkTag::TEST, "FinishUserTestLocked_001 end");
2697 }
2698 
2699 /**
2700  * @tc.name: StartSpecifiedAbility_001
2701  * @tc.desc: start specified ability.
2702  * @tc.type: FUNC
2703  * @tc.require: issueI5W4S7
2704  */
2705 HWTEST_F(AppMgrServiceInnerTest, StartSpecifiedAbility_001, TestSize.Level2)
2706 {
2707     TAG_LOGI(AAFwkTag::TEST, "StartSpecifiedAbility_001 start");
2708     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2709     EXPECT_NE(appMgrServiceInner, nullptr);
2710 
2711     AAFwk::Want want;
2712     AbilityInfo abilityInfo;
2713     appMgrServiceInner->StartSpecifiedAbility(want, abilityInfo);
2714 
2715     appMgrServiceInner->StartSpecifiedAbility(want, *abilityInfo_);
2716 
2717     abilityInfo_->applicationInfo = *applicationInfo_;
2718     appMgrServiceInner->StartSpecifiedAbility(want, *abilityInfo_);
2719 
2720     appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(nullptr);
2721     appMgrServiceInner->StartSpecifiedAbility(want, *abilityInfo_);
2722 
2723     appMgrServiceInner->remoteClientManager_ = nullptr;
2724     appMgrServiceInner->StartSpecifiedAbility(want, *abilityInfo_);
2725 
2726     TAG_LOGI(AAFwkTag::TEST, "StartSpecifiedAbility_001 end");
2727 }
2728 
2729 /**
2730  * @tc.name: RegisterStartSpecifiedAbilityResponse_001
2731  * @tc.desc: register start specified ability response.
2732  * @tc.type: FUNC
2733  * @tc.require: issueI5W4S7
2734  */
2735 HWTEST_F(AppMgrServiceInnerTest, RegisterStartSpecifiedAbilityResponse_001, TestSize.Level2)
2736 {
2737     TAG_LOGI(AAFwkTag::TEST, "RegisterStartSpecifiedAbilityResponse_001 start");
2738     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2739     EXPECT_NE(appMgrServiceInner, nullptr);
2740 
2741     appMgrServiceInner->RegisterStartSpecifiedAbilityResponse(nullptr);
2742 
2743     sptr<IStartSpecifiedAbilityResponse> response;
2744     appMgrServiceInner->RegisterStartSpecifiedAbilityResponse(response);
2745 
2746     TAG_LOGI(AAFwkTag::TEST, "RegisterStartSpecifiedAbilityResponse_001 end");
2747 }
2748 
2749 /**
2750  * @tc.name: ScheduleAcceptWantDone_001
2751  * @tc.desc: schedule accept want done.
2752  * @tc.type: FUNC
2753  * @tc.require: issueI5W4S7
2754  */
2755 HWTEST_F(AppMgrServiceInnerTest, ScheduleAcceptWantDone_001, TestSize.Level2)
2756 {
2757     TAG_LOGI(AAFwkTag::TEST, "ScheduleAcceptWantDone_001 start");
2758     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2759     EXPECT_NE(appMgrServiceInner, nullptr);
2760 
2761     AAFwk::Want want;
2762     std::string flag = "test_flag";
2763     appMgrServiceInner->ScheduleAcceptWantDone(0, want, flag);
2764 
2765     BundleInfo bundleInfo;
2766     std::string processName = "test_processName";
2767     std::shared_ptr<AppRunningRecord> appRecord =
2768         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2769     appMgrServiceInner->ScheduleAcceptWantDone(appRecord->GetRecordId(), want, flag);
2770 
2771     sptr<IStartSpecifiedAbilityResponse> response;
2772     appMgrServiceInner->RegisterStartSpecifiedAbilityResponse(response);
2773     appMgrServiceInner->ScheduleAcceptWantDone(appRecord->GetRecordId(), want, flag);
2774 
2775     appRecord->SetSpecifiedAbilityFlagAndWant(0, AAFwk::Want(), "");
2776     appMgrServiceInner->ScheduleAcceptWantDone(appRecord->GetRecordId(), want, flag);
2777     EXPECT_FALSE(appRecord->IsStartSpecifiedAbility());
2778 
2779     TAG_LOGI(AAFwkTag::TEST, "ScheduleAcceptWantDone_001 end");
2780 }
2781 
2782 /**
2783  * @tc.name: HandleStartSpecifiedAbilityTimeOut_001
2784  * @tc.desc: handle start specified ability time out.
2785  * @tc.type: FUNC
2786  * @tc.require: issueI5W4S7
2787  */
2788 HWTEST_F(AppMgrServiceInnerTest, HandleStartSpecifiedAbilityTimeOut_001, TestSize.Level2)
2789 {
2790     TAG_LOGI(AAFwkTag::TEST, "HandleStartSpecifiedAbilityTimeOut_001 start");
2791     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2792     EXPECT_NE(appMgrServiceInner, nullptr);
2793 
2794     appMgrServiceInner->HandleStartSpecifiedAbilityTimeOut(nullptr);
2795 
2796     BundleInfo bundleInfo;
2797     std::string appName = "test_appName";
2798     std::string processName = "test_processName";
2799     std::string bundleName = "test_bundleName";
2800     sptr<IRemoteObject> token = new MockAbilityToken();
2801     std::shared_ptr<AppRunningRecord> appRecord =
2802         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2803     EXPECT_NE(appRecord, nullptr);
2804 
2805     appRecord->specifiedAbilityRequest_ = std::make_shared<SpecifiedRequest>();
2806     appRecord->specifiedAbilityRequest_->requestId = 1;
2807     appMgrServiceInner->HandleStartSpecifiedAbilityTimeOut(appRecord);
2808 
2809     sptr<IStartSpecifiedAbilityResponse> response;
2810     appMgrServiceInner->startSpecifiedAbilityResponse_ = response;
2811     appMgrServiceInner->HandleStartSpecifiedAbilityTimeOut(appRecord);
2812 
2813     appRecord->specifiedAbilityRequest_ = nullptr;
2814     appMgrServiceInner->HandleStartSpecifiedAbilityTimeOut(appRecord);
2815 
2816     TAG_LOGI(AAFwkTag::TEST, "HandleStartSpecifiedAbilityTimeOut_001 end");
2817 }
2818 
2819 /**
2820  * @tc.name: UpdateConfiguration_001
2821  * @tc.desc: update configuration.
2822  * @tc.type: FUNC
2823  * @tc.require: issueI5W4S7
2824  */
2825 HWTEST_F(AppMgrServiceInnerTest, UpdateConfiguration_001, TestSize.Level2)
2826 {
2827     TAG_LOGI(AAFwkTag::TEST, "UpdateConfiguration_001 start");
2828     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2829     EXPECT_NE(appMgrServiceInner, nullptr);
2830 
2831     Configuration config;
2832     appMgrServiceInner->UpdateConfiguration(config);
2833 
2834     auto testLanguge = "ch-zh";
2835     config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, testLanguge);
2836     appMgrServiceInner->UpdateConfiguration(config);
2837 
2838     auto appRunningRecordMap = appMgrServiceInner->appRunningManager_->appRunningRecordMap_;
2839     for (const auto& item : appRunningRecordMap) {
2840         const auto& appRecord = item.second;
2841         if (appRecord) {
2842             appRecord->appLifeCycleDeal_ = nullptr;
2843         }
2844     }
2845     appMgrServiceInner->UpdateConfiguration(config);
2846 
2847     sptr<MockConfigurationObserver> observer(new (std::nothrow) MockConfigurationObserver());
2848     appMgrServiceInner->configurationObservers_.push_back({ observer, 100 });
2849     sptr<IConfigurationObserver> observer1;
2850     appMgrServiceInner->configurationObservers_.push_back({ observer1, 100 });
2851     appMgrServiceInner->configurationObservers_.push_back({ nullptr, 100 });
2852     appMgrServiceInner->UpdateConfiguration(config);
2853 
2854     appMgrServiceInner->appRunningManager_ = nullptr;
2855     appMgrServiceInner->UpdateConfiguration(config);
2856 
2857     TAG_LOGI(AAFwkTag::TEST, "UpdateConfiguration_001 end");
2858 }
2859 
2860 /**
2861  * @tc.name: RegisterConfigurationObserver_001
2862  * @tc.desc: register configuration observer.
2863  * @tc.type: FUNC
2864  * @tc.require: issueI5W4S7
2865  */
2866 HWTEST_F(AppMgrServiceInnerTest, RegisterConfigurationObserver_001, TestSize.Level2)
2867 {
2868     TAG_LOGI(AAFwkTag::TEST, "RegisterConfigurationObserver_001 start");
2869     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2870     EXPECT_NE(appMgrServiceInner, nullptr);
2871 
2872     appMgrServiceInner->configurationObservers_.clear();
2873 
2874     appMgrServiceInner->RegisterConfigurationObserver(nullptr);
2875 
2876     sptr<MockConfigurationObserver> observer(new (std::nothrow) MockConfigurationObserver());
2877     appMgrServiceInner->RegisterConfigurationObserver(observer);
2878     appMgrServiceInner->RegisterConfigurationObserver(observer);
2879 
2880     TAG_LOGI(AAFwkTag::TEST, "RegisterConfigurationObserver_001 end");
2881 }
2882 
2883 /**
2884  * @tc.name: UnregisterConfigurationObserver_001
2885  * @tc.desc: unregister configuration observer.
2886  * @tc.type: FUNC
2887  * @tc.require: issueI5W4S7
2888  */
2889 HWTEST_F(AppMgrServiceInnerTest, UnregisterConfigurationObserver_001, TestSize.Level2)
2890 {
2891     TAG_LOGI(AAFwkTag::TEST, "UnregisterConfigurationObserver_001 start");
2892     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2893     EXPECT_NE(appMgrServiceInner, nullptr);
2894 
2895     appMgrServiceInner->configurationObservers_.clear();
2896 
2897     appMgrServiceInner->UnregisterConfigurationObserver(nullptr);
2898 
2899     sptr<MockConfigurationObserver> observer(new (std::nothrow) MockConfigurationObserver());
2900     appMgrServiceInner->UnregisterConfigurationObserver(observer);
2901 
2902     appMgrServiceInner->RegisterConfigurationObserver(observer);
2903     appMgrServiceInner->UnregisterConfigurationObserver(observer);
2904 
2905     TAG_LOGI(AAFwkTag::TEST, "UnregisterConfigurationObserver_001 end");
2906 }
2907 
2908 /**
2909  * @tc.name: InitGlobalConfiguration_001
2910  * @tc.desc: init global configuration.
2911  * @tc.type: FUNC
2912  * @tc.require: issueI5W4S7
2913  */
2914 HWTEST_F(AppMgrServiceInnerTest, InitGlobalConfiguration_001, TestSize.Level2)
2915 {
2916     TAG_LOGI(AAFwkTag::TEST, "InitGlobalConfiguration_001 start");
2917     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2918     EXPECT_NE(appMgrServiceInner, nullptr);
2919 
2920     appMgrServiceInner->InitGlobalConfiguration();
2921 
2922     appMgrServiceInner->InitGlobalConfiguration();
2923 
2924     TAG_LOGI(AAFwkTag::TEST, "InitGlobalConfiguration_001 end");
2925 }
2926 
2927 /**
2928  * @tc.name: KillApplicationByRecord_001
2929  * @tc.desc: kill application by record.
2930  * @tc.type: FUNC
2931  * @tc.require: issueI5W4S7
2932  */
2933 HWTEST_F(AppMgrServiceInnerTest, KillApplicationByRecord_001, TestSize.Level2)
2934 {
2935     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByRecord_001 start");
2936     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2937     EXPECT_NE(appMgrServiceInner, nullptr);
2938 
2939     std::shared_ptr<AppRunningRecord> appRecord = nullptr;
2940     BundleInfo bundleInfo;
2941     std::string processName = "test_processName";
2942     std::shared_ptr<AppRunningRecord> appRecord1 =
2943         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2944     EXPECT_NE(appRecord1, nullptr);
2945     appMgrServiceInner->KillApplicationByRecord(appRecord);
2946     appMgrServiceInner->KillApplicationByRecord(appRecord1);
2947 
2948     appMgrServiceInner->taskHandler_ = nullptr;
2949     appMgrServiceInner->KillApplicationByRecord(appRecord);
2950     appMgrServiceInner->KillApplicationByRecord(appRecord1);
2951 
2952     TAG_LOGI(AAFwkTag::TEST, "KillApplicationByRecord_001 end");
2953 }
2954 
2955 /**
2956  * @tc.name: SendHiSysEvent_001
2957  * @tc.desc: send hi sys event.
2958  * @tc.type: FUNC
2959  * @tc.require: issueI5W4S7
2960  */
2961 HWTEST_F(AppMgrServiceInnerTest, SendHiSysEvent_001, TestSize.Level2)
2962 {
2963     TAG_LOGI(AAFwkTag::TEST, "SendHiSysEvent_001 start");
2964     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2965     EXPECT_NE(appMgrServiceInner, nullptr);
2966 
2967     appMgrServiceInner->SendHiSysEvent(0, nullptr);
2968 
2969     BundleInfo bundleInfo;
2970     std::string processName = "test_processName";
2971     std::shared_ptr<AppRunningRecord> appRecord =
2972         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
2973     EXPECT_NE(appRecord, nullptr);
2974     appMgrServiceInner->SendHiSysEvent(0, appRecord);
2975     appMgrServiceInner->SendHiSysEvent(1, appRecord);
2976     appMgrServiceInner->SendHiSysEvent(2, appRecord);
2977     appMgrServiceInner->SendHiSysEvent(3, appRecord);
2978     appMgrServiceInner->SendHiSysEvent(4, appRecord);
2979 
2980     TAG_LOGI(AAFwkTag::TEST, "SendHiSysEvent_001 end");
2981 }
2982 
2983 /**
2984  * @tc.name: GetAbilityRecordsByProcessID_001
2985  * @tc.desc: get ability records by process id.
2986  * @tc.type: FUNC
2987  * @tc.require: issueI5W4S7
2988  */
2989 HWTEST_F(AppMgrServiceInnerTest, GetAbilityRecordsByProcessID_001, TestSize.Level2)
2990 {
2991     TAG_LOGI(AAFwkTag::TEST, "GetAbilityRecordsByProcessID_001 start");
2992     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
2993     EXPECT_NE(appMgrServiceInner, nullptr);
2994 
2995     std::vector<sptr<IRemoteObject>> tokens;
2996     appMgrServiceInner->GetAbilityRecordsByProcessID(0, tokens);
2997 
2998     BundleInfo bundleInfo;
2999     std::string processName = "test_processName";
3000     std::shared_ptr<AppRunningRecord> appRecord =
3001         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
3002     EXPECT_NE(appRecord, nullptr);
3003     int pid = appRecord->GetPriorityObject()->GetPid();
3004     appMgrServiceInner->GetAbilityRecordsByProcessID(pid, tokens);
3005 
3006     TAG_LOGI(AAFwkTag::TEST, "GetAbilityRecordsByProcessID_001 end");
3007 }
3008 
3009 /**
3010  * @tc.name: GetApplicationInfoByProcessID_001
3011  * @tc.desc: get applicationInfo by process id.
3012  * @tc.type: FUNC
3013  * @tc.require: issueI5W4S7
3014  */
3015 HWTEST_F(AppMgrServiceInnerTest, GetApplicationInfoByProcessID_001, TestSize.Level2)
3016 {
3017     TAG_LOGI(AAFwkTag::TEST, "GetApplicationInfoByProcessID_001 start");
3018     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3019     EXPECT_NE(appMgrServiceInner, nullptr);
3020 
3021     ApplicationInfo application;
3022     bool debug = false;
3023     appMgrServiceInner->GetApplicationInfoByProcessID(0, application, debug);
3024 
3025     BundleInfo bundleInfo;
3026     std::string processName = "test_processName";
3027     std::shared_ptr<AppRunningRecord> appRecord =
3028         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
3029     EXPECT_NE(appRecord, nullptr);
3030     int pid = appRecord->GetPriorityObject()->GetPid();
3031     appMgrServiceInner->GetApplicationInfoByProcessID(pid, application, debug);
3032 
3033     appRecord->appInfo_ = nullptr;
3034     appMgrServiceInner->GetApplicationInfoByProcessID(pid, application, debug);
3035 
3036     TAG_LOGI(AAFwkTag::TEST, "GetApplicationInfoByProcessID_001 end");
3037 }
3038 
3039 /**
3040  * @tc.name: NotifyAppMgrRecordExitReason_001
3041  * @tc.desc: NotifyAppMgrRecordExitReason.
3042  * @tc.type: FUNC
3043  * @tc.require: issueI5W4S7
3044  */
3045 HWTEST_F(AppMgrServiceInnerTest, NotifyAppMgrRecordExitReason_001, TestSize.Level2)
3046 {
3047     TAG_LOGI(AAFwkTag::TEST, "NotifyAppMgrRecordExitReason_001 start");
3048     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3049     EXPECT_NE(appMgrServiceInner, nullptr);
3050 
3051     int32_t reason = 0;
3052     int32_t pid = 1;
3053     std::string exitMsg = "JsError";
3054     auto ret = appMgrServiceInner->NotifyAppMgrRecordExitReason(reason, pid, exitMsg);
3055     EXPECT_NE(ret, ERR_OK);
3056     TAG_LOGI(AAFwkTag::TEST, "NotifyAppMgrRecordExitReason_001 end");
3057 }
3058 
3059 /**
3060  * @tc.name: VerifyKillProcessPermission_001
3061  * @tc.desc: verify process permission.
3062  * @tc.type: FUNC
3063  * @tc.require: issueI5W4S7
3064  */
3065 HWTEST_F(AppMgrServiceInnerTest, VerifyKillProcessPermission_001, TestSize.Level2)
3066 {
3067     TAG_LOGI(AAFwkTag::TEST, "VerifyKillProcessPermission_001 start");
3068     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3069     EXPECT_NE(appMgrServiceInner, nullptr);
3070 
3071     appMgrServiceInner->VerifyKillProcessPermission("");
3072 
3073     appMgrServiceInner->appRunningManager_ = nullptr;
3074     appMgrServiceInner->VerifyKillProcessPermission("");
3075 
3076     TAG_LOGI(AAFwkTag::TEST, "VerifyKillProcessPermission_001 end");
3077 }
3078 
3079 /**
3080  * @tc.name: VerifyAPL_001
3081  * @tc.desc: verify APL.
3082  * @tc.type: FUNC
3083  * @tc.require: issueI5W4S7
3084  */
3085 HWTEST_F(AppMgrServiceInnerTest, VerifyAPL_001, TestSize.Level2)
3086 {
3087     TAG_LOGI(AAFwkTag::TEST, "VerifyAPL_001 start");
3088     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3089     EXPECT_NE(appMgrServiceInner, nullptr);
3090 
3091     appMgrServiceInner->VerifyAPL();
3092 
3093     appMgrServiceInner->appRunningManager_ = nullptr;
3094     appMgrServiceInner->VerifyAPL();
3095 
3096     TAG_LOGI(AAFwkTag::TEST, "VerifyAPL_001 end");
3097 }
3098 
3099 /**
3100  * @tc.name: VerifyAccountPermission_001
3101  * @tc.desc: verify account permission.
3102  * @tc.type: FUNC
3103  * @tc.require: issueI5W4S7
3104  */
3105 HWTEST_F(AppMgrServiceInnerTest, VerifyAccountPermission_001, TestSize.Level2)
3106 {
3107     TAG_LOGI(AAFwkTag::TEST, "VerifyAccountPermission_001 start");
3108     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3109     EXPECT_NE(appMgrServiceInner, nullptr);
3110 
3111     std::string permissionName = "test_permissionName";
3112     appMgrServiceInner->VerifyAccountPermission(permissionName, 0);
3113 
3114     TAG_LOGI(AAFwkTag::TEST, "VerifyAccountPermission_001 end");
3115 }
3116 
3117 /**
3118  * @tc.name: PreStartNWebSpawnProcess_003
3119  * @tc.desc: prestart nwebspawn process.
3120  * @tc.type: FUNC
3121  * @tc.require: issueI5W4S7
3122  */
3123 HWTEST_F(AppMgrServiceInnerTest, PreStartNWebSpawnProcess_003, TestSize.Level2)
3124 {
3125     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3126     EXPECT_NE(appMgrServiceInner, nullptr);
3127 
3128     int callingPid = 1;
3129     appMgrServiceInner->remoteClientManager_->nwebSpawnClient_ = nullptr;
3130     int ret = appMgrServiceInner->PreStartNWebSpawnProcess(callingPid);
3131     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3132 }
3133 
3134 /**
3135  * @tc.name: StartRenderProcess_001
3136  * @tc.desc: start render process.
3137  * @tc.type: FUNC
3138  * @tc.require: issueI5W4S7
3139  */
3140 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_001, TestSize.Level2)
3141 {
3142     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_001 start");
3143     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3144     EXPECT_NE(appMgrServiceInner, nullptr);
3145 
3146     pid_t hostPid = 0;
3147     std::string renderParam = "";
3148     pid_t renderPid = 0;
3149     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, FdGuard(-1), FdGuard(-1), FdGuard(-1),
3150         renderPid);
3151     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3152     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_001 end");
3153 }
3154 
3155 /**
3156  * @tc.name: StartRenderProcess_003
3157  * @tc.desc: start render process.
3158  * @tc.type: FUNC
3159  * @tc.require: issueI5W4S7
3160  */
3161 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_003, TestSize.Level2)
3162 {
3163     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_003 start");
3164     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3165     EXPECT_NE(appMgrServiceInner, nullptr);
3166 
3167     pid_t hostPid = 0;
3168     std::string renderParam = "";
3169     FdGuard ipcFd(0);
3170     FdGuard sharedFd(0);
3171     FdGuard crashFd(1);
3172     pid_t renderPid = 0;
3173     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3174         std::move(crashFd), renderPid);
3175     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3176     ipcFd.Release();
3177     sharedFd.Release();
3178     crashFd.Release();
3179     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_003 end");
3180 }
3181 
3182 /**
3183  * @tc.name: StartRenderProcess_004
3184  * @tc.desc: start render process.
3185  * @tc.type: FUNC
3186  * @tc.require: issueI5W4S7
3187  */
3188 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_004, TestSize.Level2)
3189 {
3190     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_004 start");
3191     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3192     EXPECT_NE(appMgrServiceInner, nullptr);
3193 
3194     pid_t hostPid = 0;
3195     std::string renderParam = "";
3196     FdGuard ipcFd(0);
3197     FdGuard sharedFd(1);
3198     FdGuard crashFd(0);
3199     pid_t renderPid = 0;
3200     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3201         std::move(crashFd), renderPid);
3202     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3203     ipcFd.Release();
3204     sharedFd.Release();
3205     crashFd.Release();
3206     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_004 end");
3207 }
3208 
3209 /**
3210  * @tc.name: StartRenderProcess_005
3211  * @tc.desc: start render process.
3212  * @tc.type: FUNC
3213  * @tc.require: issueI5W4S7
3214  */
3215 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_005, TestSize.Level2)
3216 {
3217     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_005 start");
3218     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3219     EXPECT_NE(appMgrServiceInner, nullptr);
3220 
3221     pid_t hostPid = 0;
3222     std::string renderParam = "";
3223     FdGuard ipcFd(0);
3224     FdGuard sharedFd(1);
3225     FdGuard crashFd(1);
3226     pid_t renderPid = 0;
3227     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3228         std::move(crashFd), renderPid);
3229     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3230     ipcFd.Release();
3231     sharedFd.Release();
3232     crashFd.Release();
3233     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_005 end");
3234 }
3235 
3236 /**
3237  * @tc.name: StartRenderProcess_006
3238  * @tc.desc: start render process.
3239  * @tc.type: FUNC
3240  * @tc.require: issueI5W4S7
3241  */
3242 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_006, TestSize.Level2)
3243 {
3244     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_006 start");
3245     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3246     EXPECT_NE(appMgrServiceInner, nullptr);
3247 
3248     pid_t hostPid = 0;
3249     std::string renderParam = "";
3250     FdGuard ipcFd(1);
3251     FdGuard sharedFd(0);
3252     FdGuard crashFd(0);
3253     pid_t renderPid = 0;
3254     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3255         std::move(crashFd), renderPid);
3256     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3257     ipcFd.Release();
3258     sharedFd.Release();
3259     crashFd.Release();
3260     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_006 end");
3261 }
3262 
3263 /**
3264  * @tc.name: StartRenderProcess_007
3265  * @tc.desc: start render process.
3266  * @tc.type: FUNC
3267  * @tc.require: issueI5W4S7
3268  */
3269 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_007, TestSize.Level2)
3270 {
3271     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_007 start");
3272     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3273     EXPECT_NE(appMgrServiceInner, nullptr);
3274 
3275     pid_t hostPid = 0;
3276     std::string renderParam = "";
3277     FdGuard ipcFd(1);
3278     FdGuard sharedFd(0);
3279     FdGuard crashFd(1);
3280     pid_t renderPid = 0;
3281     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3282         std::move(crashFd), renderPid);
3283     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3284     ipcFd.Release();
3285     sharedFd.Release();
3286     crashFd.Release();
3287     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_007 end");
3288 }
3289 
3290 /**
3291  * @tc.name: StartRenderProcess_008
3292  * @tc.desc: start render process.
3293  * @tc.type: FUNC
3294  * @tc.require: issueI5W4S7
3295  */
3296 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_008, TestSize.Level2)
3297 {
3298     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_008 start");
3299     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3300     EXPECT_NE(appMgrServiceInner, nullptr);
3301 
3302     pid_t hostPid = 0;
3303     std::string renderParam = "";
3304     FdGuard ipcFd(1);
3305     FdGuard sharedFd(1);
3306     FdGuard crashFd(0);
3307     pid_t renderPid = 0;
3308     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3309         std::move(crashFd), renderPid);
3310     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3311     ipcFd.Release();
3312     sharedFd.Release();
3313     crashFd.Release();
3314     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_008 end");
3315 }
3316 
3317 /**
3318  * @tc.name: StartRenderProcess_009
3319  * @tc.desc: start render process.
3320  * @tc.type: FUNC
3321  * @tc.require: issueI5W4S7
3322  */
3323 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_009, TestSize.Level2)
3324 {
3325     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_009 start");
3326     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3327     EXPECT_NE(appMgrServiceInner, nullptr);
3328 
3329     pid_t hostPid = 0;
3330     std::string renderParam = "";
3331     FdGuard ipcFd(1);
3332     FdGuard sharedFd(1);
3333     FdGuard crashFd(1);
3334     pid_t renderPid = 0;
3335     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3336         std::move(crashFd), renderPid);
3337     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3338     ipcFd.Release();
3339     sharedFd.Release();
3340     crashFd.Release();
3341     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_009 end");
3342 }
3343 
3344 /**
3345  * @tc.name: StartRenderProcess_010
3346  * @tc.desc: start render process.
3347  * @tc.type: FUNC
3348  * @tc.require: issueI5W4S7
3349  */
3350 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_010, TestSize.Level2)
3351 {
3352     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_010 start");
3353     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3354     EXPECT_NE(appMgrServiceInner, nullptr);
3355 
3356     pid_t hostPid = 0;
3357     std::string renderParam = "test_renderParam";
3358     FdGuard ipcFd(0);
3359     FdGuard sharedFd(0);
3360     FdGuard crashFd(0);
3361     pid_t renderPid = 0;
3362     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3363         std::move(crashFd), renderPid);
3364     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3365     ipcFd.Release();
3366     sharedFd.Release();
3367     crashFd.Release();
3368     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_010 end");
3369 }
3370 
3371 /**
3372  * @tc.name: StartRenderProcess_011
3373  * @tc.desc: start render process.
3374  * @tc.type: FUNC
3375  * @tc.require: issueI5W4S7
3376  */
3377 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_011, TestSize.Level2)
3378 {
3379     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_011 start");
3380     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3381     EXPECT_NE(appMgrServiceInner, nullptr);
3382 
3383     pid_t hostPid = 0;
3384     std::string renderParam = "test_renderParam";
3385     FdGuard ipcFd(0);
3386     FdGuard sharedFd(0);
3387     FdGuard crashFd(1);
3388     pid_t renderPid = 0;
3389     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3390         std::move(crashFd), renderPid);
3391     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3392     ipcFd.Release();
3393     sharedFd.Release();
3394     crashFd.Release();
3395     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_011 end");
3396 }
3397 
3398 /**
3399  * @tc.name: StartRenderProcess_012
3400  * @tc.desc: start render process.
3401  * @tc.type: FUNC
3402  * @tc.require: issueI5W4S7
3403  */
3404 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_012, TestSize.Level2)
3405 {
3406     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_012 start");
3407     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3408     EXPECT_NE(appMgrServiceInner, nullptr);
3409 
3410     pid_t hostPid = 0;
3411     std::string renderParam = "test_renderParam";
3412     FdGuard ipcFd(0);
3413     FdGuard sharedFd(1);
3414     FdGuard crashFd(0);
3415     pid_t renderPid = 0;
3416     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3417         std::move(crashFd), renderPid);
3418     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3419     ipcFd.Release();
3420     sharedFd.Release();
3421     crashFd.Release();
3422     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_012 end");
3423 }
3424 
3425 /**
3426  * @tc.name: StartRenderProcess_013
3427  * @tc.desc: start render process.
3428  * @tc.type: FUNC
3429  * @tc.require: issueI5W4S7
3430  */
3431 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_013, TestSize.Level2)
3432 {
3433     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_013 start");
3434     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3435     EXPECT_NE(appMgrServiceInner, nullptr);
3436 
3437     pid_t hostPid = 0;
3438     std::string renderParam = "test_renderParam";
3439     FdGuard ipcFd(0);
3440     FdGuard sharedFd(1);
3441     FdGuard crashFd(1);
3442     pid_t renderPid = 0;
3443     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3444         std::move(crashFd), renderPid);
3445     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3446     ipcFd.Release();
3447     sharedFd.Release();
3448     crashFd.Release();
3449     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_013 end");
3450 }
3451 
3452 /**
3453  * @tc.name: StartRenderProcess_014
3454  * @tc.desc: start render process.
3455  * @tc.type: FUNC
3456  * @tc.require: issueI5W4S7
3457  */
3458 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_014, TestSize.Level2)
3459 {
3460     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_014 start");
3461     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3462     EXPECT_NE(appMgrServiceInner, nullptr);
3463 
3464     pid_t hostPid = 0;
3465     std::string renderParam = "test_renderParam";
3466     FdGuard ipcFd(1);
3467     FdGuard sharedFd(0);
3468     FdGuard crashFd(0);
3469     pid_t renderPid = 0;
3470     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3471         std::move(crashFd), renderPid);
3472     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3473     ipcFd.Release();
3474     sharedFd.Release();
3475     crashFd.Release();
3476     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_014 end");
3477 }
3478 
3479 /**
3480  * @tc.name: StartRenderProcess_015
3481  * @tc.desc: start render process.
3482  * @tc.type: FUNC
3483  * @tc.require: issueI5W4S7
3484  */
3485 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_015, TestSize.Level2)
3486 {
3487     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_015 start");
3488     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3489     EXPECT_NE(appMgrServiceInner, nullptr);
3490 
3491     pid_t hostPid = 0;
3492     std::string renderParam = "test_renderParam";
3493     FdGuard ipcFd(1);
3494     FdGuard sharedFd(0);
3495     FdGuard crashFd(1);
3496     pid_t renderPid = 0;
3497     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3498         std::move(crashFd), renderPid);
3499     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3500     ipcFd.Release();
3501     sharedFd.Release();
3502     crashFd.Release();
3503     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_015 end");
3504 }
3505 
3506 /**
3507  * @tc.name: StartRenderProcess_016
3508  * @tc.desc: start render process.
3509  * @tc.type: FUNC
3510  * @tc.require: issueI5W4S7
3511  */
3512 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_016, TestSize.Level2)
3513 {
3514     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_016 start");
3515     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3516     EXPECT_NE(appMgrServiceInner, nullptr);
3517 
3518     pid_t hostPid = 0;
3519     std::string renderParam = "test_renderParam";
3520     FdGuard ipcFd(1);
3521     FdGuard sharedFd(1);
3522     FdGuard crashFd(0);
3523     pid_t renderPid = 0;
3524     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3525         std::move(crashFd), renderPid);
3526     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3527     ipcFd.Release();
3528     sharedFd.Release();
3529     crashFd.Release();
3530     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_016 end");
3531 }
3532 
3533 /**
3534  * @tc.name: StartRenderProcess_017
3535  * @tc.desc: start render process.
3536  * @tc.type: FUNC
3537  * @tc.require: issueI5W4S7
3538  */
3539 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_017, TestSize.Level2)
3540 {
3541     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_017 start");
3542     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3543     EXPECT_NE(appMgrServiceInner, nullptr);
3544 
3545     pid_t hostPid = 0;
3546     std::string renderParam = "test_renderParam";
3547     FdGuard ipcFd(1);
3548     FdGuard sharedFd(1);
3549     FdGuard crashFd(1);
3550     pid_t renderPid = 0;
3551     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3552         std::move(crashFd), renderPid);
3553     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3554     ipcFd.Release();
3555     sharedFd.Release();
3556     crashFd.Release();
3557     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_017 end");
3558 }
3559 
3560 /**
3561  * @tc.name: StartRenderProcess_018
3562  * @tc.desc: start render process.
3563  * @tc.type: FUNC
3564  * @tc.require: issueI5W4S7
3565  */
3566 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_018, TestSize.Level2)
3567 {
3568     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_018 start");
3569     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3570     EXPECT_NE(appMgrServiceInner, nullptr);
3571 
3572     pid_t hostPid = 1;
3573     std::string renderParam = "";
3574     FdGuard ipcFd(0);
3575     FdGuard sharedFd(0);
3576     FdGuard crashFd(0);
3577     pid_t renderPid = 0;
3578     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3579         std::move(crashFd), renderPid);
3580     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3581     ipcFd.Release();
3582     sharedFd.Release();
3583     crashFd.Release();
3584     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_018 end");
3585 }
3586 
3587 /**
3588  * @tc.name: StartRenderProcess_019
3589  * @tc.desc: start render process.
3590  * @tc.type: FUNC
3591  * @tc.require: issueI5W4S7
3592  */
3593 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_019, TestSize.Level2)
3594 {
3595     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_019 start");
3596     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3597     EXPECT_NE(appMgrServiceInner, nullptr);
3598 
3599     pid_t hostPid = 1;
3600     std::string renderParam = "";
3601     FdGuard ipcFd(0);
3602     FdGuard sharedFd(0);
3603     FdGuard crashFd(1);
3604     pid_t renderPid = 0;
3605     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3606         std::move(crashFd), renderPid);
3607     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3608     ipcFd.Release();
3609     sharedFd.Release();
3610     crashFd.Release();
3611     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_019 end");
3612 }
3613 
3614 /**
3615  * @tc.name: StartRenderProcess_020
3616  * @tc.desc: start render process.
3617  * @tc.type: FUNC
3618  * @tc.require: issueI5W4S7
3619  */
3620 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_020, TestSize.Level2)
3621 {
3622     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_020 start");
3623     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3624     EXPECT_NE(appMgrServiceInner, nullptr);
3625 
3626     pid_t hostPid = 1;
3627     std::string renderParam = "";
3628     FdGuard ipcFd(0);
3629     FdGuard sharedFd(1);
3630     FdGuard crashFd(0);
3631     pid_t renderPid = 0;
3632     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3633         std::move(crashFd), renderPid);
3634     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3635     ipcFd.Release();
3636     sharedFd.Release();
3637     crashFd.Release();
3638     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_020 end");
3639 }
3640 
3641 /**
3642  * @tc.name: StartRenderProcess_021
3643  * @tc.desc: start render process.
3644  * @tc.type: FUNC
3645  * @tc.require: issueI5W4S7
3646  */
3647 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_021, TestSize.Level2)
3648 {
3649     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_021 start");
3650     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3651     EXPECT_NE(appMgrServiceInner, nullptr);
3652 
3653     pid_t hostPid = 1;
3654     std::string renderParam = "";
3655     FdGuard ipcFd(0);
3656     FdGuard sharedFd(1);
3657     FdGuard crashFd(1);
3658     pid_t renderPid = 0;
3659     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3660         std::move(crashFd), renderPid);
3661     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3662     ipcFd.Release();
3663     sharedFd.Release();
3664     crashFd.Release();
3665     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_021 end");
3666 }
3667 
3668 /**
3669  * @tc.name: StartRenderProcess_002
3670  * @tc.desc: start render process.
3671  * @tc.type: FUNC
3672  * @tc.require: issueI5W4S7
3673  */
3674 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_002, TestSize.Level2)
3675 {
3676     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_002 start");
3677     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3678     EXPECT_NE(appMgrServiceInner, nullptr);
3679 
3680     pid_t hostPid = 1;
3681     std::string renderParam = "";
3682     FdGuard ipcFd(1);
3683     FdGuard sharedFd(0);
3684     FdGuard crashFd(0);
3685     pid_t renderPid = 0;
3686     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3687         std::move(crashFd), renderPid);
3688     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3689     ipcFd.Release();
3690     sharedFd.Release();
3691     crashFd.Release();
3692     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_002 end");
3693 }
3694 
3695 /**
3696  * @tc.name: StartRenderProcess_022
3697  * @tc.desc: start render process.
3698  * @tc.type: FUNC
3699  * @tc.require: issueI5W4S7
3700  */
3701 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_022, TestSize.Level2)
3702 {
3703     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_022 start");
3704     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3705     EXPECT_NE(appMgrServiceInner, nullptr);
3706 
3707     pid_t hostPid = 1;
3708     std::string renderParam = "";
3709     FdGuard ipcFd(1);
3710     FdGuard sharedFd(0);
3711     FdGuard crashFd(1);
3712     pid_t renderPid = 0;
3713     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3714         std::move(crashFd), renderPid);
3715     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3716     ipcFd.Release();
3717     sharedFd.Release();
3718     crashFd.Release();
3719     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_022 end");
3720 }
3721 
3722 /**
3723  * @tc.name: StartRenderProcess_032
3724  * @tc.desc: start render process.
3725  * @tc.type: FUNC
3726  * @tc.require: issueI5W4S7
3727  */
3728 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_032, TestSize.Level2)
3729 {
3730     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_032 start");
3731     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3732     EXPECT_NE(appMgrServiceInner, nullptr);
3733 
3734     pid_t hostPid = 1;
3735     std::string renderParam = "";
3736     FdGuard ipcFd(1);
3737     FdGuard sharedFd(1);
3738     FdGuard crashFd(0);
3739     pid_t renderPid = 0;
3740     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3741         std::move(crashFd), renderPid);
3742     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3743     ipcFd.Release();
3744     sharedFd.Release();
3745     crashFd.Release();
3746     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_032 end");
3747 }
3748 
3749 /**
3750  * @tc.name: StartRenderProcess_023
3751  * @tc.desc: start render process.
3752  * @tc.type: FUNC
3753  * @tc.require: issueI5W4S7
3754  */
3755 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_023, TestSize.Level2)
3756 {
3757     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_023 start");
3758     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3759     EXPECT_NE(appMgrServiceInner, nullptr);
3760 
3761     pid_t hostPid = 1;
3762     std::string renderParam = "";
3763     FdGuard ipcFd(1);
3764     FdGuard sharedFd(1);
3765     FdGuard crashFd(1);
3766     pid_t renderPid = 0;
3767     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3768         std::move(crashFd), renderPid);
3769     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3770     ipcFd.Release();
3771     sharedFd.Release();
3772     crashFd.Release();
3773     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_023 end");
3774 }
3775 
3776 /**
3777  * @tc.name: StartRenderProcess_024
3778  * @tc.desc: start render process.
3779  * @tc.type: FUNC
3780  * @tc.require: issueI5W4S7
3781  */
3782 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_024, TestSize.Level2)
3783 {
3784     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_024 start");
3785     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3786     EXPECT_NE(appMgrServiceInner, nullptr);
3787 
3788     pid_t hostPid = 1;
3789     std::string renderParam = "test_renderParam";
3790     FdGuard ipcFd(0);
3791     FdGuard sharedFd(0);
3792     FdGuard crashFd(0);
3793     pid_t renderPid = 0;
3794     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3795         std::move(crashFd), renderPid);
3796     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3797     ipcFd.Release();
3798     sharedFd.Release();
3799     crashFd.Release();
3800     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_024 end");
3801 }
3802 
3803 /**
3804  * @tc.name: StartRenderProcess_025
3805  * @tc.desc: start render process.
3806  * @tc.type: FUNC
3807  * @tc.require: issueI5W4S7
3808  */
3809 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_025, TestSize.Level2)
3810 {
3811     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_025 start");
3812     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3813     EXPECT_NE(appMgrServiceInner, nullptr);
3814 
3815     pid_t hostPid = 1;
3816     std::string renderParam = "test_renderParam";
3817     FdGuard ipcFd(0);
3818     FdGuard sharedFd(0);
3819     FdGuard crashFd(1);
3820     pid_t renderPid = 0;
3821     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3822         std::move(crashFd), renderPid);
3823     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3824     ipcFd.Release();
3825     sharedFd.Release();
3826     crashFd.Release();
3827     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_025 end");
3828 }
3829 
3830 /**
3831  * @tc.name: StartRenderProcess_026
3832  * @tc.desc: start render process.
3833  * @tc.type: FUNC
3834  * @tc.require: issueI5W4S7
3835  */
3836 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_026, TestSize.Level2)
3837 {
3838     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_026 start");
3839     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3840     EXPECT_NE(appMgrServiceInner, nullptr);
3841 
3842     pid_t hostPid = 1;
3843     std::string renderParam = "test_renderParam";
3844     FdGuard ipcFd(0);
3845     FdGuard sharedFd(1);
3846     FdGuard crashFd(0);
3847     pid_t renderPid = 0;
3848     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3849         std::move(crashFd), renderPid);
3850     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3851     ipcFd.Release();
3852     sharedFd.Release();
3853     crashFd.Release();
3854     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_026 end");
3855 }
3856 
3857 /**
3858  * @tc.name: StartRenderProcess_027
3859  * @tc.desc: start render process.
3860  * @tc.type: FUNC
3861  * @tc.require: issueI5W4S7
3862  */
3863 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_027, TestSize.Level2)
3864 {
3865     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_027 start");
3866     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3867     EXPECT_NE(appMgrServiceInner, nullptr);
3868 
3869     pid_t hostPid = 1;
3870     std::string renderParam = "test_renderParam";
3871     FdGuard ipcFd(0);
3872     FdGuard sharedFd(1);
3873     FdGuard crashFd(1);
3874     pid_t renderPid = 0;
3875     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3876         std::move(crashFd), renderPid);
3877     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3878     ipcFd.Release();
3879     sharedFd.Release();
3880     crashFd.Release();
3881     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_027 end");
3882 }
3883 
3884 /**
3885  * @tc.name: StartRenderProcess_028
3886  * @tc.desc: start render process.
3887  * @tc.type: FUNC
3888  * @tc.require: issueI5W4S7
3889  */
3890 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_028, TestSize.Level2)
3891 {
3892     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_028 start");
3893     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3894     EXPECT_NE(appMgrServiceInner, nullptr);
3895 
3896     pid_t hostPid = 1;
3897     std::string renderParam = "test_renderParam";
3898     FdGuard ipcFd(1);
3899     FdGuard sharedFd(0);
3900     FdGuard crashFd(0);
3901     pid_t renderPid = 0;
3902     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3903         std::move(crashFd), renderPid);
3904     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3905     ipcFd.Release();
3906     sharedFd.Release();
3907     crashFd.Release();
3908     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_028 end");
3909 }
3910 
3911 /**
3912  * @tc.name: StartRenderProcess_029
3913  * @tc.desc: start render process.
3914  * @tc.type: FUNC
3915  * @tc.require: issueI5W4S7
3916  */
3917 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_029, TestSize.Level2)
3918 {
3919     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_029 start");
3920     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3921     EXPECT_NE(appMgrServiceInner, nullptr);
3922 
3923     pid_t hostPid = 1;
3924     std::string renderParam = "test_renderParam";
3925     FdGuard ipcFd(1);
3926     FdGuard sharedFd(0);
3927     FdGuard crashFd(1);
3928     pid_t renderPid = 0;
3929     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3930         std::move(crashFd), renderPid);
3931     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3932     ipcFd.Release();
3933     sharedFd.Release();
3934     crashFd.Release();
3935     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_029 end");
3936 }
3937 
3938 /**
3939  * @tc.name: StartRenderProcess_030
3940  * @tc.desc: start render process.
3941  * @tc.type: FUNC
3942  * @tc.require: issueI5W4S7
3943  */
3944 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_030, TestSize.Level2)
3945 {
3946     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_030 start");
3947     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3948     EXPECT_NE(appMgrServiceInner, nullptr);
3949 
3950     pid_t hostPid = 1;
3951     std::string renderParam = "test_renderParam";
3952     FdGuard ipcFd(1);
3953     FdGuard sharedFd(1);
3954     FdGuard crashFd(0);
3955     pid_t renderPid = 0;
3956     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3957         std::move(crashFd), renderPid);
3958     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3959     ipcFd.Release();
3960     sharedFd.Release();
3961     crashFd.Release();
3962     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_030 end");
3963 }
3964 
3965 /**
3966  * @tc.name: StartRenderProcess_031
3967  * @tc.desc: start render process.
3968  * @tc.type: FUNC
3969  * @tc.require: issueI5W4S7
3970  */
3971 HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_031, TestSize.Level2)
3972 {
3973     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_031 start");
3974     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
3975     EXPECT_NE(appMgrServiceInner, nullptr);
3976 
3977     pid_t hostPid = 1;
3978     std::string renderParam = "test_renderParam";
3979     FdGuard ipcFd(1);
3980     FdGuard sharedFd(1);
3981     FdGuard crashFd(1);
3982     pid_t renderPid = 0;
3983     int ret = appMgrServiceInner->StartRenderProcess(hostPid, renderParam, std::move(ipcFd), std::move(sharedFd),
3984         std::move(crashFd), renderPid);
3985     EXPECT_EQ(ret, ERR_INVALID_VALUE);
3986     ipcFd.Release();
3987     sharedFd.Release();
3988     crashFd.Release();
3989     TAG_LOGI(AAFwkTag::TEST, "StartRenderProcess_031 end");
3990 }
3991 
3992 /**
3993  * @tc.name: AttachRenderProcess_001
3994  * @tc.desc: attach render process.
3995  * @tc.type: FUNC
3996  */
3997 HWTEST_F(AppMgrServiceInnerTest, AttachRenderProcess_001, TestSize.Level2)
3998 {
3999     TAG_LOGI(AAFwkTag::TEST, "AttachRenderProcess_001 start");
4000     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4001     EXPECT_NE(appMgrServiceInner, nullptr);
4002 
4003     pid_t pid = 0;
4004     sptr<IRenderScheduler> scheduler;
4005     appMgrServiceInner->AttachRenderProcess(pid, scheduler);
4006     TAG_LOGI(AAFwkTag::TEST, "AttachRenderProcess_001 end");
4007 }
4008 
4009 /**
4010  * @tc.name: AttachRenderProcess_002
4011  * @tc.desc: attach render process.
4012  * @tc.type: FUNC
4013  */
4014 HWTEST_F(AppMgrServiceInnerTest, AttachRenderProcess_002, TestSize.Level2)
4015 {
4016     TAG_LOGI(AAFwkTag::TEST, "AttachRenderProcess_002 start");
4017     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4018     EXPECT_NE(appMgrServiceInner, nullptr);
4019 
4020     pid_t pid = 1;
4021     sptr<IRenderScheduler> scheduler;
4022     appMgrServiceInner->AttachRenderProcess(pid, scheduler);
4023     TAG_LOGI(AAFwkTag::TEST, "AttachRenderProcess_002 end");
4024 }
4025 
4026 #ifdef WITH_DLP
4027 /**
4028  * @tc.name: BuildStartFlags_001
4029  * @tc.desc: build start flags.
4030  * @tc.type: FUNC
4031  * @tc.require: issueI5W4S7
4032  */
4033 HWTEST_F(AppMgrServiceInnerTest, BuildStartFlags_001, TestSize.Level2)
4034 {
4035     TAG_LOGI(AAFwkTag::TEST, "BuildStartFlags_001 start");
4036 
4037     AAFwk::Want want;
4038     AbilityInfo abilityInfo;
4039     AppspawnUtil::BuildStartFlags(want, abilityInfo);
4040 
4041     want.SetParam("coldStart", true);
4042     want.SetParam("ohos.dlp.params.index", 1);
4043     abilityInfo.extensionAbilityType = ExtensionAbilityType::BACKUP;
4044     uint32_t result = AppspawnUtil::BuildStartFlags(want, abilityInfo);
4045     EXPECT_EQ(result, 7);
4046 
4047     TAG_LOGI(AAFwkTag::TEST, "BuildStartFlags_001 end");
4048 }
4049 #endif // WITH_DLP
4050 
4051 /**
4052  * @tc.name: RegisterFocusListener_001
4053  * @tc.desc: register focus listener.
4054  * @tc.type: FUNC
4055  * @tc.require: issueI5W4S7
4056  */
4057 HWTEST_F(AppMgrServiceInnerTest, RegisterFocusListener_001, TestSize.Level2)
4058 {
4059     TAG_LOGI(AAFwkTag::TEST, "RegisterFocusListener_001 start");
4060     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4061     EXPECT_NE(appMgrServiceInner, nullptr);
4062 
4063     appMgrServiceInner->RegisterFocusListener();
4064 
4065     appMgrServiceInner->focusListener_ = nullptr;
4066     appMgrServiceInner->RegisterFocusListener();
4067 
4068     TAG_LOGI(AAFwkTag::TEST, "RegisterFocusListener_001 end");
4069 }
4070 
4071 /**
4072  * @tc.name: HandleFocused_001
4073  * @tc.desc: handle focused.
4074  * @tc.type: FUNC
4075  * @tc.require: issueI5W4S7
4076  */
4077 HWTEST_F(AppMgrServiceInnerTest, HandleFocused_001, TestSize.Level2)
4078 {
4079     TAG_LOGI(AAFwkTag::TEST, "HandleFocused_001 start");
4080     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4081     EXPECT_NE(appMgrServiceInner, nullptr);
4082 
4083     sptr<Rosen::FocusChangeInfo> focusChangeInfo;
4084     appMgrServiceInner->HandleFocused(focusChangeInfo);
4085 
4086     pid_t pid = 1;
4087     focusChangeInfo = new Rosen::FocusChangeInfo();
4088     appMgrServiceInner->HandleFocused(focusChangeInfo);
4089 
4090     focusChangeInfo->pid_ = pid;
4091     appMgrServiceInner->HandleFocused(focusChangeInfo);
4092 
4093     BundleInfo bundleInfo;
4094     std::string processName = "test_processName";
4095     std::shared_ptr<AppRunningRecord> appRecord =
4096         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
4097     EXPECT_NE(appRecord, nullptr);
4098     appRecord->GetPriorityObject()->SetPid(pid);
4099     appMgrServiceInner->HandleFocused(focusChangeInfo);
4100 
4101     TAG_LOGI(AAFwkTag::TEST, "HandleFocused_001 end");
4102 }
4103 
4104 /**
4105  * @tc.name: HandleUnfocused_001
4106  * @tc.desc: handle unfocused.
4107  * @tc.type: FUNC
4108  * @tc.require: issueI5W4S7
4109  */
4110 HWTEST_F(AppMgrServiceInnerTest, HandleUnfocused_001, TestSize.Level2)
4111 {
4112     TAG_LOGI(AAFwkTag::TEST, "HandleUnfocused_001 start");
4113     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4114     EXPECT_NE(appMgrServiceInner, nullptr);
4115 
4116     sptr<Rosen::FocusChangeInfo> focusChangeInfo;
4117     appMgrServiceInner->HandleUnfocused(focusChangeInfo);
4118 
4119     pid_t pid = 1;
4120     focusChangeInfo = new Rosen::FocusChangeInfo();
4121     appMgrServiceInner->HandleUnfocused(focusChangeInfo);
4122 
4123     focusChangeInfo->pid_ = pid;
4124     appMgrServiceInner->HandleUnfocused(focusChangeInfo);
4125 
4126     BundleInfo bundleInfo;
4127     std::string processName = "test_processName";
4128     std::shared_ptr<AppRunningRecord> appRecord =
4129         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
4130     EXPECT_NE(appRecord, nullptr);
4131     appRecord->GetPriorityObject()->SetPid(pid);
4132     appMgrServiceInner->HandleUnfocused(focusChangeInfo);
4133 
4134     TAG_LOGI(AAFwkTag::TEST, "HandleUnfocused_001 end");
4135 }
4136 
4137 /**
4138  * @tc.name: GetAppRunningStateByBundleName_001
4139  * @tc.desc: get app running state by bundle name.
4140  * @tc.type: FUNC
4141  * @tc.require: issueI5W4S7
4142  */
4143 HWTEST_F(AppMgrServiceInnerTest, GetAppRunningStateByBundleName_001, TestSize.Level2)
4144 {
4145     TAG_LOGI(AAFwkTag::TEST, "GetAppRunningStateByBundleName_001 start");
4146     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4147     EXPECT_NE(appMgrServiceInner, nullptr);
4148 
4149     std::string bundleName = "test_bundleName";
4150     appMgrServiceInner->GetAppRunningStateByBundleName(bundleName);
4151 
4152     appMgrServiceInner->appRunningManager_ = nullptr;
4153     appMgrServiceInner->GetAppRunningStateByBundleName(bundleName);
4154 
4155     TAG_LOGI(AAFwkTag::TEST, "GetAppRunningStateByBundleName_001 end");
4156 }
4157 
4158 /**
4159  * @tc.name: NotifyLoadRepairPatch_001
4160  * @tc.desc: notify load repair patch.
4161  * @tc.type: FUNC
4162  * @tc.require: issueI5W4S7
4163  */
4164 HWTEST_F(AppMgrServiceInnerTest, NotifyLoadRepairPatch_001, TestSize.Level2)
4165 {
4166     TAG_LOGI(AAFwkTag::TEST, "NotifyLoadRepairPatch_001 start");
4167     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4168     EXPECT_NE(appMgrServiceInner, nullptr);
4169 
4170     std::string bundleName = "test_bundleName";
4171     sptr<IQuickFixCallback> callback;
4172     appMgrServiceInner->NotifyLoadRepairPatch(bundleName, callback);
4173 
4174     appMgrServiceInner->appRunningManager_ = nullptr;
4175     appMgrServiceInner->NotifyLoadRepairPatch(bundleName, callback);
4176 
4177     TAG_LOGI(AAFwkTag::TEST, "NotifyLoadRepairPatch_001 end");
4178 }
4179 
4180 /**
4181  * @tc.name: NotifyHotReloadPage_001
4182  * @tc.desc: notify hot reload page.
4183  * @tc.type: FUNC
4184  * @tc.require: issueI5W4S7
4185  */
4186 HWTEST_F(AppMgrServiceInnerTest, NotifyHotReloadPage_001, TestSize.Level2)
4187 {
4188     TAG_LOGI(AAFwkTag::TEST, "NotifyHotReloadPage_001 start");
4189     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4190     EXPECT_NE(appMgrServiceInner, nullptr);
4191 
4192     std::string bundleName = "test_bundleName";
4193     sptr<IQuickFixCallback> callback;
4194     appMgrServiceInner->NotifyHotReloadPage(bundleName, callback);
4195 
4196     appMgrServiceInner->appRunningManager_ = nullptr;
4197     appMgrServiceInner->NotifyHotReloadPage(bundleName, callback);
4198 
4199     TAG_LOGI(AAFwkTag::TEST, "NotifyHotReloadPage_001 end");
4200 }
4201 
4202 /**
4203  * @tc.name: SetContinuousTaskProcess_001
4204  * @tc.desc: set continuous task process.
4205  * @tc.type: FUNC
4206  * @tc.require: issueI5W4S7
4207  */
4208 #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
4209 HWTEST_F(AppMgrServiceInnerTest, SetContinuousTaskProcess_001, TestSize.Level2)
4210 {
4211     TAG_LOGI(AAFwkTag::TEST, "SetContinuousTaskProcess_001 start");
4212     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4213     EXPECT_NE(appMgrServiceInner, nullptr);
4214 
4215     int32_t ret = appMgrServiceInner->SetContinuousTaskProcess(0, true);
4216     EXPECT_EQ(ret, ERR_INVALID_VALUE);
4217 
4218     BundleInfo bundleInfo;
4219     std::string processName = "test_processName";
4220     std::shared_ptr<AppRunningRecord> appRecord =
4221         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, bundleInfo, "");
4222     EXPECT_NE(appRecord, nullptr);
4223     appRecord->GetPriorityObject()->SetPid(0);
4224     ret = appMgrServiceInner->SetContinuousTaskProcess(0, true);
4225     EXPECT_EQ(ret, 0);
4226 
4227     appMgrServiceInner->appRunningManager_ = nullptr;
4228     ret = appMgrServiceInner->SetContinuousTaskProcess(0, true);
4229     EXPECT_EQ(ret, ERR_INVALID_OPERATION);
4230 
4231     TAG_LOGI(AAFwkTag::TEST, "SetContinuousTaskProcess_001 end");
4232 }
4233 #endif
4234 
4235 /**
4236  * @tc.name: NotifyUnLoadRepairPatch_001
4237  * @tc.desc: notify unload repair patch.
4238  * @tc.type: FUNC
4239  * @tc.require: issueI5W4S7
4240  */
4241 HWTEST_F(AppMgrServiceInnerTest, NotifyUnLoadRepairPatch_001, TestSize.Level2)
4242 {
4243     TAG_LOGI(AAFwkTag::TEST, "NotifyUnLoadRepairPatch_001 start");
4244     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4245     EXPECT_NE(appMgrServiceInner, nullptr);
4246 
4247     std::string bundleName = "test_bundleName";
4248     sptr<IQuickFixCallback> callback;
4249     appMgrServiceInner->NotifyUnLoadRepairPatch(bundleName, callback);
4250 
4251     appMgrServiceInner->appRunningManager_ = nullptr;
4252     appMgrServiceInner->NotifyUnLoadRepairPatch(bundleName, callback);
4253 
4254     TAG_LOGI(AAFwkTag::TEST, "NotifyUnLoadRepairPatch_001 end");
4255 }
4256 
4257 /**
4258  * @tc.name: SetCurrentUserId_001
4259  * @tc.desc: set current userId.
4260  * @tc.type: FUNC
4261  */
4262 HWTEST_F(AppMgrServiceInnerTest, SetCurrentUserId_001, TestSize.Level2)
4263 {
4264     TAG_LOGI(AAFwkTag::TEST, "SetCurrentUserId_001 start");
4265     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4266     EXPECT_NE(appMgrServiceInner, nullptr);
4267 
4268     int userId = 0;
4269     appMgrServiceInner->SetCurrentUserId(userId);
4270     EXPECT_EQ(appMgrServiceInner->currentUserId_, userId);
4271 
4272     TAG_LOGI(AAFwkTag::TEST, "SetCurrentUserId_001 end");
4273 }
4274 
4275 /**
4276  * @tc.name: GetProcessMemoryByPid_001
4277  * @tc.desc: Get memorySize by pid.
4278  * @tc.type: FUNC
4279  * @tc.require: issueI76JBF
4280  */
4281 HWTEST_F(AppMgrServiceInnerTest, GetProcessMemoryByPid_001, TestSize.Level2)
4282 {
4283     TAG_LOGI(AAFwkTag::TEST, "GetProcessMemoryByPid_001 start");
4284     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4285     EXPECT_NE(appMgrServiceInner, nullptr);
4286 
4287     int32_t pid = 0;
4288     int32_t memorySize = 0;
4289     int32_t ret = appMgrServiceInner->GetProcessMemoryByPid(pid, memorySize);
4290     EXPECT_EQ(ret, ERR_OK);
4291 
4292     TAG_LOGI(AAFwkTag::TEST, "GetProcessMemoryByPid_001 end");
4293 }
4294 
4295 /**
4296  * @tc.name: GetRunningProcessInformation_001
4297  * @tc.desc: Get application processes information list by bundleName.
4298  * @tc.type: FUNC
4299  * @tc.require: issueI76JBF
4300  */
4301 HWTEST_F(AppMgrServiceInnerTest, GetRunningProcessInformation_001, TestSize.Level2)
4302 {
4303     TAG_LOGI(AAFwkTag::TEST, "GetRunningProcessInformation_001 start");
4304     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4305     EXPECT_NE(appMgrServiceInner, nullptr);
4306 
4307     std::string bundleName = "testBundleName";
4308     int32_t userId = 100;
4309     std::vector<RunningProcessInfo> info;
4310     int32_t ret = appMgrServiceInner->GetRunningProcessInformation(bundleName, userId, info);
4311     EXPECT_EQ(ret, ERR_OK);
4312 
4313     appMgrServiceInner->remoteClientManager_ = nullptr;
4314     ret = appMgrServiceInner->GetRunningProcessInformation(bundleName, userId, info);
4315     EXPECT_EQ(ret, ERR_NO_INIT);
4316 
4317     appMgrServiceInner->appRunningManager_ = nullptr;
4318     ret = appMgrServiceInner->GetRunningProcessInformation(bundleName, userId, info);
4319     EXPECT_EQ(ret, ERR_NO_INIT);
4320 
4321     TAG_LOGI(AAFwkTag::TEST, "GetRunningProcessInformation_001 end");
4322 }
4323 
4324 /**
4325  * @tc.name: GetBundleNameByPid_001
4326  * @tc.desc: get bundle name by Pid.
4327  * @tc.type: FUNC
4328  */
4329 HWTEST_F(AppMgrServiceInnerTest, GetBundleNameByPid_001, TestSize.Level1)
4330 {
4331     TAG_LOGI(AAFwkTag::TEST, "GetBundleNameByPid_001 start");
4332 
4333     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4334     EXPECT_NE(appMgrServiceInner, nullptr);
4335     int32_t pid = 0;
4336     std::string name = "test_name";
4337     int32_t uid = 0;
4338     auto ret  = appMgrServiceInner->GetBundleNameByPid(pid, name, uid);
4339     EXPECT_EQ(ret, ERR_INVALID_OPERATION);
4340 
4341     TAG_LOGI(AAFwkTag::TEST, "GetBundleNameByPid_001 end");
4342 }
4343 
4344 /**
4345  * @tc.name: GetBundleNameByPid_002
4346  * @tc.desc: get bundle name by Pid.
4347  * @tc.type: FUNC
4348  */
4349 HWTEST_F(AppMgrServiceInnerTest, GetBundleNameByPid_002, TestSize.Level1)
4350 {
4351     TAG_LOGI(AAFwkTag::TEST, "GetBundleNameByPid_002 start");
4352 
4353     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4354     EXPECT_NE(appMgrServiceInner, nullptr);
4355     BundleInfo info;
4356     std::string processName = "test_processName";
4357     appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
4358     int32_t pid = 0;
4359     std::string name = "test_name";
4360     int32_t uid = 0;
4361     auto ret  = appMgrServiceInner->GetBundleNameByPid(pid, name, uid);
4362     EXPECT_EQ(ret, ERR_OK);
4363 
4364     TAG_LOGI(AAFwkTag::TEST, "GetBundleNameByPid_002 end");
4365 }
4366 
4367 /**
4368  * @tc.name: AppRecoveryNotifyApp_001
4369  * @tc.desc: AppRecovery NotifyApp.
4370  * @tc.type: FUNC
4371  */
4372 HWTEST_F(AppMgrServiceInnerTest, AppRecoveryNotifyApp_001, TestSize.Level1)
4373 {
4374     TAG_LOGI(AAFwkTag::TEST, "AppRecoveryNotifyApp_001 start");
4375     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4376     EXPECT_NE(appMgrServiceInner, nullptr);
4377     int32_t pid = 0;
4378     std::string bundleName = "com.is.hiserice";
4379     appMgrServiceInner->AppRecoveryNotifyApp(pid, bundleName, FaultDataType::RESOURCE_CONTROL, "appRecovery");
4380     appMgrServiceInner->AppRecoveryNotifyApp(pid, bundleName, FaultDataType::APP_FREEZE, "recovery");
4381     TAG_LOGI(AAFwkTag::TEST, "AppRecoveryNotifyApp_001 end");
4382 }
4383 
4384 /**
4385  * @tc.name: NotifyAppFault_001
4386  * @tc.desc: Notify AppFault.
4387  * @tc.type: FUNC
4388  */
4389 HWTEST_F(AppMgrServiceInnerTest, NotifyAppFault_001, TestSize.Level1)
4390 {
4391     TAG_LOGI(AAFwkTag::TEST, "NotifyAppFault_001 start");
4392     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4393     EXPECT_NE(appMgrServiceInner, nullptr);
4394     FaultData faultData1;
4395     faultData1.errorObject.name = "1234";
4396     faultData1.timeoutMarkers = "456";
4397     int32_t ret1 = appMgrServiceInner->NotifyAppFault(faultData1);
4398     EXPECT_EQ(ret1, ERR_INVALID_VALUE);
4399 }
4400 
4401 /**
4402  * @tc.name: TimeoutNotifyApp_001
4403  * @tc.desc: Timeout Notify App.
4404  * @tc.type: FUNC
4405  */
4406 HWTEST_F(AppMgrServiceInnerTest, TimeoutNotifyApp_001, TestSize.Level1)
4407 {
4408     TAG_LOGI(AAFwkTag::TEST, "TimeoutNotifyApp_001 start");
4409     std::shared_ptr<AppMgrServiceInner> appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4410     EXPECT_NE(appMgrServiceInner, nullptr);
4411     std::shared_ptr<MockTaskHandlerWrap> taskHandler = MockTaskHandlerWrap::CreateQueueHandler("app_mgr_task_queue");
4412     EXPECT_CALL(*taskHandler, SubmitTaskInner(_, _)).Times(AtLeast(1));
4413     appMgrServiceInner->SetTaskHandler(taskHandler);
4414 
4415     int32_t pid = 0;
4416     int32_t uid = 0;
4417     std::string bundleName = "test_processName";
4418     std::string processName = "test_processName";
4419     FaultData faultData;
4420     faultData.errorObject.name = "1234";
4421     faultData.faultType = FaultDataType::APP_FREEZE;
4422     appMgrServiceInner->TimeoutNotifyApp(pid, uid, bundleName, processName, faultData);
4423     EXPECT_NE(taskHandler, nullptr);
4424     TAG_LOGI(AAFwkTag::TEST, "TimeoutNotifyApp_001 end");
4425 }
4426 
4427 /**
4428  * @tc.name: NotifyAppFaultBySA_001
4429  * @tc.desc: Notify Fault Data By SA
4430  * @tc.type: FUNC
4431  */
4432 HWTEST_F(AppMgrServiceInnerTest, NotifyAppFaultBySA_001, TestSize.Level1)
4433 {
4434     TAG_LOGI(AAFwkTag::TEST, "NotifyAppFaultBySA_001 start");
4435     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4436     EXPECT_NE(appMgrServiceInner, nullptr);
4437     AppFaultDataBySA faultData;
4438     faultData.pid = 8142;
4439     faultData.errorObject.name = "appRecovery";
4440     int32_t ret = appMgrServiceInner->NotifyAppFaultBySA(faultData);
4441     EXPECT_EQ(ret, ERR_INVALID_VALUE);
4442     TAG_LOGI(AAFwkTag::TEST, "NotifyAppFaultBySA_001 end");
4443 }
4444 
4445 /**
4446  * @tc.name: RegisterAppDebugListener_001
4447  * @tc.desc: Test the status of RegisterAppDebugListener.
4448  * @tc.type: FUNC
4449  */
4450 HWTEST_F(AppMgrServiceInnerTest, RegisterAppDebugListener_001, TestSize.Level2)
4451 {
4452     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4453     EXPECT_NE(appMgrServiceInner, nullptr);
4454     sptr<IAppDebugListener> listener = nullptr;
4455     appMgrServiceInner->appDebugManager_ = std::make_shared<AppDebugManager>();
4456     auto result = appMgrServiceInner->RegisterAppDebugListener(listener);
4457     EXPECT_EQ(result, ERR_INVALID_DATA);
4458     appMgrServiceInner->appDebugManager_ = nullptr;
4459     result = appMgrServiceInner->RegisterAppDebugListener(listener);
4460     EXPECT_EQ(result, ERR_NO_INIT);
4461 }
4462 
4463 /**
4464  * @tc.name: UnregisterAppDebugListener_001
4465  * @tc.desc: Test the status of UnregisterAppDebugListener.
4466  * @tc.type: FUNC
4467  */
4468 HWTEST_F(AppMgrServiceInnerTest, UnregisterAppDebugListener_001, TestSize.Level2)
4469 {
4470     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4471     EXPECT_NE(appMgrServiceInner, nullptr);
4472     sptr<IAppDebugListener> listener = nullptr;
4473     appMgrServiceInner->appDebugManager_ = std::make_shared<AppDebugManager>();
4474     auto result = appMgrServiceInner->UnregisterAppDebugListener(listener);
4475     EXPECT_EQ(result, ERR_INVALID_DATA);
4476     appMgrServiceInner->appDebugManager_ = nullptr;
4477     result = appMgrServiceInner->UnregisterAppDebugListener(listener);
4478     EXPECT_EQ(result, ERR_NO_INIT);
4479 }
4480 
4481 /**
4482  * @tc.name: AttachAppDebug_001
4483  * @tc.desc: Test the status of AttachAppDebug.
4484  * @tc.type: FUNC
4485  */
4486 HWTEST_F(AppMgrServiceInnerTest, AttachAppDebug_001, TestSize.Level2)
4487 {
4488     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4489     EXPECT_NE(appMgrServiceInner, nullptr);
4490     std::string bundleName;
4491     appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
4492     appMgrServiceInner->appDebugManager_ = std::make_shared<AppDebugManager>();
4493     auto result = appMgrServiceInner->AttachAppDebug(bundleName, false);
4494     EXPECT_EQ(result, ERR_OK);
4495 }
4496 
4497 /**
4498  * @tc.name: AttachAppDebug_002
4499  * @tc.desc: Test the status of AttachAppDebug, check nullptr AppRunningManager.
4500  * @tc.type: FUNC
4501  */
4502 HWTEST_F(AppMgrServiceInnerTest, AttachAppDebug_002, TestSize.Level2)
4503 {
4504     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4505     EXPECT_NE(appMgrServiceInner, nullptr);
4506     std::string bundleName;
4507     appMgrServiceInner->appRunningManager_ = nullptr;
4508     appMgrServiceInner->appDebugManager_ = std::make_shared<AppDebugManager>();
4509     auto result = appMgrServiceInner->AttachAppDebug(bundleName, false);
4510     EXPECT_EQ(result, ERR_NO_INIT);
4511 }
4512 
4513 /**
4514  * @tc.name: DetachAppDebug_001
4515  * @tc.desc: Test the status of DetachAppDebug.
4516  * @tc.type: FUNC
4517  */
4518 HWTEST_F(AppMgrServiceInnerTest, DetachAppDebug_001, TestSize.Level2)
4519 {
4520     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4521     EXPECT_NE(appMgrServiceInner, nullptr);
4522     std::string bundleName;
4523     appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
4524     appMgrServiceInner->appDebugManager_ = std::make_shared<AppDebugManager>();
4525     auto result = appMgrServiceInner->DetachAppDebug(bundleName);
4526     EXPECT_EQ(result, ERR_OK);
4527 }
4528 
4529 /**
4530  * @tc.name: DetachAppDebug_002
4531  * @tc.desc: Test the status of DetachAppDebug, check nullptr AppRunningManager.
4532  * @tc.type: FUNC
4533  */
4534 HWTEST_F(AppMgrServiceInnerTest, DetachAppDebug_002, TestSize.Level2)
4535 {
4536     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4537     EXPECT_NE(appMgrServiceInner, nullptr);
4538     std::string bundleName;
4539     appMgrServiceInner->appRunningManager_ = nullptr;
4540     appMgrServiceInner->appDebugManager_ = std::make_shared<AppDebugManager>();
4541     auto result = appMgrServiceInner->DetachAppDebug(bundleName);
4542     EXPECT_EQ(result, ERR_NO_INIT);
4543 }
4544 
4545 /**
4546  * @tc.name: SetAppWaitingDebug_001
4547  * @tc.desc: Test function SetAppWaitingDebug.
4548  * @tc.type: FUNC
4549  */
4550 HWTEST_F(AppMgrServiceInnerTest, SetAppWaitingDebug_001, TestSize.Level2)
4551 {
4552     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4553     EXPECT_NE(appMgrServiceInner, nullptr);
4554     std::string bundleName("test");
4555     auto result = appMgrServiceInner->SetAppWaitingDebug(bundleName, false);
4556     EXPECT_EQ(result, ERR_PERMISSION_DENIED);
4557 }
4558 
4559 /**
4560  * @tc.name: CancelAppWaitingDebug_001
4561  * @tc.desc: Test function CancelAppWaitingDebug.
4562  * @tc.type: FUNC
4563  */
4564 HWTEST_F(AppMgrServiceInnerTest, CancelAppWaitingDebug_001, TestSize.Level2)
4565 {
4566     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4567     EXPECT_NE(appMgrServiceInner, nullptr);
4568     auto result = appMgrServiceInner->CancelAppWaitingDebug();
4569     EXPECT_EQ(result, ERR_PERMISSION_DENIED);
4570 }
4571 
4572 /**
4573  * @tc.name: GetWaitingDebugApp_001
4574  * @tc.desc: Test function GetWaitingDebugApp.
4575  * @tc.type: FUNC
4576  */
4577 HWTEST_F(AppMgrServiceInnerTest, GetWaitingDebugApp_001, TestSize.Level2)
4578 {
4579     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4580     EXPECT_NE(appMgrServiceInner, nullptr);
4581     std::vector<std::string> debugInfoList;
4582     auto result = appMgrServiceInner->GetWaitingDebugApp(debugInfoList);
4583     EXPECT_EQ(result, ERR_PERMISSION_DENIED);
4584 }
4585 
4586 /**
4587  * @tc.name: RegisterAbilityDebugResponse_001
4588  * @tc.desc: Test the status of RegisterAbilityDebugResponse.
4589  * @tc.type: FUNC
4590  */
4591 HWTEST_F(AppMgrServiceInnerTest, RegisterAbilityDebugResponse_001, TestSize.Level2)
4592 {
4593     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4594     EXPECT_NE(appMgrServiceInner, nullptr);
4595     sptr<IAbilityDebugResponse> response = nullptr;
4596     appMgrServiceInner->RegisterAbilityDebugResponse(response);
4597     EXPECT_TRUE(appMgrServiceInner != nullptr);
4598 }
4599 
4600 /**
4601  * @tc.name: NotifyAbilitysDebugChange_001
4602  * @tc.desc: Test the status of NotifyAbilitiesDebugChange.
4603  * @tc.type: FUNC
4604  */
4605 HWTEST_F(AppMgrServiceInnerTest, NotifyAbilitysDebugChange_001, TestSize.Level2)
4606 {
4607     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4608     EXPECT_NE(appMgrServiceInner, nullptr);
4609     std::string bundleName;
4610     bool isAppDebug = true;
4611     appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
4612     appMgrServiceInner->appDebugManager_ = std::make_shared<AppDebugManager>();
4613     auto result = appMgrServiceInner->NotifyAbilitiesDebugChange(bundleName, isAppDebug);
4614     EXPECT_EQ(result, ERR_NO_INIT);
4615 }
4616 
4617 /**
4618  * @tc.name: ProcessAppDebug_001
4619  * @tc.desc: Test the status of ProcessAppDebug.
4620  * @tc.type: FUNC
4621  */
4622 HWTEST_F(AppMgrServiceInnerTest, ProcessAppDebug_001, TestSize.Level2)
4623 {
4624     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4625     EXPECT_NE(appMgrServiceInner, nullptr);
4626     appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
4627     std::shared_ptr<ApplicationInfo> info = std::make_shared<ApplicationInfo>();
4628     int32_t recordId = RECORD_ID;
4629     std::string processName = "processName";
4630     std::shared_ptr<AppRunningRecord> appRecord = std::make_shared<AppRunningRecord>(info, recordId, processName);
4631     bool isDebugStart = true;
4632     appRecord->SetDebugApp(false);
4633     appMgrServiceInner->ProcessAppDebug(appRecord, isDebugStart);
4634     EXPECT_EQ(appRecord->IsDebugApp(), true);
4635 }
4636 
4637 /**
4638  * @tc.name: MakeAppDebugInfo_001
4639  * @tc.desc: Test the status of MakeAppDebugInfo.
4640  * @tc.type: FUNC
4641  */
4642 HWTEST_F(AppMgrServiceInnerTest, MakeAppDebugInfo_001, TestSize.Level2)
4643 {
4644     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4645     EXPECT_NE(appMgrServiceInner, nullptr);
4646     appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
4647     std::shared_ptr<ApplicationInfo> info = std::make_shared<ApplicationInfo>();
4648     int32_t recordId = RECORD_ID;
4649     std::string processName = "processName";
4650     std::shared_ptr<AppRunningRecord> appRecord = std::make_shared<AppRunningRecord>(info, recordId, processName);
4651     bool isDebugStart = true;
4652     appRecord->SetDebugApp(false);
4653     auto appDebugInfo = appMgrServiceInner->MakeAppDebugInfo(appRecord, isDebugStart);
4654     EXPECT_EQ(appDebugInfo.bundleName, "");
4655     EXPECT_EQ(appDebugInfo.pid, APP_DEBUG_INFO_PID);
4656     EXPECT_EQ(appDebugInfo.isDebugStart, true);
4657 }
4658 
4659 /**
4660  * @tc.name: ChangeAppGcState_001
4661  * @tc.desc: Change app Gc state
4662  * @tc.type: FUNC
4663  */
4664 HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_001, TestSize.Level1)
4665 {
4666     TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_001 start");
4667     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4668     EXPECT_NE(appMgrServiceInner, nullptr);
4669     int32_t pid = 0;
4670     int32_t state = 0;
4671     int32_t ret = appMgrServiceInner->ChangeAppGcState(pid, state);
4672     EXPECT_EQ(ret, ERR_INVALID_VALUE);
4673     TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_001 end");
4674 }
4675 
4676 /**
4677  * @tc.name: ChangeAppGcState_002
4678  * @tc.desc: Change app Gc state
4679  * @tc.type: FUNC
4680  */
4681 HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_002, TestSize.Level1)
4682 {
4683     TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_002 start");
4684     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4685     EXPECT_NE(appMgrServiceInner, nullptr);
4686     int32_t pid = 0;
4687     int32_t state = 0;
4688     uint64_t tid = 1;
4689     int32_t ret = appMgrServiceInner->ChangeAppGcState(pid, state, tid);
4690     EXPECT_EQ(ret, ERR_INVALID_VALUE);
4691     TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_002 end");
4692 }
4693 
4694 /**
4695  * @tc.name: SendReStartProcessEvent_001
4696  * @tc.desc: Change app Gc state
4697  * @tc.type: FUNC
4698  */
4699 HWTEST_F(AppMgrServiceInnerTest, SendReStartProcessEvent_001, TestSize.Level1)
4700 {
4701     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_001 start");
4702     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4703     EXPECT_NE(appMgrServiceInner, nullptr);
4704     AAFwk::EventInfo eventInfo;
4705     appMgrServiceInner->SendReStartProcessEvent(eventInfo, 0);
4706     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_001 end");
4707 }
4708 
4709 /**
4710  * @tc.name: SendReStartProcessEvent_002
4711  * @tc.desc: Change app Gc state
4712  * @tc.type: FUNC
4713  */
4714 HWTEST_F(AppMgrServiceInnerTest, SendReStartProcessEvent_002, TestSize.Level1)
4715 {
4716     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_002 start");
4717     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4718     EXPECT_NE(appMgrServiceInner, nullptr);
4719     AAFwk::EventInfo eventInfo;
4720     BundleInfo info;
4721     std::string processName = "test_processName";
4722     auto record =
4723         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
4724     recordId_ += 1;
4725     int64_t restartTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::
4726         system_clock::now().time_since_epoch()).count();
4727     int64_t killedTime = restartTime - 3000;
4728     appMgrServiceInner->killedProcessMap_.emplace(killedTime, processName);
4729     appMgrServiceInner->SendReStartProcessEvent(eventInfo, record->GetUid());
4730     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_002 end");
4731 }
4732 
4733 /**
4734  * @tc.name: SendReStartProcessEvent_003
4735  * @tc.desc: Change app Gc state
4736  * @tc.type: FUNC
4737  */
4738 HWTEST_F(AppMgrServiceInnerTest, SendReStartProcessEvent_003, TestSize.Level1)
4739 {
4740     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_003 start");
4741     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4742     EXPECT_NE(appMgrServiceInner, nullptr);
4743     AAFwk::EventInfo eventInfo;
4744     eventInfo.bundleName = "bundleName";
4745     eventInfo.callerBundleName = "callerBundleName";
4746     BundleInfo info;
4747     std::string processName = "test_processName";
4748     auto record =
4749         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
4750     recordId_ += 1;
4751     int64_t restartTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::
4752         system_clock::now().time_since_epoch()).count();
4753     int64_t killedTime = restartTime - 1000;
4754     appMgrServiceInner->killedProcessMap_.emplace(killedTime, processName);
4755     appMgrServiceInner->SendReStartProcessEvent(eventInfo, record->GetUid());
4756     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_003 end");
4757 }
4758 
4759 /**
4760  * @tc.name: SendReStartProcessEvent_004
4761  * @tc.desc: Change app Gc state
4762  * @tc.type: FUNC
4763  */
4764 HWTEST_F(AppMgrServiceInnerTest, SendReStartProcessEvent_004, TestSize.Level1)
4765 {
4766     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_004 start");
4767     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4768     EXPECT_NE(appMgrServiceInner, nullptr);
4769     AAFwk::EventInfo eventInfo;
4770     BundleInfo info;
4771     std::string processName = "test_processName";
4772     eventInfo.bundleName = "bundleName";
4773     eventInfo.callerBundleName = "bundleName";
4774     eventInfo.callerProcessName = processName;
4775     auto record =
4776         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
4777     recordId_ += 1;
4778     int64_t restartTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::
4779         system_clock::now().time_since_epoch()).count();
4780     int64_t killedTime = restartTime - 1000;
4781     appMgrServiceInner->killedProcessMap_.emplace(killedTime, processName);
4782     appMgrServiceInner->SendReStartProcessEvent(eventInfo, record->GetUid());
4783     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_004 end");
4784 }
4785 
4786 /**
4787  * @tc.name: SendReStartProcessEvent_005
4788  * @tc.desc: Change app Gc state
4789  * @tc.type: FUNC
4790  */
4791 HWTEST_F(AppMgrServiceInnerTest, SendReStartProcessEvent_005, TestSize.Level1)
4792 {
4793     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_005 start");
4794     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4795     EXPECT_NE(appMgrServiceInner, nullptr);
4796     AAFwk::EventInfo eventInfo;
4797     BundleInfo info;
4798     std::string processName = "test_processName";
4799     eventInfo.bundleName = "bundleName";
4800     eventInfo.callerBundleName = "bundleName";
4801     eventInfo.callerProcessName = "processName";
4802     auto record =
4803         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
4804     recordId_ += 1;
4805     int64_t restartTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::
4806         system_clock::now().time_since_epoch()).count();
4807     int64_t killedTime = restartTime - 1000;
4808     appMgrServiceInner->killedProcessMap_.emplace(killedTime, processName);
4809     appMgrServiceInner->SendReStartProcessEvent(eventInfo, record->GetUid());
4810     TAG_LOGI(AAFwkTag::TEST, "SendReStartProcessEvent_005 end");
4811 }
4812 
4813 /**
4814  * @tc.name: SendAppLaunchEvent_001
4815  * @tc.desc: launch application.
4816  * @tc.type: FUNC
4817  * @tc.require: issueI5W4S7
4818  */
4819 HWTEST_F(AppMgrServiceInnerTest, SendAppLaunchEvent_001, TestSize.Level2)
4820 {
4821     TAG_LOGI(AAFwkTag::TEST, "SendAppLaunchEvent_001 start");
4822     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4823     EXPECT_NE(appMgrServiceInner, nullptr);
4824 
4825     appMgrServiceInner->SendAppLaunchEvent(nullptr);
4826     BundleInfo info;
4827     std::string processName = "test_processName";
4828     std::shared_ptr<AppRunningRecord> appRecord =
4829         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
4830     recordId_ += 1;
4831     std::shared_ptr<AppRunningRecord> appRecord2 =
4832         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
4833     recordId_ += 1;
4834     appRecord->SetState(ApplicationState::APP_STATE_CREATE);
4835     appRecord->SetKeepAliveEnableState(false);
4836     appRecord->SetKeepAliveDkv(false);
4837     appRecord->SetEmptyKeepAliveAppState(false);
4838     Want want;
4839     appRecord->SetSpecifiedAbilityFlagAndWant(-1, want, "");
4840     appMgrServiceInner->SendAppLaunchEvent(appRecord);
4841     appRecord->SetCallerPid(appRecord2->GetPriorityObject()->GetPid());
4842     appMgrServiceInner->SendAppLaunchEvent(appRecord);
4843     appRecord->appInfo_ = nullptr;
4844     appRecord2->appInfo_ = nullptr;
4845     appMgrServiceInner->SendAppLaunchEvent(appRecord);
4846     TAG_LOGI(AAFwkTag::TEST, "SendAppLaunchEvent_001 end");
4847 }
4848 
4849 HWTEST_F(AppMgrServiceInnerTest, IsMainProcess_001, TestSize.Level2)
4850 {
4851     TAG_LOGI(AAFwkTag::TEST, "IsMainProcess_001 start");
4852     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4853     EXPECT_NE(appMgrServiceInner, nullptr);
4854 
4855     HapModuleInfo hapModuleInfo;
4856     hapModuleInfo.moduleName = "module123";
4857     applicationInfo_->process = "";
4858     EXPECT_EQ(appMgrServiceInner->IsMainProcess(nullptr, ""), true);
4859     EXPECT_EQ(appMgrServiceInner->IsMainProcess(applicationInfo_, ""), false);
4860     EXPECT_EQ(appMgrServiceInner->IsMainProcess(applicationInfo_, "processName1"), false);
4861     EXPECT_EQ(appMgrServiceInner->IsMainProcess(applicationInfo_, applicationInfo_->bundleName), true);
4862     applicationInfo_->process = "processName2";
4863     EXPECT_EQ(appMgrServiceInner->IsMainProcess(applicationInfo_, applicationInfo_->bundleName), false);
4864     EXPECT_EQ(appMgrServiceInner->IsMainProcess(applicationInfo_, "processName2"), true);
4865     applicationInfo_->process = "";
4866 
4867     TAG_LOGI(AAFwkTag::TEST, "IsMainProcess_001 end");
4868 }
4869 
4870 /**
4871  * @tc.name: IsApplicationRunning_001
4872  * @tc.desc: Obtain application running status through bundleName.
4873  * @tc.type: FUNC
4874  */
4875 HWTEST_F(AppMgrServiceInnerTest, IsApplicationRunning_001, TestSize.Level1)
4876 {
4877     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
4878     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4879     EXPECT_NE(appMgrServiceInner, nullptr);
4880     std::string bundleName = "com.is.hiserice";
4881     std::string processName = "test_processName";
4882     bool isRunning = false;
4883     auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
4884     EXPECT_NE(appRecord, nullptr);
4885     appRecord->mainBundleName_ = "com.is.hiserice";
4886     appMgrServiceInner->appRunningManager_->appRunningRecordMap_.emplace(recordId_, appRecord);
4887     int32_t ret = appMgrServiceInner->IsApplicationRunning(bundleName, isRunning);
4888     EXPECT_EQ(ret, ERR_OK);
4889     EXPECT_TRUE(isRunning);
4890 }
4891 
4892 /**
4893  * @tc.name: IsApplicationRunning_002
4894  * @tc.desc: Not passing in bundleName, unable to obtain application running status.
4895  * @tc.type: FUNC
4896  */
4897 HWTEST_F(AppMgrServiceInnerTest, IsApplicationRunning_002, TestSize.Level1)
4898 {
4899     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
4900     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4901     EXPECT_NE(appMgrServiceInner, nullptr);
4902     std::string bundleName = "com.is.hiserice";
4903     std::string processName = "test_processName";
4904     bool isRunning = false;
4905     auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
4906     EXPECT_NE(appRecord, nullptr);
4907     appMgrServiceInner->appRunningManager_->appRunningRecordMap_.emplace(recordId_, appRecord);
4908     int32_t ret = appMgrServiceInner->IsApplicationRunning(bundleName, isRunning);
4909     EXPECT_EQ(ret, ERR_OK);
4910     EXPECT_FALSE(isRunning);
4911 }
4912 
4913 /**
4914  * @tc.name: InitWindowVisibilityChangedListener_001
4915  * @tc.desc: init windowVisibilityChangedListener
4916  * @tc.type: FUNC
4917  */
4918 HWTEST_F(AppMgrServiceInnerTest, InitWindowVisibilityChangedListener_001, TestSize.Level1)
4919 {
4920     GTEST_LOG_(INFO) << "InitWindowVisibilityChangedListener_001 start" ;
4921     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4922     EXPECT_NE(appMgrServiceInner, nullptr);
4923 
4924     appMgrServiceInner->InitWindowVisibilityChangedListener();
4925     EXPECT_NE(appMgrServiceInner->windowVisibilityChangedListener_, nullptr);
4926     GTEST_LOG_(INFO) << "InitWindowVisibilityChangedListener_001 end";
4927 }
4928 
4929 /**
4930  * @tc.name: FreeWindowVisibilityChangedListener_001
4931  * @tc.desc: free windowVisibilityChangedListener
4932  * @tc.type: FUNC
4933  */
4934 HWTEST_F(AppMgrServiceInnerTest, FreeWindowVisibilityChangedListener_001, TestSize.Level1)
4935 {
4936     GTEST_LOG_(INFO) << "FreeWindowVisibilityChangedListener_001 start";
4937     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4938     EXPECT_NE(appMgrServiceInner, nullptr);
4939 
4940     appMgrServiceInner->FreeWindowVisibilityChangedListener();
4941     EXPECT_EQ(appMgrServiceInner->windowVisibilityChangedListener_, nullptr);
4942     GTEST_LOG_(INFO) << "FreeWindowVisibilityChangedListener_001 end";
4943 }
4944 
4945 /**
4946  * @tc.name: HandleWindowVisibilityChanged_001
4947  * @tc.desc: handle window visibility changed
4948  * @tc.type: FUNC
4949  */
4950 HWTEST_F(AppMgrServiceInnerTest, HandleWindowVisibilityChanged_001, TestSize.Level1)
4951 {
4952     GTEST_LOG_(INFO) << "HandleWindowVisibilityChanged_001 start";
4953     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4954     EXPECT_NE(appMgrServiceInner, nullptr);
4955 
4956     std::vector<sptr<Rosen::WindowVisibilityInfo>> visibilityInfos;
4957     appMgrServiceInner->HandleWindowVisibilityChanged(visibilityInfos);
4958     EXPECT_NE(appMgrServiceInner, nullptr);
4959     GTEST_LOG_(INFO) << "HandleWindowVisibilityChanged_001 end";
4960 }
4961 
4962 /**
4963  * @tc.name: InitWindowPidVisibilityChangedListener_001
4964  * @tc.desc: init windowPidVisibilityChangedListener
4965  * @tc.type: FUNC
4966  */
4967 HWTEST_F(AppMgrServiceInnerTest, InitWindowPidVisibilityChangedListener_001, TestSize.Level1)
4968 {
4969     GTEST_LOG_(INFO) << "InitWindowPidVisibilityChangedListener_001 start" ;
4970     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4971     EXPECT_NE(appMgrServiceInner, nullptr);
4972 
4973     appMgrServiceInner->FreeWindowPidVisibilityChangedListener();
4974     EXPECT_EQ(appMgrServiceInner->windowPidVisibilityChangedListener_, nullptr);
4975     appMgrServiceInner->InitWindowPidVisibilityChangedListener();
4976     EXPECT_NE(appMgrServiceInner->windowPidVisibilityChangedListener_, nullptr);
4977 
4978     std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler_ = nullptr;
4979     appMgrServiceInner->SetTaskHandler(taskHandler_);
4980     appMgrServiceInner->InitWindowPidVisibilityChangedListener();
4981     EXPECT_EQ(appMgrServiceInner->taskHandler_, nullptr);
4982     GTEST_LOG_(INFO) << "InitWindowPidVisibilityChangedListener_001 end";
4983 }
4984 
4985 /**
4986  * @tc.name: FreeWindowPidVisibilityChangedListener_001
4987  * @tc.desc: free windowPidVisibilityChangedListener
4988  * @tc.type: FUNC
4989  */
4990 HWTEST_F(AppMgrServiceInnerTest, FreeWindowPidVisibilityChangedListener_001, TestSize.Level1)
4991 {
4992     GTEST_LOG_(INFO) << "FreeWindowPidVisibilityChangedListener_001 start";
4993     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
4994     EXPECT_NE(appMgrServiceInner, nullptr);
4995 
4996     appMgrServiceInner->FreeWindowPidVisibilityChangedListener();
4997     EXPECT_EQ(appMgrServiceInner->windowPidVisibilityChangedListener_, nullptr);
4998 
4999     appMgrServiceInner->FreeWindowPidVisibilityChangedListener();
5000     GTEST_LOG_(INFO) << "FreeWindowPidVisibilityChangedListener_001 end";
5001 }
5002 
5003 /**
5004  * @tc.name: HandleWindowPidVisibilityChanged_001
5005  * @tc.desc: handle window pid visibility changed
5006  * @tc.type: FUNC
5007  */
5008 HWTEST_F(AppMgrServiceInnerTest, HandleWindowPidVisibilityChanged_001, TestSize.Level1)
5009 {
5010     GTEST_LOG_(INFO) << "HandleWindowPidVisibilityChanged_001 start";
5011     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5012     EXPECT_NE(appMgrServiceInner, nullptr);
5013 
5014     sptr<Rosen::WindowPidVisibilityInfo> windowPidVisibilityInfo;
5015     appMgrServiceInner->HandleWindowPidVisibilityChanged(windowPidVisibilityInfo);
5016     EXPECT_NE(appMgrServiceInner, nullptr);
5017     GTEST_LOG_(INFO) << "HandleWindowPidVisibilityChanged_001 end";
5018 }
5019 
5020 /**
5021  * @tc.name: IsAppRunning_001
5022  * @tc.desc: Obtain application running status through bundleName.
5023  * @tc.type: FUNC
5024  */
5025 HWTEST_F(AppMgrServiceInnerTest, IsAppRunning_001, TestSize.Level1)
5026 {
5027     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
5028     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5029     EXPECT_NE(appMgrServiceInner, nullptr);
5030     std::string bundleName = "com.is.hiserice";
5031     std::string processName = "test_processName";
5032     int32_t appCloneIndex = 0;
5033     bool isRunning = false;
5034     auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
5035     EXPECT_NE(appRecord, nullptr);
5036     appRecord->mainBundleName_ = "com.is.hiserice";
5037     appMgrServiceInner->appRunningManager_->appRunningRecordMap_.emplace(recordId_, appRecord);
5038     int32_t ret = appMgrServiceInner->IsAppRunning(bundleName, appCloneIndex, isRunning);
5039     EXPECT_EQ(ret, AAFwk::ERR_APP_CLONE_INDEX_INVALID);
5040     EXPECT_FALSE(isRunning);
5041 }
5042 
5043 /**
5044  * @tc.name: IsAppRunning_002
5045  * @tc.desc: Not passing in bundleName, unable to obtain application running status.
5046  * @tc.type: FUNC
5047  */
5048 HWTEST_F(AppMgrServiceInnerTest, IsAppRunning_002, TestSize.Level1)
5049 {
5050     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
5051     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5052     EXPECT_NE(appMgrServiceInner, nullptr);
5053     std::string bundleName = "com.is.hiserice";
5054     std::string processName = "test_processName";
5055     int32_t appCloneIndex = 0;
5056     bool isRunning = false;
5057     auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
5058     EXPECT_NE(appRecord, nullptr);
5059     appMgrServiceInner->appRunningManager_->appRunningRecordMap_.emplace(recordId_, appRecord);
5060     int32_t ret = appMgrServiceInner->IsAppRunning(bundleName, appCloneIndex, isRunning);
5061     EXPECT_EQ(ret, AAFwk::ERR_APP_CLONE_INDEX_INVALID);
5062     EXPECT_FALSE(isRunning);
5063 }
5064 
5065 /**
5066  * @tc.name: RegisterAbilityForegroundStateObserver_0100
5067  * @tc.desc: Verify it when observer is nullptr.
5068  * @tc.type: FUNC
5069  */
5070 HWTEST_F(AppMgrServiceInnerTest, RegisterAbilityForegroundStateObserver_0100, TestSize.Level2)
5071 {
5072     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5073     EXPECT_NE(appMgrServiceInner, nullptr);
5074     auto res = appMgrServiceInner->RegisterAbilityForegroundStateObserver(nullptr);
5075     EXPECT_EQ(res, ERR_INVALID_VALUE);
5076 }
5077 
5078 /**
5079  * @tc.name: UnregisterAbilityForegroundStateObserver_0100
5080  * @tc.desc: Verify it when observer is nullptr.
5081  * @tc.type: FUNC
5082  */
5083 HWTEST_F(AppMgrServiceInnerTest, UnregisterAbilityForegroundStateObserver_0100, TestSize.Level2)
5084 {
5085     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5086     EXPECT_NE(appMgrServiceInner, nullptr);
5087     auto res = appMgrServiceInner->UnregisterAbilityForegroundStateObserver(nullptr);
5088     EXPECT_EQ(res, ERR_INVALID_VALUE);
5089 }
5090 
5091 /**
5092  * @tc.name: RegisterAppForegroundStateObserver_0100
5093  * @tc.desc: Test the return when observer is nullptr.
5094  * @tc.type: FUNC
5095  */
5096 HWTEST_F(AppMgrServiceInnerTest, RegisterAppForegroundStateObserver_0100, TestSize.Level1)
5097 {
5098     sptr<IAppForegroundStateObserver> observer = nullptr;
5099     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5100     auto res = appMgrServiceInner->RegisterAppForegroundStateObserver(observer);
5101     EXPECT_EQ(ERR_INVALID_VALUE, res);
5102 }
5103 
5104 /**
5105  * @tc.name: UnregisterAppForegroundStateObserver_0100
5106  * @tc.desc: Test the return when observer is nullptr.
5107  * @tc.type: FUNC
5108  */
5109 HWTEST_F(AppMgrServiceInnerTest, UnregisterAppForegroundStateObserver_0100, TestSize.Level1)
5110 {
5111     sptr<IAppForegroundStateObserver> observer = nullptr;
5112     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5113     auto res = appMgrServiceInner->RegisterAppForegroundStateObserver(observer);
5114     EXPECT_EQ(ERR_INVALID_VALUE, res);
5115 }
5116 
5117 /**
5118  * @tc.name: RegisterStateStateObserver_0100
5119  * @tc.desc: Test unregister by nullptr.
5120  * @tc.type: FUNC
5121  */
5122 HWTEST_F(AppMgrServiceInnerTest, RegisterRenderStateObserver_0100, TestSize.Level1)
5123 {
5124     sptr<IRenderStateObserver> observer = nullptr;
5125     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5126     auto res = appMgrServiceInner->RegisterRenderStateObserver(observer);
5127     EXPECT_EQ(ERR_INVALID_VALUE, res);
5128 }
5129 
5130 /**
5131  * @tc.name: RegisterStateStateObserver_0200
5132  * @tc.desc: Test unregister without permission.
5133  * @tc.type: FUNC
5134  */
5135 HWTEST_F(AppMgrServiceInnerTest, RegisterRenderStateObserver_0200, TestSize.Level1)
5136 {
5137     AAFwk::IsMockSaCall::IsMockSaCallWithPermission();
5138     sptr<IRenderStateObserver> observer = new (std::nothrow) RenderStateObserverMock();
5139     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5140     auto res = appMgrServiceInner->RegisterRenderStateObserver(observer);
5141     EXPECT_EQ(ERR_OK, res);
5142 }
5143 
5144 /**
5145  * @tc.name: UnregisterRenderStateObserver_0100
5146  * @tc.desc: Test unregister by nullptr.
5147  * @tc.type: FUNC
5148  */
5149 HWTEST_F(AppMgrServiceInnerTest, UnregisterRenderStateObserver_0100, TestSize.Level1)
5150 {
5151     sptr<IRenderStateObserver> observer = nullptr;
5152     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5153     auto res = appMgrServiceInner->RegisterRenderStateObserver(observer);
5154     EXPECT_EQ(ERR_INVALID_VALUE, res);
5155 }
5156 
5157 /**
5158  * @tc.name: UnregisterRenderStateObserver_0200
5159  * @tc.desc: Test unregister without permission.
5160  * @tc.type: FUNC
5161  */
5162 HWTEST_F(AppMgrServiceInnerTest, UnregisterRenderStateObserver_0200, TestSize.Level1)
5163 {
5164     AAFwk::IsMockSaCall::IsMockSaCallWithPermission();
5165     sptr<IRenderStateObserver> observer = new (std::nothrow) RenderStateObserverMock();
5166     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5167     auto res = appMgrServiceInner->RegisterRenderStateObserver(observer);
5168     EXPECT_EQ(ERR_OK, res);
5169 }
5170 
5171 /**
5172  * @tc.name: GetAllUIExtensionRootHostPid_0100
5173  * @tc.desc: Get all ui extension root host pid.
5174  * @tc.type: FUNC
5175  */
5176 HWTEST_F(AppMgrServiceInnerTest, GetAllUIExtensionRootHostPid_0100, TestSize.Level1)
5177 {
5178     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
5179     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5180     ASSERT_NE(appMgrServiceInner, nullptr);
5181     pid_t pid = 0;
5182     std::vector<pid_t> hostPids;
5183     auto ret = appMgrServiceInner->GetAllUIExtensionRootHostPid(pid, hostPids);
5184     EXPECT_EQ(ret, ERR_OK);
5185 }
5186 
5187 /**
5188  * @tc.name: GetAllUIExtensionProviderPid_0100
5189  * @tc.desc: Get all ui extension provider pid.
5190  * @tc.type: FUNC
5191  */
5192 HWTEST_F(AppMgrServiceInnerTest, GetAllUIExtensionProviderPid_0100, TestSize.Level1)
5193 {
5194     AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission();
5195     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5196     ASSERT_NE(appMgrServiceInner, nullptr);
5197     pid_t hostPid = 0;
5198     std::vector<pid_t> providerPids;
5199     auto ret = appMgrServiceInner->GetAllUIExtensionProviderPid(hostPid, providerPids);
5200     EXPECT_EQ(ret, ERR_OK);
5201 }
5202 
5203 /**
5204  * @tc.name: AddUIExtensionLauncherItem_0100
5205  * @tc.desc: Add ui extension launcher item.
5206  * @tc.type: FUNC
5207  */
5208 HWTEST_F(AppMgrServiceInnerTest, AddUIExtensionLauncherItem_0100, TestSize.Level1)
5209 {
5210     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5211     ASSERT_NE(appMgrServiceInner, nullptr);
5212 
5213     std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
5214     ASSERT_NE(want, nullptr);
5215     want->SetParam("ability.want.params.uiExtensionAbilityId", 1);
5216     want->SetParam("ability.want.params.uiExtensionRootHostPid", 1000);
5217 
5218     std::shared_ptr<ApplicationInfo> appInfo = std::make_shared<ApplicationInfo>();
5219     ASSERT_NE(appInfo, nullptr);
5220     int32_t recordId = 0;
5221     std::string processName = "";
5222     std::shared_ptr<AppRunningRecord> appRecord = std::make_shared<AppRunningRecord>(appInfo, recordId, processName);
5223     ASSERT_NE(appRecord, nullptr);
5224     appRecord->GetPriorityObject()->SetPid(1001);
5225 
5226     sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
5227 
5228     appMgrServiceInner->AddUIExtensionLauncherItem(want, appRecord, token);
5229     // check want param has been erased.
5230     EXPECT_EQ(want->HasParameter("ability.want.params.uiExtensionAbilityId"), false);
5231     EXPECT_EQ(want->HasParameter("ability.want.params.uiExtensionRootHostPid"), false);
5232     appMgrServiceInner->RemoveUIExtensionLauncherItem(appRecord, token);
5233 }
5234 
5235 /**
5236  * @tc.name: PreloadApplication_0100
5237  * @tc.desc: Preload Application.
5238  * @tc.type: FUNC
5239  * @tc.Function: PreloadApplication
5240  * @tc.SubFunction: NA
5241  * @tc.EnvConditions: NA
5242  */
5243 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0100, TestSize.Level1)
5244 {
5245     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0100 start");
5246     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5247     ASSERT_NE(appMgrServiceInner, nullptr);
5248 
5249     std::string bundleName = "com.acts.preloadtest";
5250     int32_t userId = 100;
5251     PreloadMode preloadMode = PreloadMode::PRE_MAKE;
5252     int32_t appIndex = 0;
5253     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5254     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5255     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0100 end");
5256 }
5257 
5258 /**
5259  * @tc.name: PreloadApplication_0200
5260  * @tc.desc: Preload Application.
5261  * @tc.type: FUNC
5262  * @tc.Function: PreloadApplication
5263  * @tc.SubFunction: NA
5264  * @tc.EnvConditions: NA
5265  */
5266 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0200, TestSize.Level1)
5267 {
5268     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0200 start");
5269     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5270     ASSERT_NE(appMgrServiceInner, nullptr);
5271 
5272     std::string bundleName = "";
5273     int32_t userId = 100;
5274     PreloadMode preloadMode = PreloadMode::PRE_MAKE;
5275     int32_t appIndex = 0;
5276     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5277     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5278     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0200 end");
5279 }
5280 
5281 /**
5282  * @tc.name: PreloadApplication_0300
5283  * @tc.desc: Preload Application.
5284  * @tc.type: FUNC
5285  * @tc.Function: PreloadApplication
5286  * @tc.SubFunction: NA
5287  * @tc.EnvConditions: NA
5288  */
5289 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0300, TestSize.Level1)
5290 {
5291     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0300 start");
5292     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5293     ASSERT_NE(appMgrServiceInner, nullptr);
5294 
5295     std::string bundleName = "com.acts.preloadtest";
5296     int32_t userId = 100;
5297     PreloadMode preloadMode = PreloadMode::PRESS_DOWN;
5298     int32_t appIndex = 0;
5299     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5300     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5301     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0300 end");
5302 }
5303 
5304 /**
5305  * @tc.name: PreloadApplication_0400
5306  * @tc.desc: Preload Application.
5307  * @tc.type: FUNC
5308  * @tc.Function: PreloadApplication
5309  * @tc.SubFunction: NA
5310  * @tc.EnvConditions: NA
5311  */
5312 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0400, TestSize.Level1)
5313 {
5314     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0400 start");
5315     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5316     ASSERT_NE(appMgrServiceInner, nullptr);
5317 
5318     std::string bundleName = "";
5319     int32_t userId = 100;
5320     PreloadMode preloadMode = PreloadMode::PRESS_DOWN;
5321     int32_t appIndex = 0;
5322     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5323     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5324     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0400 end");
5325 }
5326 
5327 /**
5328  * @tc.name: PreloadApplication_0500
5329  * @tc.desc: Preload Application.
5330  * @tc.type: FUNC
5331  * @tc.Function: PreloadApplication
5332  * @tc.SubFunction: NA
5333  * @tc.EnvConditions: NA
5334  */
5335 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0500, TestSize.Level1)
5336 {
5337     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0500 start");
5338     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5339     ASSERT_NE(appMgrServiceInner, nullptr);
5340 
5341     std::string bundleName = "com.acts.preloadtest";
5342     int32_t userId = 1;
5343     PreloadMode preloadMode = PreloadMode::PRE_MAKE;
5344     int32_t appIndex = 0;
5345     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5346     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5347     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0500 end");
5348 }
5349 
5350 /**
5351  * @tc.name: PreloadApplication_0600
5352  * @tc.desc: Preload Application.
5353  * @tc.type: FUNC
5354  * @tc.Function: PreloadApplication
5355  * @tc.SubFunction: NA
5356  * @tc.EnvConditions: NA
5357  */
5358 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0600, TestSize.Level1)
5359 {
5360     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0600 start");
5361     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5362     ASSERT_NE(appMgrServiceInner, nullptr);
5363 
5364     std::string bundleName = "com.acts.preloadtest";
5365     int32_t userId = 1;
5366     PreloadMode preloadMode = PreloadMode::PRESS_DOWN;
5367     int32_t appIndex = 0;
5368     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5369     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5370     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0600 end");
5371 }
5372 
5373 /**
5374  * @tc.name: PreloadApplication_0700
5375  * @tc.desc: Preload Application.
5376  * @tc.type: FUNC
5377  * @tc.Function: PreloadApplication
5378  * @tc.SubFunction: NA
5379  * @tc.EnvConditions: NA
5380  */
5381 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0700, TestSize.Level1)
5382 {
5383     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0700 start");
5384     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5385     ASSERT_NE(appMgrServiceInner, nullptr);
5386 
5387     std::string bundleName = "";
5388     int32_t userId = 1;
5389     PreloadMode preloadMode = PreloadMode::PRE_MAKE;
5390     int32_t appIndex = 0;
5391     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5392     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5393     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0700 end");
5394 }
5395 
5396 /**
5397  * @tc.name: PreloadApplication_0800
5398  * @tc.desc: Preload Application.
5399  * @tc.type: FUNC
5400  * @tc.Function: PreloadApplication
5401  * @tc.SubFunction: NA
5402  * @tc.EnvConditions: NA
5403  */
5404 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0800, TestSize.Level1)
5405 {
5406     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0800 start");
5407     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5408     ASSERT_NE(appMgrServiceInner, nullptr);
5409 
5410     std::string bundleName = "";
5411     int32_t userId = 1;
5412     PreloadMode preloadMode = PreloadMode::PRESS_DOWN;
5413     int32_t appIndex = 0;
5414     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5415     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5416     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0800 end");
5417 }
5418 
5419 /**
5420  * @tc.name: PreloadApplication_0900
5421  * @tc.desc: Preload Application.
5422  * @tc.type: FUNC
5423  * @tc.Function: PreloadApplication
5424  * @tc.SubFunction: NA
5425  * @tc.EnvConditions: NA
5426  */
5427 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0900, TestSize.Level1)
5428 {
5429     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0900 start");
5430     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5431     ASSERT_NE(appMgrServiceInner, nullptr);
5432 
5433     std::string bundleName = "com.acts.preloadtest";
5434     int32_t userId = 0;
5435     PreloadMode preloadMode = PreloadMode::PRE_MAKE;
5436     int32_t appIndex = 1;
5437     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5438     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5439     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_0900 end");
5440 }
5441 
5442 /**
5443  * @tc.name: PreloadApplication_1000
5444  * @tc.desc: Preload Application.
5445  * @tc.type: FUNC
5446  * @tc.Function: PreloadApplication
5447  * @tc.SubFunction: NA
5448  * @tc.EnvConditions: NA
5449  */
5450 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_1000, TestSize.Level1)
5451 {
5452     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_1000 start");
5453     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5454     ASSERT_NE(appMgrServiceInner, nullptr);
5455 
5456     std::string bundleName = "";
5457     int32_t userId = 0;
5458     PreloadMode preloadMode = PreloadMode::PRE_MAKE;
5459     int32_t appIndex = 1;
5460     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5461     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5462     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_1000 end");
5463 }
5464 
5465 /**
5466  * @tc.name: PreloadApplication_1100
5467  * @tc.desc: Preload Application.
5468  * @tc.type: FUNC
5469  * @tc.Function: PreloadApplication
5470  * @tc.SubFunction: NA
5471  * @tc.EnvConditions: NA
5472  */
5473 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_1100, TestSize.Level1)
5474 {
5475     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_1100 start");
5476     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5477     ASSERT_NE(appMgrServiceInner, nullptr);
5478 
5479     std::string bundleName = "com.acts.preloadtest";
5480     int32_t userId = 0;
5481     PreloadMode preloadMode = PreloadMode::PRESS_DOWN;
5482     int32_t appIndex = 1;
5483     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5484     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5485     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_1100 end");
5486 }
5487 
5488 /**
5489  * @tc.name: PreloadApplication_1200
5490  * @tc.desc: Preload Application.
5491  * @tc.type: FUNC
5492  * @tc.Function: PreloadApplication
5493  * @tc.SubFunction: NA
5494  * @tc.EnvConditions: NA
5495  */
5496 HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_1200, TestSize.Level1)
5497 {
5498     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_1200 start");
5499     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5500     ASSERT_NE(appMgrServiceInner, nullptr);
5501 
5502     std::string bundleName = "";
5503     int32_t userId = 0;
5504     PreloadMode preloadMode = PreloadMode::PRESS_DOWN;
5505     int32_t appIndex = 1;
5506     int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
5507     EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
5508     TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_1200 end");
5509 }
5510 
5511 /**
5512  * @tc.name: LPreloadModuleFinished_0001
5513  * @tc.desc: PreloadModuleFinished
5514  * @tc.type: FUNC
5515  * @tc.Function: PreloadModuleFinished
5516  * @tc.SubFunction: NA
5517  * @tc.EnvConditions: NA
5518  */
5519 HWTEST_F(AppMgrServiceInnerTest, PreloadModuleFinished_0001, TestSize.Level1)
5520 {
5521     TAG_LOGI(AAFwkTag::TEST, "PreloadModuleFinished_0001 start");
5522     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5523     int32_t appRecord = 0;
5524 
5525     std::shared_ptr<MockTaskHandlerWrap> taskHandler = MockTaskHandlerWrap::CreateQueueHandler("app_mgr_tasks_queue");
5526     EXPECT_CALL(*taskHandler, SubmitTaskInner(_, _)).Times(AnyNumber());
5527     appMgrServiceInner->SetTaskHandler(taskHandler);
5528 
5529     appMgrServiceInner->PreloadModuleFinished(appRecord);
5530     TAG_LOGI(AAFwkTag::TEST, "PreloadModuleFinished_0001 end");
5531 }
5532 
5533 /**
5534  * @tc.name: SetSupportedProcessCacheSelf_001
5535  * @tc.desc: The application sets itself whether or not to support process cache.
5536  * @tc.type: FUNC
5537  */
5538 HWTEST_F(AppMgrServiceInnerTest, SetSupportedProcessCacheSelf_001, TestSize.Level2)
5539 {
5540     TAG_LOGI(AAFwkTag::TEST, "SetSupportedProcessCacheSelf_001 start");
5541     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5542     EXPECT_NE(appMgrServiceInner, nullptr);
5543 
5544     bool isSupported = false;
5545     EXPECT_EQ(appMgrServiceInner->SetSupportedProcessCacheSelf(isSupported), ERR_INVALID_VALUE);
5546 
5547     appMgrServiceInner->appRunningManager_ = nullptr;
5548     EXPECT_EQ(appMgrServiceInner->SetSupportedProcessCacheSelf(isSupported), ERR_NO_INIT);
5549 
5550     TAG_LOGI(AAFwkTag::TEST, "SetSupportedProcessCacheSelf_001 end");
5551 }
5552 
5553 /**
5554  * @tc.name: OnAppCacheStateChanged_001
5555  * @tc.desc: on application cache state changed.
5556  * @tc.type: FUNC
5557  */
5558 HWTEST_F(AppMgrServiceInnerTest, OnAppCacheStateChanged_001, TestSize.Level2)
5559 {
5560     TAG_LOGI(AAFwkTag::TEST, "OnAppCacheStateChanged_001 start");
5561     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5562     EXPECT_NE(appMgrServiceInner, nullptr);
5563 
5564     appMgrServiceInner->OnAppCacheStateChanged(nullptr, ApplicationState::APP_STATE_CACHED);
5565 
5566     std::string bundleName = "com.is.hiserice";
5567     std::string processName = "test_processName";
5568     bool isRunning = false;
5569     auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
5570     EXPECT_NE(appRecord, nullptr);
5571     appRecord->mainBundleName_ = "com.is.hiserice";
5572     appRecord->SetState(ApplicationState::APP_STATE_CACHED);
5573 
5574     appRecord->priorityObject_ = nullptr;
5575     appMgrServiceInner->OnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CACHED);
5576 
5577     appRecord->priorityObject_ = std::make_shared<PriorityObject>();
5578     appMgrServiceInner->OnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CACHED);
5579 
5580 
5581     TAG_LOGI(AAFwkTag::TEST, "OnAppCacheStateChanged_001 end");
5582 }
5583 
5584 /**
5585  * @tc.name: GetRunningMultiAppInfoByBundleName_001
5586  * @tc.desc: Get multiApp information list by bundleName.
5587  * @tc.type: FUNC
5588  * @tc.require: issueI9HMAO
5589  */
5590 HWTEST_F(AppMgrServiceInnerTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1)
5591 {
5592     TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_001 start");
5593     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5594     EXPECT_NE(appMgrServiceInner, nullptr);
5595 
5596     std::string bundleName = "testBundleName";
5597     RunningMultiAppInfo info;
5598     int32_t ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info);
5599     EXPECT_NE(ret, ERR_OK);
5600 
5601     appMgrServiceInner->remoteClientManager_ = nullptr;
5602     ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info);
5603     EXPECT_EQ(ret, ERR_INVALID_VALUE);
5604 
5605     TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_001 end");
5606 }
5607 
5608 /**
5609  * @tc.name: GetRunningMultiAppInfoByBundleName_002
5610  * @tc.desc: Get multiApp information list by bundleName.
5611  * @tc.type: FUNC
5612  * @tc.require: issueI9HMAO
5613  */
5614 HWTEST_F(AppMgrServiceInnerTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Level1)
5615 {
5616     TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_002 start");
5617     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5618     EXPECT_NE(appMgrServiceInner, nullptr);
5619 
5620     std::string bundleName = "";
5621     RunningMultiAppInfo info;
5622     int32_t ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info);
5623     EXPECT_EQ(ret, AAFwk::INVALID_PARAMETERS_ERR);
5624 
5625     TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_002 end");
5626 }
5627 
5628 /**
5629  * @tc.name: GetAllRunningInstanceKeysBySelf_001
5630  * @tc.desc: GetAllRunningInstanceKeysBySelf.
5631  * @tc.type: FUNC
5632  * @tc.require: issueI9HMAO
5633  */
5634 HWTEST_F(AppMgrServiceInnerTest, GetAllRunningInstanceKeysBySelf_001, TestSize.Level1)
5635 {
5636     TAG_LOGI(AAFwkTag::TEST, "GetAllRunningInstanceKeysBySelf_001 start");
5637     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5638     EXPECT_NE(appMgrServiceInner, nullptr);
5639 
5640     std::vector<std::string> instanceKeys;
5641     int32_t ret = appMgrServiceInner->GetAllRunningInstanceKeysBySelf(instanceKeys);
5642     EXPECT_NE(ret, ERR_OK);
5643 
5644     appMgrServiceInner->remoteClientManager_ = nullptr;
5645     ret = appMgrServiceInner->GetAllRunningInstanceKeysBySelf(instanceKeys);
5646     EXPECT_EQ(ret, ERR_NO_INIT);
5647 
5648     appMgrServiceInner->remoteClientManager_ = std::make_shared<RemoteClientManager>();
5649     ret = appMgrServiceInner->GetAllRunningInstanceKeysBySelf(instanceKeys);
5650     EXPECT_NE(ret, ERR_NO_INIT);
5651 
5652     TAG_LOGI(AAFwkTag::TEST, "GetAllRunningInstanceKeysBySelf_001 end");
5653 }
5654 
5655 /**
5656  * @tc.name: GetAllRunningInstanceKeysByBundleName_001
5657  * @tc.desc: GetAllRunningInstanceKeysByBundleName.
5658  * @tc.type: FUNC
5659  * @tc.require: issueI9HMAO
5660  */
5661 HWTEST_F(AppMgrServiceInnerTest, GetAllRunningInstanceKeysByBundleName_001, TestSize.Level1)
5662 {
5663     TAG_LOGI(AAFwkTag::TEST, "GetAllRunningInstanceKeysByBundleName_001 start");
5664     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5665     EXPECT_NE(appMgrServiceInner, nullptr);
5666 
5667     std::string bundleName = "testBundleName";
5668     std::vector<std::string> instanceKeys;
5669     int32_t ret = appMgrServiceInner->GetAllRunningInstanceKeysByBundleName(bundleName, instanceKeys);
5670     EXPECT_NE(ret, ERR_OK);
5671 
5672     TAG_LOGI(AAFwkTag::TEST, "GetAllRunningInstanceKeysByBundleName_001 end");
5673 }
5674 
5675 /**
5676  * @tc.name: SendCreateAtomicServiceProcessEvent_001
5677  * @tc.desc: Report event of create atomic service process.
5678  * @tc.type: FUNC
5679  */
5680 HWTEST_F(AppMgrServiceInnerTest, SendCreateAtomicServiceProcessEvent_001, TestSize.Level1)
5681 {
5682     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5683     EXPECT_NE(appMgrServiceInner, nullptr);
5684     std::string processName = "test_processName";
5685     std::string moduleName = "test_modulenName";
5686     std::string abilityName = "test_abilityName";
5687     auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
5688     auto bundleType = BundleType::ATOMIC_SERVICE;
5689     auto ret = appMgrServiceInner->SendCreateAtomicServiceProcessEvent(nullptr, bundleType, moduleName, abilityName);
5690     EXPECT_EQ(ret, false);
5691     ret = appMgrServiceInner->SendCreateAtomicServiceProcessEvent(appRecord, bundleType, moduleName, abilityName);
5692     EXPECT_EQ(ret, true);
5693     bundleType = BundleType::APP;
5694     ret = appMgrServiceInner->SendCreateAtomicServiceProcessEvent(appRecord, bundleType, moduleName, abilityName);
5695     EXPECT_EQ(ret, false);
5696 }
5697 
5698 /**
5699  * @tc.name: AttachedToStatusBar_001
5700  * @tc.desc: Attach one ability to status bar.
5701  * @tc.type: FUNC
5702  */
5703 HWTEST_F(AppMgrServiceInnerTest, AttachedToStatusBar_001, TestSize.Level1)
5704 {
5705     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5706     EXPECT_NE(appMgrServiceInner, nullptr);
5707 
5708     appMgrServiceInner->AttachedToStatusBar(nullptr);
5709 
5710     OHOS::sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
5711     appMgrServiceInner->AttachedToStatusBar(token);
5712 
5713     BundleInfo bundleInfo;
5714     HapModuleInfo hapModuleInfo;
5715     std::shared_ptr<AAFwk::Want> want;
5716     std::string processName = "test_processName";
5717     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
5718     loadParam->token = token;
5719     std::shared_ptr<AppRunningRecord> appRecord = appMgrServiceInner->CreateAppRunningRecord(loadParam,
5720     applicationInfo_, abilityInfo_, processName, bundleInfo, hapModuleInfo, want);
5721     EXPECT_NE(appRecord, nullptr);
5722     appMgrServiceInner->AttachedToStatusBar(token);
5723 }
5724 
5725 /**
5726  * @tc.name: BlockProcessCacheByPids_001
5727  * @tc.desc: Block process cache feature using pids.
5728  * @tc.type: FUNC
5729  */
5730 HWTEST_F(AppMgrServiceInnerTest, BlockProcessCacheByPids_001, TestSize.Level1)
5731 {
5732     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5733     EXPECT_NE(appMgrServiceInner, nullptr);
5734 
5735     BundleInfo info;
5736     std::string processName = "test_processName";
5737     auto record =
5738         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
5739     std::shared_ptr<PriorityObject> priorityObject = std::make_shared<PriorityObject>();
5740     EXPECT_NE(priorityObject, nullptr);
5741     std::string callerBundleName = "callerBundleName";
5742     priorityObject->SetPid(2);
5743     record->priorityObject_ = priorityObject;
5744     record->mainBundleName_ = callerBundleName;
5745     record->SetCallerPid(1);
5746 
5747     std::vector<int32_t> pids{2};
5748     appMgrServiceInner->BlockProcessCacheByPids(pids);
5749 }
5750 
5751 /**
5752  * @tc.name: GetSupportedProcessCachePids_001
5753  * @tc.desc: Get pids of processes which belong to specific bundle name and support process cache feature.
5754  * @tc.type: FUNC
5755  * @tc.require: issueI76JBF
5756  */
5757 HWTEST_F(AppMgrServiceInnerTest, GetSupportedProcessCachePids_001, TestSize.Level2)
5758 {
5759     TAG_LOGI(AAFwkTag::TEST, "GetSupportedProcessCachePids_001 start");
5760     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5761     EXPECT_NE(appMgrServiceInner, nullptr);
5762 
5763     std::string bundleName = "testBundleName";
5764     std::vector<int32_t> pidList;
5765     int32_t ret = appMgrServiceInner->GetSupportedProcessCachePids(bundleName, pidList);
5766     EXPECT_EQ(ret, ERR_OK);
5767 
5768     appMgrServiceInner->appRunningManager_ = nullptr;
5769     ret = appMgrServiceInner->GetSupportedProcessCachePids(bundleName, pidList);
5770     EXPECT_NE(ret, ERR_OK);
5771 
5772     TAG_LOGI(AAFwkTag::TEST, "GetSupportedProcessCachePids_001 end");
5773 }
5774 
5775 /**
5776  * @tc.name: RegisterKiaInterceptor_001
5777  * @tc.desc: verify RegisterKiaInterceptor.
5778  * @tc.type: FUNC
5779  */
5780 HWTEST_F(AppMgrServiceInnerTest, RegisterKiaInterceptor_001, TestSize.Level2)
5781 {
5782     TAG_LOGI(AAFwkTag::TEST, "RegisterKiaInterceptor_001 start");
5783     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5784     EXPECT_NE(appMgrServiceInner, nullptr);
5785 
5786     sptr<IKiaInterceptor> interceptor = new MockKiaInterceptor();
5787     appMgrServiceInner->RegisterKiaInterceptor(interceptor);
5788 
5789     TAG_LOGI(AAFwkTag::TEST, "RegisterKiaInterceptor_001 end");
5790 }
5791 
5792 /**
5793  * @tc.name: CheckIsKiaProcess_001
5794  * @tc.desc: verify CheckIsKiaProcess.
5795  * @tc.type: FUNC
5796  */
5797 HWTEST_F(AppMgrServiceInnerTest, CheckIsKiaProcess_001, TestSize.Level2)
5798 {
5799     TAG_LOGI(AAFwkTag::TEST, "CheckIsKiaProcess_001 start");
5800     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5801     EXPECT_NE(appMgrServiceInner, nullptr);
5802 
5803     pid_t pid = 1234;
5804     bool isKia = false;
5805     appMgrServiceInner->CheckIsKiaProcess(pid, isKia);
5806 
5807     TAG_LOGI(AAFwkTag::TEST, "CheckIsKiaProcess_001 end");
5808 }
5809 
5810 /**
5811  * @tc.name: SetJITPermissions_001
5812  * @tc.desc: set jit permissions.
5813  * @tc.type: FUNC
5814  */
5815 HWTEST_F(AppMgrServiceInnerTest, SetJITPermissions_001, TestSize.Level2)
5816 {
5817     TAG_LOGI(AAFwkTag::TEST, "SetJITPermissions_001 start");
5818     uint32_t accessTokenId = 0;
5819     AppSpawnStartMsg startMsg = {0};
5820     std::vector<std::string> permissionsList;
5821     AppspawnUtil::SetJITPermissions(accessTokenId, permissionsList);
5822     EXPECT_EQ(permissionsList.size(), 0);
5823     TAG_LOGI(AAFwkTag::TEST, "SetJITPermissions_001 end");
5824 }
5825 
5826 /**
5827  * @tc.name: SendAppSpawnUninstallDebugHapMsg_001
5828  * @tc.desc: SendAppSpawnUninstallDebugHapMsg
5829  * @tc.type: FUNC
5830  */
5831 HWTEST_F(AppMgrServiceInnerTest, SendAppSpawnUninstallDebugHapMsg_001, TestSize.Level2)
5832 {
5833     TAG_LOGI(AAFwkTag::TEST, "SendAppSpawnUninstallDebugHapMsg_001 start");
5834     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5835     EXPECT_NE(appMgrServiceInner, nullptr);
5836     appMgrServiceInner->SendAppSpawnUninstallDebugHapMsg(0);
5837     TAG_LOGI(AAFwkTag::TEST, "SendAppSpawnUninstallDebugHapMsg_001 end");
5838 }
5839 
5840 /**
5841  * @tc.name: DoAllProcessExitCallback_001
5842  * @tc.desc: DoAllProcessExitCallback
5843  * @tc.type: FUNC
5844  */
5845 HWTEST_F(AppMgrServiceInnerTest, DoAllProcessExitCallback_001, TestSize.Level2)
5846 {
5847     TAG_LOGI(AAFwkTag::TEST, "DoAllProcessExitCallback_001 start");
5848     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5849     EXPECT_NE(appMgrServiceInner, nullptr);
5850     std::list<SimpleProcessInfo> processInfos;
5851     int32_t userId = 100;
5852     sptr<AAFwk::IUserCallback> callback = nullptr;
5853     int64_t startTime = 0;
5854     auto ret = appMgrServiceInner->DoAllProcessExitCallback(processInfos, userId, callback, startTime);
5855     EXPECT_FALSE(ret);
5856     TAG_LOGI(AAFwkTag::TEST, "DoAllProcessExitCallback_001 end");
5857 }
5858 
5859 /**
5860  * @tc.name: DoAllProcessExitCallback_002
5861  * @tc.desc: DoAllProcessExitCallback
5862  * @tc.type: FUNC
5863  */
5864 HWTEST_F(AppMgrServiceInnerTest, DoAllProcessExitCallback_002, TestSize.Level2)
5865 {
5866     TAG_LOGI(AAFwkTag::TEST, "DoAllProcessExitCallback_002 start");
5867     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5868     EXPECT_NE(appMgrServiceInner, nullptr);
5869     std::list<SimpleProcessInfo> processInfos;
5870     int32_t userId = 100;
5871     sptr<AAFwk::IUserCallback> callback = new MockIUserCallback();
5872     int64_t startTime = 0;
5873     auto ret = appMgrServiceInner->DoAllProcessExitCallback(processInfos, userId, callback, startTime);
5874     EXPECT_FALSE(ret);
5875     TAG_LOGI(AAFwkTag::TEST, "DoAllProcessExitCallback_002 end");
5876 }
5877 
5878 /**
5879  * @tc.name: IsProcessCacheSupported_001
5880  * @tc.desc: IsProcessCacheSupported.
5881  * @tc.type: FUNC
5882  */
5883 HWTEST_F(AppMgrServiceInnerTest, IsProcessCacheSupported_001, TestSize.Level2)
5884 {
5885     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5886     EXPECT_NE(appMgrServiceInner, nullptr);
5887 
5888     int32_t pid = 1;
5889     bool isSupport = false;
5890     EXPECT_EQ(appMgrServiceInner->IsProcessCacheSupported(pid, isSupport), AAFwk::ERR_NO_APP_RECORD);
5891 
5892     appMgrServiceInner->appRunningManager_ = nullptr;
5893     EXPECT_EQ(appMgrServiceInner->IsProcessCacheSupported(pid, isSupport), AAFwk::ERR_NULL_APP_RUNNING_MANAGER);
5894 }
5895 
5896 /**
5897  * @tc.name: SetProcessCacheEnable_001
5898  * @tc.desc: SetProcessCacheEnable.
5899  * @tc.type: FUNC
5900  */
5901 HWTEST_F(AppMgrServiceInnerTest, SetProcessCacheEnable_001, TestSize.Level2)
5902 {
5903     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5904     EXPECT_NE(appMgrServiceInner, nullptr);
5905 
5906     int32_t pid = 1;
5907     bool enable = false;
5908     EXPECT_EQ(appMgrServiceInner->SetProcessCacheEnable(pid, enable), AAFwk::ERR_NO_APP_RECORD);
5909 
5910     appMgrServiceInner->appRunningManager_ = nullptr;
5911     EXPECT_EQ(appMgrServiceInner->SetProcessCacheEnable(pid, enable), AAFwk::ERR_NULL_APP_RUNNING_MANAGER);
5912 }
5913 
5914 /**
5915  * @tc.name: ReportEventToRSS_001
5916  * @tc.desc: test ReportEventToRSS
5917  * @tc.type: FUNC
5918  */
5919 HWTEST_F(AppMgrServiceInnerTest, ReportEventToRSS_001, TestSize.Level1)
5920 {
5921     TAG_LOGI(AAFwkTag::TEST, "ReportEventToRSS_001 start");
5922     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5923     AbilityInfo abilityInfo;
5924     std::string temp = "";
5925     std::shared_ptr<ApplicationInfo> info = std::make_shared<ApplicationInfo>();
5926     auto appRecord = std::make_shared<AppRunningRecord>(info, 0, temp);
5927     appMgrServiceInner->taskHandler_ = nullptr;
5928     appMgrServiceInner->ReportEventToRSS(abilityInfo, appRecord);
5929     EXPECT_EQ(appRecord->GetPid(), 0);
5930     appMgrServiceInner->ReportEventToRSS(abilityInfo, nullptr);
5931 
5932     appRecord->priorityObject_->SetPid(FUN_TEST_PID);
5933     appMgrServiceInner->ReportEventToRSS(abilityInfo, nullptr);
5934     EXPECT_EQ(appRecord->GetPid(), FUN_TEST_PID);
5935     TAG_LOGI(AAFwkTag::TEST, "ReportEventToRSS_001 end");
5936 }
5937 
5938 /**
5939  * @tc.name: CreateAppRunningRecord_0001
5940  * @tc.desc: launch application.
5941  * @tc.type: FUNC
5942  * @tc.require: issueI5W4S7
5943  */
5944 HWTEST_F(AppMgrServiceInnerTest, CreateAppRunningRecord_0001, TestSize.Level1)
5945 {
5946     TAG_LOGI(AAFwkTag::TEST, "CreateAppRunningRecord_0001 start");
5947     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5948     EXPECT_NE(appMgrServiceInner, nullptr);
5949 
5950     appMgrServiceInner->LaunchApplication(nullptr);
5951 
5952     BundleInfo info;
5953     std::string processName = "test_processName";
5954     std::shared_ptr<AppRunningRecord> appRecord =
5955         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
5956 
5957     ASSERT_NE(appRecord, nullptr);
5958 }
5959 
5960 /**
5961  * @tc.name: GetSpecifiedProcessFlag_0001
5962  * @tc.desc: Verify that GetSpecifiedProcessFlag returns the correct flag when AbilityInfo is a UIExtension and
5963  * isolationProcess is true.
5964  * @tc.type: FUNC
5965  */
5966 HWTEST_F(AppMgrServiceInnerTest, GetSpecifiedProcessFlag_0001, TestSize.Level1)
5967 {
5968     AbilityInfo abilityInfo;
5969     abilityInfo.type = AbilityType::PAGE;
5970     abilityInfo.isStageBasedModel = false;
5971     abilityInfo.isolationProcess = true;
5972     abilityInfo.extensionAbilityType = ExtensionAbilityType::SYS_COMMON_UI;
5973 
5974     AAFwk::Want want;
5975     std::string flag = "uiext_flag";
5976     want.SetParam("ohoSpecifiedProcessFlag", flag);
5977     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5978     std::string result = appMgrServiceInner->GetSpecifiedProcessFlag(abilityInfo, want);
5979     EXPECT_EQ(result, flag);
5980 }
5981 
5982 /**
5983  * @tc.name: GetSpecifiedProcessFlag_0002
5984  * @tc.desc: Verify that GetSpecifiedProcessFlag returns an empty string when AbilityInfo does not meet the conditions.
5985  * @tc.type: FUNC
5986  */
5987 HWTEST_F(AppMgrServiceInnerTest, GetSpecifiedProcessFlag_0002, TestSize.Level1)
5988 {
5989     AbilityInfo abilityInfo;
5990     abilityInfo.type = AbilityType::PAGE;
5991     abilityInfo.isStageBasedModel = false;
5992     abilityInfo.isolationProcess = false;
5993     abilityInfo.extensionAbilityType = ExtensionAbilityType::UNSPECIFIED;
5994 
5995     AAFwk::Want want;
5996     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
5997     std::string result = appMgrServiceInner->GetSpecifiedProcessFlag(abilityInfo, want);
5998     EXPECT_EQ(result, "");
5999 }
6000 
6001 /**
6002  * @tc.name: GetSpecifiedProcessFlag_0003
6003  * @tc.desc: Verify that GetSpecifiedProcessFlag returns an empty string when the flag is set in the want but
6004  * AbilityInfo does not meet the conditions.
6005  * @tc.type: FUNC
6006  */
6007 HWTEST_F(AppMgrServiceInnerTest, GetSpecifiedProcessFlag_0003, TestSize.Level1)
6008 {
6009     AbilityInfo abilityInfo;
6010     abilityInfo.type = AbilityType::PAGE;
6011     abilityInfo.isStageBasedModel = false;
6012     abilityInfo.isolationProcess = false;
6013     abilityInfo.extensionAbilityType = ExtensionAbilityType::UNSPECIFIED;
6014     AAFwk::Want want;
6015     std::string flag = "uiext_flag";
6016     want.SetParam("ohoSpecifiedProcessFlag", flag);
6017 
6018     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
6019     std::string result = appMgrServiceInner->GetSpecifiedProcessFlag(abilityInfo, want);
6020     EXPECT_EQ(result, "");
6021 }
6022 
6023 /**
6024  * @tc.name: GetSpecifiedProcessFlag_0004
6025  * @tc.desc: Verify that GetSpecifiedProcessFlag returns an empty string when AbilityInfo is a UIExtension and
6026  * isolationProcess is false, even if the flag is set in want.
6027  * @tc.type: FUNC
6028  */
6029 HWTEST_F(AppMgrServiceInnerTest, GetSpecifiedProcessFlag_0004, TestSize.Level1)
6030 {
6031     AbilityInfo abilityInfo;
6032     abilityInfo.type = AbilityType::PAGE;
6033     abilityInfo.isStageBasedModel = false;
6034     abilityInfo.isolationProcess = false;
6035     abilityInfo.extensionAbilityType = ExtensionAbilityType::SYS_COMMON_UI;
6036 
6037     AAFwk::Want want;
6038     std::string flag = "uiext_flag";
6039     want.SetParam("ohoSpecifiedProcessFlag", flag);
6040     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
6041     std::string result = appMgrServiceInner->GetSpecifiedProcessFlag(abilityInfo, want);
6042     EXPECT_EQ(result, "");
6043 }
6044 
6045 /**
6046  * @tc.name: AfterLoadAbility_0001
6047  * @tc.desc: AfterLoadAbility
6048  * @tc.type: FUNC
6049  */
6050 HWTEST_F(AppMgrServiceInnerTest, AfterLoadAbility_0001, TestSize.Level1)
6051 {
6052     TAG_LOGI(AAFwkTag::TEST, "AfterLoadAbility_0001 start");
6053     auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
6054     EXPECT_NE(appMgrServiceInner, nullptr);
6055     BundleInfo info;
6056     std::string processName = "test_processName";
6057     std::shared_ptr<AppRunningRecord> appRecord =
6058         appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info, "");
6059     AbilityInfo abilityInfo;
6060     abilityInfo.visible = true;
6061     abilityInfo.applicationName = "hiUiextension";
6062     abilityInfo.type = AbilityType::EXTENSION;
6063     abilityInfo.name = "UiextensionAbility";
6064     abilityInfo.bundleName = "com.ix.hiuiextension";
6065     abilityInfo.moduleName = "entry";
6066     abilityInfo.deviceId = "device";
6067     abilityInfo.extensionAbilityType = ExtensionAbilityType::SYS_COMMON_UI;
6068     std::shared_ptr<AbilityInfo> abilityInfoSptr = std::make_shared<AbilityInfo>(abilityInfo);
6069     auto loadParam = std::make_shared<AbilityRuntime::LoadParam>();
6070     appMgrServiceInner->taskHandler_ = nullptr;
6071     appMgrServiceInner->AfterLoadAbility(appRecord, abilityInfoSptr, loadParam);
6072     ASSERT_NE(appRecord, nullptr);
6073 }
6074 } // namespace AppExecFwk
6075 } // namespace OHOS
6076