Test service extensions (#7849)
...and fix bugs that the tests uncovered. WRITE TEST FIND BUG
This commit is contained in:
@@ -2,9 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
class TestTestBinding extends AutomatedTestWidgetsFlutterBinding {
|
||||
@override
|
||||
DebugPrintCallback get debugPrintOverride => testPrint;
|
||||
static void testPrint(String message, { int wrapWidth }) { print(message); }
|
||||
}
|
||||
|
||||
Future<Null> guardedHelper(WidgetTester tester) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
await tester.pumpWidget(new Text('Hello'));
|
||||
@@ -12,8 +19,8 @@ Future<Null> guardedHelper(WidgetTester tester) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
new TestTestBinding();
|
||||
testWidgets('TestAsyncUtils - custom guarded sections', (WidgetTester tester) async {
|
||||
debugPrint = (String message, { int wrapWidth }) { print(message); };
|
||||
await tester.pumpWidget(new Container());
|
||||
expect(find.byElementType(Container), isNotNull);
|
||||
guardedHelper(tester);
|
||||
|
||||
@@ -2,16 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
class TestTestBinding extends AutomatedTestWidgetsFlutterBinding {
|
||||
@override
|
||||
DebugPrintCallback get debugPrintOverride => testPrint;
|
||||
static void testPrint(String message, { int wrapWidth }) { print(message); }
|
||||
}
|
||||
|
||||
Future<Null> helperFunction(WidgetTester tester) async {
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
void main() {
|
||||
new TestTestBinding();
|
||||
testWidgets('TestAsyncUtils - handling unguarded async helper functions', (WidgetTester tester) async {
|
||||
debugPrint = (String message, { int wrapWidth }) { print(message); };
|
||||
helperFunction(tester);
|
||||
helperFunction(tester);
|
||||
// this should fail
|
||||
|
||||
Reference in New Issue
Block a user