change powermanager mock for ut test

Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
Mupceet 2022-03-07 14:00:29 +08:00
parent 25c0eb0f22
commit 5bf6eb5df1
4 changed files with 116 additions and 22 deletions

View File

@ -81,8 +81,6 @@ config("module_private_config") {
]
}
MockPowerManagerSrc = [ "mock/powermanager/src/mock_power_mgr_client.cpp" ]
MockAafwkSrc = [ "mock/aafwk/src/mock_ability_manager_client.cpp" ]
MockDistributedscheduleSrc = [
@ -140,7 +138,7 @@ ohos_moduletest("aams_accessibility_touch_guider_test") {
sources += aams_mock_distributeddatamgr_src
sources += aams_mock_multimodalinput_src
sources += MockPowerManagerSrc
sources += aams_mock_powermanager_src
sources += MockAafwkSrc
sources += MockDistributedscheduleSrc
@ -226,7 +224,7 @@ ohos_moduletest("aams_accessibility_touchEvent_injector_test") {
sources += aams_mock_distributeddatamgr_src
sources += aams_mock_multimodalinput_src
sources += MockPowerManagerSrc
sources += aams_mock_powermanager_src
sources += MockAafwkSrc
sources += MockDistributedscheduleSrc
@ -324,7 +322,7 @@ ohos_moduletest("aams_accessible_ability_channel_test") {
sources += aams_mock_distributeddatamgr_src
sources += aams_mock_multimodalinput_src
sources += MockPowerManagerSrc
sources += aams_mock_powermanager_src
sources += MockAafwkSrc
sources += MockDistributedscheduleSrc
@ -424,7 +422,7 @@ ohos_moduletest("aams_server_test") {
sources += aams_mock_distributeddatamgr_src
sources += aams_mock_multimodalinput_src
sources += MockPowerManagerSrc
sources += aams_mock_powermanager_src
sources += MockAafwkSrc
sources += MockDistributedscheduleSrc
@ -512,7 +510,7 @@ ohos_moduletest("aams_accessibility_keyevent_filter_test") {
sources += aams_mock_distributeddatamgr_src
sources += aams_mock_multimodalinput_src
sources += MockPowerManagerSrc
sources += aams_mock_powermanager_src
sources += MockAafwkSrc
sources += MockDistributedscheduleSrc
@ -609,7 +607,7 @@ ohos_moduletest("aams_common_event_registry_test") {
sources += aams_mock_distributeddatamgr_src
sources += aams_mock_multimodalinput_src
sources += MockPowerManagerSrc
sources += aams_mock_powermanager_src
sources += MockAafwkSrc
sources += MockDistributedscheduleSrc

View File

@ -20,6 +20,7 @@ aams_mock_include_dirs = [
"//foundation/multimodalinput/input/common/include",
"//foundation/multimodalinput/input/interfaces/native/innerkits/proxy/include",
"//foundation/multimodalinput/input/interfaces/native/innerkits/event/include",
"//base/powermgr/power_manager/interfaces/innerkits/native/include",
]
aams_mock_distributeddatamgr_src =
@ -31,3 +32,7 @@ aams_mock_multimodalinput_src = [
"$AAMS_MOCK_PATH/multimodalinput/src/mock_key_event.cpp",
"$AAMS_MOCK_PATH/multimodalinput/src/mock_pointer_event.cpp",
]
aams_mock_powermanager_src =
[ "$AAMS_MOCK_PATH/powermanager/src/mock_power_mgr_client.cpp", ]

View File

@ -13,21 +13,13 @@
* limitations under the License.
*/
#ifndef POWERMGR_POWER_MGR_CLIENT_H
#define POWERMGR_POWER_MGR_CLIENT_H
#ifndef MOCK_POWERMGR_POWER_MGR_CLIENT_H
#define MOCK_POWERMGR_POWER_MGR_CLIENT_H
#include <string>
#include <singleton.h>
#include "power_state_machine_info.h"
#include "power_mgr_client.h"
namespace OHOS {
namespace PowerMgr {
class PowerMgrClient final : public DelayedRefSingleton<PowerMgrClient> {
DECLARE_DELAYED_REF_SINGLETON(PowerMgrClient)
public:
void RefreshActivity(UserActivityType type = UserActivityType::USER_ACTIVITY_TYPE_OTHER);
};
} // namespace PowerMgr
} // namespace OHOS
#endif // POWERMGR_POWER_MGR_CLIENT_H

View File

@ -13,17 +13,116 @@
* limitations under the License.
*/
#include "power_mgr_client.h"
#include "mock_power_mgr_client.h"
namespace OHOS {
namespace PowerMgr {
PowerMgrClient::PowerMgrClient()
{}
PowerMgrClient::PowerMgrClient() {}
PowerMgrClient::~PowerMgrClient()
{}
ErrCode PowerMgrClient::Connect()
{
return ERR_OK;
}
void PowerMgrClient::ResetProxy(const wptr<IRemoteObject>& remote)
{
}
void PowerMgrClient::PowerMgrDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
{
}
void PowerMgrClient::RebootDevice(const std::string& reason)
{
}
void PowerMgrClient::ShutDownDevice(const std::string& reason)
{
}
void PowerMgrClient::SuspendDevice(SuspendDeviceType reason, bool suspendImmed)
{
}
void PowerMgrClient::WakeupDevice(WakeupDeviceType reason, const std::string& detail)
{
}
void PowerMgrClient::RefreshActivity(UserActivityType type)
{
}
bool PowerMgrClient::IsRunningLockTypeSupported(uint32_t type)
{
return true;
}
bool PowerMgrClient::ForceSuspendDevice()
{
return true;
}
bool PowerMgrClient::IsScreenOn()
{
return true;
}
PowerState PowerMgrClient::GetState()
{
return PowerState::UNKNOWN;
}
std::shared_ptr<RunningLock> PowerMgrClient::CreateRunningLock(const std::string& name, RunningLockType type)
{
return nullptr;
}
void PowerMgrClient::RegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback)
{
}
void PowerMgrClient::UnRegisterPowerStateCallback(const sptr<IPowerStateCallback>& callback)
{
}
void PowerMgrClient::RegisterShutdownCallback(const sptr<IShutdownCallback>& callback,
IShutdownCallback::ShutdownPriority priority)
{
}
void PowerMgrClient::UnRegisterShutdownCallback(const sptr<IShutdownCallback>& callback)
{
}
void PowerMgrClient::RegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback)
{
}
void PowerMgrClient::UnRegisterPowerModeCallback(const sptr<IPowerModeCallback>& callback)
{
}
void PowerMgrClient::SetDisplaySuspend(bool enable)
{
}
void PowerMgrClient::SetDeviceMode(const uint32_t mode)
{
}
uint32_t PowerMgrClient::GetDeviceMode()
{
return ERR_OK;
}
std::string PowerMgrClient::Dump(const std::vector<std::string>& args)
{
return "ERR_OK";
}
} // namespace PowerMgr
} // namespace OHOS