Unnecessary new (#20138)
* enable lint unnecessary_new
* fix tests
* fix tests
* fix tests
diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart
index 0c26bf4..19645ed 100644
--- a/packages/flutter_goldens/test/flutter_goldens_test.dart
+++ b/packages/flutter_goldens/test/flutter_goldens_test.dart
@@ -24,9 +24,9 @@
MockProcessManager process;
setUp(() {
- fs = new MemoryFileSystem();
- platform = new FakePlatform(environment: <String, String>{'FLUTTER_ROOT': _kFlutterRoot});
- process = new MockProcessManager();
+ fs = MemoryFileSystem();
+ platform = FakePlatform(environment: <String, String>{'FLUTTER_ROOT': _kFlutterRoot});
+ process = MockProcessManager();
fs.directory(_kFlutterRoot).createSync(recursive: true);
fs.directory(_kRepositoryRoot).createSync(recursive: true);
fs.file(_kVersionFile).createSync(recursive: true);
@@ -37,7 +37,7 @@
GoldensClient goldens;
setUp(() {
- goldens = new GoldensClient(
+ goldens = GoldensClient(
fs: fs,
platform: platform,
process: process,
@@ -47,7 +47,7 @@
group('prepare', () {
test('performs minimal work if versions match', () async {
when(process.run(any, workingDirectory: anyNamed('workingDirectory')))
- .thenAnswer((_) => new Future<io.ProcessResult>.value(io.ProcessResult(123, 0, _kGoldensVersion, '')));
+ .thenAnswer((_) => Future<io.ProcessResult>.value(io.ProcessResult(123, 0, _kGoldensVersion, '')));
await goldens.prepare();
// Verify that we only spawned `git rev-parse HEAD`
@@ -65,17 +65,17 @@
FlutterGoldenFileComparator comparator;
setUp(() {
- fs = new MemoryFileSystem();
+ fs = MemoryFileSystem();
final Directory flutterRoot = fs.directory('/path/to/flutter')..createSync(recursive: true);
final Directory goldensRoot = flutterRoot.childDirectory('bin/cache/goldens')..createSync(recursive: true);
final Directory testDirectory = goldensRoot.childDirectory('test/foo/bar')..createSync(recursive: true);
- comparator = new FlutterGoldenFileComparator(testDirectory.uri, fs: fs);
+ comparator = FlutterGoldenFileComparator(testDirectory.uri, fs: fs);
});
group('fromDefaultComparator', () {
test('calculates the basedir correctly', () async {
- final MockGoldensClient goldens = new MockGoldensClient();
- final MockLocalFileComparator defaultComparator = new MockLocalFileComparator();
+ final MockGoldensClient goldens = MockGoldensClient();
+ final MockLocalFileComparator defaultComparator = MockLocalFileComparator();
final Directory flutterRoot = fs.directory('/foo')..createSync(recursive: true);
final Directory goldensRoot = flutterRoot.childDirectory('bar')..createSync(recursive: true);
when(goldens.fs).thenReturn(fs);
@@ -91,7 +91,7 @@
group('compare', () {
test('throws if golden file is not found', () async {
try {
- await comparator.compare(new Uint8List.fromList(<int>[1, 2, 3]), Uri.parse('test.png'));
+ await comparator.compare(Uint8List.fromList(<int>[1, 2, 3]), Uri.parse('test.png'));
fail('TestFailure expected but not thrown');
} on TestFailure catch (error) {
expect(error.message, contains('Could not be compared against non-existent file'));
@@ -102,7 +102,7 @@
final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png')
..createSync(recursive: true);
goldenFile.writeAsBytesSync(<int>[4, 5, 6], flush: true);
- final bool result = await comparator.compare(new Uint8List.fromList(<int>[1, 2, 3]), Uri.parse('test.png'));
+ final bool result = await comparator.compare(Uint8List.fromList(<int>[1, 2, 3]), Uri.parse('test.png'));
expect(result, isFalse);
});
@@ -110,7 +110,7 @@
final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png')
..createSync(recursive: true);
goldenFile.writeAsBytesSync(<int>[1, 2, 3], flush: true);
- final bool result = await comparator.compare(new Uint8List.fromList(<int>[1, 2, 3]), Uri.parse('test.png'));
+ final bool result = await comparator.compare(Uint8List.fromList(<int>[1, 2, 3]), Uri.parse('test.png'));
expect(result, isTrue);
});
});
@@ -119,7 +119,7 @@
test('creates golden file if it does not already exist', () async {
final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png');
expect(goldenFile.existsSync(), isFalse);
- await comparator.update(Uri.parse('test.png'), new Uint8List.fromList(<int>[1, 2, 3]));
+ await comparator.update(Uri.parse('test.png'), Uint8List.fromList(<int>[1, 2, 3]));
expect(goldenFile.existsSync(), isTrue);
expect(goldenFile.readAsBytesSync(), <int>[1, 2, 3]);
});
@@ -128,7 +128,7 @@
final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png')
..createSync(recursive: true);
goldenFile.writeAsBytesSync(<int>[4, 5, 6], flush: true);
- await comparator.update(Uri.parse('test.png'), new Uint8List.fromList(<int>[1, 2, 3]));
+ await comparator.update(Uri.parse('test.png'), Uint8List.fromList(<int>[1, 2, 3]));
expect(goldenFile.readAsBytesSync(), <int>[1, 2, 3]);
});
});