Commit 895f3e63 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Declare locals final where not reassigned (flutter_test) (#8569)

parent 7a09316c
...@@ -154,7 +154,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -154,7 +154,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
Future<Null> setLocale(String languageCode, String countryCode) { Future<Null> setLocale(String languageCode, String countryCode) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
assert(inTest); assert(inTest);
Locale locale = new Locale(languageCode, countryCode); final Locale locale = new Locale(languageCode, countryCode);
dispatchLocaleChanged(locale); dispatchLocaleChanged(locale);
return null; return null;
}); });
...@@ -220,7 +220,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -220,7 +220,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// null in that case. /// null in that case.
dynamic takeException() { dynamic takeException() {
assert(inTest); assert(inTest);
dynamic result = _pendingExceptionDetails?.exception; final dynamic result = _pendingExceptionDetails?.exception;
_pendingExceptionDetails = null; _pendingExceptionDetails = null;
return result; return result;
} }
...@@ -315,7 +315,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -315,7 +315,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
} }
}; };
_currentTestCompleter = new Completer<Null>(); _currentTestCompleter = new Completer<Null>();
ZoneSpecification errorHandlingZoneSpecification = new ZoneSpecification( final ZoneSpecification errorHandlingZoneSpecification = new ZoneSpecification(
handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone, dynamic exception, StackTrace stack) { handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone, dynamic exception, StackTrace stack) {
if (_currentTestCompleter.isCompleted) { if (_currentTestCompleter.isCompleted) {
// Well this is not a good sign. // Well this is not a good sign.
...@@ -388,7 +388,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -388,7 +388,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
} }
); );
_parentZone = Zone.current; _parentZone = Zone.current;
Zone testZone = _parentZone.fork(specification: errorHandlingZoneSpecification); final Zone testZone = _parentZone.fork(specification: errorHandlingZoneSpecification);
testZone.runBinaryGuarded(_runTestBody, testBody, invariantTester) testZone.runBinaryGuarded(_runTestBody, testBody, invariantTester)
.whenComplete(_testCompletionHandler); .whenComplete(_testCompletionHandler);
asyncBarrier(); // When using AutomatedTestWidgetsFlutterBinding, this flushes the microtasks. asyncBarrier(); // When using AutomatedTestWidgetsFlutterBinding, this flushes the microtasks.
...@@ -498,7 +498,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -498,7 +498,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
Future<Null> idle() { Future<Null> idle() {
Future<Null> result = super.idle(); final Future<Null> result = super.idle();
_fakeAsync.flushMicrotasks(); _fakeAsync.flushMicrotasks();
return result; return result;
} }
...@@ -755,16 +755,16 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -755,16 +755,16 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
Point globalToLocal(Point point) { Point globalToLocal(Point point) {
Matrix4 transform = renderView.configuration.toHitTestMatrix(); final Matrix4 transform = renderView.configuration.toHitTestMatrix();
double det = transform.invert(); final double det = transform.invert();
assert(det != 0.0); assert(det != 0.0);
Point result = MatrixUtils.transformPoint(transform, point); final Point result = MatrixUtils.transformPoint(transform, point);
return result; return result;
} }
@override @override
Point localToGlobal(Point point) { Point localToGlobal(Point point) {
Matrix4 transform = renderView.configuration.toHitTestMatrix(); final Matrix4 transform = renderView.configuration.toHitTestMatrix();
return MatrixUtils.transformPoint(transform, point); return MatrixUtils.transformPoint(transform, point);
} }
} }
...@@ -853,8 +853,8 @@ class _LiveTestRenderView extends RenderView { ...@@ -853,8 +853,8 @@ class _LiveTestRenderView extends RenderView {
@override @override
bool hitTest(HitTestResult result, { Point position }) { bool hitTest(HitTestResult result, { Point position }) {
Matrix4 transform = configuration.toHitTestMatrix(); final Matrix4 transform = configuration.toHitTestMatrix();
double det = transform.invert(); final double det = transform.invert();
assert(det != 0.0); assert(det != 0.0);
position = MatrixUtils.transformPoint(transform, position); position = MatrixUtils.transformPoint(transform, position);
return super.hitTest(result, position: position); return super.hitTest(result, position: position);
...@@ -878,7 +878,7 @@ class _LiveTestRenderView extends RenderView { ...@@ -878,7 +878,7 @@ class _LiveTestRenderView extends RenderView {
..style = PaintingStyle.stroke; ..style = PaintingStyle.stroke;
bool dirty = false; bool dirty = false;
for (int pointer in _pointers.keys) { for (int pointer in _pointers.keys) {
_LiveTestPointerRecord record = _pointers[pointer]; final _LiveTestPointerRecord record = _pointers[pointer];
paint.color = record.color.withOpacity(record.decay < 0 ? (record.decay / (_kPointerDecay - 1)) : 1.0); paint.color = record.color.withOpacity(record.decay < 0 ? (record.decay / (_kPointerDecay - 1)) : 1.0);
canvas.drawPath(path.shift(record.position.toOffset()), paint); canvas.drawPath(path.shift(record.position.toOffset()), paint);
if (record.decay < 0) if (record.decay < 0)
......
...@@ -75,7 +75,7 @@ class WidgetController { ...@@ -75,7 +75,7 @@ class WidgetController {
Iterable<T> widgetList<T extends Widget>(Finder finder) { Iterable<T> widgetList<T extends Widget>(Finder finder) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
return finder.evaluate().map<T>((Element element) { return finder.evaluate().map<T>((Element element) {
T result = element.widget; final T result = element.widget;
return result; return result;
}); });
} }
...@@ -223,7 +223,7 @@ class WidgetController { ...@@ -223,7 +223,7 @@ class WidgetController {
Iterable<T> renderObjectList<T extends RenderObject>(Finder finder) { Iterable<T> renderObjectList<T extends RenderObject>(Finder finder) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
return finder.evaluate().map<T>((Element element) { return finder.evaluate().map<T>((Element element) {
T result = element.renderObject; final T result = element.renderObject;
return result; return result;
}); });
} }
...@@ -235,7 +235,7 @@ class WidgetController { ...@@ -235,7 +235,7 @@ class WidgetController {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
yield layer; yield layer;
if (layer is ContainerLayer) { if (layer is ContainerLayer) {
ContainerLayer root = layer; final ContainerLayer root = layer;
Layer child = root.firstChild; Layer child = root.firstChild;
while (child != null) { while (child != null) {
yield* _walkLayers(child); yield* _walkLayers(child);
...@@ -259,7 +259,7 @@ class WidgetController { ...@@ -259,7 +259,7 @@ class WidgetController {
/// location. /// location.
Future<Null> tapAt(Point location, { int pointer: 1 }) { Future<Null> tapAt(Point location, { int pointer: 1 }) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
TestGesture gesture = await startGesture(location, pointer: pointer); final TestGesture gesture = await startGesture(location, pointer: pointer);
await gesture.up(); await gesture.up();
return null; return null;
}); });
...@@ -278,7 +278,7 @@ class WidgetController { ...@@ -278,7 +278,7 @@ class WidgetController {
/// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events. /// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events.
Future<Null> longPressAt(Point location, { int pointer: 1 }) { Future<Null> longPressAt(Point location, { int pointer: 1 }) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
TestGesture gesture = await startGesture(location, pointer: pointer); final TestGesture gesture = await startGesture(location, pointer: pointer);
await pump(kLongPressTimeout + kPressTimeout); await pump(kLongPressTimeout + kPressTimeout);
await gesture.up(); await gesture.up();
return null; return null;
...@@ -360,7 +360,7 @@ class WidgetController { ...@@ -360,7 +360,7 @@ class WidgetController {
/// the given offset, and a pointer up. /// the given offset, and a pointer up.
Future<Null> scrollAt(Point startLocation, Offset offset, { int pointer: 1 }) { Future<Null> scrollAt(Point startLocation, Offset offset, { int pointer: 1 }) {
return TestAsyncUtils.guard(() async { return TestAsyncUtils.guard(() async {
TestGesture gesture = await startGesture(startLocation, pointer: pointer); final TestGesture gesture = await startGesture(startLocation, pointer: pointer);
await gesture.moveBy(offset); await gesture.moveBy(offset);
await gesture.up(); await gesture.up();
return null; return null;
...@@ -421,8 +421,8 @@ class WidgetController { ...@@ -421,8 +421,8 @@ class WidgetController {
Point _getElementPoint(Finder finder, Point sizeToPoint(Size size)) { Point _getElementPoint(Finder finder, Point sizeToPoint(Size size)) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
Element element = finder.evaluate().single; final Element element = finder.evaluate().single;
RenderBox box = element.renderObject; final RenderBox box = element.renderObject;
assert(box != null); assert(box != null);
return box.localToGlobal(sizeToPoint(box.size)); return box.localToGlobal(sizeToPoint(box.size));
} }
...@@ -431,8 +431,8 @@ class WidgetController { ...@@ -431,8 +431,8 @@ class WidgetController {
/// the widget's render object has been laid out at least once. /// the widget's render object has been laid out at least once.
Size getSize(Finder finder) { Size getSize(Finder finder) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
Element element = finder.evaluate().single; final Element element = finder.evaluate().single;
RenderBox box = element.renderObject; final RenderBox box = element.renderObject;
assert(box != null); assert(box != null);
return box.size; return box.size;
} }
......
...@@ -341,7 +341,7 @@ class _TextFinder extends MatchFinder { ...@@ -341,7 +341,7 @@ class _TextFinder extends MatchFinder {
bool matches(Element candidate) { bool matches(Element candidate) {
if (candidate.widget is! Text) if (candidate.widget is! Text)
return false; return false;
Text textWidget = candidate.widget; final Text textWidget = candidate.widget;
return textWidget.data == text; return textWidget.data == text;
} }
} }
...@@ -358,7 +358,7 @@ class _IconFinder extends MatchFinder { ...@@ -358,7 +358,7 @@ class _IconFinder extends MatchFinder {
bool matches(Element candidate) { bool matches(Element candidate) {
if (candidate.widget is! Icon) if (candidate.widget is! Icon)
return false; return false;
Icon iconWidget = candidate.widget; final Icon iconWidget = candidate.widget;
return iconWidget.icon == icon; return iconWidget.icon == icon;
} }
} }
...@@ -379,7 +379,7 @@ class _WidgetWithTextFinder extends Finder { ...@@ -379,7 +379,7 @@ class _WidgetWithTextFinder extends Finder {
if (textElement.widget is! Text) if (textElement.widget is! Text)
return null; return null;
Text textWidget = textElement.widget; final Text textWidget = textElement.widget;
if (textWidget.data == text) { if (textWidget.data == text) {
try { try {
textElement.visitAncestorElements((Element element) { textElement.visitAncestorElements((Element element) {
......
...@@ -100,7 +100,7 @@ class _FindsWidgetMatcher extends Matcher { ...@@ -100,7 +100,7 @@ class _FindsWidgetMatcher extends Matcher {
assert(min == null || max == null || min <= max); assert(min == null || max == null || min <= max);
matchState[Finder] = finder; matchState[Finder] = finder;
int count = 0; int count = 0;
Iterator<Element> iterator = finder.evaluate().iterator; final Iterator<Element> iterator = finder.evaluate().iterator;
if (min != null) { if (min != null) {
while (count < min && iterator.moveNext()) while (count < min && iterator.moveNext())
count += 1; count += 1;
...@@ -146,8 +146,8 @@ class _FindsWidgetMatcher extends Matcher { ...@@ -146,8 +146,8 @@ class _FindsWidgetMatcher extends Matcher {
Map<dynamic, dynamic> matchState, Map<dynamic, dynamic> matchState,
bool verbose bool verbose
) { ) {
Finder finder = matchState[Finder]; final Finder finder = matchState[Finder];
int count = finder.evaluate().length; final int count = finder.evaluate().length;
if (count == 0) { if (count == 0) {
assert(min != null && min > 0); assert(min != null && min > 0);
if (min == 1 && max == 1) if (min == 1 && max == 1)
...@@ -167,7 +167,7 @@ class _FindsWidgetMatcher extends Matcher { ...@@ -167,7 +167,7 @@ class _FindsWidgetMatcher extends Matcher {
} }
bool _hasAncestorMatching(Finder finder, bool predicate(Widget widget)) { bool _hasAncestorMatching(Finder finder, bool predicate(Widget widget)) {
Iterable<Element> nodes = finder.evaluate(); final Iterable<Element> nodes = finder.evaluate();
if (nodes.length != 1) if (nodes.length != 1)
return false; return false;
bool result = false; bool result = false;
...@@ -206,12 +206,12 @@ class _IsOnstage extends Matcher { ...@@ -206,12 +206,12 @@ class _IsOnstage extends Matcher {
@override @override
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) { bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) {
Iterable<Element> nodes = finder.evaluate(); final Iterable<Element> nodes = finder.evaluate();
if (nodes.length != 1) if (nodes.length != 1)
return false; return false;
bool result = true; bool result = true;
nodes.single.visitAncestorElements((Element ancestor) { nodes.single.visitAncestorElements((Element ancestor) {
Widget widget = ancestor.widget; final Widget widget = ancestor.widget;
if (widget is Offstage) { if (widget is Offstage) {
result = !widget.offstage; result = !widget.offstage;
return false; return false;
...@@ -250,7 +250,7 @@ class _HasOneLineDescription extends Matcher { ...@@ -250,7 +250,7 @@ class _HasOneLineDescription extends Matcher {
@override @override
bool matches(Object object, Map<dynamic, dynamic> matchState) { bool matches(Object object, Map<dynamic, dynamic> matchState) {
String description = object.toString(); final String description = object.toString();
return description.isNotEmpty return description.isNotEmpty
&& !description.contains('\n') && !description.contains('\n')
&& !description.contains('Instance of ') && !description.contains('Instance of ')
......
...@@ -23,7 +23,7 @@ int reportExpectCall(StackTrace stack, StringBuffer information) { ...@@ -23,7 +23,7 @@ int reportExpectCall(StackTrace stack, StringBuffer information) {
line2.firstMatch(stackLines[2]) != null && line2.firstMatch(stackLines[2]) != null &&
line3.firstMatch(stackLines[3]) != null line3.firstMatch(stackLines[3]) != null
) { ) {
Match expectMatch = line4.firstMatch(stackLines[4]); final Match expectMatch = line4.firstMatch(stackLines[4]);
assert(expectMatch != null); assert(expectMatch != null);
assert(expectMatch.groupCount == 2); assert(expectMatch.groupCount == 2);
information.writeln('This was caught by the test expectation on the following line:'); information.writeln('This was caught by the test expectation on the following line:');
...@@ -31,4 +31,4 @@ int reportExpectCall(StackTrace stack, StringBuffer information) { ...@@ -31,4 +31,4 @@ int reportExpectCall(StackTrace stack, StringBuffer information) {
return 4; return 4;
} }
return 0; return 0;
} }
\ No newline at end of file
...@@ -59,20 +59,20 @@ class TestAsyncUtils { ...@@ -59,20 +59,20 @@ class TestAsyncUtils {
/// This method first calls [guardSync]. /// This method first calls [guardSync].
static Future<Null> guard(Future<Null> body()) { static Future<Null> guard(Future<Null> body()) {
guardSync(); guardSync();
Zone zone = Zone.current.fork( final Zone zone = Zone.current.fork(
zoneValues: <dynamic, dynamic>{ zoneValues: <dynamic, dynamic>{
_scopeStack: true // so we can recognize this as our own zone _scopeStack: true // so we can recognize this as our own zone
} }
); );
_AsyncScope scope = new _AsyncScope(StackTrace.current, zone); final _AsyncScope scope = new _AsyncScope(StackTrace.current, zone);
_scopeStack.add(scope); _scopeStack.add(scope);
Future<Null> result = scope.zone.run(body); final Future<Null> result = scope.zone.run(body);
void completionHandler(dynamic error, StackTrace stack) { void completionHandler(dynamic error, StackTrace stack) {
assert(_scopeStack.isNotEmpty); assert(_scopeStack.isNotEmpty);
assert(_scopeStack.contains(scope)); assert(_scopeStack.contains(scope));
bool leaked = false; bool leaked = false;
_AsyncScope closedScope; _AsyncScope closedScope;
StringBuffer message = new StringBuffer(); final StringBuffer message = new StringBuffer();
while (_scopeStack.isNotEmpty) { while (_scopeStack.isNotEmpty) {
closedScope = _scopeStack.removeLast(); closedScope = _scopeStack.removeLast();
if (closedScope == scope) if (closedScope == scope)
...@@ -177,7 +177,7 @@ class TestAsyncUtils { ...@@ -177,7 +177,7 @@ class TestAsyncUtils {
assert(candidateScope.zone != null); assert(candidateScope.zone != null);
} while (candidateScope.zone != zone); } while (candidateScope.zone != zone);
assert(scope != null); assert(scope != null);
StringBuffer message = new StringBuffer(); final StringBuffer message = new StringBuffer();
message.writeln('Guarded function conflict. You must use "await" with all Future-returning test APIs.'); message.writeln('Guarded function conflict. You must use "await" with all Future-returning test APIs.');
final _StackEntry originalGuarder = _findResponsibleMethod(scope.creationStack, 'guard', message); final _StackEntry originalGuarder = _findResponsibleMethod(scope.creationStack, 'guard', message);
final _StackEntry collidingGuarder = _findResponsibleMethod(StackTrace.current, 'guardSync', message); final _StackEntry collidingGuarder = _findResponsibleMethod(StackTrace.current, 'guardSync', message);
...@@ -261,7 +261,7 @@ class TestAsyncUtils { ...@@ -261,7 +261,7 @@ class TestAsyncUtils {
/// This is used at the end of tests to ensure that nothing leaks out of the test. /// This is used at the end of tests to ensure that nothing leaks out of the test.
static void verifyAllScopesClosed() { static void verifyAllScopesClosed() {
if (_scopeStack.isNotEmpty) { if (_scopeStack.isNotEmpty) {
StringBuffer message = new StringBuffer(); final StringBuffer message = new StringBuffer();
message.writeln('Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.'); message.writeln('Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.');
for (_AsyncScope scope in _scopeStack) { for (_AsyncScope scope in _scopeStack) {
final _StackEntry guarder = _findResponsibleMethod(scope.creationStack, 'guard', message); final _StackEntry guarder = _findResponsibleMethod(scope.creationStack, 'guard', message);
......
...@@ -61,7 +61,7 @@ class TestPointer { ...@@ -61,7 +61,7 @@ class TestPointer {
/// argument. /// argument.
PointerMoveEvent move(Point newLocation, { Duration timeStamp: Duration.ZERO }) { PointerMoveEvent move(Point newLocation, { Duration timeStamp: Duration.ZERO }) {
assert(isDown); assert(isDown);
Offset delta = newLocation - location; final Offset delta = newLocation - location;
_location = newLocation; _location = newLocation;
return new PointerMoveEvent( return new PointerMoveEvent(
timeStamp: timeStamp, timeStamp: timeStamp,
......
...@@ -44,11 +44,11 @@ class TestTextInput { ...@@ -44,11 +44,11 @@ class TestTextInput {
void updateEditingState(TextEditingState state) { void updateEditingState(TextEditingState state) {
expect(_client, isNonZero); expect(_client, isNonZero);
String message = JSON.encode(<String, dynamic>{ final String message = JSON.encode(<String, dynamic>{
'method': 'TextInputClient.updateEditingState', 'method': 'TextInputClient.updateEditingState',
'args': <dynamic>[_client, state.toJSON()], 'args': <dynamic>[_client, state.toJSON()],
}); });
Uint8List encoded = UTF8.encoder.convert(message); final Uint8List encoded = UTF8.encoder.convert(message);
PlatformMessages.handlePlatformMessage( PlatformMessages.handlePlatformMessage(
_kTextInputClientChannel, encoded.buffer.asByteData(), (_) {}); _kTextInputClientChannel, encoded.buffer.asByteData(), (_) {});
} }
......
...@@ -47,8 +47,8 @@ void testWidgets(String description, WidgetTesterCallback callback, { ...@@ -47,8 +47,8 @@ void testWidgets(String description, WidgetTesterCallback callback, {
bool skip: false, bool skip: false,
test_package.Timeout timeout test_package.Timeout timeout
}) { }) {
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
WidgetTester tester = new WidgetTester._(binding); final WidgetTester tester = new WidgetTester._(binding);
timeout ??= binding.defaultTestTimeout; timeout ??= binding.defaultTestTimeout;
test_package.group('-', () { test_package.group('-', () {
test_package.test(description, () => binding.runTest(() => callback(tester), tester._endOfTestVerifications), skip: skip); test_package.test(description, () => binding.runTest(() => callback(tester), tester._endOfTestVerifications), skip: skip);
...@@ -106,9 +106,9 @@ Future<Null> benchmarkWidgets(WidgetTesterCallback callback) { ...@@ -106,9 +106,9 @@ Future<Null> benchmarkWidgets(WidgetTesterCallback callback) {
print('└─────────────────────────────────────────────────╌┄┈ 🐢'); print('└─────────────────────────────────────────────────╌┄┈ 🐢');
return true; return true;
}); });
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
assert(binding is! AutomatedTestWidgetsFlutterBinding); assert(binding is! AutomatedTestWidgetsFlutterBinding);
WidgetTester tester = new WidgetTester._(binding); final WidgetTester tester = new WidgetTester._(binding);
return binding.runTest(() => callback(tester), tester._endOfTestVerifications) ?? new Future<Null>.value(); return binding.runTest(() => callback(tester), tester._endOfTestVerifications) ?? new Future<Null>.value();
} }
......
...@@ -10,9 +10,9 @@ void main() { ...@@ -10,9 +10,9 @@ void main() {
expect(false, isTrue); expect(false, isTrue);
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} catch (e, stack) { } catch (e, stack) {
StringBuffer information = new StringBuffer(); final StringBuffer information = new StringBuffer();
expect(reportExpectCall(stack, information), 4); expect(reportExpectCall(stack, information), 4);
List<String> lines = information.toString().split('\n'); final List<String> lines = information.toString().split('\n');
expect(lines[0], 'This was caught by the test expectation on the following line:'); expect(lines[0], 'This was caught by the test expectation on the following line:');
expect(lines[1], matches(r'^ .*stack_manipulation_test.dart line [0-9]+$')); expect(lines[1], matches(r'^ .*stack_manipulation_test.dart line [0-9]+$'));
} }
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
try { try {
throw null; throw null;
} catch (e, stack) { } catch (e, stack) {
StringBuffer information = new StringBuffer(); final StringBuffer information = new StringBuffer();
expect(reportExpectCall(stack, information), 0); expect(reportExpectCall(stack, information), 0);
expect(information.toString(), ''); expect(information.toString(), '');
} }
......
...@@ -39,14 +39,14 @@ Future<Null> guardedHelper(WidgetTester tester) { ...@@ -39,14 +39,14 @@ Future<Null> guardedHelper(WidgetTester tester) {
void main() { void main() {
test('TestAsyncUtils - one class', () async { test('TestAsyncUtils - one class', () async {
TestAPI testAPI = new TestAPI(); final TestAPI testAPI = new TestAPI();
Future<Null> f1, f2; Future<Null> f1, f2;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
f2 = testAPI.testGuard2(); f2 = testAPI.testGuard2();
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} on FlutterError catch (e) { } on FlutterError catch (e) {
List<String> lines = e.message.split('\n'); final List<String> lines = e.message.split('\n');
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.'); real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
real_test.expect(lines[1], matches(r'The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.')); real_test.expect(lines[1], matches(r'The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.'));
real_test.expect(lines[2], matches(r'Then, the "testGuard2" method \(also from class TestAPI\) was called from .*test_async_utils_test.dart on line [0-9]+\.')); real_test.expect(lines[2], matches(r'Then, the "testGuard2" method \(also from class TestAPI\) was called from .*test_async_utils_test.dart on line [0-9]+\.'));
...@@ -60,14 +60,14 @@ void main() { ...@@ -60,14 +60,14 @@ void main() {
}); });
test('TestAsyncUtils - two classes, all callers in superclass', () async { test('TestAsyncUtils - two classes, all callers in superclass', () async {
TestAPI testAPI = new TestAPISubclass(); final TestAPI testAPI = new TestAPISubclass();
Future<Null> f1, f2; Future<Null> f1, f2;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
f2 = testAPI.testGuard2(); f2 = testAPI.testGuard2();
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} on FlutterError catch (e) { } on FlutterError catch (e) {
List<String> lines = e.message.split('\n'); final List<String> lines = e.message.split('\n');
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.'); real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
real_test.expect(lines[2], matches(r'^Then, the "testGuard2" method \(also from class TestAPI\) was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[2], matches(r'^Then, the "testGuard2" method \(also from class TestAPI\) was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
...@@ -81,14 +81,14 @@ void main() { ...@@ -81,14 +81,14 @@ void main() {
}); });
test('TestAsyncUtils - two classes, mixed callers', () async { test('TestAsyncUtils - two classes, mixed callers', () async {
TestAPISubclass testAPI = new TestAPISubclass(); final TestAPISubclass testAPI = new TestAPISubclass();
Future<Null> f1, f2; Future<Null> f1, f2;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
f2 = testAPI.testGuard3(); f2 = testAPI.testGuard3();
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} on FlutterError catch (e) { } on FlutterError catch (e) {
List<String> lines = e.message.split('\n'); final List<String> lines = e.message.split('\n');
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.'); real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
real_test.expect(lines[2], matches(r'^Then, the "testGuard3" method from class TestAPISubclass was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[2], matches(r'^Then, the "testGuard3" method from class TestAPISubclass was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
...@@ -102,14 +102,14 @@ void main() { ...@@ -102,14 +102,14 @@ void main() {
}); });
test('TestAsyncUtils - expect() catches pending async work', () async { test('TestAsyncUtils - expect() catches pending async work', () async {
TestAPI testAPI = new TestAPISubclass(); final TestAPI testAPI = new TestAPISubclass();
Future<Null> f1; Future<Null> f1;
f1 = testAPI.testGuard1(); f1 = testAPI.testGuard1();
try { try {
flutter_test.expect(0, 0); flutter_test.expect(0, 0);
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} on FlutterError catch (e) { } on FlutterError catch (e) {
List<String> lines = e.message.split('\n'); final List<String> lines = e.message.split('\n');
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.'); real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
real_test.expect(lines[2], matches(r'^Then, the "expect" function was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[2], matches(r'^Then, the "expect" function was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
...@@ -129,7 +129,7 @@ void main() { ...@@ -129,7 +129,7 @@ void main() {
f2 = tester.pump(); f2 = tester.pump();
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} on FlutterError catch (e) { } on FlutterError catch (e) {
List<String> lines = e.message.split('\n'); final List<String> lines = e.message.split('\n');
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.'); real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
real_test.expect(lines[2], matches(r'^Then, it was called from .*test_async_utils_test.dart on line [0-9]+\.$')); real_test.expect(lines[2], matches(r'^Then, it was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
...@@ -149,7 +149,7 @@ void main() { ...@@ -149,7 +149,7 @@ void main() {
TestAsyncUtils.verifyAllScopesClosed(); TestAsyncUtils.verifyAllScopesClosed();
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} on FlutterError catch (e) { } on FlutterError catch (e) {
List<String> lines = e.message.split('\n'); final List<String> lines = e.message.split('\n');
real_test.expect(lines[0], 'Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.'); real_test.expect(lines[0], 'Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.');
real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+, but never completed before its parent scope closed\.$')); real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+, but never completed before its parent scope closed\.$'));
real_test.expect(lines[2], matches(r'^The guarded method "pump" from class AutomatedTestWidgetsFlutterBinding was called from [^ ]+ on line [0-9]+, but never completed before its parent scope closed\.')); real_test.expect(lines[2], matches(r'^The guarded method "pump" from class AutomatedTestWidgetsFlutterBinding was called from [^ ]+ on line [0-9]+, but never completed before its parent scope closed\.'));
...@@ -165,7 +165,7 @@ void main() { ...@@ -165,7 +165,7 @@ void main() {
TestAsyncUtils.verifyAllScopesClosed(); TestAsyncUtils.verifyAllScopesClosed();
throw 'unexpectedly did not throw'; throw 'unexpectedly did not throw';
} on FlutterError catch (e) { } on FlutterError catch (e) {
List<String> lines = e.message.split('\n'); final List<String> lines = e.message.split('\n');
real_test.expect(lines[0], 'Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.'); real_test.expect(lines[0], 'Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.');
real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+, but never completed before its parent scope closed\.$')); real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+, but never completed before its parent scope closed\.$'));
real_test.expect(lines[2], matches(r'^The guarded method "pump" from class AutomatedTestWidgetsFlutterBinding was called from [^ ]+ on line [0-9]+, but never completed before its parent scope closed\.')); real_test.expect(lines[2], matches(r'^The guarded method "pump" from class AutomatedTestWidgetsFlutterBinding was called from [^ ]+ on line [0-9]+, but never completed before its parent scope closed\.'));
......
...@@ -21,7 +21,7 @@ void main() { ...@@ -21,7 +21,7 @@ void main() {
} }
expect(failure, isNotNull); expect(failure, isNotNull);
String message = failure.message; final String message = failure.message;
expect(message, contains('Expected: exactly one matching node in the widget tree\n')); expect(message, contains('Expected: exactly one matching node in the widget tree\n'));
expect(message, contains('Actual: ?:<zero widgets with text "foo">\n')); expect(message, contains('Actual: ?:<zero widgets with text "foo">\n'));
expect(message, contains('Which: means none were found but one was expected\n')); expect(message, contains('Which: means none were found but one was expected\n'));
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
} }
expect(failure, isNotNull); expect(failure, isNotNull);
String message = failure.message; final String message = failure.message;
expect(message, contains('Expected: no matching nodes in the widget tree\n')); expect(message, contains('Expected: no matching nodes in the widget tree\n'));
expect(message, contains('Actual: ?:<exactly one widget with text "foo": Text("foo")>\n')); expect(message, contains('Actual: ?:<exactly one widget with text "foo": Text("foo")>\n'));
...@@ -62,7 +62,7 @@ void main() { ...@@ -62,7 +62,7 @@ void main() {
} }
expect(failure, isNotNull); expect(failure, isNotNull);
String message = failure.message; final String message = failure.message;
expect(message, contains('Expected: no matching nodes in the widget tree\n')); expect(message, contains('Expected: no matching nodes in the widget tree\n'));
expect(message, contains('Actual: ?:<exactly one widget with text "foo" (ignoring offstage widgets): Text("foo")>\n')); expect(message, contains('Actual: ?:<exactly one widget with text "foo" (ignoring offstage widgets): Text("foo")>\n'));
...@@ -73,7 +73,7 @@ void main() { ...@@ -73,7 +73,7 @@ void main() {
await tester.pumpWidget(new Text('foo')); await tester.pumpWidget(new Text('foo'));
int count; int count;
AnimationController test = new AnimationController( final AnimationController test = new AnimationController(
duration: const Duration(milliseconds: 5100), duration: const Duration(milliseconds: 5100),
vsync: tester, vsync: tester,
); );
...@@ -108,7 +108,7 @@ void main() { ...@@ -108,7 +108,7 @@ void main() {
testWidgets('fails with a custom description in the message', (WidgetTester tester) async { testWidgets('fails with a custom description in the message', (WidgetTester tester) async {
await tester.pumpWidget(new Text('foo')); await tester.pumpWidget(new Text('foo'));
String customDescription = 'custom description'; final String customDescription = 'custom description';
TestFailure failure; TestFailure failure;
try { try {
expect(find.byElementPredicate((_) => false, description: customDescription), findsOneWidget); expect(find.byElementPredicate((_) => false, description: customDescription), findsOneWidget);
...@@ -125,7 +125,7 @@ void main() { ...@@ -125,7 +125,7 @@ void main() {
testWidgets('fails with a custom description in the message', (WidgetTester tester) async { testWidgets('fails with a custom description in the message', (WidgetTester tester) async {
await tester.pumpWidget(new Text('foo')); await tester.pumpWidget(new Text('foo'));
String customDescription = 'custom description'; final String customDescription = 'custom description';
TestFailure failure; TestFailure failure;
try { try {
expect(find.byWidgetPredicate((_) => false, description: customDescription), findsOneWidget); expect(find.byWidgetPredicate((_) => false, description: customDescription), findsOneWidget);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment