Literals get type annotations.

As per the recent fix to the `always_specify_types` lint (https://github.com/dart-lang/linter/issues/199), literal maps and lists are now expected to be explicitly typed.

Running that lint on the repo identifies quite a few spots to update.  This focuses on `flutter_driver` and `flutter_sprites` (somewhat arbitrarily) but the changes are fairly representative.

Note there are a number of places where I made a quick judgement on how specific to make the types.  Feedback on those is welcome.  (Especially as we move forward with more.)
This commit is contained in:
pq
2016-05-04 09:18:31 -07:00
parent 1e093701b7
commit bcede8dffb
11 changed files with 54 additions and 54 deletions

View File

@@ -28,7 +28,7 @@ void main() {
group('frame_count', () {
test('counts frames', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
begin(1000), end(2000),
begin(3000), end(5000),
]).countFrames(),
@@ -39,12 +39,12 @@ void main() {
group('average_frame_build_time_millis', () {
test('returns null when there is no data', () {
expect(summarize([]).computeAverageFrameBuildTimeMillis(), isNull);
expect(summarize(<Map<String, dynamic>>[]).computeAverageFrameBuildTimeMillis(), isNull);
});
test('computes average frame build time in milliseconds', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
begin(1000), end(2000),
begin(3000), end(5000),
]).computeAverageFrameBuildTimeMillis(),
@@ -54,7 +54,7 @@ void main() {
test('skips leading "end" events', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
end(1000),
begin(2000), end(4000),
]).computeAverageFrameBuildTimeMillis(),
@@ -64,7 +64,7 @@ void main() {
test('skips trailing "begin" events', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
begin(2000), end(4000),
begin(5000),
]).computeAverageFrameBuildTimeMillis(),
@@ -75,19 +75,19 @@ void main() {
group('worst_frame_build_time_millis', () {
test('returns null when there is no data', () {
expect(summarize([]).computeWorstFrameBuildTimeMillis(), isNull);
expect(summarize(<Map<String, dynamic>>[]).computeWorstFrameBuildTimeMillis(), isNull);
});
test('computes worst frame build time in milliseconds', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
begin(1000), end(2000),
begin(3000), end(5000),
]).computeWorstFrameBuildTimeMillis(),
2.0
);
expect(
summarize([
summarize(<Map<String, dynamic>>[
begin(3000), end(5000),
begin(1000), end(2000),
]).computeWorstFrameBuildTimeMillis(),
@@ -97,7 +97,7 @@ void main() {
test('skips leading "end" events', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
end(1000),
begin(2000), end(4000),
]).computeWorstFrameBuildTimeMillis(),
@@ -107,7 +107,7 @@ void main() {
test('skips trailing "begin" events', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
begin(2000), end(4000),
begin(5000),
]).computeWorstFrameBuildTimeMillis(),
@@ -118,7 +118,7 @@ void main() {
group('computeMissedFrameBuildBudgetCount', () {
test('computes the number of missed build budgets', () {
TimelineSummary summary = summarize([
TimelineSummary summary = summarize(<Map<String, dynamic>>[
begin(1000), end(10000),
begin(11000), end(12000),
begin(13000), end(23000),
@@ -132,12 +132,12 @@ void main() {
group('summaryJson', () {
test('computes and returns summary as JSON', () {
expect(
summarize([
summarize(<Map<String, dynamic>>[
begin(1000), end(10000),
begin(11000), end(12000),
begin(13000), end(24000),
]).summaryJson,
{
<String, dynamic>{
'average_frame_build_time_millis': 7.0,
'worst_frame_build_time_millis': 11.0,
'missed_frame_build_budget_count': 2,
@@ -158,7 +158,7 @@ void main() {
});
test('writes timeline to JSON file', () async {
await summarize([{'foo': 'bar'}])
await summarize(<Map<String, String>>[<String, String>{'foo': 'bar'}])
.writeTimelineToFile('test', destinationDirectory: '/temp');
String written =
await fs.file('/temp/test.timeline.json').readAsString();
@@ -166,14 +166,14 @@ void main() {
});
test('writes summary to JSON file', () async {
await summarize([
await summarize(<Map<String, dynamic>>[
begin(1000), end(10000),
begin(11000), end(12000),
begin(13000), end(24000),
]).writeSummaryToFile('test', destinationDirectory: '/temp');
String written =
await fs.file('/temp/test.timeline_summary.json').readAsString();
expect(JSON.decode(written), {
expect(JSON.decode(written), <String, dynamic>{
'average_frame_build_time_millis': 7.0,
'worst_frame_build_time_millis': 11.0,
'missed_frame_build_budget_count': 2,

View File

@@ -8,9 +8,9 @@ import 'package:flutter_driver/src/timeline.dart';
void main() {
group('Timeline', () {
test('parses JSON', () {
Timeline timeline = new Timeline.fromJson({
'traceEvents': [
{
Timeline timeline = new Timeline.fromJson(<String, dynamic>{
'traceEvents': <Map<String, dynamic>>[
<String, dynamic>{
'name': 'test event',
'cat': 'test category',
'ph': 'B',
@@ -19,12 +19,12 @@ void main() {
'dur': 345,
'ts': 456,
'tts': 567,
'args': {
'args': <String, dynamic>{
'arg1': true,
}
},
// Tests that we don't choke on missing data
{}
<String, dynamic>{}
]
});
@@ -39,7 +39,7 @@ void main() {
expect(e1.duration, const Duration(microseconds: 345));
expect(e1.timestampMicros, 456);
expect(e1.threadTimestampMicros, 567);
expect(e1.arguments, { 'arg1': true });
expect(e1.arguments, <String, dynamic>{ 'arg1': true });
TimelineEvent e2 = timeline.events[1];
expect(e2.name, isNull);