Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
122f2425
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
未验证
提交
122f2425
编写于
11月 04, 2020
作者:
G
gaaclarke
提交者:
GitHub
11月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added unit tests to the rasterizer (#22282)
上级
d5b72698
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
137 addition
and
0 deletion
+137
-0
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+1
-0
shell/common/BUILD.gn
shell/common/BUILD.gn
+1
-0
shell/common/rasterizer_unittests.cc
shell/common/rasterizer_unittests.cc
+135
-0
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
122f2425
...
...
@@ -631,6 +631,7 @@ FILE: ../../../flutter/shell/common/pointer_data_dispatcher.cc
FILE: ../../../flutter/shell/common/pointer_data_dispatcher.h
FILE: ../../../flutter/shell/common/rasterizer.cc
FILE: ../../../flutter/shell/common/rasterizer.h
FILE: ../../../flutter/shell/common/rasterizer_unittests.cc
FILE: ../../../flutter/shell/common/run_configuration.cc
FILE: ../../../flutter/shell/common/run_configuration.h
FILE: ../../../flutter/shell/common/serialization_callbacks.cc
...
...
shell/common/BUILD.gn
浏览文件 @
122f2425
...
...
@@ -244,6 +244,7 @@ if (enable_unittests) {
"input_events_unittests.cc",
"persistent_cache_unittests.cc",
"pipeline_unittests.cc",
"rasterizer_unittests.cc",
"shell_unittests.cc",
"skp_shader_warmup_unittests.cc",
]
...
...
shell/common/rasterizer_unittests.cc
0 → 100644
浏览文件 @
122f2425
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/testing/testing.h"
#include "gmock/gmock.h"
using
testing
::
_
;
using
testing
::
Return
;
using
testing
::
ReturnRef
;
namespace
flutter
{
namespace
{
class
MockDelegate
:
public
Rasterizer
::
Delegate
{
public:
MOCK_METHOD1
(
OnFrameRasterized
,
void
(
const
FrameTiming
&
frame_timing
));
MOCK_METHOD0
(
GetFrameBudget
,
fml
::
Milliseconds
());
MOCK_CONST_METHOD0
(
GetLatestFrameTargetTime
,
fml
::
TimePoint
());
MOCK_CONST_METHOD0
(
GetTaskRunners
,
const
TaskRunners
&
());
MOCK_CONST_METHOD0
(
GetIsGpuDisabledSyncSwitch
,
std
::
shared_ptr
<
fml
::
SyncSwitch
>
());
};
class
MockSurface
:
public
Surface
{
public:
MOCK_METHOD0
(
IsValid
,
bool
());
MOCK_METHOD1
(
AcquireFrame
,
std
::
unique_ptr
<
SurfaceFrame
>
(
const
SkISize
&
size
));
MOCK_CONST_METHOD0
(
GetRootTransformation
,
SkMatrix
());
MOCK_METHOD0
(
GetContext
,
GrDirectContext
*
());
MOCK_METHOD0
(
GetExternalViewEmbedder
,
ExternalViewEmbedder
*
());
MOCK_METHOD0
(
MakeRenderContextCurrent
,
std
::
unique_ptr
<
GLContextResult
>
());
MOCK_METHOD0
(
ClearRenderContext
,
bool
());
};
class
MockExternalViewEmbedder
:
public
ExternalViewEmbedder
{
public:
MOCK_METHOD0
(
GetRootCanvas
,
SkCanvas
*
());
MOCK_METHOD0
(
CancelFrame
,
void
());
MOCK_METHOD4
(
BeginFrame
,
void
(
SkISize
frame_size
,
GrDirectContext
*
context
,
double
device_pixel_ratio
,
fml
::
RefPtr
<
fml
::
RasterThreadMerger
>
raster_thread_merger
));
MOCK_METHOD2
(
PrerollCompositeEmbeddedView
,
void
(
int
view_id
,
std
::
unique_ptr
<
EmbeddedViewParams
>
params
));
MOCK_METHOD1
(
PostPrerollAction
,
PostPrerollResult
(
fml
::
RefPtr
<
fml
::
RasterThreadMerger
>
raster_thread_merger
));
MOCK_METHOD0
(
GetCurrentCanvases
,
std
::
vector
<
SkCanvas
*>
());
MOCK_METHOD1
(
CompositeEmbeddedView
,
SkCanvas
*
(
int
view_id
));
MOCK_METHOD2
(
SubmitFrame
,
void
(
GrDirectContext
*
context
,
std
::
unique_ptr
<
SurfaceFrame
>
frame
));
MOCK_METHOD2
(
EndFrame
,
void
(
bool
should_resubmit_frame
,
fml
::
RefPtr
<
fml
::
RasterThreadMerger
>
raster_thread_merger
));
MOCK_METHOD0
(
SupportsDynamicThreadMerging
,
bool
());
};
}
// namespace
TEST
(
RasterizerTest
,
create
)
{
MockDelegate
delegate
;
auto
rasterizer
=
std
::
make_unique
<
Rasterizer
>
(
delegate
);
EXPECT_TRUE
(
rasterizer
!=
nullptr
);
}
TEST
(
RasterizerTest
,
drawEmptyPipeline
)
{
std
::
string
test_name
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
name
();
ThreadHost
thread_host
(
"io.flutter.test."
+
test_name
+
"."
,
ThreadHost
::
Type
::
Platform
|
ThreadHost
::
Type
::
GPU
|
ThreadHost
::
Type
::
IO
|
ThreadHost
::
Type
::
UI
);
TaskRunners
task_runners
(
"test"
,
thread_host
.
platform_thread
->
GetTaskRunner
(),
thread_host
.
raster_thread
->
GetTaskRunner
(),
thread_host
.
ui_thread
->
GetTaskRunner
(),
thread_host
.
io_thread
->
GetTaskRunner
());
MockDelegate
delegate
;
ON_CALL
(
delegate
,
GetTaskRunners
()).
WillByDefault
(
ReturnRef
(
task_runners
));
auto
rasterizer
=
std
::
make_unique
<
Rasterizer
>
(
delegate
);
auto
surface
=
std
::
make_unique
<
MockSurface
>
();
rasterizer
->
Setup
(
std
::
move
(
surface
));
fml
::
AutoResetWaitableEvent
latch
;
thread_host
.
raster_thread
->
GetTaskRunner
()
->
PostTask
([
&
]
{
auto
pipeline
=
fml
::
AdoptRef
(
new
Pipeline
<
LayerTree
>
(
/*depth=*/
10
));
rasterizer
->
Draw
(
pipeline
,
nullptr
);
latch
.
Signal
();
});
latch
.
Wait
();
}
TEST
(
RasterizerTest
,
drawWithExternalViewEmbedder
)
{
std
::
string
test_name
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
name
();
ThreadHost
thread_host
(
"io.flutter.test."
+
test_name
+
"."
,
ThreadHost
::
Type
::
Platform
|
ThreadHost
::
Type
::
GPU
|
ThreadHost
::
Type
::
IO
|
ThreadHost
::
Type
::
UI
);
TaskRunners
task_runners
(
"test"
,
thread_host
.
platform_thread
->
GetTaskRunner
(),
thread_host
.
raster_thread
->
GetTaskRunner
(),
thread_host
.
ui_thread
->
GetTaskRunner
(),
thread_host
.
io_thread
->
GetTaskRunner
());
MockDelegate
delegate
;
EXPECT_CALL
(
delegate
,
GetTaskRunners
())
.
WillRepeatedly
(
ReturnRef
(
task_runners
));
EXPECT_CALL
(
delegate
,
OnFrameRasterized
(
_
));
auto
rasterizer
=
std
::
make_unique
<
Rasterizer
>
(
delegate
);
auto
surface
=
std
::
make_unique
<
MockSurface
>
();
MockExternalViewEmbedder
external_view_embedder
;
EXPECT_CALL
(
*
surface
,
GetExternalViewEmbedder
())
.
WillRepeatedly
(
Return
(
&
external_view_embedder
));
EXPECT_CALL
(
external_view_embedder
,
BeginFrame
(
SkISize
(),
nullptr
,
2.0
,
fml
::
RefPtr
<
fml
::
RasterThreadMerger
>
(
nullptr
)));
EXPECT_CALL
(
external_view_embedder
,
EndFrame
(
false
,
fml
::
RefPtr
<
fml
::
RasterThreadMerger
>
(
nullptr
)));
rasterizer
->
Setup
(
std
::
move
(
surface
));
fml
::
AutoResetWaitableEvent
latch
;
thread_host
.
raster_thread
->
GetTaskRunner
()
->
PostTask
([
&
]
{
auto
pipeline
=
fml
::
AdoptRef
(
new
Pipeline
<
LayerTree
>
(
/*depth=*/
10
));
auto
layer_tree
=
std
::
make_unique
<
LayerTree
>
(
/*frame_size=*/
SkISize
(),
/*device_pixel_ratio=*/
2.0
f
);
bool
result
=
pipeline
->
Produce
().
Complete
(
std
::
move
(
layer_tree
));
EXPECT_TRUE
(
result
);
std
::
function
<
bool
(
LayerTree
&
)
>
no_discard
=
[](
LayerTree
&
)
{
return
false
;
};
rasterizer
->
Draw
(
pipeline
,
no_discard
);
latch
.
Signal
();
});
latch
.
Wait
();
}
}
// namespace flutter
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录