Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
f49c62a9
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
f49c62a9
编写于
6月 11, 2021
作者:
Y
Yegor
提交者:
GitHub
6月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[web] more null-safe tests (#26712)
上级
201ee6f7
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
157 addition
and
177 deletion
+157
-177
lib/web_ui/test/canvaskit/vertices_test.dart
lib/web_ui/test/canvaskit/vertices_test.dart
+3
-4
lib/web_ui/test/engine/image/html_image_codec_test.dart
lib/web_ui/test/engine/image/html_image_codec_test.dart
+2
-3
lib/web_ui/test/engine/semantics/accessibility_test.dart
lib/web_ui/test/engine/semantics/accessibility_test.dart
+3
-4
lib/web_ui/test/engine/semantics/semantics_test.dart
lib/web_ui/test/engine/semantics/semantics_test.dart
+30
-31
lib/web_ui/test/engine/services/serialization_test.dart
lib/web_ui/test/engine/services/serialization_test.dart
+0
-1
lib/web_ui/test/engine/surface/frame_timings_test.dart
lib/web_ui/test/engine/surface/frame_timings_test.dart
+1
-2
lib/web_ui/test/engine/surface/platform_view_test.dart
lib/web_ui/test/engine/surface/platform_view_test.dart
+1
-2
lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart
...test/engine/surface/shaders/normalized_gradient_test.dart
+0
-1
lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart
...b_ui/test/engine/surface/shaders/shader_builder_test.dart
+1
-2
lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart
...st/golden_tests/engine/canvas_draw_image_golden_test.dart
+66
-67
lib/web_ui/test/golden_tests/engine/canvas_rect_golden_test.dart
..._ui/test/golden_tests/engine/canvas_rect_golden_test.dart
+2
-3
lib/web_ui/test/golden_tests/engine/canvas_rrect_golden_test.dart
...ui/test/golden_tests/engine/canvas_rrect_golden_test.dart
+5
-6
lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart
.../golden_tests/engine/canvas_stroke_joins_golden_test.dart
+2
-3
lib/web_ui/test/golden_tests/engine/canvas_stroke_rects_golden_test.dart
.../golden_tests/engine/canvas_stroke_rects_golden_test.dart
+2
-3
lib/web_ui/test/golden_tests/engine/canvas_winding_rule_test.dart
...ui/test/golden_tests/engine/canvas_winding_rule_test.dart
+2
-3
lib/web_ui/test/golden_tests/engine/clip_op_golden_test.dart
lib/web_ui/test/golden_tests/engine/clip_op_golden_test.dart
+1
-2
lib/web_ui/test/golden_tests/engine/conic_golden_test.dart
lib/web_ui/test/golden_tests/engine/conic_golden_test.dart
+3
-4
lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart
lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart
+6
-7
lib/web_ui/test/text/font_collection_test.dart
lib/web_ui/test/text/font_collection_test.dart
+16
-17
lib/web_ui/test/text/font_loading_test.dart
lib/web_ui/test/text/font_loading_test.dart
+11
-12
未找到文件。
lib/web_ui/test/canvaskit/vertices_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'package:test/bootstrap/browser.dart'
;
import
'package:test/test.dart'
;
import
'package:ui/src/engine.dart'
;
...
...
@@ -29,7 +28,7 @@ void testMain() {
canvas
.
drawVertices
(
vertices
,
ui
.
BlendMode
.
srcOver
,
ui
.
Paint
(),
Ck
Paint
(),
);
vertices
.
delete
();
});
...
...
@@ -37,7 +36,7 @@ void testMain() {
},
skip:
isIosSafari
);
}
ui
.
Vertices
_testVertices
(
)
{
Ck
Vertices
_testVertices
(
)
{
return
ui
.
Vertices
(
ui
.
VertexMode
.
triangles
,
<
ui
.
Offset
>[
...
...
@@ -56,5 +55,5 @@ ui.Vertices _testVertices() {
ui
.
Color
.
fromRGBO
(
0
,
0
,
255
,
1.0
),
],
indices:
<
int
>[
0
,
1
,
2
],
);
)
as
CkVertices
;
}
lib/web_ui/test/engine/image/html_image_codec_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:async'
;
import
'dart:typed_data'
;
...
...
@@ -103,7 +102,7 @@ void testMain() async {
group
(
'ImageCodecUrl'
,
()
{
test
(
'loads sample image from web'
,
()
async
{
final
Uri
uri
=
Uri
.
base
.
resolve
(
'sample_image1.png'
);
final
HtmlCodec
codec
=
await
ui
.
webOnlyInstantiateImageCodecFromUrl
(
uri
);
final
HtmlCodec
codec
=
await
ui
.
webOnlyInstantiateImageCodecFromUrl
(
uri
)
as
HtmlCodec
;
final
ui
.
FrameInfo
frameInfo
=
await
codec
.
getNextFrame
();
expect
(
frameInfo
.
image
,
isNotNull
);
expect
(
frameInfo
.
image
.
width
,
100
);
...
...
@@ -114,7 +113,7 @@ void testMain() async {
final
HtmlCodec
codec
=
await
ui
.
webOnlyInstantiateImageCodecFromUrl
(
uri
,
chunkCallback:
(
int
loaded
,
int
total
)
{
buffer
.
write
(
'
$loaded
/
$total
,'
);
});
})
as
HtmlCodec
;
await
codec
.
getNextFrame
();
expect
(
buffer
.
toString
(),
'0/100,100/100,'
);
});
...
...
lib/web_ui/test/engine/semantics/accessibility_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:async'
show
Future
;
import
'dart:html'
;
...
...
@@ -10,7 +9,7 @@ import 'package:test/bootstrap/browser.dart';
import
'package:test/test.dart'
;
import
'package:ui/src/engine.dart'
;
const
MessageCodec
<
dynamic
>
codec
=
StandardMessageCodec
();
const
StandardMessageCodec
codec
=
StandardMessageCodec
();
const
String
testMessage
=
'This is an tooltip.'
;
const
Map
<
dynamic
,
dynamic
>
testInput
=
<
dynamic
,
dynamic
>{
'data'
:
<
dynamic
,
dynamic
>{
'message'
:
testMessage
}
...
...
@@ -21,7 +20,7 @@ void main() {
}
void
testMain
(
)
{
AccessibilityAnnouncements
accessibilityAnnouncements
;
late
AccessibilityAnnouncements
accessibilityAnnouncements
;
group
(
'
$AccessibilityAnnouncements
'
,
()
{
setUp
(()
{
...
...
@@ -45,7 +44,7 @@ void testMain() {
isNotNull
,
);
final
LabelElement
input
=
document
.
getElementById
(
'accessibility-element'
);
document
.
getElementById
(
'accessibility-element'
)
as
LabelElement
;
expect
(
input
.
getAttribute
(
'aria-live'
),
equals
(
'polite'
));
expect
(
input
.
text
,
testMessage
);
...
...
lib/web_ui/test/engine/semantics/semantics_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.9
@TestOn
(
'chrome || safari || firefox'
)
import
'dart:async'
;
...
...
@@ -88,7 +87,7 @@ void _testEngineSemanticsOwner() {
// Synthesize a click on the placeholder.
final
html
.
Element
placeholder
=
appShadowRoot
.
querySelector
(
'flt-semantics-placeholder'
);
appShadowRoot
.
querySelector
(
'flt-semantics-placeholder'
)
!
;
expect
(
placeholder
.
isConnected
,
isTrue
);
...
...
@@ -101,7 +100,7 @@ void _testEngineSemanticsOwner() {
// On mobile semantics is enabled asynchronously.
if
(
isMobile
)
{
while
(
placeholder
.
isConnected
)
{
while
(
placeholder
.
isConnected
!
)
{
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
50
));
}
}
...
...
@@ -114,7 +113,7 @@ void _testEngineSemanticsOwner() {
expect
(
semantics
().
semanticsEnabled
,
isFalse
);
final
html
.
Element
placeholder
=
appShadowRoot
.
querySelector
(
'flt-semantics-placeholder'
);
appShadowRoot
.
querySelector
(
'flt-semantics-placeholder'
)
!
;
expect
(
placeholder
.
isConnected
,
isTrue
);
...
...
@@ -159,12 +158,12 @@ void _testEngineSemanticsOwner() {
// Create
renderLabel
(
'Hello'
);
final
Map
<
int
,
SemanticsObject
>
tree
=
semantics
().
debugSemanticsTree
;
final
Map
<
int
,
SemanticsObject
>
tree
=
semantics
().
debugSemanticsTree
!
;
expect
(
tree
.
length
,
2
);
expect
(
tree
[
0
].
id
,
0
);
expect
(
tree
[
0
].
element
.
tagName
.
toLowerCase
(),
'flt-semantics'
);
expect
(
tree
[
1
].
id
,
1
);
expect
(
tree
[
1
].
label
,
'Hello'
);
expect
(
tree
[
0
]
!
.
id
,
0
);
expect
(
tree
[
0
]
!
.
element
.
tagName
.
toLowerCase
(),
'flt-semantics'
);
expect
(
tree
[
1
]
!
.
id
,
1
);
expect
(
tree
[
1
]
!
.
label
,
'Hello'
);
expectSemanticsTree
(
'''
<sem style="
$rootSemanticStyle
">
...
...
@@ -383,9 +382,9 @@ void _testContainer() {
</sem>'''
);
final
html
.
Element
parentElement
=
appShadowRoot
.
querySelector
(
'flt-semantics'
);
appShadowRoot
.
querySelector
(
'flt-semantics'
)
!
;
final
html
.
Element
container
=
appShadowRoot
.
querySelector
(
'flt-semantics-container'
);
appShadowRoot
.
querySelector
(
'flt-semantics-container'
)
!
;
if
(
isMacOrIOS
)
{
expect
(
parentElement
.
style
.
top
,
'0px'
);
...
...
@@ -431,9 +430,9 @@ void _testContainer() {
</sem>'''
);
final
html
.
Element
parentElement
=
appShadowRoot
.
querySelector
(
'flt-semantics'
);
appShadowRoot
.
querySelector
(
'flt-semantics'
)
!
;
final
html
.
Element
container
=
appShadowRoot
.
querySelector
(
'flt-semantics-container'
);
appShadowRoot
.
querySelector
(
'flt-semantics-container'
)
!
;
expect
(
parentElement
.
style
.
transform
,
'matrix(1, 0, 0, 1, 10, 10)'
);
expect
(
parentElement
.
style
.
transformOrigin
,
'0px 0px 0px'
);
...
...
@@ -477,9 +476,9 @@ void _testContainer() {
}
final
html
.
Element
parentElement
=
appShadowRoot
.
querySelector
(
'flt-semantics'
);
appShadowRoot
.
querySelector
(
'flt-semantics'
)
!
;
final
html
.
Element
container
=
appShadowRoot
.
querySelector
(
'flt-semantics-container'
);
appShadowRoot
.
querySelector
(
'flt-semantics-container'
)
!
;
if
(
isMacOrIOS
)
{
expect
(
parentElement
.
style
.
top
,
'0px'
);
...
...
@@ -550,12 +549,12 @@ void _testVerticalScrolling() {
</sem-c>
</sem>'''
);
final
html
.
Element
scrollable
=
findScrollable
();
final
html
.
Element
?
scrollable
=
findScrollable
();
expect
(
scrollable
,
isNotNull
);
// When there's less content than the available size the neutral scrollTop
// is 0.
expect
(
scrollable
.
scrollTop
,
0
);
expect
(
scrollable
!
.
scrollTop
,
0
);
semantics
().
semanticsEnabled
=
false
;
});
...
...
@@ -574,7 +573,7 @@ void _testVerticalScrolling() {
final
Zone
testZone
=
Zone
.
current
;
ui
.
window
.
onSemanticsAction
=
(
int
id
,
ui
.
SemanticsAction
action
,
ByteData
args
)
{
(
int
id
,
ui
.
SemanticsAction
action
,
ByteData
?
args
)
{
idLogController
.
add
(
id
);
actionLogController
.
add
(
action
);
testZone
.
run
(()
{
...
...
@@ -620,7 +619,7 @@ void _testVerticalScrolling() {
</sem-c>
</sem>'''
);
final
html
.
Element
scrollable
=
findScrollable
();
final
html
.
Element
?
scrollable
=
findScrollable
();
expect
(
scrollable
,
isNotNull
);
// When there's more content than the available size the neutral scrollTop
...
...
@@ -633,7 +632,7 @@ void _testVerticalScrolling() {
browserMaxScrollDiff
=
1
;
}
expect
(
scrollable
.
scrollTop
>=
(
10
-
browserMaxScrollDiff
),
isTrue
);
expect
(
scrollable
!
.
scrollTop
>=
(
10
-
browserMaxScrollDiff
),
isTrue
);
scrollable
.
scrollTop
=
20
;
expect
(
scrollable
.
scrollTop
,
20
);
...
...
@@ -702,12 +701,12 @@ void _testHorizontalScrolling() {
</sem-c>
</sem>'''
);
final
html
.
Element
scrollable
=
findScrollable
();
final
html
.
Element
?
scrollable
=
findScrollable
();
expect
(
scrollable
,
isNotNull
);
// When there's less content than the available size the neutral
// scrollLeft is 0.
expect
(
scrollable
.
scrollLeft
,
0
);
expect
(
scrollable
!
.
scrollLeft
,
0
);
semantics
().
semanticsEnabled
=
false
;
});
...
...
@@ -753,7 +752,7 @@ void _testHorizontalScrolling() {
</sem-c>
</sem>'''
);
final
html
.
Element
scrollable
=
findScrollable
();
final
html
.
Element
?
scrollable
=
findScrollable
();
expect
(
scrollable
,
isNotNull
);
// When there's more content than the available size the neutral scrollTop
...
...
@@ -765,7 +764,7 @@ void _testHorizontalScrolling() {
operatingSystem
==
OperatingSystem
.
macOs
)
{
browserMaxScrollDiff
=
1
;
}
expect
(
scrollable
.
scrollLeft
>=
(
10
-
browserMaxScrollDiff
),
isTrue
);
expect
(
scrollable
!
.
scrollLeft
>=
(
10
-
browserMaxScrollDiff
),
isTrue
);
scrollable
.
scrollLeft
=
20
;
expect
(
scrollable
.
scrollLeft
,
20
);
...
...
@@ -835,7 +834,7 @@ void _testIncrementables() {
<input aria-valuenow="1" aria-valuetext="d" aria-valuemax="2" aria-valuemin="1">
</sem>'''
);
final
html
.
InputElement
input
=
appShadowRoot
.
querySelector
(
'input'
);
final
html
.
InputElement
input
=
appShadowRoot
.
querySelector
(
'input'
)
as
html
.
InputElement
;
input
.
value
=
'2'
;
input
.
dispatchEvent
(
html
.
Event
(
'change'
));
...
...
@@ -869,7 +868,7 @@ void _testIncrementables() {
<input aria-valuenow="1" aria-valuetext="d" aria-valuemax="1" aria-valuemin="0">
</sem>'''
);
final
html
.
InputElement
input
=
appShadowRoot
.
querySelector
(
'input'
);
final
html
.
InputElement
input
=
appShadowRoot
.
querySelector
(
'input'
)
as
html
.
InputElement
;
input
.
value
=
'0'
;
input
.
dispatchEvent
(
html
.
Event
(
'change'
));
...
...
@@ -963,7 +962,7 @@ void _testTextField() {
semantics
().
updateSemantics
(
builder
.
build
());
final
html
.
Element
textField
=
appShadowRoot
.
querySelector
(
'input[data-semantics-role="text-field"]'
);
appShadowRoot
.
querySelector
(
'input[data-semantics-role="text-field"]'
)
!
;
expect
(
appShadowRoot
.
activeElement
,
isNot
(
textField
));
...
...
@@ -1491,10 +1490,10 @@ void updateNode(
String
increasedValue
=
''
,
String
decreasedValue
=
''
,
ui
.
TextDirection
textDirection
=
ui
.
TextDirection
.
ltr
,
Float64List
transform
,
Int32List
childrenInTraversalOrder
,
Int32List
childrenInHitTestOrder
,
Int32List
additionalActions
,
Float64List
?
transform
,
Int32List
?
childrenInTraversalOrder
,
Int32List
?
childrenInHitTestOrder
,
Int32List
?
additionalActions
,
})
{
transform
??=
Float64List
.
fromList
(
Matrix4
.
identity
().
storage
);
childrenInTraversalOrder
??=
Int32List
(
0
);
...
...
lib/web_ui/test/engine/services/serialization_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:typed_data'
;
import
'package:test/test.dart'
;
...
...
lib/web_ui/test/engine/surface/frame_timings_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'package:test/bootstrap/browser.dart'
;
import
'package:test/test.dart'
;
import
'package:ui/src/engine.dart'
;
...
...
@@ -15,7 +14,7 @@ void main() {
void
testMain
(
)
{
setUp
(()
async
{
await
initializeEngine
();
initializeEngine
();
});
test
(
'collects frame timings'
,
()
async
{
...
...
lib/web_ui/test/engine/surface/platform_view_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:async'
;
import
'dart:html'
as
html
;
...
...
@@ -22,7 +21,7 @@ void main() {
}
void
testMain
(
)
{
PersistedPlatformView
view
;
late
PersistedPlatformView
view
;
group
(
'PersistedPlatformView'
,
()
{
setUp
(()
async
{
...
...
lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'package:test/bootstrap/browser.dart'
;
import
'package:test/test.dart'
;
import
'package:ui/src/engine/html/shaders/normalized_gradient.dart'
;
...
...
lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'package:test/bootstrap/browser.dart'
;
import
'package:test/test.dart'
;
import
'package:ui/src/engine.dart'
;
...
...
@@ -25,7 +24,7 @@ void testMain() {
')'
;
setUpAll
(()
async
{
await
webOnlyInitializeEngine
();
webOnlyInitializeEngine
();
});
group
(
'Shader Declarations'
,
()
{
...
...
lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'dart:math'
as
math
;
import
'dart:js_util'
as
js_util
;
...
...
@@ -48,7 +47,7 @@ void testMain() async {
}
}
sceneElement
.
append
(
engineCanvas
.
rootElement
);
html
.
document
.
body
.
append
(
sceneElement
);
html
.
document
.
body
!
.
append
(
sceneElement
);
await
matchGoldenFile
(
'
$fileName
.png'
,
region:
region
,
maxDiffRatePercent:
maxDiffRatePercent
,
write:
write
);
}
finally
{
...
...
@@ -68,7 +67,7 @@ void testMain() async {
final
RecordingCanvas
rc
=
RecordingCanvas
(
const
Rect
.
fromLTRB
(
0
,
0
,
400
,
300
));
rc
.
save
();
rc
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
new
Paint
());
rc
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_image'
);
});
...
...
@@ -79,7 +78,7 @@ void testMain() async {
rc
.
save
();
rc
.
translate
(
50.0
,
100.0
);
rc
.
rotate
(
math
.
pi
/
4.0
);
rc
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
new
Paint
());
rc
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_image_with_transform'
);
});
...
...
@@ -90,7 +89,7 @@ void testMain() async {
rc
.
save
();
rc
.
translate
(
50.0
,
100.0
);
rc
.
rotate
(
math
.
pi
/
4.0
);
rc
.
drawImage
(
createTestImage
(),
Offset
(
30
,
20
),
new
Paint
());
rc
.
drawImage
(
createTestImage
(),
Offset
(
30
,
20
),
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_image_with_transform_and_offset'
);
});
...
...
@@ -105,7 +104,7 @@ void testMain() async {
double
testWidth
=
testImage
.
width
.
toDouble
();
double
testHeight
=
testImage
.
height
.
toDouble
();
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_image_rect_with_transform'
);
});
...
...
@@ -121,7 +120,7 @@ void testMain() async {
testImage
,
Rect
.
fromLTRB
(
testWidth
/
2
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_image_rect_with_source'
);
});
...
...
@@ -139,7 +138,7 @@ void testMain() async {
testImage
,
Rect
.
fromLTRB
(
testWidth
/
2
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_image_rect_with_source_and_clip'
);
});
...
...
@@ -157,7 +156,7 @@ void testMain() async {
testImage
,
Rect
.
fromLTRB
(
testWidth
/
2
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_image_rect_with_transform_source'
);
});
...
...
@@ -172,11 +171,11 @@ void testMain() async {
double
testWidth
=
testImage
.
width
.
toDouble
();
double
testHeight
=
testImage
.
height
.
toDouble
();
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
drawCircle
(
Offset
(
100
,
100
),
50.0
,
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
.
fromARGB
(
128
,
0
,
0
,
0
));
rc
.
restore
();
...
...
@@ -195,11 +194,11 @@ void testMain() async {
rc
.
drawCircle
(
Offset
(
100
,
100
),
50.0
,
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
.
fromARGB
(
128
,
0
,
0
,
0
));
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
restore
();
await
_checkScreenshot
(
rc
,
'draw_circle_below_image'
);
});
...
...
@@ -215,11 +214,11 @@ void testMain() async {
double
testHeight
=
testImage
.
height
.
toDouble
();
rc
.
clipRect
(
Rect
.
fromLTRB
(
75
,
75
,
160
,
160
),
ClipOp
.
intersect
);
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
drawCircle
(
Offset
(
100
,
100
),
50.0
,
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
.
fromARGB
(
128
,
0
,
0
,
0
));
rc
.
restore
();
...
...
@@ -241,11 +240,11 @@ void testMain() async {
rc
.
translate
(-
100
,
-
100
);
rc
.
clipRect
(
Rect
.
fromLTRB
(
75
,
75
,
160
,
160
),
ClipOp
.
intersect
);
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
drawCircle
(
Offset
(
100
,
100
),
50.0
,
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
.
fromARGB
(
128
,
0
,
0
,
0
));
rc
.
restore
();
...
...
@@ -268,11 +267,11 @@ void testMain() async {
rc
.
translate
(-
100
,
-
100
);
rc
.
clipRect
(
Rect
.
fromLTRB
(
75
,
75
,
160
,
160
),
ClipOp
.
intersect
);
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
new
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
drawCircle
(
Offset
(
100
,
100
),
50.0
,
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
.
fromARGB
(
128
,
0
,
0
,
0
));
rc
.
restore
();
...
...
@@ -291,11 +290,11 @@ void testMain() async {
double
testHeight
=
testImage
.
height
.
toDouble
();
rc
.
clipRRect
(
RRect
.
fromLTRBR
(
75
,
75
,
160
,
160
,
Radius
.
circular
(
5
)));
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
drawCircle
(
Offset
(
100
,
100
),
50.0
,
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
.
fromARGB
(
128
,
0
,
0
,
0
));
rc
.
restore
();
...
...
@@ -318,11 +317,11 @@ void testMain() async {
path
.
lineTo
(
160
,
160
);
rc
.
clipPath
(
path
);
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Paint
());
Rect
.
fromLTRB
(
100
,
30
,
2
*
testWidth
,
2
*
testHeight
),
Surface
Paint
());
rc
.
drawCircle
(
Offset
(
100
,
100
),
50.0
,
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
.
fromARGB
(
128
,
0
,
0
,
0
));
rc
.
restore
();
...
...
@@ -349,10 +348,10 @@ void testMain() async {
paragraph1
.
layout
(
const
ParagraphConstraints
(
width:
400.0
));
rc
.
drawParagraph
(
paragraph1
,
const
Offset
(
20
,
100
));
rc
.
drawImageRect
(
testImage
,
Rect
.
fromLTRB
(
0
,
0
,
testWidth
,
testHeight
),
Rect
.
fromLTRB
(
100
,
100
,
200
,
200
),
Paint
());
Rect
.
fromLTRB
(
100
,
100
,
200
,
200
),
Surface
Paint
());
rc
.
drawRect
(
Rect
.
fromLTWH
(
50
,
50
,
100
,
200
),
Paint
()
Surface
Paint
()
..
strokeWidth
=
3
..
color
=
Color
(
0xA0000000
));
final
Color
cyan
=
Color
(
0xFF0097A7
);
...
...
@@ -378,7 +377,7 @@ void testMain() async {
Image
testImage
=
createNineSliceImage
();
canvas
.
clipRect
(
Rect
.
fromLTWH
(
0
,
0
,
420
,
200
));
canvas
.
drawImageNine
(
testImage
,
Rect
.
fromLTWH
(
20
,
20
,
20
,
20
),
Rect
.
fromLTWH
(
20
,
20
,
400
,
400
),
Paint
());
Rect
.
fromLTWH
(
20
,
20
,
400
,
400
),
Surface
Paint
());
Picture
picture
=
recorder
.
endRecording
();
final
SurfaceSceneBuilder
builder
=
SurfaceSceneBuilder
();
...
...
@@ -387,8 +386,8 @@ void testMain() async {
// Wrap in <flt-scene> so that our CSS selectors kick in.
final
html
.
Element
sceneElement
=
html
.
Element
.
tag
(
'flt-scene'
);
try
{
sceneElement
.
append
(
builder
.
build
().
webOnlyRootElement
);
html
.
document
.
body
.
append
(
sceneElement
);
sceneElement
.
append
(
builder
.
build
().
webOnlyRootElement
!
);
html
.
document
.
body
!
.
append
(
sceneElement
);
await
matchGoldenFile
(
'draw_nine_slice.png'
,
region:
region
,
maxDiffRatePercent:
0
);
}
finally
{
...
...
@@ -411,7 +410,7 @@ void testMain() async {
// of the image are 40x40. Drawing into a destination that is smaller
// than that will not provide enough room to draw the center portion.
canvas
.
drawImageNine
(
testImage
,
Rect
.
fromLTWH
(
20
,
20
,
20
,
20
),
Rect
.
fromLTWH
(
20
,
20
,
36
,
36
),
Paint
());
Rect
.
fromLTWH
(
20
,
20
,
36
,
36
),
Surface
Paint
());
Picture
picture
=
recorder
.
endRecording
();
final
SurfaceSceneBuilder
builder
=
SurfaceSceneBuilder
();
...
...
@@ -420,8 +419,8 @@ void testMain() async {
// Wrap in <flt-scene> so that our CSS selectors kick in.
final
html
.
Element
sceneElement
=
html
.
Element
.
tag
(
'flt-scene'
);
try
{
sceneElement
.
append
(
builder
.
build
().
webOnlyRootElement
);
html
.
document
.
body
.
append
(
sceneElement
);
sceneElement
.
append
(
builder
.
build
().
webOnlyRootElement
!
);
html
.
document
.
body
!
.
append
(
sceneElement
);
await
matchGoldenFile
(
'draw_nine_slice_empty_center.png'
,
region:
region
,
maxDiffRatePercent:
0
);
}
finally
{
...
...
@@ -447,7 +446,7 @@ void testMain() async {
..
lineTo
(
50
,
30
)
..
lineTo
(
10
,
30
)
..
close
());
canvas
.
drawImage
(
createNineSliceImage
(),
Offset
.
zero
,
Paint
());
canvas
.
drawImage
(
createNineSliceImage
(),
Offset
.
zero
,
Surface
Paint
());
await
_checkScreenshot
(
canvas
,
'draw_clipped_and_transformed_image'
,
region:
region
,
maxDiffRatePercent:
1.0
);
});
...
...
@@ -457,12 +456,12 @@ void testMain() async {
final
Rect
region
=
const
Rect
.
fromLTRB
(
0
,
0
,
200
,
200
);
final
RecordingCanvas
canvas
=
RecordingCanvas
(
region
);
canvas
.
translate
(
10
,
10
);
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
new
Paint
());
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
Surface
Paint
());
Matrix4
transform
=
Matrix4
.
identity
()
..
setRotationY
(
0.8
)
..
setEntry
(
3
,
2
,
0.0005
);
// perspective
canvas
.
transform
(
transform
.
storage
);
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
100
),
new
Paint
());
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
100
),
Surface
Paint
());
await
_checkScreenshot
(
canvas
,
'draw_3d_image'
,
region:
region
,
maxDiffRatePercent:
6.0
,
...
...
@@ -473,17 +472,17 @@ void testMain() async {
test
(
'Should render image with perspective inside clip area'
,
()
async
{
final
Rect
region
=
const
Rect
.
fromLTRB
(
0
,
0
,
200
,
200
);
final
RecordingCanvas
canvas
=
RecordingCanvas
(
region
);
canvas
.
drawRect
(
region
,
Paint
()..
color
=
Color
(
0xFFE0E0E0
));
canvas
.
drawRect
(
region
,
Surface
Paint
()..
color
=
Color
(
0xFFE0E0E0
));
canvas
.
translate
(
10
,
10
);
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
new
Paint
());
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
0
),
Surface
Paint
());
Matrix4
transform
=
Matrix4
.
identity
()
..
setRotationY
(
0.8
)
..
setEntry
(
3
,
2
,
0.0005
);
// perspective
canvas
.
transform
(
transform
.
storage
);
canvas
.
clipRect
(
region
,
ClipOp
.
intersect
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
0
,
100
,
200
),
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
100
),
new
Paint
());
canvas
.
drawRect
(
Rect
.
fromLTWH
(
50
,
150
,
50
,
20
),
Paint
()..
color
=
Color
(
0x80000000
));
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
0
,
100
,
200
),
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawImage
(
createTestImage
(),
Offset
(
0
,
100
),
Surface
Paint
());
canvas
.
drawRect
(
Rect
.
fromLTWH
(
50
,
150
,
50
,
20
),
Surface
Paint
()..
color
=
Color
(
0x80000000
));
await
_checkScreenshot
(
canvas
,
'draw_3d_image_clipped'
,
region:
region
,
maxDiffRatePercent:
5.0
,
...
...
@@ -493,21 +492,21 @@ void testMain() async {
test
(
'Should render rect with perspective transform'
,
()
async
{
final
Rect
region
=
const
Rect
.
fromLTRB
(
0
,
0
,
400
,
400
);
final
RecordingCanvas
canvas
=
RecordingCanvas
(
region
);
canvas
.
drawRect
(
region
,
Paint
()..
color
=
Color
(
0xFFE0E0E0
));
canvas
.
drawRect
(
region
,
Surface
Paint
()..
color
=
Color
(
0xFFE0E0E0
));
canvas
.
translate
(
20
,
20
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
0
,
100
,
40
),
Paint
()..
color
=
Color
(
0xFF000000
));
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
Matrix4
transform
=
Matrix4
.
identity
()
..
setRotationY
(
0.8
)
..
setEntry
(
3
,
2
,
0.001
);
// perspective
canvas
.
transform
(
transform
.
storage
);
canvas
.
clipRect
(
region
,
ClipOp
.
intersect
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
60
,
120
,
40
),
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawRect
(
Rect
.
fromLTWH
(
300
,
250
,
120
,
40
),
Paint
()..
color
=
Color
(
0x80E010E0
));
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
60
,
120
,
40
),
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawRect
(
Rect
.
fromLTWH
(
300
,
250
,
120
,
40
),
Surface
Paint
()..
color
=
Color
(
0x80E010E0
));
canvas
.
drawRRect
(
RRect
.
fromRectAndRadius
(
Rect
.
fromLTWH
(
0
,
120
,
160
,
40
),
Radius
.
circular
(
5
)),
Paint
()..
color
=
Color
(
0x801080E0
));
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawRRect
(
RRect
.
fromRectAndRadius
(
Rect
.
fromLTWH
(
300
,
320
,
90
,
40
),
Radius
.
circular
(
20
)),
Paint
()..
color
=
Color
(
0x80E010E0
));
Surface
Paint
()..
color
=
Color
(
0x80E010E0
));
await
_checkScreenshot
(
canvas
,
'draw_3d_rect_clipped'
,
region:
region
,
maxDiffRatePercent:
1.0
,
...
...
@@ -517,22 +516,22 @@ void testMain() async {
test
(
'Should render color and ovals with perspective transform'
,
()
async
{
final
Rect
region
=
const
Rect
.
fromLTRB
(
0
,
0
,
400
,
400
);
final
RecordingCanvas
canvas
=
RecordingCanvas
(
region
);
canvas
.
drawRect
(
region
,
Paint
()..
color
=
Color
(
0xFFFF0000
));
canvas
.
drawRect
(
region
,
Surface
Paint
()..
color
=
Color
(
0xFFFF0000
));
canvas
.
drawColor
(
Color
(
0xFFE0E0E0
),
BlendMode
.
src
);
canvas
.
translate
(
20
,
20
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
0
,
100
,
40
),
Paint
()..
color
=
Color
(
0xFF000000
));
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
Matrix4
transform
=
Matrix4
.
identity
()
..
setRotationY
(
0.8
)
..
setEntry
(
3
,
2
,
0.001
);
// perspective
canvas
.
transform
(
transform
.
storage
);
canvas
.
clipRect
(
region
,
ClipOp
.
intersect
);
canvas
.
drawOval
(
Rect
.
fromLTWH
(
0
,
120
,
130
,
40
),
Paint
()..
color
=
Color
(
0x801080E0
));
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawOval
(
Rect
.
fromLTWH
(
300
,
290
,
90
,
40
),
Paint
()..
color
=
Color
(
0x80E010E0
));
canvas
.
drawCircle
(
Offset
(
60
,
240
),
50
,
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawCircle
(
Offset
(
360
,
370
),
30
,
Paint
()..
color
=
Color
(
0x80E010E0
));
Surface
Paint
()..
color
=
Color
(
0x80E010E0
));
canvas
.
drawCircle
(
Offset
(
60
,
240
),
50
,
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawCircle
(
Offset
(
360
,
370
),
30
,
Surface
Paint
()..
color
=
Color
(
0x80E010E0
));
await
_checkScreenshot
(
canvas
,
'draw_3d_oval_clipped'
,
region:
region
,
maxDiffRatePercent:
1.0
,
...
...
@@ -542,29 +541,29 @@ void testMain() async {
test
(
'Should render path with perspective transform'
,
()
async
{
final
Rect
region
=
const
Rect
.
fromLTRB
(
0
,
0
,
400
,
400
);
final
RecordingCanvas
canvas
=
RecordingCanvas
(
region
);
canvas
.
drawRect
(
region
,
Paint
()..
color
=
Color
(
0xFFFF0000
));
canvas
.
drawRect
(
region
,
Surface
Paint
()..
color
=
Color
(
0xFFFF0000
));
canvas
.
drawColor
(
Color
(
0xFFE0E0E0
),
BlendMode
.
src
);
canvas
.
translate
(
20
,
20
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
0
,
100
,
20
),
Paint
()..
color
=
Color
(
0xFF000000
));
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
Matrix4
transform
=
Matrix4
.
identity
()
..
setRotationY
(
0.8
)
..
setEntry
(
3
,
2
,
0.001
);
// perspective
canvas
.
transform
(
transform
.
storage
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
120
,
130
,
40
),
Paint
()..
color
=
Color
(
0x801080E0
));
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawOval
(
Rect
.
fromLTWH
(
300
,
290
,
90
,
40
),
Paint
()..
color
=
Color
(
0x80E010E0
));
Surface
Paint
()..
color
=
Color
(
0x80E010E0
));
Path
path
=
Path
();
path
.
moveTo
(
50
,
50
);
path
.
lineTo
(
100
,
50
);
path
.
lineTo
(
100
,
100
);
path
.
close
();
canvas
.
drawPath
(
path
,
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawPath
(
path
,
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawCircle
(
Offset
(
50
,
50
),
4
,
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
100
),
4
,
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
50
),
4
,
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
50
,
50
),
4
,
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
100
),
4
,
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
50
),
4
,
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
await
_checkScreenshot
(
canvas
,
'draw_3d_path'
,
region:
region
,
maxDiffRatePercent:
1.0
,
...
...
@@ -574,30 +573,30 @@ void testMain() async {
test
(
'Should render path with perspective transform'
,
()
async
{
final
Rect
region
=
const
Rect
.
fromLTRB
(
0
,
0
,
400
,
400
);
final
RecordingCanvas
canvas
=
RecordingCanvas
(
region
);
canvas
.
drawRect
(
region
,
Paint
()..
color
=
Color
(
0xFFFF0000
));
canvas
.
drawRect
(
region
,
Surface
Paint
()..
color
=
Color
(
0xFFFF0000
));
canvas
.
drawColor
(
Color
(
0xFFE0E0E0
),
BlendMode
.
src
);
canvas
.
translate
(
20
,
20
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
0
,
100
,
20
),
Paint
()..
color
=
Color
(
0xFF000000
));
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
Matrix4
transform
=
Matrix4
.
identity
()
..
setRotationY
(
0.8
)
..
setEntry
(
3
,
2
,
0.001
);
// perspective
canvas
.
transform
(
transform
.
storage
);
//canvas.clipRect(region, ClipOp.intersect);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0
,
120
,
130
,
40
),
Paint
()..
color
=
Color
(
0x801080E0
));
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawOval
(
Rect
.
fromLTWH
(
300
,
290
,
90
,
40
),
Paint
()..
color
=
Color
(
0x80E010E0
));
Surface
Paint
()..
color
=
Color
(
0x80E010E0
));
Path
path
=
Path
();
path
.
moveTo
(
50
,
50
);
path
.
lineTo
(
100
,
50
);
path
.
lineTo
(
100
,
100
);
path
.
close
();
canvas
.
drawPath
(
path
,
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawPath
(
path
,
Surface
Paint
()..
color
=
Color
(
0x801080E0
));
canvas
.
drawCircle
(
Offset
(
50
,
50
),
4
,
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
100
),
4
,
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
50
),
4
,
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
50
,
50
),
4
,
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
100
),
4
,
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
canvas
.
drawCircle
(
Offset
(
100
,
50
),
4
,
Surface
Paint
()..
color
=
Color
(
0xFF000000
));
await
_checkScreenshot
(
canvas
,
'draw_3d_path_clipped'
,
region:
region
,
maxDiffRatePercent:
1.0
,
...
...
lib/web_ui/test/golden_tests/engine/canvas_rect_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'package:test/bootstrap/browser.dart'
;
...
...
@@ -19,7 +18,7 @@ void main() {
void
testMain
(
)
async
{
final
Rect
region
=
Rect
.
fromLTWH
(
0
,
0
,
150
,
420
);
BitmapCanvas
canvas
;
late
BitmapCanvas
canvas
;
setUp
(()
{
canvas
=
BitmapCanvas
(
region
,
RenderStrategy
());
...
...
@@ -33,7 +32,7 @@ void testMain() async {
paintRects
(
canvas
);
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_rect_flipped.png'
,
region:
region
);
});
}
...
...
lib/web_ui/test/golden_tests/engine/canvas_rrect_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'package:test/bootstrap/browser.dart'
;
...
...
@@ -19,7 +18,7 @@ void main() {
void
testMain
(
)
async
{
final
Rect
region
=
Rect
.
fromLTWH
(
8
,
8
,
500
,
100
);
// Compensate for old scuba tester padding
BitmapCanvas
canvas
;
late
BitmapCanvas
canvas
;
final
SurfacePaintData
niceRRectPaint
=
SurfacePaintData
()
..
color
=
const
Color
.
fromRGBO
(
250
,
186
,
218
,
1.0
)
// #fabada
...
...
@@ -48,7 +47,7 @@ void testMain() async {
niceRRectPaint
);
}
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_rrect_round_square.png'
,
region:
region
);
});
...
...
@@ -61,7 +60,7 @@ void testMain() async {
Radius
.
circular
(
30
)),
niceRRectPaint
);
canvas
.
drawPath
(
Path
()..
moveTo
(
0
,
0
)..
lineTo
(
20
,
0
),
niceRRectPaint
);
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_rrect_flipped.png'
,
region:
Rect
.
fromLTWH
(
0
,
0
,
100
,
200
));
});
...
...
@@ -78,7 +77,7 @@ void testMain() async {
canvas
.
drawRRect
(
rrect
,
niceRRectPaint
);
}
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_rrect_overlapping_radius.png'
,
region:
region
);
});
...
...
@@ -101,7 +100,7 @@ void testMain() async {
canvas
.
drawDRRect
(
outerRRect
,
innerRRect
,
niceRRectPaint
);
}
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_drrect_overlapping_radius.png'
,
region:
region
);
});
}
lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'package:test/bootstrap/browser.dart'
;
...
...
@@ -19,7 +18,7 @@ void main() {
void
testMain
(
)
async
{
final
Rect
region
=
Rect
.
fromLTWH
(
0
,
0
,
300
,
300
);
BitmapCanvas
canvas
;
late
BitmapCanvas
canvas
;
setUp
(()
{
canvas
=
BitmapCanvas
(
region
,
RenderStrategy
());
...
...
@@ -33,7 +32,7 @@ void testMain() async {
paintStrokeJoins
(
canvas
);
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_stroke_joins.png'
,
region:
region
);
});
...
...
lib/web_ui/test/golden_tests/engine/canvas_stroke_rects_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'dart:math'
as
math
;
...
...
@@ -20,7 +19,7 @@ void main() {
void
testMain
(
)
async
{
final
Rect
region
=
Rect
.
fromLTWH
(
0
,
0
,
300
,
300
);
BitmapCanvas
canvas
;
late
BitmapCanvas
canvas
;
setUp
(()
{
canvas
=
BitmapCanvas
(
region
,
RenderStrategy
());
...
...
@@ -34,7 +33,7 @@ void testMain() async {
paintSideBySideRects
(
canvas
);
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_stroke_rects.png'
,
region:
region
);
});
...
...
lib/web_ui/test/golden_tests/engine/canvas_winding_rule_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'package:test/bootstrap/browser.dart'
;
...
...
@@ -19,7 +18,7 @@ void main() {
void
testMain
(
)
async
{
final
Rect
region
=
Rect
.
fromLTWH
(
0
,
0
,
500
,
500
);
BitmapCanvas
canvas
;
late
BitmapCanvas
canvas
;
setUp
(()
{
canvas
=
BitmapCanvas
(
region
,
RenderStrategy
());
...
...
@@ -31,7 +30,7 @@ void testMain() async {
test
(
'draws paths using nonzero and evenodd winding rules'
,
()
async
{
paintPaths
(
canvas
);
html
.
document
.
body
.
append
(
canvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
canvas
.
rootElement
);
await
matchGoldenFile
(
'canvas_path_winding.png'
,
region:
region
);
});
...
...
lib/web_ui/test/golden_tests/engine/clip_op_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'package:test/bootstrap/browser.dart'
;
import
'package:test/test.dart'
;
import
'package:ui/ui.dart'
;
...
...
@@ -23,7 +22,7 @@ void testMain() async {
final
Rect
region
=
const
Rect
.
fromLTRB
(
0
,
0
,
400
,
300
);
final
RecordingCanvas
canvas
=
RecordingCanvas
(
region
);
final
Rect
titleRect
=
Rect
.
fromLTWH
(
20
,
0
,
50
,
20
);
final
Paint
paint
=
Paint
()
final
SurfacePaint
paint
=
Surface
Paint
()
..
style
=
PaintingStyle
.
stroke
..
color
=
const
Color
(
0xff000000
)
..
strokeWidth
=
1
;
...
...
lib/web_ui/test/golden_tests/engine/conic_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'package:test/bootstrap/browser.dart'
;
...
...
@@ -25,13 +24,13 @@ void testMain() async {
RenderStrategy
());
final
RecordingCanvas
canvas
=
RecordingCanvas
(
canvasBounds
);
Paint
paint
=
Paint
()
SurfacePaint
paint
=
Surface
Paint
()
..
color
=
const
Color
(
0x7F7F7F7F
)
..
style
=
PaintingStyle
.
fill
;
canvas
.
drawPath
(
path
,
paint
);
paint
=
Paint
()
paint
=
Surface
Paint
()
..
strokeWidth
=
2.0
..
color
=
const
Color
(
0xFF7F007F
)
..
style
=
PaintingStyle
.
stroke
;
...
...
@@ -39,7 +38,7 @@ void testMain() async {
canvas
.
drawPath
(
path
,
paint
);
canvas
.
endRecording
();
html
.
document
.
body
.
append
(
bitmapCanvas
.
rootElement
);
html
.
document
.
body
!
.
append
(
bitmapCanvas
.
rootElement
);
canvas
.
apply
(
bitmapCanvas
,
canvasBounds
);
await
matchGoldenFile
(
'
$scubaFileName
.png'
,
region:
region
);
bitmapCanvas
.
rootElement
.
remove
();
...
...
lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'package:test/bootstrap/browser.dart'
;
...
...
@@ -23,7 +22,7 @@ void main() {
void
testMain
(
)
async
{
final
Rect
region
=
Rect
.
fromLTWH
(
0
,
0
,
550
,
300
);
SurfaceSceneBuilder
builder
;
late
SurfaceSceneBuilder
builder
;
setUpStableTestFonts
();
...
...
@@ -32,7 +31,7 @@ void testMain() async {
});
void
_paintShapeOutline
()
{
final
EnginePictureRecorder
recorder
=
PictureRecorder
();
final
EnginePictureRecorder
recorder
=
Engine
PictureRecorder
();
final
RecordingCanvas
canvas
=
recorder
.
beginRecording
(
Rect
.
largest
);
canvas
.
drawRect
(
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
20.0
,
20.0
),
...
...
@@ -81,7 +80,7 @@ void testMain() async {
..
addRect
(
const
Rect
.
fromLTRB
(
0
,
0
,
20
,
20
));
builder
.
pushOffset
(
offset
.
dx
,
offset
.
dy
);
final
EnginePictureRecorder
recorder
=
PictureRecorder
();
final
EnginePictureRecorder
recorder
=
Engine
PictureRecorder
();
final
RecordingCanvas
canvas
=
recorder
.
beginRecording
(
Rect
.
largest
);
canvas
.
debugEnforceArbitraryPaint
();
// make sure DOM canvas doesn't take over
...
...
@@ -107,7 +106,7 @@ void testMain() async {
..
close
();
builder
.
pushOffset
(
offset
.
dx
,
offset
.
dy
);
final
EnginePictureRecorder
recorder
=
PictureRecorder
();
final
EnginePictureRecorder
recorder
=
Engine
PictureRecorder
();
final
RecordingCanvas
canvas
=
recorder
.
beginRecording
(
Rect
.
largest
);
canvas
.
debugEnforceArbitraryPaint
();
// make sure DOM canvas doesn't take over
...
...
@@ -157,8 +156,8 @@ void testMain() async {
builder
.
pop
();
final
html
.
Element
sceneElement
=
builder
.
build
().
webOnlyRootElement
;
html
.
document
.
body
.
append
(
sceneElement
);
final
html
.
Element
sceneElement
=
builder
.
build
().
webOnlyRootElement
!
;
html
.
document
.
body
!
.
append
(
sceneElement
);
await
matchGoldenFile
(
'shadows.png'
,
...
...
lib/web_ui/test/text/font_collection_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:html'
as
html
;
import
'package:test/bootstrap/browser.dart'
;
...
...
@@ -16,7 +15,7 @@ void main() {
void
testMain
(
)
{
group
(
'
$FontManager
'
,
()
{
FontManager
fontManager
;
late
FontManager
fontManager
;
const
String
_testFontUrl
=
'packages/ui/assets/ahem.ttf'
;
setUp
(()
{
...
...
@@ -24,7 +23,7 @@ void testMain() {
});
tearDown
(()
{
html
.
document
.
fonts
.
clear
();
html
.
document
.
fonts
!
.
clear
();
});
group
(
'regular special characters'
,
()
{
...
...
@@ -35,9 +34,9 @@ void testMain() {
fontManager
.
registerAsset
(
_testFontFamily
,
'url(
$_testFontUrl
)'
,
const
<
String
,
String
>{});
await
fontManager
.
ensureFontsLoaded
();
html
.
document
.
fonts
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
f
,
html
.
FontFace
f2
,
html
.
FontFaceSet
s
)
{
fontFamilyList
.
add
(
f
.
family
);
fontFamilyList
.
add
(
f
.
family
!
);
});
expect
(
fontFamilyList
.
length
,
equals
(
1
));
...
...
@@ -53,9 +52,9 @@ void testMain() {
fontManager
.
registerAsset
(
_testFontFamily
,
'url(
$_testFontUrl
)'
,
const
<
String
,
String
>{});
await
fontManager
.
ensureFontsLoaded
();
html
.
document
.
fonts
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
f
,
html
.
FontFace
f2
,
html
.
FontFaceSet
s
)
{
fontFamilyList
.
add
(
f
.
family
);
fontFamilyList
.
add
(
f
.
family
!
);
});
expect
(
fontFamilyList
.
length
,
equals
(
1
));
...
...
@@ -73,9 +72,9 @@ void testMain() {
fontManager
.
registerAsset
(
_testFontFamily
,
'url(
$_testFontUrl
)'
,
const
<
String
,
String
>{});
await
fontManager
.
ensureFontsLoaded
();
html
.
document
.
fonts
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
f
,
html
.
FontFace
f2
,
html
.
FontFaceSet
s
)
{
fontFamilyList
.
add
(
f
.
family
);
fontFamilyList
.
add
(
f
.
family
!
);
});
expect
(
fontFamilyList
.
length
,
equals
(
1
));
...
...
@@ -93,9 +92,9 @@ void testMain() {
fontManager
.
registerAsset
(
_testFontFamily
,
'url(
$_testFontUrl
)'
,
const
<
String
,
String
>{});
await
fontManager
.
ensureFontsLoaded
();
html
.
document
.
fonts
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
f
,
html
.
FontFace
f2
,
html
.
FontFaceSet
s
)
{
fontFamilyList
.
add
(
f
.
family
);
fontFamilyList
.
add
(
f
.
family
!
);
});
if
(
browserEngine
!=
BrowserEngine
.
firefox
)
{
...
...
@@ -119,9 +118,9 @@ void testMain() {
fontManager
.
registerAsset
(
_testFontFamily
,
'url(
$_testFontUrl
)'
,
const
<
String
,
String
>{});
await
fontManager
.
ensureFontsLoaded
();
html
.
document
.
fonts
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
f
,
html
.
FontFace
f2
,
html
.
FontFaceSet
s
)
{
fontFamilyList
.
add
(
f
.
family
);
fontFamilyList
.
add
(
f
.
family
!
);
});
if
(
browserEngine
!=
BrowserEngine
.
firefox
)
{
...
...
@@ -145,9 +144,9 @@ void testMain() {
fontManager
.
registerAsset
(
_testFontFamily
,
'url(
$_testFontUrl
)'
,
const
<
String
,
String
>{});
await
fontManager
.
ensureFontsLoaded
();
html
.
document
.
fonts
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
f
,
html
.
FontFace
f2
,
html
.
FontFaceSet
s
)
{
fontFamilyList
.
add
(
f
.
family
);
fontFamilyList
.
add
(
f
.
family
!
);
});
if
(
browserEngine
!=
BrowserEngine
.
firefox
)
{
...
...
@@ -172,9 +171,9 @@ void testMain() {
fontManager
.
registerAsset
(
testFontFamily
,
'url(
$_testFontUrl
)'
,
const
<
String
,
String
>{});
await
fontManager
.
ensureFontsLoaded
();
html
.
document
.
fonts
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
f
,
html
.
FontFace
f2
,
html
.
FontFaceSet
s
)
{
fontFamilyList
.
add
(
f
.
family
);
fontFamilyList
.
add
(
f
.
family
!
);
});
if
(
browserEngine
!=
BrowserEngine
.
firefox
)
{
...
...
lib/web_ui/test/text/font_loading_test.dart
浏览文件 @
f49c62a9
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:html'
as
html
;
...
...
@@ -23,7 +22,7 @@ void testMain() async {
const
String
_testFontUrl
=
'packages/ui/assets/ahem.ttf'
;
tearDown
(()
{
html
.
document
.
fonts
.
clear
();
html
.
document
.
fonts
!
.
clear
();
});
test
(
'surfaces error from invalid font buffer'
,
()
async
{
...
...
@@ -53,7 +52,7 @@ void testMain() async {
browserEngine
==
BrowserEngine
.
webkit
));
test
(
'loading font should clear measurement caches'
,
()
async
{
final
ui
.
ParagraphStyle
style
=
ui
.
ParagraphStyle
();
final
EngineParagraphStyle
style
=
Engine
ParagraphStyle
();
final
ui
.
ParagraphConstraints
constraints
=
ui
.
ParagraphConstraints
(
width:
30.0
);
...
...
@@ -61,7 +60,7 @@ void testMain() async {
domBuilder
.
addText
(
'test'
);
// Triggers the measuring and verifies the result has been cached.
domBuilder
.
build
().
layout
(
constraints
);
expect
(
TextMeasurementService
.
rulerManager
.
rulers
.
length
,
1
);
expect
(
TextMeasurementService
.
rulerManager
!
.
rulers
.
length
,
1
);
final
CanvasParagraphBuilder
canvasBuilder
=
CanvasParagraphBuilder
(
style
);
canvasBuilder
.
addText
(
'test'
);
...
...
@@ -79,7 +78,7 @@ void testMain() async {
// Verifies the font is loaded, and the cache is cleaned.
expect
(
_containsFontFamily
(
'Blehm'
),
isTrue
);
expect
(
TextMeasurementService
.
rulerManager
.
rulers
.
length
,
0
);
expect
(
TextMeasurementService
.
rulerManager
!
.
rulers
.
length
,
0
);
expect
(
Spanometer
.
rulers
.
length
,
0
);
},
// TODO(nurhan): https://github.com/flutter/flutter/issues/56702
...
...
@@ -88,13 +87,13 @@ void testMain() async {
browserEngine
==
BrowserEngine
.
webkit
));
test
(
'loading font should send font change message'
,
()
async
{
final
ui
.
PlatformMessageCallback
oldHandler
=
ui
.
window
.
onPlatformMessage
;
String
actualName
;
String
message
;
window
.
onPlatformMessage
=
(
String
name
,
ByteData
data
,
ui
.
PlatformMessageResponseCallback
callback
)
{
final
ui
.
PlatformMessageCallback
?
oldHandler
=
ui
.
window
.
onPlatformMessage
;
String
?
actualName
;
String
?
message
;
window
.
onPlatformMessage
=
(
String
name
,
ByteData
?
data
,
ui
.
PlatformMessageResponseCallback
?
callback
)
{
actualName
=
name
;
final
buffer
=
data
.
buffer
;
final
buffer
=
data
!
.
buffer
;
final
Uint8List
list
=
buffer
.
asUint8List
(
data
.
offsetInBytes
,
data
.
lengthInBytes
);
message
=
utf8
.
decode
(
list
);
...
...
@@ -120,7 +119,7 @@ void testMain() async {
bool
_containsFontFamily
(
String
family
)
{
bool
found
=
false
;
html
.
document
.
fonts
.
forEach
((
html
.
FontFace
fontFace
,
html
.
document
.
fonts
!
.
forEach
((
html
.
FontFace
fontFace
,
html
.
FontFace
fontFaceAgain
,
html
.
FontFaceSet
fontFaceSet
)
{
if
(
fontFace
.
family
==
family
)
{
found
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录