Declare locals final where not reassigned (gallery) (#8571)
This commit is contained in:
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/demo/calculator_demo.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.allowAllFrames = true;
|
||||
|
||||
@@ -16,10 +16,10 @@ void main() {
|
||||
testWidgets('Flutter calculator app smoke test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(new CalculatorDemo());
|
||||
|
||||
Finder oneButton = find.widgetWithText(InkResponse, '1');
|
||||
final Finder oneButton = find.widgetWithText(InkResponse, '1');
|
||||
expect(oneButton, findsOneWidget);
|
||||
|
||||
Finder twoButton = find.widgetWithText(InkResponse, '2');
|
||||
final Finder twoButton = find.widgetWithText(InkResponse, '2');
|
||||
expect(twoButton, findsOneWidget);
|
||||
|
||||
await tester.tap(oneButton);
|
||||
@@ -28,7 +28,7 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1)); // Wait until it has finished.
|
||||
|
||||
Finder display = find.widgetWithText(Expanded, '12');
|
||||
final Finder display = find.widgetWithText(Expanded, '12');
|
||||
expect(display, findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.allowAllFrames = true;
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('Flutter gallery example code parser test', () async {
|
||||
TestAssetBundle bundle = new TestAssetBundle();
|
||||
final TestAssetBundle bundle = new TestAssetBundle();
|
||||
|
||||
String codeSnippet0 = await getExampleCode('test_0', bundle);
|
||||
final String codeSnippet0 = await getExampleCode('test_0', bundle);
|
||||
expect(codeSnippet0, 'test 0 0\ntest 0 1');
|
||||
|
||||
String codeSnippet1 = await getExampleCode('test_1', bundle);
|
||||
final String codeSnippet1 = await getExampleCode('test_1', bundle);
|
||||
expect(codeSnippet1, 'test 1 0\ntest 1 1');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_gallery/gallery/app.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.allowAllFrames = true;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_gallery/main.dart' as flutter_gallery_main;
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.allowAllFrames = true;
|
||||
|
||||
@@ -16,7 +16,7 @@ void main() {
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
Finder finder = find.byWidgetPredicate((Widget widget) {
|
||||
final Finder finder = find.byWidgetPredicate((Widget widget) {
|
||||
return widget is Tooltip && widget.message == 'Open navigation menu';
|
||||
});
|
||||
expect(finder, findsOneWidget);
|
||||
|
||||
@@ -32,16 +32,16 @@ void reportToStringError(String name, String route, int lineNumber, List<String>
|
||||
// If you're on line 12, then it has index 11.
|
||||
// If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12.
|
||||
// That's (lineNumber-1)-margin .. (lineNumber-1)+margin, or lineNumber-(margin+1) .. lineNumber+(margin-1)
|
||||
int margin = 5;
|
||||
int firstLine = math.max(0, lineNumber - margin);
|
||||
int lastLine = math.min(lines.length, lineNumber + margin);
|
||||
final int margin = 5;
|
||||
final int firstLine = math.max(0, lineNumber - margin);
|
||||
final int lastLine = math.min(lines.length, lineNumber + margin);
|
||||
print('$name : $route : line $lineNumber of ${lines.length} : $message; nearby lines were:\n ${lines.sublist(firstLine, lastLine).join("\n ")}');
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
void verifyToStringOutput(String name, String route, String testString) {
|
||||
int lineNumber = 0;
|
||||
List<String> lines = testString.split('\n');
|
||||
final List<String> lines = testString.split('\n');
|
||||
if (!testString.endsWith('\n'))
|
||||
reportToStringError(name, route, lines.length, lines, 'does not end with a line feed');
|
||||
for (String line in lines) {
|
||||
@@ -103,7 +103,7 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
|
||||
// Go back
|
||||
Finder backButton = find.byTooltip('Back');
|
||||
final Finder backButton = find.byTooltip('Back');
|
||||
expect(backButton, findsOneWidget);
|
||||
await tester.tap(backButton);
|
||||
await tester.pump(); // Start the pop "back" operation.
|
||||
@@ -125,7 +125,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
|
||||
expect(find.text(kCaption), findsOneWidget);
|
||||
|
||||
for (String routeName in routeNames) {
|
||||
Finder finder = findGalleryItemByRouteName(tester, routeName);
|
||||
final Finder finder = findGalleryItemByRouteName(tester, routeName);
|
||||
Scrollable.ensureVisible(tester.element(finder), alignment: 0.5);
|
||||
await tester.pump();
|
||||
await tester.pumpUntilNoTransientCallbacks();
|
||||
@@ -135,7 +135,7 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
|
||||
|
||||
expect(errors, 0);
|
||||
|
||||
Finder navigationMenuButton = find.byTooltip('Open navigation menu');
|
||||
final Finder navigationMenuButton = find.byTooltip('Open navigation menu');
|
||||
expect(navigationMenuButton, findsOneWidget);
|
||||
await tester.tap(navigationMenuButton);
|
||||
await tester.pump(); // Start opening drawer.
|
||||
|
||||
@@ -11,7 +11,7 @@ Future<String> mockUpdateUrlFetcher() {
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
if (binding is LiveTestWidgetsFlutterBinding) binding.allowAllFrames = true;
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/pull/5168
|
||||
@@ -29,7 +29,7 @@ void main() {
|
||||
await tester.pump(); // Launch shrine
|
||||
await tester.pump(const Duration(seconds: 1)); // transition is complete
|
||||
|
||||
Finder backButton = find.byTooltip('Back');
|
||||
final Finder backButton = find.byTooltip('Back');
|
||||
expect(backButton, findsOneWidget);
|
||||
await tester.tap(backButton);
|
||||
await tester.pump(); // Start the pop "back" operation.
|
||||
|
||||
Reference in New Issue
Block a user