mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
Modify data saving asynchronous bug
Signed-off-by: zhaoyuan17 <zhaoyuan17@huawei.com>
This commit is contained in:
parent
7e2a19253a
commit
b2d02d951e
@ -88,10 +88,9 @@ public:
|
||||
/**
|
||||
* @brief Save data and states of an ability when it is restored by the system. and Calling information back to
|
||||
* Ability. This method should be implemented by a Page ability.
|
||||
* @param instate The Want object to connect to.
|
||||
*
|
||||
*/
|
||||
void DispatchSaveAbilityState(PacMap &outState);
|
||||
void DispatchSaveAbilityState();
|
||||
|
||||
/**
|
||||
* @brief Restores data and states of an ability when it is restored by the system. and Calling information back
|
||||
@ -390,6 +389,15 @@ protected:
|
||||
*/
|
||||
bool CheckAndRestore();
|
||||
|
||||
/**
|
||||
* @brief Check if it needs to save the data to the ability.
|
||||
*
|
||||
* @return Return true if success, otherwise return false.
|
||||
*/
|
||||
bool CheckAndSave();
|
||||
|
||||
PacMap & GetRestoreData();
|
||||
|
||||
int lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
sptr<IRemoteObject> token_;
|
||||
std::shared_ptr<Ability> ability_;
|
||||
@ -422,6 +430,7 @@ private:
|
||||
sptr<AbilityKeyEventHandle> abilityKeyEventHandle_ = nullptr;
|
||||
sptr<AbilityTouchEventHandle> abilityTouchEventHandle_ = nullptr;
|
||||
bool hasSaveData_ = false;
|
||||
bool needSaveDate_ = false;
|
||||
PacMap restoreData_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
@ -120,9 +120,8 @@ public:
|
||||
|
||||
/**
|
||||
* @description: Provide operating system SaveabilityState information to the observer
|
||||
* @param state Indicates save ability state used to dispatch.
|
||||
*/
|
||||
void ScheduleSaveAbilityState(PacMap &state);
|
||||
void ScheduleSaveAbilityState();
|
||||
|
||||
/**
|
||||
* @description: Provide operating system RestoreAbilityState information to the observer
|
||||
@ -414,12 +413,6 @@ private:
|
||||
*/
|
||||
void HandleCommandAbility(const Want &want, bool restart, int startId);
|
||||
|
||||
/**
|
||||
* @description: Handle the SaveAbility state.
|
||||
* @param state Indicates save ability state used to dispatchSaveAbilityState.
|
||||
*/
|
||||
void HandleSaveAbilityState(PacMap &state);
|
||||
|
||||
/**
|
||||
* @description: Handle the restoreAbility state.
|
||||
* @param state Indicates save ability state used to dispatchRestoreAbilityState.
|
||||
|
@ -204,10 +204,9 @@ void AbilityImpl::Background()
|
||||
/**
|
||||
* @brief Save data and states of an ability when it is restored by the system. and Calling information back to Ability.
|
||||
* This method should be implemented by a Page ability.
|
||||
* @param instate The Want object to connect to.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DispatchSaveAbilityState(PacMap &outState)
|
||||
void AbilityImpl::DispatchSaveAbilityState()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
@ -216,8 +215,7 @@ void AbilityImpl::DispatchSaveAbilityState(PacMap &outState)
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::DispatchSaveAbilityState");
|
||||
ability_->OnSaveAbilityState(outState);
|
||||
abilityLifecycleCallbacks_->OnAbilitySaveState(outState);
|
||||
needSaveDate_ = true;
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
@ -637,6 +635,39 @@ bool AbilityImpl::CheckAndRestore()
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if it needs to save the data to the ability.
|
||||
*
|
||||
* @return Return true if need and success, otherwise return false.
|
||||
*/
|
||||
bool AbilityImpl::CheckAndSave()
|
||||
{
|
||||
APP_LOGI("AbilityImpl::CheckAndSave called start");
|
||||
if (!needSaveDate_) {
|
||||
APP_LOGE("AbilityImpl::CheckAndSave needSaveDate_ is false");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::CheckAndSave ability_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::CheckAndSave ready to save");
|
||||
ability_->OnSaveAbilityState(restoreData_);
|
||||
abilityLifecycleCallbacks_->OnAbilitySaveState(restoreData_);
|
||||
|
||||
needSaveDate_ = false;
|
||||
|
||||
APP_LOGI("AbilityImpl::CheckAndSave called end");
|
||||
return true;
|
||||
}
|
||||
|
||||
PacMap & AbilityImpl::GetRestoreData()
|
||||
{
|
||||
return restoreData_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set deviceId/bundleName/abilityName of the calling ability
|
||||
*
|
||||
|
@ -363,24 +363,6 @@ void AbilityThread::HandleCommandAbility(const Want &want, bool restart, int sta
|
||||
APP_LOGI("AbilityThread::HandleCommandAbility end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Handle the SaveAbility state.
|
||||
* @param state Indicates save ability state used to dispatchSaveAbilityState.
|
||||
*/
|
||||
void AbilityThread::HandleSaveAbilityState(PacMap &state)
|
||||
{
|
||||
APP_LOGI("AbilityThread::HandleSaveAbilityState begin");
|
||||
if (abilityImpl_ == nullptr) {
|
||||
APP_LOGE("AbilityThread::HandleSaveAbilityState abilityImpl_ == nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityThread::HandleSaveAbilityState before abilityImpl_->DispatchSaveAbilityState");
|
||||
abilityImpl_->DispatchSaveAbilityState(state);
|
||||
APP_LOGI("AbilityThread::HandleSaveAbilityState after abilityImpl_->DispatchSaveAbilityState");
|
||||
APP_LOGI("AbilityThread::HandleSaveAbilityState end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Handle the restoreAbility state.
|
||||
* @param state Indicates save ability state used to dispatchRestoreAbilityState.
|
||||
@ -401,9 +383,8 @@ void AbilityThread::HandleRestoreAbilityState(const PacMap &state)
|
||||
|
||||
/**
|
||||
* @description: Provide operating system SaveabilityState information to the observer
|
||||
* @param state Indicates save ability state used to dispatch.
|
||||
*/
|
||||
void AbilityThread::ScheduleSaveAbilityState(PacMap &state)
|
||||
void AbilityThread::ScheduleSaveAbilityState()
|
||||
{
|
||||
APP_LOGI("AbilityThread::ScheduleSaveAbilityState begin");
|
||||
if (abilityImpl_ == nullptr) {
|
||||
@ -412,7 +393,9 @@ void AbilityThread::ScheduleSaveAbilityState(PacMap &state)
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityThread::ScheduleSaveAbilityState before abilityImpl_->DispatchSaveAbilityState");
|
||||
abilityImpl_->DispatchSaveAbilityState(state);
|
||||
|
||||
abilityImpl_->DispatchSaveAbilityState();
|
||||
|
||||
APP_LOGI("AbilityThread::ScheduleSaveAbilityState after abilityImpl_->DispatchSaveAbilityState");
|
||||
APP_LOGI("AbilityThread::ScheduleSaveAbilityState end");
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ void DataAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
|
||||
}
|
||||
}
|
||||
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state);
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, GetRestoreData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,11 +50,15 @@ void PageAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
|
||||
Inactive();
|
||||
}
|
||||
|
||||
if (targetState.state == AAFwk::ABILITY_STATE_BACKGROUND) {
|
||||
CheckAndSave();
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
ret = AbilityTransaction(want, targetState);
|
||||
if (ret) {
|
||||
APP_LOGI("AbilityThread::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state);
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, GetRestoreData());
|
||||
APP_LOGI("AbilityThread::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
}
|
||||
APP_LOGI("PageAbilityImpl::HandleAbilityTransaction end");
|
||||
|
@ -65,7 +65,7 @@ void ServiceAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk:
|
||||
|
||||
if (ret) {
|
||||
APP_LOGI("ServiceAbilityImpl::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state);
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, GetRestoreData());
|
||||
APP_LOGI("ServiceAbilityImpl::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
}
|
||||
APP_LOGI("ServiceAbilityImpl::HandleAbilityTransaction end");
|
||||
|
@ -81,6 +81,16 @@ public:
|
||||
return ability_;
|
||||
}
|
||||
|
||||
bool CheckAndSave()
|
||||
{
|
||||
return AbilityImpl::CheckAndSave();
|
||||
}
|
||||
|
||||
bool CheckAndRestore()
|
||||
{
|
||||
return AbilityImpl::CheckAndRestore();
|
||||
}
|
||||
|
||||
private:
|
||||
AbilityImpl AbilityImpl_;
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ ErrCode AbilityManagerClient::AttachAbilityThread(
|
||||
return -1;
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -49,14 +49,14 @@ public:
|
||||
|
||||
class MockAbilityThread : public IRemoteStub<AAFwk::IAbilityScheduler> {
|
||||
public:
|
||||
virtual void ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState){};
|
||||
virtual void SendResult(int requestCode, int resultCode, const Want &resultWant){};
|
||||
virtual void ScheduleConnectAbility(const Want &want){};
|
||||
virtual void ScheduleDisconnectAbility(const Want &want){};
|
||||
virtual void ScheduleCommandAbility(const Want &want, bool restart, int startId){};
|
||||
virtual void ScheduleSaveAbilityState(PacMap &outState){};
|
||||
virtual void ScheduleRestoreAbilityState(const PacMap &inState){};
|
||||
virtual void ScheduleUpdateConfiguration(const DummyConfiguration &config){};
|
||||
virtual void ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState) {};
|
||||
virtual void SendResult(int requestCode, int resultCode, const Want &resultWant) {};
|
||||
virtual void ScheduleConnectAbility(const Want &want) {};
|
||||
virtual void ScheduleDisconnectAbility(const Want &want) {};
|
||||
virtual void ScheduleCommandAbility(const Want &want, bool restart, int startId) {};
|
||||
virtual void ScheduleSaveAbilityState() {};
|
||||
virtual void ScheduleRestoreAbilityState(const PacMap &inState) {};
|
||||
virtual void ScheduleUpdateConfiguration(const DummyConfiguration &config) {};
|
||||
virtual std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter)
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
@ -106,8 +106,8 @@ public:
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual void NotifyMultiWinModeChanged(int32_t winModeKey, bool flag){};
|
||||
virtual void NotifyTopActiveAbilityChanged(bool flag){};
|
||||
virtual void NotifyMultiWinModeChanged(int32_t winModeKey, bool flag) {};
|
||||
virtual void NotifyTopActiveAbilityChanged(bool flag) {};
|
||||
virtual bool ScheduleNotifyChange(const Uri &uri)
|
||||
{
|
||||
return true;
|
||||
|
@ -81,7 +81,7 @@ ErrCode AbilityManagerClient::AttachAbilityThread(
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -58,13 +58,13 @@ ErrCode AbilityManagerClient::AttachAbilityThread(
|
||||
return abms->AttachAbilityThread(scheduler, token);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
if (remoteObject_ == nullptr) {
|
||||
return ABILITY_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
sptr<IAbilityManager> abms = iface_cast<IAbilityManager>(remoteObject_);
|
||||
return abms->AbilityTransitionDone(token, state);
|
||||
return abms->AbilityTransitionDone(token, state, saveData);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::ScheduleConnectAbilityDone(
|
||||
|
@ -112,7 +112,8 @@ int MockAbilityManagerService::AttachAbilityThread(
|
||||
void MockAbilityManagerService::DumpState(const std::string &args, std::vector<std::string> &info)
|
||||
{}
|
||||
|
||||
int MockAbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
int MockAbilityManagerService::AbilityTransitionDone(
|
||||
const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
int AttachAbilityThread(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override;
|
||||
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state) override;
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
|
||||
int ScheduleConnectAbilityDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override;
|
||||
int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override;
|
||||
int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
MOCK_METHOD1(ScheduleConnectAbility, void(const AAFwk::Want &));
|
||||
MOCK_METHOD1(ScheduleDisconnectAbility, void(const AAFwk::Want &));
|
||||
MOCK_METHOD3(ScheduleCommandAbility, void(const AAFwk::Want &, bool, int));
|
||||
MOCK_METHOD1(ScheduleSaveAbilityState, void(PacMap &));
|
||||
MOCK_METHOD0(ScheduleSaveAbilityState, void());
|
||||
MOCK_METHOD1(ScheduleRestoreAbilityState, void(const PacMap &));
|
||||
MOCK_METHOD1(ScheduleUpdateConfiguration, void(const AAFwk::DummyConfiguration &));
|
||||
MOCK_METHOD2(GetFileTypes, std::vector<std::string>(const Uri &, const std::string &));
|
||||
|
@ -96,7 +96,7 @@ void AbilityImpl::Background()
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::Background called";
|
||||
}
|
||||
|
||||
void AbilityImpl::DispatchSaveAbilityState(PacMap &outState)
|
||||
void AbilityImpl::DispatchSaveAbilityState()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::DispatchSaveAbilityState called";
|
||||
}
|
||||
|
@ -216,6 +216,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Stop_001, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
ability->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
mockAbilityimpl->ImplStop();
|
||||
@ -617,10 +619,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DispatchSaveAbilityState_001, TestSi
|
||||
std::shared_ptr<Ability> ability = std::make_shared<Ability>();
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
PacMap outState;
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->DispatchSaveAbilityState(outState);
|
||||
mockAbilityimpl->DispatchSaveAbilityState();
|
||||
}
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DispatchSaveAbilityState_001 end";
|
||||
@ -653,9 +653,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DispatchSaveAbilityState_002, TestSi
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
PacMap outState;
|
||||
mockAbilityimpl->DispatchSaveAbilityState(outState);
|
||||
mockAbilityimpl->DispatchSaveAbilityState();
|
||||
}
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DispatchSaveAbilityState_002 end";
|
||||
@ -1340,5 +1338,89 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Query_001, TestSize.Level1)
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_Query_001 end";
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityImpl
|
||||
* Function: CheckAndSave
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: CheckAndSave
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Test the normal behavior of the AbilityImpl::CheckAndSave
|
||||
*/
|
||||
HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CheckAndSave_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_CheckAndSave_001 start";
|
||||
std::shared_ptr<MockAbilityimpl> mockAbilityimpl = std::make_shared<MockAbilityimpl>();
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
std::shared_ptr<AbilityLocalRecord> record = std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
std::shared_ptr<EventRunner> eventRunner = EventRunner::Create(abilityInfo->name);
|
||||
sptr<AbilityThread> abilityThread = sptr<AbilityThread>(new (std::nothrow) AbilityThread());
|
||||
EXPECT_NE(abilityThread, nullptr);
|
||||
if (abilityThread != nullptr) {
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<Ability> ability;
|
||||
MockPageAbility *pMocKPageAbility = new (std::nothrow) MockPageAbility();
|
||||
EXPECT_NE(pMocKPageAbility, nullptr);
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
EXPECT_FALSE(mockAbilityimpl->CheckAndSave());
|
||||
mockAbilityimpl->DispatchSaveAbilityState();
|
||||
EXPECT_TRUE(mockAbilityimpl->CheckAndSave());
|
||||
}
|
||||
}
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_CheckAndSave_001 end";
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityImpl
|
||||
* Function: CheckAndRestore
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: CheckAndRestore
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Test the normal behavior of the AbilityImpl::CheckAndRestore
|
||||
*/
|
||||
HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CheckAndRestore_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_CheckAndRestore_001 start";
|
||||
std::shared_ptr<MockAbilityimpl> mockAbilityimpl = std::make_shared<MockAbilityimpl>();
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
std::shared_ptr<AbilityLocalRecord> record = std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
std::shared_ptr<EventRunner> eventRunner = EventRunner::Create(abilityInfo->name);
|
||||
sptr<AbilityThread> abilityThread = sptr<AbilityThread>(new (std::nothrow) AbilityThread());
|
||||
EXPECT_NE(abilityThread, nullptr);
|
||||
if (abilityThread != nullptr) {
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<Ability> ability;
|
||||
MockPageAbility *pMocKPageAbility = new (std::nothrow) MockPageAbility();
|
||||
EXPECT_NE(pMocKPageAbility, nullptr);
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
EXPECT_FALSE(mockAbilityimpl->CheckAndRestore());
|
||||
PacMap inState;
|
||||
mockAbilityimpl->DispatchRestoreAbilityState(inState);
|
||||
EXPECT_TRUE(mockAbilityimpl->CheckAndRestore());
|
||||
}
|
||||
}
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_CheckAndRestore_001 end";
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -99,8 +99,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleSaveAbilityState_0100, F
|
||||
std::shared_ptr<EventRunner> mainRunner = EventRunner::Create(abilityInfo->name);
|
||||
abilitythread->Attach(application, abilityRecord, mainRunner);
|
||||
|
||||
PacMap state;
|
||||
abilitythread->ScheduleSaveAbilityState(state);
|
||||
abilitythread->ScheduleSaveAbilityState();
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
@ -120,8 +119,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleSaveAbilityState_0200, F
|
||||
AbilityThread *abilitythread = new (std::nothrow) AbilityThread();
|
||||
EXPECT_NE(abilitythread, nullptr);
|
||||
if (abilitythread != nullptr) {
|
||||
PacMap state;
|
||||
abilitythread->ScheduleSaveAbilityState(state);
|
||||
abilitythread->ScheduleSaveAbilityState();
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityThread_ScheduleSaveAbilityState_0200 end";
|
||||
}
|
||||
@ -171,8 +169,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleRestoreAbilityState_0200
|
||||
AbilityThread *abilitythread = new (std::nothrow) AbilityThread();
|
||||
EXPECT_NE(abilitythread, nullptr);
|
||||
if (abilitythread != nullptr) {
|
||||
PacMap state;
|
||||
abilitythread->ScheduleSaveAbilityState(state);
|
||||
abilitythread->ScheduleSaveAbilityState();
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityThread_ScheduleRestoreAbilityState_0200 end";
|
||||
}
|
||||
@ -475,6 +472,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleCommandAbility_0100, Fun
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "MockServiceAbility";
|
||||
abilityInfo->type = AbilityType::SERVICE;
|
||||
abilityInfo->isNativeAbility = true;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@ -482,7 +480,6 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleCommandAbility_0100, Fun
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord =
|
||||
std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
std::shared_ptr<EventRunner> mainRunner = EventRunner::Create(abilityInfo->name);
|
||||
std::shared_ptr<AbilityImpl> abilityimpl = std::make_shared<AbilityImpl>();
|
||||
abilitythread->Attach(application, abilityRecord, mainRunner);
|
||||
|
||||
Want want;
|
||||
|
@ -74,15 +74,14 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetType_001, Function |
|
||||
std::shared_ptr<EventRunner> eventRunner = EventRunner::Create(abilityInfo->name);
|
||||
sptr<AbilityThread> abilityThread = sptr<AbilityThread>(new (std::nothrow) AbilityThread());
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<MockDataAbility> dataAbility = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<Ability> ability;
|
||||
ability.reset(dataAbility.get());
|
||||
std::shared_ptr<Ability> ability = std::make_shared<MockDataAbility>();;
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
dataabilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Uri uri("\nullptr");
|
||||
|
||||
EXPECT_STREQ("Type1", dataabilityimpl->GetType(uri).c_str());
|
||||
std::string resStr = dataabilityimpl->GetType(uri);
|
||||
|
||||
EXPECT_STREQ("Type1", resStr.c_str());
|
||||
sleep(1);
|
||||
GTEST_LOG_(INFO) << "AaFwk_DataAbilityImplTest_GetType_001 end";
|
||||
}
|
||||
@ -133,9 +132,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetFileTypes_001, Functi
|
||||
std::shared_ptr<EventRunner> eventRunner = EventRunner::Create(abilityInfo->name);
|
||||
sptr<AbilityThread> abilityThread = sptr<AbilityThread>(new (std::nothrow) AbilityThread());
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<MockDataAbility> dataAbility = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<Ability> ability;
|
||||
ability.reset(dataAbility.get());
|
||||
std::shared_ptr<Ability> ability = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
dataabilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
@ -192,9 +189,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenFile_001, Function |
|
||||
std::shared_ptr<EventRunner> eventRunner = EventRunner::Create(abilityInfo->name);
|
||||
sptr<AbilityThread> abilityThread = sptr<AbilityThread>(new (std::nothrow) AbilityThread());
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<MockDataAbility> dataAbility = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<Ability> ability;
|
||||
ability.reset(dataAbility.get());
|
||||
std::shared_ptr<Ability> ability = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
dataabilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
@ -247,9 +242,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenRawFile_001, Functio
|
||||
std::shared_ptr<EventRunner> eventRunner = EventRunner::Create(abilityInfo->name);
|
||||
sptr<AbilityThread> abilityThread = sptr<AbilityThread>(new (std::nothrow) AbilityThread());
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<MockDataAbility> dataAbility = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<Ability> ability;
|
||||
ability.reset(dataAbility.get());
|
||||
std::shared_ptr<Ability> ability = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
dataabilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
@ -302,9 +295,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Reload_001, Function | M
|
||||
std::shared_ptr<EventRunner> eventRunner = EventRunner::Create(abilityInfo->name);
|
||||
sptr<AbilityThread> abilityThread = sptr<AbilityThread>(new (std::nothrow) AbilityThread());
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<MockDataAbility> dataAbility = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<Ability> ability;
|
||||
ability.reset(dataAbility.get());
|
||||
std::shared_ptr<Ability> ability = std::make_shared<MockDataAbility>();
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
dataabilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
|
@ -601,9 +601,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DispatchSaveAbilityState_010
|
||||
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
pageAbilityImpl_->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
PacMap outState;
|
||||
pageAbilityImpl_->DispatchSaveAbilityState(outState);
|
||||
pageAbilityImpl_->DispatchSaveAbilityState();
|
||||
|
||||
GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DispatchSaveAbilityState_0100 end";
|
||||
}
|
||||
|
@ -58,13 +58,13 @@ ErrCode AbilityManagerClient::AttachAbilityThread(
|
||||
return abms->AttachAbilityThread(scheduler, token);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
if (remoteObject_ == nullptr) {
|
||||
return ABILITY_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
sptr<IAbilityManager> abms = iface_cast<IAbilityManager>(remoteObject_);
|
||||
return abms->AbilityTransitionDone(token, state);
|
||||
return abms->AbilityTransitionDone(token, state, saveData);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::ScheduleConnectAbilityDone(
|
||||
|
@ -95,7 +95,7 @@ int MockAbilityManagerService::ConnectAbility(
|
||||
{
|
||||
if (abilityScheduler_ != nullptr) {
|
||||
PacMap inState;
|
||||
abilityScheduler_->ScheduleSaveAbilityState(inState);
|
||||
abilityScheduler_->ScheduleSaveAbilityState();
|
||||
abilityScheduler_->ScheduleRestoreAbilityState(inState);
|
||||
}
|
||||
return 0;
|
||||
@ -128,7 +128,8 @@ int MockAbilityManagerService::AttachAbilityThread(
|
||||
void MockAbilityManagerService::DumpState(const std::string &args, std::vector<std::string> &info)
|
||||
{}
|
||||
|
||||
int MockAbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
int MockAbilityManagerService::AbilityTransitionDone(
|
||||
const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAbilityManagerService::AbilityTransitionDone called";
|
||||
EXPECT_EQ(curstate_, state);
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
|
||||
int AttachAbilityThread(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override;
|
||||
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state) override;
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
|
||||
int ScheduleConnectAbilityDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override;
|
||||
int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override;
|
||||
int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override;
|
||||
|
@ -104,7 +104,8 @@ int MockServiceAbilityManagerService::AttachAbilityThread(
|
||||
void MockServiceAbilityManagerService::DumpState(const std::string &args, std::vector<std::string> &info)
|
||||
{}
|
||||
|
||||
int MockServiceAbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
int MockServiceAbilityManagerService::AbilityTransitionDone(
|
||||
const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockServiceAbilityManagerService::AbilityTransitionDone startAbility is " << startAbility;
|
||||
want_.SetElementName("BundleName", "abilityName");
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
|
||||
int AttachAbilityThread(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token) override;
|
||||
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state) override;
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
|
||||
int ScheduleConnectAbilityDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject) override;
|
||||
int ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token) override;
|
||||
int ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token) override;
|
||||
|
@ -78,6 +78,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_ConnectAbility_0100, Function
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::SERVICE;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
AbilityThread::AbilityThreadMain(application, abilityRecord);
|
||||
@ -104,6 +105,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_DisconnectAbility_0100, Funct
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::SERVICE;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
AbilityThread::AbilityThreadMain(application, abilityRecord);
|
||||
@ -131,6 +133,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_StartAbility_0100, Function |
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::SERVICE;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
AbilityThread::AbilityThreadMain(application, abilityRecord);
|
||||
@ -152,6 +155,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_TerminateAbility_0100, Functi
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::SERVICE;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
AbilityThread::AbilityThreadMain(application, abilityRecord);
|
||||
@ -179,6 +183,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_TerminateAbility_0200, Functi
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::SERVICE;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
AbilityThread::AbilityThreadMain(application, abilityRecord);
|
||||
@ -203,6 +208,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_StopService_0100, Function |
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::SERVICE;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
AbilityThread::AbilityThreadMain(application, abilityRecord);
|
||||
@ -232,6 +238,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_StopService_0200, Function |
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::SERVICE;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
AbilityThread::AbilityThreadMain(application, abilityRecord);
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
OHOS::sptr<OHOS::IRemoteObject> abilityObject_;
|
||||
static constexpr int TEST_WAIT_TIME = 500 * 1000; // 500 ms
|
||||
static constexpr int TEST_WAIT_TIME = 500 * 1000 * 2; // 500 ms * 2
|
||||
static const int RESULT_CODE = 1992;
|
||||
|
||||
public:
|
||||
@ -881,6 +881,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_DataAbility_Launch_0100, Function | MediumT
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->type = AppExecFwk::AbilityType::DATA;
|
||||
abilityInfo->name = "DemoAbility";
|
||||
abilityInfo->isNativeAbility = true;
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord =
|
||||
std::make_shared<AbilityLocalRecord>(abilityInfo, abilityToken);
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
* @param state,.the state of ability lift cycle.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode AbilityTransitionDone(const sptr<IRemoteObject> &token, int state);
|
||||
ErrCode AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData);
|
||||
|
||||
/**
|
||||
* ScheduleConnectAbilityDone, service ability call this interface while session was connected.
|
||||
|
@ -165,7 +165,7 @@ public:
|
||||
* @param state,.the state of ability lift cycle.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state) = 0;
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) = 0;
|
||||
|
||||
/**
|
||||
* ScheduleConnectAbilityDone, service ability call this interface while session was connected.
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
/*
|
||||
* ScheduleSaveAbilityState, scheduling save ability state.
|
||||
*/
|
||||
virtual void ScheduleSaveAbilityState(PacMap &outState) = 0;
|
||||
virtual void ScheduleSaveAbilityState() = 0;
|
||||
|
||||
/*
|
||||
* ScheduleRestoreAbilityState, scheduling restore ability state.
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
* @param state,.the state of ability lift cycle.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state) override;
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
|
||||
|
||||
/**
|
||||
* ScheduleConnectAbilityDone, service ability call this interface while session was connected.
|
||||
|
@ -170,7 +170,7 @@ public:
|
||||
* @param state,.the state of ability lift cycle.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state) override;
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
|
||||
|
||||
/**
|
||||
* ScheduleConnectAbilityDone, service ability call this interface while session was connected.
|
||||
|
@ -437,6 +437,7 @@ public:
|
||||
*
|
||||
*/
|
||||
void SaveAbilityState();
|
||||
void SaveAbilityState(const PacMap &inState);
|
||||
|
||||
/**
|
||||
* restore ability state.
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
/*
|
||||
* ScheduleSaveAbilityState, scheduling save ability state.
|
||||
*/
|
||||
void ScheduleSaveAbilityState(PacMap &outState) override;
|
||||
void ScheduleSaveAbilityState() override;
|
||||
|
||||
/*
|
||||
* ScheduleRestoreAbilityState, scheduling restore ability state.
|
||||
|
@ -200,9 +200,10 @@ public:
|
||||
*
|
||||
* @param token,.ability's token.
|
||||
* @param state,.the state of ability lift cycle.
|
||||
* @param saveData, save ability data
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state);
|
||||
int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData);
|
||||
|
||||
/**
|
||||
* AddWindowInfo, add windowToken to AbilityRecord.
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
void DisconnectAbility(const Want &want);
|
||||
void Terminate(const Want &want, LifeCycleStateInfo &stateInfo);
|
||||
void CommandAbility(const Want &want, bool reStart, int startId);
|
||||
void SaveAbilityState(PacMap &outState);
|
||||
void SaveAbilityState();
|
||||
void RestoreAbilityState(const PacMap &inState);
|
||||
void UpdateConfiguration(const DummyConfiguration &config);
|
||||
|
||||
|
@ -70,11 +70,11 @@ ErrCode AbilityManagerClient::AttachAbilityThread(
|
||||
return abms->AttachAbilityThread(scheduler, token);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
ErrCode AbilityManagerClient::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
CHECK_REMOTE_OBJECT_AND_RETURN(remoteObject_, ABILITY_SERVICE_NOT_CONNECTED);
|
||||
sptr<IAbilityManager> abms = iface_cast<IAbilityManager>(remoteObject_);
|
||||
return abms->AbilityTransitionDone(token, state);
|
||||
return abms->AbilityTransitionDone(token, state, saveData);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::ScheduleConnectAbilityDone(
|
||||
|
@ -311,7 +311,7 @@ int AbilityManagerProxy::AttachAbilityThread(const sptr<IAbilityScheduler> &sche
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
int AbilityManagerProxy::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
int error;
|
||||
MessageParcel data;
|
||||
@ -325,6 +325,10 @@ int AbilityManagerProxy::AbilityTransitionDone(const sptr<IRemoteObject> &token,
|
||||
HILOG_ERROR("data write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteParcelable(&saveData)) {
|
||||
HILOG_ERROR("data write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
error = Remote()->SendRequest(IAbilityManager::ABILITY_TRANSITION_DONE, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Send request error: %{public}d", error);
|
||||
|
@ -898,7 +898,7 @@ void AbilityManagerService::DumpState(const std::string &args, std::vector<std::
|
||||
info.push_back("error: invalid argument, please see 'ability dump -h'.");
|
||||
}
|
||||
|
||||
int AbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
int AbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
HILOG_INFO("Ability transition done, state:%{public}d", state);
|
||||
if (!VerificationToken(token)) {
|
||||
@ -921,7 +921,7 @@ int AbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &toke
|
||||
return systemAppManager_->AbilityTransitionDone(token, state);
|
||||
}
|
||||
|
||||
return currentStackManager_->AbilityTransitionDone(token, state);
|
||||
return currentStackManager_->AbilityTransitionDone(token, state, saveData);
|
||||
}
|
||||
|
||||
int AbilityManagerService::ScheduleConnectAbilityDone(
|
||||
|
@ -157,7 +157,12 @@ int AbilityManagerStub::AbilityTransitionDoneInner(MessageParcel &data, MessageP
|
||||
{
|
||||
auto token = data.ReadParcelable<IRemoteObject>();
|
||||
int targetState = data.ReadInt32();
|
||||
int32_t result = AbilityTransitionDone(token, targetState);
|
||||
std::unique_ptr<PacMap> saveData(data.ReadParcelable<PacMap>());
|
||||
if (!saveData) {
|
||||
HILOG_INFO("save data is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t result = AbilityTransitionDone(token, targetState, *saveData);
|
||||
reply.WriteInt32(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
@ -517,7 +517,13 @@ void AbilityRecord::SaveAbilityState()
|
||||
{
|
||||
HILOG_INFO("%{public}s", __func__);
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
lifecycleDeal_->SaveAbilityState(stateDatas_);
|
||||
lifecycleDeal_->SaveAbilityState();
|
||||
}
|
||||
|
||||
void AbilityRecord::SaveAbilityState(const PacMap &inState)
|
||||
{
|
||||
HILOG_INFO("%{public}s : pacmap save", __func__);
|
||||
stateDatas_ = inState;
|
||||
}
|
||||
|
||||
void AbilityRecord::RestoreAbilityState()
|
||||
|
@ -129,7 +129,7 @@ void AbilitySchedulerProxy::ScheduleCommandAbility(const Want &want, bool restar
|
||||
}
|
||||
}
|
||||
|
||||
void AbilitySchedulerProxy::ScheduleSaveAbilityState(PacMap &outState)
|
||||
void AbilitySchedulerProxy::ScheduleSaveAbilityState()
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -141,12 +141,6 @@ void AbilitySchedulerProxy::ScheduleSaveAbilityState(PacMap &outState)
|
||||
if (err != NO_ERROR) {
|
||||
HILOG_ERROR("ScheduleSaveAbilityState fail to SendRequest. err: %d", err);
|
||||
}
|
||||
std::unique_ptr<PacMap> pacMap(reply.ReadParcelable<PacMap>());
|
||||
if (!pacMap) {
|
||||
HILOG_ERROR("readParcelableInfo<PacMap> failed");
|
||||
return;
|
||||
}
|
||||
outState = *pacMap;
|
||||
}
|
||||
|
||||
void AbilitySchedulerProxy::ScheduleRestoreAbilityState(const PacMap &inState)
|
||||
|
@ -152,12 +152,7 @@ int AbilitySchedulerStub::CommandAbilityInner(MessageParcel &data, MessageParcel
|
||||
|
||||
int AbilitySchedulerStub::SaveAbilityStateInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
PacMap pacMap;
|
||||
ScheduleSaveAbilityState(pacMap);
|
||||
if (!reply.WriteParcelable(&pacMap)) {
|
||||
HILOG_ERROR("AbilityManagerStub: SaveAbilityState error");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
ScheduleSaveAbilityState();
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1043,7 +1043,7 @@ int AbilityStackManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sche
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int AbilityStackManager::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
int AbilityStackManager::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(stackLock_);
|
||||
auto abilityRecord = GetAbilityRecordByToken(token);
|
||||
@ -1058,6 +1058,10 @@ int AbilityStackManager::AbilityTransitionDone(const sptr<IRemoteObject> &token,
|
||||
std::string abilityState = AbilityRecord::ConvertAbilityState(static_cast<AbilityState>(targetState));
|
||||
HILOG_INFO("ability: %{public}s, state: %{public}s", element.c_str(), abilityState.c_str());
|
||||
|
||||
if (targetState == AbilityState::BACKGROUND) {
|
||||
abilityRecord->SaveAbilityState(saveData);
|
||||
}
|
||||
|
||||
return DispatchState(abilityRecord, targetState);
|
||||
}
|
||||
|
||||
|
@ -88,11 +88,11 @@ void LifecycleDeal::CommandAbility(const Want &want, bool reStart, int startId)
|
||||
abilityScheduler_->ScheduleCommandAbility(want, reStart, startId);
|
||||
}
|
||||
|
||||
void LifecycleDeal::SaveAbilityState(PacMap &outState)
|
||||
void LifecycleDeal::SaveAbilityState()
|
||||
{
|
||||
HILOG_INFO("%{public}s, %{public}d", __func__, __LINE__);
|
||||
CHECK_POINTER(abilityScheduler_);
|
||||
abilityScheduler_->ScheduleSaveAbilityState(outState);
|
||||
abilityScheduler_->ScheduleSaveAbilityState();
|
||||
}
|
||||
|
||||
void LifecycleDeal::RestoreAbilityState(const PacMap &inState)
|
||||
|
@ -118,7 +118,8 @@ void AppMgrEventHandler::ScheduleAbilityTransaction(const AppExecFwk::InnerEvent
|
||||
usleep(BLOCK_TEST_TIME);
|
||||
}
|
||||
}
|
||||
server_->AbilityTransitionDone(ability->GetToken(), targetState);
|
||||
PacMap saveData;
|
||||
server_->AbilityTransitionDone(ability->GetToken(), targetState, saveData);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
|
||||
void ScheduleCommandAbility(const Want &want, bool restart, int startId) override;
|
||||
|
||||
void ScheduleSaveAbilityState(PacMap &outState) override;
|
||||
void ScheduleSaveAbilityState() override;
|
||||
|
||||
void ScheduleRestoreAbilityState(const PacMap &inState) override;
|
||||
|
||||
|
@ -54,7 +54,7 @@ void AbilityScheduler::ScheduleDisconnectAbility(const Want &want)
|
||||
void AbilityScheduler::ScheduleCommandAbility(const Want &want, bool restart, int startId)
|
||||
{}
|
||||
|
||||
void AbilityScheduler::ScheduleSaveAbilityState(PacMap &outState)
|
||||
void AbilityScheduler::ScheduleSaveAbilityState()
|
||||
{}
|
||||
|
||||
void AbilityScheduler::ScheduleRestoreAbilityState(const PacMap &inState)
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
MOCK_METHOD3(SendResult, void(int, int, const Want &));
|
||||
MOCK_METHOD1(ScheduleConnectAbility, void(const Want &));
|
||||
MOCK_METHOD1(ScheduleDisconnectAbility, void(const Want &));
|
||||
MOCK_METHOD1(ScheduleSaveAbilityState, void(PacMap &));
|
||||
MOCK_METHOD0(ScheduleSaveAbilityState, void());
|
||||
MOCK_METHOD1(ScheduleRestoreAbilityState, void(const PacMap &));
|
||||
MOCK_METHOD1(ScheduleUpdateConfiguration, void(const DummyConfiguration &));
|
||||
MOCK_METHOD1(ScheduleNewWant, void(const Want &));
|
||||
|
@ -280,7 +280,8 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_0011, TestSize.Level0)
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest));
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
auto res = proxy_->AbilityTransitionDone(token, 1);
|
||||
PacMap saveData;
|
||||
auto res = proxy_->AbilityTransitionDone(token, 1, saveData);
|
||||
|
||||
EXPECT_EQ(IAbilityManager::ABILITY_TRANSITION_DONE, mock_->code_);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
@ -300,7 +301,8 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_012, TestSize.Level0)
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeErrorSendRequest));
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
auto res = proxy_->AbilityTransitionDone(token, 1);
|
||||
PacMap saveData;
|
||||
auto res = proxy_->AbilityTransitionDone(token, 1, saveData);
|
||||
|
||||
EXPECT_EQ(IAbilityManager::ABILITY_TRANSITION_DONE, mock_->code_);
|
||||
EXPECT_NE(res, NO_ERROR);
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -594,12 +594,13 @@ HWTEST_F(AbilityManagerServiceTest, Interface_012, TestSize.Level1)
|
||||
EXPECT_EQ(topAbility->GetAbilityInfo().name, "MusicAbility");
|
||||
|
||||
OHOS::sptr<Token> nullToken = nullptr;
|
||||
auto res = abilityMs_->AbilityTransitionDone(nullToken, OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
PacMap saveData;
|
||||
auto res = abilityMs_->AbilityTransitionDone(nullToken, OHOS::AAFwk::AbilityState::ACTIVE, saveData);
|
||||
EXPECT_EQ(res, OHOS::ERR_INVALID_VALUE);
|
||||
|
||||
std::shared_ptr<AbilityRecord> record = nullptr;
|
||||
OHOS::sptr<Token> token = new Token(record);
|
||||
auto res1 = abilityMs_->AbilityTransitionDone(token, OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
auto res1 = abilityMs_->AbilityTransitionDone(token, OHOS::AAFwk::AbilityState::ACTIVE, saveData);
|
||||
EXPECT_EQ(res1, OHOS::ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state)
|
||||
virtual int AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -248,6 +248,9 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_009, TestSize.Level0)
|
||||
WriteInterfaceToken(data);
|
||||
data.WriteParcelable(token);
|
||||
data.WriteInt32(1);
|
||||
PacMap pMap;
|
||||
pMap.PutIntValue(std::string("1"), 1);
|
||||
data.WriteParcelable(&pMap);
|
||||
int res = stub_->OnRemoteRequest(IAbilityManager::ABILITY_TRANSITION_DONE, data, reply, option);
|
||||
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
#ifndef ABILITY_UNITTEST_ABILITY_MANAGER_STUB_MOCK_H
|
||||
#define ABILITY_UNITTEST_ABILITY_MANAGER_STUB_MOCK_H
|
||||
#include <gmock/gmock.h>
|
||||
#include <iremote_object.h>
|
||||
#include <iremote_stub.h>
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ability_manager_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class AbilityManagerStubMock : public IRemoteStub<IAbilityManager> {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IAbilityManagerMock");
|
||||
|
||||
AbilityManagerStubMock()
|
||||
{}
|
||||
virtual ~AbilityManagerStubMock()
|
||||
{}
|
||||
|
||||
MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel &, MessageParcel &, MessageOption &));
|
||||
MOCK_METHOD2(StartAbility, int(const Want &, int));
|
||||
MOCK_METHOD3(TerminateAbility, int(const sptr<IRemoteObject> &, int, const Want *));
|
||||
MOCK_METHOD3(ConnectAbility, int(const Want &, const sptr<IAbilityConnection> &, const sptr<IRemoteObject> &));
|
||||
|
||||
MOCK_METHOD1(DisconnectAbility, int(const sptr<IAbilityConnection> &));
|
||||
MOCK_METHOD3(AcquireDataAbility, sptr<IAbilityScheduler>(const Uri &, bool, const sptr<IRemoteObject> &));
|
||||
MOCK_METHOD2(ReleaseDataAbility, int(sptr<IAbilityScheduler>, const sptr<IRemoteObject> &));
|
||||
MOCK_METHOD2(AddWindowInfo, void(const sptr<IRemoteObject> &, int32_t));
|
||||
MOCK_METHOD2(AttachAbilityThread, int(const sptr<IAbilityScheduler> &, const sptr<IRemoteObject> &));
|
||||
MOCK_METHOD3(AbilityTransitionDone, int(const sptr<IRemoteObject> &, int, const PacMap &));
|
||||
MOCK_METHOD2(ScheduleConnectAbilityDone, int(const sptr<IRemoteObject> &, const sptr<IRemoteObject> &));
|
||||
MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr<IRemoteObject> &));
|
||||
MOCK_METHOD1(ScheduleCommandAbilityDone, int(const sptr<IRemoteObject> &));
|
||||
MOCK_METHOD2(DumpState, void(const std::string &, std::vector<std::string> &));
|
||||
MOCK_METHOD2(TerminateAbilityResult, int(const sptr<IRemoteObject> &, int));
|
||||
MOCK_METHOD1(StopServiceAbility, int(const Want &));
|
||||
MOCK_METHOD1(GetAllStackInfo, int(StackInfo &));
|
||||
MOCK_METHOD3(GetRecentMissions, int(const int32_t, const int32_t, std::vector<AbilityMissionInfo> &));
|
||||
MOCK_METHOD2(GetMissionSnapshot, int(const int32_t, MissionSnapshotInfo &));
|
||||
MOCK_METHOD1(RemoveMission, int(int));
|
||||
MOCK_METHOD1(RemoveStack, int(int));
|
||||
MOCK_METHOD1(MoveMissionToTop, int(int32_t));
|
||||
MOCK_METHOD1(KillProcess, int(const std::string &));
|
||||
MOCK_METHOD1(UninstallApp, int(const std::string &));
|
||||
MOCK_METHOD2(TerminateAbilityByCaller, int(const sptr<IRemoteObject> &callerToken, int requestCode));
|
||||
MOCK_METHOD3(StartAbility, int(const Want &want, const sptr<IRemoteObject> &callerToken, int requestCode));
|
||||
MOCK_METHOD2(MoveMissionToEnd, int(const sptr<IRemoteObject> &token, const bool nonFirst));
|
||||
MOCK_METHOD1(IsFirstInMission, bool(const sptr<IRemoteObject> &token));
|
||||
MOCK_METHOD4(CompelVerifyPermission, int(const std::string &permission, int pid, int uid, std::string &message));
|
||||
MOCK_METHOD0(PowerOff, int());
|
||||
MOCK_METHOD0(PowerOn, int());
|
||||
MOCK_METHOD1(LockMission, int(int));
|
||||
MOCK_METHOD1(UnlockMission, int(int));
|
||||
MOCK_METHOD2(SetMissionDescriptionInfo, int(const sptr<IRemoteObject> &token, const MissionDescriptionInfo &info));
|
||||
MOCK_METHOD0(GetMissionLockModeState, int());
|
||||
MOCK_METHOD1(UpdateConfiguration, int(const DummyConfiguration &));
|
||||
MOCK_METHOD2(
|
||||
GetWantSender, sptr<IWantSender>(const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken));
|
||||
MOCK_METHOD2(SendWantSender, int(const sptr<IWantSender> &target, const SenderInfo &senderInfo));
|
||||
MOCK_METHOD1(CancelWantSender, void(const sptr<IWantSender> &sender));
|
||||
MOCK_METHOD1(GetPendingWantUid, int(const sptr<IWantSender> &target));
|
||||
MOCK_METHOD1(GetPendingWantUserId, int(const sptr<IWantSender> &target));
|
||||
MOCK_METHOD1(GetPendingWantBundleName, std::string(const sptr<IWantSender> &target));
|
||||
MOCK_METHOD1(GetPendingWantCode, int(const sptr<IWantSender> &target));
|
||||
MOCK_METHOD1(GetPendingWantType, int(const sptr<IWantSender> &target));
|
||||
MOCK_METHOD2(RegisterCancelListener, void(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver));
|
||||
MOCK_METHOD2(UnregisterCancelListener, void(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver));
|
||||
MOCK_METHOD2(GetPendingRequestWant, int(const sptr<IWantSender> &target, std::shared_ptr<Want> &want));
|
||||
|
||||
MOCK_METHOD4(StartAbility, int(const Want &want, const AbilityStartSetting &abilityStartSetting,
|
||||
const sptr<IRemoteObject> &callerToken, int requestCode));
|
||||
MOCK_METHOD1(MoveMissionToFloatingStack, int(const MissionOption &missionOption));
|
||||
MOCK_METHOD2(MoveMissionToSplitScreenStack, int(const MissionOption &primary, const MissionOption &secondary));
|
||||
MOCK_METHOD2(
|
||||
ChangeFocusAbility, int(const sptr<IRemoteObject> &lostFocusToken, const sptr<IRemoteObject> &getFocusToken));
|
||||
MOCK_METHOD1(MinimizeMultiWindow, int(int missionId));
|
||||
MOCK_METHOD1(GetFloatingMissions, int(std::vector<AbilityMissionInfo> &list));
|
||||
MOCK_METHOD1(CloseMultiWindow, int(int missionId));
|
||||
MOCK_METHOD1(SetMissionStackSetting, int(const StackSetting &stackSetting));
|
||||
MOCK_METHOD1(MaximizeMultiWindow, int(int missionId));
|
||||
MOCK_METHOD1(ChangeFocusTest, void(const std::vector<int> missionId));
|
||||
MOCK_METHOD1(TerminateAbilityTest, void(int id));
|
||||
MOCK_METHOD1(MoveMissionToEnd, int(int id));
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
#endif
|
@ -0,0 +1,331 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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
|
||||
#define protected public
|
||||
#include "system_ability_definition.h"
|
||||
#include "ability_manager_client.h"
|
||||
#undef private
|
||||
#undef protected
|
||||
|
||||
#include "ability_manager_stub_mock.h"
|
||||
#include "ability_scheduler_mock.h"
|
||||
#include "ability_manager_service.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "ability_record.h"
|
||||
#include "ability_scheduler.h"
|
||||
#include "mock_ability_connect_callback.h"
|
||||
#include "mock_bundle_manager.h"
|
||||
#include "sa_mgr_client.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
const std::string LAUNCHER_ABILITY = "MainAbility";
|
||||
const std::string LAUNCHER_BUNDLE = "com.ohos.hiworld";
|
||||
const std::string NAME_BUNDLE_MGR_SERVICE = "BundleMgrService";
|
||||
const std::string NAME_ABILITY_MGR_SERVICE = "AbilityManagerService";
|
||||
const std::string SERVICE_ABILITY = "ServiceAbility";
|
||||
const std::string SERVICE_BUNDLE = "com.ohos.hiservcie";
|
||||
} // namespace
|
||||
|
||||
class AbilityManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
|
||||
public:
|
||||
static constexpr int TEST_WAIT_TIME = 100000;
|
||||
std::shared_ptr<AbilityManagerClient> abilityClient_ = nullptr;
|
||||
sptr<AbilityManagerStubMock> mock_ {nullptr};
|
||||
Want want_ {};
|
||||
};
|
||||
|
||||
void AbilityManagerTest::SetUpTestCase(void)
|
||||
{}
|
||||
void AbilityManagerTest::TearDownTestCase(void)
|
||||
{}
|
||||
void AbilityManagerTest::TearDown(void)
|
||||
{}
|
||||
|
||||
void AbilityManagerTest::SetUp(void)
|
||||
{
|
||||
abilityClient_ = std::make_shared<AbilityManagerClient>();
|
||||
mock_ = new AbilityManagerStubMock();
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: StartAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient StartAbility
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of startability
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_001, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, StartAbility(::testing::_, ::testing::_)).Times(1);
|
||||
EXPECT_EQ(abilityClient_->StartAbility(want_), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->StartAbility(want_), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: AttachAbilityThread
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient AttachAbilityThread
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of attachAbilityThread
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_002, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, AttachAbilityThread(::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityScheduler> scheduler = new AbilitySchedulerMock();
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
EXPECT_EQ(abilityClient_->AttachAbilityThread(scheduler, token), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->AttachAbilityThread(scheduler, token), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: AbilityTransitionDone
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient AbilityTransitionDone
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of abilityTransitionDone
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_003, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, AbilityTransitionDone(::testing::_, ::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityScheduler> scheduler = new AbilitySchedulerMock();
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
PacMap saveData;
|
||||
EXPECT_EQ(abilityClient_->AbilityTransitionDone(token, 1, saveData), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->AbilityTransitionDone(token, 1, saveData), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: ScheduleConnectAbilityDone
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient ScheduleConnectAbilityDone
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of scheduleConnectAbilityDone
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_004, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, ScheduleConnectAbilityDone(::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityScheduler> scheduler = new AbilitySchedulerMock();
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
sptr<IRemoteObject> remoteObject = nullptr;
|
||||
EXPECT_EQ(abilityClient_->ScheduleConnectAbilityDone(token, remoteObject), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->ScheduleConnectAbilityDone(token, remoteObject), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: ScheduleDisconnectAbilityDone
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient ScheduleDisconnectAbilityDone
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of scheduleDisconnectAbilityDone
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_005, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, ScheduleDisconnectAbilityDone(::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityScheduler> scheduler = new AbilitySchedulerMock();
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
sptr<IRemoteObject> remoteObject = nullptr;
|
||||
EXPECT_EQ(abilityClient_->ScheduleDisconnectAbilityDone(token), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->ScheduleDisconnectAbilityDone(token), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: AddWindowInfo
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient AddWindowInfo
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of addWindowInfo
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_006, TestSize.Level2)
|
||||
{
|
||||
std::string args;
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, AddWindowInfo(::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityScheduler> scheduler = new AbilitySchedulerMock();
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
int32_t t = 1;
|
||||
abilityClient_->AddWindowInfo(token, t);
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
abilityClient_->AddWindowInfo(token, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: TerminateAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient TerminateAbility
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of terminateAbility
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_007, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, TerminateAbility(::testing::_, ::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityScheduler> scheduler = new AbilitySchedulerMock();
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
EXPECT_EQ(abilityClient_->TerminateAbility(token, 1, &want_), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->TerminateAbility(token, 1, &want_), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: ConnectAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient ConnectAbility
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of ConnectAbility
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_008, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, ConnectAbility(::testing::_, ::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityConnection> connect = nullptr;
|
||||
sptr<IRemoteObject> callerToken = nullptr;
|
||||
EXPECT_EQ(abilityClient_->ConnectAbility(want_, connect, callerToken), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->ConnectAbility(want_, connect, callerToken), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: DisconnectAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient DisconnectAbility
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of DisconnectAbility
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_009, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, DisconnectAbility(::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityConnection> connect = nullptr;
|
||||
EXPECT_EQ(abilityClient_->DisconnectAbility(connect), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->DisconnectAbility(connect), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: DumpState
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient DumpState
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of DumpState
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_010, TestSize.Level2)
|
||||
{
|
||||
std::string args;
|
||||
std::vector<std::string> vec;
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, DumpState(::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
sptr<IAbilityConnection> connect = nullptr;
|
||||
EXPECT_EQ(abilityClient_->DumpState(args, vec), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->DumpState(args, vec), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: GetAllStackInfo
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient GetAllStackInfo
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal and abnormal cases of GetAllStackInfo
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_011, TestSize.Level2)
|
||||
{
|
||||
std::string args;
|
||||
std::vector<std::string> vec;
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_CALL(*mock_, GetAllStackInfo(::testing::_)).Times(1);
|
||||
|
||||
StackInfo info;
|
||||
EXPECT_EQ(abilityClient_->GetAllStackInfo(info), 0);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
EXPECT_EQ(abilityClient_->GetAllStackInfo(info), ABILITY_SERVICE_NOT_CONNECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: Connect
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient Connect
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify Connect operation
|
||||
*/
|
||||
HWTEST_F(AbilityManagerTest, AAFWK_AbilityMS_AbilityManager_test_012, TestSize.Level2)
|
||||
{
|
||||
abilityClient_->remoteObject_ = mock_;
|
||||
EXPECT_EQ(abilityClient_->Connect(), 0);
|
||||
|
||||
sptr<ISystemAbilityManager> manager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
ISystemAbilityManager::SAExtraProp prop;
|
||||
manager->AddSystemAbility(ABILITY_MGR_SERVICE_ID, mock_, prop);
|
||||
|
||||
abilityClient_->remoteObject_ = nullptr;
|
||||
|
||||
EXPECT_EQ(abilityClient_->Connect(), 0);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -36,7 +36,7 @@ public:
|
||||
virtual void ScheduleCommandAbility(const Want &want, bool restart, int startId) override
|
||||
{}
|
||||
|
||||
virtual void ScheduleSaveAbilityState(PacMap &outState) override
|
||||
virtual void ScheduleSaveAbilityState() override
|
||||
{}
|
||||
virtual void ScheduleRestoreAbilityState(const PacMap &inState) override
|
||||
{}
|
||||
|
@ -932,23 +932,24 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_023, TestSize.
|
||||
auto topAbility = stackManager_->GetCurrentTopAbility();
|
||||
topAbility->SetAbilityState(OHOS::AAFwk::INITIAL);
|
||||
auto token = topAbility->GetToken();
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token, OHOS::AAFwk::ACTIVE), 0);
|
||||
PacMap saveData;
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token, OHOS::AAFwk::ACTIVE, saveData), 0);
|
||||
|
||||
std::shared_ptr<AbilityRecord> record = nullptr;
|
||||
auto nullToken = new Token(record);
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(nullToken, OHOS::AAFwk::INACTIVE), 0);
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(nullToken, OHOS::AAFwk::INACTIVE, saveData), 0);
|
||||
|
||||
auto token1 = topAbility->GetToken();
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token1, OHOS::AAFwk::BACKGROUND), 0);
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token1, OHOS::AAFwk::BACKGROUND, saveData), 0);
|
||||
|
||||
auto token2 = topAbility->GetToken();
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token2, OHOS::AAFwk::INITIAL), 0);
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token2, OHOS::AAFwk::INITIAL, saveData), 0);
|
||||
|
||||
auto token3 = topAbility->GetToken();
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token3, OHOS::AAFwk::TERMINATING), 0);
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token3, OHOS::AAFwk::TERMINATING, saveData), 0);
|
||||
|
||||
auto token4 = topAbility->GetToken();
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token4, OHOS::AAFwk::INACTIVE), 0);
|
||||
EXPECT_NE(stackManager_->AbilityTransitionDone(token4, OHOS::AAFwk::INACTIVE, saveData), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -45,7 +45,7 @@ void AbilityScheduler::ScheduleDisconnectAbility(const Want &want)
|
||||
void AbilityScheduler::ScheduleCommandAbility(const Want &want, bool restart, int startId)
|
||||
{}
|
||||
|
||||
void AbilityScheduler::ScheduleSaveAbilityState(PacMap &outState)
|
||||
void AbilityScheduler::ScheduleSaveAbilityState()
|
||||
{}
|
||||
|
||||
void AbilityScheduler::ScheduleRestoreAbilityState(const PacMap &inState)
|
||||
|
@ -399,7 +399,6 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_AbilityTransitionDone_
|
||||
HILOG_INFO("AaFwk_DataAbilityManager_AbilityTransitionDone_001 start.");
|
||||
|
||||
std::unique_ptr<DataAbilityManager> dataAbilityManager = std::make_unique<DataAbilityManager>();
|
||||
|
||||
EXPECT_EQ(dataAbilityManager->AbilityTransitionDone(nullptr, INACTIVE), ERR_NULL_OBJECT);
|
||||
|
||||
HILOG_INFO("AaFwk_DataAbilityManager_AbilityTransitionDone_001 end.");
|
||||
|
@ -376,7 +376,8 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_StartLauncherAbilityLifeCycle_005, TestS
|
||||
pthread_join(tid, nullptr);
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, command_->state_), OHOS::ERR_OK);
|
||||
PacMap saveData;
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, command_->state_, saveData), OHOS::ERR_OK);
|
||||
if (launcherAbilityRecord_->GetAbilityState() != OHOS::AAFwk::AbilityState::ACTIVE) {
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(launcherAbilityRecord_->GetAbilityState(), OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
@ -454,7 +455,8 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_002, TestSize.Leve
|
||||
EXPECT_EQ(AttachAbility(launcherScheduler_, launcherToken_), 0);
|
||||
EXPECT_TRUE(StartNextAbility());
|
||||
// launcher is in inactivating process.
|
||||
EXPECT_NE(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::ACTIVE), 0);
|
||||
PacMap saveData;
|
||||
EXPECT_NE(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::ACTIVE, saveData), 0);
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(launcherAbilityRecord_->GetAbilityState(), OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
EXPECT_EQ(nextAbilityRecord_->GetAbilityState(), OHOS::AAFwk::AbilityState::INITIAL);
|
||||
@ -479,7 +481,8 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_003, TestSize.Leve
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_TRUE(StartNextAbility());
|
||||
launcherAbilityRecord_->SetAbilityState(OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE), 0);
|
||||
PacMap saveData;
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE, saveData), 0);
|
||||
// launcher oninactive done.
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
@ -510,11 +513,12 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_004, TestSize.Leve
|
||||
EXPECT_EQ(AttachAbility(launcherScheduler_, launcherToken_), 0);
|
||||
EXPECT_TRUE(StartNextAbility());
|
||||
launcherAbilityRecord_->SetAbilityState(OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE), 0);
|
||||
PacMap saveData;
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE, saveData), 0);
|
||||
// launcher oninactive done.
|
||||
nextAbilityRecord_->SetAbilityState(OHOS::AAFwk::AbilityState::INITIAL);
|
||||
EXPECT_EQ(AttachAbility(nextScheduler_, nextToken_), 0);
|
||||
EXPECT_NE(abilityMs_->AbilityTransitionDone(nullptr, OHOS::AAFwk::AbilityState::ACTIVE), 0);
|
||||
EXPECT_NE(abilityMs_->AbilityTransitionDone(nullptr, OHOS::AAFwk::AbilityState::ACTIVE, saveData), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -538,7 +542,8 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_005, TestSize.Leve
|
||||
EXPECT_EQ(AttachAbility(launcherScheduler_, launcherToken_), 0);
|
||||
EXPECT_TRUE(StartNextAbility());
|
||||
launcherAbilityRecord_->SetAbilityState(OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE), 0);
|
||||
PacMap saveData;
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE, saveData), 0);
|
||||
WaitUntilTaskFinished();
|
||||
// launcher oninactive done.
|
||||
nextAbilityRecord_->SetAbilityState(OHOS::AAFwk::AbilityState::INITIAL);
|
||||
@ -606,7 +611,9 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_007, TestSize.Leve
|
||||
EXPECT_EQ(AttachAbility(launcherScheduler_, launcherToken_), 0);
|
||||
EXPECT_TRUE(StartNextAbility());
|
||||
launcherAbilityRecord_->SetAbilityState(OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE), OHOS::ERR_OK);
|
||||
PacMap saveData;
|
||||
EXPECT_EQ(abilityMs_->AbilityTransitionDone(
|
||||
launcherToken_, OHOS::AAFwk::AbilityState::INACTIVE, saveData), OHOS::ERR_OK);
|
||||
// launcher oninactive done.
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(launcherAbilityRecord_->GetAbilityState(), OHOS::AAFwk::AbilityState::INACTIVE);
|
||||
|
@ -239,18 +239,19 @@ void TerminateAbilityTest::TerminateAbility(
|
||||
const OHOS::sptr<Token> &curToken, const OHOS::sptr<Token> &preToken, const Want *resultWant)
|
||||
{
|
||||
EXPECT_EQ(g_aams->TerminateAbility(curToken, -1, resultWant), 0);
|
||||
PacMap saveData;
|
||||
if (Token::GetAbilityRecordByToken(curToken)->GetAbilityState() != OHOS::AAFwk::AbilityState::INACTIVATING) {
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::INITIAL), 0);
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::INITIAL, saveData), 0);
|
||||
WaitUntilTaskFinished();
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::INACTIVE), 0);
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::INACTIVE, saveData), 0);
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(preToken, OHOS::AAFwk::AbilityState::ACTIVE), 0);
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(preToken, OHOS::AAFwk::AbilityState::ACTIVE, saveData), 0);
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::BACKGROUND), 0);
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::BACKGROUND, saveData), 0);
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::INITIAL), 0);
|
||||
EXPECT_EQ(g_aams->AbilityTransitionDone(curToken, OHOS::AAFwk::AbilityState::INITIAL, saveData), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -599,7 +600,8 @@ HWTEST_F(TerminateAbilityTest, AAFWK_g_aamsTerminateAbility_010, TestSize.Level1
|
||||
int resultValue = 10;
|
||||
want.SetParam(key, resultValue);
|
||||
EXPECT_EQ(g_aams->TerminateAbility(tokenB, -1, &musicAbilityRequest_.want), 0);
|
||||
EXPECT_NE(g_aams->AbilityTransitionDone(tokenA, OHOS::AAFwk::AbilityState::ACTIVE), 0);
|
||||
PacMap saveData;
|
||||
EXPECT_NE(g_aams->AbilityTransitionDone(tokenA, OHOS::AAFwk::AbilityState::ACTIVE, saveData), 0);
|
||||
// clear testAbilityRecordC testAbilityRecordA
|
||||
EXPECT_EQ(g_aams->TerminateAbility(tokenC, -1, nullptr), 0);
|
||||
EXPECT_EQ(g_aams->TerminateAbility(tokenA, -1, nullptr), 0);
|
||||
@ -648,7 +650,8 @@ HWTEST_F(TerminateAbilityTest, AAFWK_g_aamsTerminateAbility_011, TestSize.Level1
|
||||
int resultValue = 11;
|
||||
want.SetParam(key, resultValue);
|
||||
EXPECT_EQ(g_aams->TerminateAbility(launcherTokenB, -1, &launcherAbilityRequest_.want), 0);
|
||||
EXPECT_NE(g_aams->AbilityTransitionDone(launcherTokenA, OHOS::AAFwk::AbilityState::ACTIVE), 0);
|
||||
PacMap saveData;
|
||||
EXPECT_NE(g_aams->AbilityTransitionDone(launcherTokenA, OHOS::AAFwk::AbilityState::ACTIVE, saveData), 0);
|
||||
EXPECT_EQ(g_aams->TerminateAbility(launcherTokenC, -1, &want), 0);
|
||||
EXPECT_EQ(g_aams->TerminateAbility(launcherTokenA, -1, &want), TERMINATE_LAUNCHER_DENIED);
|
||||
WaitUntilTaskFinished();
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
MOCK_METHOD2(ReleaseDataAbility, int(sptr<IAbilityScheduler>, const sptr<IRemoteObject> &));
|
||||
MOCK_METHOD2(AddWindowInfo, void(const sptr<IRemoteObject> &token, int32_t windowToken));
|
||||
MOCK_METHOD2(AttachAbilityThread, int(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token));
|
||||
MOCK_METHOD2(AbilityTransitionDone, int(const sptr<IRemoteObject> &token, int state));
|
||||
MOCK_METHOD3(AbilityTransitionDone, int(const sptr<IRemoteObject> &token, int state, const PacMap &));
|
||||
MOCK_METHOD2(
|
||||
ScheduleConnectAbilityDone, int(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject));
|
||||
MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr<IRemoteObject> &token));
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
MOCK_METHOD1(ScheduleDisconnectAbility, void(const Want &want));
|
||||
MOCK_METHOD3(ScheduleCommandAbility, void(const Want &want, bool restart, int startid));
|
||||
MOCK_METHOD0(AsObject, sptr<IRemoteObject>());
|
||||
MOCK_METHOD1(ScheduleSaveAbilityState, void(PacMap &outState));
|
||||
MOCK_METHOD0(ScheduleSaveAbilityState, void());
|
||||
MOCK_METHOD1(ScheduleRestoreAbilityState, void(const PacMap &inState));
|
||||
MOCK_METHOD1(ScheduleUpdateConfiguration, void(const DummyConfiguration &));
|
||||
MOCK_METHOD1(ScheduleNewWant, void(const Want &want));
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
MOCK_METHOD1(ScheduleConnectAbility, void(const Want &));
|
||||
MOCK_METHOD1(ScheduleDisconnectAbility, void(const Want &));
|
||||
MOCK_METHOD3(ScheduleCommandAbility, void(const Want &, bool, int));
|
||||
MOCK_METHOD1(ScheduleSaveAbilityState, void(PacMap &));
|
||||
MOCK_METHOD0(ScheduleSaveAbilityState, void());
|
||||
MOCK_METHOD1(ScheduleRestoreAbilityState, void(const PacMap &));
|
||||
MOCK_METHOD1(ScheduleUpdateConfiguration, void(const DummyConfiguration &));
|
||||
MOCK_METHOD2(GetFileTypes, std::vector<std::string>(const Uri &, const std::string &));
|
||||
|
@ -298,8 +298,9 @@ void AbilityMgrModuleTest::MockAbilityTransitionDone(bool &testFailed, sptr<IRem
|
||||
auto mockAbilityTransation = [&testFailed, &dataAbilityToken, &abilityMgrServ](
|
||||
const Want &want, const LifeCycleStateInfo &targetState) {
|
||||
testFailed = testFailed || (targetState.state != ABILITY_STATE_ACTIVE);
|
||||
std::thread(&AbilityManagerService::AbilityTransitionDone, abilityMgrServ.get(), dataAbilityToken, ACTIVE)
|
||||
.detach();
|
||||
PacMap saveData;
|
||||
std::thread(&AbilityManagerService::AbilityTransitionDone,
|
||||
abilityMgrServ.get(), dataAbilityToken, ACTIVE, saveData).detach();
|
||||
};
|
||||
|
||||
EXPECT_CALL(*mockDataAbilityScheduler, ScheduleAbilityTransaction(_, _))
|
||||
@ -416,8 +417,9 @@ void AbilityMgrModuleTest::CheckTestRecord(std::shared_ptr<AbilityRecord> &recor
|
||||
EXPECT_EQ((std::size_t)0, abilityMgrServ_->GetConnectRecordListByCallback(callback2).size());
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, UpdateAbilityState(_, _)).Times(counts);
|
||||
abilityMgrServ_->AbilityTransitionDone(record1->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL);
|
||||
abilityMgrServ_->AbilityTransitionDone(record2->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record1->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL, saveData);
|
||||
abilityMgrServ_->AbilityTransitionDone(record2->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL, saveData);
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::TERMINATING, record1->GetAbilityState());
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::TERMINATING, record2->GetAbilityState());
|
||||
|
||||
@ -759,7 +761,9 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_007, TestSize.Level1)
|
||||
EXPECT_TRUE(curMissionStack);
|
||||
curMissionStack->AddMissionRecordToTop(mission);
|
||||
|
||||
int result = abilityMgrServ_->AbilityTransitionDone(abilityRecord->GetToken(), OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
PacMap saveData;
|
||||
int result = abilityMgrServ_->AbilityTransitionDone(
|
||||
abilityRecord->GetToken(), OHOS::AAFwk::AbilityState::ACTIVE, saveData);
|
||||
usleep(50 * 1000);
|
||||
EXPECT_EQ(OHOS::ERR_OK, result);
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::ACTIVE, abilityRecord->GetAbilityState());
|
||||
@ -817,7 +821,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_008, TestSize.Level1)
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::INACTIVATING, record->GetAbilityState());
|
||||
|
||||
EXPECT_CALL(*scheduler, ScheduleConnectAbility(_)).Times(1);
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INACTIVE);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INACTIVE, saveData);
|
||||
EXPECT_TRUE(record->GetConnectingRecord());
|
||||
EXPECT_EQ(OHOS::AAFwk::ConnectionState::CONNECTING, connectRecord->GetConnectState());
|
||||
|
||||
@ -879,7 +884,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_009, TestSize.Level1)
|
||||
EXPECT_EQ((std::size_t)0, abilityMgrServ_->connectManager_->GetConnectMap().size());
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, UpdateAbilityState(_, _)).Times(1);
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL, saveData);
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::TERMINATING, record->GetAbilityState());
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, TerminateAbility(_)).Times(1);
|
||||
@ -1009,7 +1015,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_011, TestSize.Level1)
|
||||
int testId = 0;
|
||||
auto handler = [&](const Want &want, bool restart, int startid) { testId = startid; };
|
||||
EXPECT_CALL(*scheduler, ScheduleCommandAbility(_, _, _)).Times(1).WillOnce(Invoke(handler));
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INACTIVE);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INACTIVE, saveData);
|
||||
EXPECT_EQ(1, testId);
|
||||
|
||||
abilityMgrServ_->ScheduleCommandAbilityDone(record->GetToken());
|
||||
@ -1079,7 +1086,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_012, TestSize.Level1)
|
||||
int testId = 0;
|
||||
auto handler = [&](const Want &want, bool restart, int startid) { testId = startid; };
|
||||
EXPECT_CALL(*scheduler, ScheduleCommandAbility(_, _, _)).Times(1).WillOnce(Invoke(handler));
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INACTIVE);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INACTIVE, saveData);
|
||||
EXPECT_EQ(1, testId);
|
||||
|
||||
abilityMgrServ_->ScheduleCommandAbilityDone(record->GetToken());
|
||||
@ -1173,7 +1181,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_014, TestSize.Level1)
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::TERMINATING, record->GetAbilityState());
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, UpdateAbilityState(_, _)).Times(1);
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL, saveData);
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, TerminateAbility(_)).Times(1);
|
||||
abilityMgrServ_->OnAbilityRequestDone(
|
||||
@ -1218,7 +1227,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_015, TestSize.Level1)
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::TERMINATING, record->GetAbilityState());
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, UpdateAbilityState(_, _)).Times(1);
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL, saveData);
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, TerminateAbility(_)).Times(1);
|
||||
abilityMgrServ_->OnAbilityRequestDone(
|
||||
@ -1385,7 +1395,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_018, TestSize.Level1)
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::TERMINATING, record->GetAbilityState());
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, UpdateAbilityState(_, _)).Times(1);
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL, saveData);
|
||||
EXPECT_CALL(*mockAppMgrClient_, TerminateAbility(_)).Times(1);
|
||||
abilityMgrServ_->OnAbilityRequestDone(
|
||||
record->GetToken(), (int32_t)OHOS::AppExecFwk::AbilityState::ABILITY_STATE_BACKGROUND);
|
||||
@ -1452,7 +1463,8 @@ HWTEST_F(AbilityMgrModuleTest, ability_mgr_service_test_019, TestSize.Level1)
|
||||
EXPECT_EQ(OHOS::AAFwk::AbilityState::TERMINATING, record->GetAbilityState());
|
||||
|
||||
EXPECT_CALL(*mockAppMgrClient_, UpdateAbilityState(_, _)).Times(1);
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL);
|
||||
PacMap saveData;
|
||||
abilityMgrServ_->AbilityTransitionDone(record->GetToken(), AbilityLifeCycleState::ABILITY_STATE_INITIAL, saveData);
|
||||
EXPECT_CALL(*mockAppMgrClient_, TerminateAbility(_)).Times(1);
|
||||
abilityMgrServ_->OnAbilityRequestDone(
|
||||
record->GetToken(), (int32_t)OHOS::AppExecFwk::AbilityState::ABILITY_STATE_BACKGROUND);
|
||||
|
@ -318,7 +318,7 @@ HWTEST_F(AbilityRecordModuleTest, AbilityScheduler_001, TestSize.Level3)
|
||||
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
|
||||
EXPECT_CALL(*mockAbilityScheduerStub, ScheduleSaveAbilityState(_)).Times(1);
|
||||
EXPECT_CALL(*mockAbilityScheduerStub, ScheduleSaveAbilityState()).Times(1);
|
||||
|
||||
// Activate
|
||||
auto mockActivateHandler = [&](const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo) {
|
||||
|
@ -642,7 +642,9 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_008, TestSize.Level1)
|
||||
std::make_shared<AbilityEventHandler>(nullptr, OHOS::DelayedSingleton<AbilityManagerService>::GetInstance());
|
||||
OHOS::DelayedSingleton<AbilityManagerService>::GetInstance()->handler_ = handler;
|
||||
|
||||
int result = stackManager_->AbilityTransitionDone(abilityRecord->GetToken(), OHOS::AAFwk::AbilityState::INITIAL);
|
||||
PacMap saveData;
|
||||
int result = stackManager_->AbilityTransitionDone(
|
||||
abilityRecord->GetToken(), OHOS::AAFwk::AbilityState::INITIAL, saveData);
|
||||
EXPECT_EQ(OHOS::ERR_OK, result);
|
||||
|
||||
GTEST_LOG_(INFO) << "AbilityStackModuleTest ability_stack_test_008 end";
|
||||
@ -755,7 +757,7 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_011, TestSize.Level1)
|
||||
.Times(testing::AtLeast(2))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller2));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState(_)).Times(AtLeast(1));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState()).Times(AtLeast(1));
|
||||
|
||||
firstTopAbility->SetScheduler(scheduler);
|
||||
|
||||
@ -817,7 +819,7 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_012, TestSize.Level1)
|
||||
.WillOnce(Return(nullptr))
|
||||
.WillOnce(Return(nullptr));
|
||||
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState(testing::_)).Times(testing::AtLeast(3));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState()).Times(testing::AtLeast(3));
|
||||
|
||||
EXPECT_CALL(*scheduler, ScheduleAbilityTransaction(testing::_, testing::_))
|
||||
.Times(testing::AtLeast(3))
|
||||
@ -825,7 +827,7 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_012, TestSize.Level1)
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller2))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller3))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState(_)).Times(AtLeast(1));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState()).Times(AtLeast(1));
|
||||
|
||||
firstTopAbility->SetScheduler(scheduler);
|
||||
|
||||
@ -852,14 +854,14 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_012, TestSize.Level1)
|
||||
.WillOnce(Return(nullptr))
|
||||
.WillOnce(Return(nullptr));
|
||||
|
||||
EXPECT_CALL(*scheduler2, ScheduleSaveAbilityState(testing::_)).Times(testing::AtLeast(3));
|
||||
EXPECT_CALL(*scheduler2, ScheduleSaveAbilityState()).Times(testing::AtLeast(3));
|
||||
|
||||
EXPECT_CALL(*scheduler2, ScheduleAbilityTransaction(testing::_, testing::_))
|
||||
.Times(testing::AtLeast(3))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller2_1))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller2_2))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller2_3));
|
||||
EXPECT_CALL(*scheduler2, ScheduleSaveAbilityState(_)).Times(AtLeast(1));
|
||||
EXPECT_CALL(*scheduler2, ScheduleSaveAbilityState()).Times(AtLeast(1));
|
||||
|
||||
secondTopAbility->SetScheduler(scheduler2);
|
||||
|
||||
@ -1024,7 +1026,7 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_014, TestSize.Level1)
|
||||
.Times(testing::AtLeast(2))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller3))
|
||||
.WillOnce(testing::Invoke(transactionDoneCaller4));
|
||||
EXPECT_CALL(*scheduler2, ScheduleSaveAbilityState(_)).Times(AtLeast(1));
|
||||
EXPECT_CALL(*scheduler2, ScheduleSaveAbilityState()).Times(AtLeast(1));
|
||||
|
||||
secondTopAbility->SetAbilityState(OHOS::AAFwk::INACTIVE);
|
||||
auto musicMisionRecord = secondTopAbility->GetMissionRecord();
|
||||
@ -1362,7 +1364,7 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_021, TestSize.Level1)
|
||||
.WillOnce(testing::Invoke(transactionDoneTerminate));
|
||||
|
||||
// when restart ability save the ability state
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState(testing::_)).Times(testing::AtLeast(1));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState()).Times(testing::AtLeast(1));
|
||||
// when restart ability restore the ability state
|
||||
EXPECT_CALL(*scheduler, ScheduleRestoreAbilityState(testing::_)).Times(testing::AtLeast(1));
|
||||
|
||||
@ -1434,7 +1436,7 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_022, TestSize.Level1)
|
||||
.WillOnce(testing::Invoke(transactionDoneTerminate));
|
||||
|
||||
// when restart ability save the ability state
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState(testing::_)).Times(testing::AtLeast(1));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState()).Times(testing::AtLeast(1));
|
||||
// when restart ability restore the ability state
|
||||
EXPECT_CALL(*scheduler, ScheduleRestoreAbilityState(testing::_)).Times(testing::AtLeast(1));
|
||||
|
||||
@ -1500,7 +1502,7 @@ HWTEST_F(AbilityStackModuleTest, ability_stack_test_023, TestSize.Level1)
|
||||
.WillOnce(testing::Invoke(transactionDoneTerminate));
|
||||
|
||||
// when restart ability save the ability state
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState(testing::_)).Times(testing::AtLeast(1));
|
||||
EXPECT_CALL(*scheduler, ScheduleSaveAbilityState()).Times(testing::AtLeast(1));
|
||||
// when restart ability restore the ability state
|
||||
EXPECT_CALL(*scheduler, ScheduleRestoreAbilityState(testing::_)).Times(testing::AtLeast(1));
|
||||
|
||||
|
@ -128,10 +128,11 @@ HWTEST_F(IpcAbilityMgrModuleTest, AbilityMgrService_IPC_002, TestSize.Level1)
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
sptr<MockAbilityMgrService> mockAbilityMgr(new MockAbilityMgrService());
|
||||
sptr<IAbilityManager> abilityMgrClient = iface_cast<IAbilityManager>(mockAbilityMgr);
|
||||
EXPECT_CALL(*mockAbilityMgr, AbilityTransitionDone(_, _))
|
||||
EXPECT_CALL(*mockAbilityMgr, AbilityTransitionDone(_, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(mockAbilityMgr.GetRefPtr(), &MockAbilityMgrService::Post));
|
||||
abilityMgrClient->AbilityTransitionDone(abilityRecord->GetToken(), 0);
|
||||
PacMap pmap;
|
||||
abilityMgrClient->AbilityTransitionDone(abilityRecord->GetToken(), 0, pmap);
|
||||
mockAbilityMgr->Wait();
|
||||
}
|
||||
|
||||
|
@ -238,15 +238,14 @@ HWTEST_F(IpcAbilitySchedulerModuleTest, ScheduleSaveAbilityState_001, TestSize.L
|
||||
sptr<IAbilityScheduler> proxy = iface_cast<IAbilityScheduler>(stub);
|
||||
|
||||
bool testResult = false;
|
||||
auto mockHandler = [&](const PacMap &pacMap) {
|
||||
auto mockHandler = [&]() {
|
||||
testResult = true;
|
||||
sem.Post();
|
||||
};
|
||||
|
||||
EXPECT_CALL(*stub, ScheduleSaveAbilityState(_)).Times(1).WillOnce(Invoke(mockHandler));
|
||||
EXPECT_CALL(*stub, ScheduleSaveAbilityState()).Times(1).WillOnce(Invoke(mockHandler));
|
||||
|
||||
PacMap pacMap;
|
||||
proxy->ScheduleSaveAbilityState(pacMap);
|
||||
proxy->ScheduleSaveAbilityState();
|
||||
|
||||
sem.Wait();
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
ReleaseDataAbility, int(sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken));
|
||||
MOCK_METHOD2(AddWindowInfo, void(const sptr<IRemoteObject> &token, int32_t windowToken));
|
||||
MOCK_METHOD2(AttachAbilityThread, int(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token));
|
||||
MOCK_METHOD2(AbilityTransitionDone, int(const sptr<IRemoteObject> &token, int state));
|
||||
MOCK_METHOD3(AbilityTransitionDone, int(const sptr<IRemoteObject> &token, int state, const PacMap &));
|
||||
MOCK_METHOD2(
|
||||
ScheduleConnectAbilityDone, int(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject));
|
||||
MOCK_METHOD1(ScheduleDisconnectAbilityDone, int(const sptr<IRemoteObject> &token));
|
||||
|
Loading…
Reference in New Issue
Block a user