fix up analysis for Dart in Engine (flutter/engine#7404)
* fix up analysis for Dart in Engine, particularly for tests
This commit is contained in:
@@ -10,9 +10,6 @@
|
|||||||
# private fields, especially on the Window object):
|
# private fields, especially on the Window object):
|
||||||
|
|
||||||
analyzer:
|
analyzer:
|
||||||
language:
|
|
||||||
enableStrictCallChecks: true
|
|
||||||
enableSuperMixins: true
|
|
||||||
strong-mode:
|
strong-mode:
|
||||||
implicit-dynamic: false
|
implicit-dynamic: false
|
||||||
errors:
|
errors:
|
||||||
@@ -20,6 +17,7 @@ analyzer:
|
|||||||
missing_required_param: warning
|
missing_required_param: warning
|
||||||
# treat missing returns as a warning (not a hint)
|
# treat missing returns as a warning (not a hint)
|
||||||
missing_return: warning
|
missing_return: warning
|
||||||
|
native_function_body_in_non_sdk_code: ignore
|
||||||
# allow having TODOs in the code
|
# allow having TODOs in the code
|
||||||
todo: ignore
|
todo: ignore
|
||||||
# `flutter analyze` (without `--watch`) just ignores directories
|
# `flutter analyze` (without `--watch`) just ignores directories
|
||||||
@@ -94,7 +92,6 @@ linter:
|
|||||||
# - parameter_assignments # we do this commonly
|
# - parameter_assignments # we do this commonly
|
||||||
- prefer_adjacent_string_concatenation
|
- prefer_adjacent_string_concatenation
|
||||||
- prefer_asserts_in_initializer_lists
|
- prefer_asserts_in_initializer_lists
|
||||||
- prefer_bool_in_asserts
|
|
||||||
- prefer_collection_literals
|
- prefer_collection_literals
|
||||||
- prefer_conditional_assignment
|
- prefer_conditional_assignment
|
||||||
- prefer_const_constructors
|
- prefer_const_constructors
|
||||||
|
|||||||
@@ -4,13 +4,7 @@ RESULTS=`dartanalyzer \
|
|||||||
--options flutter/analysis_options.yaml \
|
--options flutter/analysis_options.yaml \
|
||||||
out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart \
|
out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart \
|
||||||
2>&1 \
|
2>&1 \
|
||||||
| grep -v "Native functions can only be declared in the SDK and code that is loaded through native extensions" \
|
| grep -Ev "No issues found!" \
|
||||||
| 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 "Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui\.dart"`
|
| grep -Ev "Analyzing.+out/host_debug_unopt/gen/sky/bindings/dart_ui/ui\.dart"`
|
||||||
|
|
||||||
echo "$RESULTS"
|
echo "$RESULTS"
|
||||||
|
|||||||
@@ -2,17 +2,22 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// 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;
|
part of dart.ui;
|
||||||
|
|
||||||
|
// ignore: unused_element
|
||||||
String _decodeUTF8(ByteData message) {
|
String _decodeUTF8(ByteData message) {
|
||||||
return message != null ? utf8.decoder.convert(message.buffer.asUint8List()) : null;
|
return message != null ? utf8.decoder.convert(message.buffer.asUint8List()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: unused_element
|
||||||
dynamic _decodeJSON(String message) {
|
dynamic _decodeJSON(String message) {
|
||||||
return message != null ? json.decode(message) : null;
|
return message != null ? json.decode(message) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _updateWindowMetrics(double devicePixelRatio,
|
void _updateWindowMetrics(double devicePixelRatio,
|
||||||
double width,
|
double width,
|
||||||
double height,
|
double height,
|
||||||
@@ -50,9 +55,11 @@ String _localeClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
_LocaleClosure _getLocaleClosure() => _localeClosure;
|
_LocaleClosure _getLocaleClosure() => _localeClosure;
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _updateLocales(List<String> locales) {
|
void _updateLocales(List<String> locales) {
|
||||||
const int stringsPerLocale = 4;
|
const int stringsPerLocale = 4;
|
||||||
final int numLocales = locales.length ~/ stringsPerLocale;
|
final int numLocales = locales.length ~/ stringsPerLocale;
|
||||||
@@ -71,6 +78,7 @@ void _updateLocales(List<String> locales) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _updateUserSettingsData(String jsonData) {
|
void _updateUserSettingsData(String jsonData) {
|
||||||
final Map<String, dynamic> data = json.decode(jsonData);
|
final Map<String, dynamic> data = json.decode(jsonData);
|
||||||
if (data.isEmpty) {
|
if (data.isEmpty) {
|
||||||
@@ -90,12 +98,14 @@ void _updateAlwaysUse24HourFormat(bool alwaysUse24HourFormat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _updateSemanticsEnabled(bool enabled) {
|
void _updateSemanticsEnabled(bool enabled) {
|
||||||
window._semanticsEnabled = enabled;
|
window._semanticsEnabled = enabled;
|
||||||
_invoke(window.onSemanticsEnabledChanged, window._onSemanticsEnabledChangedZone);
|
_invoke(window.onSemanticsEnabledChanged, window._onSemanticsEnabledChangedZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _updateAccessibilityFeatures(int values) {
|
void _updateAccessibilityFeatures(int values) {
|
||||||
final AccessibilityFeatures newFeatures = new AccessibilityFeatures._(values);
|
final AccessibilityFeatures newFeatures = new AccessibilityFeatures._(values);
|
||||||
if (newFeatures == window._accessibilityFeatures)
|
if (newFeatures == window._accessibilityFeatures)
|
||||||
@@ -122,12 +132,14 @@ void _dispatchPlatformMessage(String name, ByteData data, int responseId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _dispatchPointerDataPacket(ByteData packet) {
|
void _dispatchPointerDataPacket(ByteData packet) {
|
||||||
if (window.onPointerDataPacket != null)
|
if (window.onPointerDataPacket != null)
|
||||||
_invoke1<PointerDataPacket>(window.onPointerDataPacket, window._onPointerDataPacketZone, _unpackPointerDataPacket(packet));
|
_invoke1<PointerDataPacket>(window.onPointerDataPacket, window._onPointerDataPacketZone, _unpackPointerDataPacket(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _dispatchSemanticsAction(int id, int action, ByteData args) {
|
void _dispatchSemanticsAction(int id, int action, ByteData args) {
|
||||||
_invoke3<int, SemanticsAction, ByteData>(
|
_invoke3<int, SemanticsAction, ByteData>(
|
||||||
window.onSemanticsAction,
|
window.onSemanticsAction,
|
||||||
@@ -139,11 +151,13 @@ void _dispatchSemanticsAction(int id, int action, ByteData args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _beginFrame(int microseconds) {
|
void _beginFrame(int microseconds) {
|
||||||
_invoke1<Duration>(window.onBeginFrame, window._onBeginFrameZone, new Duration(microseconds: microseconds));
|
_invoke1<Duration>(window.onBeginFrame, window._onBeginFrameZone, new Duration(microseconds: microseconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
|
// ignore: unused_element
|
||||||
void _drawFrame() {
|
void _drawFrame() {
|
||||||
_invoke(window.onDrawFrame, window._onDrawFrameZone);
|
_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].
|
/// 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) {
|
void _invoke2<A1, A2>(void callback(A1 a1, A2 a2), Zone zone, A1 arg1, A2 arg2) {
|
||||||
if (callback == null)
|
if (callback == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// 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;
|
part of dart.ui;
|
||||||
|
|
||||||
// Corelib 'print' implementation.
|
// Corelib 'print' implementation.
|
||||||
@@ -28,7 +30,7 @@ Future<developer.ServiceExtensionResponse> _scheduleFrame(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void _setupHooks() {
|
void _setupHooks() { // ignore: unused_element
|
||||||
assert(() {
|
assert(() {
|
||||||
// In debug mode, register the schedule frame extension.
|
// In debug mode, register the schedule frame extension.
|
||||||
developer.registerExtension('ext.ui.window.scheduleFrame', _scheduleFrame);
|
developer.registerExtension('ext.ui.window.scheduleFrame', _scheduleFrame);
|
||||||
@@ -67,9 +69,9 @@ int _getCallbackHandle(Function closure) native 'GetCallbackHandle';
|
|||||||
Function _getCallbackFromHandle(int handle) native 'GetCallbackFromHandle';
|
Function _getCallbackFromHandle(int handle) native 'GetCallbackFromHandle';
|
||||||
|
|
||||||
// Required for gen_snapshot to work correctly.
|
// Required for gen_snapshot to work correctly.
|
||||||
int _isolateId;
|
int _isolateId; // ignore: unused_element
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
Function _getPrintClosure() => _print;
|
Function _getPrintClosure() => _print; // ignore: unused_element
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
Function _getScheduleMicrotaskClosure() => _scheduleMicrotask;
|
Function _getScheduleMicrotaskClosure() => _scheduleMicrotask; // ignore: unused_element
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
/// text, layout, and rendering subsystems.
|
/// text, layout, and rendering subsystems.
|
||||||
library dart.ui;
|
library dart.ui;
|
||||||
|
|
||||||
import 'dart:_internal' hide Symbol;
|
import 'dart:_internal' hide Symbol; // ignore: import_internal_library, unused_import
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection' as collection;
|
import 'dart:collection' as collection;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer' as developer;
|
import 'dart:developer' as developer;
|
||||||
import 'dart:io';
|
import 'dart:io'; // ignore: unused_import
|
||||||
import 'dart:isolate' show SendPort;
|
import 'dart:isolate' show SendPort;
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:nativewrappers';
|
import 'dart:nativewrappers';
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
print("Hello");
|
print('Hello');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,51 +2,52 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:ui';
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
typedef void CanvasCallback(Canvas canvas);
|
typedef CanvasCallback = void Function(Canvas canvas);
|
||||||
|
|
||||||
void testCanvas(CanvasCallback callback) {
|
void testCanvas(CanvasCallback callback) {
|
||||||
try {
|
try {
|
||||||
callback(Canvas(PictureRecorder(), Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)));
|
callback(Canvas(PictureRecorder(), Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)));
|
||||||
} catch (error) { }
|
} catch (error) { } // ignore: empty_catches
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test("canvas APIs should not crash", () {
|
test('canvas APIs should not crash', () {
|
||||||
Paint paint = Paint();
|
final Paint paint = Paint();
|
||||||
Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan);
|
final Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan);
|
||||||
RRect rrect = RRect.fromRectAndCorners(rect);
|
final RRect rrect = RRect.fromRectAndCorners(rect);
|
||||||
Offset offset = Offset(double.nan, double.nan);
|
const Offset offset = Offset(double.nan, double.nan);
|
||||||
Path path = Path();
|
final Path path = Path();
|
||||||
Color color = Color(0);
|
const Color color = Color(0);
|
||||||
Paragraph paragraph = ParagraphBuilder(ParagraphStyle()).build();
|
final Paragraph paragraph = ParagraphBuilder(ParagraphStyle()).build();
|
||||||
|
|
||||||
PictureRecorder recorder = PictureRecorder();
|
final PictureRecorder recorder = PictureRecorder();
|
||||||
Canvas recorderCanvas = Canvas(recorder);
|
final Canvas recorderCanvas = Canvas(recorder);
|
||||||
Picture picture = recorder.endRecording();
|
recorderCanvas.scale(1.0, 1.0);
|
||||||
Image image = picture.toImage(1, 1);
|
final Picture picture = recorder.endRecording();
|
||||||
|
final Image image = picture.toImage(1, 1);
|
||||||
|
|
||||||
try { Canvas(null, null); } catch (error) { }
|
try { Canvas(null, null); } catch (error) { } // ignore: empty_catches
|
||||||
try { Canvas(null, rect); } catch (error) { }
|
try { Canvas(null, rect); } catch (error) { } // ignore: empty_catches
|
||||||
try { Canvas(PictureRecorder(), null); } catch (error) { }
|
try { Canvas(PictureRecorder(), null); } catch (error) { } // ignore: empty_catches
|
||||||
try { Canvas(PictureRecorder(), rect); } catch (error) { }
|
try { Canvas(PictureRecorder(), rect); } catch (error) { } // ignore: empty_catches
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PictureRecorder()
|
PictureRecorder()
|
||||||
..endRecording()
|
..endRecording()
|
||||||
..endRecording()
|
..endRecording()
|
||||||
..endRecording();
|
..endRecording();
|
||||||
} catch (error) { }
|
} catch (error) { } // ignore: empty_catches
|
||||||
|
|
||||||
testCanvas((Canvas canvas) => canvas.clipPath(path));
|
testCanvas((Canvas canvas) => canvas.clipPath(path));
|
||||||
testCanvas((Canvas canvas) => canvas.clipRect(rect));
|
testCanvas((Canvas canvas) => canvas.clipRect(rect));
|
||||||
testCanvas((Canvas canvas) => canvas.clipRRect(rrect));
|
testCanvas((Canvas canvas) => canvas.clipRRect(rrect));
|
||||||
testCanvas((Canvas canvas) => canvas.drawArc(rect, 0.0, 0.0, false, paint));
|
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.drawCircle(offset, double.nan, paint));
|
||||||
testCanvas((Canvas canvas) => canvas.drawColor(color, BlendMode.src));
|
testCanvas((Canvas canvas) => canvas.drawColor(color, BlendMode.src));
|
||||||
testCanvas((Canvas canvas) => canvas.drawDRRect(rrect, rrect, paint));
|
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.drawParagraph(paragraph, offset));
|
||||||
testCanvas((Canvas canvas) => canvas.drawPath(path, paint));
|
testCanvas((Canvas canvas) => canvas.drawPath(path, paint));
|
||||||
testCanvas((Canvas canvas) => canvas.drawPicture(picture));
|
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.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.drawRawPoints(PointMode.points, Float32List(0), paint));
|
||||||
testCanvas((Canvas canvas) => canvas.drawRect(rect, 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, null));
|
||||||
testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, false));
|
testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, false));
|
||||||
testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, true));
|
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.getSaveCount());
|
||||||
testCanvas((Canvas canvas) => canvas.restore());
|
testCanvas((Canvas canvas) => canvas.restore());
|
||||||
testCanvas((Canvas canvas) => canvas.rotate(double.nan));
|
testCanvas((Canvas canvas) => canvas.rotate(double.nan));
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:ui' as ui;
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
@@ -27,7 +26,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Fails with invalid data', () async {
|
test('Fails with invalid data', () async {
|
||||||
Uint8List data = new Uint8List.fromList([1, 2, 3]);
|
final Uint8List data = Uint8List.fromList(<int>[1, 2, 3]);
|
||||||
expect(
|
expect(
|
||||||
ui.instantiateImageCodec(data),
|
ui.instantiateImageCodec(data),
|
||||||
throwsA(exceptionWithMessage('operation failed'))
|
throwsA(exceptionWithMessage('operation failed'))
|
||||||
@@ -35,64 +34,64 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('nextFrame', () async {
|
test('nextFrame', () async {
|
||||||
Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes();
|
final Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes();
|
||||||
ui.Codec codec = await ui.instantiateImageCodec(data);
|
final ui.Codec codec = await ui.instantiateImageCodec(data);
|
||||||
List<List<int>> decodedFrameInfos = [];
|
final List<List<int>> decodedFrameInfos = <List<int>>[];
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
ui.FrameInfo frameInfo = await codec.getNextFrame();
|
final ui.FrameInfo frameInfo = await codec.getNextFrame();
|
||||||
decodedFrameInfos.add([
|
decodedFrameInfos.add(<int>[
|
||||||
frameInfo.duration.inMilliseconds,
|
frameInfo.duration.inMilliseconds,
|
||||||
frameInfo.image.width,
|
frameInfo.image.width,
|
||||||
frameInfo.image.height,
|
frameInfo.image.height,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
expect(decodedFrameInfos, equals([
|
expect(decodedFrameInfos, equals(<List<int>>[
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('decodedCacheRatioCap', () async {
|
test('decodedCacheRatioCap', () async {
|
||||||
// No real way to test the native layer, but a smoke test here to at least
|
// 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.
|
// verify that animation is still consistent with caching disabled.
|
||||||
Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes();
|
final Uint8List data = await _getSkiaResource('test640x479.gif').readAsBytes();
|
||||||
ui.Codec codec = await ui.instantiateImageCodec(data, decodedCacheRatioCap: 1.0);
|
final ui.Codec codec = await ui.instantiateImageCodec(data, decodedCacheRatioCap: 1.0);
|
||||||
List<List<int>> decodedFrameInfos = [];
|
final List<List<int>> decodedFrameInfos = <List<int>>[];
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
ui.FrameInfo frameInfo = await codec.getNextFrame();
|
final ui.FrameInfo frameInfo = await codec.getNextFrame();
|
||||||
decodedFrameInfos.add([
|
decodedFrameInfos.add(<int>[
|
||||||
frameInfo.duration.inMilliseconds,
|
frameInfo.duration.inMilliseconds,
|
||||||
frameInfo.image.width,
|
frameInfo.image.width,
|
||||||
frameInfo.image.height,
|
frameInfo.image.height,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
expect(decodedFrameInfos, equals([
|
expect(decodedFrameInfos, equals(<List<int>>[
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
[200, 640, 479],
|
<int>[200, 640, 479],
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('non animated image', () async {
|
test('non animated image', () async {
|
||||||
Uint8List data = await _getSkiaResource('baby_tux.png').readAsBytes();
|
final Uint8List data = await _getSkiaResource('baby_tux.png').readAsBytes();
|
||||||
ui.Codec codec = await ui.instantiateImageCodec(data);
|
final ui.Codec codec = await ui.instantiateImageCodec(data);
|
||||||
List<List<int>> decodedFrameInfos = [];
|
final List<List<int>> decodedFrameInfos = <List<int>>[];
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
ui.FrameInfo frameInfo = await codec.getNextFrame();
|
final ui.FrameInfo frameInfo = await codec.getNextFrame();
|
||||||
decodedFrameInfos.add([
|
decodedFrameInfos.add(<int>[
|
||||||
frameInfo.duration.inMilliseconds,
|
frameInfo.duration.inMilliseconds,
|
||||||
frameInfo.image.width,
|
frameInfo.image.width,
|
||||||
frameInfo.image.height,
|
frameInfo.image.height,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
expect(decodedFrameInfos, equals([
|
expect(decodedFrameInfos, equals(<List<int>>[
|
||||||
[0, 240, 246],
|
<int>[0, 240, 246],
|
||||||
[0, 240, 246],
|
<int>[0, 240, 246],
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -104,13 +103,13 @@ File _getSkiaResource(String fileName) {
|
|||||||
// assuming the curent working directory is engine/src.
|
// assuming the curent working directory is engine/src.
|
||||||
// This is fragile and should be changed once the Platform.script issue is
|
// This is fragile and should be changed once the Platform.script issue is
|
||||||
// resolved.
|
// resolved.
|
||||||
String assetPath =
|
final String assetPath =
|
||||||
path.join('third_party', 'skia', 'resources', 'images', fileName);
|
path.join('third_party', 'skia', 'resources', 'images', fileName);
|
||||||
return new File(assetPath);
|
return File(assetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher exceptionWithMessage(String m) {
|
Matcher exceptionWithMessage(String m) {
|
||||||
return predicate((e) {
|
return predicate<Exception>((Exception e) {
|
||||||
return e is Exception && e.toString().contains(m);
|
return e is Exception && e.toString().contains(m);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class NotAColor extends Color {
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('color accessors should work', () {
|
test('color accessors should work', () {
|
||||||
final Color foo = const Color(0x12345678);
|
const Color foo = Color(0x12345678);
|
||||||
expect(foo.alpha, equals(0x12));
|
expect(foo.alpha, equals(0x12));
|
||||||
expect(foo.red, equals(0x34));
|
expect(foo.red, equals(0x34));
|
||||||
expect(foo.green, equals(0x56));
|
expect(foo.green, equals(0x56));
|
||||||
@@ -20,7 +20,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('paint set to black', () {
|
test('paint set to black', () {
|
||||||
final Color c = const Color(0x00000000);
|
const Color c = Color(0x00000000);
|
||||||
final Paint p = new Paint();
|
final Paint p = new Paint();
|
||||||
p.color = c;
|
p.color = c;
|
||||||
expect(c.toString(), equals('Color(0x00000000)'));
|
expect(c.toString(), equals('Color(0x00000000)'));
|
||||||
@@ -28,7 +28,7 @@ void main() {
|
|||||||
|
|
||||||
test('color created with out of bounds value', () {
|
test('color created with out of bounds value', () {
|
||||||
try {
|
try {
|
||||||
final Color c = const Color(0x100 << 24);
|
const Color c = Color(0x100 << 24);
|
||||||
final Paint p = new Paint();
|
final Paint p = new Paint();
|
||||||
p.color = c;
|
p.color = c;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -38,7 +38,7 @@ void main() {
|
|||||||
|
|
||||||
test('color created with wildly out of bounds value', () {
|
test('color created with wildly out of bounds value', () {
|
||||||
try {
|
try {
|
||||||
final Color c = const Color(1 << 1000000);
|
const Color c = Color(1 << 1000000);
|
||||||
final Paint p = new Paint();
|
final Paint p = new Paint();
|
||||||
p.color = c;
|
p.color = c;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -48,7 +48,7 @@ void main() {
|
|||||||
|
|
||||||
test('two colors are only == if they have the same runtime type', () {
|
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(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 Color(321))));
|
||||||
expect(const Color(123), isNot(equals(const NotAColor(123))));
|
expect(const Color(123), isNot(equals(const NotAColor(123))));
|
||||||
expect(const NotAColor(123), isNot(equals(const Color(123))));
|
expect(const NotAColor(123), isNot(equals(const Color(123))));
|
||||||
@@ -123,14 +123,14 @@ void main() {
|
|||||||
|
|
||||||
test('compute gray luminance', () {
|
test('compute gray luminance', () {
|
||||||
// Each color component is at 20%.
|
// 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.
|
// Relative luminance's formula is just the linearized color value for gray.
|
||||||
// ((0.2 + 0.055) / 1.055) ^ 2.4.
|
// ((0.2 + 0.055) / 1.055) ^ 2.4.
|
||||||
expect(lightGray.computeLuminance(), equals(0.033104766570885055));
|
expect(lightGray.computeLuminance(), equals(0.033104766570885055));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compute color luminance', () {
|
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.2126 * ((1.0 + 0.055) / 1.055) ^ 2.4 +
|
||||||
// 0.7152 * ((0.23137254902 +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
|
// 0.0722 * ((0.18823529411 + 0.055) / 1.055) ^ 2.4
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
@@ -20,14 +20,14 @@ void main() {
|
|||||||
group('Image.toByteData', () {
|
group('Image.toByteData', () {
|
||||||
group('RGBA format', () {
|
group('RGBA format', () {
|
||||||
test('works with simple image', () async {
|
test('works with simple image', () async {
|
||||||
ByteData data = await Square4x4Image.image.toByteData();
|
final ByteData data = await Square4x4Image.image.toByteData();
|
||||||
expect(new Uint8List.view(data.buffer), Square4x4Image.bytes);
|
expect(Uint8List.view(data.buffer), Square4x4Image.bytes);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('converts grayscale images', () async {
|
test('converts grayscale images', () async {
|
||||||
Image image = await GrayscaleImage.load();
|
final Image image = await GrayscaleImage.load();
|
||||||
ByteData data = await image.toByteData();
|
final ByteData data = await image.toByteData();
|
||||||
Uint8List bytes = data.buffer.asUint8List();
|
final Uint8List bytes = data.buffer.asUint8List();
|
||||||
expect(bytes, hasLength(16));
|
expect(bytes, hasLength(16));
|
||||||
expect(bytes, GrayscaleImage.bytesAsRgba);
|
expect(bytes, GrayscaleImage.bytesAsRgba);
|
||||||
});
|
});
|
||||||
@@ -35,15 +35,15 @@ void main() {
|
|||||||
|
|
||||||
group('Unmodified format', () {
|
group('Unmodified format', () {
|
||||||
test('works with simple image', () async {
|
test('works with simple image', () async {
|
||||||
Image image = Square4x4Image.image;
|
final Image image = Square4x4Image.image;
|
||||||
ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified);
|
final ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified);
|
||||||
expect(new Uint8List.view(data.buffer), Square4x4Image.bytes);
|
expect(Uint8List.view(data.buffer), Square4x4Image.bytes);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('works with grayscale images', () async {
|
test('works with grayscale images', () async {
|
||||||
Image image = await GrayscaleImage.load();
|
final Image image = await GrayscaleImage.load();
|
||||||
ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified);
|
final ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified);
|
||||||
Uint8List bytes = data.buffer.asUint8List();
|
final Uint8List bytes = data.buffer.asUint8List();
|
||||||
expect(bytes, hasLength(4));
|
expect(bytes, hasLength(4));
|
||||||
expect(bytes, GrayscaleImage.bytesUnmodified);
|
expect(bytes, GrayscaleImage.bytesUnmodified);
|
||||||
});
|
});
|
||||||
@@ -51,46 +51,48 @@ void main() {
|
|||||||
|
|
||||||
group('PNG format', () {
|
group('PNG format', () {
|
||||||
test('works with simple image', () async {
|
test('works with simple image', () async {
|
||||||
Image image = Square4x4Image.image;
|
final Image image = Square4x4Image.image;
|
||||||
ByteData data = await image.toByteData(format: ImageByteFormat.png);
|
final ByteData data = await image.toByteData(format: ImageByteFormat.png);
|
||||||
List<int> expected = await readFile('square.png');
|
final List<int> expected = await readFile('square.png');
|
||||||
expect(new Uint8List.view(data.buffer), expected);
|
expect(Uint8List.view(data.buffer), expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class Square4x4Image {
|
class Square4x4Image {
|
||||||
|
Square4x4Image._();
|
||||||
|
|
||||||
static Image get image {
|
static Image get image {
|
||||||
double width = _kWidth.toDouble();
|
final double width = _kWidth.toDouble();
|
||||||
double radius = _kRadius.toDouble();
|
final double radius = _kRadius.toDouble();
|
||||||
double innerWidth = (_kWidth - 2 * _kRadius).toDouble();
|
final double innerWidth = (_kWidth - 2 * _kRadius).toDouble();
|
||||||
|
|
||||||
PictureRecorder recorder = new PictureRecorder();
|
final PictureRecorder recorder = PictureRecorder();
|
||||||
Canvas canvas =
|
final Canvas canvas =
|
||||||
new Canvas(recorder, new Rect.fromLTWH(0.0, 0.0, width, width));
|
Canvas(recorder, Rect.fromLTWH(0.0, 0.0, width, width));
|
||||||
|
|
||||||
Paint black = new Paint()
|
final Paint black = Paint()
|
||||||
..strokeWidth = 1.0
|
..strokeWidth = 1.0
|
||||||
..color = _kBlack;
|
..color = _kBlack;
|
||||||
Paint green = new Paint()
|
final Paint green = Paint()
|
||||||
..strokeWidth = 1.0
|
..strokeWidth = 1.0
|
||||||
..color = _kGreen;
|
..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(
|
canvas.drawRect(
|
||||||
new Rect.fromLTWH(radius, radius, innerWidth, innerWidth), green);
|
Rect.fromLTWH(radius, radius, innerWidth, innerWidth), green);
|
||||||
return recorder.endRecording().toImage(_kWidth, _kWidth);
|
return recorder.endRecording().toImage(_kWidth, _kWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<int> get bytes {
|
static List<int> get bytes {
|
||||||
int bytesPerChannel = 4;
|
const int bytesPerChannel = 4;
|
||||||
List<int> result = new List<int>(_kWidth * _kWidth * bytesPerChannel);
|
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 i = min; i < max; i++) {
|
||||||
for (int j = min; j < max; j++) {
|
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] = color.red;
|
||||||
result[offset + 1] = color.green;
|
result[offset + 1] = color.green;
|
||||||
result[offset + 2] = color.blue;
|
result[offset + 2] = color.blue;
|
||||||
@@ -107,9 +109,11 @@ class Square4x4Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GrayscaleImage {
|
class GrayscaleImage {
|
||||||
|
GrayscaleImage._();
|
||||||
|
|
||||||
static Future<Image> load() async {
|
static Future<Image> load() async {
|
||||||
Uint8List bytes = await readFile('4x4.png');
|
final Uint8List bytes = await readFile('4x4.png');
|
||||||
Completer<Image> completer = new Completer<Image>();
|
final Completer<Image> completer = Completer<Image>();
|
||||||
decodeImageFromList(bytes, (Image image) => completer.complete(image));
|
decodeImageFromList(bytes, (Image image) => completer.complete(image));
|
||||||
return await completer.future;
|
return await completer.future;
|
||||||
}
|
}
|
||||||
@@ -126,7 +130,7 @@ class GrayscaleImage {
|
|||||||
static List<int> get bytesUnmodified => <int>[255, 127, 127, 0];
|
static List<int> get bytesUnmodified => <int>[255, 127, 127, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> readFile(fileName) async {
|
Future<Uint8List> readFile(String fileName) async {
|
||||||
final file = new File(path.join('flutter', 'testing', 'resources', fileName));
|
final File file = File(path.join('flutter', 'testing', 'resources', fileName));
|
||||||
return await file.readAsBytes();
|
return await file.readAsBytes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:typed_data' show Float64List;
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
@@ -66,7 +65,7 @@ void main() {
|
|||||||
Offset.zero,
|
Offset.zero,
|
||||||
1.0,
|
1.0,
|
||||||
),
|
),
|
||||||
throwsA(const isInstanceOf<AssertionError>()),
|
throwsA(const TypeMatcher<AssertionError>()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,23 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
const kPortName = 'foobar';
|
const String kPortName = 'foobar';
|
||||||
const kErrorCode = -1;
|
const int kErrorCode = -1;
|
||||||
const kStartCode = 0;
|
const int kStartCode = 0;
|
||||||
const kCloseCode = 1;
|
const int kCloseCode = 1;
|
||||||
const kDeletedCode = 2;
|
const int kDeletedCode = 2;
|
||||||
|
|
||||||
void isolateSpawnEntrypoint(SendPort port) {
|
void isolateSpawnEntrypoint(SendPort port) {
|
||||||
sendHelper(int code, [String message = '']) {
|
void sendHelper(int code, [String message = '']) {
|
||||||
port.send(<dynamic>[code, message]);
|
port.send(<dynamic>[code, message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendPort shared = IsolateNameServer.lookupPortByName(kPortName);
|
final SendPort shared = IsolateNameServer.lookupPortByName(kPortName);
|
||||||
if (shared == null) {
|
if (shared == null) {
|
||||||
sendHelper(kErrorCode, 'Could not find port: $kPortName');
|
sendHelper(kErrorCode, 'Could not find port: $kPortName');
|
||||||
return;
|
return;
|
||||||
@@ -35,7 +34,7 @@ void isolateSpawnEntrypoint(SendPort port) {
|
|||||||
// send another message to ensure we don't crash.
|
// send another message to ensure we don't crash.
|
||||||
shared.send('garbage');
|
shared.send('garbage');
|
||||||
|
|
||||||
bool result = IsolateNameServer.removePortNameMapping(kPortName);
|
final bool result = IsolateNameServer.removePortNameMapping(kPortName);
|
||||||
if (result) {
|
if (result) {
|
||||||
sendHelper(kDeletedCode);
|
sendHelper(kDeletedCode);
|
||||||
} else {
|
} else {
|
||||||
@@ -55,14 +54,14 @@ void main() {
|
|||||||
expect(IsolateNameServer.removePortNameMapping(kPortName), isFalse);
|
expect(IsolateNameServer.removePortNameMapping(kPortName), isFalse);
|
||||||
|
|
||||||
// Register a SendPort.
|
// Register a SendPort.
|
||||||
final receivePort = new ReceivePort();
|
final ReceivePort receivePort = ReceivePort();
|
||||||
final sendPort = receivePort.sendPort;
|
final SendPort sendPort = receivePort.sendPort;
|
||||||
expect(IsolateNameServer.registerPortWithName(sendPort, kPortName), isTrue);
|
expect(IsolateNameServer.registerPortWithName(sendPort, kPortName), isTrue);
|
||||||
expect(IsolateNameServer.lookupPortByName(kPortName), sendPort);
|
expect(IsolateNameServer.lookupPortByName(kPortName), sendPort);
|
||||||
|
|
||||||
// Check we can't register the same name twice.
|
// Check we can't register the same name twice.
|
||||||
final receivePort2 = new ReceivePort();
|
final ReceivePort receivePort2 = ReceivePort();
|
||||||
final sendPort2 = receivePort2.sendPort;
|
final SendPort sendPort2 = receivePort2.sendPort;
|
||||||
expect(
|
expect(
|
||||||
IsolateNameServer.registerPortWithName(sendPort2, kPortName), isFalse);
|
IsolateNameServer.registerPortWithName(sendPort2, kPortName), isFalse);
|
||||||
expect(IsolateNameServer.lookupPortByName(kPortName), sendPort);
|
expect(IsolateNameServer.lookupPortByName(kPortName), sendPort);
|
||||||
@@ -83,13 +82,13 @@ void main() {
|
|||||||
|
|
||||||
test('isolate name server multi-isolate', () async {
|
test('isolate name server multi-isolate', () async {
|
||||||
// Register our send port with the name server.
|
// Register our send port with the name server.
|
||||||
final receivePort = new ReceivePort();
|
final ReceivePort receivePort = ReceivePort();
|
||||||
final sendPort = receivePort.sendPort;
|
final SendPort sendPort = receivePort.sendPort;
|
||||||
expect(IsolateNameServer.registerPortWithName(sendPort, kPortName), isTrue);
|
expect(IsolateNameServer.registerPortWithName(sendPort, kPortName), isTrue);
|
||||||
|
|
||||||
// Test driver.
|
// Test driver.
|
||||||
final testReceivePort = new ReceivePort();
|
final ReceivePort testReceivePort = ReceivePort();
|
||||||
testReceivePort.listen(expectAsync1((response) {
|
testReceivePort.listen(expectAsync1<void, dynamic>((dynamic response) {
|
||||||
final int code = response[0];
|
final int code = response[0];
|
||||||
final String message = response[1];
|
final String message = response[1];
|
||||||
switch (code) {
|
switch (code) {
|
||||||
@@ -110,7 +109,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
}, count: 3));
|
}, count: 3));
|
||||||
|
|
||||||
receivePort.listen(expectAsync1((message) {
|
receivePort.listen(expectAsync1<void, dynamic>((dynamic message) {
|
||||||
// If we don't get this message, we timeout and fail.
|
// If we don't get this message, we timeout and fail.
|
||||||
expect(message, kPortName);
|
expect(message, kPortName);
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import 'package:test/test.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('Locale', () {
|
test('Locale', () {
|
||||||
final Null $null = null;
|
const Null $null = null;
|
||||||
expect(const Locale('en').toString(), 'en');
|
expect(const Locale('en').toString(), 'en');
|
||||||
expect(const Locale('en'), new Locale('en', $null));
|
expect(const Locale('en'), const Locale('en', $null));
|
||||||
expect(const Locale('en').hashCode, new Locale('en', $null).hashCode);
|
expect(const Locale('en').hashCode, const Locale('en', $null).hashCode);
|
||||||
expect(const Locale('en'), isNot(new Locale('en', '')));
|
expect(const Locale('en'), isNot(const Locale('en', '')));
|
||||||
expect(const Locale('en').hashCode, isNot(new Locale('en', '').hashCode));
|
expect(const Locale('en').hashCode, isNot(const Locale('en', '').hashCode));
|
||||||
expect(const Locale('en', 'US').toString(), 'en_US');
|
expect(const Locale('en', 'US').toString(), 'en_US');
|
||||||
expect(const Locale('iw').toString(), 'he');
|
expect(const Locale('iw').toString(), 'he');
|
||||||
expect(const Locale('iw', 'DD').toString(), 'he_DE');
|
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').toString(), 'und_US');
|
||||||
expect(const Locale.fromSubtags(countryCode: 'US').countryCode, 'US');
|
expect(const Locale.fromSubtags(countryCode: 'US').countryCode, 'US');
|
||||||
|
|
||||||
expect(Locale.fromSubtags(languageCode: 'es', countryCode: '419').toString(), 'es_419');
|
expect(const Locale.fromSubtags(languageCode: 'es', countryCode: '419').toString(), 'es_419');
|
||||||
expect(Locale.fromSubtags(languageCode: 'es', countryCode: '419').languageCode, 'es');
|
expect(const 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').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', () {
|
test('Locale equality', () {
|
||||||
expect(Locale.fromSubtags(languageCode: 'en'),
|
expect(const Locale.fromSubtags(languageCode: 'en'),
|
||||||
isNot(Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn')));
|
isNot(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn')));
|
||||||
expect(Locale.fromSubtags(languageCode: 'en').hashCode,
|
expect(const Locale.fromSubtags(languageCode: 'en').hashCode,
|
||||||
isNot(Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn').hashCode));
|
isNot(const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Latn').hashCode));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ void main() {
|
|||||||
final Paragraph paragraph = builder.build();
|
final Paragraph paragraph = builder.build();
|
||||||
expect(paragraph, isNotNull);
|
expect(paragraph, isNotNull);
|
||||||
|
|
||||||
paragraph.layout(ParagraphConstraints(width: 800.0));
|
paragraph.layout(const ParagraphConstraints(width: 800.0));
|
||||||
expect(paragraph.width, isNonZero);
|
expect(paragraph.width, isNonZero);
|
||||||
expect(paragraph.height, isNonZero);
|
expect(paragraph.height, isNonZero);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ void main() {
|
|||||||
test('transformation tests', () {
|
test('transformation tests', () {
|
||||||
final Rect bounds = new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0);
|
final Rect bounds = new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0);
|
||||||
final Path p = new Path()..addRect(bounds);
|
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
|
2.5, 0.0, 0.0, 0.0, // first col
|
||||||
0.0, 0.5, 0.0, 0.0, // second col
|
0.0, 0.5, 0.0, 0.0, // second col
|
||||||
0.0, 0.0, 1.0, 0.0, // third 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 double midPoint = simpleMetricsDiagonal.iterator.current.length / 2;
|
||||||
final Tangent posTanDiagonal =
|
final Tangent posTanDiagonal =
|
||||||
simpleMetricsDiagonal.iterator.current.getTangentForOffset(midPoint);
|
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,
|
expect(posTanDiagonal.angle,
|
||||||
closeTo(-0.7853981633974483, .00001)); // ~45 degrees
|
closeTo(-0.7853981633974483, .00001)); // ~45 degrees
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'dart:ui';
|
|||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
String top() => "top";
|
String top() => 'top';
|
||||||
|
|
||||||
class Foo {
|
class Foo {
|
||||||
const Foo();
|
const Foo();
|
||||||
@@ -19,29 +19,29 @@ const Foo foo = const Foo();
|
|||||||
void main() {
|
void main() {
|
||||||
test('PluginUtilities Callback Handles', () {
|
test('PluginUtilities Callback Handles', () {
|
||||||
// Top level callback.
|
// Top level callback.
|
||||||
final hTop = PluginUtilities.getCallbackHandle(top);
|
final CallbackHandle hTop = PluginUtilities.getCallbackHandle(top);
|
||||||
expect(hTop, isNotNull);
|
expect(hTop, isNotNull);
|
||||||
expect(hTop, isNot(0));
|
expect(hTop, isNot(0));
|
||||||
expect(PluginUtilities.getCallbackHandle(top), hTop);
|
expect(PluginUtilities.getCallbackHandle(top), hTop);
|
||||||
final topClosure = PluginUtilities.getCallbackFromHandle(hTop);
|
final Function topClosure = PluginUtilities.getCallbackFromHandle(hTop);
|
||||||
expect(topClosure, isNotNull);
|
expect(topClosure, isNotNull);
|
||||||
expect(topClosure(), "top");
|
expect(topClosure(), 'top');
|
||||||
|
|
||||||
// Static method callback.
|
// Static method callback.
|
||||||
final hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt);
|
final CallbackHandle hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt);
|
||||||
expect(hGetInt, isNotNull);
|
expect(hGetInt, isNotNull);
|
||||||
expect(hGetInt, isNot(0));
|
expect(hGetInt, isNot(0));
|
||||||
expect(PluginUtilities.getCallbackHandle(Foo.getInt), hGetInt);
|
expect(PluginUtilities.getCallbackHandle(Foo.getInt), hGetInt);
|
||||||
final getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt);
|
final Function getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt);
|
||||||
expect(getIntClosure, isNotNull);
|
expect(getIntClosure, isNotNull);
|
||||||
expect(getIntClosure(), 1);
|
expect(getIntClosure(), 1);
|
||||||
|
|
||||||
// Instance method callbacks cannot be looked up.
|
// Instance method callbacks cannot be looked up.
|
||||||
final foo = new Foo();
|
const Foo foo = Foo();
|
||||||
expect(PluginUtilities.getCallbackHandle(foo.getDouble), isNull);
|
expect(PluginUtilities.getCallbackHandle(foo.getDouble), isNull);
|
||||||
|
|
||||||
// Anonymous closures cannot be looked up.
|
// 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);
|
expect(PluginUtilities.getCallbackHandle(anon), isNull);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,3 +2,9 @@ name: engine_tests
|
|||||||
dependencies:
|
dependencies:
|
||||||
test: 1.3.0
|
test: 1.3.0
|
||||||
path: 1.6.2
|
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
|
||||||
@@ -7,16 +7,16 @@ import 'dart:ui';
|
|||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test("rect accessors", () {
|
test('rect accessors', () {
|
||||||
final Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
|
final Rect r = Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
|
||||||
expect(r.left, equals(1.0));
|
expect(r.left, equals(1.0));
|
||||||
expect(r.top, equals(3.0));
|
expect(r.top, equals(3.0));
|
||||||
expect(r.right, equals(5.0));
|
expect(r.right, equals(5.0));
|
||||||
expect(r.bottom, equals(7.0));
|
expect(r.bottom, equals(7.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rect created by width and height", () {
|
test('rect created by width and height', () {
|
||||||
final Rect r = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
|
final Rect r = Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
|
||||||
expect(r.left, equals(1.0));
|
expect(r.left, equals(1.0));
|
||||||
expect(r.top, equals(3.0));
|
expect(r.top, equals(3.0));
|
||||||
expect(r.right, equals(6.0));
|
expect(r.right, equals(6.0));
|
||||||
@@ -25,9 +25,9 @@ void main() {
|
|||||||
expect(r.longestSide, equals(7.0));
|
expect(r.longestSide, equals(7.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rect intersection", () {
|
test('rect intersection', () {
|
||||||
final Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
|
final Rect r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
|
||||||
final Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
|
final Rect r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
|
||||||
final Rect r3 = r1.intersect(r2);
|
final Rect r3 = r1.intersect(r2);
|
||||||
expect(r3.left, equals(50.0));
|
expect(r3.left, equals(50.0));
|
||||||
expect(r3.top, equals(50.0));
|
expect(r3.top, equals(50.0));
|
||||||
@@ -37,9 +37,9 @@ void main() {
|
|||||||
expect(r4, equals(r3));
|
expect(r4, equals(r3));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rect expandToInclude overlapping rects", () {
|
test('rect expandToInclude overlapping rects', () {
|
||||||
final Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
|
final Rect r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
|
||||||
final Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
|
final Rect r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
|
||||||
final Rect r3 = r1.expandToInclude(r2);
|
final Rect r3 = r1.expandToInclude(r2);
|
||||||
expect(r3.left, equals(0.0));
|
expect(r3.left, equals(0.0));
|
||||||
expect(r3.top, equals(0.0));
|
expect(r3.top, equals(0.0));
|
||||||
@@ -49,9 +49,9 @@ void main() {
|
|||||||
expect(r4, equals(r3));
|
expect(r4, equals(r3));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rect expandToInclude crossing rects", () {
|
test('rect expandToInclude crossing rects', () {
|
||||||
final Rect r1 = new Rect.fromLTRB(50.0, 0.0, 50.0, 200.0);
|
final Rect r1 = Rect.fromLTRB(50.0, 0.0, 50.0, 200.0);
|
||||||
final Rect r2 = new Rect.fromLTRB(0.0, 50.0, 200.0, 50.0);
|
final Rect r2 = Rect.fromLTRB(0.0, 50.0, 200.0, 50.0);
|
||||||
final Rect r3 = r1.expandToInclude(r2);
|
final Rect r3 = r1.expandToInclude(r2);
|
||||||
expect(r3.left, equals(0.0));
|
expect(r3.left, equals(0.0));
|
||||||
expect(r3.top, equals(0.0));
|
expect(r3.top, equals(0.0));
|
||||||
@@ -61,17 +61,17 @@ void main() {
|
|||||||
expect(r4, equals(r3));
|
expect(r4, equals(r3));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("size created from doubles", () {
|
test('size created from doubles', () {
|
||||||
final Size size = new Size(5.0, 7.0);
|
const Size size = Size(5.0, 7.0);
|
||||||
expect(size.width, equals(5.0));
|
expect(size.width, equals(5.0));
|
||||||
expect(size.height, equals(7.0));
|
expect(size.height, equals(7.0));
|
||||||
expect(size.shortestSide, equals(5.0));
|
expect(size.shortestSide, equals(5.0));
|
||||||
expect(size.longestSide, equals(7.0));
|
expect(size.longestSide, equals(7.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rounded rect created from rect and radii", () {
|
test('rounded rect created from rect and radii', () {
|
||||||
final Rect baseRect = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
|
final Rect baseRect = Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
|
||||||
final RRect r = new RRect.fromRectXY(baseRect, 1.0, 1.0);
|
final RRect r = RRect.fromRectXY(baseRect, 1.0, 1.0);
|
||||||
expect(r.left, equals(1.0));
|
expect(r.left, equals(1.0));
|
||||||
expect(r.top, equals(3.0));
|
expect(r.top, equals(3.0));
|
||||||
expect(r.right, equals(6.0));
|
expect(r.right, equals(6.0));
|
||||||
|
|||||||
@@ -6,15 +6,14 @@
|
|||||||
library dart.ui;
|
library dart.ui;
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
// this needs to be imported because painting.dart expects it this way
|
||||||
import 'dart:typed_data';
|
import 'dart:collection' as collection;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer' as developer;
|
import 'dart:developer' as developer;
|
||||||
import 'dart:math' as math;
|
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';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void main() {
|
|||||||
test('window.sendPlatformMessage preserves callback zone', () {
|
test('window.sendPlatformMessage preserves callback zone', () {
|
||||||
runZoned(() {
|
runZoned(() {
|
||||||
final Zone innerZone = Zone.current;
|
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), expectAsync1((ByteData data) {
|
||||||
final Zone runZone = Zone.current;
|
final Zone runZone = Zone.current;
|
||||||
expect(runZone, isNotNull);
|
expect(runZone, isNotNull);
|
||||||
expect(runZone, same(innerZone));
|
expect(runZone, same(innerZone));
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ run_test () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Verify that a failing test returns a failure code.
|
# 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
|
for TEST_SCRIPT in flutter/testing/dart/*.dart; do
|
||||||
run_test $TEST_SCRIPT
|
run_test $TEST_SCRIPT
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
name: smoke_test_failure
|
||||||
|
dependencies:
|
||||||
|
test: 1.3.0
|
||||||
|
path: 1.6.2
|
||||||
@@ -30,7 +30,7 @@ void main(List<String> arguments) {
|
|||||||
|
|
||||||
final Iterable<String> releaseBuilds = new Directory(outPath).listSync()
|
final Iterable<String> releaseBuilds = new Directory(outPath).listSync()
|
||||||
.where((FileSystemEntity entity) => entity is Directory)
|
.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'));
|
.where((String s) => s.contains('_release'));
|
||||||
|
|
||||||
final Iterable<String> iosReleaseBuilds = releaseBuilds
|
final Iterable<String> iosReleaseBuilds = releaseBuilds
|
||||||
|
|||||||
Reference in New Issue
Block a user