From 11548314f9f03a9826f2cc4352fecc1c0d248eed Mon Sep 17 00:00:00 2001 From: zhuhan Date: Tue, 9 May 2023 19:01:20 +0800 Subject: [PATCH] quick fix tdd Signed-off-by: zhuhan Change-Id: I0fcb8bdf78c4843deae8fc1a9cfbec70c117d424 --- .../quick_fix_manager_apply_task_test.cpp | 236 ++++++++++++++++++ tools/aa/BUILD.gn | 6 +- ...son => shell_command_executor_config.json} | 0 tools/aa/src/test_observer.cpp | 2 +- 4 files changed, 240 insertions(+), 4 deletions(-) rename tools/aa/resource/{shell_command_excutor_config.json => shell_command_executor_config.json} (100%) diff --git a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp index 0c151af2ac..f956aeda35 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp @@ -24,6 +24,7 @@ #define private public #include "quick_fix_manager_service.h" #undef private +#include "quick_fix_result_info.h" #include "system_ability_definition.h" using namespace testing; @@ -205,5 +206,240 @@ HWTEST_F(QuickFixManagerApplyTaskTest, NotifyApplyStatus_0100, TestSize.Level1) applyTask->NotifyApplyStatus(QUICK_FIX_OK); HILOG_INFO("%{public}s end.", __func__); } + +/** + * @tc.name: RemoveTimeoutTask_0100 + * @tc.desc: remove timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RemoveTimeoutTask_0100, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RemoveTimeoutTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: RemoveTimeoutTask_0200 + * @tc.desc: remove timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RemoveTimeoutTask_0200, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RemoveTimeoutTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: SetQuickFixInfo_0100 + * @tc.desc: set quick fix info + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, SetQuickFixInfo_0100, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::shared_ptr quickFixRes = + std::make_shared(); + bool res = applyTask->SetQuickFixInfo(quickFixRes); + ASSERT_EQ(res, false); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: SetQuickFixInfo_0200 + * @tc.desc: set quick fix info + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, SetQuickFixInfo_0200, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + auto quickFixRes = std::make_shared(); + quickFixRes->bundleName = "bundleName"; + quickFixRes->type = AppExecFwk::QuickFixType::PATCH; + bool res = applyTask->SetQuickFixInfo(quickFixRes); + ASSERT_EQ(res, true); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: SetQuickFixInfo_0300 + * @tc.desc: set quick fix info + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, SetQuickFixInfo_0300, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + auto quickFixRes = std::make_shared(); + quickFixRes->bundleName = "bundleName"; + bool res = applyTask->SetQuickFixInfo(quickFixRes); + ASSERT_EQ(res, false); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: GetRunningState_0100 + * @tc.desc: get running state + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, GetRunningState_0100, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, nullptr, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + bool res = applyTask->GetRunningState(); + ASSERT_EQ(res, false); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: PostNotifyLoadRepairPatchTask_0100 + * @tc.desc: post notify load repair patch task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostNotifyLoadRepairPatchTask_0100, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostNotifyLoadRepairPatchTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: PostNotifyLoadRepairPatchTask_0200 + * @tc.desc: post notify load repair patch task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostNotifyLoadRepairPatchTask_0200, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostNotifyLoadRepairPatchTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: PostNotifyUnloadRepairPatchTask_0100 + * @tc.desc: post notify unload repair patch task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostNotifyUnloadRepairPatchTask_0100, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostNotifyUnloadRepairPatchTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: PostNotifyUnloadRepairPatchTask_0200 + * @tc.desc: post notify unload repair patch task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostNotifyUnloadRepairPatchTask_0200, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostNotifyUnloadRepairPatchTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: PostNotifyHotReloadPageTask_0100 + * @tc.desc: post notify hotreload page task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostNotifyHotReloadPageTask_0100, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostNotifyHotReloadPageTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: PostNotifyHotReloadPageTask_0200 + * @tc.desc: post notify hotreload page task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostNotifyHotReloadPageTask_0200, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostNotifyHotReloadPageTask(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: RegAppStateObserver_0100 + * @tc.desc: register app state observer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RegAppStateObserver_0100, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RegAppStateObserver(); + HILOG_INFO("%{public}s end.", __func__); +} + +/** + * @tc.name: RegAppStateObserver_0200 + * @tc.desc: register app state observer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RegAppStateObserver_0200, TestSize.Level1) +{ + HILOG_INFO("%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, nullptr, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RegAppStateObserver(); + HILOG_INFO("%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index a5ff86c6cb..97102af232 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -116,8 +116,8 @@ ohos_executable("aa") { part_name = "ability_tools" } -ohos_prebuilt_etc("shell_command_excutor_config.json") { - source = "resource/shell_command_excutor_config.json" +ohos_prebuilt_etc("shell_command_executor_config.json") { + source = "resource/shell_command_executor_config.json" subsystem_name = "ability" part_name = "ability_tools" } @@ -125,6 +125,6 @@ ohos_prebuilt_etc("shell_command_excutor_config.json") { group("tools_aa") { deps = [ ":aa", - ":shell_command_excutor_config.json", + ":shell_command_executor_config.json", ] } diff --git a/tools/aa/resource/shell_command_excutor_config.json b/tools/aa/resource/shell_command_executor_config.json similarity index 100% rename from tools/aa/resource/shell_command_excutor_config.json rename to tools/aa/resource/shell_command_executor_config.json diff --git a/tools/aa/src/test_observer.cpp b/tools/aa/src/test_observer.cpp index 53dd024bc0..8bb1b06a4d 100644 --- a/tools/aa/src/test_observer.cpp +++ b/tools/aa/src/test_observer.cpp @@ -29,7 +29,7 @@ using namespace std::chrono_literals; namespace OHOS { namespace AAFwk { namespace { - constexpr const char* AA_TOOL_COMMAND_CONFIG = "/system/etc/shell_command_excutor_config.json"; + constexpr const char* AA_TOOL_COMMAND_CONFIG = "/system/etc/shell_command_executor_config.json"; } TestObserver::TestObserver() : isFinished_(false)