From 9e1c7a0c4db55d151f5bb9cdc547450db3886809 Mon Sep 17 00:00:00 2001 From: liuzongze Date: Wed, 2 Jul 2025 14:45:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85TDD&=E6=84=8F=E5=9B=BEform?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuzongze Change-Id: Iaa30a2f615d7fa33dbbce573acb86070ee6b9439 --- .../insight_intent_info_for_query.cpp | 2 +- .../ability_manager_service_sixth_test.cpp | 5 +++++ .../ams_app_running_record_test.cpp | 17 ++++++++++++++ .../app_lifecycle_deal_test.cpp | 16 ++++++++++++++ .../app_mgr_client_test.cpp | 18 +++++++++++++++ .../app_mgr_proxy_test/app_mgr_proxy_test.cpp | 18 +++++++++++++++ .../app_mgr_service_inner_tdd_test.cpp | 22 +++++++++++++++++++ .../app_mgr_service_inner_test.cpp | 18 +++++++++++++++ .../app_mgr_service_test.cpp | 16 ++++++++++++++ .../app_mgr_stub_test/app_mgr_stub_test.cpp | 1 + .../app_scheduler_proxy_test.cpp | 13 +++++++++++ .../main_thread_test/main_thread_test.cpp | 12 ++++++++++ 12 files changed, 157 insertions(+), 1 deletion(-) diff --git a/services/abilitymgr/src/insight_intent/insight_intent_info_for_query.cpp b/services/abilitymgr/src/insight_intent/insight_intent_info_for_query.cpp index 8aab967d91e..9670c86ca68 100644 --- a/services/abilitymgr/src/insight_intent/insight_intent_info_for_query.cpp +++ b/services/abilitymgr/src/insight_intent/insight_intent_info_for_query.cpp @@ -221,7 +221,7 @@ void from_json(const cJSON *jsonObject, InsightIntentInfoForQuery &insightIntent } else if (insightIntentInfo.intentType == INSIGHT_INTENTS_TYPE_ENTRY) { GetObjectValueIfFindKey(jsonObject, INSIGHT_INTENT_ENTRY_INFO, insightIntentInfo.entryInfo, false, g_parseResult); - } else if (insightIntentInfo.intentType == INSIGHT_INTENT_FORM_INFO) { + } else if (insightIntentInfo.intentType == INSIGHT_INTENTS_TYPE_FORM) { GetObjectValueIfFindKey(jsonObject, INSIGHT_INTENT_FORM_INFO, insightIntentInfo.formInfo, false, g_parseResult); } } diff --git a/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp b/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp index c3e2b5f9984..73ccbc144b5 100644 --- a/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp +++ b/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp @@ -417,6 +417,11 @@ HWTEST_F(AbilityManagerServiceSixthTest, CheckUIExtensionUsage_001, TestSize.Lev extensionType = AppExecFwk::ExtensionAbilityType::WINDOW; ret = abilityMs->CheckUIExtensionUsage(uiExtensionUsage, extensionType); EXPECT_EQ(ret, ERR_INVALID_VALUE); + + uiExtensionUsage = UIExtensionUsage::PRE_VIEW_EMBEDDED; + extensionType = AppExecFwk::ExtensionAbilityType::FORM; + ret = abilityMs->CheckUIExtensionUsage(uiExtensionUsage, extensionType); + EXPECT_EQ(ret, ERR_INVALID_VALUE); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest CheckUIExtensionUsage_001 end"); MyFlag::flag_ = 0; } diff --git a/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp b/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp index 14622e0c6b5..db31a26b9be 100644 --- a/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp +++ b/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp @@ -2943,6 +2943,23 @@ HWTEST_F(AmsAppRunningRecordTest, ChangeAppGcState_002, TestSize.Level1) TAG_LOGD(AAFwkTag::TEST, "ChangeAppGcState_002 end."); } +/* + * Feature: AMS + * Function: ChangeAppGcState + * SubFunction: ChangeAppGcState_003 + * FunctionPoints: check params + * EnvConditions: Mobile that can run ohos test framework + * CaseDescription: Change app Gc state + */ +HWTEST_F(AmsAppRunningRecordTest, ChangeAppGcState_003, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "ChangeAppGcState_003 start."); + auto record = GetTestAppRunningRecord(); + record->appLifeCycleDeal_ = std::make_shared(); + EXPECT_EQ(ERR_INVALID_VALUE, record->ChangeAppGcState(0, 1)); + TAG_LOGD(AAFwkTag::TEST, "ChangeAppGcState_003 end."); +} + /** * @tc.name: IsAbilitiesBackgrounded_001 * @tc.desc: verify that ModuleRunningRecord correctly judges Abilitiesbackground diff --git a/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp b/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp index 565e8315603..7ce417a5f80 100644 --- a/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp +++ b/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp @@ -149,6 +149,22 @@ HWTEST_F(AppLifecycleDealTest, ChangeAppGcState_001, TestSize.Level1) EXPECT_EQ(ERR_OK, result1); } +/** + * @tc.name: ChangeAppGcState_002 + * @tc.desc: Verify that the ChangeAppGcState interface calls normally + * @tc.type: FUNC + */ +HWTEST_F(AppLifecycleDealTest, ChangeAppGcState_002, TestSize.Level1) +{ + auto appLifeCycle = std::make_shared(); + int32_t result = appLifeCycle->ChangeAppGcState(0, 1); + EXPECT_EQ(result, ERR_INVALID_VALUE); + sptr mockAppScheduler = new (std::nothrow) MockAppScheduler(); + appLifeCycle->SetApplicationClient(mockAppScheduler); + int32_t result1 = appLifeCycle->ChangeAppGcState(0, 1); + EXPECT_EQ(ERR_OK, result1); +} + /** * @tc.name: UpdateApplicationInfoInstalled_001 * @tc.desc: Test the normal state of UpdateApplicationInfoInstalled diff --git a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp index 0d8390fd698..9d683362d20 100644 --- a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp +++ b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp @@ -840,6 +840,24 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_ChangeAppGcState_001, TestSize.Level1) EXPECT_EQ(resultCode, NO_ERROR); } +/** + * @tc.name: AppMgrClient_ChangeAppGcState_002 + * @tc.desc: ChangeAppGcState. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrClientTest, AppMgrClient_ChangeAppGcState_002, TestSize.Level1) +{ + auto appMgrClient = std::make_unique(); + EXPECT_NE(appMgrClient, nullptr); + auto result = appMgrClient->ConnectAppMgrService(); + EXPECT_EQ(result, AppMgrResultCode::RESULT_OK); + pid_t pid = 0; + int32_t state = 0; + uint64_t tid = 1; + auto resultCode = appMgrClient->ChangeAppGcState(pid, state, tid); + EXPECT_EQ(resultCode, NO_ERROR); +} + /** * @tc.name: AppMgrClient_RegisterAppDebugListener_001 * @tc.desc: Register app debug listener, check nullptr listener. diff --git a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp index dcc5295348f..bdb44d5919c 100644 --- a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp +++ b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp @@ -389,6 +389,24 @@ HWTEST_F(AppMgrProxyTest, ChangeAppGcState_001, TestSize.Level1) EXPECT_EQ(mockAppMgrService_->code_, static_cast(AppMgrInterfaceCode::CHANGE_APP_GC_STATE)); } +/** + * @tc.name: ChangeAppGcState_002 + * @tc.desc: Change app Gc state. + * @tc.type: FUNC + * @tc.require: issuesI85VVU + */ +HWTEST_F(AppMgrProxyTest, ChangeAppGcState_002, TestSize.Level1) +{ + EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _)) + .Times(1) + .WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest)); + int32_t pid = 0; + int32_t state = 0; + uint64_t tid = 1; + appMgrProxy_->ChangeAppGcState(pid, state, tid); + EXPECT_EQ(mockAppMgrService_->code_, static_cast(AppMgrInterfaceCode::CHANGE_APP_GC_STATE)); +} + /** * @tc.name: IsApplicationRunning_001 * @tc.desc: Send request to query the running status of the application. diff --git a/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp b/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp index b52e8e64118..2e4609350bc 100644 --- a/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp +++ b/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp @@ -967,6 +967,28 @@ HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_001, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_001 end"); } +/** + * @tc.name: ChangeAppGcState_002 + * @tc.desc: Change app Gc state + * @tc.type: FUNC + * @tc.Function: ChangeAppGcState + * @tc.SubFunction: NA + * @tc.EnvConditions: NA + */ +HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_002 start"); + auto appMgrServiceInner = std::make_shared(); + appMgrServiceInner->Init(); + EXPECT_NE(appMgrServiceInner, nullptr); + int32_t pid = 0; + int32_t state = 0; + uint64_t tid = 1; + int32_t ret = appMgrServiceInner->ChangeAppGcState(pid, state, tid); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_002 end"); +} + /** * @tc.name: QueryExtensionSandBox_001 * @tc.desc: query extension sandBox. diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 00b87dd64d3..1bfd45a6dcb 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -4610,6 +4610,24 @@ HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_001, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_001 end"); } +/** + * @tc.name: ChangeAppGcState_002 + * @tc.desc: Change app Gc state + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_002 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + int32_t pid = 0; + int32_t state = 0; + uint64_t tid = 1; + int32_t ret = appMgrServiceInner->ChangeAppGcState(pid, state, tid); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_002 end"); +} + /** * @tc.name: SendReStartProcessEvent_001 * @tc.desc: Change app Gc state diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 5f0f6a165ad..b3d55a5f7f2 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1372,6 +1372,22 @@ HWTEST_F(AppMgrServiceTest, ChangeAppGcState_001, TestSize.Level1) appMgrService->appMgrServiceInner_ = nullptr; } +/** + * @tc.name: ChangeAppGcState_002 + * @tc.desc: Change app Gc state + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceTest, ChangeAppGcState_002, TestSize.Level1) +{ + sptr appMgrService = new (std::nothrow) AppMgrService(); + appMgrService->SetInnerService(std::make_shared()); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = std::make_shared(taskHandler_, appMgrService->appMgrServiceInner_); + int32_t res = appMgrService->ChangeAppGcState(0, 0, 1); + EXPECT_EQ(ERR_INVALID_VALUE, res); + appMgrService->appMgrServiceInner_ = nullptr; +} + /** * @tc.name: IsAppRunning_001 * @tc.desc: Determine that the application is running by returning a value. diff --git a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp index 7cdbab6100c..672a149c46b 100644 --- a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp +++ b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp @@ -376,6 +376,7 @@ HWTEST_F(AppMgrStubTest, HandleChangeAppGcState_001, TestSize.Level1) WriteInterfaceToken(data); data.WriteInt32(0); data.WriteInt32(0); + data.WriteInt32(1); auto result = mockAppMgrService_->OnRemoteRequest( static_cast(AppMgrInterfaceCode::CHANGE_APP_GC_STATE), data, reply, option); EXPECT_EQ(result, NO_ERROR); diff --git a/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp b/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp index 7bdf69e6b10..05642b2ef12 100644 --- a/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp +++ b/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp @@ -84,6 +84,19 @@ HWTEST_F(AppSchedulerProxyTest, ScheduleChangeAppGcState_001, TestSize.Level1) EXPECT_EQ(result, ERR_NULL_OBJECT); } +/** + * @tc.name: ScheduleChangeAppGcState_002 + * @tc.desc: Verify that the ScheduleChangeAppGcState interface calls normally + * @tc.type: FUNC + */ +HWTEST_F(AppSchedulerProxyTest, ScheduleChangeAppGcState_002, TestSize.Level1) +{ + sptr impl; + sptr appSchedulerProxy = new (std::nothrow) AppSchedulerProxy(impl); + int32_t result = appSchedulerProxy->ScheduleChangeAppGcState(0, 1); + EXPECT_EQ(result, ERR_NULL_OBJECT); +} + /** * @tc.name: AttachAppDebug_001 * @tc.desc: Verify that AttachAppDebug interface calls normally. diff --git a/test/unittest/appkit/main_thread_test/main_thread_test.cpp b/test/unittest/appkit/main_thread_test/main_thread_test.cpp index 3fe10f33d9b..29cc9ea0370 100644 --- a/test/unittest/appkit/main_thread_test/main_thread_test.cpp +++ b/test/unittest/appkit/main_thread_test/main_thread_test.cpp @@ -2459,6 +2459,18 @@ HWTEST_F(MainThreadTest, ScheduleChangeAppGcState_0100, TestSize.Level1) EXPECT_EQ(ret, NO_ERROR); } +/** + * @tc.name: ScheduleChangeAppGcState_0200 + * @tc.desc: Schedule Gc state chage. + * @tc.type: FUNC + * @tc.require: issuesI85VVU + */ +HWTEST_F(MainThreadTest, ScheduleChangeAppGcState_0200, TestSize.Level1) +{ + auto ret = mainThread_->ScheduleChangeAppGcState(0, 1); + EXPECT_EQ(ret, NO_ERROR); +} + /** * @tc.name: GetPluginNativeLibPath_0100 * @tc.desc: Get native library path when lib compressed and not isolated. -- Gitee