!5820 元能力故障管理提供故障通知接口和退出原因tdd测试用例添加

Merge pull request !5820 from xinking129/master
This commit is contained in:
openharmony_ci
2023-06-30 01:53:32 +00:00
committed by Gitee
22 changed files with 1177 additions and 9 deletions
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -73,5 +73,34 @@ HWTEST_F(AbilityManagerClientTest, AbilityManagerClient_DumpSysState_0100, TestS
HILOG_INFO("AbilityManagerClient_DumpSysState_0100 end");
}
/**
* @tc.name: AbilityManagerClient_ForceExitApp_0100
* @tc.desc: ForceExitApp
* @tc.type: FUNC
*/
HWTEST_F(AbilityManagerClientTest, AbilityManagerClient_ForceExitApp_0100, TestSize.Level1)
{
HILOG_INFO("AbilityManagerClient_ForceExitApp_0100 start");
int32_t pid = 0;
Reason exitReason = REASON_JS_ERROR;
auto result = AbilityManagerClient::GetInstance()->ForceExitApp(pid, exitReason);
EXPECT_EQ(result, ERR_OK);
HILOG_INFO("AbilityManagerClient_ForceExitApp_0100 end");
}
/**
* @tc.name: AbilityManagerClient_RecordAppExitReason_0100
* @tc.desc: RecordAppExitReason
* @tc.type: FUNC
*/
HWTEST_F(AbilityManagerClientTest, AbilityManagerClient_RecordAppExitReason_0100, TestSize.Level1)
{
HILOG_INFO("AbilityManagerClient_RecordAppExitReason_0100 start");
Reason exitReason = REASON_JS_ERROR;
auto result = AbilityManagerClient::GetInstance()->RecordAppExitReason(exitReason);
EXPECT_EQ(result, ERR_OK);
HILOG_INFO("AbilityManagerClient_RecordAppExitReason_0100 end");
}
} // namespace AAFwk
} // namespace OHOS
+4
View File
@@ -318,6 +318,7 @@ group("unittest") {
"ams_service_event_drive_test:unittest",
"ams_service_load_ability_process_test:unittest",
"ams_service_startup_test:unittest",
"app_lifecycle_deal_test:unittest",
"app_mgr_client_test:unittest",
"app_mgr_proxy_test:unittest",
"app_mgr_service_dump_test:unittest",
@@ -328,6 +329,8 @@ group("unittest") {
"app_mgr_stub_test:unittest",
"app_recovery_test:unittest",
"app_running_processes_info_test:unittest",
"app_scheduler_host_test:unittest",
"app_scheduler_proxy_test:unittest",
"app_scheduler_test:unittest",
"app_spawn_client_test:unittest",
"app_spawn_socket_test:unittest",
@@ -364,6 +367,7 @@ group("unittest") {
"dummy_values_bucket_test:unittest",
"event_report_test:unittest",
"extension_config_mgr_test:unittest",
"fault_data:unittest",
"file_path_utils_test:unittest",
"form_extension_context_test:unittest",
"frameworks_kits_ability_ability_runtime_test:unittest",
@@ -2220,5 +2220,44 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_IsValidMissionIds_006, Tes
proxy_ = std::make_shared<AbilityManagerProxy>(nullptr);
EXPECT_EQ(proxy_->IsValidMissionIds(missionIds, results), INNER_ERR);
}
/*
* Feature: AbilityManagerService
* Function: ForceExitApp
* SubFunction: NA
* FunctionPoints: AbilityManagerService ForceExitApp
* EnvConditions: NA
* CaseDescription: Verify the normal process of ForceExitApp
*/
HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ForceExitApp_001, TestSize.Level1)
{
EXPECT_CALL(*mock_, SendRequest(_, _, _, _))
.Times(1)
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest));
int32_t pid = 0;
Reason exitReason = REASON_JS_ERROR;
auto res = proxy_->ForceExitApp(pid, exitReason);
EXPECT_EQ(IAbilityManager::FORCE_EXIT_APP, mock_->code_);
EXPECT_EQ(res, NO_ERROR);
}
/*
* Feature: AbilityManagerService
* Function: RecordAppExitReason
* SubFunction: NA
* FunctionPoints: AbilityManagerService RecordAppExitReason
* EnvConditions: NA
* CaseDescription: Verify the normal process of RecordAppExitReason
*/
HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_RecordAppExitReason_001, TestSize.Level1)
{
EXPECT_CALL(*mock_, SendRequest(_, _, _, _))
.Times(1)
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest));
Reason exitReason = REASON_JS_ERROR;
auto res = proxy_->RecordAppExitReason(exitReason);
EXPECT_EQ(IAbilityManager::RECORD_APP_EXIT_REASON, mock_->code_);
EXPECT_EQ(res, NO_ERROR);
}
} // namespace AAFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -2695,5 +2695,41 @@ HWTEST_F(AmsAppRunningRecordTest, IsUIExtension_002, TestSize.Level1)
EXPECT_EQ(otherRecord->IsUIExtension(), true);
}
/*
* Feature: AMS
* Function: NotifyAppFault
* SubFunction: NotifyAppFault
* FunctionPoints: check params
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: Ability Unfocused
*/
HWTEST_F(AmsAppRunningRecordTest, NotifyAppFault_001, TestSize.Level1)
{
HILOG_DEBUG("NotifyAppFault_001 start.");
auto record = GetTestAppRunningRecord();
FaultData faultData;
record->appLifeCycleDeal_ = nullptr;
EXPECT_EQ(ERR_INVALID_VALUE, record->NotifyAppFault(faultData));
HILOG_DEBUG("NotifyAppFault_001 end.");
}
/*
* Feature: AMS
* Function: NotifyAppFault
* SubFunction: NotifyAppFault
* FunctionPoints: check params
* EnvConditions: Mobile that can run ohos test framework
* CaseDescription: Ability Unfocused
*/
HWTEST_F(AmsAppRunningRecordTest, NotifyAppFault_002, TestSize.Level1)
{
HILOG_DEBUG("NotifyAppFault_002 start.");
auto record = GetTestAppRunningRecord();
FaultData faultData;
record->appLifeCycleDeal_ = std::make_shared<AppLifeCycleDeal>();
EXPECT_EQ(ERR_INVALID_VALUE, record->NotifyAppFault(faultData));
HILOG_DEBUG("NotifyAppFault_002 end.");
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -0,0 +1,73 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/appmgrservice"
ohos_unittest("app_lifecycle_deal_test") {
module_out_path = module_output_path
configs = [
"${ability_runtime_services_path}/common:common_config",
"${ability_runtime_services_path}/abilitymgr:abilityms_config",
]
include_dirs = [
"${ability_runtime_test_path}/mock/common/include",
"${ability_runtime_test_path}/mock/services_appmgr_test/include",
"${ability_runtime_services_path}/abilitymgr/include",
"${ability_runtime_services_path}/appmgr/include",
"${ability_runtime_services_path}/appmgr/test/unittest/mocks",
"${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include",
]
sources = [ "app_lifecycle_deal_test.cpp" ]
deps = [
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/appmgr:libappms",
"${ability_runtime_services_path}/common:perm_verification",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:configuration",
"ability_base:session_info",
"ability_base:want",
"ability_base:zuri",
"ability_runtime:app_manager",
"access_token:libaccesstoken_sdk",
"access_token:libnativetoken",
"access_token:libtoken_setproc",
"bundle_framework:appexecfwk_base",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"init:libbeget_proxy",
"ipc:ipc_core",
]
if (background_task_mgr_continuous_task_enable) {
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
}
}
group("unittest") {
testonly = true
deps = [ ":app_lifecycle_deal_test" ]
}
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#define private public
#include "app_lifecycle_deal.h"
#include "mock_app_scheduler.h"
#undef private
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
class AppLifecycleDealTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void AppLifecycleDealTest::SetUpTestCase(void)
{}
void AppLifecycleDealTest::TearDownTestCase(void)
{}
void AppLifecycleDealTest::SetUp()
{}
void AppLifecycleDealTest::TearDown()
{}
/**
* @tc.name: NotifyAppFault_001
* @tc.desc: Verify that the NotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppLifecycleDealTest, NotifyAppFault_001, TestSize.Level1)
{
auto appLifeCycle = std::make_shared<AppLifeCycleDeal>();
FaultData faultData;
int32_t result = appLifeCycle->NotifyAppFault(faultData);
EXPECT_EQ(result, ERR_INVALID_VALUE);
}
/**
* @tc.name: NotifyAppFault_002
* @tc.desc: Verify that the NotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppLifecycleDealTest, NotifyAppFault_002, TestSize.Level1)
{
auto appLifeCycle = std::make_shared<AppLifeCycleDeal>();
sptr<MockAppScheduler> mockAppScheduler = new (std::nothrow) MockAppScheduler();
appLifeCycle->SetApplicationClient(mockAppScheduler);
FaultData faultData;
auto retsult = appLifeCycle->NotifyAppFault(faultData);
EXPECT_EQ(ERR_OK, retsult);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -625,5 +625,55 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_StartNativeProcessForDebugger_001, TestS
AAFwk::Want want;
appMgrClient->StartNativeProcessForDebugger(want);
}
/**
* @tc.name: AppMgrClient_GetBundleNameByPid_001
* @tc.desc: GetBundleNameByPid.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrClientTest, AppMgrClient_GetBundleNameByPid_001, TestSize.Level1)
{
auto appMgrClient = std::make_unique<AppMgrClient>();
EXPECT_NE(appMgrClient, nullptr);
auto result = appMgrClient->ConnectAppMgrService();
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
int32_t pid = 0;
std::string name = "test";
int32_t uid = 0;
auto ret = appMgrClient->GetBundleNameByPid(pid, name, uid);
EXPECT_EQ(ret, NO_ERROR);
}
/**
* @tc.name: AppMgrClient_NotifyAppFault_001
* @tc.desc: NotifyAppFault.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrClientTest, AppMgrClient_NotifyAppFault_001, TestSize.Level1)
{
auto appMgrClient = std::make_unique<AppMgrClient>();
EXPECT_NE(appMgrClient, nullptr);
auto result = appMgrClient->ConnectAppMgrService();
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
FaultData faultData;
auto resultCode = appMgrClient->NotifyAppFault(faultData);
EXPECT_EQ(resultCode, ERR_INVALID_VALUE);
}
/**
* @tc.name: AppMgrClient_NotifyAppFaultBySA_001
* @tc.desc: NotifyAppFaultBySA.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrClientTest, AppMgrClient_NotifyAppFaultBySA_001, TestSize.Level1)
{
auto appMgrClient = std::make_unique<AppMgrClient>();
EXPECT_NE(appMgrClient, nullptr);
auto result = appMgrClient->ConnectAppMgrService();
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
AppFaultDataBySA faultData;
auto resultCode = appMgrClient->NotifyAppFaultBySA(faultData);
EXPECT_EQ(resultCode, ERR_INVALID_VALUE);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -233,5 +233,37 @@ HWTEST_F(AppMgrProxyTest, PreStartNWebSpawnProcess_001, TestSize.Level0)
HILOG_INFO("%{public}s end.", __func__);
}
/**
* @tc.name: NotifyAppFault_001
* @tc.desc: Notify app fault.
* @tc.type: FUNC
* @tc.require: issueI79RY8
*/
HWTEST_F(AppMgrProxyTest, NotifyAppFault_001, TestSize.Level1)
{
EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _))
.Times(1)
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
FaultData faultData;
appMgrProxy_->NotifyAppFault(faultData);
EXPECT_EQ(mockAppMgrService_->code_, static_cast<uint32_t>(IAppMgr::Message::NOTIFY_APP_FAULT));
}
/**
* @tc.name: NotifyAppFaultBySA_001
* @tc.desc: Notify app fault by SA.
* @tc.type: FUNC
* @tc.require: issueI79RY8
*/
HWTEST_F(AppMgrProxyTest, NotifyAppFaultBySA_001, TestSize.Level1)
{
EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _))
.Times(1)
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
AppFaultDataBySA faultData;
appMgrProxy_->NotifyAppFaultBySA(faultData);
EXPECT_EQ(mockAppMgrService_->code_, static_cast<uint32_t>(IAppMgr::Message::NOTIFY_APP_FAULT_BY_SA));
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -409,5 +409,55 @@ HWTEST_F(AppMgrServiceInnerTest, UpDateStartupType_003, TestSize.Level1)
EXPECT_EQ(expectedVal, extensionType);
HILOG_INFO("UpDateStartupType_003 end");
}
/**
* @tc.name: NotifyAppFault_001
* @tc.desc: Verify that the NotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceInnerTest, NotifyAppFault_001, TestSize.Level1)
{
HILOG_INFO("NotifyAppFault_001 start");
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
EXPECT_NE(appMgrServiceInner, nullptr);
FaultData faultData;
EXPECT_EQ(ERR_INVALID_VALUE, appMgrServiceInner->NotifyAppFault(faultData));
HILOG_INFO("NotifyAppFault_001 end");
}
/**
* @tc.name: NotifyAppFaultBySA_001
* @tc.desc: Verify that the NotifyAppFaultBySA interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceInnerTest, NotifyAppFaultBySA_001, TestSize.Level1)
{
HILOG_INFO("NotifyAppFaultBySA_001 start");
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
EXPECT_NE(appMgrServiceInner, nullptr);
AppFaultDataBySA faultData;
appMgrServiceInner->appRunningManager_ = nullptr;
EXPECT_EQ(ERR_INVALID_VALUE, appMgrServiceInner->NotifyAppFaultBySA(faultData));
HILOG_INFO("NotifyAppFaultBySA_001 end");
}
/**
* @tc.name: FaultTypeToString_001
* @tc.desc: Verify that the FaultTypeToString interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceInnerTest, FaultTypeToString_001, TestSize.Level1)
{
HILOG_INFO("FaultTypeToString_001 start");
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
EXPECT_NE(appMgrServiceInner, nullptr);
EXPECT_EQ("CPP_CRASH", appMgrServiceInner->FaultTypeToString(AppExecFwk::FaultDataType::CPP_CRASH));
EXPECT_EQ("JS_ERROR", appMgrServiceInner->FaultTypeToString(AppExecFwk::FaultDataType::JS_ERROR));
EXPECT_EQ("APP_FREEZE", appMgrServiceInner->FaultTypeToString(AppExecFwk::FaultDataType::APP_FREEZE));
EXPECT_EQ("PERFORMANCE_CONTROL",
appMgrServiceInner->FaultTypeToString(AppExecFwk::FaultDataType::PERFORMANCE_CONTROL));
EXPECT_EQ("RESOURCE_CONTROL", appMgrServiceInner->FaultTypeToString(AppExecFwk::FaultDataType::RESOURCE_CONTROL));
HILOG_INFO("FaultTypeToString_001 end");
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -3260,5 +3260,48 @@ HWTEST_F(AppMgrServiceInnerTest, SetCurrentUserId_001, TestSize.Level0)
HILOG_INFO("SetCurrentUserId_001 end");
}
/**
* @tc.name: GetBundleNameByPid_001
* @tc.desc: get bundle name by Pid.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceInnerTest, GetBundleNameByPid_001, TestSize.Level1)
{
HILOG_INFO("GetBundleNameByPid_001 start");
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
EXPECT_NE(appMgrServiceInner, nullptr);
int32_t pid = 0;
std::string name = "test_name";
int32_t uid = 0;
auto ret = appMgrServiceInner->GetBundleNameByPid(pid, name, uid);
EXPECT_EQ(ret, ERR_INVALID_OPERATION);
HILOG_INFO("GetBundleNameByPid_001 end");
}
/**
* @tc.name: GetBundleNameByPid_002
* @tc.desc: get bundle name by Pid.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceInnerTest, GetBundleNameByPid_002, TestSize.Level1)
{
HILOG_INFO("GetBundleNameByPid_002 start");
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
EXPECT_NE(appMgrServiceInner, nullptr);
BundleInfo info;
std::string processName = "test_processName";
appMgrServiceInner->appRunningManager_->CreateAppRunningRecord(applicationInfo_, processName, info);
int32_t pid = 0;
std::string name = "test_name";
int32_t uid = 0;
auto ret = appMgrServiceInner->GetBundleNameByPid(pid, name, uid);
EXPECT_EQ(ret, ERR_OK);
HILOG_INFO("GetBundleNameByPid_002 end");
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -1203,5 +1203,52 @@ HWTEST_F(AppMgrServiceTest, NotifyUnLoadRepairPatch_002, TestSize.Level0)
int32_t res = appMgrService->NotifyUnLoadRepairPatch(bundleName, callback);
EXPECT_NE(res, ERR_INVALID_OPERATION);
}
/**
* @tc.name: NotifyAppFault_001
* @tc.desc: Verify that the NotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceTest, NotifyAppFault_001, TestSize.Level1)
{
sptr<AppMgrService> appMgrService = new (std::nothrow) AppMgrService();
appMgrService->SetInnerService(nullptr);
FaultData faultData;
int32_t res = appMgrService->NotifyAppFault(faultData);
EXPECT_EQ(res, ERR_INVALID_OPERATION);
}
/**
* @tc.name: NotifyAppFault_002
* @tc.desc: Verify that the NotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceTest, NotifyAppFault_002, TestSize.Level1)
{
sptr<AppMgrService> appMgrService = new (std::nothrow) AppMgrService();
appMgrService->SetInnerService(nullptr);
AppFaultDataBySA faultData;
int32_t res = appMgrService->NotifyAppFaultBySA(faultData);
EXPECT_EQ(res, ERR_INVALID_OPERATION);
}
/**
* @tc.name: NotifyAppFault_003
* @tc.desc: Verify that the NotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceTest, NotifyAppFault_003, TestSize.Level1)
{
sptr<AppMgrService> appMgrService = new (std::nothrow) AppMgrService();
appMgrService->SetInnerService(std::make_shared<AppMgrServiceInner>());
appMgrService->taskHandler_ = taskHandler_;
appMgrService->eventHandler_ = std::make_shared<AMSEventHandler>(taskHandler_, appMgrService->appMgrServiceInner_);
AppFaultDataBySA faultData;
int32_t res = appMgrService->NotifyAppFaultBySA(faultData);
EXPECT_EQ(ERR_INVALID_VALUE, res);
appMgrService->appMgrServiceInner_ = nullptr;
res = appMgrService->NotifyAppFaultBySA(faultData);
EXPECT_EQ(ERR_INVALID_OPERATION, res);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -218,5 +218,54 @@ HWTEST_F(AppMgrStubTest, PreStartNWebSpawnProcess_001, TestSize.Level0)
HILOG_INFO("%{public}s end.", __func__);
}
/**
* @tc.name: HandleNotifyFault_001
* @tc.desc: Handle notify fault.
* @tc.type: FUNC
* @tc.require: issueI79RY8
*/
HWTEST_F(AppMgrStubTest, HandleNotifyFault_001, TestSize.Level1)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
WriteInterfaceToken(data);
FaultData faultData;
faultData.errorObject.name = "testName";
faultData.errorObject.message = "testMessage";
faultData.errorObject.stack = "testStack";
faultData.faultType = FaultDataType::UNKNOWN;
data.WriteParcelable(&faultData);
EXPECT_CALL(*mockAppMgrService_, NotifyAppFault(_)).Times(1);
auto result = mockAppMgrService_->OnRemoteRequest(
static_cast<uint32_t>(IAppMgr::Message::NOTIFY_APP_FAULT), data, reply, option);
EXPECT_EQ(result, NO_ERROR);
}
/**
* @tc.name: HandleNotifyFaultBySA_001
* @tc.desc: Handle notify fault by SA.
* @tc.type: FUNC
* @tc.require: issueI79RY8
*/
HWTEST_F(AppMgrStubTest, HandleNotifyFaultBySA_001, TestSize.Level1)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
WriteInterfaceToken(data);
AppFaultDataBySA faultData;
faultData.errorObject.name = "testName";
faultData.errorObject.message = "testMessage";
faultData.errorObject.stack = "testStack";
faultData.faultType = FaultDataType::UNKNOWN;
faultData.pid = 24;
data.WriteParcelable(&faultData);
EXPECT_CALL(*mockAppMgrService_, NotifyAppFaultBySA(_)).Times(1);
auto result = mockAppMgrService_->OnRemoteRequest(
static_cast<uint32_t>(IAppMgr::Message::NOTIFY_APP_FAULT_BY_SA), data, reply, option);
EXPECT_EQ(result, NO_ERROR);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -0,0 +1,70 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/appmgrservice"
ohos_unittest("app_scheduler_host_test") {
module_out_path = module_output_path
configs = [
"${ability_runtime_services_path}/common:common_config",
"${ability_runtime_services_path}/abilitymgr:abilityms_config",
]
include_dirs = [
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
"${ability_runtime_services_path}/appmgr/include",
"${ability_runtime_test_path}/mock/services_appmgr_test/include",
"${ability_runtime_test_path}/moduletest/mock/include",
]
sources = [ "app_scheduler_host_test.cpp" ]
deps = [
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/common:perm_verification",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:configuration",
"ability_base:session_info",
"ability_base:want",
"ability_base:zuri",
"ability_runtime:app_manager",
"access_token:libaccesstoken_sdk",
"access_token:libnativetoken",
"access_token:libtoken_setproc",
"bundle_framework:appexecfwk_base",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"init:libbeget_proxy",
"ipc:ipc_core",
]
if (background_task_mgr_continuous_task_enable) {
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
}
}
group("unittest") {
testonly = true
deps = [ ":app_scheduler_host_test" ]
}
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#define private public
#include "fault_data.h"
#include "message_parcel.h"
#include "mock_app_scheduler.h"
#undef private
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
class AppSchedulerHostTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
sptr<MockAppScheduler> mockAppScheduler_;
void WriteInterfaceToken(MessageParcel& data);
};
void AppSchedulerHostTest::SetUpTestCase(void)
{}
void AppSchedulerHostTest::TearDownTestCase(void)
{}
void AppSchedulerHostTest::SetUp()
{
GTEST_LOG_(INFO) << "AppSchedulerHostTest::SetUp()";
mockAppScheduler_ = new MockAppScheduler();
}
void AppSchedulerHostTest::TearDown()
{}
void AppSchedulerHostTest::WriteInterfaceToken(MessageParcel& data)
{
GTEST_LOG_(INFO) << "AppSchedulerHostTest::WriteInterfaceToken()";
data.WriteInterfaceToken(AppSchedulerHost::GetDescriptor());
}
/**
* @tc.name: HandleNotifyAppFault_001
* @tc.desc: Verify that the HandleNotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppSchedulerHostTest, HandleNotifyAppFault_001, TestSize.Level1)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
WriteInterfaceToken(data);
FaultData faultData;
faultData.errorObject.name = "testName";
faultData.errorObject.message = "testMessage";
faultData.errorObject.stack = "testStack";
faultData.faultType = FaultDataType::UNKNOWN;
data.WriteParcelable(&faultData);
EXPECT_CALL(*mockAppScheduler_, ScheduleNotifyAppFault(_)).Times(1);
auto result = mockAppScheduler_->OnRemoteRequest(
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_NOTIFY_FAULT), data, reply, option);
EXPECT_EQ(result, NO_ERROR);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -0,0 +1,70 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/appmgrservice"
ohos_unittest("app_scheduler_proxy_test") {
module_out_path = module_output_path
configs = [
"${ability_runtime_services_path}/common:common_config",
"${ability_runtime_services_path}/abilitymgr:abilityms_config",
]
include_dirs = [
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
"${ability_runtime_services_path}/appmgr/include",
"${ability_runtime_test_path}/mock/services_appmgr_test/include",
"${ability_runtime_test_path}/moduletest/mock/include",
]
sources = [ "app_scheduler_proxy_test.cpp" ]
deps = [
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/common:perm_verification",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:configuration",
"ability_base:session_info",
"ability_base:want",
"ability_base:zuri",
"ability_runtime:app_manager",
"access_token:libaccesstoken_sdk",
"access_token:libnativetoken",
"access_token:libtoken_setproc",
"bundle_framework:appexecfwk_base",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"init:libbeget_proxy",
"ipc:ipc_core",
]
if (background_task_mgr_continuous_task_enable) {
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
}
}
group("unittest") {
testonly = true
deps = [ ":app_scheduler_proxy_test" ]
}
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#define private public
#include "app_scheduler_proxy.h"
#include "fault_data.h"
#undef private
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
class AppSchedulerProxyTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void AppSchedulerProxyTest::SetUpTestCase(void)
{}
void AppSchedulerProxyTest::TearDownTestCase(void)
{}
void AppSchedulerProxyTest::SetUp()
{}
void AppSchedulerProxyTest::TearDown()
{}
/**
* @tc.name: ScheduleNotifyAppFault_001
* @tc.desc: Verify that the ScheduleNotifyAppFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppSchedulerProxyTest, ScheduleNotifyAppFault_001, TestSize.Level1)
{
sptr<IRemoteObject> impl;
sptr<AppSchedulerProxy> appSchedulerProxy = new (std::nothrow) AppSchedulerProxy(impl);
FaultData faultData;
faultData.faultType = FaultDataType::APP_FREEZE;
faultData.errorObject.message = "msgContent";
faultData.errorObject.stack = "stack";
faultData.errorObject.name = "eventType";
int32_t result = appSchedulerProxy->ScheduleNotifyAppFault(faultData);
EXPECT_EQ(result, ERR_NULL_OBJECT);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -1148,5 +1148,17 @@ HWTEST_F(AppSchedulerTest, AppScheduler_SetCurrentUserId_001, TestSize.Level1)
ASSERT_NE(DelayedSingleton<AppScheduler>::GetInstance()->appMgrClient_, nullptr);
DelayedSingleton<AppScheduler>::GetInstance()->SetCurrentUserId(userId);
}
/**
* @tc.name: AppScheduler_NotifyFault_001
* @tc.desc: Verify that the NotifyFault interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(AppSchedulerTest, AppScheduler_NotifyFault_001, TestSize.Level1)
{
AppExecFwk::FaultData faultData;
int res = DelayedSingleton<AppScheduler>::GetInstance()->NotifyFault(faultData);
EXPECT_EQ(res, INNER_ERR);
}
} // namespace AAFwk
} // namespace OHOS
@@ -2183,5 +2183,22 @@ HWTEST_F(MainThreadTest, HandleOnOverlayChanged_0100, TestSize.Level1)
mainThread_->HandleOnOverlayChanged(data, resourceManager, bundleName, moduleName, loadPath);
}
/**
* @tc.name: ScheduleNotifyAppFault_0100
* @tc.desc: Schedule notify app Fault.
* @tc.type: FUNC
* @tc.require: issueI79RY8
*/
HWTEST_F(MainThreadTest, ScheduleNotifyAppFault_0100, TestSize.Level1)
{
FaultData faultData;
faultData.faultType = FaultDataType::APP_FREEZE;
faultData.errorObject.message = "msgContent";
faultData.errorObject.stack = "stack";
faultData.errorObject.name = "eventType";
auto ret = mainThread_->ScheduleNotifyAppFault(faultData);
EXPECT_EQ(ret, NO_ERROR);
}
} // namespace AppExecFwk
} // namespace OHOS
+70
View File
@@ -0,0 +1,70 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/appmgrservice"
ohos_unittest("fault_data_test") {
module_out_path = module_output_path
configs = [
"${ability_runtime_services_path}/common:common_config",
"${ability_runtime_services_path}/abilitymgr:abilityms_config",
]
include_dirs = [
"${ability_runtime_test_path}/mock/common/include",
"${ability_runtime_services_path}/abilitymgr/include",
"${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include",
"${ability_runtime_services_path}/appmgr/test/unittest/mocks",
]
sources = [ "fault_data_test.cpp" ]
deps = [
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/common:perm_verification",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:configuration",
"ability_base:session_info",
"ability_base:want",
"ability_base:zuri",
"ability_runtime:app_manager",
"access_token:libaccesstoken_sdk",
"access_token:libnativetoken",
"access_token:libtoken_setproc",
"bundle_framework:appexecfwk_base",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"init:libbeget_proxy",
"ipc:ipc_core",
]
if (background_task_mgr_continuous_task_enable) {
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
}
}
group("unittest") {
testonly = true
deps = [ ":fault_data_test" ]
}
@@ -0,0 +1,216 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#define private public
#include "fault_data.h"
#include "message_parcel.h"
#undef private
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
class FaultDataTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void FaultDataTest::SetUpTestCase(void)
{}
void FaultDataTest::TearDownTestCase(void)
{}
void FaultDataTest::SetUp()
{}
void FaultDataTest::TearDown()
{}
/**
* @tc.name: ReadFromParcel_001
* @tc.desc: Verify that the ReadFromParcel interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(FaultDataTest, ReadFromParcel_001, TestSize.Level1)
{
auto faultData = std::make_shared<FaultData>();
MessageParcel messageFirst;
bool retFirst = faultData->ReadFromParcel(messageFirst);
EXPECT_EQ(false, retFirst);
MessageParcel messageSecond;
std::string helloWord = "HelloWord";
messageSecond.WriteString(helloWord);
bool retSecond = faultData->ReadFromParcel(messageSecond);
EXPECT_EQ(false, retSecond);
MessageParcel messageThird;
messageThird.WriteString(helloWord);
messageThird.WriteString(helloWord);
bool retThird = faultData->ReadFromParcel(messageThird);
EXPECT_EQ(false, retThird);
MessageParcel messageFourth;
messageFourth.WriteString(helloWord);
messageFourth.WriteString(helloWord);
messageFourth.WriteString(helloWord);
bool retFourth = faultData->ReadFromParcel(messageFourth);
EXPECT_EQ(false, retFourth);
MessageParcel messageFifth;
messageFifth.WriteString(helloWord);
messageFifth.WriteString(helloWord);
messageFifth.WriteString(helloWord);
messageFifth.WriteInt32(12);
bool retFifth = faultData->ReadFromParcel(messageFifth);
EXPECT_EQ(true, retFifth);
}
/**
* @tc.name: Unmarshalling_001
* @tc.desc: Verify that the Unmarshalling interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(FaultDataTest, Unmarshalling_001, TestSize.Level1)
{
auto faultData = std::make_shared<FaultData>();
MessageParcel message;
auto retFirst = faultData->Unmarshalling(message);
EXPECT_EQ(nullptr, retFirst);
std::string helloWord = "HelloWord";
message.WriteString(helloWord);
message.WriteString(helloWord);
message.WriteString(helloWord);
message.WriteInt32(12);
auto retSecond = faultData->Unmarshalling(message);
EXPECT_NE(nullptr, retSecond);
}
/**
* @tc.name: Marshalling_001
* @tc.desc: Verify that the Marshalling interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(FaultDataTest, Marshalling_001, TestSize.Level1)
{
auto faultData = std::make_shared<FaultData>();
faultData->errorObject.name = "1234";
faultData->errorObject.message = "5678";
faultData->errorObject.stack = "90";
MessageParcel message;
bool ret = faultData->Marshalling(message);
EXPECT_EQ(true, ret);
}
/**
* @tc.name: ReadFromParcel_002
* @tc.desc: Verify that the ReadFromParcel interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(FaultDataTest, ReadFromParcel_002, TestSize.Level1)
{
auto appFaultDataBySA = std::make_shared<AppFaultDataBySA>();
MessageParcel messageFirst;
bool retFirst = appFaultDataBySA->ReadFromParcel(messageFirst);
EXPECT_EQ(false, retFirst);
MessageParcel messageSecond;
std::string helloWord = "HelloWord";
messageSecond.WriteString(helloWord);
bool retSecond = appFaultDataBySA->ReadFromParcel(messageSecond);
EXPECT_EQ(false, retSecond);
MessageParcel messageThird;
messageThird.WriteString(helloWord);
messageThird.WriteString(helloWord);
bool retThird = appFaultDataBySA->ReadFromParcel(messageThird);
EXPECT_EQ(false, retThird);
MessageParcel messageFourth;
messageFourth.WriteString(helloWord);
messageFourth.WriteString(helloWord);
messageFourth.WriteString(helloWord);
bool retFourth = appFaultDataBySA->ReadFromParcel(messageFourth);
EXPECT_EQ(false, retFourth);
MessageParcel messageFifth;
messageFifth.WriteString(helloWord);
messageFifth.WriteString(helloWord);
messageFifth.WriteString(helloWord);
messageFifth.WriteInt32(12);
bool retFifth = appFaultDataBySA->ReadFromParcel(messageFifth);
EXPECT_EQ(false, retFifth);
MessageParcel messageSixth;
messageSixth.WriteString(helloWord);
messageSixth.WriteString(helloWord);
messageSixth.WriteString(helloWord);
messageSixth.WriteInt32(12);
messageSixth.WriteInt32(34);
bool retSixth = appFaultDataBySA->ReadFromParcel(messageSixth);
EXPECT_EQ(true, retSixth);
}
/**
* @tc.name: Unmarshalling_002
* @tc.desc: Verify that the Unmarshalling interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(FaultDataTest, Unmarshalling_002, TestSize.Level1)
{
auto appFaultDataBySA = std::make_shared<AppFaultDataBySA>();
MessageParcel message;
auto retFirst = appFaultDataBySA->Unmarshalling(message);
EXPECT_EQ(nullptr, retFirst);
std::string helloWord = "HelloWord";
message.WriteString(helloWord);
message.WriteString(helloWord);
message.WriteString(helloWord);
message.WriteInt32(12);
message.WriteInt32(34);
message.WriteInt32(56);
message.WriteString(helloWord);
auto retSecond = appFaultDataBySA->Unmarshalling(message);
EXPECT_NE(nullptr, retSecond);
}
/**
* @tc.name: Marshalling_002
* @tc.desc: Verify that the Marshalling interface calls normally
* @tc.type: FUNC
*/
HWTEST_F(FaultDataTest, Marshalling_002, TestSize.Level1)
{
auto appFaultDataBySA = std::make_shared<AppFaultDataBySA>();
appFaultDataBySA->errorObject.name = "1234";
appFaultDataBySA->errorObject.message = "5678";
appFaultDataBySA->errorObject.stack = "90";
MessageParcel message;
bool ret = appFaultDataBySA->Marshalling(message);
EXPECT_EQ(true, ret);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -480,5 +480,22 @@ HWTEST_F(WatchdogTest, WatchdogTest_GetTag_001, TestSize.Level1)
EXPECT_EQ(mainHandlerDumper_->GetTag(), "");
GTEST_LOG_(INFO) << "WatchdogTest_GetTag_001 end";
}
/**
* @tc.number: WatchdogTest_ReportEvent_008
* @tc.name: ReportEvent
* @tc.desc: Verify that function ReportEvent.
*/
HWTEST_F(WatchdogTest, WatchdogTest_ReportEvent_008, TestSize.Level1)
{
watchdog_->lastWatchTime_ = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::
system_clock::now().time_since_epoch()).count() - TEST_INTERVAL_TIME;
std::shared_ptr<EventHandler> eventHandler = std::make_shared<EventHandler>();
watchdog_->applicationInfo_ = std::make_shared<ApplicationInfo>();
watchdog_->needReport_ = true;
watchdog_->isSixSecondEvent_.store(true);
EXPECT_TRUE(watchdog_->needReport_);
watchdog_->ReportEvent();
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -755,6 +755,21 @@ HWTEST_F(JsRuntimeTest, PostSyncTask_0100, TestSize.Level0)
EXPECT_EQ(taskExecuted, true);
}
/**
* @tc.name: JsRuntimeStartProfilerTest_0100
* @tc.desc: JsRuntime test for StartProfiler.
* @tc.type: FUNC
*/
HWTEST_F(JsRuntimeTest, JsRuntimeStartProfilerTest_0100, TestSize.Level1)
{
AbilityRuntime::Runtime::Options options;
options.preload = false;
auto jsRuntime = AbilityRuntime::JsRuntime::Create(options);
std::string perfCmd = "profile test";
jsRuntime->StartProfiler(perfCmd);
ASSERT_NE(jsRuntime, nullptr);
}
/**
* @tc.name: PostTask_0100
* @tc.desc: Js runtime post task.