1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17
18 #define private public
19 #define protected public
20 #include "ability_manager_service.h"
21 #include "ability_connect_manager.h"
22 #include "ability_connection.h"
23 #include "ability_start_setting.h"
24 #include "recovery_param.h"
25 #undef private
26 #undef protected
27
28 #include "ability_manager_errors.h"
29 #include "ability_info.h"
30 #include "connection_observer_errors.h"
31 #include "free_install_manager.h"
32 #include "hilog_tag_wrapper.h"
33 #include "session/host/include/session.h"
34 #include "scene_board_judgement.h"
35 #include "uri.h"
36
37 using namespace testing;
38 using namespace testing::ext;
39 using namespace OHOS::AppExecFwk;
40 using OHOS::AppExecFwk::AbilityType;
41 using OHOS::AppExecFwk::ExtensionAbilityType;
42 namespace OHOS {
43 namespace AAFwk {
44 namespace {
45 const int32_t USER_ID_U100 = 100;
46 const int32_t APP_MEMORY_SIZE = 512;
47 const uint32_t TOKENID = 211;
48 const std::string SESSIONID = "sessionId";
49 const std::string APPID = "1003";
50 const int REQUESTCODE = 10;
51 } // namespace
52 class AbilityManagerServiceThirdTest : public testing::Test {
53 public:
54 static void SetUpTestCase();
55 static void TearDownTestCase();
56 void SetUp();
57 void TearDown();
58
59 std::shared_ptr<AbilityRecord> MockAbilityRecord(AbilityType);
60 sptr<Token> MockToken(AbilityType);
61
62 AbilityRequest GenerateAbilityRequest(const std::string& deviceName, const std::string& abilityName,
63 const std::string& appName, const std::string& bundleName, const std::string& moduleName);
64
65 public:
66 AbilityRequest abilityRequest_{};
67 Want want_{};
68 };
69
GenerateAbilityRequest(const std::string & deviceName,const std::string & abilityName,const std::string & appName,const std::string & bundleName,const std::string & moduleName)70 AbilityRequest AbilityManagerServiceThirdTest::GenerateAbilityRequest(const std::string& deviceName,
71 const std::string& abilityName, const std::string& appName, const std::string& bundleName,
72 const std::string& moduleName)
73 {
74 ElementName element(deviceName, bundleName, abilityName, moduleName);
75 want_.SetElement(element);
76
77 AbilityInfo abilityInfo;
78 abilityInfo.visible = true;
79 abilityInfo.applicationName = appName;
80 abilityInfo.type = AbilityType::EXTENSION;
81 abilityInfo.name = abilityName;
82 abilityInfo.bundleName = bundleName;
83 abilityInfo.moduleName = moduleName;
84 abilityInfo.deviceId = deviceName;
85 ApplicationInfo appinfo;
86 appinfo.name = appName;
87 appinfo.bundleName = bundleName;
88 abilityInfo.applicationInfo = appinfo;
89 AbilityRequest abilityRequest;
90 abilityRequest.want = want_;
91 abilityRequest.abilityInfo = abilityInfo;
92 abilityRequest.appInfo = appinfo;
93
94 return abilityRequest;
95 }
96
SetUpTestCase()97 void AbilityManagerServiceThirdTest::SetUpTestCase() {}
98
TearDownTestCase()99 void AbilityManagerServiceThirdTest::TearDownTestCase() {}
100
SetUp()101 void AbilityManagerServiceThirdTest::SetUp() {}
102
TearDown()103 void AbilityManagerServiceThirdTest::TearDown() {}
104
MockAbilityRecord(AbilityType abilityType)105 std::shared_ptr<AbilityRecord> AbilityManagerServiceThirdTest::MockAbilityRecord(AbilityType abilityType)
106 {
107 AbilityRequest abilityRequest;
108 abilityRequest.appInfo.bundleName = "com.test.demo";
109 abilityRequest.abilityInfo.name = "MainAbility";
110 abilityRequest.abilityInfo.type = abilityType;
111 return AbilityRecord::CreateAbilityRecord(abilityRequest);
112 }
113
MockToken(AbilityType abilityType)114 sptr<Token> AbilityManagerServiceThirdTest::MockToken(AbilityType abilityType)
115 {
116 std::shared_ptr<AbilityRecord> abilityRecord = MockAbilityRecord(abilityType);
117 if (!abilityRecord) {
118 return nullptr;
119 }
120 return abilityRecord->GetToken();
121 }
122
123 /*
124 * Feature: AbilityManagerService
125 * Function: HandleActiveTimeOut
126 * SubFunction: NA
127 * FunctionPoints: AbilityManagerService HandleActiveTimeOut
128 */
129 HWTEST_F(AbilityManagerServiceThirdTest, HandleActiveTimeOut_001, TestSize.Level1)
130 {
131 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest HandleActiveTimeOut_001 start");
132 auto abilityMs_ = std::make_shared<AbilityManagerService>();
133 ASSERT_NE(abilityMs_, nullptr);
134 abilityMs_->HandleActiveTimeOut(100);
135 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest HandleActiveTimeOut_001 end");
136 }
137
138 /*
139 * Feature: AbilityManagerService
140 * Function: HandleInactiveTimeOut
141 * SubFunction: NA
142 * FunctionPoints: AbilityManagerService HandleInactiveTimeOut
143 */
144 HWTEST_F(AbilityManagerServiceThirdTest, HandleInactiveTimeOut_001, TestSize.Level1)
145 {
146 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest HandleInactiveTimeOut_001 start");
147 auto abilityMs_ = std::make_shared<AbilityManagerService>();
148 ASSERT_NE(abilityMs_, nullptr);
149 abilityMs_->HandleInactiveTimeOut(100);
150 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest HandleInactiveTimeOut_001 end");
151 }
152
153 /*
154 * Feature: AbilityManagerService
155 * Function: VerificationToken
156 * SubFunction: NA
157 * FunctionPoints: AbilityManagerService VerificationToken
158 */
159 HWTEST_F(AbilityManagerServiceThirdTest, VerificationToken_001, TestSize.Level1)
160 {
161 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest VerificationToken_001 start");
162 auto abilityMs_ = std::make_shared<AbilityManagerService>();
163 EXPECT_FALSE(abilityMs_->VerificationToken(nullptr));
164 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest VerificationToken_001 end");
165 }
166
167 /*
168 * Feature: AbilityManagerService
169 * Function: VerificationAllToken
170 * SubFunction: NA
171 * FunctionPoints: AbilityManagerService VerificationAllToken
172 */
173 HWTEST_F(AbilityManagerServiceThirdTest, VerificationAllToken_001, TestSize.Level1)
174 {
175 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest VerificationAllToken_001 start");
176 auto abilityMs_ = std::make_shared<AbilityManagerService>();
177 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
178 abilityMs_->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
179 EXPECT_FALSE(abilityMs_->VerificationAllToken(nullptr));
180 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest VerificationAllToken_001 end");
181 }
182
183 /*
184 * Feature: AbilityManagerService
185 * Function: GetDataAbilityManager
186 * SubFunction: NA
187 * FunctionPoints: AbilityManagerService GetDataAbilityManager
188 */
189 HWTEST_F(AbilityManagerServiceThirdTest, GetDataAbilityManager_001, TestSize.Level1)
190 {
191 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityManager_001 start");
192 auto abilityMs_ = std::make_shared<AbilityManagerService>();
193 EXPECT_EQ(abilityMs_->GetDataAbilityManager(nullptr), nullptr);
194 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityManager_001 end");
195 }
196
197 /*
198 * Feature: AbilityManagerService
199 * Function: GetMissionListManagerByUserId
200 * SubFunction: NA
201 * FunctionPoints: AbilityManagerService GetMissionListManagerByUserId
202 */
203 HWTEST_F(AbilityManagerServiceThirdTest, GetListManagerByUserId_001, TestSize.Level1)
204 {
205 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetListManagerByUserId_001 start");
206 auto abilityMs_ = std::make_shared<AbilityManagerService>();
207 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
208 EXPECT_EQ(abilityMs_->GetMissionListManagerByUserId(100), nullptr);
209
210 auto temp = abilityMs_->subManagersHelper_->missionListManagers_;
211 abilityMs_->subManagersHelper_->missionListManagers_.clear();
212 EXPECT_EQ(abilityMs_->GetMissionListManagerByUserId(100).get(), nullptr);
213 abilityMs_->subManagersHelper_->missionListManagers_ = temp;
214 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetListManagerByUserId_001 end");
215 }
216
217 /*
218 * Feature: AbilityManagerService
219 * Function: GetDataAbilityManagerByUserId
220 * SubFunction: NA
221 * FunctionPoints: AbilityManagerService GetDataAbilityManagerByUserId
222 */
223 HWTEST_F(AbilityManagerServiceThirdTest, GetDataAbilityManagerByUserId_001, TestSize.Level1)
224 {
225 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityManagerByUserId_001 start");
226 auto abilityMs_ = std::make_shared<AbilityManagerService>();
227 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
228 EXPECT_EQ(abilityMs_->GetDataAbilityManagerByUserId(100), nullptr);
229
230 auto temp = abilityMs_->subManagersHelper_->dataAbilityManagers_;
231 abilityMs_->subManagersHelper_->dataAbilityManagers_.clear();
232 EXPECT_EQ(abilityMs_->GetDataAbilityManagerByUserId(100).get(), nullptr);
233 abilityMs_->subManagersHelper_->dataAbilityManagers_ = temp;
234 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityManagerByUserId_001 end");
235 }
236
237 /*
238 * Feature: AbilityManagerService
239 * Function: GetConnectManagerByToken
240 * SubFunction: NA
241 * FunctionPoints: AbilityManagerService GetConnectManagerByToken
242 */
243 HWTEST_F(AbilityManagerServiceThirdTest, GetConnectManagerByToken_001, TestSize.Level1)
244 {
245 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetConnectManagerByToken_001 start");
246 auto abilityMs_ = std::make_shared<AbilityManagerService>();
247 EXPECT_EQ(abilityMs_->GetConnectManagerByToken(nullptr), nullptr);
248 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetConnectManagerByToken_001 end");
249 }
250
251 /*
252 * Feature: AbilityManagerService
253 * Function: GetDataAbilityManagerByToken
254 * SubFunction: NA
255 * FunctionPoints: AbilityManagerService GetDataAbilityManagerByToken
256 */
257 HWTEST_F(AbilityManagerServiceThirdTest, GetDataAbilityManagerByToken_001, TestSize.Level1)
258 {
259 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityManagerByToken_001 start");
260 auto abilityMs_ = std::make_shared<AbilityManagerService>();
261 EXPECT_EQ(abilityMs_->GetDataAbilityManagerByToken(nullptr), nullptr);
262 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityManagerByToken_001 end");
263 }
264
265 /*
266 * Feature: AbilityManagerService
267 * Function: ConnectBmsService
268 * SubFunction: NA
269 * FunctionPoints: AbilityManagerService ConnectBmsService
270 */
271 HWTEST_F(AbilityManagerServiceThirdTest, ConnectBmsService_001, TestSize.Level1)
272 {
273 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ConnectBmsService_001 start");
274 auto abilityMs_ = std::make_shared<AbilityManagerService>();
275 ASSERT_NE(abilityMs_, nullptr);
276 abilityMs_->ConnectBmsService();
277 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ConnectBmsService_001 end");
278 }
279
280 /*
281 * Feature: AbilityManagerService
282 * Function: GetWantSenderInfo
283 * SubFunction: NA
284 * FunctionPoints: AbilityManagerService GetWantSenderInfo
285 */
286 HWTEST_F(AbilityManagerServiceThirdTest, GetWantSenderInfo_001, TestSize.Level1)
287 {
288 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetWantSenderInfo_001 start");
289 auto abilityMs_ = std::make_shared<AbilityManagerService>();
290 std::shared_ptr<WantSenderInfo> info;
291 EXPECT_EQ(abilityMs_->GetWantSenderInfo(nullptr, info), ERR_INVALID_VALUE);
292 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetWantSenderInfo_001 end");
293 }
294
295 /*
296 * Feature: AbilityManagerService
297 * Function: GetAppMemorySize
298 * SubFunction: NA
299 * FunctionPoints: AbilityManagerService GetAppMemorySize
300 */
301 HWTEST_F(AbilityManagerServiceThirdTest, GetAppMemorySize_001, TestSize.Level1)
302 {
303 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetAppMemorySize_001 start");
304 auto abilityMs_ = std::make_shared<AbilityManagerService>();
305 EXPECT_EQ(abilityMs_->GetAppMemorySize(), APP_MEMORY_SIZE);
306 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetAppMemorySize_001 end");
307 }
308
309 /*
310 * Feature: AbilityManagerService
311 * Function: IsRamConstrainedDevice
312 * SubFunction: NA
313 * FunctionPoints: AbilityManagerService IsRamConstrainedDevice
314 */
315 HWTEST_F(AbilityManagerServiceThirdTest, IsRamConstrainedDevice_001, TestSize.Level1)
316 {
317 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsRamConstrainedDevice_001 start");
318 auto abilityMs_ = std::make_shared<AbilityManagerService>();
319 EXPECT_FALSE(abilityMs_->IsRamConstrainedDevice());
320 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsRamConstrainedDevice_001 end");
321 }
322
323 /*
324 * Feature: AbilityManagerService
325 * Function: GetMissionSaveTime
326 * SubFunction: NA
327 * FunctionPoints: AbilityManagerService GetMissionSaveTime
328 */
329 HWTEST_F(AbilityManagerServiceThirdTest, GetMissionSaveTime_001, TestSize.Level1)
330 {
331 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetMissionSaveTime_001 start");
332 auto abilityMs_ = std::make_shared<AbilityManagerService>();
333 EXPECT_NE(AmsConfigurationParameter::GetInstance().GetMissionSaveTime(), 0);
334 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetMissionSaveTime_001 end");
335 }
336
337 /*
338 * Feature: AbilityManagerService
339 * Function: GetAbilityTokenByMissionId
340 * SubFunction: NA
341 * FunctionPoints: AbilityManagerService GetAbilityTokenByMissionId
342 */
343 HWTEST_F(AbilityManagerServiceThirdTest, GetAbilityTokenByMissionId_001, TestSize.Level1)
344 {
345 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetAbilityTokenByMissionId_001 start");
346 auto abilityMs_ = std::make_shared<AbilityManagerService>();
347 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
348 EXPECT_EQ(abilityMs_->GetAbilityTokenByMissionId(100), nullptr);
349
350 auto temp = abilityMs_->subManagersHelper_->currentMissionListManager_;
351 abilityMs_->subManagersHelper_->currentMissionListManager_.reset();
352 EXPECT_EQ(abilityMs_->GetAbilityTokenByMissionId(100), nullptr);
353 abilityMs_->subManagersHelper_->currentMissionListManager_ = temp;
354 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetAbilityTokenByMissionId_001 end");
355 }
356
357 /*
358 * Feature: AbilityManagerService
359 * Function: StartRemoteAbilityByCall
360 * SubFunction: NA
361 * FunctionPoints: AbilityManagerService StartRemoteAbilityByCall
362 */
363 HWTEST_F(AbilityManagerServiceThirdTest, StartRemoteAbilityByCall_001, TestSize.Level1)
364 {
365 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartRemoteAbilityByCall_001 start");
366 auto abilityMs_ = std::make_shared<AbilityManagerService>();
367 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
368 abilityMs_->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
369 Want want;
370 EXPECT_EQ(abilityMs_->StartRemoteAbilityByCall(want, nullptr, nullptr), ERR_INVALID_VALUE);
371 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartRemoteAbilityByCall_001 end");
372 }
373
374 /*
375 * Feature: AbilityManagerService
376 * Function: ReleaseRemoteAbility
377 * SubFunction: NA
378 * FunctionPoints: AbilityManagerService ReleaseRemoteAbility
379 */
380 HWTEST_F(AbilityManagerServiceThirdTest, ReleaseRemoteAbility_001, TestSize.Level1)
381 {
382 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReleaseRemoteAbility_001 start");
383 auto abilityMs_ = std::make_shared<AbilityManagerService>();
384 AppExecFwk::ElementName element;
385 EXPECT_EQ(abilityMs_->ReleaseRemoteAbility(nullptr, element), ERR_NULL_OBJECT);
386 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReleaseRemoteAbility_001 end");
387 }
388
389 /*
390 * Feature: AbilityManagerService
391 * Function: ReleaseCall
392 * SubFunction: NA
393 * FunctionPoints: AbilityManagerService ReleaseCall
394 */
395 HWTEST_F(AbilityManagerServiceThirdTest, ReleaseCall_001, TestSize.Level1)
396 {
397 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReleaseCall_001 start");
398 auto abilityMs_ = std::make_shared<AbilityManagerService>();
399 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
400 abilityMs_->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
401 AppExecFwk::ElementName element;
402 EXPECT_EQ(abilityMs_->ReleaseCall(nullptr, element), ERR_INVALID_VALUE);
403 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReleaseCall_001 end");
404 }
405
406 /*
407 * Feature: AbilityManagerService
408 * Function: JudgeAbilityVisibleControl
409 * SubFunction: NA
410 * FunctionPoints: AbilityManagerService JudgeAbilityVisibleControl
411 */
412 HWTEST_F(AbilityManagerServiceThirdTest, JudgeAbilityVisibleControl_001, TestSize.Level1)
413 {
414 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest JudgeAbilityVisibleControl_001 start");
415 auto abilityMs_ = std::make_shared<AbilityManagerService>();
416 AppExecFwk::AbilityInfo abilityInfo;
417 abilityInfo.visible = true;
418 EXPECT_EQ(abilityMs_->JudgeAbilityVisibleControl(abilityInfo), ERR_OK);
419
420 abilityInfo.visible = false;
421 EXPECT_EQ(abilityMs_->JudgeAbilityVisibleControl(abilityInfo), ERR_OK);
422
423 abilityInfo.applicationInfo.accessTokenId = IPCSkeleton::GetCallingTokenID();
424 EXPECT_EQ(abilityMs_->JudgeAbilityVisibleControl(abilityInfo), ERR_OK);
425
426 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest JudgeAbilityVisibleControl_001 end");
427 }
428
429 /*
430 * Feature: AbilityManagerService
431 * Function: OnAcceptWantResponse
432 * SubFunction: NA
433 * FunctionPoints: AbilityManagerService OnAcceptWantResponse
434 */
435 HWTEST_F(AbilityManagerServiceThirdTest, OnAcceptWantResponse_001, TestSize.Level1)
436 {
437 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest OnAcceptWantResponse_001 start");
438 auto abilityMs_ = std::make_shared<AbilityManagerService>();
439 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
440 abilityMs_->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
441 AAFwk::Want want;
442 ASSERT_NE(abilityMs_, nullptr);
443 abilityMs_->OnAcceptWantResponse(want, "test");
444
445 auto temp = abilityMs_->subManagersHelper_->currentMissionListManager_;
446 abilityMs_->subManagersHelper_->currentMissionListManager_.reset();
447 abilityMs_->OnAcceptWantResponse(want, "test");
448 abilityMs_->subManagersHelper_->currentMissionListManager_ = temp;
449 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest OnAcceptWantResponse_001 end");
450 }
451
452 /*
453 * Feature: AbilityManagerService
454 * Function: OnStartSpecifiedAbilityTimeoutResponse
455 * SubFunction: NA
456 * FunctionPoints: AbilityManagerService OnStartSpecifiedAbilityTimeoutResponse
457 */
458 HWTEST_F(AbilityManagerServiceThirdTest, OnStartSpecifiedAbilityTimeoutResponse_001, TestSize.Level1)
459 {
460 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest OnStartSpecifiedAbilityTimeoutResponse_001 start");
461 auto abilityMs_ = std::make_shared<AbilityManagerService>();
462 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
463 AAFwk::Want want;
464 ASSERT_NE(abilityMs_, nullptr);
465 abilityMs_->OnStartSpecifiedAbilityTimeoutResponse(want);
466
467 auto temp = abilityMs_->subManagersHelper_->currentMissionListManager_;
468 abilityMs_->subManagersHelper_->currentMissionListManager_.reset();
469 abilityMs_->OnStartSpecifiedAbilityTimeoutResponse(want);
470 abilityMs_->subManagersHelper_->currentMissionListManager_ = temp;
471 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest OnStartSpecifiedAbilityTimeoutResponse_001 end");
472 }
473
474 /*
475 * Feature: AbilityManagerService
476 * Function: GetAbilityRunningInfos
477 * SubFunction: NA
478 * FunctionPoints: AbilityManagerService GetAbilityRunningInfos
479 */
480 HWTEST_F(AbilityManagerServiceThirdTest, GetAbilityRunningInfos_001, TestSize.Level1)
481 {
482 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetAbilityRunningInfos_001 start");
483 auto abilityMs_ = std::make_shared<AbilityManagerService>();
484 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
485 abilityMs_->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
486 std::vector<AbilityRunningInfo> info;
487 if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
488 EXPECT_NE(abilityMs_->GetAbilityRunningInfos(info), ERR_OK);
489
490 auto temp1 = abilityMs_->subManagersHelper_->currentMissionListManager_;
491 abilityMs_->subManagersHelper_->currentMissionListManager_.reset();
492 EXPECT_EQ(abilityMs_->GetAbilityRunningInfos(info), ERR_INVALID_VALUE);
493 abilityMs_->subManagersHelper_->currentMissionListManager_ = temp1;
494
495 auto temp2 = abilityMs_->subManagersHelper_->currentConnectManager_;
496 abilityMs_->subManagersHelper_->currentConnectManager_.reset();
497 EXPECT_NE(abilityMs_->GetAbilityRunningInfos(info), ERR_OK);
498 abilityMs_->subManagersHelper_->currentConnectManager_ = temp2;
499
500 auto temp3 = abilityMs_->subManagersHelper_->currentDataAbilityManager_;
501 abilityMs_->subManagersHelper_->currentDataAbilityManager_.reset();
502 EXPECT_NE(abilityMs_->GetAbilityRunningInfos(info), ERR_OK);
503 abilityMs_->subManagersHelper_->currentDataAbilityManager_ = temp3;
504 }
505 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetAbilityRunningInfos_001 end");
506 }
507
508 /*
509 * Feature: AbilityManagerService
510 * Function: GetExtensionRunningInfos
511 * SubFunction: NA
512 * FunctionPoints: AbilityManagerService GetExtensionRunningInfos
513 */
514 HWTEST_F(AbilityManagerServiceThirdTest, GetExtensionRunningInfos_001, TestSize.Level1)
515 {
516 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetExtensionRunningInfos_001 start");
517 auto abilityMs_ = std::make_shared<AbilityManagerService>();
518 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
519 std::vector<AAFwk::ExtensionRunningInfo> extensionRunningInfo;
520 EXPECT_NE(abilityMs_->GetExtensionRunningInfos(10, extensionRunningInfo), ERR_OK);
521
522 auto temp = abilityMs_->subManagersHelper_->currentConnectManager_;
523 abilityMs_->subManagersHelper_->currentConnectManager_.reset();
524 EXPECT_EQ(abilityMs_->GetExtensionRunningInfos(10, extensionRunningInfo), ERR_INVALID_VALUE);
525 abilityMs_->subManagersHelper_->currentConnectManager_ = temp;
526 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetExtensionRunningInfos_001 end");
527 }
528
529 /*
530 * Feature: AbilityManagerService
531 * Function: GetProcessRunningInfos
532 * SubFunction: NA
533 * FunctionPoints: AbilityManagerService GetProcessRunningInfos
534 */
535 HWTEST_F(AbilityManagerServiceThirdTest, GetProcessRunningInfos_001, TestSize.Level1)
536 {
537 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetProcessRunningInfos_001 start");
538 auto abilityMs_ = std::make_shared<AbilityManagerService>();
539 std::vector<AppExecFwk::RunningProcessInfo> info;
540 EXPECT_EQ(abilityMs_->GetProcessRunningInfos(info), ERR_OK);
541 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetProcessRunningInfos_001 end");
542 }
543
544 /*
545 * Feature: AbilityManagerService
546 * Function: GetProcessRunningInfosByUserId
547 * SubFunction: NA
548 * FunctionPoints: AbilityManagerService GetProcessRunningInfosByUserId
549 */
550 HWTEST_F(AbilityManagerServiceThirdTest, GetProcessRunningInfosByUserId_001, TestSize.Level1)
551 {
552 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetProcessRunningInfosByUserId_001 start");
553 auto abilityMs_ = std::make_shared<AbilityManagerService>();
554 std::vector<AppExecFwk::RunningProcessInfo> info;
555 EXPECT_NE(abilityMs_->GetProcessRunningInfosByUserId(info, 100), INNER_ERR);
556 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetProcessRunningInfosByUserId_001 end");
557 }
558
559 /*
560 * Feature: AbilityManagerService
561 * Function: ClearUserData
562 * SubFunction: NA
563 * FunctionPoints: AbilityManagerService ClearUserData
564 */
565 HWTEST_F(AbilityManagerServiceThirdTest, ClearUserData_001, TestSize.Level1)
566 {
567 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ClearUserData_001 start");
568 auto abilityMs_ = std::make_shared<AbilityManagerService>();
569 ASSERT_NE(abilityMs_, nullptr);
570 abilityMs_->ClearUserData(100);
571 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ClearUserData_001 end");
572 }
573
574 /*
575 * Feature: AbilityManagerService
576 * Function: CallRequestDone
577 * SubFunction: NA
578 * FunctionPoints: AbilityManagerService CallRequestDone
579 */
580 HWTEST_F(AbilityManagerServiceThirdTest, CallRequestDone_001, TestSize.Level1)
581 {
582 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CallRequestDone_001 start");
583 auto abilityMs_ = std::make_shared<AbilityManagerService>();
584 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
585 abilityMs_->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
586 sptr<IRemoteObject> token = nullptr;
587 sptr<IRemoteObject> callStub = nullptr;
588 ASSERT_NE(abilityMs_, nullptr);
589 abilityMs_->CallRequestDone(token, callStub);
590 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CallRequestDone_001 end");
591 }
592
593 /*
594 * Feature: AbilityManagerService
595 * Function: UpdateMissionSnapShot
596 * SubFunction: NA
597 * FunctionPoints: AbilityManagerService UpdateMissionSnapShot
598 */
599 HWTEST_F(AbilityManagerServiceThirdTest, UpdateMissionSnapShot_001, TestSize.Level1)
600 {
601 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest UpdateMissionSnapShot_001 start");
602 auto abilityMs_ = std::make_shared<AbilityManagerService>();
603 auto pixelMap = std::shared_ptr<Media::PixelMap>();
604 MissionSnapshot missionSnapshot;
605 ASSERT_NE(abilityMs_, nullptr);
606 abilityMs_->UpdateMissionSnapShot(nullptr, pixelMap);
607 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest UpdateMissionSnapShot_001 end");
608 }
609
610 /*
611 * Feature: AbilityManagerService
612 * Function: GetRemoteMissionSnapshotInfo
613 * SubFunction: NA
614 * FunctionPoints: AbilityManagerService GetRemoteMissionSnapshotInfo
615 */
616 HWTEST_F(AbilityManagerServiceThirdTest, GetRemoteMissionSnapshotInfo_001, TestSize.Level1)
617 {
618 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetRemoteMissionSnapshotInfo_001 start");
619 auto abilityMs_ = std::make_shared<AbilityManagerService>();
620 MissionSnapshot missionSnapshot;
621 EXPECT_EQ(abilityMs_->GetRemoteMissionSnapshotInfo("", 1, missionSnapshot), ERR_NULL_OBJECT);
622 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetRemoteMissionSnapshotInfo_001 end");
623 }
624
625 /*
626 * Feature: AbilityManagerService
627 * Function: GetValidUserId
628 * SubFunction: NA
629 * FunctionPoints: AbilityManagerService GetValidUserId
630 */
631 HWTEST_F(AbilityManagerServiceThirdTest, GetValidUserId_001, TestSize.Level1)
632 {
633 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetValidUserId_001 start");
634 auto abilityMs_ = std::make_shared<AbilityManagerService>();
635 MissionSnapshot missionSnapshot;
636 EXPECT_EQ(abilityMs_->GetValidUserId(100), 100);
637 EXPECT_EQ(abilityMs_->GetValidUserId(0), 0);
638 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetValidUserId_001 end");
639 }
640
641 /*
642 * Feature: AbilityManagerService
643 * Function: IsRunningInStabilityTest
644 * SubFunction: NA
645 * FunctionPoints: AbilityManagerService IsRunningInStabilityTest
646 */
647 HWTEST_F(AbilityManagerServiceThirdTest, IsRunningInStabilityTest_001, TestSize.Level1)
648 {
649 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsRunningInStabilityTest_001 start");
650 auto abilityMs_ = std::make_shared<AbilityManagerService>();
651 abilityMs_->controllerIsAStabilityTest_ = false;
652 EXPECT_FALSE(abilityMs_->IsRunningInStabilityTest());
653 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsRunningInStabilityTest_001 end");
654 }
655
656 #ifdef ABILITY_COMMAND_FOR_TEST
657 /*
658 * Feature: AbilityManagerService
659 * Function: ForceTimeoutForTest
660 * SubFunction: NA
661 * FunctionPoints: AbilityManagerService ForceTimeoutForTest
662 */
663 HWTEST_F(AbilityManagerServiceThirdTest, ForceTimeoutForTest_001, TestSize.Level1)
664 {
665 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ForceTimeoutForTest_001 start");
666 auto abilityMs_ = std::make_shared<AbilityManagerService>();
667 EXPECT_EQ(abilityMs_->ForceTimeoutForTest("", ""), INVALID_DATA);
668 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("clean", ""), ERR_OK);
669 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("INITIAL", ""), ERR_OK);
670 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("INACTIVE", ""), ERR_OK);
671 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("FOREGROUND", ""), ERR_OK);
672 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("BACKGROUND", ""), ERR_OK);
673 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("TERMINATING", ""), ERR_OK);
674 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("COMMAND", ""), ERR_OK);
675 EXPECT_TRUE(abilityMs_->ForceTimeoutForTest("test", ""), INVALID_DATA);
676 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ForceTimeoutForTest_001 end");
677 }
678 #endif
679
680 /*
681 * Feature: AbilityManagerService
682 * Function: JudgeMultiUserConcurrency
683 * SubFunction: NA
684 * FunctionPoints: AbilityManagerService JudgeMultiUserConcurrency
685 */
686 HWTEST_F(AbilityManagerServiceThirdTest, JudgeMultiUserConcurrency_001, TestSize.Level1)
687 {
688 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest JudgeMultiUserConcurrency_001 start");
689 auto abilityMs_ = std::make_shared<AbilityManagerService>();
690 EXPECT_TRUE(abilityMs_->JudgeMultiUserConcurrency(0));
691
692 auto temp = abilityMs_->userController_;
693 abilityMs_->userController_ = nullptr;
694 EXPECT_FALSE(abilityMs_->JudgeMultiUserConcurrency(100));
695 abilityMs_->userController_ = temp;
696 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest JudgeMultiUserConcurrency_001 end");
697 }
698
699 /*
700 * Feature: AbilityManagerService
701 * Function: CheckWindowMode
702 * SubFunction: NA
703 * FunctionPoints: AbilityManagerService CheckWindowMode
704 */
705 HWTEST_F(AbilityManagerServiceThirdTest, CheckWindowMode_001, TestSize.Level1)
706 {
707 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CheckWindowMode_001 start");
708 auto abilityMs_ = std::make_shared<AbilityManagerService>();
709 auto windowMode = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED;
710 std::vector<AppExecFwk::SupportWindowMode> windowModes;
711 EXPECT_TRUE(abilityMs_->CheckWindowMode(windowMode, windowModes));
712
713 windowMode = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FULLSCREEN;
714 EXPECT_FALSE(abilityMs_->CheckWindowMode(windowMode, windowModes));
715 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CheckWindowMode_001 end");
716 }
717
718 /*
719 * Feature: AbilityManagerService
720 * Function: IsNeedTimeoutForTest
721 * SubFunction: NA
722 * FunctionPoints: AbilityManagerService IsNeedTimeoutForTest
723 */
724 HWTEST_F(AbilityManagerServiceThirdTest, IsNeedTimeoutForTest_001, TestSize.Level1)
725 {
726 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsNeedTimeoutForTest_001 start");
727 auto abilityMs_ = std::make_shared<AbilityManagerService>();
728 EXPECT_FALSE(abilityMs_->IsNeedTimeoutForTest("", ""));
729 abilityMs_->timeoutMap_.insert({"state", "abilityName"});
730 EXPECT_TRUE(abilityMs_->IsNeedTimeoutForTest("abilityName", "state"));
731 abilityMs_->timeoutMap_.clear();
732 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsNeedTimeoutForTest_001 end");
733 }
734
735 /*
736 * Feature: AbilityManagerService
737 * Function: GetValidDataAbilityUri
738 * SubFunction: NA
739 * FunctionPoints: AbilityManagerService GetValidDataAbilityUri
740 */
741 HWTEST_F(AbilityManagerServiceThirdTest, GetValidDataAbilityUri_001, TestSize.Level1)
742 {
743 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetValidDataAbilityUri_001 start");
744 auto abilityMs_ = std::make_shared<AbilityManagerService>();
745 std::string adjustUri;
746 EXPECT_FALSE(abilityMs_->GetValidDataAbilityUri("test", adjustUri));
747
748 EXPECT_TRUE(abilityMs_->GetValidDataAbilityUri("//test", adjustUri));
749 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetValidDataAbilityUri_001 end");
750 }
751
752 /*
753 * Feature: AbilityManagerService
754 * Function: GetDataAbilityUri
755 * SubFunction: NA
756 * FunctionPoints: AbilityManagerService GetDataAbilityUri
757 */
758 HWTEST_F(AbilityManagerServiceThirdTest, GetDataAbilityUri_001, TestSize.Level1)
759 {
760 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityUri_001 start");
761 auto abilityMs_ = std::make_shared<AbilityManagerService>();
762 std::vector<AppExecFwk::AbilityInfo> abilityInfos;
763 std::string uri;
764 EXPECT_FALSE(abilityMs_->GetDataAbilityUri(abilityInfos, "", uri));
765 EXPECT_FALSE(abilityMs_->GetDataAbilityUri(abilityInfos, "test", uri));
766
767 AppExecFwk::AbilityInfo abilityInfo;
768 abilityInfos.push_back(abilityInfo);
769 EXPECT_FALSE(abilityMs_->GetDataAbilityUri(abilityInfos, "", uri));
770
771 abilityInfo.type = AbilityType::DATA;
772 abilityInfo.name = "test";
773 EXPECT_FALSE(abilityMs_->GetDataAbilityUri(abilityInfos, "test", uri));
774 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetDataAbilityUri_001 end");
775 }
776
777 /**
778 * @tc.number: ReportDrawnCompleted_002
779 * @tc.name: ReportDrawnCompleted
780 * @tc.desc: After passing in a callerToken with parameter nullptr, INNER_ERR is returned
781 */
782 HWTEST_F(AbilityManagerServiceThirdTest, ReportDrawnCompleted_002, TestSize.Level1)
783 {
784 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReportDrawnCompleted_002 start");
785 auto abilityMs_ = std::make_shared<AbilityManagerService>();
786 sptr<IRemoteObject> callerToken = nullptr;
787 EXPECT_EQ(abilityMs_->ReportDrawnCompleted(callerToken), INNER_ERR);
788 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReportDrawnCompleted_002 end");
789 }
790
791 /*
792 * Feature: AbilityManagerService
793 * Function: CreateVerificationInfo
794 * SubFunction: NA
795 * FunctionPoints: AbilityManagerService CreateVerificationInfo
796 */
797 HWTEST_F(AbilityManagerServiceThirdTest, CreateVerificationInfo_001, TestSize.Level1)
798 {
799 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CreateVerificationInfo_001 start");
800 auto abilityMs_ = std::make_shared<AbilityManagerService>();
801 AbilityRequest abilityRequest;
802 abilityMs_->whiteListassociatedWakeUpFlag_ = false;
803 EXPECT_FALSE(abilityMs_->CreateVerificationInfo(abilityRequest).associatedWakeUp);
804
805 abilityMs_->whiteListassociatedWakeUpFlag_ = true;
806 abilityRequest.appInfo.bundleName = "com.ohos.settingsdata";
807 EXPECT_TRUE(abilityMs_->CreateVerificationInfo(abilityRequest).associatedWakeUp);
808
809 abilityRequest.appInfo.bundleName = "test";
810 abilityRequest.appInfo.associatedWakeUp = false;
811 EXPECT_FALSE(abilityMs_->CreateVerificationInfo(abilityRequest).associatedWakeUp);
812 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CreateVerificationInfo_001 end");
813 }
814
815 /*
816 * Feature: AbilityManagerService
817 * Function: StartUser
818 * SubFunction: NA
819 * FunctionPoints: AbilityManagerService StartUser
820 */
821 HWTEST_F(AbilityManagerServiceThirdTest, StartUser_001, TestSize.Level1)
822 {
823 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartUser_001 start");
824 auto abilityMs_ = std::make_shared<AbilityManagerService>();
825 EXPECT_EQ(abilityMs_->StartUser(USER_ID_U100, nullptr), CHECK_PERMISSION_FAILED);
826 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartUser_001 end");
827 }
828
829 /*
830 * Feature: AbilityManagerService
831 * Function: StopUser
832 * SubFunction: NA
833 * FunctionPoints: AbilityManagerService StopUser
834 */
835 HWTEST_F(AbilityManagerServiceThirdTest, StopUser_001, TestSize.Level1)
836 {
837 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StopUser_001 start");
838 auto abilityMs_ = std::make_shared<AbilityManagerService>();
839 EXPECT_EQ(abilityMs_->StopUser(USER_ID_U100, nullptr), CHECK_PERMISSION_FAILED);
840 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StopUser_001 end");
841 }
842
843 /*
844 * Feature: AbilityManagerService
845 * Function: GetStartUpNewRuleFlag
846 * SubFunction: NA
847 * FunctionPoints: AbilityManagerService GetStartUpNewRuleFlag
848 */
849 HWTEST_F(AbilityManagerServiceThirdTest, GetStartUpNewRuleFlag_001, TestSize.Level1)
850 {
851 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetStartUpNewRuleFlag_001 start");
852 auto abilityMs_ = std::make_shared<AbilityManagerService>();
853 EXPECT_EQ(abilityMs_->GetStartUpNewRuleFlag(), abilityMs_->startUpNewRule_);
854 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetStartUpNewRuleFlag_001 end");
855 }
856
857 /*
858 * Feature: AbilityManagerService
859 * Function: IsCrossUserCall
860 * SubFunction: NA
861 * FunctionPoints: AbilityManagerService IsCrossUserCall
862 */
863 HWTEST_F(AbilityManagerServiceThirdTest, IsCrossUserCall_001, TestSize.Level1)
864 {
865 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsCrossUserCall_001 start");
866 auto abilityMs_ = std::make_shared<AbilityManagerService>();
867 int32_t userId = -1;
868 EXPECT_EQ(abilityMs_->IsCrossUserCall(userId), false);
869 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsCrossUserCall_001 end");
870 }
871
872 /*
873 * Feature: AbilityManagerService
874 * Function: IsCrossUserCall
875 * SubFunction: NA
876 * FunctionPoints: AbilityManagerService IsCrossUserCall
877 */
878 HWTEST_F(AbilityManagerServiceThirdTest, IsCrossUserCall_002, TestSize.Level1)
879 {
880 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsCrossUserCall_002 start");
881 auto abilityMs_ = std::make_shared<AbilityManagerService>();
882 int32_t userId = 0;
883 EXPECT_EQ(abilityMs_->IsCrossUserCall(userId), false);
884 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsCrossUserCall_002 end");
885 }
886
887 /*
888 * Feature: AbilityManagerService
889 * Function: IsCrossUserCall
890 * SubFunction: NA
891 * FunctionPoints: AbilityManagerService IsCrossUserCall
892 */
893 HWTEST_F(AbilityManagerServiceThirdTest, IsCrossUserCall_003, TestSize.Level1)
894 {
895 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsCrossUserCall_003 start");
896 auto abilityMs_ = std::make_shared<AbilityManagerService>();
897 int32_t userId = 10;
898 EXPECT_EQ(abilityMs_->IsCrossUserCall(userId), true);
899 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsCrossUserCall_003 end");
900 }
901
902 /*
903 * Feature: AbilityManagerService
904 * Function: IsValidMissionIds
905 * SubFunction: NA
906 * FunctionPoints: AbilityManagerService IsValidMissionIds
907 */
908 HWTEST_F(AbilityManagerServiceThirdTest, IsValidMissionIds_001, TestSize.Level1)
909 {
910 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsValidMissionIds_001 start");
911 auto abilityMs_ = std::make_shared<AbilityManagerService>();
912 std::vector<int32_t> missionIds;
913 std::vector<MissionValidResult> results;
914 EXPECT_EQ(abilityMs_->IsValidMissionIds(missionIds, results), ERR_INVALID_VALUE);
915 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest IsValidMissionIds_001 end");
916 }
917
918 /*
919 * Feature: AbilityManagerService
920 * Function: CheckUIExtensionIsFocused
921 * SubFunction: NA
922 * FunctionPoints: AbilityManagerService CheckUIExtensionIsFocused
923 */
924 HWTEST_F(AbilityManagerServiceThirdTest, CheckUIExtensionIsFocused_001, TestSize.Level1)
925 {
926 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CheckUIExtensionIsFocused_001 start");
927 auto abilityMs_ = std::make_shared<AbilityManagerService>();
928 bool isFocused = false;
929 EXPECT_EQ(abilityMs_->CheckUIExtensionIsFocused(0, isFocused), CHECK_PERMISSION_FAILED);
930 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest CheckUIExtensionIsFocused_001 end");
931 }
932
933 /*
934 * Feature: AbilityManagerService
935 * Function: NotifySaveAsResult
936 * SubFunction: NA
937 * FunctionPoints: AbilityManagerService NotifySaveAsResult
938 */
939 HWTEST_F(AbilityManagerServiceThirdTest, NotifySaveAsResult_001, TestSize.Level1)
940 {
941 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest NotifySaveAsResult_001 start");
942 auto abilityMs_ = std::make_shared<AbilityManagerService>();
943
944 Want want;
945 auto result = abilityMs_->NotifySaveAsResult(want, 0, 0);
946 EXPECT_EQ(result, CHECK_PERMISSION_FAILED);
947
948 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest NotifySaveAsResult_001 end");
949 }
950
951 /*
952 * Feature: AbilityManagerService
953 * Function: CheckCollaboratorType
954 * SubFunction: NA
955 * FunctionPoints: AbilityManagerService CheckCollaboratorType
956 * @tc.require: issueI7LF4X
957 */
958 HWTEST_F(AbilityManagerServiceThirdTest, CheckCollaboratorType_001, TestSize.Level1)
959 {
960 auto abilityMs_ = std::make_shared<AbilityManagerService>();
961 bool res = abilityMs_->CheckCollaboratorType(CollaboratorType::RESERVE_TYPE);
962 EXPECT_EQ(res, true);
963
964 res = abilityMs_->CheckCollaboratorType(CollaboratorType::DEFAULT_TYPE);
965 EXPECT_EQ(res, false);
966 }
967
968 /*
969 * Feature: AbilityManagerService
970 * Function: RegisterSessionHandler
971 * SubFunction: NA
972 * FunctionPoints: AbilityManagerService RegisterSessionHandler
973 */
974 HWTEST_F(AbilityManagerServiceThirdTest, RegisterSessionHandler_001, TestSize.Level1)
975 {
976 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest RegisterSessionHandler_001 start");
977 auto abilityMs_ = std::make_shared<AbilityManagerService>();
978 EXPECT_EQ(abilityMs_->RegisterSessionHandler(nullptr), ERR_WRONG_INTERFACE_CALL);
979 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest RegisterSessionHandler_001 end");
980 }
981
982 /*
983 * Feature: AbilityManagerService
984 * Function: CheckUserIdActive
985 * SubFunction: NA
986 * FunctionPoints: AbilityManagerService CheckUserIdActive
987 */
988 HWTEST_F(AbilityManagerServiceThirdTest, CheckUserIdActive_001, TestSize.Level1)
989 {
990 auto abilityMs_ = std::make_shared<AbilityManagerService>();
991 EXPECT_NE(abilityMs_, nullptr);
992 abilityMs_->CheckUserIdActive(USER_ID_U100);
993 }
994
995 /*
996 * Feature: AbilityManagerService
997 * Function: RegisterSessionHandler
998 * SubFunction: NA
999 * FunctionPoints: AbilityManagerService RegisterSessionHandler
1000 */
1001 HWTEST_F(AbilityManagerServiceThirdTest, RegisterSessionHandler_002, TestSize.Level1)
1002 {
1003 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest RegisterSessionHandler_002 start");
1004 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1005 abilityMs_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
1006 abilityMs_->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
1007 EXPECT_EQ(abilityMs_->RegisterSessionHandler(nullptr), ERR_WRONG_INTERFACE_CALL);
1008 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest RegisterSessionHandler_002 end");
1009 }
1010
1011 /*
1012 * Feature: AbilityManagerService
1013 * Function: IsAbilityControllerStart
1014 * SubFunction: NA
1015 * FunctionPoints: AbilityManagerService IsAbilityControllerStart
1016 */
1017 HWTEST_F(AbilityManagerServiceThirdTest, IsAbilityControllerStart_003, TestSize.Level1)
1018 {
1019 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1020 Want want;
1021 EXPECT_TRUE(abilityMs_->IsAbilityControllerStart(want));
1022 }
1023
1024 /*
1025 * Feature: AbilityManagerService
1026 * Function: SetPickerElementName
1027 * SubFunction: NA
1028 * FunctionPoints: AbilityManagerService SetPickerElementName
1029 */
1030 HWTEST_F(AbilityManagerServiceThirdTest, SetPickerElementName_001, TestSize.Level1)
1031 {
1032 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1033 EXPECT_NE(abilityMs_, nullptr);
1034 abilityMs_->SetPickerElementName(nullptr, USER_ID_U100);
1035 }
1036
1037 /*
1038 * Feature: AbilityManagerService
1039 * Function: SetPickerElementName
1040 * SubFunction: NA
1041 * FunctionPoints: AbilityManagerService SetPickerElementName
1042 */
1043 HWTEST_F(AbilityManagerServiceThirdTest, SetPickerElementName_002, TestSize.Level1)
1044 {
1045 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1046 EXPECT_NE(abilityMs_, nullptr);
1047 sptr<SessionInfo> sessionInfo = new SessionInfo();
1048 const sptr<SessionInfo> extensionSessionInfo = sessionInfo;
1049 abilityMs_->SetPickerElementName(extensionSessionInfo, USER_ID_U100);
1050 }
1051
1052 /*
1053 * Feature: AbilityManagerService
1054 * Function: SetPickerElementName
1055 * SubFunction: NA
1056 * FunctionPoints: AbilityManagerService SetPickerElementName
1057 */
1058 HWTEST_F(AbilityManagerServiceThirdTest, SetPickerElementName_003, TestSize.Level1)
1059 {
1060 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1061 EXPECT_NE(abilityMs_, nullptr);
1062 sptr<SessionInfo> sessionInfo = new SessionInfo();
1063 Want want;
1064 const std::string type = "share";
1065 want.SetParam("ability.want.params.uiExtensionTargetType", type);
1066 sessionInfo->want = want;
1067 const sptr<SessionInfo> extensionSessionInfo = sessionInfo;
1068 abilityMs_->SetPickerElementName(extensionSessionInfo, USER_ID_U100);
1069 }
1070
1071 /*
1072 * Feature: AbilityManagerService
1073 * Function: SetPickerElementName
1074 * SubFunction: NA
1075 * FunctionPoints: AbilityManagerService SetPickerElementName
1076 */
1077 HWTEST_F(AbilityManagerServiceThirdTest, SetPickerElementName_004, TestSize.Level1)
1078 {
1079 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1080 EXPECT_NE(abilityMs_, nullptr);
1081 sptr<SessionInfo> sessionInfo = new SessionInfo();
1082 Want want;
1083 want.SetElementName("com.example.share", "ShareUIExtensionAbility");
1084 sessionInfo->want = want;
1085 const sptr<SessionInfo> extensionSessionInfo = sessionInfo;
1086 abilityMs_->SetPickerElementName(extensionSessionInfo, USER_ID_U100);
1087 }
1088
1089 /*
1090 * Feature: AbilityManagerService
1091 * Function: OpenAtomicService
1092 * SubFunction: NA
1093 * FunctionPoints: AbilityManagerService OpenAtomicService
1094 */
1095 HWTEST_F(AbilityManagerServiceThirdTest, OpenAtomicService_001, TestSize.Level1)
1096 {
1097 auto abilityMs = std::make_shared<AbilityManagerService>();
1098 EXPECT_NE(abilityMs, nullptr);
1099 Want want;
1100 StartOptions startOptions;
1101 int32_t userId = 100;
1102 auto openRet = abilityMs->OpenAtomicService(want, startOptions, nullptr, 1, userId);
1103 EXPECT_EQ(openRet, CHECK_PERMISSION_FAILED);
1104 }
1105
1106 /*
1107 * Feature: AbilityManagerService
1108 * Function: RestartApp
1109 * FunctionPoints: AbilityManagerService RestartApp
1110 */
1111 HWTEST_F(AbilityManagerServiceThirdTest, RestartApp_001, TestSize.Level1)
1112 {
1113 auto abilityMs = std::make_shared<AbilityManagerService>();
1114 EXPECT_NE(abilityMs, nullptr);
1115 AAFwk::Want want;
1116 int32_t res = abilityMs->RestartApp(want);
1117 EXPECT_NE(res, ERR_OK);
1118 }
1119
1120 /*
1121 * Feature: AbilityManagerService
1122 * Function: UnloadUIExtensionAbility
1123 * FunctionPoints: AbilityManagerService UnloadUIExtensionAbility
1124 */
1125 HWTEST_F(AbilityManagerServiceThirdTest, UnloadUIExtensionAbility_001, TestSize.Level1)
1126 {
1127 TAG_LOGI(AAFwkTag::TEST, "start.");
1128 auto abilityMs = std::make_shared<AbilityManagerService>();
1129 AbilityRequest abilityRequest;
1130 AppExecFwk::ElementName providerElement("0", "com.ohos.uiextensionprovider", "UIExtensionProvider", "entry");
1131 abilityRequest.want.SetElement(providerElement);
1132 abilityRequest.abilityInfo.type = AbilityType::EXTENSION;
1133 std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
1134 std::string hostBundleName = "com.ohos.uiextensionuser";
1135 auto result = abilityMs->UnloadUIExtensionAbility(abilityRecord, hostBundleName);
1136 EXPECT_EQ(result, ERR_INVALID_VALUE);
1137 TAG_LOGI(AAFwkTag::TEST, "finish.");
1138 }
1139
1140 /*
1141 * Feature: AbilityManagerService
1142 * Function: PreloadUIExtensionAbility
1143 * FunctionPoints: AbilityManagerService PreloadUIExtensionAbility
1144 */
1145 HWTEST_F(AbilityManagerServiceThirdTest, PreloadUIExtensionAbility_001, TestSize.Level1)
1146 {
1147 TAG_LOGI(AAFwkTag::TEST, "start.");
1148 auto abilityMs = std::make_shared<AbilityManagerService>();
1149 Want providerWant;
1150 AppExecFwk::ElementName providerElement("0", "com.ohos.uiextensionprovider", "UIExtensionProvider", "entry");
1151 providerWant.SetElement(providerElement);
1152 std::string hostBundleName = "com.ohos.uiextensionuser";
1153 auto result = abilityMs->PreloadUIExtensionAbility(providerWant, hostBundleName, DEFAULT_INVAL_VALUE);
1154 EXPECT_EQ(result, ERR_PERMISSION_DENIED);
1155 TAG_LOGI(AAFwkTag::TEST, "finish.");
1156 }
1157
1158 /*
1159 * Feature: AbilityManagerService
1160 * Function: PreloadUIExtensionAbilityInner
1161 * FunctionPoints: AbilityManagerService PreloadUIExtensionAbility
1162 */
1163 HWTEST_F(AbilityManagerServiceThirdTest, PreloadUIExtensionAbilityInner_001, TestSize.Level1)
1164 {
1165 TAG_LOGI(AAFwkTag::TEST, "start.");
1166 auto abilityMs = std::make_shared<AbilityManagerService>();
1167 Want providerWant;
1168 AppExecFwk::ElementName providerElement("0", "com.ohos.uiextensionprovider", "UIExtensionProvider", "entry");
1169 providerWant.SetElement(providerElement);
1170 std::string hostBundleName = "com.ohos.uiextensionuser";
1171 auto result = abilityMs->PreloadUIExtensionAbilityInner(providerWant, hostBundleName, DEFAULT_INVAL_VALUE);
1172 EXPECT_NE(result, ERR_OK);
1173 TAG_LOGI(AAFwkTag::TEST, "finish.");
1174 }
1175
1176 /*
1177 * Feature: AbilityManagerService
1178 * Function: CheckRestartAppWant
1179 * FunctionPoints: AbilityManagerService CheckRestartAppWant
1180 */
1181 HWTEST_F(AbilityManagerServiceThirdTest, CheckRestartAppWant_001, TestSize.Level1)
1182 {
1183 auto abilityMs = std::make_shared<AbilityManagerService>();
1184 EXPECT_NE(abilityMs, nullptr);
1185 AAFwk::Want want;
1186 int32_t res = abilityMs->CheckRestartAppWant(want, 0);
1187 EXPECT_EQ(res, AAFwk::ERR_RESTART_APP_INCORRECT_ABILITY);
1188 }
1189
1190 /*
1191 * Feature: AbilityManagerService
1192 * Function: GetAbilityStateByPersistentId
1193 * FunctionPoints: AbilityManagerService GetAbilityStateByPersistentId
1194 */
1195 HWTEST_F(AbilityManagerServiceThirdTest, GetAbilityStateByPersistentId_001, TestSize.Level1)
1196 {
1197 auto abilityMs = std::make_shared<AbilityManagerService>();
1198 EXPECT_NE(abilityMs, nullptr);
1199 int32_t persistentId = 100;
1200 bool state;
1201 int32_t res = abilityMs->GetAbilityStateByPersistentId(persistentId, state);
1202 EXPECT_EQ(res, ERR_PERMISSION_DENIED);
1203 }
1204
1205 /*
1206 * Feature: AbilityManagerService
1207 * Function: OpenLink
1208 * FunctionPoints: AbilityManagerService OpenLink
1209 */
1210 HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_001, TestSize.Level1)
1211 {
1212 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1213 EXPECT_NE(abilityMs_, nullptr);
1214 sptr<IRemoteObject> token = MockToken(AbilityType::PAGE);
1215 AAFwk::Want want;
1216 Uri uri("");
1217 want.GetOperation().SetUri(uri);
1218
1219 auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE);
1220 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest OpenLink_001 call result %{public}d", result);
1221 }
1222
1223 /*
1224 * Feature: AbilityManagerService
1225 * Function: NotifySCBToHandleAtomicServiceException
1226 * FunctionPoints: AbilityManagerService NotifySCBToHandleAtomicServiceException
1227 */
1228 HWTEST_F(AbilityManagerServiceThirdTest, NotifySCBToHandleAtomicServiceException_001, TestSize.Level1)
1229 {
1230 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1231 EXPECT_NE(abilityMs_, nullptr);
1232
1233 int32_t errCode = 0;
1234 std::string reason;
1235 abilityMs_->NotifySCBToHandleAtomicServiceException(SESSIONID, errCode, reason);
1236 }
1237
1238 /*
1239 * Feature: AbilityManagerService
1240 * Function: StartUIAbilityByPreInstallInner
1241 * FunctionPoints: AbilityManagerService StartUIAbilityByPreInstallInner
1242 */
1243 HWTEST_F(AbilityManagerServiceThirdTest, StartUIAbilityByPreInstallInner_001, TestSize.Level1)
1244 {
1245 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1246 EXPECT_NE(abilityMs_, nullptr);
1247
1248 FreeInstallInfo taskInfo;
1249 auto result2 = abilityMs_->StartUIAbilityByPreInstall(taskInfo);
1250 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartUIAbilityByPreInstallInner_001 result2 %{public}d",
1251 result2);
1252 }
1253
1254 /*
1255 * Feature: AbilityManagerService
1256 * Function: PreStartInner
1257 * FunctionPoints: AbilityManagerService PreStartInner
1258 */
1259 HWTEST_F(AbilityManagerServiceThirdTest, PreStartInner_001, TestSize.Level1)
1260 {
1261 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1262 EXPECT_NE(abilityMs_, nullptr);
1263
1264 FreeInstallInfo taskInfo;
1265 auto result = abilityMs_->PreStartInner(taskInfo);
1266 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest PreStartInner_001 call result %{public}d", result);
1267 }
1268
1269 /*
1270 * Feature: AbilityManagerService
1271 * Function: PreStartMission
1272 * FunctionPoints: PreStartMission
1273 */
1274 HWTEST_F(AbilityManagerServiceThirdTest, PreStartMission_001, TestSize.Level1)
1275 {
1276 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1277 EXPECT_NE(abilityMs_, nullptr);
1278
1279 auto result = abilityMs_->PreStartMission("com.ix.hiservcie", "entry", "ServiceAbility", "2024-07-16 10:00:00");
1280 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest PreStartMission_001 call result %{public}d", result);
1281 }
1282
1283 /*
1284 * Feature: AbilityManagerService
1285 * Function: NotifyFrozenProcessByRSS
1286 * FunctionPoints: NotifyFrozenProcessByRSS
1287 */
1288 HWTEST_F(AbilityManagerServiceThirdTest, NotifyFrozenProcessByRSS_001, TestSize.Level1)
1289 {
1290 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1291 EXPECT_NE(abilityMs_, nullptr);
1292
1293 std::vector<int32_t> pidList;
1294 int32_t UID = 1000;
1295 abilityMs_->NotifyFrozenProcessByRSS(pidList, UID);
1296 }
1297
1298 /*
1299 * Feature: AbilityManagerService
1300 * Function: GetRunningMultiAppIndex
1301 * FunctionPoints: GetRunningMultiAppIndex
1302 */
1303 HWTEST_F(AbilityManagerServiceThirdTest, GetRunningMultiAppIndex_001, TestSize.Level1)
1304 {
1305 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1306 EXPECT_NE(abilityMs_, nullptr);
1307
1308 int32_t UID = 1000;
1309 int32_t APPINDEX = 28;
1310 abilityMs_->GetRunningMultiAppIndex("com.ix.hiservcie", UID, APPINDEX);
1311 }
1312
1313 /*
1314 * Feature: AbilityManagerService
1315 * Function: TransferAbilityResultForExtension
1316 * FunctionPoints: TransferAbilityResultForExtension
1317 */
1318 HWTEST_F(AbilityManagerServiceThirdTest, TransferAbilityResultForExtension_001, TestSize.Level1)
1319 {
1320 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1321 EXPECT_NE(abilityMs_, nullptr);
1322
1323 AAFwk::Want want;
1324 sptr<IRemoteObject> token = MockToken(AbilityType::PAGE);
1325 int32_t resultCode = 0;
1326 auto result = abilityMs_->TransferAbilityResultForExtension(token, resultCode, want);
1327 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest TransferAbilityResultForExtension %{public}d", result);
1328 }
1329
1330 /*
1331 * Feature: AbilityManagerService
1332 * Function: StartShortcut
1333 * FunctionPoints: StartShortcut
1334 */
1335 HWTEST_F(AbilityManagerServiceThirdTest, StartShortcut_001, TestSize.Level1)
1336 {
1337 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1338 EXPECT_NE(abilityMs_, nullptr);
1339
1340 AAFwk::Want want;
1341 StartOptions startOp;
1342 auto result = abilityMs_->StartShortcut(want, startOp);
1343 TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartShortcut %{public}d", result);
1344 }
1345
1346 /*
1347 * Feature: AbilityManagerService
1348 * Function: ConvertFullPath
1349 * FunctionPoints: ConvertFullPath
1350 */
1351 HWTEST_F(AbilityManagerServiceThirdTest, ConvertFullPath_001, TestSize.Level1)
1352 {
1353 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1354 EXPECT_NE(abilityMs_, nullptr);
1355
1356 std::string partialPath = "";
1357 std::string fullPath;
1358 EXPECT_EQ(abilityMs_->ConvertFullPath(partialPath, fullPath), false);
1359
1360 partialPath = "hello";
1361 EXPECT_NE(abilityMs_->ConvertFullPath(partialPath, fullPath), true);
1362 }
1363
1364 /*
1365 * Feature: AbilityManagerService
1366 * Function: ParseJsonValueFromFile
1367 * FunctionPoints: ParseJsonValueFromFile
1368 */
1369 HWTEST_F(AbilityManagerServiceThirdTest, ParseJsonValueFromFile_001, TestSize.Level1)
1370 {
1371 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1372 EXPECT_NE(abilityMs_, nullptr);
1373
1374 std::string filePath = "hello";
1375 nlohmann::json value;
1376 abilityMs_->ParseJsonValueFromFile(value, filePath);
1377 }
1378
1379 /*
1380 * Feature: AbilityManagerService
1381 * Function: GetConfigFileAbsolutePath
1382 * FunctionPoints: GetConfigFileAbsolutePath
1383 */
1384 HWTEST_F(AbilityManagerServiceThirdTest, GetConfigFileAbsolutePath_001, TestSize.Level1)
1385 {
1386 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1387 EXPECT_NE(abilityMs_, nullptr);
1388
1389 EXPECT_EQ(abilityMs_->GetConfigFileAbsolutePath(""), "");
1390 std::string relativePath = "hello";
1391 abilityMs_->GetConfigFileAbsolutePath(relativePath);
1392 }
1393
1394 /*
1395 * Feature: AbilityManagerService
1396 * Function: ParseJsonFromBoot
1397 * FunctionPoints: ParseJsonFromBoot
1398 */
1399 HWTEST_F(AbilityManagerServiceThirdTest, ParseJsonFromBoot_001, TestSize.Level1)
1400 {
1401 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1402 EXPECT_NE(abilityMs_, nullptr);
1403
1404 abilityMs_->ParseJsonFromBoot("");
1405 }
1406
1407 /*
1408 * Feature: AbilityManagerService
1409 * Function: IsInWhiteList
1410 * FunctionPoints: IsInWhiteList
1411 */
1412 HWTEST_F(AbilityManagerServiceThirdTest, IsInWhiteList_001, TestSize.Level1)
1413 {
1414 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1415 EXPECT_NE(abilityMs_, nullptr);
1416
1417 abilityMs_->IsInWhiteList("", "", "");
1418 }
1419
1420 /*
1421 * Feature: AbilityManagerService
1422 * Function: ReportPreventStartAbilityResult
1423 * FunctionPoints: ReportPreventStartAbilityResult
1424 */
1425 HWTEST_F(AbilityManagerServiceThirdTest, ReportPreventStartAbilityResult_001, TestSize.Level1)
1426 {
1427 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1428 EXPECT_NE(abilityMs_, nullptr);
1429
1430 AppExecFwk::AbilityInfo abilityInfo;
1431 AppExecFwk::AbilityInfo abilityInfo2;
1432 abilityMs_->ReportPreventStartAbilityResult(abilityInfo, abilityInfo2);
1433 }
1434
1435 /*
1436 * Feature: AbilityManagerService
1437 * Function: ShouldPreventStartAbility
1438 * FunctionPoints: ShouldPreventStartAbility
1439 */
1440 HWTEST_F(AbilityManagerServiceThirdTest, ShouldPreventStartAbility_001, TestSize.Level1)
1441 {
1442 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1443 EXPECT_NE(abilityMs_, nullptr);
1444
1445 AbilityRequest abilityRequest;
1446 abilityRequest.appInfo.bundleName = "com.test.demo";
1447 abilityRequest.abilityInfo.name = "MainAbility";
1448 abilityRequest.abilityInfo.type = AbilityType::PAGE;
1449
1450 abilityMs_->ShouldPreventStartAbility(abilityRequest);
1451 }
1452
1453 /*
1454 * Feature: AbilityManagerService
1455 * Function: IsEmbeddedOpenAllowed
1456 * FunctionPoints: IsEmbeddedOpenAllowed
1457 */
1458 HWTEST_F(AbilityManagerServiceThirdTest, IsEmbeddedOpenAllowed_001, TestSize.Level1)
1459 {
1460 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1461 EXPECT_NE(abilityMs_, nullptr);
1462
1463 sptr<IRemoteObject> token = MockToken(AbilityType::PAGE);
1464 abilityMs_->IsEmbeddedOpenAllowed(token, APPID);
1465 }
1466
1467 /*
1468 * Feature: AbilityManagerService
1469 * Function: SignRestartAppFlag
1470 * FunctionPoints: SignRestartAppFlag
1471 */
1472 HWTEST_F(AbilityManagerServiceThirdTest, SignRestartAppFlag_001, TestSize.Level1)
1473 {
1474 auto abilityMs_ = std::make_shared<AbilityManagerService>();
1475 EXPECT_NE(abilityMs_, nullptr);
1476
1477 abilityMs_->SignRestartAppFlag(USER_ID_U100, 1);
1478 }
1479
1480 /*
1481 * Feature: AbilityManagerService
1482 * Function: StartUIAbilityByPreInstall
1483 * FunctionPoints: AbilityManagerService StartUIAbilityByPreInstall free install not finished
1484 */
1485 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_StartUIAbilityByPreInstall_001, TestSize.Level1)
1486 {
1487 auto abilityMs = std::make_shared<AbilityManagerService>();
1488 EXPECT_NE(abilityMs, nullptr);
1489 FreeInstallInfo taskInfo = {
1490 .isFreeInstallFinished = false,
1491 };
1492 int32_t res = abilityMs->StartUIAbilityByPreInstall(taskInfo);
1493 EXPECT_EQ(res, ERR_INVALID_VALUE);
1494 }
1495
1496 /*
1497 * Feature: AbilityManagerService
1498 * Function: StartUIAbilityByPreInstall
1499 * FunctionPoints: AbilityManagerService StartUIAbilityByPreInstall free install failed
1500 */
1501 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_StartUIAbilityByPreInstall_002, TestSize.Level1)
1502 {
1503 auto abilityMs = std::make_shared<AbilityManagerService>();
1504 EXPECT_NE(abilityMs, nullptr);
1505 FreeInstallInfo taskInfo = {
1506 .isInstalled = false,
1507 };
1508 int32_t res = abilityMs->StartUIAbilityByPreInstall(taskInfo);
1509 EXPECT_EQ(res, ERR_INVALID_VALUE);
1510 }
1511
1512 /*
1513 * Feature: AbilityManagerService
1514 * Function: StartUIAbilityByPreInstall
1515 * FunctionPoints: AbilityManagerService StartUIAbilityByPreInstall StartUIAbilityBySCB not called
1516 */
1517 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_StartUIAbilityByPreInstall_003, TestSize.Level1)
1518 {
1519 auto abilityMs = std::make_shared<AbilityManagerService>();
1520 EXPECT_NE(abilityMs, nullptr);
1521 FreeInstallInfo taskInfo = {
1522 .isStartUIAbilityBySCBCalled = false,
1523 };
1524 int32_t res = abilityMs->StartUIAbilityByPreInstall(taskInfo);
1525 EXPECT_EQ(res, ERR_INVALID_VALUE);
1526 }
1527
1528 /*
1529 * Feature: AbilityManagerService
1530 * Function: StartUIAbilityByPreInstall
1531 * FunctionPoints: AbilityManagerService StartUIAbilityByPreInstall empty sessionId
1532 */
1533 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_StartUIAbilityByPreInstall_004, TestSize.Level1)
1534 {
1535 auto abilityMs = std::make_shared<AbilityManagerService>();
1536 EXPECT_NE(abilityMs, nullptr);
1537 FreeInstallInfo taskInfo = {
1538 .isFreeInstallFinished = true,
1539 .isInstalled = true,
1540 .isStartUIAbilityBySCBCalled = true,
1541 };
1542 int32_t res = abilityMs->StartUIAbilityByPreInstall(taskInfo);
1543 EXPECT_EQ(res, ERR_INVALID_VALUE);
1544 }
1545
1546 /*
1547 * Feature: AbilityManagerService
1548 * Function: StartUIAbilityByPreInstall
1549 * FunctionPoints: AbilityManagerService StartUIAbilityByPreInstall session not found
1550 */
1551 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_StartUIAbilityByPreInstall_005, TestSize.Level1)
1552 {
1553 auto abilityMs = std::make_shared<AbilityManagerService>();
1554 EXPECT_NE(abilityMs, nullptr);
1555 Want want;
1556 std::string sessionId = "1234567890";
1557 want.SetParam(KEY_SESSION_ID, sessionId);
1558 FreeInstallInfo taskInfo = {
1559 .want = want,
1560 .isFreeInstallFinished = true,
1561 .isInstalled = true,
1562 .isStartUIAbilityBySCBCalled = true,
1563 };
1564 int32_t res = abilityMs->StartUIAbilityByPreInstall(taskInfo);
1565 EXPECT_EQ(res, ERR_INVALID_VALUE);
1566 }
1567
1568 /*
1569 * Feature: AbilityManagerService
1570 * Function: RemovePreStartSession
1571 * FunctionPoints: AbilityManagerService RemovePreStartSession
1572 */
1573 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_RemovePreStartSession_001, TestSize.Level1)
1574 {
1575 auto abilityMs = std::make_shared<AbilityManagerService>();
1576 EXPECT_NE(abilityMs, nullptr);
1577 sptr<SessionInfo> sessionInfo = new (std::nothrow) SessionInfo();
1578 std::string sessionId = "123456";
1579 (abilityMs->preStartSessionMap_).insert(std::make_pair(sessionId, sessionInfo));
1580 abilityMs->RemovePreStartSession(sessionId);
1581 EXPECT_EQ((abilityMs->preStartSessionMap_).find(sessionId), (abilityMs->preStartSessionMap_).end());
1582 }
1583
1584 /*
1585 * Feature: AbilityManagerService
1586 * Function: PreStartMission
1587 * FunctionPoints: AbilityManagerService PreStartMission permission denied
1588 */
1589 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_PreStartMission_001, TestSize.Level1)
1590 {
1591 auto abilityMs = std::make_shared<AbilityManagerService>();
1592 EXPECT_NE(abilityMs, nullptr);
1593 int res = abilityMs->PreStartMission("bundle", "module", "ability", "startTime");
1594 EXPECT_EQ(res, ERR_PERMISSION_DENIED);
1595 }
1596
1597 /*
1598 * Feature: AbilityManagerService
1599 * Function: OpenLink
1600 * FunctionPoints: AbilityManagerService OpenLink
1601 */
1602 HWTEST_F(AbilityManagerServiceThirdTest, AbilityManagerServiceTest_OpenLink_001, TestSize.Level1)
1603 {
1604 auto abilityMs = std::make_shared<AbilityManagerService>();
1605 EXPECT_NE(abilityMs, nullptr);
1606 Want want;
1607 sptr<IRemoteObject> callerToken = nullptr;
1608 int res = abilityMs->OpenLink(want, callerToken, 0, -1);
1609 EXPECT_NE(res, ERR_OK);
1610 }
1611
1612 /*
1613 * Feature: AbilityManagerService
1614 * Function: CheckUIExtensionCallerPidByHostWindowId
1615 * FunctionPoints: AbilityManagerService CheckUIExtensionCallerPidByHostWindowId
1616 */
1617 HWTEST_F(AbilityManagerServiceThirdTest, CheckUIExtensionCallerPidByHostWindowId_001, TestSize.Level1)
1618 {
1619 auto abilityMs = std::make_shared<AbilityManagerService>();
1620 ASSERT_NE(abilityMs, nullptr);
1621 AbilityRequest abilityRequest = GenerateAbilityRequest("0", "abilityName", "appName", "bundleName", "moduleName");
1622 sptr<IRemoteObject> token = MockToken(AbilityType::PAGE);
1623 ASSERT_NE(token, nullptr);
1624 abilityRequest.callerToken = token;
1625 auto sessionInfo = sptr<SessionInfo>::MakeSptr();
1626 ASSERT_NE(sessionInfo, nullptr);
1627 sessionInfo->hostWindowId = 1;
1628 abilityRequest.sessionInfo = sessionInfo;
1629 abilityMs->CheckUIExtensionCallerPidByHostWindowId(abilityRequest);
1630 }
1631
1632 /*
1633 * Feature: AbilityManagerService
1634 * Function: CheckUIExtensionCallerPidByHostWindowId
1635 * FunctionPoints: AbilityManagerService CheckUIExtensionCallerPidByHostWindowId
1636 */
1637 HWTEST_F(AbilityManagerServiceThirdTest, CheckUIExtensionCallerPidByHostWindowId_002, TestSize.Level1)
1638 {
1639 auto abilityMs = std::make_shared<AbilityManagerService>();
1640 ASSERT_NE(abilityMs, nullptr);
1641 AbilityRequest callerRequest = GenerateAbilityRequest("0", "abilityName", "appName", "bundleName", "moduleName");
1642 callerRequest.abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::SYS_COMMON_UI;
1643 auto callerRecord = AbilityRecord::CreateAbilityRecord(callerRequest);
1644 ASSERT_NE(callerRecord, nullptr);
1645
1646 AbilityRequest abilityRequest = GenerateAbilityRequest("0", "abilityName", "appName", "bundleName", "moduleName");
1647 abilityRequest.callerToken = callerRecord->GetToken();
1648 auto sessionInfo = sptr<SessionInfo>::MakeSptr();
1649 ASSERT_NE(sessionInfo, nullptr);
1650 sessionInfo->hostWindowId = 1;
1651 abilityRequest.sessionInfo = sessionInfo;
1652 abilityMs->CheckUIExtensionCallerPidByHostWindowId(abilityRequest);
1653 }
1654 } // namespace AAFwk
1655 } // namespace OHOS
1656