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