mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
[BUG] TDD增强ability_manager_service 3
Signed-off-by: zhubingwei <zhubingwei@huawei.com>
This commit is contained in:
+112
-1
@@ -20,7 +20,7 @@
|
||||
#include "mock_ipc_skeleton.h"
|
||||
#include "mock_permission_verification.h"
|
||||
#include "mock_my_flag.h"
|
||||
#include "mock_permission_verification.h"
|
||||
|
||||
#include "ability_manager_service.h"
|
||||
#include "ability_start_setting.h"
|
||||
#include "recovery_param.h"
|
||||
@@ -54,6 +54,8 @@ class AbilityManagerServiceThirdTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
std::shared_ptr<AbilityRecord> MockAbilityRecord(AbilityType);
|
||||
sptr<Token> MockToken(AbilityType);
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
|
||||
@@ -69,6 +71,23 @@ void AbilityManagerServiceThirdTest::TearDownTestCase() {}
|
||||
void AbilityManagerServiceThirdTest::SetUp() {}
|
||||
|
||||
void AbilityManagerServiceThirdTest::TearDown() {}
|
||||
std::shared_ptr<AbilityRecord> AbilityManagerServiceThirdTest::MockAbilityRecord(AbilityType abilityType)
|
||||
{
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.test.demo";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = abilityType;
|
||||
return AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
}
|
||||
|
||||
sptr<Token> AbilityManagerServiceThirdTest::MockToken(AbilityType abilityType)
|
||||
{
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = MockAbilityRecord(abilityType);
|
||||
if (!abilityRecord) {
|
||||
return nullptr;
|
||||
}
|
||||
return abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
@@ -1984,6 +2003,7 @@ HWTEST_F(AbilityManagerServiceThirdTest, RequestDialogService_002, TestSize.Leve
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceThirdTest, RequestDialogServiceInner_001, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest RequestDialogServiceInner_001 start");
|
||||
auto abilityMs = std::make_shared<AbilityManagerService>();
|
||||
Want want;
|
||||
const sptr<IRemoteObject> callerToken;
|
||||
@@ -1991,6 +2011,15 @@ HWTEST_F(AbilityManagerServiceThirdTest, RequestDialogServiceInner_001, TestSize
|
||||
int32_t userId = 0;
|
||||
auto result = abilityMs->RequestDialogServiceInner(want, callerToken, requestCode, userId);
|
||||
EXPECT_EQ(result, ERR_INVALID_CALLER);
|
||||
|
||||
abilityMs->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
|
||||
abilityMs->subManagersHelper_->currentUIAbilityManager_ = std::make_shared<UIAbilityLifecycleManager>();
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = MockAbilityRecord(AbilityType::PAGE);
|
||||
sptr<IRemoteObject> callerToken2 = abilityRecord->GetToken();
|
||||
|
||||
result = abilityMs->RequestDialogServiceInner(want, callerToken2, requestCode, userId);
|
||||
EXPECT_EQ(result, ERR_INVALID_CALLER);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest RequestDialogServiceInner_001 end");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2107,6 +2136,23 @@ HWTEST_F(AbilityManagerServiceThirdTest, AppUpgradeCompleted_002, TestSize.Level
|
||||
EXPECT_TRUE(abilityMs != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: GetConfiguration
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService GetConfiguration
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceThirdTest, GetConfiguration_001, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetConfiguration_001 start");
|
||||
auto abilityMs_ = std::make_shared<AbilityManagerService>();
|
||||
AppExecFwk::Configuration config;
|
||||
abilityMs_->SubscribeBackgroundTask();
|
||||
EXPECT_EQ(abilityMs_->GetConfiguration(config), 0);
|
||||
abilityMs_->UnSubscribeBackgroundTask();
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest GetConfiguration_001 end");
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: GetAppMgr
|
||||
@@ -2119,6 +2165,42 @@ HWTEST_F(AbilityManagerServiceThirdTest, GetAppMgr_001, TestSize.Level1)
|
||||
EXPECT_NE(result, nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ReportAbilitStartInfoToRSS
|
||||
* FunctionPoints: AbilityManagerService ReportAbilitStartInfoToRSS
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceThirdTest, ReportAbilitStartInfoToRSS_001, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReportAbilitStartInfoToRSS start");
|
||||
auto abilityMs = std::make_shared<AbilityManagerService>();
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
abilityInfo.type = AppExecFwk::AbilityType::PAGE;
|
||||
abilityMs->ReportAbilitStartInfoToRSS(abilityInfo);
|
||||
EXPECT_EQ(abilityInfo.type, AppExecFwk::AbilityType::PAGE);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReportAbilitStartInfoToRSS end");
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ReportAbilitAssociatedStartInfoToRSS
|
||||
* FunctionPoints: AbilityManagerService ReportAbilitAssociatedStartInfoToRSS
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceThirdTest, ReportAbilitAssociatedStartInfoToRSS_001, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReportAbilitAssociatedStartInfoToRSS start");
|
||||
auto abilityMs = std::make_shared<AbilityManagerService>();
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
abilityInfo.type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> callerToken = nullptr;
|
||||
int64_t type = 0;
|
||||
abilityMs->ReportAbilitAssociatedStartInfoToRSS(abilityInfo, type, callerToken);
|
||||
callerToken = MockToken(AbilityType::PAGE);
|
||||
abilityMs->ReportAbilitAssociatedStartInfoToRSS(abilityInfo, type, callerToken);
|
||||
EXPECT_EQ(abilityInfo.type, AppExecFwk::AbilityType::PAGE);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest ReportAbilitAssociatedStartInfoToRSS end");
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: OnAddSystemAbility
|
||||
@@ -2401,6 +2483,35 @@ HWTEST_F(AbilityManagerServiceThirdTest, StartExtensionAbilityInner_003, TestSiz
|
||||
EXPECT_EQ(result, ERR_INVALID_CALLER);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: StartExtensionAbilityInner
|
||||
* FunctionPoints: AbilityManagerService StartExtensionAbilityInner
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceThirdTest, StartExtensionAbilityInner_004, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartExtensionAbilityInner_004 start");
|
||||
auto abilityMs = std::make_shared<AbilityManagerService>();
|
||||
Want want;
|
||||
sptr<IRemoteObject> callerToken = nullptr;
|
||||
int32_t userId = 0;
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::VPN;
|
||||
bool checkSystemCaller = true;
|
||||
bool isImplicit = true;
|
||||
bool isDlp = true;
|
||||
abilityMs->interceptorExecuter_ = std::make_shared<AbilityInterceptorExecuter>();
|
||||
abilityMs->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
|
||||
auto result = abilityMs->StartExtensionAbilityInner(want, callerToken, userId, extensionType, checkSystemCaller,
|
||||
isImplicit, isDlp);
|
||||
EXPECT_EQ(result, ERR_IMPLICIT_START_ABILITY_FAIL);
|
||||
|
||||
abilityMs-> implicitStartProcessor_ = std::make_shared<ImplicitStartProcessor>();
|
||||
result = abilityMs->StartExtensionAbilityInner(want, callerToken, userId, extensionType, checkSystemCaller,
|
||||
isImplicit, isDlp);
|
||||
EXPECT_EQ(result, ERR_IMPLICIT_START_ABILITY_FAIL);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartExtensionAbilityInner_004 end");
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: MoveAbilityToBackground
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ using InterceptorMap = std::unordered_map<std::string, std::shared_ptr<IAbilityI
|
||||
* @class AbilityInterceptorExecuter
|
||||
* AbilityInterceptorExecuter excute the interceptors.
|
||||
*/
|
||||
class AbilityInterceptorExecuter {
|
||||
class MockAbilityInterceptorExecuter {
|
||||
public:
|
||||
/**
|
||||
* Add Interceptor to Executer.
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
|
||||
ErrCode AbilityInterceptorExecuter::DoProcess(AbilityInterceptorParam param)
|
||||
ErrCode MockAbilityInterceptorExecuter::DoProcess(AbilityInterceptorParam param)
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user