mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-23 06:50:30 +00:00
补充DT代码
Signed-off-by: fanzexuan <fanzexuan@huawei.com>
This commit is contained in:
parent
fb09ac49fb
commit
8937abc43e
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 MOCK_MT_ACCESSIBILITY_TOUCHEVENT_INJECTOR_H
|
||||
#define MOCK_MT_ACCESSIBILITY_TOUCHEVENT_INJECTOR_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "accessibility_touchEvent_injector.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class MockMtTouchInjectHandler : public TouchInjectHandler {
|
||||
public:
|
||||
MockMtTouchInjectHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner, TouchEventInjector& server);
|
||||
virtual ~MockMtTouchInjectHandler() = default;
|
||||
|
||||
MOCK_METHOD1(ProcessEvent, void(const AppExecFwk::InnerEvent::Pointer& event));
|
||||
};
|
||||
|
||||
class MockTouchEventInjector : public TouchEventInjector {
|
||||
public:
|
||||
MockTouchEventInjector();
|
||||
~MockTouchEventInjector()
|
||||
{}
|
||||
|
||||
MOCK_METHOD1(OnPointerEvent, void(MMI::PointerEvent& event));
|
||||
MOCK_METHOD0(DestroyEvents, void());
|
||||
MOCK_METHOD1(InjectEvents, void(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath));
|
||||
MOCK_METHOD1(SendPointerEvent, void(MMI::PointerEvent& event));
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // MOCK_MT_ACCESSIBILITY_TOUCHEVENT_INJECTOR_H
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 MOCK_ACCESSIBILITY_TOUCH_GUIDER_H
|
||||
#define MOCK_ACCESSIBILITY_TOUCH_GUIDER_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "accessibility_touch_guider.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class MockMtTGEventHandler : public TGEventHandler {
|
||||
public:
|
||||
MockMtTGEventHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner, TouchGuider& tgServer);
|
||||
virtual ~MockMtTGEventHandler() = default;
|
||||
|
||||
MOCK_METHOD1(ProcessEvent, void(const AppExecFwk::InnerEvent::Pointer& event));
|
||||
};
|
||||
|
||||
class MockTouchGuider : public TouchGuider {
|
||||
public:
|
||||
MockTouchGuider();
|
||||
~MockTouchGuider()
|
||||
{}
|
||||
|
||||
MOCK_METHOD0(StartUp, void());
|
||||
MOCK_METHOD1(OnPointerEvent, void(MMI::PointerEvent& event));
|
||||
MOCK_METHOD0(DestroyEvents, void());
|
||||
MOCK_METHOD2(SendEventToMultimodal, void(MMI::PointerEvent& event, int32_t action));
|
||||
MOCK_METHOD1(SendAccessibilityEventToAA, void(EventType eventType));
|
||||
MOCK_METHOD0(getHoverEnterAndMoveEvent, std::list<MMI::PointerEvent>());
|
||||
MOCK_METHOD0(ClearHoverEnterAndMoveEvent, void());
|
||||
MOCK_METHOD0(getLastReceivedEvent, std::shared_ptr<MMI::PointerEvent>());
|
||||
|
||||
/* For TouchGuide */
|
||||
inline void OnTouchInteractionStart()
|
||||
{
|
||||
isTouchStart_ = true;
|
||||
}
|
||||
|
||||
inline void OnTouchInteractionEnd()
|
||||
{
|
||||
isTouchStart_ = false;
|
||||
}
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // MOCK_ACCESSIBILITY_TOUCH_GUIDER_H
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 MOCK_MT_ACCESSIBILITY_WINDOW_CONNECTION_H
|
||||
#define MOCK_MT_ACCESSIBILITY_WINDOW_CONNECTION_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "accessibility_window_connection.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class MockMtAccessibilityWindowConnection : public AccessibilityWindowConnection {
|
||||
public:
|
||||
MockMtAccessibilityWindowConnection(
|
||||
const int32_t windowId, const sptr<IAccessibilityElementOperator>& connection, const int32_t accountId);
|
||||
MockMtAccessibilityWindowConnection(const int32_t windowId, const int32_t treeId,
|
||||
const sptr<IAccessibilityElementOperator>& connection, const int32_t accountId);
|
||||
~MockMtAccessibilityWindowConnection();
|
||||
|
||||
inline sptr<IAccessibilityElementOperator> GetProxy()
|
||||
{
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
sptr<IAccessibilityElementOperator> GetCardProxy(const int32_t treeId);
|
||||
|
||||
RetError SetCardProxy(const int32_t treeId, sptr<IAccessibilityElementOperator> operation);
|
||||
|
||||
void GetAllTreeId(std::vector<int32_t> &treeIds);
|
||||
|
||||
RetError GetRootParentId(int32_t treeId, int64_t &elementId);
|
||||
|
||||
RetError SetRootParentId(const int32_t treeId, const int64_t elementId);
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // MOCK_MT_ACCESSIBILITY_WINDOW_CONNECTION_H
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 MOCK_MT_ACCESSIBILITY_WINDOW_MANGER_H
|
||||
#define MOCK_MT_ACCESSIBILITY_WINDOW_MANGER_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "accessibility_window_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class MockMtAccessibilityWindowListener : public AccessibilityWindowListener {
|
||||
public:
|
||||
MOCK_METHOD2(OnWindowUpdate, void(const sptr<Rosen::AccessibilityWindowInfo>& windowInfo,
|
||||
Rosen::WindowUpdateType type));
|
||||
};
|
||||
|
||||
class MockAccessibilityWindowInfoManager : public AccessibilityWindowManager {
|
||||
public:
|
||||
~MockAccessibilityWindowInfoManager() = default;
|
||||
MOCK_METHOD1(CreateAccessibilityWindowInfo, AccessibilityWindowInfo(
|
||||
sptr<Rosen::AccessibilityWindowInfo> windowInfo));
|
||||
MOCK_METHOD2(ConvertToRealWindowId, int32_t(int32_t windowId, int32_t focusType));
|
||||
MOCK_METHOD1(RegisterWindowListener, void(const std::shared_ptr<AppExecFwk::EventHandler> &handler));
|
||||
MOCK_METHOD0(DeregisterWindowListener, void());
|
||||
MOCK_METHOD1(SetActiveWindow, void(int32_t windowId, bool isSendEvent));
|
||||
MOCK_METHOD1(SetAccessibilityFocusedWindow, void(int32_t windowId));
|
||||
MOCK_METHOD0(GetAccessibilityWindows, std::vector<AccessibilityWindowInfo>());
|
||||
MOCK_METHOD2(GetAccessibilityWindow, bool(int32_t windowId, AccessibilityWindowInfo& window));
|
||||
MOCK_METHOD1(IsValidWindow, bool(int32_t windowId));
|
||||
MOCK_METHOD2(SetWindowSize, void(int32_t windowId, Rect rect));
|
||||
MOCK_METHOD2(GetSceneBoardElementId, int32_t(const int32_t windowId, const int64_t elementId));
|
||||
MOCK_METHOD2(GetRealWindowAndElementId, void(int32_t windowId, int64_t elementId));
|
||||
MOCK_METHOD3(GetSceneBoardInnerWinId, void(int32_t windowId, int64_t elementId, int32_t& innerWid));
|
||||
MOCK_METHOD1(GetFocusedWindowId, RetError(int32_t &focusedWindowId));
|
||||
MOCK_METHOD0(GetActiveWindowId, int32_t());
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // MOCK_MT_ACCESSIBILITY_WINDOW_MANGER_H
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 MOCK_MT_ACCESSIBILITY_ZOOM_GESTURE_H
|
||||
#define MOCK_MT_ACCESSIBILITY_ZOOM_GESTURE_H
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include "accessibility_zoom_gesture.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class MockMtAccessibilityZoomGesture : public AccessibilityZoomGesture {
|
||||
public:
|
||||
MockMtAccessibilityZoomGesture();
|
||||
~MockMtAccessibilityZoomGesture();
|
||||
|
||||
MOCK_METHOD1(Triple, bool(MMI::PointerEvent& event));
|
||||
MOCK_METHOD0(Up, void());
|
||||
MOCK_METHOD0(Clear, void());
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // MOCK_MT_ACCESSIBILITY_ZOOM_GESTURE_H
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 MOCK_MT_ACCESSIBLE_ABILITY_CLIENT_STUB_IMPL_H
|
||||
#define MOCK_MT_ACCESSIBLE_ABILITY_CLIENT_STUB_IMPL_H
|
||||
|
||||
#include <memory>
|
||||
#include "accessible_ability_client_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
class MockMtAccessibleAbilityClientStubImpl : public AccessibleAbilityClientStub {
|
||||
public:
|
||||
MockMtAccessibleAbilityClientStubImpl();
|
||||
virtual ~MockMtAccessibleAbilityClientStubImpl();
|
||||
|
||||
virtual int OnRemoteRequest(
|
||||
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
|
||||
|
||||
virtual void Init(const sptr<IAccessibleAbilityChannel>& channel, const int32_t channelId) override;
|
||||
virtual void Disconnect(const int32_t channelId) override;
|
||||
virtual void OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo) override;
|
||||
virtual void OnKeyPressEvent(const MMI::KeyEvent& keyEvent, const int32_t sequence) override;
|
||||
|
||||
private:
|
||||
ErrCode HandleInit(MessageParcel& data, MessageParcel& reply);
|
||||
ErrCode HandleDisconnect(MessageParcel& data, MessageParcel& reply);
|
||||
ErrCode HandleOnAccessibilityEvent(MessageParcel& data, MessageParcel& reply);
|
||||
ErrCode HandleOnKeyPressEvent(MessageParcel& data, MessageParcel& reply);
|
||||
DISALLOW_COPY_AND_MOVE(MockMtAccessibleAbilityClientStubImpl);
|
||||
};
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
||||
#endif // MOCK_MT_ACCESSIBLE_ABILITY_CLIENT_STUB_IMPL_H
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "accessibility_touchEvent_injector.h"
|
||||
#include "accessible_ability_manager_service.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
MockTouchInjectHandler::MockTouchInjectHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner>& runner, TouchEventInjector& server)
|
||||
: AppExecFwk::EventHandler(runner), server_(server)
|
||||
{
|
||||
(void)runner;
|
||||
(void)server;
|
||||
}
|
||||
|
||||
void MockTouchInjectHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event)
|
||||
{
|
||||
std::shared_ptr<SendEventArgs> parameters = nullptr;
|
||||
if (!event) {
|
||||
return;
|
||||
}
|
||||
switch (event->GetInnerEventId()) {
|
||||
case TouchEventInjector::SEND_TOUCH_EVENT_MSG:
|
||||
parameters = event->GetSharedObject<SendEventArgs>();
|
||||
if (!parameters->event_) {
|
||||
return;
|
||||
}
|
||||
server_.SendPointerEvent(*parameters->event_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TouchEventInjector::TouchEventInjector()
|
||||
{}
|
||||
|
||||
bool TouchEventInjector::OnPointerEvent(MMI::PointerEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
return false;
|
||||
}
|
||||
|
||||
void TouchEventInjector::DestroyEvents()
|
||||
{
|
||||
isDestroyEvent_ = true;
|
||||
}
|
||||
|
||||
void TouchEventInjector::SendPointerEvent(MMI::PointerEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
}
|
||||
|
||||
void TouchEventInjector::CancelGesture()
|
||||
{}
|
||||
|
||||
void TouchEventInjector::CancelInjectedEvents()
|
||||
{}
|
||||
|
||||
std::shared_ptr<MMI::PointerEvent> TouchEventInjector::obtainTouchEvent(
|
||||
int32_t action, MMI::PointerEvent::PointerItem point, int64_t actionTime)
|
||||
{
|
||||
(void)action;
|
||||
(void)point;
|
||||
(void)actionTime;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int64_t TouchEventInjector::GetSystemTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TouchEventInjector::InjectEvents(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,790 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "accessibility_touch_guider.h"
|
||||
#include "accessibility_window_manager.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
namespace {
|
||||
constexpr int32_t POINTER_COUNT_1 = 1;
|
||||
constexpr int32_t POINTER_COUNT_2 = 2;
|
||||
} // namespace
|
||||
|
||||
TGEventHandler::TGEventHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner, MockTouchGuider& tgServer)
|
||||
: AppExecFwk::EventHandler(runner), tgServer_(tgServer)
|
||||
{
|
||||
}
|
||||
|
||||
MockTouchGuider::MockTouchGuider()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING);
|
||||
}
|
||||
|
||||
void MockTouchGuider::StartUp()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
touchGuideListener_ = std::make_unique<TouchGuideListener>(*this);
|
||||
gestureRecognizer_.RegisterListener(*touchGuideListener_.get());
|
||||
runner_ = Singleton<AccessibleAbilityManagerService>::GetInstance().GetMainRunner();
|
||||
if (!runner_) {
|
||||
HILOG_ERROR("get runner failed");
|
||||
return;
|
||||
}
|
||||
|
||||
handler_ = std::make_shared<TGEventHandler>(runner_, *this);
|
||||
if (!handler_) {
|
||||
HILOG_ERROR("create event handler failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void TGEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
switch (event->GetInnerEventId()) {
|
||||
case MockTouchGuider::EXIT_GESTURE_REC_MSG:
|
||||
tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
|
||||
break;
|
||||
case MockTouchGuider::SEND_HOVER_ENTER_MOVE_MSG:
|
||||
HoverEnterAndMoveRunner();
|
||||
break;
|
||||
case MockTouchGuider::SEND_HOVER_EXIT_MSG:
|
||||
HoverExitRunner();
|
||||
break;
|
||||
case MockTouchGuider::SEND_TOUCH_INTERACTION_END_MSG:
|
||||
tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
|
||||
break;
|
||||
case MockTouchGuider::SEND_TOUCH_GUIDE_END_MSG:
|
||||
tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool MockTouchGuider::OnPointerEvent(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (event.GetSourceType() != MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
|
||||
EventTransmission::OnPointerEvent(event);
|
||||
return false;
|
||||
}
|
||||
if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_CANCEL) {
|
||||
Clear(event);
|
||||
return true;
|
||||
}
|
||||
RecordReceivedEvent(event);
|
||||
if (gestureRecognizer_.OnPointerEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
switch (static_cast<TouchGuideState>(currentState_)) {
|
||||
case TouchGuideState::TOUCH_GUIDING:
|
||||
HandleTouchGuidingState(event);
|
||||
break;
|
||||
case TouchGuideState::DRAGGING:
|
||||
HandleDraggingState(event);
|
||||
break;
|
||||
case TouchGuideState::TRANSMITTING:
|
||||
HandleTransmitingState(event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MockTouchGuider::DestroyEvents()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
Clear();
|
||||
EventTransmission::DestroyEvents();
|
||||
}
|
||||
|
||||
void MockTouchGuider::SendAccessibilityEventToAA(EventType eventType)
|
||||
{
|
||||
HILOG_DEBUG("eventType is 0x%{public}x.", eventType);
|
||||
|
||||
AccessibilityEventInfo eventInfo {};
|
||||
eventInfo.SetEventType(eventType);
|
||||
int32_t windowsId = Singleton<AccessibilityWindowManager>::GetInstance().activeWindowId_;
|
||||
eventInfo.SetWindowId(windowsId);
|
||||
Singleton<AccessibleAbilityManagerService>::GetInstance().SendEvent(eventInfo);
|
||||
if (eventType == EventType::TYPE_TOUCH_GUIDE_BEGIN) {
|
||||
isTouchGuiding_ = true;
|
||||
} else if (eventType == EventType::TYPE_TOUCH_GUIDE_END) {
|
||||
isTouchGuiding_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::SendEventToMultimodal(MMI::PointerEvent& event, int32_t action)
|
||||
{
|
||||
HILOG_DEBUG("action is %{public}d.", action);
|
||||
HILOG_DEBUG("SourceType is %{public}d.", event.GetSourceType());
|
||||
|
||||
switch (action) {
|
||||
case HOVER_MOVE:
|
||||
if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
|
||||
event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
|
||||
event.SetSourceType(MMI::PointerEvent::SOURCE_TYPE_MOUSE);
|
||||
}
|
||||
break;
|
||||
case POINTER_DOWN:
|
||||
if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
|
||||
event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
|
||||
}
|
||||
break;
|
||||
case POINTER_UP:
|
||||
if (event.GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
|
||||
event.SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
EventTransmission::OnPointerEvent(event);
|
||||
RecordInjectedEvent(event);
|
||||
}
|
||||
|
||||
std::list<MMI::PointerEvent> MockTouchGuider::getHoverEnterAndMoveEvent()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
return pointerEvents_;
|
||||
}
|
||||
|
||||
void MockTouchGuider::ClearHoverEnterAndMoveEvent()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
pointerEvents_.clear();
|
||||
gestureRecognizer_.Clear();
|
||||
}
|
||||
|
||||
std::shared_ptr<MMI::PointerEvent> MockTouchGuider::getLastReceivedEvent()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
return receivedRecorder_.lastEvent;
|
||||
}
|
||||
|
||||
bool MockTouchGuider::TouchGuideListener::OnDoubleTap(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
MMI::PointerEvent::PointerItem clickPoint = {};
|
||||
if (server_.currentState_ != static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING)) {
|
||||
return false;
|
||||
}
|
||||
server_.OnTouchInteractionEnd();
|
||||
server_.CancelPostEventIfNeed(server_.SEND_HOVER_ENTER_MOVE_MSG);
|
||||
server_.CancelPostEventIfNeed(server_.SEND_HOVER_EXIT_MSG);
|
||||
server_.ForceSendAndRemoveEvent(server_.SEND_TOUCH_GUIDE_END_MSG, event);
|
||||
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
|
||||
|
||||
return server_.ExecuteActionOnAccessibilityFocused(ActionType::ACCESSIBILITY_ACTION_CLICK);
|
||||
}
|
||||
|
||||
bool MockTouchGuider::TouchGuideListener::OnStarted()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
server_.currentState_ = static_cast<int32_t>(TouchGuideState::TRANSMITTING);
|
||||
server_.CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG);
|
||||
server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
|
||||
server_.PostGestureRecognizeExit();
|
||||
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_BEGIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MockTouchGuider::TouchGuideListener::OnCompleted(GestureType gestureId)
|
||||
{
|
||||
HILOG_DEBUG("OnCompleted, gestureId is %{public}d", gestureId);
|
||||
|
||||
if (server_.currentState_ != static_cast<int32_t>(TouchGuideState::TRANSMITTING)) {
|
||||
HILOG_DEBUG("OnCompleted, state is not transmitting.");
|
||||
return false;
|
||||
}
|
||||
server_.OnTouchInteractionEnd();
|
||||
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
|
||||
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
|
||||
server_.CancelPostEvent(EXIT_GESTURE_REC_MSG);
|
||||
server_.currentState_ = static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING);
|
||||
|
||||
AccessibilityEventInfo eventInfo {};
|
||||
eventInfo.SetEventType(EventType::TYPE_GESTURE_EVENT);
|
||||
eventInfo.SetGestureType(gestureId);
|
||||
Singleton<AccessibleAbilityManagerService>::GetInstance().SendEvent(eventInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MockTouchGuider::TouchGuideListener::OnCancelled(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
switch (static_cast<TouchGuideState>(server_.currentState_)) {
|
||||
case TouchGuideState::TRANSMITTING:
|
||||
server_.OnTouchInteractionEnd();
|
||||
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_GESTURE_END);
|
||||
if (event.GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP &&
|
||||
event.GetPointerIds().size() == POINTER_COUNT_1) {
|
||||
server_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
|
||||
}
|
||||
server_.CancelPostEvent(EXIT_GESTURE_REC_MSG);
|
||||
server_.currentState_ = static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING);
|
||||
break;
|
||||
case TouchGuideState::TOUCH_GUIDING:
|
||||
server_.pointerEvents_.push_back(event);
|
||||
server_.ForceSendAndRemoveEvent(SEND_HOVER_ENTER_MOVE_MSG, event);
|
||||
server_.CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
|
||||
server_.SendEventToMultimodal(event, HOVER_MOVE);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MockTouchGuider::HandleTouchGuidingState(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
switch (event.GetPointerAction()) {
|
||||
case MMI::PointerEvent::POINTER_ACTION_DOWN:
|
||||
if (event.GetPointerIds().size() == POINTER_COUNT_1) {
|
||||
HandleTouchGuidingStateInnerDown(event);
|
||||
} else {
|
||||
CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG);
|
||||
CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
|
||||
}
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_MOVE:
|
||||
HandleTouchGuidingStateInnerMove(event);
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
if (event.GetPointerIds().size() == POINTER_COUNT_1) {
|
||||
OnTouchInteractionEnd();
|
||||
if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) {
|
||||
PostHoverExit();
|
||||
} else {
|
||||
SendExitEvents();
|
||||
}
|
||||
if (!HasEventPending(SEND_TOUCH_INTERACTION_END_MSG)) {
|
||||
PostAccessibilityEvent(SEND_TOUCH_INTERACTION_END_MSG);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::HandleDraggingState(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
switch (event.GetPointerAction()) {
|
||||
case MMI::PointerEvent::POINTER_ACTION_DOWN:
|
||||
HILOG_DEBUG("MMI::PointerEvent::POINTER_ACTION_DOWN");
|
||||
if (event.GetPointerIds().size() == POINTER_COUNT_1) {
|
||||
Clear(event);
|
||||
} else {
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TRANSMITTING);
|
||||
SendAllUpEvents(event);
|
||||
}
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_MOVE:
|
||||
HILOG_DEBUG("MMI::PointerEvent::POINTER_ACTION_MOVE");
|
||||
HandleDraggingStateInnerMove(event);
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
HILOG_DEBUG("MMI::PointerEvent::POINTER_ACTION_UP");
|
||||
if (event.GetPointerIds().size() == POINTER_COUNT_1) {
|
||||
OnTouchInteractionEnd();
|
||||
SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
|
||||
SendEventToMultimodal(event, NO_CHANGE);
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING);
|
||||
} else {
|
||||
SendEventToMultimodal(event, NO_CHANGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::HandleTransmitingState(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
switch (event.GetPointerAction()) {
|
||||
case MMI::PointerEvent::POINTER_ACTION_DOWN:
|
||||
if (event.GetPointerIds().size() == POINTER_COUNT_1) {
|
||||
Clear(event);
|
||||
}
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
if (event.GetPointerIds().size() == POINTER_COUNT_1) {
|
||||
if (longPressPointId_ >= 0) {
|
||||
// Adjust this event's location.
|
||||
MMI::PointerEvent::PointerItem pointer = {};
|
||||
event.GetPointerItem(event.GetPointerId(), pointer);
|
||||
pointer.SetDisplayX(pointer.GetDisplayX() + longPressOffsetX_);
|
||||
pointer.SetDisplayY(pointer.GetDisplayY() + longPressOffsetY_);
|
||||
event.RemovePointerItem(event.GetPointerId());
|
||||
event.AddPointerItem(pointer);
|
||||
longPressPointId_ = INIT_POINT_ID;
|
||||
longPressOffsetX_ = INIT_MMIPOINT;
|
||||
longPressOffsetY_ = INIT_MMIPOINT;
|
||||
}
|
||||
SendEventToMultimodal(event, NO_CHANGE);
|
||||
OnTouchInteractionEnd();
|
||||
SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SendEventToMultimodal(event, NO_CHANGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::Clear(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
if (currentState_ == static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING)) {
|
||||
SendExitEvents();
|
||||
} else if (currentState_ == static_cast<int32_t>(TouchGuideState::DRAGGING) ||
|
||||
currentState_ == static_cast<int32_t>(TouchGuideState::TRANSMITTING)) {
|
||||
SendUpForAllInjectedEvent(event);
|
||||
}
|
||||
|
||||
CancelPostEvent(EXIT_GESTURE_REC_MSG);
|
||||
CancelPostEvent(SEND_TOUCH_INTERACTION_END_MSG);
|
||||
CancelPostEvent(SEND_TOUCH_GUIDE_END_MSG);
|
||||
CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG);
|
||||
CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
|
||||
ClearInjectedEventRecorder();
|
||||
ClearReceivedEventRecorder();
|
||||
pointerEvents_.clear();
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TOUCH_GUIDING);
|
||||
isTouchGuiding_ = false;
|
||||
gestureRecognizer_.Clear();
|
||||
longPressPointId_ = INIT_POINT_ID;
|
||||
longPressOffsetX_ = INIT_MMIPOINT;
|
||||
longPressOffsetY_ = INIT_MMIPOINT;
|
||||
OnTouchInteractionEnd();
|
||||
}
|
||||
|
||||
void MockTouchGuider::Clear()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::shared_ptr<MMI::PointerEvent> event = getLastReceivedEvent();
|
||||
if (event) {
|
||||
Clear(*event);
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::SendExitEvents()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
if (!HasEventPending(SEND_TOUCH_GUIDE_END_MSG)) {
|
||||
PostAccessibilityEvent(SEND_TOUCH_GUIDE_END_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::HandleTouchGuidingStateInnerDown(MMI::PointerEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
}
|
||||
|
||||
void MockTouchGuider::HandleTouchGuidingStateInnerMove(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
switch (event.GetPointerIds().size()) {
|
||||
case POINTER_COUNT_1:
|
||||
HILOG_DEBUG("POINTER_COUNT_1 begin");
|
||||
if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) {
|
||||
pointerEvents_.push_back(event);
|
||||
} else if (isTouchGuiding_) {
|
||||
SendEventToMultimodal(event, HOVER_MOVE);
|
||||
}
|
||||
HILOG_DEBUG("POINTER_COUNT_1 end");
|
||||
break;
|
||||
case POINTER_COUNT_2:
|
||||
HILOG_DEBUG("POINTER_COUNT_2 begin");
|
||||
CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG);
|
||||
CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
|
||||
if (IsDragGestureAccept(event)) {
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::DRAGGING);
|
||||
SendEventToMultimodal(event, POINTER_DOWN);
|
||||
} else {
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TRANSMITTING);
|
||||
}
|
||||
HILOG_DEBUG("POINTER_COUNT_2 end");
|
||||
break;
|
||||
default:
|
||||
HILOG_DEBUG("default begin");
|
||||
if (HasEventPending(SEND_HOVER_ENTER_MOVE_MSG)) {
|
||||
CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG);
|
||||
CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
|
||||
} else {
|
||||
SendExitEvents();
|
||||
}
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TRANSMITTING);
|
||||
HILOG_DEBUG("default end");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::HandleDraggingStateInnerMove(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::vector<int32_t> pIds = event.GetPointerIds();
|
||||
int32_t pointCount = pIds.size();
|
||||
if (pointCount == POINTER_COUNT_1) {
|
||||
HILOG_INFO("Only two pointers can be received in the dragging state");
|
||||
} else if (pointCount == POINTER_COUNT_2 && IsDragGestureAccept(event)) {
|
||||
/* get densityPixels from WMS */
|
||||
AccessibilityDisplayManager& displayMgr = Singleton<AccessibilityDisplayManager>::GetInstance();
|
||||
auto display = displayMgr.GetDefaultDisplay();
|
||||
float densityPixels = display->GetVirtualPixelRatio();
|
||||
int32_t miniZoomPointerDistance = static_cast<int32_t>(MINI_POINTER_DISTANCE_DIP * densityPixels);
|
||||
MMI::PointerEvent::PointerItem pointerF = {};
|
||||
MMI::PointerEvent::PointerItem pointerS = {};
|
||||
event.GetPointerItem(pIds[INDEX_0], pointerF);
|
||||
event.GetPointerItem(pIds[INDEX_1], pointerS);
|
||||
float xPointF = pointerF.GetDisplayX();
|
||||
float xPointS = pointerS.GetDisplayX();
|
||||
float yPointF = pointerF.GetDisplayY();
|
||||
float yPointS = pointerS.GetDisplayY();
|
||||
float offsetX = abs(xPointF - xPointS);
|
||||
float offsetY = abs(yPointF - yPointS);
|
||||
double duration = hypot(offsetX, offsetY);
|
||||
if (duration > miniZoomPointerDistance) {
|
||||
// Adjust this event's location.
|
||||
MMI::PointerEvent::PointerItem pointer = {};
|
||||
event.GetPointerItem(event.GetPointerId(), pointer);
|
||||
pointer.SetDisplayX(pointer.GetDisplayX() + DIVIDE_2(offsetX));
|
||||
pointer.SetDisplayY(pointer.GetDisplayY() + DIVIDE_2(offsetY));
|
||||
event.RemovePointerItem(event.GetPointerId());
|
||||
event.AddPointerItem(pointer);
|
||||
}
|
||||
SendEventToMultimodal(event, NO_CHANGE);
|
||||
} else {
|
||||
currentState_ = static_cast<int32_t>(TouchGuideState::TRANSMITTING);
|
||||
SendAllUpEvents(event);
|
||||
}
|
||||
}
|
||||
|
||||
float MockTouchGuider::GetAngleCos(float offsetX, float offsetY, bool isGetX)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
float ret = isGetX ? offsetX : offsetY;
|
||||
double duration = hypot(offsetX, offsetY);
|
||||
if (duration == 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = ret / duration;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MockTouchGuider::IsDragGestureAccept(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::vector<int32_t> pIds = event.GetPointerIds();
|
||||
MMI::PointerEvent::PointerItem pointerF = {};
|
||||
MMI::PointerEvent::PointerItem pointerS = {};
|
||||
if (!event.GetPointerItem(pIds[0], pointerF)) {
|
||||
HILOG_ERROR("GetPointerItem(%{public}d) failed", pIds[0]);
|
||||
}
|
||||
if (!event.GetPointerItem(pIds[1], pointerS)) {
|
||||
HILOG_ERROR("GetPointerItem(%{public}d) failed", pIds[1]);
|
||||
}
|
||||
|
||||
float xPointF = pointerF.GetDisplayX();
|
||||
float xPointS = pointerS.GetDisplayX();
|
||||
float yPointF = pointerF.GetDisplayY();
|
||||
float yPointS = pointerS.GetDisplayY();
|
||||
float xPointDownF = 0;
|
||||
float xPointDownS = 0;
|
||||
float yPointDownF = 0;
|
||||
float yPointDownS = 0;
|
||||
if (receivedRecorder_.pointerDownX.find(INDEX_0) != receivedRecorder_.pointerDownX.end()) {
|
||||
xPointDownF = receivedRecorder_.pointerDownX.find(INDEX_0)->second;
|
||||
yPointDownF = receivedRecorder_.pointerDownY.find(INDEX_0)->second;
|
||||
}
|
||||
if (receivedRecorder_.pointerDownX.find(INDEX_1) != receivedRecorder_.pointerDownX.end()) {
|
||||
xPointDownS = receivedRecorder_.pointerDownX.find(INDEX_1)->second;
|
||||
yPointDownS = receivedRecorder_.pointerDownY.find(INDEX_1)->second;
|
||||
}
|
||||
|
||||
float firstOffsetX = xPointF - xPointDownF;
|
||||
float firstOffsetY = yPointF - yPointDownF;
|
||||
float secondOffsetX = xPointS - xPointDownS;
|
||||
float secondOffsetY = yPointS - yPointDownS;
|
||||
if ((!firstOffsetX && !firstOffsetY) || (!secondOffsetX && !secondOffsetY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
float firstXCos = GetAngleCos(firstOffsetX, firstOffsetY, true);
|
||||
float firstYCos = GetAngleCos(firstOffsetX, firstOffsetY, false);
|
||||
float secondXCos = GetAngleCos(secondOffsetX, secondOffsetY, true);
|
||||
float secondYCos = GetAngleCos(secondOffsetX, secondOffsetY, false);
|
||||
if ((firstXCos * secondXCos + firstYCos * secondYCos) < MAX_DRAG_GESTURE_COSINE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MockTouchGuider::RecordInjectedEvent(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
int32_t pointerId = event.GetPointerId();
|
||||
switch (event.GetPointerAction()) {
|
||||
case MMI::PointerEvent::POINTER_ACTION_DOWN:
|
||||
injectedRecorder_.downPointerNum++;
|
||||
injectedRecorder_.downPointers.insert(pointerId);
|
||||
injectedRecorder_.lastDownTime = event.GetActionTime() / US_TO_MS;
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
injectedRecorder_.downPointers.erase(pointerId);
|
||||
if (injectedRecorder_.downPointerNum > 0) {
|
||||
injectedRecorder_.downPointerNum--;
|
||||
}
|
||||
if (injectedRecorder_.downPointers.empty()) {
|
||||
injectedRecorder_.lastDownTime = 0;
|
||||
}
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_MOVE:
|
||||
injectedRecorder_.lastHoverEvent = std::make_shared<MMI::PointerEvent>(event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::RecordReceivedEvent(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
int32_t pointId = event.GetPointerId();
|
||||
MMI::PointerEvent::PointerItem pointer;
|
||||
if (!event.GetPointerItem(pointId, pointer)) {
|
||||
HILOG_ERROR("GetPointerItem(%{public}d) failed", pointId);
|
||||
}
|
||||
receivedRecorder_.lastEvent = std::make_shared<MMI::PointerEvent>(event);
|
||||
switch (event.GetPointerAction()) {
|
||||
case MMI::PointerEvent::POINTER_ACTION_DOWN:
|
||||
receivedRecorder_.pointerDownX[pointId] = pointer.GetDisplayX();
|
||||
receivedRecorder_.pointerDownY[pointId] = pointer.GetDisplayY();
|
||||
break;
|
||||
case MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
receivedRecorder_.pointerDownX.erase(pointId);
|
||||
receivedRecorder_.pointerDownY.erase(pointId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::ClearReceivedEventRecorder()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
receivedRecorder_.pointerDownX.clear();
|
||||
receivedRecorder_.pointerDownY.clear();
|
||||
receivedRecorder_.lastEvent = nullptr;
|
||||
}
|
||||
|
||||
void MockTouchGuider::ClearInjectedEventRecorder()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
injectedRecorder_.downPointerNum = 0;
|
||||
injectedRecorder_.downPointers.clear();
|
||||
injectedRecorder_.lastHoverEvent = nullptr;
|
||||
}
|
||||
|
||||
void MockTouchGuider::SendAllDownEvents(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::vector<int32_t> pIds = event.GetPointerIds();
|
||||
for (auto& pId : pIds) {
|
||||
if (injectedRecorder_.downPointers.find(pId) == injectedRecorder_.downPointers.end()) {
|
||||
event.SetPointerId(pId);
|
||||
SendEventToMultimodal(event, POINTER_DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::SendAllUpEvents(MMI::PointerEvent &event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::vector<int32_t> pIds = event.GetPointerIds();
|
||||
for (auto& pId : pIds) {
|
||||
event.SetPointerId(pId);
|
||||
SendEventToMultimodal(event, POINTER_UP);
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::SendUpForAllInjectedEvent(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::vector<int32_t> pIds = event.GetPointerIds();
|
||||
for (const auto& pId : pIds) {
|
||||
if (injectedRecorder_.downPointers.find(pId) == injectedRecorder_.downPointers.end()) {
|
||||
continue;
|
||||
}
|
||||
SendEventToMultimodal(event, POINTER_UP);
|
||||
}
|
||||
}
|
||||
|
||||
void MockTouchGuider::PostGestureRecognizeExit()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
handler_->SendEvent(EXIT_GESTURE_REC_MSG, 0, EXIT_GESTURE_REC_TIMEOUT);
|
||||
}
|
||||
|
||||
void MockTouchGuider::PostHoverEnterAndMove(MMI::PointerEvent& event)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
CancelPostEventIfNeed(SEND_HOVER_ENTER_MOVE_MSG);
|
||||
pointerEvents_.push_back(event);
|
||||
handler_->SendEvent(SEND_HOVER_ENTER_MOVE_MSG, 0, DOUBLE_TAP_TIMEOUT);
|
||||
}
|
||||
|
||||
void MockTouchGuider::PostHoverExit()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
CancelPostEventIfNeed(SEND_HOVER_EXIT_MSG);
|
||||
handler_->SendEvent(SEND_HOVER_EXIT_MSG, 0, DOUBLE_TAP_TIMEOUT);
|
||||
}
|
||||
|
||||
void MockTouchGuider::PostAccessibilityEvent(uint32_t innerEventID)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
handler_->SendEvent(innerEventID, 0, EXIT_GESTURE_REC_TIMEOUT);
|
||||
}
|
||||
|
||||
void MockTouchGuider::CancelPostEvent(uint32_t innerEventID)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
handler_->RemoveEvent(innerEventID);
|
||||
}
|
||||
|
||||
void MockTouchGuider::CancelPostEventIfNeed(uint32_t innerEventID)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
if (HasEventPending(innerEventID)) {
|
||||
handler_->RemoveEvent(innerEventID);
|
||||
if (innerEventID == SEND_HOVER_ENTER_MOVE_MSG) {
|
||||
pointerEvents_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MockTouchGuider::HasEventPending(uint32_t innerEventID)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
return handler_->HasInnerEvent(innerEventID);
|
||||
}
|
||||
|
||||
void MockTouchGuider::ForceSendAndRemoveEvent(uint32_t innerEventID, MMI::PointerEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
HILOG_DEBUG();
|
||||
|
||||
if (!HasEventPending(innerEventID)) {
|
||||
HILOG_DEBUG("No pending event.");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (innerEventID) {
|
||||
case SEND_HOVER_ENTER_MOVE_MSG:
|
||||
SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_BEGIN);
|
||||
if (pointerEvents_.empty()) {
|
||||
break;
|
||||
}
|
||||
for (auto iter = pointerEvents_.begin(); iter != pointerEvents_.end(); ++iter) {
|
||||
SendEventToMultimodal(*iter, HOVER_MOVE);
|
||||
}
|
||||
pointerEvents_.clear();
|
||||
break;
|
||||
case SEND_TOUCH_INTERACTION_END_MSG:
|
||||
SendAccessibilityEventToAA(EventType::TYPE_TOUCH_END);
|
||||
break;
|
||||
case SEND_TOUCH_GUIDE_END_MSG:
|
||||
SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_END);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
CancelPostEvent(innerEventID);
|
||||
}
|
||||
|
||||
void TGEventHandler::HoverEnterAndMoveRunner()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::list<MMI::PointerEvent> motionEvent = tgServer_.getHoverEnterAndMoveEvent();
|
||||
tgServer_.SendAccessibilityEventToAA(EventType::TYPE_TOUCH_GUIDE_BEGIN);
|
||||
if (!motionEvent.empty()) {
|
||||
for (auto iter = motionEvent.begin(); iter != motionEvent.end(); ++iter) {
|
||||
tgServer_.SendEventToMultimodal(*iter, HOVER_MOVE);
|
||||
}
|
||||
}
|
||||
tgServer_.ClearHoverEnterAndMoveEvent();
|
||||
}
|
||||
|
||||
void TGEventHandler::HoverExitRunner()
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
std::shared_ptr<MMI::PointerEvent> pEvent = tgServer_.getLastReceivedEvent();
|
||||
tgServer_.SendEventToMultimodal(*pEvent, HOVER_MOVE);
|
||||
if (!HasInnerEvent(MockTouchGuider::SEND_TOUCH_GUIDE_END_MSG)) {
|
||||
RemoveEvent(MockTouchGuider::SEND_TOUCH_GUIDE_END_MSG);
|
||||
SendEvent(MockTouchGuider::SEND_TOUCH_GUIDE_END_MSG, 0, EXIT_GESTURE_REC_TIMEOUT);
|
||||
}
|
||||
if (HasInnerEvent(MockTouchGuider::SEND_TOUCH_INTERACTION_END_MSG)) {
|
||||
RemoveEvent(MockTouchGuider::SEND_TOUCH_INTERACTION_END_MSG);
|
||||
SendEvent(MockTouchGuider::SEND_TOUCH_INTERACTION_END_MSG, 0, EXIT_GESTURE_REC_TIMEOUT);
|
||||
}
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "accessibility_window_connection.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
MockAccessibilityWindowConnection::MockAccessibilityWindowConnection(
|
||||
const int32_t windowId, const sptr<IAccessibilityElementOperator>& connection, const int32_t accountId)
|
||||
{
|
||||
windowId_ = windowId;
|
||||
proxy_ = connection;
|
||||
accountId_ = accountId;
|
||||
}
|
||||
|
||||
MockAccessibilityWindowConnection::MockAccessibilityWindowConnection(
|
||||
const int32_t windowId, const int32_t treeId,
|
||||
const sptr<IAccessibilityElementOperator>& connection, const int32_t accountId)
|
||||
{
|
||||
windowId_ = windowId;
|
||||
treeId_ = treeId;
|
||||
proxy_ = connection;
|
||||
accountId_ = accountId;
|
||||
}
|
||||
|
||||
MockAccessibilityWindowConnection::~MockAccessibilityWindowConnection()
|
||||
{}
|
||||
|
||||
RetError MockAccessibilityWindowConnection::SetCardProxy(const int32_t treeId,
|
||||
sptr<IAccessibilityElementOperator> operation)
|
||||
{
|
||||
if (!operation) {
|
||||
return RET_ERR_FAILED;
|
||||
}
|
||||
cardProxy_[treeId] = operation;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
sptr<IAccessibilityElementOperator> MockAccessibilityWindowConnection::GetCardProxy(const int32_t treeId)
|
||||
{
|
||||
auto iter = cardProxy_.find(treeId);
|
||||
if (iter != cardProxy_.end()) {
|
||||
HILOG_DEBUG("GetCardProxy : operation is ok");
|
||||
return cardProxy_[treeId];
|
||||
}
|
||||
HILOG_DEBUG("GetCardProxy : operation is no");
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
RetError MockAccessibilityWindowConnection::SetTokenIdMap(const int32_t treeId,
|
||||
const uint32_t tokenId)
|
||||
{
|
||||
HILOG_DEBUG("treeId : %{public}d", treeId);
|
||||
tokenIdMap_[treeId] = tokenId;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
uint32_t MockAccessibilityWindowConnection::GetTokenIdMap(const int32_t treeId)
|
||||
{
|
||||
HILOG_DEBUG("treeId : %{public}d", treeId);
|
||||
return tokenIdMap_[treeId];
|
||||
}
|
||||
|
||||
void MockAccessibilityWindowConnection::GetAllTreeId(std::vector<int32_t> &treeIds)
|
||||
{
|
||||
for (auto &treeId: cardProxy_) {
|
||||
treeIds.emplace_back(treeId.first);
|
||||
}
|
||||
}
|
||||
|
||||
RetError MockAccessibilityWindowConnection::GetRootParentId(int32_t treeId, int64_t &elementId)
|
||||
{
|
||||
auto iter = treeIdParentId_.find(treeId);
|
||||
if (iter != treeIdParentId_.end()) {
|
||||
elementId = iter->second;
|
||||
return RET_OK;
|
||||
}
|
||||
return RET_ERR_FAILED;
|
||||
}
|
||||
|
||||
RetError MockAccessibilityWindowConnection::SetRootParentId(const int32_t treeId, const int64_t elementId)
|
||||
{
|
||||
treeIdParentId_[treeId] = elementId;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void MockAccessibilityWindowConnection::EraseProxy(const int32_t treeId)
|
||||
{
|
||||
auto iter = cardProxy_.find(treeId);
|
||||
if (iter != cardProxy_.end()) {
|
||||
cardProxy_.erase(iter);
|
||||
}
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "accessibility_window_manager.h"
|
||||
#include "accessibility_ut_helper.h"
|
||||
#include "accessible_ability_manager_service.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
namespace {
|
||||
constexpr int32_t TOP_X = 0;
|
||||
constexpr int32_t TOP_Y = 100;
|
||||
constexpr int32_t BOTTOM_X = 800;
|
||||
constexpr int32_t BOTTOM_Y = 400;
|
||||
} // namespace
|
||||
|
||||
AccessibilityWindowManager::AccessibilityWindowManager()
|
||||
{
|
||||
}
|
||||
|
||||
AccessibilityWindowManager::~AccessibilityWindowManager()
|
||||
{
|
||||
}
|
||||
|
||||
bool AccessibilityWindowManager::Init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::DeInit()
|
||||
{
|
||||
a11yWindows_.clear();
|
||||
activeWindowId_ = INVALID_WINDOW_ID;
|
||||
a11yFocusedWindowId_ = INVALID_WINDOW_ID;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::RegisterWindowListener(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
{
|
||||
(void)handler;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::DeregisterWindowListener()
|
||||
{
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::OnWindowUpdate(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos,
|
||||
Rosen::WindowUpdateType type)
|
||||
{
|
||||
HILOG_DEBUG("start");
|
||||
(void)infos;
|
||||
(void)type;
|
||||
}
|
||||
|
||||
int32_t AccessibilityWindowManager::ConvertToRealWindowId(int32_t windowId, int32_t focusType)
|
||||
{
|
||||
(void)windowId;
|
||||
(void)focusType;
|
||||
int32_t realId = AccessibilityAbilityHelper::GetInstance().GetRealId();
|
||||
return realId;
|
||||
}
|
||||
|
||||
AccessibilityWindowType ConvertWindowType(Rosen::WindowType type)
|
||||
{
|
||||
(void)type;
|
||||
AccessibilityWindowType winType = TYPE_WINDOW_INVALID;
|
||||
|
||||
if (type < Rosen::WindowType::SYSTEM_WINDOW_BASE) {
|
||||
winType = TYPE_APPLICATION;
|
||||
} else if ((type >= Rosen::WindowType::SYSTEM_WINDOW_BASE) && (type <= Rosen::WindowType::SYSTEM_WINDOW_END)) {
|
||||
winType = TYPE_SYSTEM;
|
||||
} else {
|
||||
HILOG_ERROR("ConvertWindowType Unknown windowType[%{public}d]", type);
|
||||
}
|
||||
return winType;
|
||||
}
|
||||
|
||||
AccessibilityWindowInfo AccessibilityWindowManager::CreateAccessibilityWindowInfo(
|
||||
const sptr<Rosen::AccessibilityWindowInfo> windowInfo)
|
||||
{
|
||||
(void)windowInfo;
|
||||
AccessibilityWindowInfo info;
|
||||
info.SetWindowId(0);
|
||||
info.SetAccessibilityWindowType(ConvertWindowType(Rosen::WindowType::SYSTEM_WINDOW_BASE));
|
||||
info.SetFocused(true);
|
||||
Rect bound(TOP_X, TOP_Y, BOTTOM_X, BOTTOM_Y);
|
||||
info.SetRectInScreen(bound);
|
||||
return info;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::SetActiveWindow(int32_t windowId, bool isSendEvent)
|
||||
{
|
||||
activeWindowId_ = windowId;
|
||||
(void)isSendEvent;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::SetAccessibilityFocusedWindow(int32_t windowId)
|
||||
{
|
||||
(void)windowId;
|
||||
}
|
||||
|
||||
std::vector<AccessibilityWindowInfo> AccessibilityWindowManager::GetAccessibilityWindows()
|
||||
{
|
||||
std::vector<AccessibilityWindowInfo> windows;
|
||||
return windows;
|
||||
}
|
||||
|
||||
bool AccessibilityWindowManager::GetAccessibilityWindow(int32_t windowId, AccessibilityWindowInfo& window)
|
||||
{
|
||||
HILOG_DEBUG("start windowId(%{public}d)", windowId);
|
||||
if (a11yWindows_.count(windowId)) {
|
||||
window = a11yWindows_[windowId];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AccessibilityWindowManager::IsValidWindow(int32_t windowId)
|
||||
{
|
||||
(void)windowId;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::SetWindowSize(int32_t windowId, Rect rect)
|
||||
{
|
||||
HILOG_DEBUG("SetWindowSize windowId(%{public}d)", windowId);
|
||||
|
||||
auto it = std::find_if(a11yWindows_.begin(), a11yWindows_.end(),
|
||||
[windowId](const std::map<int32_t, AccessibilityWindowInfo>::value_type &window) {
|
||||
return window.first == windowId;
|
||||
});
|
||||
if (it != a11yWindows_.end()) {
|
||||
it->second.SetRectInScreen(rect);
|
||||
}
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::ClearAccessibilityFocused()
|
||||
{
|
||||
}
|
||||
|
||||
int64_t AccessibilityWindowManager::GetSceneBoardElementId(const int32_t windowId, const int64_t elementId)
|
||||
{
|
||||
return elementId;
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::GetRealWindowAndElementId(int32_t& windowId, int64_t& elementId)
|
||||
{
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::GetSceneBoardInnerWinId(int32_t windowId, int64_t elementId,
|
||||
int32_t& innerWid)
|
||||
{
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::SceneBoardElementIdMap::InsertPair(const int32_t windowId, const int64_t elementId)
|
||||
{
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::SceneBoardElementIdMap::RemovePair(const int32_t windowId)
|
||||
{
|
||||
}
|
||||
|
||||
void AccessibilityWindowManager::SceneBoardElementIdMap::Clear()
|
||||
{
|
||||
}
|
||||
|
||||
std::map<int32_t, int64_t> AccessibilityWindowManager::SceneBoardElementIdMap::GetAllPairs()
|
||||
{
|
||||
return std::map<int32_t, int64_t>();
|
||||
}
|
||||
|
||||
RetError AccessibilityWindowManager::GetFocusedWindowId(int32_t &focusedWindowId)
|
||||
{
|
||||
focusedWindowId = 1;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
bool AccessibilityWindowManager::IsInnerWindowRootElement(int64_t elementId)
|
||||
{
|
||||
(void)elementId;
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t AccessibilityWindowManager::GetActiveWindowId()
|
||||
{
|
||||
return activeWindowId_;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "accessibility_element_info.h"
|
||||
#include "accessible_ability_channel_proxy.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
AccessibleAbilityChannelProxy::AccessibleAbilityChannelProxy(const sptr<IRemoteObject>& object)
|
||||
: IRemoteProxy<IAccessibleAbilityChannel>(object)
|
||||
{}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::WriteInterfaceToken(MessageParcel& data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccessibleAbilityChannelProxy::SendTransactCmd(
|
||||
AccessibilityInterfaceCode code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
|
||||
{
|
||||
(void)code;
|
||||
(void)data;
|
||||
(void)reply;
|
||||
(void)option;
|
||||
return true;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::SearchElementInfoByAccessibilityId(const ElementBasicInfo elementBasicInfo,
|
||||
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback,
|
||||
const int32_t mode, bool isFilter)
|
||||
{
|
||||
(void)elementBasicInfo;
|
||||
(void)requestId;
|
||||
(void)callback;
|
||||
(void)mode;
|
||||
(void)isFilter;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::SearchElementInfosByText(const int32_t accessibilityWindowId,
|
||||
const int64_t elementId, const std::string& text, const int32_t requestId,
|
||||
const sptr<IAccessibilityElementOperatorCallback>& callback)
|
||||
{
|
||||
(void)accessibilityWindowId;
|
||||
(void)elementId;
|
||||
(void)requestId;
|
||||
(void)callback;
|
||||
(void)text;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::FindFocusedElementInfo(const int32_t accessibilityWindowId,
|
||||
const int64_t elementId, const int32_t focusType, const int32_t requestId,
|
||||
const sptr<IAccessibilityElementOperatorCallback>& callback)
|
||||
{
|
||||
(void)accessibilityWindowId;
|
||||
(void)elementId;
|
||||
(void)requestId;
|
||||
(void)callback;
|
||||
(void)focusType;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::FocusMoveSearch(const int32_t accessibilityWindowId, const int64_t elementId,
|
||||
const int32_t direction, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
|
||||
{
|
||||
(void)accessibilityWindowId;
|
||||
(void)elementId;
|
||||
(void)requestId;
|
||||
(void)callback;
|
||||
(void)direction;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::EnableScreenCurtain(bool isEnable)
|
||||
{
|
||||
(void)isEnable;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::ExecuteAction(const int32_t accessibilityWindowId, const int64_t elementId,
|
||||
const int32_t action, const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
|
||||
const sptr<IAccessibilityElementOperatorCallback>& callback)
|
||||
{
|
||||
(void)accessibilityWindowId;
|
||||
(void)elementId;
|
||||
(void)requestId;
|
||||
(void)callback;
|
||||
(void)actionArguments;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::GetCursorPosition(const int32_t accessibilityWindowId, const int64_t elementId,
|
||||
const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
|
||||
{
|
||||
(void)accessibilityWindowId;
|
||||
(void)elementId;
|
||||
(void)requestId;
|
||||
(void)callback;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo)
|
||||
{
|
||||
(void)windowId;
|
||||
(void)windowInfo;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::GetWindows(std::vector<AccessibilityWindowInfo> &windows)
|
||||
{
|
||||
(void)windows;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::GetWindowsByDisplayId(const uint64_t displayId,
|
||||
std::vector<AccessibilityWindowInfo> &windows)
|
||||
{
|
||||
(void)displayId;
|
||||
(void)windows;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void AccessibleAbilityChannelProxy::SetOnKeyPressEventResult(const bool handled, const int32_t sequence)
|
||||
{
|
||||
(void)handled;
|
||||
(void)sequence;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::SendSimulateGesture(
|
||||
const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath)
|
||||
{
|
||||
(void)gesturePath;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
RetError AccessibleAbilityChannelProxy::SetTargetBundleName(const std::vector<std::string> &targetBundleNames)
|
||||
{
|
||||
(void)targetBundleNames;
|
||||
return RET_OK;
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "accessibility_account_data.h"
|
||||
#include "accessibility_event_info.h"
|
||||
#include "accessibility_ut_helper.h"
|
||||
#include "accessible_ability_channel_stub.h"
|
||||
#include "accessible_ability_client_proxy.h"
|
||||
#include "accessible_ability_connection.h"
|
||||
#include "accessible_ability_manager_service.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
MockAccessibleAbilityClientProxy::MockAccessibleAbilityClientProxy(const sptr<IRemoteObject>& object)
|
||||
: IRemoteProxy<IAccessibleAbilityClient>(object)
|
||||
{
|
||||
}
|
||||
|
||||
bool MockAccessibleAbilityClientProxy::WriteInterfaceToken(MessageParcel& data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MockAccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel>& channel, const int32_t channelId)
|
||||
{
|
||||
(void)channel;
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestChannelId(channelId);
|
||||
}
|
||||
|
||||
void MockAccessibleAbilityClientProxy::Disconnect(const int32_t channelId)
|
||||
{
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestChannelId(channelId);
|
||||
}
|
||||
|
||||
void MockAccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnTouchEvent OnAccessibilityEvent";
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestEventType(int(eventInfo.GetEventType()));
|
||||
AccessibilityAbilityHelper::GetInstance().SetGestureId(int(eventInfo.GetGestureType()));
|
||||
|
||||
AccessibilityAbilityHelper::GetInstance().SetEventTypeVector(eventInfo.GetEventType());
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientProxy::OnAccessibilityEvent eventType="
|
||||
<< (int32_t)eventInfo.GetEventType();
|
||||
}
|
||||
|
||||
void MockAccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent& keyEvent, const int32_t sequence)
|
||||
{
|
||||
(void)keyEvent;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
HILOG_DEBUG();
|
||||
HILOG_DEBUG("start.-----sequence--%{public}d ----------mock Proxy Start ", sequence);
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestKeyPressEvent(sequence);
|
||||
HILOG_DEBUG("start.-----------------------------mock Proxy end ");
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "mock_accessible_ability_client_stub_impl.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include "accessibility_ut_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Accessibility {
|
||||
MockAccessibleAbilityClientStubImpl::MockAccessibleAbilityClientStubImpl()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl MockAccessibleAbilityClientStubImpl()";
|
||||
}
|
||||
MockAccessibleAbilityClientStubImpl::~MockAccessibleAbilityClientStubImpl()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl ~MockAccessibleAbilityClientStubImpl()";
|
||||
}
|
||||
int MockAccessibleAbilityClientStubImpl::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
|
||||
{
|
||||
(void)code;
|
||||
(void)data;
|
||||
(void)reply;
|
||||
(void)option;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl OnRemoteRequest";
|
||||
return 0;
|
||||
}
|
||||
|
||||
ErrCode MockAccessibleAbilityClientStubImpl::HandleInit(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
(void)data;
|
||||
(void)reply;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl HandleInit";
|
||||
return 0;
|
||||
}
|
||||
ErrCode MockAccessibleAbilityClientStubImpl::HandleDisconnect(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
(void)data;
|
||||
(void)reply;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl HandleDisconnect";
|
||||
return 0;
|
||||
}
|
||||
ErrCode MockAccessibleAbilityClientStubImpl::HandleOnAccessibilityEvent(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
(void)data;
|
||||
(void)reply;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl HandleOnAccessibilityEvent";
|
||||
return 0;
|
||||
}
|
||||
ErrCode MockAccessibleAbilityClientStubImpl::HandleOnKeyPressEvent(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
(void)data;
|
||||
(void)reply;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl HandleOnKeyPressEvent";
|
||||
return 0;
|
||||
}
|
||||
void MockAccessibleAbilityClientStubImpl::Init(const sptr<IAccessibleAbilityChannel>& channel, const int32_t channelId)
|
||||
{
|
||||
(void)channel;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl Init";
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestChannelId(channelId);
|
||||
}
|
||||
void MockAccessibleAbilityClientStubImpl::Disconnect(const int32_t channelId)
|
||||
{
|
||||
(void)channelId;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl Disconnect";
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestChannelId(INVALID_CHANNEL_ID);
|
||||
}
|
||||
void MockAccessibleAbilityClientStubImpl::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl OnAccessibilityEvent";
|
||||
AccessibilityAbilityHelper::GetInstance().SetTestEventType(int32_t(eventInfo.GetEventType()));
|
||||
}
|
||||
void MockAccessibleAbilityClientStubImpl::OnKeyPressEvent(const MMI::KeyEvent& keyEvent, const int32_t sequence)
|
||||
{
|
||||
(void)keyEvent;
|
||||
(void)sequence;
|
||||
GTEST_LOG_(INFO) << "MockAccessibleAbilityClientStubImpl OnKeyPressEvent";
|
||||
}
|
||||
} // namespace Accessibility
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user