mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 23:21:05 +00:00
配置group 为true的节点 的子节点如果level为yes,也可被hover 搜索到
Signed-off-by: zhanghangkai@huawei.com <zhanghangkai@huawei.com> Change-Id: Ieaef8d6666616b58252469fa91883e57e7552f67
This commit is contained in:
parent
f49cb2bf04
commit
ce3e6bfe32
@ -117,12 +117,37 @@ AccessibilityHoverTestPath AccessibilityProperty::HoverTest(
|
|||||||
AccessibilityHoverTestPath path;
|
AccessibilityHoverTestPath path;
|
||||||
CHECK_NULL_RETURN(root, path);
|
CHECK_NULL_RETURN(root, path);
|
||||||
ACE_SCOPED_TRACE("AccessibilityHoverTest");
|
ACE_SCOPED_TRACE("AccessibilityHoverTest");
|
||||||
AccessibilityProperty::HoverTestRecursive(point, root, path, debugInfo);
|
bool ancestorGroupFlag = false;
|
||||||
|
auto accessibilityProperty = root->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
||||||
|
if (accessibilityProperty != nullptr) {
|
||||||
|
ancestorGroupFlag = accessibilityProperty->IsAccessibilityGroup();
|
||||||
|
}
|
||||||
|
AccessibilityProperty::HoverTestRecursive(point, root, path, debugInfo, ancestorGroupFlag);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetHitTestModeStr(HitTestMode hitTestMode, std::string& testModeStr)
|
||||||
|
{
|
||||||
|
switch (hitTestMode) {
|
||||||
|
case HitTestMode::HTMDEFAULT:
|
||||||
|
testModeStr = "Default";
|
||||||
|
break;
|
||||||
|
case HitTestMode::HTMBLOCK:
|
||||||
|
testModeStr = "Block";
|
||||||
|
break;
|
||||||
|
case HitTestMode::HTMTRANSPARENT:
|
||||||
|
testModeStr = "Transparent";
|
||||||
|
break;
|
||||||
|
case HitTestMode::HTMNONE:
|
||||||
|
testModeStr = "None";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
testModeStr = "Unsupported";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<JsonValue> AccessibilityProperty::CreateNodeSearchInfo(const RefPtr<FrameNode>& node,
|
std::unique_ptr<JsonValue> AccessibilityProperty::CreateNodeSearchInfo(const RefPtr<FrameNode>& node,
|
||||||
const PointF& parentPoint)
|
const PointF& parentPoint, bool& ancestorGroupFlag)
|
||||||
{
|
{
|
||||||
auto nodeInfo = JsonUtil::Create();
|
auto nodeInfo = JsonUtil::Create();
|
||||||
nodeInfo->Put("id", node->GetAccessibilityId());
|
nodeInfo->Put("id", node->GetAccessibilityId());
|
||||||
@ -131,9 +156,11 @@ std::unique_ptr<JsonValue> AccessibilityProperty::CreateNodeSearchInfo(const Ref
|
|||||||
nodeInfo->Put("parent", node->GetParent()->GetAccessibilityId());
|
nodeInfo->Put("parent", node->GetParent()->GetAccessibilityId());
|
||||||
}
|
}
|
||||||
nodeInfo->Put("visible", node->IsVisible());
|
nodeInfo->Put("visible", node->IsVisible());
|
||||||
auto [shouldSearchSelf, shouldSearchChildren] = AccessibilityProperty::GetSearchStrategy(node);
|
auto [shouldSearchSelf, shouldSearchChildren, groupFlag]
|
||||||
|
= AccessibilityProperty::GetSearchStrategy(node, ancestorGroupFlag);
|
||||||
nodeInfo->Put("shouldSearchSelf", shouldSearchSelf);
|
nodeInfo->Put("shouldSearchSelf", shouldSearchSelf);
|
||||||
nodeInfo->Put("shouldSearchChildren", shouldSearchChildren);
|
nodeInfo->Put("shouldSearchChildren", shouldSearchChildren);
|
||||||
|
nodeInfo->Put("currentGroup", groupFlag);
|
||||||
|
|
||||||
auto renderContext = node->GetRenderContext();
|
auto renderContext = node->GetRenderContext();
|
||||||
auto rect = renderContext->GetPaintRectWithoutTransform();
|
auto rect = renderContext->GetPaintRectWithoutTransform();
|
||||||
@ -158,28 +185,14 @@ std::unique_ptr<JsonValue> AccessibilityProperty::CreateNodeSearchInfo(const Ref
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string testModeStr = "";
|
std::string testModeStr = "";
|
||||||
switch (node->GetHitTestMode()) {
|
GetHitTestModeStr(node->GetHitTestMode(), testModeStr);
|
||||||
case HitTestMode::HTMDEFAULT:
|
|
||||||
testModeStr = "Default";
|
|
||||||
break;
|
|
||||||
case HitTestMode::HTMBLOCK:
|
|
||||||
testModeStr = "Block";
|
|
||||||
break;
|
|
||||||
case HitTestMode::HTMTRANSPARENT:
|
|
||||||
testModeStr = "Transparent";
|
|
||||||
break;
|
|
||||||
case HitTestMode::HTMNONE:
|
|
||||||
testModeStr = "None";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
testModeStr = "Unsupported";
|
|
||||||
}
|
|
||||||
nodeInfo->Put("hitTestMode", testModeStr.c_str());
|
nodeInfo->Put("hitTestMode", testModeStr.c_str());
|
||||||
return nodeInfo;
|
return nodeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AccessibilityProperty::ProcessHoverTestRecursive(const PointF& noOffsetPoint, const RefPtr<FrameNode>& node,
|
bool AccessibilityProperty::ProcessHoverTestRecursive(const PointF& noOffsetPoint, const RefPtr<FrameNode>& node,
|
||||||
AccessibilityHoverTestPath& path, std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo, bool hitTarget)
|
AccessibilityHoverTestPath& path, std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo,
|
||||||
|
RecursiveParam recursiveParam)
|
||||||
{
|
{
|
||||||
auto property = node->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
auto property = node->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
||||||
auto virtualNode = property->GetAccessibilityVirtualNode();
|
auto virtualNode = property->GetAccessibilityVirtualNode();
|
||||||
@ -187,7 +200,8 @@ bool AccessibilityProperty::ProcessHoverTestRecursive(const PointF& noOffsetPoin
|
|||||||
auto frameNode = AceType::DynamicCast<FrameNode>(virtualNode);
|
auto frameNode = AceType::DynamicCast<FrameNode>(virtualNode);
|
||||||
CHECK_NULL_RETURN(frameNode, false);
|
CHECK_NULL_RETURN(frameNode, false);
|
||||||
|
|
||||||
if (AccessibilityProperty::HoverTestRecursive(noOffsetPoint, frameNode, path, debugInfo)) {
|
if (AccessibilityProperty::HoverTestRecursive(noOffsetPoint, frameNode, path, debugInfo,
|
||||||
|
recursiveParam.ancestorGroupFlag)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -197,19 +211,21 @@ bool AccessibilityProperty::ProcessHoverTestRecursive(const PointF& noOffsetPoin
|
|||||||
if (child == nullptr) {
|
if (child == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (AccessibilityProperty::HoverTestRecursive(noOffsetPoint, child, path, debugInfo)) {
|
if (AccessibilityProperty::HoverTestRecursive(noOffsetPoint, child, path, debugInfo,
|
||||||
|
recursiveParam.ancestorGroupFlag)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hitTarget;
|
return recursiveParam.hitTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AccessibilityProperty::HoverTestRecursive(
|
bool AccessibilityProperty::HoverTestRecursive(
|
||||||
const PointF& parentPoint,
|
const PointF& parentPoint,
|
||||||
const RefPtr<FrameNode>& node,
|
const RefPtr<FrameNode>& node,
|
||||||
AccessibilityHoverTestPath& path,
|
AccessibilityHoverTestPath& path,
|
||||||
std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo)
|
std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo,
|
||||||
|
bool& ancestorGroupFlag)
|
||||||
{
|
{
|
||||||
if (!node->IsAccessibilityVirtualNode()) {
|
if (!node->IsAccessibilityVirtualNode()) {
|
||||||
if (!node->IsActive() || node->IsInternal()) {
|
if (!node->IsActive() || node->IsInternal()) {
|
||||||
@ -217,7 +233,7 @@ bool AccessibilityProperty::HoverTestRecursive(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debugInfo != nullptr) {
|
if (debugInfo != nullptr) {
|
||||||
auto nodeInfo = CreateNodeSearchInfo(node, parentPoint);
|
auto nodeInfo = CreateNodeSearchInfo(node, parentPoint, ancestorGroupFlag);
|
||||||
debugInfo->trace.push_back(std::move(nodeInfo));
|
debugInfo->trace.push_back(std::move(nodeInfo));
|
||||||
}
|
}
|
||||||
bool hitTarget = false;
|
bool hitTarget = false;
|
||||||
@ -225,7 +241,8 @@ bool AccessibilityProperty::HoverTestRecursive(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto [shouldSearchSelf, shouldSearchChildren] = AccessibilityProperty::GetSearchStrategy(node);
|
auto [shouldSearchSelf, shouldSearchChildren, currentGroupFlag]
|
||||||
|
= AccessibilityProperty::GetSearchStrategy(node, ancestorGroupFlag);
|
||||||
|
|
||||||
auto renderContext = node->GetRenderContext();
|
auto renderContext = node->GetRenderContext();
|
||||||
auto rect = renderContext->GetPaintRectWithoutTransform();
|
auto rect = renderContext->GetPaintRectWithoutTransform();
|
||||||
@ -243,7 +260,10 @@ bool AccessibilityProperty::HoverTestRecursive(
|
|||||||
|
|
||||||
if (shouldSearchChildren) {
|
if (shouldSearchChildren) {
|
||||||
PointF noOffsetPoint = selfPoint - rect.GetOffset();
|
PointF noOffsetPoint = selfPoint - rect.GetOffset();
|
||||||
return ProcessHoverTestRecursive(noOffsetPoint, node, path, debugInfo, hitTarget);
|
RecursiveParam recursiveParam;
|
||||||
|
recursiveParam.hitTarget = hitTarget;
|
||||||
|
recursiveParam.ancestorGroupFlag = currentGroupFlag;
|
||||||
|
return ProcessHoverTestRecursive(noOffsetPoint, node, path, debugInfo, recursiveParam);
|
||||||
}
|
}
|
||||||
return hitTarget;
|
return hitTarget;
|
||||||
}
|
}
|
||||||
@ -264,20 +284,20 @@ void UpdateSearchStrategyByHitTestMode(HitTestMode hitTestMode, bool& shouldSear
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, bool> AccessibilityProperty::GetSearchStrategy(const RefPtr<FrameNode>& node)
|
std::tuple<bool, bool, bool> AccessibilityProperty::GetSearchStrategy(const RefPtr<FrameNode>& node,
|
||||||
|
bool& ancestorGroupFlag)
|
||||||
{
|
{
|
||||||
bool shouldSearchSelf = true;
|
bool shouldSearchSelf = true;
|
||||||
bool shouldSearchChildren = true;
|
bool shouldSearchChildren = true;
|
||||||
|
bool currentGroupFlag = false;
|
||||||
|
auto level = AccessibilityProperty::Level::AUTO;
|
||||||
do {
|
do {
|
||||||
auto accessibilityProperty = node->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
auto accessibilityProperty = node->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
||||||
if (accessibilityProperty != nullptr) {
|
if (accessibilityProperty != nullptr) {
|
||||||
auto level = accessibilityProperty->GetAccessibilityLevel();
|
level = accessibilityProperty->GetAccessibilityLevel();
|
||||||
bool hasGroupOrVirtualNode = accessibilityProperty->IsAccessibilityGroup();
|
currentGroupFlag = accessibilityProperty->IsAccessibilityGroup();
|
||||||
bool hasAccessibilityText = accessibilityProperty->HasAccessibilityTextOrDescription();
|
bool hasAccessibilityText = accessibilityProperty->HasAccessibilityTextOrDescription();
|
||||||
if (level == AccessibilityProperty::Level::YES) {
|
if (level == AccessibilityProperty::Level::YES) {
|
||||||
if (hasGroupOrVirtualNode) {
|
|
||||||
shouldSearchChildren = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
} else if (level == AccessibilityProperty::Level::NO_HIDE_DESCENDANTS) {
|
} else if (level == AccessibilityProperty::Level::NO_HIDE_DESCENDANTS) {
|
||||||
shouldSearchSelf = false;
|
shouldSearchSelf = false;
|
||||||
@ -288,10 +308,6 @@ std::pair<bool, bool> AccessibilityProperty::GetSearchStrategy(const RefPtr<Fram
|
|||||||
shouldSearchSelf = false;
|
shouldSearchSelf = false;
|
||||||
} else {
|
} else {
|
||||||
// shouldSearchSelf is true here
|
// shouldSearchSelf is true here
|
||||||
if (hasGroupOrVirtualNode) {
|
|
||||||
shouldSearchChildren = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (hasAccessibilityText) {
|
if (hasAccessibilityText) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -310,7 +326,15 @@ std::pair<bool, bool> AccessibilityProperty::GetSearchStrategy(const RefPtr<Fram
|
|||||||
shouldSearchChildren = true;
|
shouldSearchChildren = true;
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
return std::make_pair(shouldSearchSelf, shouldSearchChildren);
|
|
||||||
|
if (ancestorGroupFlag == true) {
|
||||||
|
if (level != AccessibilityProperty::Level::YES) {
|
||||||
|
shouldSearchSelf = false;
|
||||||
|
}
|
||||||
|
currentGroupFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_tuple(shouldSearchSelf, shouldSearchChildren, currentGroupFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::set<std::string> TAGS_FOCUSABLE = {
|
static const std::set<std::string> TAGS_FOCUSABLE = {
|
||||||
|
@ -652,13 +652,21 @@ private:
|
|||||||
const PointF& parentPoint,
|
const PointF& parentPoint,
|
||||||
const RefPtr<FrameNode>& node,
|
const RefPtr<FrameNode>& node,
|
||||||
AccessibilityHoverTestPath& path,
|
AccessibilityHoverTestPath& path,
|
||||||
std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo
|
std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo,
|
||||||
|
bool& ancestorGroupFlag
|
||||||
);
|
);
|
||||||
|
|
||||||
static bool ProcessHoverTestRecursive(const PointF& noOffsetPoint, const RefPtr<FrameNode>& node,
|
struct RecursiveParam {
|
||||||
AccessibilityHoverTestPath& path, std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo, bool hitTarget);
|
bool hitTarget;
|
||||||
|
bool ancestorGroupFlag;
|
||||||
|
};
|
||||||
|
|
||||||
static std::unique_ptr<JsonValue> CreateNodeSearchInfo(const RefPtr<FrameNode>& node, const PointF& parentPoint);
|
static bool ProcessHoverTestRecursive(const PointF& noOffsetPoint, const RefPtr<FrameNode>& node,
|
||||||
|
AccessibilityHoverTestPath& path, std::unique_ptr<HoverTestDebugTraceInfo>& debugInfo,
|
||||||
|
RecursiveParam recursiveParam);
|
||||||
|
|
||||||
|
static std::unique_ptr<JsonValue> CreateNodeSearchInfo(const RefPtr<FrameNode>& node, const PointF& parentPoint,
|
||||||
|
bool& ancestorGroupFlag);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get whether node and its children should be searched.
|
* Get whether node and its children should be searched.
|
||||||
@ -666,7 +674,7 @@ private:
|
|||||||
* second: children of node should be searched.
|
* second: children of node should be searched.
|
||||||
* param: {node} should be not-null
|
* param: {node} should be not-null
|
||||||
*/
|
*/
|
||||||
static std::pair<bool, bool> GetSearchStrategy(const RefPtr<FrameNode>& node);
|
static std::tuple<bool, bool, bool> GetSearchStrategy(const RefPtr<FrameNode>& node, bool& ancestorGroupFlag);
|
||||||
|
|
||||||
void GetGroupTextRecursive(bool forceGetChildren, std::string& text) const;
|
void GetGroupTextRecursive(bool forceGetChildren, std::string& text) const;
|
||||||
|
|
||||||
|
@ -437,17 +437,18 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest009, TestSize.Lev
|
|||||||
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest010, TestSize.Level1)
|
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest010, TestSize.Level1)
|
||||||
{
|
{
|
||||||
AccessibilityProperty accessibilityProperty;
|
AccessibilityProperty accessibilityProperty;
|
||||||
|
bool ancestorGroupFlag = false;
|
||||||
auto root = FrameNode::CreateFrameNode(
|
auto root = FrameNode::CreateFrameNode(
|
||||||
V2::BUTTON_ETS_TAG, 12, AceType::MakeRefPtr<Pattern>(), true);
|
V2::BUTTON_ETS_TAG, 12, AceType::MakeRefPtr<Pattern>(), true);
|
||||||
NG::PointF hoverPoint(0, 0);
|
NG::PointF hoverPoint(0, 0);
|
||||||
auto result = accessibilityProperty.CreateNodeSearchInfo(root, hoverPoint);
|
auto result = accessibilityProperty.CreateNodeSearchInfo(root, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(root->IsRootNode());
|
EXPECT_TRUE(root->IsRootNode());
|
||||||
|
|
||||||
auto subNode = FrameNode::GetOrCreateFrameNode(
|
auto subNode = FrameNode::GetOrCreateFrameNode(
|
||||||
V2::BUTTON_ETS_TAG, 1, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 1, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
root->AddChild(subNode);
|
root->AddChild(subNode);
|
||||||
EXPECT_FALSE(subNode->IsRootNode());
|
EXPECT_FALSE(subNode->IsRootNode());
|
||||||
result = accessibilityProperty.CreateNodeSearchInfo(subNode, hoverPoint);
|
result = accessibilityProperty.CreateNodeSearchInfo(subNode, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(result->Contains("parent"));
|
EXPECT_TRUE(result->Contains("parent"));
|
||||||
EXPECT_TRUE(result->Contains("visible"));
|
EXPECT_TRUE(result->Contains("visible"));
|
||||||
|
|
||||||
@ -456,7 +457,7 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest010, TestSize.Lev
|
|||||||
EXPECT_TRUE(result->Contains("accessibilityLevel"));
|
EXPECT_TRUE(result->Contains("accessibilityLevel"));
|
||||||
|
|
||||||
root->SetHitTestMode(HitTestMode::HTMDEFAULT);
|
root->SetHitTestMode(HitTestMode::HTMDEFAULT);
|
||||||
result = accessibilityProperty.CreateNodeSearchInfo(subNode, hoverPoint);
|
result = accessibilityProperty.CreateNodeSearchInfo(subNode, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(result->Contains("hitTestMode"));
|
EXPECT_TRUE(result->Contains("hitTestMode"));
|
||||||
std::string value = result->GetString("hitTestMode");
|
std::string value = result->GetString("hitTestMode");
|
||||||
EXPECT_EQ(value, "Default");
|
EXPECT_EQ(value, "Default");
|
||||||
@ -465,7 +466,7 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest010, TestSize.Lev
|
|||||||
V2::BUTTON_ETS_TAG, 2, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 2, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
root->AddChild(subNode1);
|
root->AddChild(subNode1);
|
||||||
subNode1->SetHitTestMode(HitTestMode::HTMBLOCK);
|
subNode1->SetHitTestMode(HitTestMode::HTMBLOCK);
|
||||||
auto result1 = accessibilityProperty.CreateNodeSearchInfo(subNode1, hoverPoint);
|
auto result1 = accessibilityProperty.CreateNodeSearchInfo(subNode1, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(result1->Contains("hitTestMode"));
|
EXPECT_TRUE(result1->Contains("hitTestMode"));
|
||||||
std::string value1 = result1->GetString("hitTestMode");
|
std::string value1 = result1->GetString("hitTestMode");
|
||||||
EXPECT_EQ(value1, "Block");
|
EXPECT_EQ(value1, "Block");
|
||||||
@ -474,7 +475,7 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest010, TestSize.Lev
|
|||||||
V2::BUTTON_ETS_TAG, 3, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 3, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
root->AddChild(subNode2);
|
root->AddChild(subNode2);
|
||||||
subNode2->SetHitTestMode(HitTestMode::HTMTRANSPARENT);
|
subNode2->SetHitTestMode(HitTestMode::HTMTRANSPARENT);
|
||||||
auto result2 = accessibilityProperty.CreateNodeSearchInfo(subNode2, hoverPoint);
|
auto result2 = accessibilityProperty.CreateNodeSearchInfo(subNode2, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(result2->Contains("hitTestMode"));
|
EXPECT_TRUE(result2->Contains("hitTestMode"));
|
||||||
std::string value2 = result2->GetString("hitTestMode");
|
std::string value2 = result2->GetString("hitTestMode");
|
||||||
EXPECT_EQ(value2, "Transparent");
|
EXPECT_EQ(value2, "Transparent");
|
||||||
@ -495,13 +496,15 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest011, TestSize.Lev
|
|||||||
NG::PointF hoverPoint(0, 0);
|
NG::PointF hoverPoint(0, 0);
|
||||||
auto debugInfo = std::make_unique<AccessibilityProperty::HoverTestDebugTraceInfo>();
|
auto debugInfo = std::make_unique<AccessibilityProperty::HoverTestDebugTraceInfo>();
|
||||||
|
|
||||||
|
bool ancestorGroupFlag = false;
|
||||||
|
|
||||||
root->SetActive(false);
|
root->SetActive(false);
|
||||||
auto result = accessibilityProperty.HoverTestRecursive(hoverPoint, root, path, debugInfo);
|
auto result = accessibilityProperty.HoverTestRecursive(hoverPoint, root, path, debugInfo, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, false);
|
EXPECT_EQ(result, false);
|
||||||
root->SetActive(true);
|
root->SetActive(true);
|
||||||
|
|
||||||
root->SetInternal();
|
root->SetInternal();
|
||||||
result = accessibilityProperty.HoverTestRecursive(hoverPoint, root, path, debugInfo);
|
result = accessibilityProperty.HoverTestRecursive(hoverPoint, root, path, debugInfo, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, false);
|
EXPECT_EQ(result, false);
|
||||||
|
|
||||||
root->SetActive(true);
|
root->SetActive(true);
|
||||||
@ -516,50 +519,51 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest011, TestSize.Lev
|
|||||||
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest012, TestSize.Level1)
|
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest012, TestSize.Level1)
|
||||||
{
|
{
|
||||||
AccessibilityProperty accessibilityProperty;
|
AccessibilityProperty accessibilityProperty;
|
||||||
|
bool ancestorGroupFlag = false;
|
||||||
auto frameNode = FrameNode::GetOrCreateFrameNode(
|
auto frameNode = FrameNode::GetOrCreateFrameNode(
|
||||||
V2::BUTTON_ETS_TAG, 14, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 14, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
auto result = accessibilityProperty.GetSearchStrategy(frameNode);
|
auto result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, true));
|
EXPECT_EQ(result, std::make_tuple(true, true, false));
|
||||||
|
|
||||||
auto accessibilityPropertyNew = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
auto accessibilityPropertyNew = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
|
||||||
EXPECT_NE(accessibilityPropertyNew, nullptr);
|
EXPECT_NE(accessibilityPropertyNew, nullptr);
|
||||||
auto levelBak = accessibilityPropertyNew->GetAccessibilityLevel();
|
auto levelBak = accessibilityPropertyNew->GetAccessibilityLevel();
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::YES);
|
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::YES);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, true));
|
EXPECT_EQ(result, std::make_tuple(true, true, false));
|
||||||
|
|
||||||
bool hasGroupOrVirtualNodeBak = accessibilityPropertyNew->IsAccessibilityGroup();
|
bool hasGroupOrVirtualNodeBak = accessibilityPropertyNew->IsAccessibilityGroup();
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, false));
|
EXPECT_EQ(result, std::make_tuple(true, true, true));
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(levelBak);
|
accessibilityPropertyNew->SetAccessibilityLevel(levelBak);
|
||||||
|
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::NO_HIDE_DESCENDANTS);
|
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::NO_HIDE_DESCENDANTS);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(false, false));
|
EXPECT_EQ(result, std::make_tuple(false, false, false));
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(levelBak);
|
accessibilityPropertyNew->SetAccessibilityLevel(levelBak);
|
||||||
|
|
||||||
hasGroupOrVirtualNodeBak = accessibilityPropertyNew->IsAccessibilityGroup();
|
hasGroupOrVirtualNodeBak = accessibilityPropertyNew->IsAccessibilityGroup();
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, true));
|
EXPECT_EQ(result, std::make_tuple(true, true, false));
|
||||||
|
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, false));
|
EXPECT_EQ(result, std::make_tuple(true, true, true));
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
||||||
|
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::NO);
|
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::NO);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(false, true));
|
EXPECT_EQ(result, std::make_tuple(false, true, false));
|
||||||
|
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::AUTO);
|
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::AUTO);
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
||||||
bool hasGroupOrVirtualNode = accessibilityPropertyNew->IsAccessibilityGroup() ||
|
bool hasGroupOrVirtualNode = accessibilityPropertyNew->IsAccessibilityGroup() ||
|
||||||
accessibilityPropertyNew->HasAccessibilityVirtualNode();
|
accessibilityPropertyNew->HasAccessibilityVirtualNode();
|
||||||
EXPECT_TRUE(hasGroupOrVirtualNode);
|
EXPECT_TRUE(hasGroupOrVirtualNode);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, false));
|
EXPECT_EQ(result, std::make_tuple(true, true, true));
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,17 +917,18 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest028, TestSize.Lev
|
|||||||
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest029, TestSize.Level1)
|
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest029, TestSize.Level1)
|
||||||
{
|
{
|
||||||
AccessibilityProperty accessibilityProperty;
|
AccessibilityProperty accessibilityProperty;
|
||||||
|
bool ancestorGroupFlag = false;
|
||||||
auto root = FrameNode::CreateFrameNode(
|
auto root = FrameNode::CreateFrameNode(
|
||||||
V2::BUTTON_ETS_TAG, 12, AceType::MakeRefPtr<Pattern>(), true);
|
V2::BUTTON_ETS_TAG, 12, AceType::MakeRefPtr<Pattern>(), true);
|
||||||
NG::PointF hoverPoint(0, 0);
|
NG::PointF hoverPoint(0, 0);
|
||||||
auto result = accessibilityProperty.CreateNodeSearchInfo(root, hoverPoint);
|
auto result = accessibilityProperty.CreateNodeSearchInfo(root, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(root->IsRootNode());
|
EXPECT_TRUE(root->IsRootNode());
|
||||||
|
|
||||||
auto subNode = FrameNode::GetOrCreateFrameNode(
|
auto subNode = FrameNode::GetOrCreateFrameNode(
|
||||||
V2::BUTTON_ETS_TAG, 1, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 1, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
root->AddChild(subNode);
|
root->AddChild(subNode);
|
||||||
EXPECT_FALSE(subNode->IsRootNode());
|
EXPECT_FALSE(subNode->IsRootNode());
|
||||||
result = accessibilityProperty.CreateNodeSearchInfo(subNode, hoverPoint);
|
result = accessibilityProperty.CreateNodeSearchInfo(subNode, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(result->Contains("parent"));
|
EXPECT_TRUE(result->Contains("parent"));
|
||||||
EXPECT_TRUE(result->Contains("visible"));
|
EXPECT_TRUE(result->Contains("visible"));
|
||||||
|
|
||||||
@ -935,7 +940,7 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest029, TestSize.Lev
|
|||||||
V2::BUTTON_ETS_TAG, 4, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 4, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
root->AddChild(subNode3);
|
root->AddChild(subNode3);
|
||||||
subNode3->SetHitTestMode(HitTestMode::HTMNONE);
|
subNode3->SetHitTestMode(HitTestMode::HTMNONE);
|
||||||
auto result3 = accessibilityProperty.CreateNodeSearchInfo(subNode3, hoverPoint);
|
auto result3 = accessibilityProperty.CreateNodeSearchInfo(subNode3, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(result3->Contains("hitTestMode"));
|
EXPECT_TRUE(result3->Contains("hitTestMode"));
|
||||||
std::string value3 = result3->GetString("hitTestMode");
|
std::string value3 = result3->GetString("hitTestMode");
|
||||||
EXPECT_EQ(value3, "None");
|
EXPECT_EQ(value3, "None");
|
||||||
@ -944,7 +949,7 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest029, TestSize.Lev
|
|||||||
V2::BUTTON_ETS_TAG, 5, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 5, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
root->AddChild(subNode4);
|
root->AddChild(subNode4);
|
||||||
subNode4->SetHitTestMode(HitTestMode::HTMTRANSPARENT_SELF);
|
subNode4->SetHitTestMode(HitTestMode::HTMTRANSPARENT_SELF);
|
||||||
auto result4 = accessibilityProperty.CreateNodeSearchInfo(subNode4, hoverPoint);
|
auto result4 = accessibilityProperty.CreateNodeSearchInfo(subNode4, hoverPoint, ancestorGroupFlag);
|
||||||
EXPECT_TRUE(result4->Contains("hitTestMode"));
|
EXPECT_TRUE(result4->Contains("hitTestMode"));
|
||||||
std::string value4 = result4->GetString("hitTestMode");
|
std::string value4 = result4->GetString("hitTestMode");
|
||||||
EXPECT_EQ(value4, "Unsupported");
|
EXPECT_EQ(value4, "Unsupported");
|
||||||
@ -958,6 +963,7 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest029, TestSize.Lev
|
|||||||
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest030, TestSize.Level1)
|
HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest030, TestSize.Level1)
|
||||||
{
|
{
|
||||||
AccessibilityProperty accessibilityProperty;
|
AccessibilityProperty accessibilityProperty;
|
||||||
|
bool ancestorGroupFlag = false;
|
||||||
auto frameNode = FrameNode::GetOrCreateFrameNode(
|
auto frameNode = FrameNode::GetOrCreateFrameNode(
|
||||||
V2::BUTTON_ETS_TAG, 14, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
V2::BUTTON_ETS_TAG, 14, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
|
||||||
@ -965,23 +971,23 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest030, TestSize.Lev
|
|||||||
EXPECT_NE(accessibilityPropertyNew, nullptr);
|
EXPECT_NE(accessibilityPropertyNew, nullptr);
|
||||||
auto levelBak = accessibilityPropertyNew->GetAccessibilityLevel();
|
auto levelBak = accessibilityPropertyNew->GetAccessibilityLevel();
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::YES);
|
accessibilityPropertyNew->SetAccessibilityLevel(AccessibilityProperty::Level::YES);
|
||||||
auto result = accessibilityProperty.GetSearchStrategy(frameNode);
|
auto result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, true));
|
EXPECT_EQ(result, std::make_tuple(true, true, false));
|
||||||
|
|
||||||
bool hasGroupOrVirtualNodeBak = accessibilityPropertyNew->IsAccessibilityGroup();
|
bool hasGroupOrVirtualNodeBak = accessibilityPropertyNew->IsAccessibilityGroup();
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, true));
|
EXPECT_EQ(result, std::make_tuple(true, true, false));
|
||||||
|
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
accessibilityPropertyNew->SetAccessibilityGroup(true);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, false));
|
EXPECT_EQ(result, std::make_tuple(true, true, true));
|
||||||
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
accessibilityPropertyNew->SetAccessibilityGroup(hasGroupOrVirtualNodeBak);
|
||||||
|
|
||||||
accessibilityPropertyNew->SetAccessibilityText("test");
|
accessibilityPropertyNew->SetAccessibilityText("test");
|
||||||
bool hasAccessibilityText = accessibilityPropertyNew->HasAccessibilityTextOrDescription();
|
bool hasAccessibilityText = accessibilityPropertyNew->HasAccessibilityTextOrDescription();
|
||||||
EXPECT_TRUE(hasAccessibilityText);
|
EXPECT_TRUE(hasAccessibilityText);
|
||||||
result = accessibilityPropertyNew->GetSearchStrategy(frameNode);
|
result = accessibilityPropertyNew->GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, true));
|
EXPECT_EQ(result, std::make_tuple(true, true, false));
|
||||||
accessibilityPropertyNew->SetAccessibilityLevel(levelBak);
|
accessibilityPropertyNew->SetAccessibilityLevel(levelBak);
|
||||||
|
|
||||||
frameNode->accessibilityProperty_ = nullptr;
|
frameNode->accessibilityProperty_ = nullptr;
|
||||||
@ -991,19 +997,19 @@ HWTEST_F(AccessibilityPropertyTestNg, AccessibilityPropertyTest030, TestSize.Lev
|
|||||||
auto eventHub = frameNode->GetEventHub<EventHub>();
|
auto eventHub = frameNode->GetEventHub<EventHub>();
|
||||||
eventHub->SetEnabled(false);
|
eventHub->SetEnabled(false);
|
||||||
EXPECT_FALSE(eventHub->IsEnabled());
|
EXPECT_FALSE(eventHub->IsEnabled());
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, false));
|
EXPECT_EQ(result, std::make_tuple(true, false, false));
|
||||||
|
|
||||||
frameNode->SetHitTestMode(HitTestMode::HTMBLOCK);
|
frameNode->SetHitTestMode(HitTestMode::HTMBLOCK);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, false));
|
EXPECT_EQ(result, std::make_tuple(true, false, false));
|
||||||
|
|
||||||
frameNode->SetHitTestMode(HitTestMode::HTMTRANSPARENT);
|
frameNode->SetHitTestMode(HitTestMode::HTMTRANSPARENT);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(true, false));
|
EXPECT_EQ(result, std::make_tuple(true, false, false));
|
||||||
|
|
||||||
frameNode->SetHitTestMode(HitTestMode::HTMNONE);
|
frameNode->SetHitTestMode(HitTestMode::HTMNONE);
|
||||||
result = accessibilityProperty.GetSearchStrategy(frameNode);
|
result = accessibilityProperty.GetSearchStrategy(frameNode, ancestorGroupFlag);
|
||||||
EXPECT_EQ(result, std::make_pair(false, false));
|
EXPECT_EQ(result, std::make_tuple(false, false, false));
|
||||||
}
|
}
|
||||||
} // namespace OHOS::Ace::NG
|
} // namespace OHOS::Ace::NG
|
||||||
|
Loading…
Reference in New Issue
Block a user