Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
6179ac63
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,发现更多精彩内容 >>
未验证
提交
6179ac63
编写于
1月 11, 2019
作者:
D
Dan Field
提交者:
GitHub
1月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix up analysis for Dart in Engine (#7404)
* fix up analysis for Dart in Engine, particularly for tests
上级
bec12d84
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
208 addition
and
189 deletion
+208
-189
analysis_options.yaml
analysis_options.yaml
+1
-4
ci/analyze.sh
ci/analyze.sh
+1
-7
lib/ui/hooks.dart
lib/ui/hooks.dart
+15
-0
lib/ui/natives.dart
lib/ui/natives.dart
+6
-4
lib/ui/ui.dart
lib/ui/ui.dart
+2
-2
runtime/fixtures/simple_main.dart
runtime/fixtures/simple_main.dart
+1
-1
testing/dart/canvas_test.dart
testing/dart/canvas_test.dart
+24
-23
testing/dart/codec_test.dart
testing/dart/codec_test.dart
+35
-36
testing/dart/color_test.dart
testing/dart/color_test.dart
+7
-7
testing/dart/encoding_test.dart
testing/dart/encoding_test.dart
+39
-35
testing/dart/gradient_test.dart
testing/dart/gradient_test.dart
+1
-2
testing/dart/isolate_name_server_test.dart
testing/dart/isolate_name_server_test.dart
+17
-18
testing/dart/locale_test.dart
testing/dart/locale_test.dart
+13
-13
testing/dart/paragraph_builder_test.dart
testing/dart/paragraph_builder_test.dart
+1
-1
testing/dart/path_test.dart
testing/dart/path_test.dart
+2
-2
testing/dart/plugin_utilities_test.dart
testing/dart/plugin_utilities_test.dart
+8
-8
testing/dart/pubspec.yaml
testing/dart/pubspec.yaml
+6
-0
testing/dart/rect_test.dart
testing/dart/rect_test.dart
+18
-18
testing/dart/window_hooks_integration_test.dart
testing/dart/window_hooks_integration_test.dart
+4
-5
testing/dart/window_test.dart
testing/dart/window_test.dart
+1
-1
testing/run_tests.sh
testing/run_tests.sh
+1
-1
testing/smoke_test_failure/fail_test.dart
testing/smoke_test_failure/fail_test.dart
+0
-0
testing/smoke_test_failure/pubspec.yaml
testing/smoke_test_failure/pubspec.yaml
+4
-0
testing/symbols/verify_exported.dart
testing/symbols/verify_exported.dart
+1
-1
未找到文件。
analysis_options.yaml
浏览文件 @
6179ac63
...
...
@@ -10,9 +10,6 @@
# private fields, especially on the Window object):
analyzer
:
language
:
enableStrictCallChecks
:
true
enableSuperMixins
:
true
strong-mode
:
implicit-dynamic
:
false
errors
:
...
...
@@ -20,6 +17,7 @@ analyzer:
missing_required_param
:
warning
# treat missing returns as a warning (not a hint)
missing_return
:
warning
native_function_body_in_non_sdk_code
:
ignore
# allow having TODOs in the code
todo
:
ignore
# `flutter analyze` (without `--watch`) just ignores directories
...
...
@@ -94,7 +92,6 @@ linter:
# - parameter_assignments # we do this commonly
-
prefer_adjacent_string_concatenation
-
prefer_asserts_in_initializer_lists
-
prefer_bool_in_asserts
-
prefer_collection_literals
-
prefer_conditional_assignment
-
prefer_const_constructors
...
...
ci/analyze.sh
浏览文件 @
6179ac63
...
...
@@ -4,13 +4,7 @@ RESULTS=`dartanalyzer \
--options
flutter/analysis_options.yaml
\
out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart
\
2>&1
\
|
grep
-v
"Native functions can only be declared in the SDK and code that is loaded through native extensions"
\
|
grep
-Ev
"The function '.+' (is not|isn't) used"
\
|
grep
-Ev
"The top level variable '.+' isn't used"
\
|
grep
-Ev
"Undefined name 'main'"
\
|
grep
-v
"The library 'dart:_internal' is internal"
\
|
grep
-Ev
"Unused import.+ui
\.
dart"
\
|
grep
-Ev
"[0-9]+ errors.*found
\.
"
\
|
grep
-Ev
"No issues found!"
\
|
grep
-Ev
"Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui
\.
dart"
`
echo
"
$RESULTS
"
...
...
lib/ui/hooks.dart
浏览文件 @
6179ac63
...
...
@@ -2,17 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(dnfield): Remove unused_import ignores when https://github.com/dart-lang/sdk/issues/35164 is resolved.
part of
dart
.
ui
;
// ignore: unused_element
String
_decodeUTF8
(
ByteData
message
)
{
return
message
!=
null
?
utf8
.
decoder
.
convert
(
message
.
buffer
.
asUint8List
())
:
null
;
}
// ignore: unused_element
dynamic
_decodeJSON
(
String
message
)
{
return
message
!=
null
?
json
.
decode
(
message
)
:
null
;
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_updateWindowMetrics
(
double
devicePixelRatio
,
double
width
,
double
height
,
...
...
@@ -50,9 +55,11 @@ String _localeClosure() {
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
_LocaleClosure
_getLocaleClosure
(
)
=>
_localeClosure
;
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_updateLocales
(
List
<
String
>
locales
)
{
const
int
stringsPerLocale
=
4
;
final
int
numLocales
=
locales
.
length
~/
stringsPerLocale
;
...
...
@@ -71,6 +78,7 @@ void _updateLocales(List<String> locales) {
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_updateUserSettingsData
(
String
jsonData
)
{
final
Map
<
String
,
dynamic
>
data
=
json
.
decode
(
jsonData
);
if
(
data
.
isEmpty
)
{
...
...
@@ -90,12 +98,14 @@ void _updateAlwaysUse24HourFormat(bool alwaysUse24HourFormat) {
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_updateSemanticsEnabled
(
bool
enabled
)
{
window
.
_semanticsEnabled
=
enabled
;
_invoke
(
window
.
onSemanticsEnabledChanged
,
window
.
_onSemanticsEnabledChangedZone
);
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_updateAccessibilityFeatures
(
int
values
)
{
final
AccessibilityFeatures
newFeatures
=
new
AccessibilityFeatures
.
_
(
values
);
if
(
newFeatures
==
window
.
_accessibilityFeatures
)
...
...
@@ -122,12 +132,14 @@ void _dispatchPlatformMessage(String name, ByteData data, int responseId) {
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_dispatchPointerDataPacket
(
ByteData
packet
)
{
if
(
window
.
onPointerDataPacket
!=
null
)
_invoke1
<
PointerDataPacket
>(
window
.
onPointerDataPacket
,
window
.
_onPointerDataPacketZone
,
_unpackPointerDataPacket
(
packet
));
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_dispatchSemanticsAction
(
int
id
,
int
action
,
ByteData
args
)
{
_invoke3
<
int
,
SemanticsAction
,
ByteData
>(
window
.
onSemanticsAction
,
...
...
@@ -139,11 +151,13 @@ void _dispatchSemanticsAction(int id, int action, ByteData args) {
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_beginFrame
(
int
microseconds
)
{
_invoke1
<
Duration
>(
window
.
onBeginFrame
,
window
.
_onBeginFrameZone
,
new
Duration
(
microseconds:
microseconds
));
}
@pragma
(
'vm:entry-point'
)
// ignore: unused_element
void
_drawFrame
(
)
{
_invoke
(
window
.
onDrawFrame
,
window
.
_onDrawFrameZone
);
}
...
...
@@ -177,6 +191,7 @@ void _invoke1<A>(void callback(A a), Zone zone, A arg) {
}
/// Invokes [callback] inside the given [zone] passing it [arg1] and [arg2].
// ignore: unused_element
void
_invoke2
<
A1
,
A2
>(
void
callback
(
A1
a1
,
A2
a2
),
Zone
zone
,
A1
arg1
,
A2
arg2
)
{
if
(
callback
==
null
)
return
;
...
...
lib/ui/natives.dart
浏览文件 @
6179ac63
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(dnfield): remove unused_element ignores when https://github.com/dart-lang/sdk/issues/35164 is resolved.
part of
dart
.
ui
;
// Corelib 'print' implementation.
...
...
@@ -28,7 +30,7 @@ Future<developer.ServiceExtensionResponse> _scheduleFrame(
}
@pragma
(
'vm:entry-point'
)
void
_setupHooks
(
)
{
void
_setupHooks
(
)
{
// ignore: unused_element
assert
(()
{
// In debug mode, register the schedule frame extension.
developer
.
registerExtension
(
'ext.ui.window.scheduleFrame'
,
_scheduleFrame
);
...
...
@@ -67,9 +69,9 @@ int _getCallbackHandle(Function closure) native 'GetCallbackHandle';
Function
_getCallbackFromHandle
(
int
handle
)
native
'GetCallbackFromHandle'
;
// Required for gen_snapshot to work correctly.
int
_isolateId
;
int
_isolateId
;
// ignore: unused_element
@pragma
(
'vm:entry-point'
)
Function
_getPrintClosure
(
)
=>
_print
;
Function
_getPrintClosure
(
)
=>
_print
;
// ignore: unused_element
@pragma
(
'vm:entry-point'
)
Function
_getScheduleMicrotaskClosure
(
)
=>
_scheduleMicrotask
;
Function
_getScheduleMicrotaskClosure
(
)
=>
_scheduleMicrotask
;
// ignore: unused_element
lib/ui/ui.dart
浏览文件 @
6179ac63
...
...
@@ -11,12 +11,12 @@
/// text, layout, and rendering subsystems.
library
dart
.
ui
;
import
'dart:_internal'
hide
Symbol
;
import
'dart:_internal'
hide
Symbol
;
// ignore: import_internal_library, unused_import
import
'dart:async'
;
import
'dart:collection'
as
collection
;
import
'dart:convert'
;
import
'dart:developer'
as
developer
;
import
'dart:io'
;
import
'dart:io'
;
// ignore: unused_import
import
'dart:isolate'
show
SendPort
;
import
'dart:math'
as
math
;
import
'dart:nativewrappers'
;
...
...
runtime/fixtures/simple_main.dart
浏览文件 @
6179ac63
...
...
@@ -3,5 +3,5 @@
// found in the LICENSE file.
void
main
(
)
{
print
(
"Hello"
);
print
(
'Hello'
);
}
testing/dart/canvas_test.dart
浏览文件 @
6179ac63
...
...
@@ -2,51 +2,52 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
;
import
'dart:typed_data'
;
import
'dart:ui'
;
import
'package:test/test.dart'
;
typedef
void
CanvasCallback
(
Canvas
canvas
);
typedef
CanvasCallback
=
void
Function
(
Canvas
canvas
);
void
testCanvas
(
CanvasCallback
callback
)
{
try
{
callback
(
Canvas
(
PictureRecorder
(),
Rect
.
fromLTRB
(
0.0
,
0.0
,
0.0
,
0.0
)));
}
catch
(
error
)
{
}
}
catch
(
error
)
{
}
// ignore: empty_catches
}
void
main
(
)
{
test
(
"canvas APIs should not crash"
,
()
{
Paint
paint
=
Paint
();
Rect
rect
=
Rect
.
fromLTRB
(
double
.
nan
,
double
.
nan
,
double
.
nan
,
double
.
nan
);
RRect
rrect
=
RRect
.
fromRectAndCorners
(
rect
);
Offset
offset
=
Offset
(
double
.
nan
,
double
.
nan
);
Path
path
=
Path
();
Color
color
=
Color
(
0
);
Paragraph
paragraph
=
ParagraphBuilder
(
ParagraphStyle
()).
build
();
test
(
'canvas APIs should not crash'
,
()
{
final
Paint
paint
=
Paint
();
final
Rect
rect
=
Rect
.
fromLTRB
(
double
.
nan
,
double
.
nan
,
double
.
nan
,
double
.
nan
);
final
RRect
rrect
=
RRect
.
fromRectAndCorners
(
rect
);
const
Offset
offset
=
Offset
(
double
.
nan
,
double
.
nan
);
final
Path
path
=
Path
();
const
Color
color
=
Color
(
0
);
final
Paragraph
paragraph
=
ParagraphBuilder
(
ParagraphStyle
()).
build
();
PictureRecorder
recorder
=
PictureRecorder
();
Canvas
recorderCanvas
=
Canvas
(
recorder
);
Picture
picture
=
recorder
.
endRecording
();
Image
image
=
picture
.
toImage
(
1
,
1
);
final
PictureRecorder
recorder
=
PictureRecorder
();
final
Canvas
recorderCanvas
=
Canvas
(
recorder
);
recorderCanvas
.
scale
(
1.0
,
1.0
);
final
Picture
picture
=
recorder
.
endRecording
();
final
Image
image
=
picture
.
toImage
(
1
,
1
);
try
{
Canvas
(
null
,
null
);
}
catch
(
error
)
{
}
try
{
Canvas
(
null
,
rect
);
}
catch
(
error
)
{
}
try
{
Canvas
(
PictureRecorder
(),
null
);
}
catch
(
error
)
{
}
try
{
Canvas
(
PictureRecorder
(),
rect
);
}
catch
(
error
)
{
}
try
{
Canvas
(
null
,
null
);
}
catch
(
error
)
{
}
// ignore: empty_catches
try
{
Canvas
(
null
,
rect
);
}
catch
(
error
)
{
}
// ignore: empty_catches
try
{
Canvas
(
PictureRecorder
(),
null
);
}
catch
(
error
)
{
}
// ignore: empty_catches
try
{
Canvas
(
PictureRecorder
(),
rect
);
}
catch
(
error
)
{
}
// ignore: empty_catches
try
{
PictureRecorder
()
..
endRecording
()
..
endRecording
()
..
endRecording
();
}
catch
(
error
)
{
}
}
catch
(
error
)
{
}
// ignore: empty_catches
testCanvas
((
Canvas
canvas
)
=>
canvas
.
clipPath
(
path
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
clipRect
(
rect
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
clipRRect
(
rrect
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawArc
(
rect
,
0.0
,
0.0
,
false
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawAtlas
(
image
,
[],
[],
[],
BlendMode
.
src
,
rect
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawAtlas
(
image
,
<
RSTransform
>[],
<
Rect
>[],
<
Color
>
[],
BlendMode
.
src
,
rect
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawCircle
(
offset
,
double
.
nan
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawColor
(
color
,
BlendMode
.
src
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawDRRect
(
rrect
,
rrect
,
paint
));
...
...
@@ -59,7 +60,7 @@ void main() {
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawParagraph
(
paragraph
,
offset
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawPath
(
path
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawPicture
(
picture
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawPoints
(
PointMode
.
points
,
[],
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawPoints
(
PointMode
.
points
,
<
Offset
>
[],
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawRawAtlas
(
image
,
Float32List
(
0
),
Float32List
(
0
),
Int32List
(
0
),
BlendMode
.
src
,
rect
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawRawPoints
(
PointMode
.
points
,
Float32List
(
0
),
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawRect
(
rect
,
paint
));
...
...
@@ -67,7 +68,7 @@ void main() {
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawShadow
(
path
,
color
,
double
.
nan
,
null
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawShadow
(
path
,
color
,
double
.
nan
,
false
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawShadow
(
path
,
color
,
double
.
nan
,
true
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawVertices
(
Vertices
(
VertexMode
.
triangles
,
[]),
null
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
drawVertices
(
Vertices
(
VertexMode
.
triangles
,
<
Offset
>
[]),
null
,
paint
));
testCanvas
((
Canvas
canvas
)
=>
canvas
.
getSaveCount
());
testCanvas
((
Canvas
canvas
)
=>
canvas
.
restore
());
testCanvas
((
Canvas
canvas
)
=>
canvas
.
rotate
(
double
.
nan
));
...
...
testing/dart/codec_test.dart
浏览文件 @
6179ac63
...
...
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'dart:ui'
as
ui
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:test/test.dart'
;
import
'package:path/path.dart'
as
path
;
...
...
@@ -27,7 +26,7 @@ void main() {
});
test
(
'Fails with invalid data'
,
()
async
{
Uint8List
data
=
new
Uint8List
.
fromList
(
[
1
,
2
,
3
]);
final
Uint8List
data
=
Uint8List
.
fromList
(<
int
>
[
1
,
2
,
3
]);
expect
(
ui
.
instantiateImageCodec
(
data
),
throwsA
(
exceptionWithMessage
(
'operation failed'
))
...
...
@@ -35,64 +34,64 @@ void main() {
});
test
(
'nextFrame'
,
()
async
{
Uint8List
data
=
await
_getSkiaResource
(
'test640x479.gif'
).
readAsBytes
();
ui
.
Codec
codec
=
await
ui
.
instantiateImageCodec
(
data
);
List
<
List
<
int
>>
decodedFrameInfos
=
[];
final
Uint8List
data
=
await
_getSkiaResource
(
'test640x479.gif'
).
readAsBytes
();
final
ui
.
Codec
codec
=
await
ui
.
instantiateImageCodec
(
data
);
final
List
<
List
<
int
>>
decodedFrameInfos
=
<
List
<
int
>>
[];
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
ui
.
FrameInfo
frameInfo
=
await
codec
.
getNextFrame
();
decodedFrameInfos
.
add
([
final
ui
.
FrameInfo
frameInfo
=
await
codec
.
getNextFrame
();
decodedFrameInfos
.
add
(
<
int
>
[
frameInfo
.
duration
.
inMilliseconds
,
frameInfo
.
image
.
width
,
frameInfo
.
image
.
height
,
]);
}
expect
(
decodedFrameInfos
,
equals
([
[
200
,
640
,
479
],
[
200
,
640
,
479
],
[
200
,
640
,
479
],
[
200
,
640
,
479
],
[
200
,
640
,
479
],
expect
(
decodedFrameInfos
,
equals
(
<
List
<
int
>>
[
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
]));
});
test
(
'decodedCacheRatioCap'
,
()
async
{
// No real way to test the native layer, but a smoke test here to at least
// verify that animation is still consistent with caching disabled.
Uint8List
data
=
await
_getSkiaResource
(
'test640x479.gif'
).
readAsBytes
();
ui
.
Codec
codec
=
await
ui
.
instantiateImageCodec
(
data
,
decodedCacheRatioCap:
1.0
);
List
<
List
<
int
>>
decodedFrameInfos
=
[];
final
Uint8List
data
=
await
_getSkiaResource
(
'test640x479.gif'
).
readAsBytes
();
final
ui
.
Codec
codec
=
await
ui
.
instantiateImageCodec
(
data
,
decodedCacheRatioCap:
1.0
);
final
List
<
List
<
int
>>
decodedFrameInfos
=
<
List
<
int
>>
[];
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
ui
.
FrameInfo
frameInfo
=
await
codec
.
getNextFrame
();
decodedFrameInfos
.
add
([
final
ui
.
FrameInfo
frameInfo
=
await
codec
.
getNextFrame
();
decodedFrameInfos
.
add
(
<
int
>
[
frameInfo
.
duration
.
inMilliseconds
,
frameInfo
.
image
.
width
,
frameInfo
.
image
.
height
,
]);
}
expect
(
decodedFrameInfos
,
equals
([
[
200
,
640
,
479
],
[
200
,
640
,
479
],
[
200
,
640
,
479
],
[
200
,
640
,
479
],
[
200
,
640
,
479
],
expect
(
decodedFrameInfos
,
equals
(
<
List
<
int
>>
[
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
<
int
>
[
200
,
640
,
479
],
]));
});
test
(
'non animated image'
,
()
async
{
Uint8List
data
=
await
_getSkiaResource
(
'baby_tux.png'
).
readAsBytes
();
ui
.
Codec
codec
=
await
ui
.
instantiateImageCodec
(
data
);
List
<
List
<
int
>>
decodedFrameInfos
=
[];
final
Uint8List
data
=
await
_getSkiaResource
(
'baby_tux.png'
).
readAsBytes
();
final
ui
.
Codec
codec
=
await
ui
.
instantiateImageCodec
(
data
);
final
List
<
List
<
int
>>
decodedFrameInfos
=
<
List
<
int
>>
[];
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
ui
.
FrameInfo
frameInfo
=
await
codec
.
getNextFrame
();
decodedFrameInfos
.
add
([
final
ui
.
FrameInfo
frameInfo
=
await
codec
.
getNextFrame
();
decodedFrameInfos
.
add
(
<
int
>
[
frameInfo
.
duration
.
inMilliseconds
,
frameInfo
.
image
.
width
,
frameInfo
.
image
.
height
,
]);
}
expect
(
decodedFrameInfos
,
equals
([
[
0
,
240
,
246
],
[
0
,
240
,
246
],
expect
(
decodedFrameInfos
,
equals
(
<
List
<
int
>>
[
<
int
>
[
0
,
240
,
246
],
<
int
>
[
0
,
240
,
246
],
]));
});
}
...
...
@@ -104,13 +103,13 @@ File _getSkiaResource(String fileName) {
// assuming the curent working directory is engine/src.
// This is fragile and should be changed once the Platform.script issue is
// resolved.
String
assetPath
=
final
String
assetPath
=
path
.
join
(
'third_party'
,
'skia'
,
'resources'
,
'images'
,
fileName
);
return
new
File
(
assetPath
);
return
File
(
assetPath
);
}
Matcher
exceptionWithMessage
(
String
m
)
{
return
predicate
((
e
)
{
return
predicate
<
Exception
>((
Exception
e
)
{
return
e
is
Exception
&&
e
.
toString
().
contains
(
m
);
});
}
testing/dart/color_test.dart
浏览文件 @
6179ac63
...
...
@@ -12,7 +12,7 @@ class NotAColor extends Color {
void
main
(
)
{
test
(
'color accessors should work'
,
()
{
final
Color
foo
=
const
Color
(
0x12345678
);
const
Color
foo
=
Color
(
0x12345678
);
expect
(
foo
.
alpha
,
equals
(
0x12
));
expect
(
foo
.
red
,
equals
(
0x34
));
expect
(
foo
.
green
,
equals
(
0x56
));
...
...
@@ -20,7 +20,7 @@ void main() {
});
test
(
'paint set to black'
,
()
{
final
Color
c
=
const
Color
(
0x00000000
);
const
Color
c
=
Color
(
0x00000000
);
final
Paint
p
=
new
Paint
();
p
.
color
=
c
;
expect
(
c
.
toString
(),
equals
(
'Color(0x00000000)'
));
...
...
@@ -28,7 +28,7 @@ void main() {
test
(
'color created with out of bounds value'
,
()
{
try
{
final
Color
c
=
const
Color
(
0x100
<<
24
);
const
Color
c
=
Color
(
0x100
<<
24
);
final
Paint
p
=
new
Paint
();
p
.
color
=
c
;
}
catch
(
e
)
{
...
...
@@ -38,7 +38,7 @@ void main() {
test
(
'color created with wildly out of bounds value'
,
()
{
try
{
final
Color
c
=
const
Color
(
1
<<
1000000
);
const
Color
c
=
Color
(
1
<<
1000000
);
final
Paint
p
=
new
Paint
();
p
.
color
=
c
;
}
catch
(
e
)
{
...
...
@@ -48,7 +48,7 @@ void main() {
test
(
'two colors are only == if they have the same runtime type'
,
()
{
expect
(
const
Color
(
123
),
equals
(
const
Color
(
123
)));
expect
(
const
Color
(
123
),
equals
(
new
Color
(
123
)));
expect
(
const
Color
(
123
),
equals
(
Color
(
123
)));
// ignore: prefer_const_constructors
expect
(
const
Color
(
123
),
isNot
(
equals
(
const
Color
(
321
))));
expect
(
const
Color
(
123
),
isNot
(
equals
(
const
NotAColor
(
123
))));
expect
(
const
NotAColor
(
123
),
isNot
(
equals
(
const
Color
(
123
))));
...
...
@@ -123,14 +123,14 @@ void main() {
test
(
'compute gray luminance'
,
()
{
// Each color component is at 20%.
final
Color
lightGray
=
const
Color
(
0xFF333333
);
const
Color
lightGray
=
Color
(
0xFF333333
);
// Relative luminance's formula is just the linearized color value for gray.
// ((0.2 + 0.055) / 1.055) ^ 2.4.
expect
(
lightGray
.
computeLuminance
(),
equals
(
0.033104766570885055
));
});
test
(
'compute color luminance'
,
()
{
final
Color
brightRed
=
const
Color
(
0xFFFF3B30
);
const
Color
brightRed
=
Color
(
0xFFFF3B30
);
// 0.2126 * ((1.0 + 0.055) / 1.055) ^ 2.4 +
// 0.7152 * ((0.23137254902 +0.055) / 1.055) ^ 2.4 +
// 0.0722 * ((0.18823529411 + 0.055) / 1.055) ^ 2.4
...
...
testing/dart/encoding_test.dart
浏览文件 @
6179ac63
...
...
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:ui'
;
import
'dart:typed_data'
;
import
'dart:io'
;
import
'dart:typed_data'
;
import
'dart:ui'
;
import
'package:path/path.dart'
as
path
;
import
'package:test/test.dart'
;
...
...
@@ -20,14 +20,14 @@ void main() {
group
(
'Image.toByteData'
,
()
{
group
(
'RGBA format'
,
()
{
test
(
'works with simple image'
,
()
async
{
ByteData
data
=
await
Square4x4Image
.
image
.
toByteData
();
expect
(
new
Uint8List
.
view
(
data
.
buffer
),
Square4x4Image
.
bytes
);
final
ByteData
data
=
await
Square4x4Image
.
image
.
toByteData
();
expect
(
Uint8List
.
view
(
data
.
buffer
),
Square4x4Image
.
bytes
);
});
test
(
'converts grayscale images'
,
()
async
{
Image
image
=
await
GrayscaleImage
.
load
();
ByteData
data
=
await
image
.
toByteData
();
Uint8List
bytes
=
data
.
buffer
.
asUint8List
();
final
Image
image
=
await
GrayscaleImage
.
load
();
final
ByteData
data
=
await
image
.
toByteData
();
final
Uint8List
bytes
=
data
.
buffer
.
asUint8List
();
expect
(
bytes
,
hasLength
(
16
));
expect
(
bytes
,
GrayscaleImage
.
bytesAsRgba
);
});
...
...
@@ -35,15 +35,15 @@ void main() {
group
(
'Unmodified format'
,
()
{
test
(
'works with simple image'
,
()
async
{
Image
image
=
Square4x4Image
.
image
;
ByteData
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
rawUnmodified
);
expect
(
new
Uint8List
.
view
(
data
.
buffer
),
Square4x4Image
.
bytes
);
final
Image
image
=
Square4x4Image
.
image
;
final
ByteData
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
rawUnmodified
);
expect
(
Uint8List
.
view
(
data
.
buffer
),
Square4x4Image
.
bytes
);
});
test
(
'works with grayscale images'
,
()
async
{
Image
image
=
await
GrayscaleImage
.
load
();
ByteData
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
rawUnmodified
);
Uint8List
bytes
=
data
.
buffer
.
asUint8List
();
final
Image
image
=
await
GrayscaleImage
.
load
();
final
ByteData
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
rawUnmodified
);
final
Uint8List
bytes
=
data
.
buffer
.
asUint8List
();
expect
(
bytes
,
hasLength
(
4
));
expect
(
bytes
,
GrayscaleImage
.
bytesUnmodified
);
});
...
...
@@ -51,46 +51,48 @@ void main() {
group
(
'PNG format'
,
()
{
test
(
'works with simple image'
,
()
async
{
Image
image
=
Square4x4Image
.
image
;
ByteData
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
png
);
List
<
int
>
expected
=
await
readFile
(
'square.png'
);
expect
(
new
Uint8List
.
view
(
data
.
buffer
),
expected
);
final
Image
image
=
Square4x4Image
.
image
;
final
ByteData
data
=
await
image
.
toByteData
(
format:
ImageByteFormat
.
png
);
final
List
<
int
>
expected
=
await
readFile
(
'square.png'
);
expect
(
Uint8List
.
view
(
data
.
buffer
),
expected
);
});
});
});
}
class
Square4x4Image
{
Square4x4Image
.
_
();
static
Image
get
image
{
double
width
=
_kWidth
.
toDouble
();
double
radius
=
_kRadius
.
toDouble
();
double
innerWidth
=
(
_kWidth
-
2
*
_kRadius
).
toDouble
();
final
double
width
=
_kWidth
.
toDouble
();
final
double
radius
=
_kRadius
.
toDouble
();
final
double
innerWidth
=
(
_kWidth
-
2
*
_kRadius
).
toDouble
();
PictureRecorder
recorder
=
new
PictureRecorder
();
Canvas
canvas
=
new
Canvas
(
recorder
,
new
Rect
.
fromLTWH
(
0.0
,
0.0
,
width
,
width
));
final
PictureRecorder
recorder
=
PictureRecorder
();
final
Canvas
canvas
=
Canvas
(
recorder
,
Rect
.
fromLTWH
(
0.0
,
0.0
,
width
,
width
));
Paint
black
=
new
Paint
()
final
Paint
black
=
Paint
()
..
strokeWidth
=
1.0
..
color
=
_kBlack
;
Paint
green
=
new
Paint
()
final
Paint
green
=
Paint
()
..
strokeWidth
=
1.0
..
color
=
_kGreen
;
canvas
.
drawRect
(
new
Rect
.
fromLTWH
(
0.0
,
0.0
,
width
,
width
),
black
);
canvas
.
drawRect
(
Rect
.
fromLTWH
(
0.0
,
0.0
,
width
,
width
),
black
);
canvas
.
drawRect
(
new
Rect
.
fromLTWH
(
radius
,
radius
,
innerWidth
,
innerWidth
),
green
);
Rect
.
fromLTWH
(
radius
,
radius
,
innerWidth
,
innerWidth
),
green
);
return
recorder
.
endRecording
().
toImage
(
_kWidth
,
_kWidth
);
}
static
List
<
int
>
get
bytes
{
int
bytesPerChannel
=
4
;
List
<
int
>
result
=
new
List
<
int
>(
_kWidth
*
_kWidth
*
bytesPerChannel
);
const
int
bytesPerChannel
=
4
;
final
List
<
int
>
result
=
List
<
int
>(
_kWidth
*
_kWidth
*
bytesPerChannel
);
fillWithColor
(
Color
color
,
int
min
,
int
max
)
{
void
fillWithColor
(
Color
color
,
int
min
,
int
max
)
{
for
(
int
i
=
min
;
i
<
max
;
i
++)
{
for
(
int
j
=
min
;
j
<
max
;
j
++)
{
int
offset
=
i
*
bytesPerChannel
+
j
*
_kWidth
*
bytesPerChannel
;
final
int
offset
=
i
*
bytesPerChannel
+
j
*
_kWidth
*
bytesPerChannel
;
result
[
offset
]
=
color
.
red
;
result
[
offset
+
1
]
=
color
.
green
;
result
[
offset
+
2
]
=
color
.
blue
;
...
...
@@ -107,9 +109,11 @@ class Square4x4Image {
}
class
GrayscaleImage
{
GrayscaleImage
.
_
();
static
Future
<
Image
>
load
()
async
{
Uint8List
bytes
=
await
readFile
(
'4x4.png'
);
Completer
<
Image
>
completer
=
new
Completer
<
Image
>();
final
Uint8List
bytes
=
await
readFile
(
'4x4.png'
);
final
Completer
<
Image
>
completer
=
Completer
<
Image
>();
decodeImageFromList
(
bytes
,
(
Image
image
)
=>
completer
.
complete
(
image
));
return
await
completer
.
future
;
}
...
...
@@ -126,7 +130,7 @@ class GrayscaleImage {
static
List
<
int
>
get
bytesUnmodified
=>
<
int
>[
255
,
127
,
127
,
0
];
}
Future
<
Uint8List
>
readFile
(
fileName
)
async
{
final
file
=
new
File
(
path
.
join
(
'flutter'
,
'testing'
,
'resources'
,
fileName
));
Future
<
Uint8List
>
readFile
(
String
fileName
)
async
{
final
File
file
=
File
(
path
.
join
(
'flutter'
,
'testing'
,
'resources'
,
fileName
));
return
await
file
.
readAsBytes
();
}
testing/dart/gradient_test.dart
浏览文件 @
6179ac63
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:typed_data'
show
Float64List
;
import
'dart:ui'
;
import
'package:test/test.dart'
;
...
...
@@ -66,7 +65,7 @@ void main() {
Offset
.
zero
,
1.0
,
),
throwsA
(
const
isInstanceOf
<
AssertionError
>()),
throwsA
(
const
TypeMatcher
<
AssertionError
>()),
);
});
}
testing/dart/isolate_name_server_test.dart
浏览文件 @
6179ac63
...
...
@@ -2,24 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:isolate'
;
import
'dart:ui'
;
import
'package:test/test.dart'
;
const
kPortName
=
'foobar'
;
const
kErrorCode
=
-
1
;
const
kStartCode
=
0
;
const
kCloseCode
=
1
;
const
kDeletedCode
=
2
;
const
String
kPortName
=
'foobar'
;
const
int
kErrorCode
=
-
1
;
const
int
kStartCode
=
0
;
const
int
kCloseCode
=
1
;
const
int
kDeletedCode
=
2
;
void
isolateSpawnEntrypoint
(
SendPort
port
)
{
sendHelper
(
int
code
,
[
String
message
=
''
])
{
void
sendHelper
(
int
code
,
[
String
message
=
''
])
{
port
.
send
(<
dynamic
>[
code
,
message
]);
}
SendPort
shared
=
IsolateNameServer
.
lookupPortByName
(
kPortName
);
final
SendPort
shared
=
IsolateNameServer
.
lookupPortByName
(
kPortName
);
if
(
shared
==
null
)
{
sendHelper
(
kErrorCode
,
'Could not find port:
$kPortName
'
);
return
;
...
...
@@ -35,7 +34,7 @@ void isolateSpawnEntrypoint(SendPort port) {
// send another message to ensure we don't crash.
shared
.
send
(
'garbage'
);
bool
result
=
IsolateNameServer
.
removePortNameMapping
(
kPortName
);
final
bool
result
=
IsolateNameServer
.
removePortNameMapping
(
kPortName
);
if
(
result
)
{
sendHelper
(
kDeletedCode
);
}
else
{
...
...
@@ -55,14 +54,14 @@ void main() {
expect
(
IsolateNameServer
.
removePortNameMapping
(
kPortName
),
isFalse
);
// Register a SendPort.
final
receivePort
=
new
ReceivePort
();
final
sendPort
=
receivePort
.
sendPort
;
final
ReceivePort
receivePort
=
ReceivePort
();
final
SendPort
sendPort
=
receivePort
.
sendPort
;
expect
(
IsolateNameServer
.
registerPortWithName
(
sendPort
,
kPortName
),
isTrue
);
expect
(
IsolateNameServer
.
lookupPortByName
(
kPortName
),
sendPort
);
// Check we can't register the same name twice.
final
receivePort2
=
new
ReceivePort
();
final
sendPort2
=
receivePort2
.
sendPort
;
final
ReceivePort
receivePort2
=
ReceivePort
();
final
SendPort
sendPort2
=
receivePort2
.
sendPort
;
expect
(
IsolateNameServer
.
registerPortWithName
(
sendPort2
,
kPortName
),
isFalse
);
expect
(
IsolateNameServer
.
lookupPortByName
(
kPortName
),
sendPort
);
...
...
@@ -83,13 +82,13 @@ void main() {
test
(
'isolate name server multi-isolate'
,
()
async
{
// Register our send port with the name server.
final
receivePort
=
new
ReceivePort
();
final
sendPort
=
receivePort
.
sendPort
;
final
ReceivePort
receivePort
=
ReceivePort
();
final
SendPort
sendPort
=
receivePort
.
sendPort
;
expect
(
IsolateNameServer
.
registerPortWithName
(
sendPort
,
kPortName
),
isTrue
);
// Test driver.
final
testReceivePort
=
new
ReceivePort
();
testReceivePort
.
listen
(
expectAsync1
((
response
)
{
final
ReceivePort
testReceivePort
=
ReceivePort
();
testReceivePort
.
listen
(
expectAsync1
<
void
,
dynamic
>((
dynamic
response
)
{
final
int
code
=
response
[
0
];
final
String
message
=
response
[
1
];
switch
(
code
)
{
...
...
@@ -110,7 +109,7 @@ void main() {
}
},
count:
3
));
receivePort
.
listen
(
expectAsync1
((
message
)
{
receivePort
.
listen
(
expectAsync1
<
void
,
dynamic
>((
dynamic
message
)
{
// If we don't get this message, we timeout and fail.
expect
(
message
,
kPortName
);
}));
...
...
testing/dart/locale_test.dart
浏览文件 @
6179ac63
...
...
@@ -8,12 +8,12 @@ import 'package:test/test.dart';
void
main
(
)
{
test
(
'Locale'
,
()
{
final
Null
$null
=
null
;
const
Null
$null
=
null
;
expect
(
const
Locale
(
'en'
).
toString
(),
'en'
);
expect
(
const
Locale
(
'en'
),
new
Locale
(
'en'
,
$null
));
expect
(
const
Locale
(
'en'
).
hashCode
,
new
Locale
(
'en'
,
$null
).
hashCode
);
expect
(
const
Locale
(
'en'
),
isNot
(
new
Locale
(
'en'
,
''
)));
expect
(
const
Locale
(
'en'
).
hashCode
,
isNot
(
new
Locale
(
'en'
,
''
).
hashCode
));
expect
(
const
Locale
(
'en'
),
const
Locale
(
'en'
,
$null
));
expect
(
const
Locale
(
'en'
).
hashCode
,
const
Locale
(
'en'
,
$null
).
hashCode
);
expect
(
const
Locale
(
'en'
),
isNot
(
const
Locale
(
'en'
,
''
)));
expect
(
const
Locale
(
'en'
).
hashCode
,
isNot
(
const
Locale
(
'en'
,
''
).
hashCode
));
expect
(
const
Locale
(
'en'
,
'US'
).
toString
(),
'en_US'
);
expect
(
const
Locale
(
'iw'
).
toString
(),
'he'
);
expect
(
const
Locale
(
'iw'
,
'DD'
).
toString
(),
'he_DE'
);
...
...
@@ -32,17 +32,17 @@ void main() {
expect
(
const
Locale
.
fromSubtags
(
countryCode:
'US'
).
toString
(),
'und_US'
);
expect
(
const
Locale
.
fromSubtags
(
countryCode:
'US'
).
countryCode
,
'US'
);
expect
(
Locale
.
fromSubtags
(
languageCode:
'es'
,
countryCode:
'419'
).
toString
(),
'es_419'
);
expect
(
Locale
.
fromSubtags
(
languageCode:
'es'
,
countryCode:
'419'
).
languageCode
,
'es'
);
expect
(
Locale
.
fromSubtags
(
languageCode:
'es'
,
countryCode:
'419'
).
countryCode
,
'419'
);
expect
(
const
Locale
.
fromSubtags
(
languageCode:
'es'
,
countryCode:
'419'
).
toString
(),
'es_419'
);
expect
(
const
Locale
.
fromSubtags
(
languageCode:
'es'
,
countryCode:
'419'
).
languageCode
,
'es'
);
expect
(
const
Locale
.
fromSubtags
(
languageCode:
'es'
,
countryCode:
'419'
).
countryCode
,
'419'
);
expect
(
Locale
.
fromSubtags
(
languageCode:
'zh'
,
scriptCode:
'Hans'
,
countryCode:
'CN'
).
toString
(),
'zh_Hans_CN'
);
expect
(
const
Locale
.
fromSubtags
(
languageCode:
'zh'
,
scriptCode:
'Hans'
,
countryCode:
'CN'
).
toString
(),
'zh_Hans_CN'
);
});
test
(
'Locale equality'
,
()
{
expect
(
Locale
.
fromSubtags
(
languageCode:
'en'
),
isNot
(
Locale
.
fromSubtags
(
languageCode:
'en'
,
scriptCode:
'Latn'
)));
expect
(
Locale
.
fromSubtags
(
languageCode:
'en'
).
hashCode
,
isNot
(
Locale
.
fromSubtags
(
languageCode:
'en'
,
scriptCode:
'Latn'
).
hashCode
));
expect
(
const
Locale
.
fromSubtags
(
languageCode:
'en'
),
isNot
(
const
Locale
.
fromSubtags
(
languageCode:
'en'
,
scriptCode:
'Latn'
)));
expect
(
const
Locale
.
fromSubtags
(
languageCode:
'en'
).
hashCode
,
isNot
(
const
Locale
.
fromSubtags
(
languageCode:
'en'
,
scriptCode:
'Latn'
).
hashCode
));
});
}
testing/dart/paragraph_builder_test.dart
浏览文件 @
6179ac63
...
...
@@ -13,7 +13,7 @@ void main() {
final
Paragraph
paragraph
=
builder
.
build
();
expect
(
paragraph
,
isNotNull
);
paragraph
.
layout
(
ParagraphConstraints
(
width:
800.0
));
paragraph
.
layout
(
const
ParagraphConstraints
(
width:
800.0
));
expect
(
paragraph
.
width
,
isNonZero
);
expect
(
paragraph
.
height
,
isNonZero
);
});
...
...
testing/dart/path_test.dart
浏览文件 @
6179ac63
...
...
@@ -93,7 +93,7 @@ void main() {
test
(
'transformation tests'
,
()
{
final
Rect
bounds
=
new
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
);
final
Path
p
=
new
Path
()..
addRect
(
bounds
);
final
Float64List
scaleMatrix
=
new
Float64List
.
fromList
(
[
final
Float64List
scaleMatrix
=
Float64List
.
fromList
(<
double
>
[
2.5
,
0.0
,
0.0
,
0.0
,
// first col
0.0
,
0.5
,
0.0
,
0.0
,
// second col
0.0
,
0.0
,
1.0
,
0.0
,
// third col
...
...
@@ -178,7 +178,7 @@ void main() {
final
double
midPoint
=
simpleMetricsDiagonal
.
iterator
.
current
.
length
/
2
;
final
Tangent
posTanDiagonal
=
simpleMetricsDiagonal
.
iterator
.
current
.
getTangentForOffset
(
midPoint
);
expect
(
posTanDiagonal
.
position
,
equals
(
new
Offset
(
5.0
,
5.0
)));
expect
(
posTanDiagonal
.
position
,
equals
(
const
Offset
(
5.0
,
5.0
)));
expect
(
posTanDiagonal
.
angle
,
closeTo
(-
0.7853981633974483
,
.
00001
));
// ~45 degrees
...
...
testing/dart/plugin_utilities_test.dart
浏览文件 @
6179ac63
...
...
@@ -6,7 +6,7 @@ import 'dart:ui';
import
'package:test/test.dart'
;
String
top
(
)
=>
"top"
;
String
top
(
)
=>
'top'
;
class
Foo
{
const
Foo
();
...
...
@@ -19,29 +19,29 @@ const Foo foo = const Foo();
void
main
(
)
{
test
(
'PluginUtilities Callback Handles'
,
()
{
// Top level callback.
final
hTop
=
PluginUtilities
.
getCallbackHandle
(
top
);
final
CallbackHandle
hTop
=
PluginUtilities
.
getCallbackHandle
(
top
);
expect
(
hTop
,
isNotNull
);
expect
(
hTop
,
isNot
(
0
));
expect
(
PluginUtilities
.
getCallbackHandle
(
top
),
hTop
);
final
topClosure
=
PluginUtilities
.
getCallbackFromHandle
(
hTop
);
final
Function
topClosure
=
PluginUtilities
.
getCallbackFromHandle
(
hTop
);
expect
(
topClosure
,
isNotNull
);
expect
(
topClosure
(),
"top"
);
expect
(
topClosure
(),
'top'
);
// Static method callback.
final
hGetInt
=
PluginUtilities
.
getCallbackHandle
(
Foo
.
getInt
);
final
CallbackHandle
hGetInt
=
PluginUtilities
.
getCallbackHandle
(
Foo
.
getInt
);
expect
(
hGetInt
,
isNotNull
);
expect
(
hGetInt
,
isNot
(
0
));
expect
(
PluginUtilities
.
getCallbackHandle
(
Foo
.
getInt
),
hGetInt
);
final
getIntClosure
=
PluginUtilities
.
getCallbackFromHandle
(
hGetInt
);
final
Function
getIntClosure
=
PluginUtilities
.
getCallbackFromHandle
(
hGetInt
);
expect
(
getIntClosure
,
isNotNull
);
expect
(
getIntClosure
(),
1
);
// Instance method callbacks cannot be looked up.
final
foo
=
new
Foo
();
const
Foo
foo
=
Foo
();
expect
(
PluginUtilities
.
getCallbackHandle
(
foo
.
getDouble
),
isNull
);
// Anonymous closures cannot be looked up.
final
anon
=
(
int
a
,
int
b
)
=>
a
+
b
;
final
Function
anon
=
(
int
a
,
int
b
)
=>
a
+
b
;
expect
(
PluginUtilities
.
getCallbackHandle
(
anon
),
isNull
);
});
}
testing/dart/pubspec.yaml
浏览文件 @
6179ac63
...
...
@@ -2,3 +2,9 @@ name: engine_tests
dependencies
:
test
:
1.3.0
path
:
1.6.2
dependency_overrides
:
sky_engine
:
path
:
../../../out/host_debug_unopt/gen/dart-pkg/sky_engine
sky_services
:
path
:
../../../out/host_debug_unopt/gen/dart-pkg/sky_services
\ No newline at end of file
testing/dart/rect_test.dart
浏览文件 @
6179ac63
...
...
@@ -7,16 +7,16 @@ import 'dart:ui';
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
"rect accessors"
,
()
{
final
Rect
r
=
new
Rect
.
fromLTRB
(
1.0
,
3.0
,
5.0
,
7.0
);
test
(
'rect accessors'
,
()
{
final
Rect
r
=
Rect
.
fromLTRB
(
1.0
,
3.0
,
5.0
,
7.0
);
expect
(
r
.
left
,
equals
(
1.0
));
expect
(
r
.
top
,
equals
(
3.0
));
expect
(
r
.
right
,
equals
(
5.0
));
expect
(
r
.
bottom
,
equals
(
7.0
));
});
test
(
"rect created by width and height"
,
()
{
final
Rect
r
=
new
Rect
.
fromLTWH
(
1.0
,
3.0
,
5.0
,
7.0
);
test
(
'rect created by width and height'
,
()
{
final
Rect
r
=
Rect
.
fromLTWH
(
1.0
,
3.0
,
5.0
,
7.0
);
expect
(
r
.
left
,
equals
(
1.0
));
expect
(
r
.
top
,
equals
(
3.0
));
expect
(
r
.
right
,
equals
(
6.0
));
...
...
@@ -25,9 +25,9 @@ void main() {
expect
(
r
.
longestSide
,
equals
(
7.0
));
});
test
(
"rect intersection"
,
()
{
final
Rect
r1
=
new
Rect
.
fromLTRB
(
0.0
,
0.0
,
100.0
,
100.0
);
final
Rect
r2
=
new
Rect
.
fromLTRB
(
50.0
,
50.0
,
200.0
,
200.0
);
test
(
'rect intersection'
,
()
{
final
Rect
r1
=
Rect
.
fromLTRB
(
0.0
,
0.0
,
100.0
,
100.0
);
final
Rect
r2
=
Rect
.
fromLTRB
(
50.0
,
50.0
,
200.0
,
200.0
);
final
Rect
r3
=
r1
.
intersect
(
r2
);
expect
(
r3
.
left
,
equals
(
50.0
));
expect
(
r3
.
top
,
equals
(
50.0
));
...
...
@@ -37,9 +37,9 @@ void main() {
expect
(
r4
,
equals
(
r3
));
});
test
(
"rect expandToInclude overlapping rects"
,
()
{
final
Rect
r1
=
new
Rect
.
fromLTRB
(
0.0
,
0.0
,
100.0
,
100.0
);
final
Rect
r2
=
new
Rect
.
fromLTRB
(
50.0
,
50.0
,
200.0
,
200.0
);
test
(
'rect expandToInclude overlapping rects'
,
()
{
final
Rect
r1
=
Rect
.
fromLTRB
(
0.0
,
0.0
,
100.0
,
100.0
);
final
Rect
r2
=
Rect
.
fromLTRB
(
50.0
,
50.0
,
200.0
,
200.0
);
final
Rect
r3
=
r1
.
expandToInclude
(
r2
);
expect
(
r3
.
left
,
equals
(
0.0
));
expect
(
r3
.
top
,
equals
(
0.0
));
...
...
@@ -49,9 +49,9 @@ void main() {
expect
(
r4
,
equals
(
r3
));
});
test
(
"rect expandToInclude crossing rects"
,
()
{
final
Rect
r1
=
new
Rect
.
fromLTRB
(
50.0
,
0.0
,
50.0
,
200.0
);
final
Rect
r2
=
new
Rect
.
fromLTRB
(
0.0
,
50.0
,
200.0
,
50.0
);
test
(
'rect expandToInclude crossing rects'
,
()
{
final
Rect
r1
=
Rect
.
fromLTRB
(
50.0
,
0.0
,
50.0
,
200.0
);
final
Rect
r2
=
Rect
.
fromLTRB
(
0.0
,
50.0
,
200.0
,
50.0
);
final
Rect
r3
=
r1
.
expandToInclude
(
r2
);
expect
(
r3
.
left
,
equals
(
0.0
));
expect
(
r3
.
top
,
equals
(
0.0
));
...
...
@@ -61,17 +61,17 @@ void main() {
expect
(
r4
,
equals
(
r3
));
});
test
(
"size created from doubles"
,
()
{
final
Size
size
=
new
Size
(
5.0
,
7.0
);
test
(
'size created from doubles'
,
()
{
const
Size
size
=
Size
(
5.0
,
7.0
);
expect
(
size
.
width
,
equals
(
5.0
));
expect
(
size
.
height
,
equals
(
7.0
));
expect
(
size
.
shortestSide
,
equals
(
5.0
));
expect
(
size
.
longestSide
,
equals
(
7.0
));
});
test
(
"rounded rect created from rect and radii"
,
()
{
final
Rect
baseRect
=
new
Rect
.
fromLTWH
(
1.0
,
3.0
,
5.0
,
7.0
);
final
RRect
r
=
new
RRect
.
fromRectXY
(
baseRect
,
1.0
,
1.0
);
test
(
'rounded rect created from rect and radii'
,
()
{
final
Rect
baseRect
=
Rect
.
fromLTWH
(
1.0
,
3.0
,
5.0
,
7.0
);
final
RRect
r
=
RRect
.
fromRectXY
(
baseRect
,
1.0
,
1.0
);
expect
(
r
.
left
,
equals
(
1.0
));
expect
(
r
.
top
,
equals
(
3.0
));
expect
(
r
.
right
,
equals
(
6.0
));
...
...
testing/dart/window_hooks_integration_test.dart
浏览文件 @
6179ac63
...
...
@@ -6,15 +6,14 @@
library
dart
.
ui
;
import
'dart:async'
;
import
'dart:io'
;
import
'dart:
typed_data'
;
// this needs to be imported because painting.dart expects it this way
import
'dart:
collection'
as
collection
;
import
'dart:convert'
;
import
'dart:developer'
as
developer
;
import
'dart:math'
as
math
;
import
'dart:nativewrappers'
;
import
'dart:nativewrappers'
;
// ignore: unused_import
import
'dart:typed_data'
;
// this needs to be imported because painting.dart expects it this way
import
'dart:collection'
as
collection
;
import
'package:test/test.dart'
;
...
...
testing/dart/window_test.dart
浏览文件 @
6179ac63
...
...
@@ -12,7 +12,7 @@ void main() {
test
(
'window.sendPlatformMessage preserves callback zone'
,
()
{
runZoned
(()
{
final
Zone
innerZone
=
Zone
.
current
;
window
.
sendPlatformMessage
(
'test'
,
new
ByteData
.
view
(
new
Uint8List
(
0
).
buffer
),
expectAsync
((
ByteData
data
)
{
window
.
sendPlatformMessage
(
'test'
,
new
ByteData
.
view
(
new
Uint8List
(
0
).
buffer
),
expectAsync
1
((
ByteData
data
)
{
final
Zone
runZone
=
Zone
.
current
;
expect
(
runZone
,
isNotNull
);
expect
(
runZone
,
same
(
innerZone
));
...
...
testing/run_tests.sh
浏览文件 @
6179ac63
...
...
@@ -21,7 +21,7 @@ run_test () {
}
# Verify that a failing test returns a failure code.
!
run_test flutter/testing/fail_test.dart
!
run_test flutter/testing/
smoke_test_failure/
fail_test.dart
for
TEST_SCRIPT
in
flutter/testing/dart/
*
.dart
;
do
run_test
$TEST_SCRIPT
...
...
testing/fail_test.dart
→
testing/
smoke_test_failure/
fail_test.dart
浏览文件 @
6179ac63
文件已移动
testing/smoke_test_failure/pubspec.yaml
0 → 100644
浏览文件 @
6179ac63
name
:
smoke_test_failure
dependencies
:
test
:
1.3.0
path
:
1.6.2
testing/symbols/verify_exported.dart
浏览文件 @
6179ac63
...
...
@@ -30,7 +30,7 @@ void main(List<String> arguments) {
final
Iterable
<
String
>
releaseBuilds
=
new
Directory
(
outPath
).
listSync
()
.
where
((
FileSystemEntity
entity
)
=>
entity
is
Directory
)
.
map
((
FileSystemEntity
dir
)
=>
p
.
basename
(
dir
.
path
))
.
map
<
String
>
((
FileSystemEntity
dir
)
=>
p
.
basename
(
dir
.
path
))
.
where
((
String
s
)
=>
s
.
contains
(
'_release'
));
final
Iterable
<
String
>
iosReleaseBuilds
=
releaseBuilds
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录