未验证 提交 2b1f9925 编写于 作者: D Dan Field 提交者: GitHub

new lints (#8849)

Dart lints added:
* Avoid optional new
* Avoid optional const
* Prefer single quotes
* Prefer default assignment `=`
上级 0c7a3f25
...@@ -100,7 +100,7 @@ linter: ...@@ -100,7 +100,7 @@ linter:
- prefer_const_literals_to_create_immutables - prefer_const_literals_to_create_immutables
# - prefer_constructors_over_static_methods # not yet tested # - prefer_constructors_over_static_methods # not yet tested
- prefer_contains - prefer_contains
# - prefer_equal_for_default_values # not yet tested - prefer_equal_for_default_values
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
# - prefer_final_fields # DIFFERENT FROM FLUTTER/FLUTTER # - prefer_final_fields # DIFFERENT FROM FLUTTER/FLUTTER
- prefer_final_locals - prefer_final_locals
...@@ -118,15 +118,16 @@ linter: ...@@ -118,15 +118,16 @@ linter:
- slash_for_doc_comments - slash_for_doc_comments
# - sort_constructors_first # DIFFERENT FROM FLUTTER/FLUTTER # - sort_constructors_first # DIFFERENT FROM FLUTTER/FLUTTER
- sort_unnamed_constructors_first - sort_unnamed_constructors_first
- super_goes_last
- test_types_in_equals - test_types_in_equals
- throw_in_finally - throw_in_finally
# - type_annotate_public_apis # subset of always_specify_types # - type_annotate_public_apis # subset of always_specify_types
- type_init_formals - type_init_formals
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
- unnecessary_brace_in_string_interps - unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters - unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498 # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
- unnecessary_new
- unnecessary_null_aware_assignments - unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators - unnecessary_null_in_if_null_operators
- unnecessary_overrides - unnecessary_overrides
......
#!/bin/bash #!/bin/bash
echo "Analyzing dart:ui library..." echo "Analyzing dart:ui library..."
echo "Using analyzer from `which dartanalyzer`"
dartanalyzer --version
RESULTS=`dartanalyzer \ RESULTS=`dartanalyzer \
--options flutter/analysis_options.yaml \ --options flutter/analysis_options.yaml \
"$1out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart" \ "$1out/host_debug_unopt/gen/sky/bindings/dart_ui/ui.dart" \
2>&1 \ 2>&1 \
| grep -Ev "No issues found!" \ | grep -Ev "No issues 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,9 +2,10 @@ ...@@ -2,9 +2,10 @@
set -ex set -ex
PATH="$HOME/depot_tools:$PATH" PATH="$HOME/depot_tools:$PATH"
cd .. cd ..
PATH=$(pwd)/third_party/dart/tools/sdks/dart-sdk/bin:$PATH
# Build the dart UI files # Build the dart UI files
flutter/tools/gn --unoptimized flutter/tools/gn --unoptimized
ninja -C out/host_debug_unopt generate_dart_ui ninja -C out/host_debug_unopt generate_dart_ui
......
...@@ -3,6 +3,10 @@ set -e ...@@ -3,6 +3,10 @@ set -e
shopt -s nullglob shopt -s nullglob
echo "Verifying license script is still happy..." echo "Verifying license script is still happy..."
echo "Using pub from `which pub`, dart from `which dart`"
dart --version
(cd flutter/tools/licenses; pub get; dart --enable-asserts lib/main.dart --src ../../.. --out ../../../out/license_script_output --golden ../../ci/licenses_golden) (cd flutter/tools/licenses; pub get; dart --enable-asserts lib/main.dart --src ../../.. --out ../../../out/license_script_output --golden ../../ci/licenses_golden)
for f in out/license_script_output/licenses_*; do for f in out/license_script_output/licenses_*; do
......
...@@ -76,7 +76,7 @@ void _maybeAddCreationLocationArgument( ...@@ -76,7 +76,7 @@ void _maybeAddCreationLocationArgument(
} }
final NamedExpression namedArgument = final NamedExpression namedArgument =
new NamedExpression(_creationLocationParameterName, creationLocation); NamedExpression(_creationLocationParameterName, creationLocation);
namedArgument.parent = arguments; namedArgument.parent = arguments;
arguments.named.add(namedArgument); arguments.named.add(namedArgument);
} }
...@@ -149,26 +149,26 @@ class _WidgetCallSiteTransformer extends Transformer { ...@@ -149,26 +149,26 @@ class _WidgetCallSiteTransformer extends Transformer {
Location location, { Location location, {
String name, String name,
ListLiteral parameterLocations, ListLiteral parameterLocations,
bool showFile: true, bool showFile = true,
}) { }) {
final List<NamedExpression> arguments = <NamedExpression>[ final List<NamedExpression> arguments = <NamedExpression>[
new NamedExpression('line', new IntLiteral(location.line)), NamedExpression('line', IntLiteral(location.line)),
new NamedExpression('column', new IntLiteral(location.column)), NamedExpression('column', IntLiteral(location.column)),
]; ];
if (showFile) { if (showFile) {
arguments.add(new NamedExpression( arguments.add(NamedExpression(
'file', new StringLiteral(location.file.toString()))); 'file', StringLiteral(location.file.toString())));
} }
if (name != null) { if (name != null) {
arguments.add(new NamedExpression('name', new StringLiteral(name))); arguments.add(NamedExpression('name', StringLiteral(name)));
} }
if (parameterLocations != null) { if (parameterLocations != null) {
arguments arguments
.add(new NamedExpression('parameterLocations', parameterLocations)); .add(NamedExpression('parameterLocations', parameterLocations));
} }
return new ConstructorInvocation( return ConstructorInvocation(
_locationClass.constructors.first, _locationClass.constructors.first,
new Arguments(<Expression>[], named: arguments), Arguments(<Expression>[], named: arguments),
isConst: true, isConst: true,
); );
} }
...@@ -243,7 +243,7 @@ class _WidgetCallSiteTransformer extends Transformer { ...@@ -243,7 +243,7 @@ class _WidgetCallSiteTransformer extends Transformer {
_creationLocationParameterName, _creationLocationParameterName,
); );
if (creationLocationParameter != null) { if (creationLocationParameter != null) {
return new VariableGet(creationLocationParameter); return VariableGet(creationLocationParameter);
} }
} }
...@@ -270,7 +270,7 @@ class _WidgetCallSiteTransformer extends Transformer { ...@@ -270,7 +270,7 @@ class _WidgetCallSiteTransformer extends Transformer {
} }
return _constructLocation( return _constructLocation(
location, location,
parameterLocations: new ListLiteral( parameterLocations: ListLiteral(
parameterLocations, parameterLocations,
typeArgument: _locationClass.thisType, typeArgument: _locationClass.thisType,
isConst: true, isConst: true,
...@@ -342,12 +342,12 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -342,12 +342,12 @@ class WidgetCreatorTracker implements ProgramTransformer {
return; return;
} }
clazz.implementedTypes clazz.implementedTypes
.add(new Supertype(_hasCreationLocationClass, <DartType>[])); .add(Supertype(_hasCreationLocationClass, <DartType>[]));
// We intentionally use the library context of the _HasCreationLocation // We intentionally use the library context of the _HasCreationLocation
// class for the private field even if [clazz] is in a different library // class for the private field even if [clazz] is in a different library
// so that all classes implementing Widget behave consistently. // so that all classes implementing Widget behave consistently.
final Field locationField = new Field( final Field locationField = Field(
new Name( Name(
_locationFieldName, _locationFieldName,
_hasCreationLocationClass.enclosingLibrary, _hasCreationLocationClass.enclosingLibrary,
), ),
...@@ -356,7 +356,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -356,7 +356,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
clazz.addMember(locationField); clazz.addMember(locationField);
final Set<Constructor> _handledConstructors = final Set<Constructor> _handledConstructors =
new Set<Constructor>.identity(); Set<Constructor>.identity();
void handleConstructor(Constructor constructor) { void handleConstructor(Constructor constructor) {
if (!_handledConstructors.add(constructor)) { if (!_handledConstructors.add(constructor)) {
...@@ -366,7 +366,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -366,7 +366,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
constructor.function, constructor.function,
_creationLocationParameterName, _creationLocationParameterName,
)); ));
final VariableDeclaration variable = new VariableDeclaration( final VariableDeclaration variable = VariableDeclaration(
_creationLocationParameterName, _creationLocationParameterName,
type: _locationClass.thisType, type: _locationClass.thisType,
); );
...@@ -386,7 +386,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -386,7 +386,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
_maybeAddCreationLocationArgument( _maybeAddCreationLocationArgument(
initializer.arguments, initializer.arguments,
initializer.target.function, initializer.target.function,
new VariableGet(variable), VariableGet(variable),
_locationClass, _locationClass,
); );
hasRedirectingInitializer = true; hasRedirectingInitializer = true;
...@@ -394,9 +394,9 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -394,9 +394,9 @@ class WidgetCreatorTracker implements ProgramTransformer {
} }
} }
if (!hasRedirectingInitializer) { if (!hasRedirectingInitializer) {
constructor.initializers.add(new FieldInitializer( constructor.initializers.add(FieldInitializer(
locationField, locationField,
new VariableGet(variable), VariableGet(variable),
)); ));
// TODO(jacobr): add an assert verifying the locationField is not // TODO(jacobr): add an assert verifying the locationField is not
// null. Currently, we cannot safely add this assert because we do not // null. Currently, we cannot safely add this assert because we do not
...@@ -405,9 +405,9 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -405,9 +405,9 @@ class WidgetCreatorTracker implements ProgramTransformer {
// arguments but it is possible users could add classes with optional // arguments but it is possible users could add classes with optional
// positional arguments. // positional arguments.
// //
// constructor.initializers.add(new AssertInitializer(new AssertStatement( // constructor.initializers.add(AssertInitializer(AssertStatement(
// new IsExpression( // IsExpression(
// new VariableGet(variable), _locationClass.thisType), // VariableGet(variable), _locationClass.thisType),
// conditionStartOffset: constructor.fileOffset, // conditionStartOffset: constructor.fileOffset,
// conditionEndOffset: constructor.fileOffset, // conditionEndOffset: constructor.fileOffset,
// ))); // )));
...@@ -434,7 +434,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -434,7 +434,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
} }
} }
} }
return new Component()..libraries.addAll(libraries); return Component()..libraries.addAll(libraries);
} }
/// Transform the given [program]. /// Transform the given [program].
...@@ -459,13 +459,13 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -459,13 +459,13 @@ class WidgetCreatorTracker implements ProgramTransformer {
// TODO(jacobr): once there is a working incremental ClassHierarchy // TODO(jacobr): once there is a working incremental ClassHierarchy
// constructor switch to using it instead of building a ClassHierarchy off // constructor switch to using it instead of building a ClassHierarchy off
// the full program. // the full program.
hierarchy = new ClassHierarchy( hierarchy = ClassHierarchy(
_computeFullProgram(program), _computeFullProgram(program),
onAmbiguousSupertypes: (Class cls, Supertype a, Supertype b) { }, onAmbiguousSupertypes: (Class cls, Supertype a, Supertype b) { },
); );
final Set<Class> transformedClasses = new Set<Class>.identity(); final Set<Class> transformedClasses = Set<Class>.identity();
final Set<Library> librariesToTransform = new Set<Library>.identity() final Set<Library> librariesToTransform = Set<Library>.identity()
..addAll(libraries); ..addAll(libraries);
for (Library library in libraries) { for (Library library in libraries) {
...@@ -483,7 +483,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -483,7 +483,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
// Transform call sites to pass the location parameter. // Transform call sites to pass the location parameter.
final _WidgetCallSiteTransformer callsiteTransformer = final _WidgetCallSiteTransformer callsiteTransformer =
new _WidgetCallSiteTransformer( _WidgetCallSiteTransformer(
hierarchy, hierarchy,
widgetClass: _widgetClass, widgetClass: _widgetClass,
locationClass: _locationClass, locationClass: _locationClass,
...@@ -528,7 +528,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -528,7 +528,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
if (procedure.isFactory) { if (procedure.isFactory) {
_maybeAddNamedParameter( _maybeAddNamedParameter(
procedure.function, procedure.function,
new VariableDeclaration( VariableDeclaration(
_creationLocationParameterName, _creationLocationParameterName,
type: _locationClass.thisType, type: _locationClass.thisType,
), ),
...@@ -544,14 +544,14 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -544,14 +544,14 @@ class WidgetCreatorTracker implements ProgramTransformer {
} }
final Set<Constructor> _handledConstructors = final Set<Constructor> _handledConstructors =
new Set<Constructor>.identity(); Set<Constructor>.identity();
void handleConstructor(Constructor constructor) { void handleConstructor(Constructor constructor) {
if (!_handledConstructors.add(constructor)) { if (!_handledConstructors.add(constructor)) {
return; return;
} }
final VariableDeclaration variable = new VariableDeclaration( final VariableDeclaration variable = VariableDeclaration(
_creationLocationParameterName, _creationLocationParameterName,
type: _locationClass.thisType, type: _locationClass.thisType,
); );
...@@ -575,7 +575,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -575,7 +575,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
_maybeAddCreationLocationArgument( _maybeAddCreationLocationArgument(
initializer.arguments, initializer.arguments,
initializer.target.function, initializer.target.function,
new VariableGet(variable), VariableGet(variable),
_locationClass, _locationClass,
); );
} else if (initializer is SuperInitializer && } else if (initializer is SuperInitializer &&
...@@ -583,7 +583,7 @@ class WidgetCreatorTracker implements ProgramTransformer { ...@@ -583,7 +583,7 @@ class WidgetCreatorTracker implements ProgramTransformer {
_maybeAddCreationLocationArgument( _maybeAddCreationLocationArgument(
initializer.arguments, initializer.arguments,
initializer.target.function, initializer.target.function,
new VariableGet(variable), VariableGet(variable),
_locationClass, _locationClass,
); );
} }
......
...@@ -21,9 +21,9 @@ class _FlutterFrontendCompiler implements frontend.CompilerInterface{ ...@@ -21,9 +21,9 @@ class _FlutterFrontendCompiler implements frontend.CompilerInterface{
final frontend.CompilerInterface _compiler; final frontend.CompilerInterface _compiler;
_FlutterFrontendCompiler(StringSink output, _FlutterFrontendCompiler(StringSink output,
{bool trackWidgetCreation: false, bool unsafePackageSerialization}) : {bool trackWidgetCreation = false, bool unsafePackageSerialization}) :
_compiler = new frontend.FrontendCompiler(output, _compiler = frontend.FrontendCompiler(output,
transformer: trackWidgetCreation ? new WidgetCreatorTracker() : null, transformer: trackWidgetCreation ? WidgetCreatorTracker() : null,
unsafePackageSerialization: unsafePackageSerialization); unsafePackageSerialization: unsafePackageSerialization);
@override @override
...@@ -108,7 +108,7 @@ Future<int> starter( ...@@ -108,7 +108,7 @@ Future<int> starter(
'--sdk-root=$sdkRoot', '--sdk-root=$sdkRoot',
'--output-dill=$outputTrainingDill', '--output-dill=$outputTrainingDill',
'--target=flutter']); '--target=flutter']);
compiler ??= new _FlutterFrontendCompiler(output, trackWidgetCreation: true); compiler ??= _FlutterFrontendCompiler(output, trackWidgetCreation: true);
await compiler.compile(Platform.script.toFilePath(), options); await compiler.compile(Platform.script.toFilePath(), options);
compiler.acceptLastDelta(); compiler.acceptLastDelta();
...@@ -125,7 +125,7 @@ Future<int> starter( ...@@ -125,7 +125,7 @@ Future<int> starter(
} }
} }
compiler ??= new _FlutterFrontendCompiler(output, compiler ??= _FlutterFrontendCompiler(output,
trackWidgetCreation: options['track-widget-creation'], trackWidgetCreation: options['track-widget-creation'],
unsafePackageSerialization: options['unsafe-package-serialization']); unsafePackageSerialization: options['unsafe-package-serialization']);
...@@ -133,7 +133,7 @@ Future<int> starter( ...@@ -133,7 +133,7 @@ Future<int> starter(
return await compiler.compile(options.rest[0], options) ? 0 : 254; return await compiler.compile(options.rest[0], options) ? 0 : 254;
} }
final Completer<int> completer = new Completer<int>(); final Completer<int> completer = Completer<int>();
frontend.listenAndCompile(compiler, input ?? stdin, options, completer); frontend.listenAndCompile(compiler, input ?? stdin, options, completer);
return completer.future; return completer.future;
} }
...@@ -9,7 +9,7 @@ class _MockedCompiler extends Mock implements frontend.CompilerInterface {} ...@@ -9,7 +9,7 @@ class _MockedCompiler extends Mock implements frontend.CompilerInterface {}
Future<int> main() async { Future<int> main() async {
group('basic', () { group('basic', () {
final frontend.CompilerInterface compiler = new _MockedCompiler(); final frontend.CompilerInterface compiler = _MockedCompiler();
test('train with mocked compiler completes', () async { test('train with mocked compiler completes', () async {
expect(await starter(<String>['--train'], compiler: compiler), equals(0)); expect(await starter(<String>['--train'], compiler: compiler), equals(0));
......
...@@ -24,7 +24,7 @@ class Scene extends NativeFieldWrapperClass2 { ...@@ -24,7 +24,7 @@ class Scene extends NativeFieldWrapperClass2 {
/// This is a slow operation that is performed on a background thread. /// This is a slow operation that is performed on a background thread.
Future<Image> toImage(int width, int height) { Future<Image> toImage(int width, int height) {
if (width <= 0 || height <= 0) if (width <= 0 || height <= 0)
throw new Exception('Invalid image dimensions.'); throw Exception('Invalid image dimensions.');
return _futurize( return _futurize(
(_Callback<Image> callback) => _toImage(width, height, callback) (_Callback<Image> callback) => _toImage(width, height, callback)
); );
...@@ -242,7 +242,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { ...@@ -242,7 +242,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
/// Adds a [Picture] to the scene. /// Adds a [Picture] to the scene.
/// ///
/// The picture is rasterized at the given offset. /// The picture is rasterized at the given offset.
void addPicture(Offset offset, Picture picture, { bool isComplexHint: false, bool willChangeHint: false }) { void addPicture(Offset offset, Picture picture, { bool isComplexHint = false, bool willChangeHint = false }) {
int hints = 0; int hints = 0;
if (isComplexHint) if (isComplexHint)
hints |= 1; hints |= 1;
...@@ -263,7 +263,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { ...@@ -263,7 +263,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
/// previous or new size, to workaround this the framework "freezes" the /// previous or new size, to workaround this the framework "freezes" the
/// texture just before resizing the Android view and un-freezes it when it is /// texture just before resizing the Android view and un-freezes it when it is
/// certain that a frame with the new size is ready. /// certain that a frame with the new size is ready.
void addTexture(int textureId, { Offset offset: Offset.zero, double width: 0.0, double height: 0.0 , bool freeze: false}) { void addTexture(int textureId, { Offset offset = Offset.zero, double width = 0.0, double height = 0.0 , bool freeze = false}) {
assert(offset != null, 'Offset argument was null'); assert(offset != null, 'Offset argument was null');
_addTexture(offset.dx, offset.dy, width, height, textureId, freeze); _addTexture(offset.dx, offset.dy, width, height, textureId, freeze);
} }
...@@ -285,7 +285,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 { ...@@ -285,7 +285,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
/// With a platform view in the scene, Quartz has to composite the two Flutter surfaces and the /// With a platform view in the scene, Quartz has to composite the two Flutter surfaces and the
/// embedded UIView. In addition to that, on iOS versions greater than 9, the Flutter frames are /// embedded UIView. In addition to that, on iOS versions greater than 9, the Flutter frames are
/// synchronized with the UIView frames adding additional performance overhead. /// synchronized with the UIView frames adding additional performance overhead.
void addPlatformView(int viewId, { Offset offset: Offset.zero, double width: 0.0, double height: 0.0}) { void addPlatformView(int viewId, { Offset offset = Offset.zero, double width = 0.0, double height = 0.0}) {
assert(offset != null, 'Offset argument was null'); assert(offset != null, 'Offset argument was null');
_addPlatformView(offset.dx, offset.dy, width, height, viewId); _addPlatformView(offset.dx, offset.dy, width, height, viewId);
} }
...@@ -294,11 +294,11 @@ class SceneBuilder extends NativeFieldWrapperClass2 { ...@@ -294,11 +294,11 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
/// (Fuchsia-only) Adds a scene rendered by another application to the scene /// (Fuchsia-only) Adds a scene rendered by another application to the scene
/// for this application. /// for this application.
void addChildScene({ void addChildScene({
Offset offset: Offset.zero, Offset offset = Offset.zero,
double width: 0.0, double width = 0.0,
double height: 0.0, double height = 0.0,
SceneHost sceneHost, SceneHost sceneHost,
bool hitTestable: true bool hitTestable = true
}) { }) {
_addChildScene(offset.dx, _addChildScene(offset.dx,
offset.dy, offset.dy,
......
此差异已折叠。
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
part of dart.ui; part of dart.ui;
class _HashEnd { const _HashEnd(); } class _HashEnd { const _HashEnd(); }
const _HashEnd _hashEnd = const _HashEnd(); const _HashEnd _hashEnd = _HashEnd();
/// Jenkins hash function, optimized for small integers. /// Jenkins hash function, optimized for small integers.
// //
......
...@@ -31,13 +31,13 @@ void _updateWindowMetrics(double devicePixelRatio, ...@@ -31,13 +31,13 @@ void _updateWindowMetrics(double devicePixelRatio,
double viewInsetLeft) { double viewInsetLeft) {
window window
.._devicePixelRatio = devicePixelRatio .._devicePixelRatio = devicePixelRatio
.._physicalSize = new Size(width, height) .._physicalSize = Size(width, height)
.._padding = new WindowPadding._( .._padding = WindowPadding._(
top: paddingTop, top: paddingTop,
right: paddingRight, right: paddingRight,
bottom: paddingBottom, bottom: paddingBottom,
left: paddingLeft) left: paddingLeft)
.._viewInsets = new WindowPadding._( .._viewInsets = WindowPadding._(
top: viewInsetTop, top: viewInsetTop,
right: viewInsetRight, right: viewInsetRight,
bottom: viewInsetBottom, bottom: viewInsetBottom,
...@@ -63,12 +63,12 @@ _LocaleClosure _getLocaleClosure() => _localeClosure; ...@@ -63,12 +63,12 @@ _LocaleClosure _getLocaleClosure() => _localeClosure;
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;
window._locales = new List<Locale>(numLocales); window._locales = List<Locale>(numLocales);
for (int localeIndex = 0; localeIndex < numLocales; localeIndex++) { for (int localeIndex = 0; localeIndex < numLocales; localeIndex++) {
final String countryCode = locales[localeIndex * stringsPerLocale + 1]; final String countryCode = locales[localeIndex * stringsPerLocale + 1];
final String scriptCode = locales[localeIndex * stringsPerLocale + 2]; final String scriptCode = locales[localeIndex * stringsPerLocale + 2];
window._locales[localeIndex] = new Locale.fromSubtags( window._locales[localeIndex] = Locale.fromSubtags(
languageCode: locales[localeIndex * stringsPerLocale], languageCode: locales[localeIndex * stringsPerLocale],
countryCode: countryCode.isEmpty ? null : countryCode, countryCode: countryCode.isEmpty ? null : countryCode,
scriptCode: scriptCode.isEmpty ? null : scriptCode, scriptCode: scriptCode.isEmpty ? null : scriptCode,
...@@ -123,7 +123,7 @@ void _updateSemanticsEnabled(bool enabled) { ...@@ -123,7 +123,7 @@ void _updateSemanticsEnabled(bool enabled) {
@pragma('vm:entry-point') @pragma('vm:entry-point')
// ignore: unused_element // ignore: unused_element
void _updateAccessibilityFeatures(int values) { void _updateAccessibilityFeatures(int values) {
final AccessibilityFeatures newFeatures = new AccessibilityFeatures._(values); final AccessibilityFeatures newFeatures = AccessibilityFeatures._(values);
if (newFeatures == window._accessibilityFeatures) if (newFeatures == window._accessibilityFeatures)
return; return;
window._accessibilityFeatures = newFeatures; window._accessibilityFeatures = newFeatures;
...@@ -169,7 +169,7 @@ void _dispatchSemanticsAction(int id, int action, ByteData args) { ...@@ -169,7 +169,7 @@ void _dispatchSemanticsAction(int id, int action, ByteData args) {
@pragma('vm:entry-point') @pragma('vm:entry-point')
// ignore: unused_element // 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, Duration(microseconds: microseconds));
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
...@@ -277,11 +277,11 @@ PointerDataPacket _unpackPointerDataPacket(ByteData packet) { ...@@ -277,11 +277,11 @@ PointerDataPacket _unpackPointerDataPacket(ByteData packet) {
const int kBytesPerPointerData = _kPointerDataFieldCount * kStride; const int kBytesPerPointerData = _kPointerDataFieldCount * kStride;
final int length = packet.lengthInBytes ~/ kBytesPerPointerData; final int length = packet.lengthInBytes ~/ kBytesPerPointerData;
assert(length * kBytesPerPointerData == packet.lengthInBytes); assert(length * kBytesPerPointerData == packet.lengthInBytes);
final List<PointerData> data = new List<PointerData>(length); final List<PointerData> data = List<PointerData>(length);
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i) {
int offset = i * _kPointerDataFieldCount; int offset = i * _kPointerDataFieldCount;
data[i] = new PointerData( data[i] = PointerData(
timeStamp: new Duration(microseconds: packet.getInt64(kStride * offset++, _kFakeHostEndian)), timeStamp: Duration(microseconds: packet.getInt64(kStride * offset++, _kFakeHostEndian)),
change: PointerChange.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)], change: PointerChange.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
kind: PointerDeviceKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)], kind: PointerDeviceKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
signalKind: PointerSignalKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)], signalKind: PointerSignalKind.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
...@@ -308,5 +308,5 @@ PointerDataPacket _unpackPointerDataPacket(ByteData packet) { ...@@ -308,5 +308,5 @@ PointerDataPacket _unpackPointerDataPacket(ByteData packet) {
); );
assert(offset == (i + 1) * _kPointerDataFieldCount); assert(offset == (i + 1) * _kPointerDataFieldCount);
} }
return new PointerDataPacket(data: data); return PointerDataPacket(data: data);
} }
...@@ -24,7 +24,7 @@ Future<developer.ServiceExtensionResponse> _scheduleFrame( ...@@ -24,7 +24,7 @@ Future<developer.ServiceExtensionResponse> _scheduleFrame(
// Schedule the frame. // Schedule the frame.
window.scheduleFrame(); window.scheduleFrame();
// Always succeed. // Always succeed.
return new developer.ServiceExtensionResponse.result(json.encode(<String, String>{ return developer.ServiceExtensionResponse.result(json.encode(<String, String>{
'type': 'Success', 'type': 'Success',
})); }));
} }
......
此差异已折叠。
...@@ -62,7 +62,7 @@ class PluginUtilities { ...@@ -62,7 +62,7 @@ class PluginUtilities {
assert(callback != null, "'callback' must not be null."); assert(callback != null, "'callback' must not be null.");
return _forwardCache.putIfAbsent(callback, () { return _forwardCache.putIfAbsent(callback, () {
final int handle = _getCallbackHandle(callback); final int handle = _getCallbackHandle(callback);
return handle != null ? new CallbackHandle.fromRawHandle(handle) : null; return handle != null ? CallbackHandle.fromRawHandle(handle) : null;
}); });
} }
......
...@@ -70,30 +70,30 @@ enum PointerSignalKind { ...@@ -70,30 +70,30 @@ enum PointerSignalKind {
class PointerData { class PointerData {
/// Creates an object that represents the state of a pointer. /// Creates an object that represents the state of a pointer.
const PointerData({ const PointerData({
this.timeStamp: Duration.zero, this.timeStamp = Duration.zero,
this.change: PointerChange.cancel, this.change = PointerChange.cancel,
this.kind: PointerDeviceKind.touch, this.kind = PointerDeviceKind.touch,
this.signalKind, this.signalKind,
this.device: 0, this.device = 0,
this.physicalX: 0.0, this.physicalX = 0.0,
this.physicalY: 0.0, this.physicalY = 0.0,
this.buttons: 0, this.buttons = 0,
this.obscured: false, this.obscured = false,
this.pressure: 0.0, this.pressure = 0.0,
this.pressureMin: 0.0, this.pressureMin = 0.0,
this.pressureMax: 0.0, this.pressureMax = 0.0,
this.distance: 0.0, this.distance = 0.0,
this.distanceMax: 0.0, this.distanceMax = 0.0,
this.size: 0.0, this.size = 0.0,
this.radiusMajor: 0.0, this.radiusMajor = 0.0,
this.radiusMinor: 0.0, this.radiusMinor = 0.0,
this.radiusMin: 0.0, this.radiusMin = 0.0,
this.radiusMax: 0.0, this.radiusMax = 0.0,
this.orientation: 0.0, this.orientation = 0.0,
this.tilt: 0.0, this.tilt = 0.0,
this.platformData: 0, this.platformData = 0,
this.scrollDeltaX: 0.0, this.scrollDeltaX = 0.0,
this.scrollDeltaY: 0.0, this.scrollDeltaY = 0.0,
}); });
/// Time of event dispatch, relative to an arbitrary timeline. /// Time of event dispatch, relative to an arbitrary timeline.
...@@ -267,7 +267,7 @@ class PointerData { ...@@ -267,7 +267,7 @@ class PointerData {
/// A sequence of reports about the state of pointers. /// A sequence of reports about the state of pointers.
class PointerDataPacket { class PointerDataPacket {
/// Creates a packet of pointer data reports. /// Creates a packet of pointer data reports.
const PointerDataPacket({ this.data: const <PointerData>[] }); const PointerDataPacket({ this.data = const <PointerData>[] });
/// Data about the individual pointers in this packet. /// Data about the individual pointers in this packet.
/// ///
......
...@@ -42,55 +42,55 @@ class SemanticsAction { ...@@ -42,55 +42,55 @@ class SemanticsAction {
/// The equivalent of a user briefly tapping the screen with the finger /// The equivalent of a user briefly tapping the screen with the finger
/// without moving it. /// without moving it.
static const SemanticsAction tap = const SemanticsAction._(_kTapIndex); static const SemanticsAction tap = SemanticsAction._(_kTapIndex);
/// The equivalent of a user pressing and holding the screen with the finger /// The equivalent of a user pressing and holding the screen with the finger
/// for a few seconds without moving it. /// for a few seconds without moving it.
static const SemanticsAction longPress = const SemanticsAction._(_kLongPressIndex); static const SemanticsAction longPress = SemanticsAction._(_kLongPressIndex);
/// The equivalent of a user moving their finger across the screen from right /// The equivalent of a user moving their finger across the screen from right
/// to left. /// to left.
/// ///
/// This action should be recognized by controls that are horizontally /// This action should be recognized by controls that are horizontally
/// scrollable. /// scrollable.
static const SemanticsAction scrollLeft = const SemanticsAction._(_kScrollLeftIndex); static const SemanticsAction scrollLeft = SemanticsAction._(_kScrollLeftIndex);
/// The equivalent of a user moving their finger across the screen from left /// The equivalent of a user moving their finger across the screen from left
/// to right. /// to right.
/// ///
/// This action should be recognized by controls that are horizontally /// This action should be recognized by controls that are horizontally
/// scrollable. /// scrollable.
static const SemanticsAction scrollRight = const SemanticsAction._(_kScrollRightIndex); static const SemanticsAction scrollRight = SemanticsAction._(_kScrollRightIndex);
/// The equivalent of a user moving their finger across the screen from /// The equivalent of a user moving their finger across the screen from
/// bottom to top. /// bottom to top.
/// ///
/// This action should be recognized by controls that are vertically /// This action should be recognized by controls that are vertically
/// scrollable. /// scrollable.
static const SemanticsAction scrollUp = const SemanticsAction._(_kScrollUpIndex); static const SemanticsAction scrollUp = SemanticsAction._(_kScrollUpIndex);
/// The equivalent of a user moving their finger across the screen from top /// The equivalent of a user moving their finger across the screen from top
/// to bottom. /// to bottom.
/// ///
/// This action should be recognized by controls that are vertically /// This action should be recognized by controls that are vertically
/// scrollable. /// scrollable.
static const SemanticsAction scrollDown = const SemanticsAction._(_kScrollDownIndex); static const SemanticsAction scrollDown = SemanticsAction._(_kScrollDownIndex);
/// A request to increase the value represented by the semantics node. /// A request to increase the value represented by the semantics node.
/// ///
/// For example, this action might be recognized by a slider control. /// For example, this action might be recognized by a slider control.
static const SemanticsAction increase = const SemanticsAction._(_kIncreaseIndex); static const SemanticsAction increase = SemanticsAction._(_kIncreaseIndex);
/// A request to decrease the value represented by the semantics node. /// A request to decrease the value represented by the semantics node.
/// ///
/// For example, this action might be recognized by a slider control. /// For example, this action might be recognized by a slider control.
static const SemanticsAction decrease = const SemanticsAction._(_kDecreaseIndex); static const SemanticsAction decrease = SemanticsAction._(_kDecreaseIndex);
/// A request to fully show the semantics node on screen. /// A request to fully show the semantics node on screen.
/// ///
/// For example, this action might be send to a node in a scrollable list that /// For example, this action might be send to a node in a scrollable list that
/// is partially off screen to bring it on screen. /// is partially off screen to bring it on screen.
static const SemanticsAction showOnScreen = const SemanticsAction._(_kShowOnScreenIndex); static const SemanticsAction showOnScreen = SemanticsAction._(_kShowOnScreenIndex);
/// Move the cursor forward by one character. /// Move the cursor forward by one character.
/// ///
...@@ -98,7 +98,7 @@ class SemanticsAction { ...@@ -98,7 +98,7 @@ class SemanticsAction {
/// ///
/// The action includes a boolean argument, which indicates whether the cursor /// The action includes a boolean argument, which indicates whether the cursor
/// movement should extend (or start) a selection. /// movement should extend (or start) a selection.
static const SemanticsAction moveCursorForwardByCharacter = const SemanticsAction._(_kMoveCursorForwardByCharacterIndex); static const SemanticsAction moveCursorForwardByCharacter = SemanticsAction._(_kMoveCursorForwardByCharacterIndex);
/// Move the cursor backward by one character. /// Move the cursor backward by one character.
/// ///
...@@ -106,7 +106,7 @@ class SemanticsAction { ...@@ -106,7 +106,7 @@ class SemanticsAction {
/// ///
/// The action includes a boolean argument, which indicates whether the cursor /// The action includes a boolean argument, which indicates whether the cursor
/// movement should extend (or start) a selection. /// movement should extend (or start) a selection.
static const SemanticsAction moveCursorBackwardByCharacter = const SemanticsAction._(_kMoveCursorBackwardByCharacterIndex); static const SemanticsAction moveCursorBackwardByCharacter = SemanticsAction._(_kMoveCursorBackwardByCharacterIndex);
/// Set the text selection to the given range. /// Set the text selection to the given range.
/// ///
...@@ -117,16 +117,16 @@ class SemanticsAction { ...@@ -117,16 +117,16 @@ class SemanticsAction {
/// ///
/// Setting `base` and `extent` to the same value will move the cursor to /// Setting `base` and `extent` to the same value will move the cursor to
/// that position (without selecting anything). /// that position (without selecting anything).
static const SemanticsAction setSelection = const SemanticsAction._(_kSetSelectionIndex); static const SemanticsAction setSelection = SemanticsAction._(_kSetSelectionIndex);
/// Copy the current selection to the clipboard. /// Copy the current selection to the clipboard.
static const SemanticsAction copy = const SemanticsAction._(_kCopyIndex); static const SemanticsAction copy = SemanticsAction._(_kCopyIndex);
/// Cut the current selection and place it in the clipboard. /// Cut the current selection and place it in the clipboard.
static const SemanticsAction cut = const SemanticsAction._(_kCutIndex); static const SemanticsAction cut = SemanticsAction._(_kCutIndex);
/// Paste the current content of the clipboard. /// Paste the current content of the clipboard.
static const SemanticsAction paste = const SemanticsAction._(_kPasteIndex); static const SemanticsAction paste = SemanticsAction._(_kPasteIndex);
/// Indicates that the node has gained accessibility focus. /// Indicates that the node has gained accessibility focus.
/// ///
...@@ -139,7 +139,7 @@ class SemanticsAction { ...@@ -139,7 +139,7 @@ class SemanticsAction {
/// The accessibility focus is different from the input focus. The input focus /// The accessibility focus is different from the input focus. The input focus
/// is usually held by the element that currently responds to keyboard inputs. /// is usually held by the element that currently responds to keyboard inputs.
/// Accessibility focus and input focus can be held by two different nodes! /// Accessibility focus and input focus can be held by two different nodes!
static const SemanticsAction didGainAccessibilityFocus = const SemanticsAction._(_kDidGainAccessibilityFocusIndex); static const SemanticsAction didGainAccessibilityFocus = SemanticsAction._(_kDidGainAccessibilityFocusIndex);
/// Indicates that the node has lost accessibility focus. /// Indicates that the node has lost accessibility focus.
/// ///
...@@ -152,13 +152,13 @@ class SemanticsAction { ...@@ -152,13 +152,13 @@ class SemanticsAction {
/// The accessibility focus is different from the input focus. The input focus /// The accessibility focus is different from the input focus. The input focus
/// is usually held by the element that currently responds to keyboard inputs. /// is usually held by the element that currently responds to keyboard inputs.
/// Accessibility focus and input focus can be held by two different nodes! /// Accessibility focus and input focus can be held by two different nodes!
static const SemanticsAction didLoseAccessibilityFocus = const SemanticsAction._(_kDidLoseAccessibilityFocusIndex); static const SemanticsAction didLoseAccessibilityFocus = SemanticsAction._(_kDidLoseAccessibilityFocusIndex);
/// Indicates that the user has invoked a custom accessibility action. /// Indicates that the user has invoked a custom accessibility action.
/// ///
/// This handler is added automatically whenever a custom accessibility /// This handler is added automatically whenever a custom accessibility
/// action is added to a semantics node. /// action is added to a semantics node.
static const SemanticsAction customAction = const SemanticsAction._(_kCustomAction); static const SemanticsAction customAction = SemanticsAction._(_kCustomAction);
/// A request that the node should be dismissed. /// A request that the node should be dismissed.
/// ///
...@@ -167,7 +167,7 @@ class SemanticsAction { ...@@ -167,7 +167,7 @@ class SemanticsAction {
/// (with TalkBack) special hint text is spoken when focusing the node and /// (with TalkBack) special hint text is spoken when focusing the node and
/// a custom action is available in the local context menu. On iOS, /// a custom action is available in the local context menu. On iOS,
/// (with VoiceOver) users can perform a standard gesture to dismiss it. /// (with VoiceOver) users can perform a standard gesture to dismiss it.
static const SemanticsAction dismiss = const SemanticsAction._(_kDismissIndex); static const SemanticsAction dismiss = SemanticsAction._(_kDismissIndex);
/// Move the cursor forward by one word. /// Move the cursor forward by one word.
/// ///
...@@ -175,7 +175,7 @@ class SemanticsAction { ...@@ -175,7 +175,7 @@ class SemanticsAction {
/// ///
/// The action includes a boolean argument, which indicates whether the cursor /// The action includes a boolean argument, which indicates whether the cursor
/// movement should extend (or start) a selection. /// movement should extend (or start) a selection.
static const SemanticsAction moveCursorForwardByWord = const SemanticsAction._(_kMoveCursorForwardByWordIndex); static const SemanticsAction moveCursorForwardByWord = SemanticsAction._(_kMoveCursorForwardByWordIndex);
/// Move the cursor backward by one word. /// Move the cursor backward by one word.
/// ///
...@@ -183,13 +183,13 @@ class SemanticsAction { ...@@ -183,13 +183,13 @@ class SemanticsAction {
/// ///
/// The action includes a boolean argument, which indicates whether the cursor /// The action includes a boolean argument, which indicates whether the cursor
/// movement should extend (or start) a selection. /// movement should extend (or start) a selection.
static const SemanticsAction moveCursorBackwardByWord = const SemanticsAction._(_kMoveCursorBackwardByWordIndex); static const SemanticsAction moveCursorBackwardByWord = SemanticsAction._(_kMoveCursorBackwardByWordIndex);
/// The possible semantics actions. /// The possible semantics actions.
/// ///
/// The map's key is the [index] of the action and the value is the action /// The map's key is the [index] of the action and the value is the action
/// itself. /// itself.
static const Map<int, SemanticsAction> values = const <int, SemanticsAction>{ static const Map<int, SemanticsAction> values = <int, SemanticsAction>{
_kTapIndex: tap, _kTapIndex: tap,
_kLongPressIndex: longPress, _kLongPressIndex: longPress,
_kScrollLeftIndex: scrollLeft, _kScrollLeftIndex: scrollLeft,
...@@ -305,7 +305,7 @@ class SemanticsFlag { ...@@ -305,7 +305,7 @@ class SemanticsFlag {
/// See also: /// See also:
/// ///
/// * [SemanticsFlag.isChecked], which controls whether the node is "checked" or "unchecked". /// * [SemanticsFlag.isChecked], which controls whether the node is "checked" or "unchecked".
static const SemanticsFlag hasCheckedState = const SemanticsFlag._(_kHasCheckedStateIndex); static const SemanticsFlag hasCheckedState = SemanticsFlag._(_kHasCheckedStateIndex);
/// Whether a semantics node that [hasCheckedState] is checked. /// Whether a semantics node that [hasCheckedState] is checked.
/// ///
...@@ -317,7 +317,7 @@ class SemanticsFlag { ...@@ -317,7 +317,7 @@ class SemanticsFlag {
/// See also: /// See also:
/// ///
/// * [SemanticsFlag.hasCheckedState], which enables a checked state. /// * [SemanticsFlag.hasCheckedState], which enables a checked state.
static const SemanticsFlag isChecked = const SemanticsFlag._(_kIsCheckedIndex); static const SemanticsFlag isChecked = SemanticsFlag._(_kIsCheckedIndex);
/// Whether a semantics node is selected. /// Whether a semantics node is selected.
...@@ -326,25 +326,25 @@ class SemanticsFlag { ...@@ -326,25 +326,25 @@ class SemanticsFlag {
/// "unselected". /// "unselected".
/// ///
/// For example, the active tab in a tab bar has [isSelected] set to true. /// For example, the active tab in a tab bar has [isSelected] set to true.
static const SemanticsFlag isSelected = const SemanticsFlag._(_kIsSelectedIndex); static const SemanticsFlag isSelected = SemanticsFlag._(_kIsSelectedIndex);
/// Whether the semantic node represents a button. /// Whether the semantic node represents a button.
/// ///
/// Platforms has special handling for buttons, for example Android's TalkBack /// Platforms has special handling for buttons, for example Android's TalkBack
/// and iOS's VoiceOver provides an additional hint when the focused object is /// and iOS's VoiceOver provides an additional hint when the focused object is
/// a button. /// a button.
static const SemanticsFlag isButton = const SemanticsFlag._(_kIsButtonIndex); static const SemanticsFlag isButton = SemanticsFlag._(_kIsButtonIndex);
/// Whether the semantic node represents a text field. /// Whether the semantic node represents a text field.
/// ///
/// Text fields are announced as such and allow text input via accessibility /// Text fields are announced as such and allow text input via accessibility
/// affordances. /// affordances.
static const SemanticsFlag isTextField = const SemanticsFlag._(_kIsTextFieldIndex); static const SemanticsFlag isTextField = SemanticsFlag._(_kIsTextFieldIndex);
/// Whether the semantic node currently holds the user's focus. /// Whether the semantic node currently holds the user's focus.
/// ///
/// The focused element is usually the current receiver of keyboard inputs. /// The focused element is usually the current receiver of keyboard inputs.
static const SemanticsFlag isFocused = const SemanticsFlag._(_kIsFocusedIndex); static const SemanticsFlag isFocused = SemanticsFlag._(_kIsFocusedIndex);
/// The semantics node has the quality of either being "enabled" or /// The semantics node has the quality of either being "enabled" or
/// "disabled". /// "disabled".
...@@ -352,33 +352,33 @@ class SemanticsFlag { ...@@ -352,33 +352,33 @@ class SemanticsFlag {
/// For example, a button can be enabled or disabled and therefore has an /// For example, a button can be enabled or disabled and therefore has an
/// "enabled" state. Static text is usually neither enabled nor disabled and /// "enabled" state. Static text is usually neither enabled nor disabled and
/// therefore does not have an "enabled" state. /// therefore does not have an "enabled" state.
static const SemanticsFlag hasEnabledState = const SemanticsFlag._(_kHasEnabledStateIndex); static const SemanticsFlag hasEnabledState = SemanticsFlag._(_kHasEnabledStateIndex);
/// Whether a semantic node that [hasEnabledState] is currently enabled. /// Whether a semantic node that [hasEnabledState] is currently enabled.
/// ///
/// A disabled element does not respond to user interaction. For example, a /// A disabled element does not respond to user interaction. For example, a
/// button that currently does not respond to user interaction should be /// button that currently does not respond to user interaction should be
/// marked as disabled. /// marked as disabled.
static const SemanticsFlag isEnabled = const SemanticsFlag._(_kIsEnabledIndex); static const SemanticsFlag isEnabled = SemanticsFlag._(_kIsEnabledIndex);
/// Whether a semantic node is in a mutually exclusive group. /// Whether a semantic node is in a mutually exclusive group.
/// ///
/// For example, a radio button is in a mutually exclusive group because /// For example, a radio button is in a mutually exclusive group because
/// only one radio button in that group can be marked as [isChecked]. /// only one radio button in that group can be marked as [isChecked].
static const SemanticsFlag isInMutuallyExclusiveGroup = const SemanticsFlag._(_kIsInMutuallyExclusiveGroupIndex); static const SemanticsFlag isInMutuallyExclusiveGroup = SemanticsFlag._(_kIsInMutuallyExclusiveGroupIndex);
/// Whether a semantic node is a header that divides content into sections. /// Whether a semantic node is a header that divides content into sections.
/// ///
/// For example, headers can be used to divide a list of alphabetically /// For example, headers can be used to divide a list of alphabetically
/// sorted words into the sections A, B, C, etc. as can be found in many /// sorted words into the sections A, B, C, etc. as can be found in many
/// address book applications. /// address book applications.
static const SemanticsFlag isHeader = const SemanticsFlag._(_kIsHeaderIndex); static const SemanticsFlag isHeader = SemanticsFlag._(_kIsHeaderIndex);
/// Whether the value of the semantics node is obscured. /// Whether the value of the semantics node is obscured.
/// ///
/// This is usually used for text fields to indicate that its content /// This is usually used for text fields to indicate that its content
/// is a password or contains other sensitive information. /// is a password or contains other sensitive information.
static const SemanticsFlag isObscured = const SemanticsFlag._(_kIsObscuredIndex); static const SemanticsFlag isObscured = SemanticsFlag._(_kIsObscuredIndex);
/// Whether the semantics node is the root of a subtree for which a route name /// Whether the semantics node is the root of a subtree for which a route name
/// should be announced. /// should be announced.
...@@ -403,7 +403,7 @@ class SemanticsFlag { ...@@ -403,7 +403,7 @@ class SemanticsFlag {
/// ///
/// This is used in widgets such as Routes, Drawers, and Dialogs to /// This is used in widgets such as Routes, Drawers, and Dialogs to
/// communicate significant changes in the visible screen. /// communicate significant changes in the visible screen.
static const SemanticsFlag scopesRoute = const SemanticsFlag._(_kScopesRouteIndex); static const SemanticsFlag scopesRoute = SemanticsFlag._(_kScopesRouteIndex);
/// Whether the semantics node label is the name of a visually distinct /// Whether the semantics node label is the name of a visually distinct
/// route. /// route.
...@@ -416,7 +416,7 @@ class SemanticsFlag { ...@@ -416,7 +416,7 @@ class SemanticsFlag {
/// ///
/// Updating this label within the same active route subtree will not cause /// Updating this label within the same active route subtree will not cause
/// additional announcements. /// additional announcements.
static const SemanticsFlag namesRoute = const SemanticsFlag._(_kNamesRouteIndex); static const SemanticsFlag namesRoute = SemanticsFlag._(_kNamesRouteIndex);
/// Whether the semantics node is considered hidden. /// Whether the semantics node is considered hidden.
/// ///
...@@ -434,13 +434,13 @@ class SemanticsFlag { ...@@ -434,13 +434,13 @@ class SemanticsFlag {
/// the semantics tree altogether. Hidden elements are only included in the /// the semantics tree altogether. Hidden elements are only included in the
/// semantics tree to work around platform limitations and they are mainly /// semantics tree to work around platform limitations and they are mainly
/// used to implement accessibility scrolling on iOS. /// used to implement accessibility scrolling on iOS.
static const SemanticsFlag isHidden = const SemanticsFlag._(_kIsHiddenIndex); static const SemanticsFlag isHidden = SemanticsFlag._(_kIsHiddenIndex);
/// Whether the semantics node represents an image. /// Whether the semantics node represents an image.
/// ///
/// Both TalkBack and VoiceOver will inform the user the the semantics node /// Both TalkBack and VoiceOver will inform the user the the semantics node
/// represents an image. /// represents an image.
static const SemanticsFlag isImage = const SemanticsFlag._(_kIsImageIndex); static const SemanticsFlag isImage = SemanticsFlag._(_kIsImageIndex);
/// Whether the semantics node is a live region. /// Whether the semantics node is a live region.
/// ///
...@@ -451,7 +451,7 @@ class SemanticsFlag { ...@@ -451,7 +451,7 @@ class SemanticsFlag {
/// An example of a live region is a [SnackBar] widget. On Android, A live /// An example of a live region is a [SnackBar] widget. On Android, A live
/// region causes a polite announcement to be generated automatically, even /// region causes a polite announcement to be generated automatically, even
/// if the user does not have focus of the widget. /// if the user does not have focus of the widget.
static const SemanticsFlag isLiveRegion = const SemanticsFlag._(_kIsLiveRegionIndex); static const SemanticsFlag isLiveRegion = SemanticsFlag._(_kIsLiveRegionIndex);
/// The semantics node has the quality of either being "on" or "off". /// The semantics node has the quality of either being "on" or "off".
/// ///
...@@ -462,7 +462,7 @@ class SemanticsFlag { ...@@ -462,7 +462,7 @@ class SemanticsFlag {
/// See also: /// See also:
/// ///
/// * [SemanticsFlag.isToggled], which controls whether the node is "on" or "off". /// * [SemanticsFlag.isToggled], which controls whether the node is "on" or "off".
static const SemanticsFlag hasToggledState = const SemanticsFlag._(_kHasToggledStateIndex); static const SemanticsFlag hasToggledState = SemanticsFlag._(_kHasToggledStateIndex);
/// If true, the semantics node is "on". If false, the semantics node is /// If true, the semantics node is "on". If false, the semantics node is
/// "off". /// "off".
...@@ -472,7 +472,7 @@ class SemanticsFlag { ...@@ -472,7 +472,7 @@ class SemanticsFlag {
/// See also: /// See also:
/// ///
/// * [SemanticsFlag.hasToggledState], which enables a toggled state. /// * [SemanticsFlag.hasToggledState], which enables a toggled state.
static const SemanticsFlag isToggled = const SemanticsFlag._(_kIsToggledIndex); static const SemanticsFlag isToggled = SemanticsFlag._(_kIsToggledIndex);
/// Whether the platform can scroll the semantics node when the user attempts /// Whether the platform can scroll the semantics node when the user attempts
/// to move focus to an offscreen child. /// to move focus to an offscreen child.
...@@ -481,12 +481,12 @@ class SemanticsFlag { ...@@ -481,12 +481,12 @@ class SemanticsFlag {
/// easily move the accessibility focus to the next set of children. A /// easily move the accessibility focus to the next set of children. A
/// [PageView] widget does not have implicit scrolling, so that users don't /// [PageView] widget does not have implicit scrolling, so that users don't
/// navigate to the next page when reaching the end of the current one. /// navigate to the next page when reaching the end of the current one.
static const SemanticsFlag hasImplicitScrolling = const SemanticsFlag._(_kHasImplicitScrollingIndex); static const SemanticsFlag hasImplicitScrolling = SemanticsFlag._(_kHasImplicitScrollingIndex);
/// The possible semantics flags. /// The possible semantics flags.
/// ///
/// The map's key is the [index] of the flag and the value is the flag itself. /// The map's key is the [index] of the flag and the value is the flag itself.
static const Map<int, SemanticsFlag> values = const <int, SemanticsFlag>{ static const Map<int, SemanticsFlag> values = <int, SemanticsFlag>{
_kHasCheckedStateIndex: hasCheckedState, _kHasCheckedStateIndex: hasCheckedState,
_kIsCheckedIndex: isChecked, _kIsCheckedIndex: isChecked,
_kIsSelectedIndex: isSelected, _kIsSelectedIndex: isSelected,
......
...@@ -21,31 +21,31 @@ class FontWeight { ...@@ -21,31 +21,31 @@ class FontWeight {
final int index; final int index;
/// Thin, the least thick /// Thin, the least thick
static const FontWeight w100 = const FontWeight._(0); static const FontWeight w100 = FontWeight._(0);
/// Extra-light /// Extra-light
static const FontWeight w200 = const FontWeight._(1); static const FontWeight w200 = FontWeight._(1);
/// Light /// Light
static const FontWeight w300 = const FontWeight._(2); static const FontWeight w300 = FontWeight._(2);
/// Normal / regular / plain /// Normal / regular / plain
static const FontWeight w400 = const FontWeight._(3); static const FontWeight w400 = FontWeight._(3);
/// Medium /// Medium
static const FontWeight w500 = const FontWeight._(4); static const FontWeight w500 = FontWeight._(4);
/// Semi-bold /// Semi-bold
static const FontWeight w600 = const FontWeight._(5); static const FontWeight w600 = FontWeight._(5);
/// Bold /// Bold
static const FontWeight w700 = const FontWeight._(6); static const FontWeight w700 = FontWeight._(6);
/// Extra-bold /// Extra-bold
static const FontWeight w800 = const FontWeight._(7); static const FontWeight w800 = FontWeight._(7);
/// Black, the most thick /// Black, the most thick
static const FontWeight w900 = const FontWeight._(8); static const FontWeight w900 = FontWeight._(8);
/// The default font weight. /// The default font weight.
static const FontWeight normal = w400; static const FontWeight normal = w400;
...@@ -54,7 +54,7 @@ class FontWeight { ...@@ -54,7 +54,7 @@ class FontWeight {
static const FontWeight bold = w700; static const FontWeight bold = w700;
/// A list of all the font weights. /// A list of all the font weights.
static const List<FontWeight> values = const <FontWeight>[ static const List<FontWeight> values = <FontWeight>[
w100, w200, w300, w400, w500, w600, w700, w800, w900 w100, w200, w300, w400, w500, w600, w700, w800, w900
]; ];
...@@ -153,7 +153,7 @@ class TextDecoration { ...@@ -153,7 +153,7 @@ class TextDecoration {
int mask = 0; int mask = 0;
for (TextDecoration decoration in decorations) for (TextDecoration decoration in decorations)
mask |= decoration._mask; mask |= decoration._mask;
return new TextDecoration._(mask); return TextDecoration._(mask);
} }
final int _mask; final int _mask;
...@@ -164,16 +164,16 @@ class TextDecoration { ...@@ -164,16 +164,16 @@ class TextDecoration {
} }
/// Do not draw a decoration /// Do not draw a decoration
static const TextDecoration none = const TextDecoration._(0x0); static const TextDecoration none = TextDecoration._(0x0);
/// Draw a line underneath each line of text /// Draw a line underneath each line of text
static const TextDecoration underline = const TextDecoration._(0x1); static const TextDecoration underline = TextDecoration._(0x1);
/// Draw a line above each line of text /// Draw a line above each line of text
static const TextDecoration overline = const TextDecoration._(0x2); static const TextDecoration overline = TextDecoration._(0x2);
/// Draw a line through each line of text /// Draw a line through each line of text
static const TextDecoration lineThrough = const TextDecoration._(0x4); static const TextDecoration lineThrough = TextDecoration._(0x4);
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
...@@ -283,7 +283,7 @@ Int32List _encodeTextStyle( ...@@ -283,7 +283,7 @@ Int32List _encodeTextStyle(
Paint foreground, Paint foreground,
List<Shadow> shadows List<Shadow> shadows
) { ) {
final Int32List result = new Int32List(8); final Int32List result = Int32List(8);
if (color != null) { if (color != null) {
result[0] |= 1 << 1; result[0] |= 1 << 1;
result[1] = color.value; result[1] = color.value;
...@@ -408,7 +408,7 @@ class TextStyle { ...@@ -408,7 +408,7 @@ class TextStyle {
List<Shadow> shadows, List<Shadow> shadows,
}) : assert(color == null || foreground == null, }) : assert(color == null || foreground == null,
'Cannot provide both a color and a foreground\n' 'Cannot provide both a color and a foreground\n'
'The color argument is just a shorthand for "foreground: new Paint()..color = color".' 'The color argument is just a shorthand for "foreground: Paint()..color = color".'
), ),
_encoded = _encodeTextStyle( _encoded = _encodeTextStyle(
color, color,
...@@ -489,9 +489,9 @@ class TextStyle { ...@@ -489,9 +489,9 @@ class TextStyle {
@override @override
String toString() { String toString() {
return 'TextStyle(' return 'TextStyle('
'color: ${ _encoded[0] & 0x00002 == 0x00002 ? new Color(_encoded[1]) : "unspecified"}, ' 'color: ${ _encoded[0] & 0x00002 == 0x00002 ? Color(_encoded[1]) : "unspecified"}, '
'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? new TextDecoration._(_encoded[2]) : "unspecified"}, ' 'decoration: ${ _encoded[0] & 0x00004 == 0x00004 ? TextDecoration._(_encoded[2]) : "unspecified"}, '
'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? new Color(_encoded[3]) : "unspecified"}, ' 'decorationColor: ${ _encoded[0] & 0x00008 == 0x00008 ? Color(_encoded[3]) : "unspecified"}, '
'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, ' 'decorationStyle: ${ _encoded[0] & 0x00010 == 0x00010 ? TextDecorationStyle.values[_encoded[4]] : "unspecified"}, '
// The decorationThickness is not in encoded order in order to keep it near the other decoration properties. // The decorationThickness is not in encoded order in order to keep it near the other decoration properties.
'decorationThickness: ${_encoded[0] & 0x00100 == 0x00100 ? _decorationThickness : "unspecified"}, ' 'decorationThickness: ${_encoded[0] & 0x00100 == 0x00100 ? _decorationThickness : "unspecified"}, '
...@@ -547,7 +547,7 @@ Int32List _encodeParagraphStyle( ...@@ -547,7 +547,7 @@ Int32List _encodeParagraphStyle(
String ellipsis, String ellipsis,
Locale locale, Locale locale,
) { ) {
final Int32List result = new Int32List(6); // also update paragraph_builder.cc final Int32List result = Int32List(6); // also update paragraph_builder.cc
if (textAlign != null) { if (textAlign != null) {
result[0] |= 1 << 1; result[0] |= 1 << 1;
result[1] = textAlign.index; result[1] = textAlign.index;
...@@ -1028,7 +1028,7 @@ class TextBox { ...@@ -1028,7 +1028,7 @@ class TextBox {
final TextDirection direction; final TextDirection direction;
/// Returns a rect of the same size as this box. /// Returns a rect of the same size as this box.
Rect toRect() => new Rect.fromLTRB(left, top, right, bottom); Rect toRect() => Rect.fromLTRB(left, top, right, bottom);
/// The [left] edge of the box for left-to-right text; the [right] edge of the box for right-to-left text. /// The [left] edge of the box for left-to-right text; the [right] edge of the box for right-to-left text.
/// ///
...@@ -1139,7 +1139,7 @@ class TextPosition { ...@@ -1139,7 +1139,7 @@ class TextPosition {
/// The arguments must not be null (so the [offset] argument is required). /// The arguments must not be null (so the [offset] argument is required).
const TextPosition({ const TextPosition({
this.offset, this.offset,
this.affinity: TextAffinity.downstream, this.affinity = TextAffinity.downstream,
}) : assert(offset != null), }) : assert(offset != null),
assert(affinity != null); assert(affinity != null);
...@@ -1377,7 +1377,7 @@ class Paragraph extends NativeFieldWrapperClass2 { ...@@ -1377,7 +1377,7 @@ class Paragraph extends NativeFieldWrapperClass2 {
/// Returns the text position closest to the given offset. /// Returns the text position closest to the given offset.
TextPosition getPositionForOffset(Offset offset) { TextPosition getPositionForOffset(Offset offset) {
final List<int> encoded = _getPositionForOffset(offset.dx, offset.dy); final List<int> encoded = _getPositionForOffset(offset.dx, offset.dy);
return new TextPosition(offset: encoded[0], affinity: TextAffinity.values[encoded[1]]); return TextPosition(offset: encoded[0], affinity: TextAffinity.values[encoded[1]]);
} }
List<int> _getPositionForOffset(double dx, double dy) native 'Paragraph_getPositionForOffset'; List<int> _getPositionForOffset(double dx, double dy) native 'Paragraph_getPositionForOffset';
...@@ -1410,7 +1410,7 @@ class Paragraph extends NativeFieldWrapperClass2 { ...@@ -1410,7 +1410,7 @@ class Paragraph extends NativeFieldWrapperClass2 {
/// paint it with [Canvas.drawParagraph]. /// paint it with [Canvas.drawParagraph].
class ParagraphBuilder extends NativeFieldWrapperClass2 { class ParagraphBuilder extends NativeFieldWrapperClass2 {
/// Creates a [ParagraphBuilder] object, which is used to create a /// Creates a new [ParagraphBuilder] object, which is used to create a
/// [Paragraph]. /// [Paragraph].
@pragma('vm:entry-point') @pragma('vm:entry-point')
ParagraphBuilder(ParagraphStyle style) { ParagraphBuilder(ParagraphStyle style) {
...@@ -1503,7 +1503,7 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 { ...@@ -1503,7 +1503,7 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
void addText(String text) { void addText(String text) {
final String error = _addText(text); final String error = _addText(text);
if (error != null) if (error != null)
throw new ArgumentError(error); throw ArgumentError(error);
} }
String _addText(String text) native 'ParagraphBuilder_addText'; String _addText(String text) native 'ParagraphBuilder_addText';
......
...@@ -108,7 +108,7 @@ class WindowPadding { ...@@ -108,7 +108,7 @@ class WindowPadding {
final double bottom; final double bottom;
/// A window padding that has zeros for each edge. /// A window padding that has zeros for each edge.
static const WindowPadding zero = const WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0); static const WindowPadding zero = WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
@override @override
String toString() { String toString() {
...@@ -141,8 +141,8 @@ class Locale { ...@@ -141,8 +141,8 @@ class Locale {
/// For example: /// For example:
/// ///
/// ```dart /// ```dart
/// const Locale swissFrench = const Locale('fr', 'CH'); /// const Locale swissFrench = Locale('fr', 'CH');
/// const Locale canadianFrench = const Locale('fr', 'CA'); /// const Locale canadianFrench = Locale('fr', 'CA');
/// ``` /// ```
/// ///
/// The primary language subtag must not be null. The region subtag is /// The primary language subtag must not be null. The region subtag is
...@@ -228,7 +228,7 @@ class Locale { ...@@ -228,7 +228,7 @@ class Locale {
// This map is generated by //flutter/tools/gen_locale.dart // This map is generated by //flutter/tools/gen_locale.dart
// Mappings generated for language subtag registry as of 2019-02-27. // Mappings generated for language subtag registry as of 2019-02-27.
static const Map<String, String> _deprecatedLanguageSubtagMap = const <String, String>{ static const Map<String, String> _deprecatedLanguageSubtagMap = <String, String>{
'in': 'id', // Indonesian; deprecated 1989-01-01 'in': 'id', // Indonesian; deprecated 1989-01-01
'iw': 'he', // Hebrew; deprecated 1989-01-01 'iw': 'he', // Hebrew; deprecated 1989-01-01
'ji': 'yi', // Yiddish; deprecated 1989-01-01 'ji': 'yi', // Yiddish; deprecated 1989-01-01
...@@ -347,7 +347,7 @@ class Locale { ...@@ -347,7 +347,7 @@ class Locale {
// This map is generated by //flutter/tools/gen_locale.dart // This map is generated by //flutter/tools/gen_locale.dart
// Mappings generated for language subtag registry as of 2019-02-27. // Mappings generated for language subtag registry as of 2019-02-27.
static const Map<String, String> _deprecatedRegionSubtagMap = const <String, String>{ static const Map<String, String> _deprecatedRegionSubtagMap = <String, String>{
'BU': 'MM', // Burma; deprecated 1989-12-05 'BU': 'MM', // Burma; deprecated 1989-12-05
'DD': 'DE', // German Democratic Republic; deprecated 1990-10-30 'DD': 'DE', // German Democratic Republic; deprecated 1990-10-30
'FX': 'FR', // Metropolitan France; deprecated 1997-07-14 'FX': 'FR', // Metropolitan France; deprecated 1997-07-14
...@@ -867,7 +867,7 @@ class Window { ...@@ -867,7 +867,7 @@ class Window {
final String error = final String error =
_sendPlatformMessage(name, _zonedPlatformMessageResponseCallback(callback), data); _sendPlatformMessage(name, _zonedPlatformMessageResponseCallback(callback), data);
if (error != null) if (error != null)
throw new Exception(error); throw Exception(error);
} }
String _sendPlatformMessage(String name, String _sendPlatformMessage(String name,
PlatformMessageResponseCallback callback, PlatformMessageResponseCallback callback,
...@@ -1002,4 +1002,4 @@ enum Brightness { ...@@ -1002,4 +1002,4 @@ enum Brightness {
/// The [Window] singleton. This object exposes the size of the display, the /// The [Window] singleton. This object exposes the size of the display, the
/// core scheduler API, the input event callback, the graphics drawing API, and /// core scheduler API, the input event callback, the graphics drawing API, and
/// other such core services. /// other such core services.
final Window window = new Window._(); final Window window = Window._();
...@@ -10,53 +10,53 @@ void main() { ...@@ -10,53 +10,53 @@ void main() {
@pragma('vm:entry-point') @pragma('vm:entry-point')
void sayHi() { void sayHi() {
print("Hi"); print('Hi');
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
void throwExceptionNow() { void throwExceptionNow() {
throw("Hello"); throw 'Hello';
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
void canRegisterNativeCallback() async { void canRegisterNativeCallback() async {
print("In function canRegisterNativeCallback"); print('In function canRegisterNativeCallback');
NotifyNative(); notifyNative();
print("Called native method from canRegisterNativeCallback"); print('Called native method from canRegisterNativeCallback');
} }
void NotifyNative() native "NotifyNative"; void notifyNative() native 'NotifyNative';
@pragma('vm:entry-point') @pragma('vm:entry-point')
void testIsolateShutdown() { } void testIsolateShutdown() { }
@pragma('vm:entry-point') @pragma('vm:entry-point')
void testCanSaveCompilationTrace() { void testCanSaveCompilationTrace() {
List<int> trace = null; List<int> trace;
try { try {
trace = saveCompilationTrace(); trace = saveCompilationTrace();
} catch (exception) { } catch (exception) {
print("Could not save compilation trace: " + exception); print('Could not save compilation trace: ' + exception);
} }
NotifyResult(trace != null && trace.length > 0); notifyResult(trace != null && trace.isNotEmpty);
} }
void NotifyResult(bool success) native "NotifyNative"; void notifyResult(bool success) native 'NotifyNative';
void PassMessage(String message) native "PassMessage"; void passMessage(String message) native 'PassMessage';
void secondaryIsolateMain(String message) { void secondaryIsolateMain(String message) {
print("Secondary isolate got message: " + message); print('Secondary isolate got message: ' + message);
PassMessage("Hello from code is secondary isolate."); passMessage('Hello from code is secondary isolate.');
NotifyNative(); notifyNative();
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
void testCanLaunchSecondaryIsolate() { void testCanLaunchSecondaryIsolate() {
Isolate.spawn(secondaryIsolateMain, "Hello from root isolate."); Isolate.spawn(secondaryIsolateMain, 'Hello from root isolate.');
NotifyNative(); notifyNative();
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
void testCanRecieveArguments(List<String> args) { void testCanRecieveArguments(List<String> args) {
NotifyResult(args != null && args.length == 1 && args[0] == "arg1"); notifyResult(args != null && args.length == 1 && args[0] == 'arg1');
} }
...@@ -4,24 +4,24 @@ ...@@ -4,24 +4,24 @@
import 'dart:isolate'; import 'dart:isolate';
main() {} void main() {}
@pragma('vm:entry-point') @pragma('vm:entry-point')
fixturesAreFunctionalMain() { void fixturesAreFunctionalMain() {
SayHiFromFixturesAreFunctionalMain(); sayHiFromFixturesAreFunctionalMain();
} }
void SayHiFromFixturesAreFunctionalMain() native "SayHiFromFixturesAreFunctionalMain"; void sayHiFromFixturesAreFunctionalMain() native 'SayHiFromFixturesAreFunctionalMain';
void NotifyNative() native "NotifyNative"; void notifyNative() native 'NotifyNative';
void secondaryIsolateMain(String message) { void secondaryIsolateMain(String message) {
print("Secondary isolate got message: " + message); print('Secondary isolate got message: ' + message);
NotifyNative(); notifyNative();
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
void testCanLaunchSecondaryIsolate() { void testCanLaunchSecondaryIsolate() {
Isolate.spawn(secondaryIsolateMain, "Hello from root isolate."); Isolate.spawn(secondaryIsolateMain, 'Hello from root isolate.');
NotifyNative(); notifyNative();
} }
...@@ -9,7 +9,7 @@ void customEntrypoint() { ...@@ -9,7 +9,7 @@ void customEntrypoint() {
sayHiFromCustomEntrypoint(); sayHiFromCustomEntrypoint();
} }
void sayHiFromCustomEntrypoint() native "SayHiFromCustomEntrypoint"; void sayHiFromCustomEntrypoint() native 'SayHiFromCustomEntrypoint';
@pragma('vm:entry-point') @pragma('vm:entry-point')
...@@ -19,9 +19,9 @@ void customEntrypoint1() { ...@@ -19,9 +19,9 @@ void customEntrypoint1() {
sayHiFromCustomEntrypoint3(); sayHiFromCustomEntrypoint3();
} }
void sayHiFromCustomEntrypoint1() native "SayHiFromCustomEntrypoint1"; void sayHiFromCustomEntrypoint1() native 'SayHiFromCustomEntrypoint1';
void sayHiFromCustomEntrypoint2() native "SayHiFromCustomEntrypoint2"; void sayHiFromCustomEntrypoint2() native 'SayHiFromCustomEntrypoint2';
void sayHiFromCustomEntrypoint3() native "SayHiFromCustomEntrypoint3"; void sayHiFromCustomEntrypoint3() native 'SayHiFromCustomEntrypoint3';
@pragma('vm:entry-point') @pragma('vm:entry-point')
...@@ -51,16 +51,16 @@ void notifySemanticsAction(int nodeId, int action, List<int> data) native 'Notif ...@@ -51,16 +51,16 @@ void notifySemanticsAction(int nodeId, int action, List<int> data) native 'Notif
/// Returns a future that completes when `window.onSemanticsEnabledChanged` /// Returns a future that completes when `window.onSemanticsEnabledChanged`
/// fires. /// fires.
Future get semanticsChanged { Future<void> get semanticsChanged {
final Completer semanticsChanged = Completer(); final Completer<void> semanticsChanged = Completer<void>();
window.onSemanticsEnabledChanged = semanticsChanged.complete; window.onSemanticsEnabledChanged = semanticsChanged.complete;
return semanticsChanged.future; return semanticsChanged.future;
} }
/// Returns a future that completes when `window.onAccessibilityFeaturesChanged` /// Returns a future that completes when `window.onAccessibilityFeaturesChanged`
/// fires. /// fires.
Future get accessibilityFeaturesChanged { Future<void> get accessibilityFeaturesChanged {
final Completer featuresChanged = Completer(); final Completer<void> featuresChanged = Completer<void>();
window.onAccessibilityFeaturesChanged = featuresChanged.complete; window.onAccessibilityFeaturesChanged = featuresChanged.complete;
return featuresChanged.future; return featuresChanged.future;
} }
...@@ -73,7 +73,7 @@ class SemanticsActionData { ...@@ -73,7 +73,7 @@ class SemanticsActionData {
} }
Future<SemanticsActionData> get semanticsAction { Future<SemanticsActionData> get semanticsAction {
final Completer actionReceived = Completer<SemanticsActionData>(); final Completer<SemanticsActionData> actionReceived = Completer<SemanticsActionData>();
window.onSemanticsAction = (int id, SemanticsAction action, ByteData args) { window.onSemanticsAction = (int id, SemanticsAction action, ByteData args) {
actionReceived.complete(SemanticsActionData(id, action, args)); actionReceived.complete(SemanticsActionData(id, action, args));
}; };
...@@ -81,7 +81,7 @@ Future<SemanticsActionData> get semanticsAction { ...@@ -81,7 +81,7 @@ Future<SemanticsActionData> get semanticsAction {
} }
@pragma('vm:entry-point') @pragma('vm:entry-point')
void a11y_main() async { void a11y_main() async { // ignore: non_constant_identifier_names
// Return initial state (semantics disabled). // Return initial state (semantics disabled).
notifySemanticsEnabled(window.semanticsEnabled); notifySemanticsEnabled(window.semanticsEnabled);
......
...@@ -9,7 +9,7 @@ import 'dart:convert'; ...@@ -9,7 +9,7 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
class ShellProcess { class ShellProcess {
final Completer<Uri> _observatoryUriCompleter = new Completer<Uri>(); final Completer<Uri> _observatoryUriCompleter = Completer<Uri>();
final Process _process; final Process _process;
ShellProcess(this._process) : assert(_process != null) { ShellProcess(this._process) : assert(_process != null) {
...@@ -67,7 +67,7 @@ class ShellLauncher { ...@@ -67,7 +67,7 @@ class ShellLauncher {
shellArguments.addAll(args); shellArguments.addAll(args);
print('Launching $shellExecutablePath $shellArguments'); print('Launching $shellExecutablePath $shellArguments');
final Process process = await Process.start(shellExecutablePath, shellArguments); final Process process = await Process.start(shellExecutablePath, shellArguments);
return new ShellProcess(process); return ShellProcess(process);
} catch (e) { } catch (e) {
print('Error launching shell: $e'); print('Error launching shell: $e');
} }
......
...@@ -30,7 +30,7 @@ class ServiceClient { ...@@ -30,7 +30,7 @@ class ServiceClient {
'id': key, 'id': key,
}); });
client.add(request); client.add(request);
final Completer<Map<String, dynamic>> completer = new Completer<Map<String, dynamic>>(); final Completer<Map<String, dynamic>> completer = Completer<Map<String, dynamic>>();
_outstandingRequests[key] = completer; _outstandingRequests[key] = completer;
print('-> $key ($method)'); print('-> $key ($method)');
return completer.future; return completer.future;
......
...@@ -48,8 +48,8 @@ class Expect { ...@@ -48,8 +48,8 @@ class Expect {
} }
Future<String> readResponse(HttpClientResponse response) { Future<String> readResponse(HttpClientResponse response) {
final Completer<String> completer = new Completer<String>(); final Completer<String> completer = Completer<String>();
final StringBuffer contents = new StringBuffer(); final StringBuffer contents = StringBuffer();
response.transform(utf8.decoder).listen((String data) { response.transform(utf8.decoder).listen((String data) {
contents.write(data); contents.write(data);
}, onDone: () => completer.complete(contents.toString())); }, onDone: () => completer.complete(contents.toString()));
...@@ -59,7 +59,7 @@ Future<String> readResponse(HttpClientResponse response) { ...@@ -59,7 +59,7 @@ Future<String> readResponse(HttpClientResponse response) {
// Test accessing the service protocol over http. // Test accessing the service protocol over http.
Future<Null> testHttpProtocolRequest(Uri uri) async { Future<Null> testHttpProtocolRequest(Uri uri) async {
uri = uri.replace(path: 'getVM'); uri = uri.replace(path: 'getVM');
final HttpClient client = new HttpClient(); final HttpClient client = HttpClient();
final HttpClientRequest request = await client.getUrl(uri); final HttpClientRequest request = await client.getUrl(uri);
final HttpClientResponse response = await request.close(); final HttpClientResponse response = await request.close();
Expect.equals(response.statusCode, 200); Expect.equals(response.statusCode, 200);
...@@ -72,7 +72,7 @@ Future<Null> testHttpProtocolRequest(Uri uri) async { ...@@ -72,7 +72,7 @@ Future<Null> testHttpProtocolRequest(Uri uri) async {
Future<Null> testWebSocketProtocolRequest(Uri uri) async { Future<Null> testWebSocketProtocolRequest(Uri uri) async {
uri = uri.replace(scheme: 'ws', path: 'ws'); uri = uri.replace(scheme: 'ws', path: 'ws');
final WebSocket webSocketClient = await WebSocket.connect(uri.toString()); final WebSocket webSocketClient = await WebSocket.connect(uri.toString());
final ServiceClient serviceClient = new ServiceClient(webSocketClient); final ServiceClient serviceClient = ServiceClient(webSocketClient);
final Map<String, dynamic> response = await serviceClient.invokeRPC('getVM'); final Map<String, dynamic> response = await serviceClient.invokeRPC('getVM');
Expect.equals(response['type'], 'VM'); Expect.equals(response['type'], 'VM');
try { try {
...@@ -87,7 +87,7 @@ Future<Null> testWebSocketProtocolRequest(Uri uri) async { ...@@ -87,7 +87,7 @@ Future<Null> testWebSocketProtocolRequest(Uri uri) async {
// Test accessing an Observatory UI asset. // Test accessing an Observatory UI asset.
Future<Null> testHttpAssetRequest(Uri uri) async { Future<Null> testHttpAssetRequest(Uri uri) async {
uri = uri.replace(path: 'third_party/trace_viewer_full.html'); uri = uri.replace(path: 'third_party/trace_viewer_full.html');
final HttpClient client = new HttpClient(); final HttpClient client = HttpClient();
final HttpClientRequest request = await client.getUrl(uri); final HttpClientRequest request = await client.getUrl(uri);
final HttpClientResponse response = await request.close(); final HttpClientResponse response = await request.close();
Expect.equals(response.statusCode, 200); Expect.equals(response.statusCode, 200);
...@@ -98,10 +98,10 @@ Future<Null> testHttpAssetRequest(Uri uri) async { ...@@ -98,10 +98,10 @@ Future<Null> testHttpAssetRequest(Uri uri) async {
Future<Null> testStartPaused(Uri uri) async { Future<Null> testStartPaused(Uri uri) async {
uri = uri.replace(scheme: 'ws', path: 'ws'); uri = uri.replace(scheme: 'ws', path: 'ws');
final WebSocket webSocketClient = await WebSocket.connect(uri.toString()); final WebSocket webSocketClient = await WebSocket.connect(uri.toString());
final Completer<dynamic> isolateStartedId = new Completer<dynamic>(); final Completer<dynamic> isolateStartedId = Completer<dynamic>();
final Completer<dynamic> isolatePausedId = new Completer<dynamic>(); final Completer<dynamic> isolatePausedId = Completer<dynamic>();
final Completer<dynamic> isolateResumeId = new Completer<dynamic>(); final Completer<dynamic> isolateResumeId = Completer<dynamic>();
final ServiceClient serviceClient = new ServiceClient(webSocketClient, final ServiceClient serviceClient = ServiceClient(webSocketClient,
isolateStartedId: isolateStartedId, isolateStartedId: isolateStartedId,
isolatePausedId: isolatePausedId, isolatePausedId: isolatePausedId,
isolateResumeId: isolateResumeId); isolateResumeId: isolateResumeId);
...@@ -187,13 +187,13 @@ Future<Null> main(List<String> args) async { ...@@ -187,13 +187,13 @@ Future<Null> main(List<String> args) async {
final List<String> extraArgs = args.length <= 2 ? <String>[] : args.sublist(2); final List<String> extraArgs = args.length <= 2 ? <String>[] : args.sublist(2);
final ShellLauncher launcher = final ShellLauncher launcher =
new ShellLauncher(shellExecutablePath, ShellLauncher(shellExecutablePath,
mainDartPath, mainDartPath,
false, false,
extraArgs); extraArgs);
final ShellLauncher startPausedlauncher = final ShellLauncher startPausedlauncher =
new ShellLauncher(shellExecutablePath, ShellLauncher(shellExecutablePath,
mainDartPath, mainDartPath,
true, true,
extraArgs); extraArgs);
......
...@@ -11,14 +11,14 @@ typedef CanvasCallback = void Function(Canvas canvas); ...@@ -11,14 +11,14 @@ 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(), const Rect.fromLTRB(0.0, 0.0, 0.0, 0.0)));
} catch (error) { } // ignore: empty_catches } catch (error) { } // ignore: empty_catches
} }
void main() { void main() {
test('canvas APIs should not crash', () async { test('canvas APIs should not crash', () async {
final Paint paint = Paint(); final Paint paint = Paint();
final Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan); const Rect rect = Rect.fromLTRB(double.nan, double.nan, double.nan, double.nan);
final RRect rrect = RRect.fromRectAndCorners(rect); final RRect rrect = RRect.fromRectAndCorners(rect);
const Offset offset = Offset(double.nan, double.nan); const Offset offset = Offset(double.nan, double.nan);
final Path path = Path(); final Path path = Path();
......
...@@ -21,7 +21,7 @@ void main() { ...@@ -21,7 +21,7 @@ void main() {
test('paint set to black', () { test('paint set to black', () {
const Color c = Color(0x00000000); const Color c = Color(0x00000000);
final Paint p = new Paint(); final Paint p = Paint();
p.color = c; p.color = c;
expect(c.toString(), equals('Color(0x00000000)')); expect(c.toString(), equals('Color(0x00000000)'));
}); });
...@@ -29,7 +29,7 @@ void main() { ...@@ -29,7 +29,7 @@ void main() {
test('color created with out of bounds value', () { test('color created with out of bounds value', () {
try { try {
const Color c = Color(0x100 << 24); const Color c = Color(0x100 << 24);
final Paint p = new Paint(); final Paint p = Paint();
p.color = c; p.color = c;
} catch (e) { } catch (e) {
expect(e != null, equals(true)); expect(e != null, equals(true));
...@@ -39,7 +39,7 @@ void main() { ...@@ -39,7 +39,7 @@ void main() {
test('color created with wildly out of bounds value', () { test('color created with wildly out of bounds value', () {
try { try {
const Color c = Color(1 << 1000000); const Color c = Color(1 << 1000000);
final Paint p = new Paint(); final Paint p = Paint();
p.color = c; p.color = c;
} catch (e) { } catch (e) {
expect(e != null, equals(true)); expect(e != null, equals(true));
......
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
0, 0, 0, double.infinity, 0, 0, 0, double.infinity,
]); ]);
expect( expect(
() => builder.pushTransform(matrix4NaN), () => builder.pushTransform(matrix4Infinity),
throwsA(const TypeMatcher<AssertionError>()), throwsA(const TypeMatcher<AssertionError>()),
); );
}); });
......
...@@ -9,7 +9,7 @@ import 'package:test/test.dart'; ...@@ -9,7 +9,7 @@ import 'package:test/test.dart';
void main() { void main() {
test('Gradient.radial with no focal point', () { test('Gradient.radial with no focal point', () {
expect( expect(
new Gradient.radial( Gradient.radial(
Offset.zero, Offset.zero,
null, null,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)], <Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
...@@ -23,7 +23,7 @@ void main() { ...@@ -23,7 +23,7 @@ void main() {
test('radial center and focal == Offset.zero and focalRadius == 0.0 is ok', test('radial center and focal == Offset.zero and focalRadius == 0.0 is ok',
() { () {
expect( expect(
() => new Gradient.radial( () => Gradient.radial(
Offset.zero, Offset.zero,
0.0, 0.0,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)], <Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
...@@ -38,7 +38,7 @@ void main() { ...@@ -38,7 +38,7 @@ void main() {
test('radial center != focal and focalRadius == 0.0 is ok', () { test('radial center != focal and focalRadius == 0.0 is ok', () {
expect( expect(
() => new Gradient.radial( () => Gradient.radial(
Offset.zero, Offset.zero,
0.0, 0.0,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)], <Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
...@@ -55,7 +55,7 @@ void main() { ...@@ -55,7 +55,7 @@ void main() {
test('radial center and focal == Offset.zero and focalRadius != 0.0 assert', test('radial center and focal == Offset.zero and focalRadius != 0.0 assert',
() { () {
expect( expect(
() => new Gradient.radial( () => Gradient.radial(
Offset.zero, Offset.zero,
0.0, 0.0,
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)], <Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
......
...@@ -9,37 +9,31 @@ import 'package:test/test.dart'; ...@@ -9,37 +9,31 @@ import 'package:test/test.dart';
void main() { void main() {
test('path getBounds', () { test('path getBounds', () {
final Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0); const Rect r = Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
final Path p = new Path()..addRect(r); final Path p = Path()..addRect(r);
expect(p.getBounds(), equals(r)); expect(p.getBounds(), equals(r));
p.lineTo(20.0, 15.0); p.lineTo(20.0, 15.0);
expect(p.getBounds(), equals(new Rect.fromLTRB(1.0, 3.0, 20.0, 15.0))); expect(p.getBounds(), equals(const Rect.fromLTRB(1.0, 3.0, 20.0, 15.0)));
}); });
test('path combine rect', () { test('path combine rect', () {
final Rect c1 = final Rect c1 = Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0);
new Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0); final Rect c2 = Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
final Rect c2 =
new Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
final Rect c1UnionC2 = c1.expandToInclude(c2); final Rect c1UnionC2 = c1.expandToInclude(c2);
final Rect c1IntersectC2 = c1.intersect(c2); final Rect c1IntersectC2 = c1.intersect(c2);
final Path pathCircle1 = new Path()..addRect(c1); final Path pathCircle1 = Path()..addRect(c1);
final Path pathCircle2 = new Path()..addRect(c2); final Path pathCircle2 = Path()..addRect(c2);
final Path difference = final Path difference = Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
expect(difference.getBounds(), equals(c1)); expect(difference.getBounds(), equals(c1));
final Path reverseDifference = final Path reverseDifference = Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2);
Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2);
expect(reverseDifference.getBounds(), equals(c2)); expect(reverseDifference.getBounds(), equals(c2));
final Path union = final Path union = Path.combine(PathOperation.union, pathCircle1, pathCircle2);
Path.combine(PathOperation.union, pathCircle1, pathCircle2);
expect(union.getBounds(), equals(c1UnionC2)); expect(union.getBounds(), equals(c1UnionC2));
final Path intersect = final Path intersect = Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
expect(intersect.getBounds(), equals(c1IntersectC2)); expect(intersect.getBounds(), equals(c1IntersectC2));
// the bounds on this will be the same as union - but would draw a missing inside piece. // the bounds on this will be the same as union - but would draw a missing inside piece.
...@@ -48,31 +42,24 @@ void main() { ...@@ -48,31 +42,24 @@ void main() {
}); });
test('path combine oval', () { test('path combine oval', () {
final Rect c1 = final Rect c1 = Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0);
new Rect.fromCircle(center: const Offset(10.0, 10.0), radius: 10.0); final Rect c2 = Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
final Rect c2 =
new Rect.fromCircle(center: const Offset(5.0, 5.0), radius: 10.0);
final Rect c1UnionC2 = c1.expandToInclude(c2); final Rect c1UnionC2 = c1.expandToInclude(c2);
final Rect c1IntersectC2 = c1.intersect(c2); final Rect c1IntersectC2 = c1.intersect(c2);
final Path pathCircle1 = new Path()..addOval(c1); final Path pathCircle1 = Path()..addOval(c1);
final Path pathCircle2 = new Path()..addOval(c2); final Path pathCircle2 = Path()..addOval(c2);
final Path difference = final Path difference = Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
Path.combine(PathOperation.difference, pathCircle1, pathCircle2);
expect(difference.getBounds().top, closeTo(0.88, 0.01)); expect(difference.getBounds().top, closeTo(0.88, 0.01));
final Path reverseDifference = final Path reverseDifference = Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2);
Path.combine(PathOperation.reverseDifference, pathCircle1, pathCircle2); expect(reverseDifference.getBounds().right, closeTo(14.11, 0.01));
expect(reverseDifference.getBounds().right,
closeTo(14.11, 0.01));
final Path union = final Path union = Path.combine(PathOperation.union, pathCircle1, pathCircle2);
Path.combine(PathOperation.union, pathCircle1, pathCircle2);
expect(union.getBounds(), equals(c1UnionC2)); expect(union.getBounds(), equals(c1UnionC2));
final Path intersect = final Path intersect = Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
Path.combine(PathOperation.intersect, pathCircle1, pathCircle2);
expect(intersect.getBounds(), equals(c1IntersectC2)); expect(intersect.getBounds(), equals(c1IntersectC2));
// the bounds on this will be the same as union - but would draw a missing inside piece. // the bounds on this will be the same as union - but would draw a missing inside piece.
...@@ -81,8 +68,8 @@ void main() { ...@@ -81,8 +68,8 @@ void main() {
}); });
test('path clone', () { test('path clone', () {
final Path p1 = new Path()..lineTo(20.0, 20.0); final Path p1 = Path()..lineTo(20.0, 20.0);
final Path p2 = new Path.from(p1); final Path p2 = Path.from(p1);
expect(p1.getBounds(), equals(p2.getBounds())); expect(p1.getBounds(), equals(p2.getBounds()));
...@@ -91,8 +78,8 @@ void main() { ...@@ -91,8 +78,8 @@ void main() {
}); });
test('transformation tests', () { test('transformation tests', () {
final Rect bounds = new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0); const Rect bounds = Rect.fromLTRB(0.0, 0.0, 10.0, 10.0);
final Path p = new Path()..addRect(bounds); final Path p = Path()..addRect(bounds);
final Float64List scaleMatrix = Float64List.fromList(<double>[ 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
...@@ -104,41 +91,37 @@ void main() { ...@@ -104,41 +91,37 @@ void main() {
final Path pTransformed = p.transform(scaleMatrix); final Path pTransformed = p.transform(scaleMatrix);
expect(pTransformed.getBounds(), expect(pTransformed.getBounds(),
equals(new Rect.fromLTRB(0.0, 0.0, 10 * 2.5, 10 * 0.5))); equals(const Rect.fromLTRB(0.0, 0.0, 10 * 2.5, 10 * 0.5)));
final Path p2 = new Path()..lineTo(10.0, 10.0); final Path p2 = Path()..lineTo(10.0, 10.0);
p.addPath(p2, const Offset(10.0, 10.0)); p.addPath(p2, const Offset(10.0, 10.0));
expect(p.getBounds(), equals(new Rect.fromLTRB(0.0, 0.0, 20.0, 20.0))); expect(p.getBounds(), equals(const Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)));
p.addPath(p2, const Offset(20.0, 20.0), matrix4: scaleMatrix); p.addPath(p2, const Offset(20.0, 20.0), matrix4: scaleMatrix);
expect(p.getBounds(), expect(p.getBounds(),
equals(new Rect.fromLTRB(0.0, 0.0, 20 + (10 * 2.5), 20 + (10 * .5)))); equals(const Rect.fromLTRB(0.0, 0.0, 20 + (10 * 2.5), 20 + (10 * .5))));
p.extendWithPath(p2, const Offset(0.0, 0.0)); p.extendWithPath(p2, const Offset(0.0, 0.0));
expect(p.getBounds(), equals(new Rect.fromLTRB(0.0, 0.0, 45.0, 25.0))); expect(p.getBounds(), equals(const Rect.fromLTRB(0.0, 0.0, 45.0, 25.0)));
p.extendWithPath(p2, const Offset(45.0, 25.0), matrix4: scaleMatrix); p.extendWithPath(p2, const Offset(45.0, 25.0), matrix4: scaleMatrix);
expect(p.getBounds(), equals(new Rect.fromLTRB(0.0, 0.0, 70.0, 30.0))); expect(p.getBounds(), equals(const Rect.fromLTRB(0.0, 0.0, 70.0, 30.0)));
}); });
test('path metrics tests', () { test('path metrics tests', () {
final Path simpleHorizontalLine = new Path()..lineTo(10.0, 0.0); final Path simpleHorizontalLine = Path()..lineTo(10.0, 0.0);
// basic tests on horizontal line // basic tests on horizontal line
final PathMetrics simpleHorizontalMetrics = final PathMetrics simpleHorizontalMetrics = simpleHorizontalLine.computeMetrics();
simpleHorizontalLine.computeMetrics();
expect(simpleHorizontalMetrics.iterator.current, isNull); expect(simpleHorizontalMetrics.iterator.current, isNull);
expect(simpleHorizontalMetrics.iterator.moveNext(), isTrue); expect(simpleHorizontalMetrics.iterator.moveNext(), isTrue);
expect(simpleHorizontalMetrics.iterator.current, isNotNull); expect(simpleHorizontalMetrics.iterator.current, isNotNull);
expect(simpleHorizontalMetrics.iterator.current.length, equals(10.0)); expect(simpleHorizontalMetrics.iterator.current.length, equals(10.0));
expect(simpleHorizontalMetrics.iterator.current.isClosed, isFalse); expect(simpleHorizontalMetrics.iterator.current.isClosed, isFalse);
final Path simpleExtract = final Path simpleExtract = simpleHorizontalMetrics.iterator.current.extractPath(1.0, 9.0);
simpleHorizontalMetrics.iterator.current.extractPath(1.0, 9.0); expect(simpleExtract.getBounds(), equals(const Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
expect(simpleExtract.getBounds(), final Tangent posTan = simpleHorizontalMetrics.iterator.current.getTangentForOffset(1.0);
equals(new Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
final Tangent posTan =
simpleHorizontalMetrics.iterator.current.getTangentForOffset(1.0);
expect(posTan, isNotNull); expect(posTan, isNotNull);
expect(posTan.position, equals(const Offset(1.0, 0.0))); expect(posTan.position, equals(const Offset(1.0, 0.0)));
expect(posTan.angle, equals(0.0)); expect(posTan.angle, equals(0.0));
...@@ -147,43 +130,33 @@ void main() { ...@@ -147,43 +130,33 @@ void main() {
expect(simpleHorizontalMetrics.iterator.current, isNull); expect(simpleHorizontalMetrics.iterator.current, isNull);
// test with forceClosed // test with forceClosed
final PathMetrics simpleMetricsClosed = final PathMetrics simpleMetricsClosed = simpleHorizontalLine.computeMetrics(forceClosed: true);
simpleHorizontalLine.computeMetrics(forceClosed: true);
expect(simpleMetricsClosed.iterator.current, isNull); expect(simpleMetricsClosed.iterator.current, isNull);
expect(simpleMetricsClosed.iterator.moveNext(), isTrue); expect(simpleMetricsClosed.iterator.moveNext(), isTrue);
expect(simpleMetricsClosed.iterator.current, isNotNull); expect(simpleMetricsClosed.iterator.current, isNotNull);
expect(simpleMetricsClosed.iterator.current.length, expect(simpleMetricsClosed.iterator.current.length, equals(20.0)); // because we forced close
equals(20.0)); // because we forced close
expect(simpleMetricsClosed.iterator.current.isClosed, isTrue); expect(simpleMetricsClosed.iterator.current.isClosed, isTrue);
final Path simpleExtract2 = final Path simpleExtract2 = simpleMetricsClosed.iterator.current.extractPath(1.0, 9.0);
simpleMetricsClosed.iterator.current.extractPath(1.0, 9.0); expect(simpleExtract2.getBounds(), equals(const Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
expect(simpleExtract2.getBounds(),
equals(new Rect.fromLTRB(1.0, 0.0, 9.0, 0.0)));
expect(simpleMetricsClosed.iterator.moveNext(), isFalse); expect(simpleMetricsClosed.iterator.moveNext(), isFalse);
// test getTangentForOffset with vertical line // test getTangentForOffset with vertical line
final Path simpleVerticalLine = new Path()..lineTo(0.0, 10.0); final Path simpleVerticalLine = Path()..lineTo(0.0, 10.0);
final PathMetrics simpleMetricsVertical = final PathMetrics simpleMetricsVertical = simpleVerticalLine.computeMetrics()..iterator.moveNext();
simpleVerticalLine.computeMetrics()..iterator.moveNext(); final Tangent posTanVertical = simpleMetricsVertical.iterator.current.getTangentForOffset(5.0);
final Tangent posTanVertical =
simpleMetricsVertical.iterator.current.getTangentForOffset(5.0);
expect(posTanVertical.position, equals(const Offset(0.0, 5.0))); expect(posTanVertical.position, equals(const Offset(0.0, 5.0)));
expect(posTanVertical.angle, expect(posTanVertical.angle, closeTo(-1.5708, .0001)); // 90 degrees
closeTo(-1.5708, .0001)); // 90 degrees
// test getTangentForOffset with diagonal line // test getTangentForOffset with diagonal line
final Path simpleDiagonalLine = new Path()..lineTo(10.0, 10.0); final Path simpleDiagonalLine = Path()..lineTo(10.0, 10.0);
final PathMetrics simpleMetricsDiagonal = final PathMetrics simpleMetricsDiagonal = simpleDiagonalLine.computeMetrics()..iterator.moveNext();
simpleDiagonalLine.computeMetrics()..iterator.moveNext();
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(const 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
// test a multi-contour path // test a multi-contour path
final Path multiContour = new Path() final Path multiContour = Path()
..lineTo(0.0, 10.0) ..lineTo(0.0, 10.0)
..moveTo(10.0, 10.0) ..moveTo(10.0, 10.0)
..lineTo(10.0, 15.0); ..lineTo(10.0, 15.0);
......
...@@ -159,7 +159,7 @@ void main() { ...@@ -159,7 +159,7 @@ void main() {
}; };
}); });
final ByteData testData = new ByteData.view(new Uint8List(0).buffer); final ByteData testData = ByteData.view(Uint8List(0).buffer);
_dispatchPointerDataPacket(testData); _dispatchPointerDataPacket(testData);
expect(runZone, isNotNull); expect(runZone, isNotNull);
expect(runZone, same(innerZone)); expect(runZone, same(innerZone));
......
...@@ -12,7 +12,7 @@ void main() { ...@@ -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), expectAsync1((ByteData data) { window.sendPlatformMessage('test', ByteData.view(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));
......
...@@ -59,6 +59,8 @@ pushd "$BUILDROOT_DIR/flutter/testing/dart" ...@@ -59,6 +59,8 @@ pushd "$BUILDROOT_DIR/flutter/testing/dart"
"$HOST_DIR/dart-sdk/bin/pub" get "$HOST_DIR/dart-sdk/bin/pub" get
popd popd
"$HOST_DIR/dart" --version
run_test () { run_test () {
"$HOST_DIR/dart" $HOST_DIR/gen/frontend_server.dart.snapshot \ "$HOST_DIR/dart" $HOST_DIR/gen/frontend_server.dart.snapshot \
--sdk-root $HOST_DIR/flutter_patched_sdk \ --sdk-root $HOST_DIR/flutter_patched_sdk \
......
...@@ -32,12 +32,12 @@ void main(List<String> arguments) { ...@@ -32,12 +32,12 @@ void main(List<String> arguments) {
} else if (Platform.isMacOS) { } else if (Platform.isMacOS) {
platform = 'mac-x64'; platform = 'mac-x64';
} else { } else {
throw new UnimplementedError('Script only support running on Linux or MacOS.'); throw UnimplementedError('Script only support running on Linux or MacOS.');
} }
final String nmPath = p.join(buildToolsPath, platform, 'clang', 'bin', 'llvm-nm'); final String nmPath = p.join(buildToolsPath, platform, 'clang', 'bin', 'llvm-nm');
assert(new Directory(outPath).existsSync()); assert(new Directory(outPath).existsSync());
final Iterable<String> releaseBuilds = new Directory(outPath).listSync() final Iterable<String> releaseBuilds = Directory(outPath).listSync()
.where((FileSystemEntity entity) => entity is Directory) .where((FileSystemEntity entity) => entity is Directory)
.map<String>((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'));
...@@ -101,16 +101,16 @@ int _checkAndroid(String outPath, String nmPath, Iterable<String> builds) { ...@@ -101,16 +101,16 @@ int _checkAndroid(String outPath, String nmPath, Iterable<String> builds) {
continue; continue;
} }
final Iterable<NmEntry> entries = NmEntry.parse(nmResult.stdout); final Iterable<NmEntry> entries = NmEntry.parse(nmResult.stdout);
final Map<String, String> entryMap = Map.fromIterable( final Map<String, String> entryMap = Map<String, String>.fromIterable(
entries, entries,
key: (entry) => entry.name, key: (dynamic entry) => entry.name,
value: (entry) => entry.type); value: (dynamic entry) => entry.type);
final Map<String, String> expectedSymbols = { final Map<String, String> expectedSymbols = <String, String>{
'JNI_OnLoad': 'T', 'JNI_OnLoad': 'T',
'_binary_icudtl_dat_size': 'A', '_binary_icudtl_dat_size': 'A',
'_binary_icudtl_dat_start': 'D', '_binary_icudtl_dat_start': 'D',
}; };
if (!MapEquality<String, String>().equals(entryMap, expectedSymbols)) { if (!const MapEquality<String, String>().equals(entryMap, expectedSymbols)) {
print('ERROR: $libFlutter exports the wrong symbols'); print('ERROR: $libFlutter exports the wrong symbols');
print(' Expected $expectedSymbols'); print(' Expected $expectedSymbols');
print(' Library has $entryMap.'); print(' Library has $entryMap.');
...@@ -132,7 +132,7 @@ class NmEntry { ...@@ -132,7 +132,7 @@ class NmEntry {
static Iterable<NmEntry> parse(String stdout) { static Iterable<NmEntry> parse(String stdout) {
return LineSplitter.split(stdout).map((String line) { return LineSplitter.split(stdout).map((String line) {
final List<String> parts = line.split(' '); final List<String> parts = line.split(' ');
return new NmEntry._(parts[0], parts[1], parts.last); return NmEntry._(parts[0], parts[1], parts.last);
}); });
} }
} }
...@@ -39,7 +39,7 @@ Map<String, List<String>> parseSection(String section) { ...@@ -39,7 +39,7 @@ Map<String, List<String>> parseSection(String section) {
} }
Future<Null> main() async { Future<Null> main() async {
final HttpClient client = new HttpClient(); final HttpClient client = HttpClient();
final String body = (await (await (await client.getUrl(Uri.parse(registry))).close()).transform(utf8.decoder).toList()).join(''); final String body = (await (await (await client.getUrl(Uri.parse(registry))).close()).transform(utf8.decoder).toList()).join('');
final List<Map<String, List<String>>> sections = body.split('%%').map<Map<String, List<String>>>(parseSection).toList(); final List<Map<String, List<String>>> sections = body.split('%%').map<Map<String, List<String>>>(parseSection).toList();
final Map<String, List<String>> outputs = <String, List<String>>{'language': <String>[], 'region': <String>[]}; final Map<String, List<String>> outputs = <String, List<String>>{'language': <String>[], 'region': <String>[]};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册