mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 23:21:05 +00:00
OnAccessibilityHover TDD
Signed-off-by: zhouchaobo <zhouchaobo@huawei.com> Change-Id: I0250b06901b68c667e0e83cb5ca24f18f8ac1326
This commit is contained in:
parent
fb843a3197
commit
7a29bc5b1f
@ -72,7 +72,10 @@ ace_unittest("gesture_event_hub_test_ng") {
|
||||
ace_unittest("input_event_hub_test_ng") {
|
||||
type = "new"
|
||||
module_output = "events"
|
||||
sources = [ "input_event_hub_test_ng.cpp" ]
|
||||
sources = [
|
||||
"$ace_root/frameworks/core/event/mouse_event.cpp",
|
||||
"input_event_hub_test_ng.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
ace_unittest("long_press_event_test_ng") {
|
||||
|
@ -1311,4 +1311,55 @@ HWTEST_F(EventManagerTestNg, EventManagerTest072, TestSize.Level1)
|
||||
auto pageNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, pagePattern);
|
||||
EXPECT_FALSE(eventManager->IsSkipEventNode(pageNode));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: EventManagerAccessibilityHoverTest001
|
||||
* @tc.desc: Test MouseTest (frameNode)
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(EventManagerTestNg, EventManagerAccessibilityHoverTest001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create EventManager.
|
||||
* @tc.expected: eventManager is not null.
|
||||
*/
|
||||
auto eventManager = AceType::MakeRefPtr<EventManager>();
|
||||
ASSERT_NE(eventManager, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. Call MouseTest with MouseAction::WINDOW_LEAVE
|
||||
* @tc.expected: currHoverTestResults_ is empty
|
||||
*/
|
||||
TouchEvent event;
|
||||
const int nodeId = 10008;
|
||||
auto frameNode = FrameNode::GetOrCreateFrameNode(V2::LOCATION_BUTTON_ETS_TAG, nodeId, nullptr);
|
||||
TouchRestrict touchRestrict;
|
||||
|
||||
event.type = TouchType::HOVER_EXIT;
|
||||
auto hoverEventTarget = AceType::MakeRefPtr<HoverEventTarget>(V2::LOCATION_BUTTON_ETS_TAG, nodeId);
|
||||
eventManager->curAccessibilityHoverResults_.push_back(hoverEventTarget);
|
||||
ASSERT_FALSE(eventManager->curAccessibilityHoverResults_.empty());
|
||||
eventManager->AccessibilityHoverTest(event, frameNode, touchRestrict);
|
||||
ASSERT_TRUE(eventManager->curAccessibilityHoverResults_.empty());
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. Call MouseTest with MouseAction::WINDOW_ENTER
|
||||
* @tc.expected: lastHoverTestResults_ is empty
|
||||
*/
|
||||
event.type = TouchType::HOVER_ENTER;
|
||||
eventManager->lastAccessibilityHoverResults_.push_back(hoverEventTarget);
|
||||
ASSERT_FALSE(eventManager->lastAccessibilityHoverResults_.empty());
|
||||
eventManager->AccessibilityHoverTest(event, frameNode, touchRestrict);
|
||||
ASSERT_TRUE(eventManager->lastAccessibilityHoverResults_.empty());
|
||||
|
||||
/**
|
||||
* @tc.steps: step4. Call MouseTest with MouseAction::HOVER
|
||||
* @tc.expected: lastHoverTestResults_ is empty and currHoverTestResults_ is empty
|
||||
*/
|
||||
event.type = TouchType::HOVER_MOVE;
|
||||
eventManager->lastAccessibilityHoverResults_.push_back(hoverEventTarget);
|
||||
eventManager->AccessibilityHoverTest(event, frameNode, touchRestrict);
|
||||
ASSERT_TRUE(eventManager->lastAccessibilityHoverResults_.empty());
|
||||
ASSERT_TRUE(eventManager->curAccessibilityHoverResults_.empty());
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
@ -42,6 +42,7 @@ const OffsetF COORDINATE_OFFSET(WIDTH, HEIGHT);
|
||||
constexpr bool HOVER_VALUE = true;
|
||||
const std::string RESULT_SUCCESS_ONE = "sucess1";
|
||||
const std::string RESULT_SUCCESS_TWO = "sucess2";
|
||||
bool accessibilityHover = false;
|
||||
} // namespace
|
||||
|
||||
class InputEventHubTestNg : public testing::Test {
|
||||
@ -421,6 +422,50 @@ HWTEST_F(InputEventHubTestNg, InputEventHubBindContextMenuTest007, TestSize.Leve
|
||||
EXPECT_NE(inputEventHub->mouseEventActuator_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InputEventHubProcessMouseTest008
|
||||
* @tc.desc: Create InputEventHub and invoke ProcessMouseTestHit functions.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(InputEventHubTestNg, InputEventHubProcessMouseTest008, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create InputEventHub.
|
||||
*/
|
||||
auto eventHub = AceType::MakeRefPtr<EventHub>();
|
||||
auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<Pattern>());
|
||||
eventHub->AttachHost(frameNode);
|
||||
auto inputEventHub = AceType::MakeRefPtr<InputEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
|
||||
EXPECT_NE(inputEventHub, nullptr);
|
||||
TouchTestResult mouseResult;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. Set HoverEvent and hoverEventActuator_ and userCallback_ will be initialized.
|
||||
*/
|
||||
const OnAccessibilityHoverFunc onHover = [](bool, AccessibilityHoverInfo) { accessibilityHover = true; };
|
||||
OnAccessibilityHoverFunc onHover1 = onHover;
|
||||
inputEventHub->SetAccessibilityHoverEvent(std::move(onHover1));
|
||||
EXPECT_NE(inputEventHub->accessibilityHoverEventActuator_->userCallback_, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. Invoke ProcessMouseTestHit when the userCallback_ has already been
|
||||
* initialized.
|
||||
* @tc.expected: ProcessMouseTestHit return false, mouse and hover result size has been increased one.
|
||||
*/
|
||||
EXPECT_FALSE(inputEventHub->ProcessMouseTestHit(COORDINATE_OFFSET, mouseResult));
|
||||
EXPECT_EQ(inputEventHub->accessibilityHoverEventActuator_->accessibilityHoverEventTarget_->GetCoordinateOffset(),
|
||||
Offset(COORDINATE_OFFSET.GetX(), COORDINATE_OFFSET.GetY()));
|
||||
EXPECT_EQ(mouseResult.size(), INPUT_EVENTS_SIZE);
|
||||
|
||||
/**
|
||||
* @tc.steps: step11. Handle mouse and hover event when the events and userCallback is nullptr or not.
|
||||
*/
|
||||
TouchEvent event;
|
||||
inputEventHub->accessibilityHoverEventActuator_->accessibilityHoverEventTarget_->HandleAccessibilityHoverEvent(
|
||||
HOVER_VALUE, event);
|
||||
EXPECT_EQ(accessibilityHover, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DisableMouseEvent001
|
||||
* @tc.desc: Test disable mouse event.
|
||||
|
Loading…
Reference in New Issue
Block a user