Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
9b4bb20a
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9b4bb20a
编写于
11月 02, 2020
作者:
C
chunhtai
提交者:
GitHub
11月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
makes android semanticsnode to ignore hittest if it is not focusable (#22205)
上级
d3182bc2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
70 addition
and
1 deletion
+70
-1
shell/platform/android/io/flutter/view/AccessibilityBridge.java
...platform/android/io/flutter/view/AccessibilityBridge.java
+6
-1
shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java
...android/test/io/flutter/view/AccessibilityBridgeTest.java
+64
-0
未找到文件。
shell/platform/android/io/flutter/view/AccessibilityBridge.java
浏览文件 @
9b4bb20a
...
...
@@ -207,6 +207,11 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
// beneath a stylus or mouse cursor.
@Nullable
private
SemanticsNode
hoveredObject
;
@VisibleForTesting
public
int
getHoveredObjectId
()
{
return
hoveredObject
.
id
;
}
// A Java/Android cached representation of the Flutter app's navigation stack. The Flutter
// navigation stack is tracked so that accessibility announcements can be made during Flutter's
// navigation changes.
...
...
@@ -2180,7 +2185,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
return
result
;
}
}
return
this
;
return
isFocusable
()
?
this
:
null
;
}
// TODO(goderbauer): This should be decided by the framework once we have more information
...
...
shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java
浏览文件 @
9b4bb20a
...
...
@@ -204,6 +204,70 @@ public class AccessibilityBridgeTest {
assertEquals
(
sentences
.
get
(
0
).
toString
(),
"new_node2"
);
}
@Test
public
void
itIgnoresUnfocusableNodeDuringHitTest
()
{
AccessibilityViewEmbedder
mockViewEmbedder
=
mock
(
AccessibilityViewEmbedder
.
class
);
AccessibilityManager
mockManager
=
mock
(
AccessibilityManager
.
class
);
View
mockRootView
=
mock
(
View
.
class
);
Context
context
=
mock
(
Context
.
class
);
when
(
mockRootView
.
getContext
()).
thenReturn
(
context
);
when
(
context
.
getPackageName
()).
thenReturn
(
"test"
);
AccessibilityBridge
accessibilityBridge
=
setUpBridge
(
mockRootView
,
mockManager
,
mockViewEmbedder
);
ViewParent
mockParent
=
mock
(
ViewParent
.
class
);
when
(
mockRootView
.
getParent
()).
thenReturn
(
mockParent
);
when
(
mockManager
.
isEnabled
()).
thenReturn
(
true
);
when
(
mockManager
.
isTouchExplorationEnabled
()).
thenReturn
(
true
);
TestSemanticsNode
root
=
new
TestSemanticsNode
();
root
.
id
=
0
;
root
.
left
=
0
;
root
.
top
=
0
;
root
.
bottom
=
20
;
root
.
right
=
20
;
TestSemanticsNode
ignored
=
new
TestSemanticsNode
();
ignored
.
id
=
1
;
ignored
.
addFlag
(
AccessibilityBridge
.
Flag
.
SCOPES_ROUTE
);
ignored
.
left
=
0
;
ignored
.
top
=
0
;
ignored
.
bottom
=
20
;
ignored
.
right
=
20
;
root
.
children
.
add
(
ignored
);
TestSemanticsNode
child
=
new
TestSemanticsNode
();
child
.
id
=
2
;
child
.
label
=
"label"
;
child
.
left
=
0
;
child
.
top
=
0
;
child
.
bottom
=
20
;
child
.
right
=
20
;
root
.
children
.
add
(
child
);
TestSemanticsUpdate
testSemanticsUpdate
=
root
.
toUpdate
();
accessibilityBridge
.
updateSemantics
(
testSemanticsUpdate
.
buffer
,
testSemanticsUpdate
.
strings
);
ArgumentCaptor
<
AccessibilityEvent
>
eventCaptor
=
ArgumentCaptor
.
forClass
(
AccessibilityEvent
.
class
);
verify
(
mockParent
,
times
(
2
))
.
requestSendAccessibilityEvent
(
eq
(
mockRootView
),
eventCaptor
.
capture
());
AccessibilityEvent
event
=
eventCaptor
.
getAllValues
().
get
(
0
);
assertEquals
(
event
.
getEventType
(),
AccessibilityEvent
.
TYPE_WINDOW_STATE_CHANGED
);
// Synthesize an accessibility hit test event.
MotionEvent
mockEvent
=
mock
(
MotionEvent
.
class
);
when
(
mockEvent
.
getX
()).
thenReturn
(
10.0f
);
when
(
mockEvent
.
getY
()).
thenReturn
(
10.0f
);
when
(
mockEvent
.
getAction
()).
thenReturn
(
MotionEvent
.
ACTION_HOVER_ENTER
);
boolean
hit
=
accessibilityBridge
.
onAccessibilityHoverEvent
(
mockEvent
);
assertEquals
(
hit
,
true
);
eventCaptor
=
ArgumentCaptor
.
forClass
(
AccessibilityEvent
.
class
);
verify
(
mockParent
,
times
(
3
))
.
requestSendAccessibilityEvent
(
eq
(
mockRootView
),
eventCaptor
.
capture
());
event
=
eventCaptor
.
getAllValues
().
get
(
2
);
assertEquals
(
event
.
getEventType
(),
AccessibilityEvent
.
TYPE_VIEW_HOVER_ENTER
);
assertEquals
(
accessibilityBridge
.
getHoveredObjectId
(),
2
);
}
@Test
public
void
itAnnouncesRouteNameWhenRemoveARoute
()
{
AccessibilityViewEmbedder
mockViewEmbedder
=
mock
(
AccessibilityViewEmbedder
.
class
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录