Declare locals as final where not reassigned (flutter_driver) (#8567)

This commit is contained in:
Chris Bracken
2017-03-03 18:31:21 -08:00
committed by GitHub
parent e0c51480d2
commit cdeb83cf59
14 changed files with 81 additions and 81 deletions

View File

@@ -53,7 +53,7 @@ void main() {
when(mockIsolate.resume()).thenReturn(new Future<Null>.value());
when(mockIsolate.onExtensionAdded).thenReturn(new Stream<String>.fromIterable(<String>['ext.flutter.driver']));
FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
expect(driver, isNotNull);
expectLogContains('Isolate is paused at start');
});
@@ -62,7 +62,7 @@ void main() {
when(mockIsolate.pauseEvent).thenReturn(new MockVMPauseBreakpointEvent());
when(mockIsolate.resume()).thenReturn(new Future<Null>.value());
FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
expect(driver, isNotNull);
expectLogContains('Isolate is paused mid-flight');
});
@@ -79,14 +79,14 @@ void main() {
return new Future<Null>.error(new rpc.RpcException(101, ''));
});
FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
expect(driver, isNotNull);
expectLogContains('Attempted to resume an already resumed isolate');
});
test('connects to unpaused isolate', () async {
when(mockIsolate.pauseEvent).thenReturn(new MockVMResumeEvent());
FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: '');
expect(driver, isNotNull);
expectLogContains('Isolate is not paused. Assuming application is ready.');
});
@@ -108,7 +108,7 @@ void main() {
test('checks the health of the driver extension', () async {
when(mockIsolate.invokeExtension(any, any)).thenReturn(
makeMockResponse(<String, dynamic>{'status': 'ok'}));
Health result = await driver.checkHealth();
final Health result = await driver.checkHealth();
expect(result.status, HealthStatus.ok);
});
@@ -175,7 +175,7 @@ void main() {
'text': 'hello'
});
});
String result = await driver.getText(find.byValueKey(123));
final String result = await driver.getText(find.byValueKey(123));
expect(result, 'hello');
});
});
@@ -240,7 +240,7 @@ void main() {
};
});
Timeline timeline = await driver.traceAction(() {
final Timeline timeline = await driver.traceAction(() {
actionCalled = true;
});
@@ -279,7 +279,7 @@ void main() {
};
});
Timeline timeline = await driver.traceAction(() {
final Timeline timeline = await driver.traceAction(() {
actionCalled = true;
},
streams: const <TimelineStream>[

View File

@@ -8,8 +8,8 @@ import 'package:flutter_driver/src/matcher_util.dart';
void main() {
group('match', () {
test('matches', () {
_TestMatcher matcher = new _TestMatcher(1);
MatchResult ok = match(1, matcher);
final _TestMatcher matcher = new _TestMatcher(1);
final MatchResult ok = match(1, matcher);
expect(ok.hasMatched, isTrue);
expect(ok.mismatchDescription, isNull);
expect(matcher.matchState1 is Map<dynamic, dynamic>, isTrue);
@@ -17,8 +17,8 @@ void main() {
});
test('mismatches', () {
_TestMatcher matcher = new _TestMatcher(2);
MatchResult fail = match(1, matcher);
final _TestMatcher matcher = new _TestMatcher(2);
final MatchResult fail = match(1, matcher);
expect(fail.hasMatched, isFalse);
expect(fail.mismatchDescription, 'mismatch!');
expect(matcher.matchState1, matcher.matchState2);

View File

@@ -15,7 +15,7 @@ void main() {
setUp(() {
fakeAsync = new FakeAsync();
Clock fakeClock = fakeAsync.getClock(new DateTime.now());
final Clock fakeClock = fakeAsync.getClock(new DateTime.now());
stopwatchFactory = () {
return new FakeStopwatch(
() => fakeClock.now().millisecondsSinceEpoch,

View File

@@ -84,7 +84,7 @@ void main() {
group('computeMissedFrameBuildBudgetCount', () {
test('computes the number of missed build budgets', () {
TimelineSummary summary = summarize(<Map<String, dynamic>>[
final TimelineSummary summary = summarize(<Map<String, dynamic>>[
build(1000, 9000),
build(11000, 1000),
build(13000, 10000),
@@ -176,7 +176,7 @@ void main() {
group('computeMissedFrameRasterizerBudgetCount', () {
test('computes the number of missed rasterizer budgets', () {
TimelineSummary summary = summarize(<Map<String, dynamic>>[
final TimelineSummary summary = summarize(<Map<String, dynamic>>[
begin(1000), end(10000),
begin(11000), end(12000),
begin(13000), end(23000),
@@ -229,7 +229,7 @@ void main() {
test('writes timeline to JSON file', () async {
await summarize(<Map<String, String>>[<String, String>{'foo': 'bar'}])
.writeTimelineToFile('test', destinationDirectory: tempDir.path);
String written =
final String written =
await fs.file(path.join(tempDir.path, 'test.timeline.json')).readAsString();
expect(written, '{"traceEvents":[{"foo":"bar"}]}');
});
@@ -243,7 +243,7 @@ void main() {
build(11000, 1000),
build(13000, 11000),
]).writeSummaryToFile('test', destinationDirectory: tempDir.path);
String written =
final String written =
await fs.file(path.join(tempDir.path, 'test.timeline_summary.json')).readAsString();
expect(JSON.decode(written), <String, dynamic>{
'average_frame_build_time_millis': 7.0,

View File

@@ -8,7 +8,7 @@ import 'package:flutter_driver/src/timeline.dart';
void main() {
group('Timeline', () {
test('parses JSON', () {
Timeline timeline = new Timeline.fromJson(<String, dynamic>{
final Timeline timeline = new Timeline.fromJson(<String, dynamic>{
'traceEvents': <Map<String, dynamic>>[
<String, dynamic>{
'name': 'test event',
@@ -31,7 +31,7 @@ void main() {
expect(timeline.events, hasLength(2));
TimelineEvent e1 = timeline.events[0];
final TimelineEvent e1 = timeline.events[0];
expect(e1.name, 'test event');
expect(e1.category, 'test category');
expect(e1.phase, 'B');
@@ -43,7 +43,7 @@ void main() {
expect(e1.threadTimestampMicros, 567);
expect(e1.arguments, <String, dynamic>{ 'arg1': true });
TimelineEvent e2 = timeline.events[1];
final TimelineEvent e2 = timeline.events[1];
expect(e2.name, isNull);
expect(e2.category, isNull);
expect(e2.phase, isNull);