mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
013520d6e6
@ -22,9 +22,11 @@
|
||||
#include "distributed_sched_util.h"
|
||||
#include "dtbschedmgr_device_info_storage.h"
|
||||
#include "dtbschedmgr_log.h"
|
||||
#include "form_mgr_errors.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "mock_form_mgr_service.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "test_log.h"
|
||||
#include "thread_pool.h"
|
||||
@ -740,5 +742,77 @@ HWTEST_F(DistributedSchedServiceTest, StartLocalAbility_004, TestSize.Level1)
|
||||
DTEST_LOG << "result2:" << result2 << std::endl;
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartLocalAbility_004 end" << std::endl;
|
||||
}
|
||||
/**
|
||||
* @tc.name: StartRemoteShareForm_001
|
||||
* @tc.desc: call StartRemoteShareForm with dms
|
||||
* @tc.type: StartRemoteShareForm
|
||||
* @tc.require: issueI5M62D
|
||||
*/
|
||||
HWTEST_F(DistributedSchedServiceTest, StartRemoteShareForm_001, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartRemoteShareForm_001 start" << std::endl;
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
const std::string remoteDeviceId = "";
|
||||
const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
|
||||
auto result = proxy->StartRemoteShareForm(remoteDeviceId, formShareInfo);
|
||||
DTEST_LOG << "result:" << result << std::endl;
|
||||
EXPECT_EQ(static_cast<int>(INVALID_PARAMETERS_ERR), result);
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartRemoteShareForm_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartRemoteShareForm_002
|
||||
* @tc.desc: call StartAbilityFromRemote with dms
|
||||
* @tc.type: StartRemoteShareForm
|
||||
* @tc.require: issueI5M62D
|
||||
*/
|
||||
HWTEST_F(DistributedSchedServiceTest, StartRemoteShareForm_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartRemoteShareForm_002 start" << std::endl;
|
||||
sptr<IDistributedSched> proxy = GetDms();
|
||||
const std::string remoteDeviceId = "123456";
|
||||
const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
|
||||
auto result = proxy->StartRemoteShareForm(remoteDeviceId, formShareInfo);
|
||||
DTEST_LOG << "result:" << result << std::endl;
|
||||
EXPECT_EQ(static_cast<int>(DMS_PERMISSION_DENIED), result);
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartRemoteShareForm_002 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartShareFormFromRemote_001
|
||||
* @tc.desc: call StartAbilityFromRemote with dms
|
||||
* @tc.type: StartShareFormFromRemote
|
||||
* @tc.require: issueI5M62D
|
||||
*/
|
||||
HWTEST_F(DistributedSchedServiceTest, StartShareFormFromRemote_001, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartShareFormFromRemote_001 start" << std::endl;
|
||||
std::string remoteDeviceId = "";
|
||||
DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(remoteDeviceId);
|
||||
const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
|
||||
DistributedSchedService::GetInstance().formMgrProxy_ = new MockFormMgrService();
|
||||
auto result = DistributedSchedService::GetInstance().StartShareFormFromRemote(remoteDeviceId, formShareInfo);
|
||||
DTEST_LOG << "result:" << result << std::endl;
|
||||
EXPECT_EQ(static_cast<int>(ERR_OK), result);
|
||||
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartShareFormFromRemote_001 end" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StartShareFormFromRemote_002
|
||||
* @tc.desc: call StartAbilityFromRemote with dms
|
||||
* @tc.type: StartShareFormFromRemote
|
||||
* @tc.require: issueI5M62D
|
||||
*/
|
||||
HWTEST_F(DistributedSchedServiceTest, StartShareFormFromRemote_002, TestSize.Level1)
|
||||
{
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartShareFormFromRemote_002 start" << std::endl;
|
||||
std::string remoteDeviceId = "123456";
|
||||
const OHOS::AppExecFwk::FormShareInfo formShareInfo {};
|
||||
auto result = DistributedSchedService::GetInstance().StartShareFormFromRemote(remoteDeviceId, formShareInfo);
|
||||
DTEST_LOG << "result:" << result << std::endl;
|
||||
EXPECT_EQ(static_cast<int>(INVALID_REMOTE_PARAMETERS_ERR), result);
|
||||
DTEST_LOG << "DistributedSchedServiceTest StartShareFormFromRemote_002 end" << std::endl;
|
||||
}
|
||||
} // namespace DistributedSchedule
|
||||
} // namespace OHOS
|
194
services/dtbschedmgr/test/unittest/mock_form_mgr_service.h
Normal file
194
services/dtbschedmgr/test/unittest/mock_form_mgr_service.h
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H
|
||||
#define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H
|
||||
|
||||
#include <codecvt>
|
||||
#include <memory>
|
||||
#include <singleton.h>
|
||||
#include <system_ability.h>
|
||||
#include <thread_ex.h>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "form_event_handler.h"
|
||||
#include "form_mgr_stub.h"
|
||||
#include "form_provider_data.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
/**
|
||||
* @class MockFormMgrService
|
||||
*/
|
||||
class MockFormMgrService : public FormMgrStub,
|
||||
public std::enable_shared_from_this<MockFormMgrService> {
|
||||
public:
|
||||
MockFormMgrService() = default;
|
||||
virtual~MockFormMgrService() = default;
|
||||
int32_t AddForm(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
FormJsInfo &formInfo) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DeleteForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t ReleaseForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const bool delCache) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t UpdateForm(const int64_t formId, const FormProviderData &FormProviderData) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t SetNextRefreshTime(const int64_t formId, const int64_t nextTime) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t LifecycleUpdate(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken,
|
||||
const bool updateType) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
ErrCode AddFormInfo(FormInfo &formInfo) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
ErrCode RemoveFormInfo(const std::string &moduleName, const std::string &formName) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
ErrCode RequestPublishForm(Want &want, bool withFormBindingData,
|
||||
std::unique_ptr<FormProviderData> &formBindingData, int64_t &formId) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t RequestForm(const int64_t formId, const sptr<IRemoteObject> &callerToken, const Want &want) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t NotifyWhetherVisibleForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken,
|
||||
const int32_t formVisibleType) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t CastTempForm(const int64_t formId, const sptr<IRemoteObject> &callerToken) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DumpStorageFormInfos(std::string &formInfos) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DumpFormInfoByBundleName(const std::string &bundleName, std::string &formInfos) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DumpFormInfoByFormId(const std::int64_t formId, std::string &formInfo) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DumpFormTimerByFormId(const std::int64_t formId, std::string &isTimingService) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t MessageEvent(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t RouterEvent(const int64_t formId, Want &want) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t BatchAddFormRecords(const Want &want) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t ClearFormRecords() override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DistributedDataAddForm(const Want &want) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DistributedDataDeleteForm(const std::string &formId) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t DeleteInvalidForms(const std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken,
|
||||
int32_t &numFormsDeleted) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t AcquireFormState(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
FormStateInfo &stateInfo) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t NotifyFormsVisible(const std::vector<int64_t> &formIds, bool isVisible,
|
||||
const sptr<IRemoteObject> &callerToken) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t NotifyFormsEnableUpdate(const std::vector<int64_t> &formIds, bool isEnableUpdate,
|
||||
const sptr<IRemoteObject> &callerToken) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t GetAllFormsInfo(std::vector<FormInfo> &formInfos) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t GetFormsInfoByApp(std::string &bundleName, std::vector<FormInfo> &formInfos) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t GetFormsInfoByModule(std::string &bundleName, std::string &moduleName,
|
||||
std::vector<FormInfo> &formInfos) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t UpdateRouterAction(const int64_t formId, std::string &action) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t ShareForm(const int64_t formId, const std::string &deviceId,
|
||||
const sptr<IRemoteObject> &callerToken, const int64_t requestCode) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t RecvFormShareInfoFromRemote(const FormShareInfo &info) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
bool IsRequestPublishFormSupported() override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
int32_t StartAbility(const Want &want, const sptr<IRemoteObject> &callerToken) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
int32_t GetFormsInfo(const FormInfoFilter &filter, std::vector<FormInfo> &formInfos) override
|
||||
{
|
||||
return ERR_OK;
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_MGR_SERVICE_H
|
Loading…
Reference in New Issue
Block a user