Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
12847e89
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,发现更多精彩内容 >>
未验证
提交
12847e89
编写于
7月 17, 2020
作者:
E
Emmanuel Garcia
提交者:
GitHub
7月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support talkback in hybrid composition (#19860)
上级
cb3b5ba7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
2 deletion
+72
-2
shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
...tform/android/io/flutter/embedding/engine/FlutterJNI.java
+2
-1
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
...d/io/flutter/plugin/platform/PlatformViewsController.java
+6
-1
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
.../flutter/plugin/platform/PlatformViewsControllerTest.java
+64
-0
未找到文件。
shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
浏览文件 @
12847e89
...
...
@@ -676,7 +676,8 @@ public class FlutterJNI {
// Called by native.
// TODO(mattcarroll): determine if message is nonull or nullable
@SuppressWarnings
(
"unused"
)
private
void
handlePlatformMessage
(
@VisibleForTesting
public
void
handlePlatformMessage
(
@NonNull
final
String
channel
,
byte
[]
message
,
final
int
replyId
)
{
if
(
platformMessageHandler
!=
null
)
{
platformMessageHandler
.
handleMessageFromDart
(
channel
,
message
,
replyId
);
...
...
shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
浏览文件 @
12847e89
...
...
@@ -524,6 +524,10 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
@Override
public
View
getPlatformViewById
(
Integer
id
)
{
// Hybrid composition.
if
(
platformViews
.
get
(
id
)
!=
null
)
{
return
platformViews
.
get
(
id
);
}
VirtualDisplayController
controller
=
vdControllers
.
get
(
id
);
if
(
controller
==
null
)
{
return
null
;
...
...
@@ -641,7 +645,8 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
}
}
private
void
initializePlatformViewIfNeeded
(
int
viewId
)
{
@VisibleForTesting
void
initializePlatformViewIfNeeded
(
int
viewId
)
{
if
(
platformViews
.
get
(
viewId
)
!=
null
)
{
return
;
}
...
...
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
浏览文件 @
12847e89
...
...
@@ -3,16 +3,30 @@ package io.flutter.plugin.platform;
import
static
io
.
flutter
.
embedding
.
engine
.
systemchannels
.
PlatformViewsChannel
.
PlatformViewTouch
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
mockito
.
Matchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
android.content.Context
;
import
android.content.res.AssetManager
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
io.flutter.embedding.android.FlutterView
;
import
io.flutter.embedding.android.MotionEventTracker
;
import
io.flutter.embedding.engine.FlutterJNI
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.StandardMethodCodec
;
import
java.nio.ByteBuffer
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -186,4 +200,54 @@ public class PlatformViewsControllerTest {
assertNotEquals
(
resolvedEvent
.
getAction
(),
frameWorkTouch
.
action
);
assertEquals
(
resolvedEvent
.
getAction
(),
original
.
getAction
());
}
@Test
public
void
getPlatformViewById__hybridComposition
()
{
PlatformViewsController
platformViewsController
=
new
PlatformViewsController
();
int
platformViewId
=
0
;
assertNull
(
platformViewsController
.
getPlatformViewById
(
platformViewId
));
FlutterJNI
jni
=
new
FlutterJNI
();
AssetManager
assetManager
=
mock
(
AssetManager
.
class
);
Context
context
=
RuntimeEnvironment
.
application
.
getApplicationContext
();
DartExecutor
executor
=
new
DartExecutor
(
jni
,
assetManager
);
executor
.
onAttachedToJNI
();
platformViewsController
.
attach
(
context
,
null
,
executor
);
platformViewsController
.
attachToView
(
mock
(
FlutterView
.
class
));
PlatformViewFactory
viewFactory
=
mock
(
PlatformViewFactory
.
class
);
PlatformView
platformView
=
mock
(
PlatformView
.
class
);
View
androidView
=
mock
(
View
.
class
);
when
(
platformView
.
getView
()).
thenReturn
(
androidView
);
when
(
viewFactory
.
create
(
any
(),
eq
(
platformViewId
),
any
())).
thenReturn
(
platformView
);
platformViewsController
.
getRegistry
().
registerViewFactory
(
"testType"
,
viewFactory
);
// Simulate create call from the framework.
Map
<
String
,
Object
>
platformViewCreateArguments
=
new
HashMap
<>();
platformViewCreateArguments
.
put
(
"hybrid"
,
true
);
platformViewCreateArguments
.
put
(
"id"
,
platformViewId
);
platformViewCreateArguments
.
put
(
"viewType"
,
"testType"
);
platformViewCreateArguments
.
put
(
"direction"
,
0
);
MethodCall
platformCreateMethodCall
=
new
MethodCall
(
"create"
,
platformViewCreateArguments
);
jni
.
handlePlatformMessage
(
"flutter/platform_views"
,
encodeMethodCall
(
platformCreateMethodCall
),
/*replyId=*/
0
);
platformViewsController
.
initializePlatformViewIfNeeded
(
platformViewId
);
View
resultAndroidView
=
platformViewsController
.
getPlatformViewById
(
platformViewId
);
assertNotNull
(
resultAndroidView
);
assertEquals
(
resultAndroidView
,
androidView
);
}
private
static
byte
[]
encodeMethodCall
(
MethodCall
call
)
{
ByteBuffer
buffer
=
StandardMethodCodec
.
INSTANCE
.
encodeMethodCall
(
call
);
buffer
.
rewind
();
byte
[]
dest
=
new
byte
[
buffer
.
remaining
()];
buffer
.
get
(
dest
);
return
dest
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录