Commit 46291903 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Declare locals final where not reassigned (tests) (#8566)

parent 27e8cc37
......@@ -13,7 +13,7 @@ void main() {
});
test('Can set value during status callback', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
......@@ -45,12 +45,12 @@ void main() {
});
test('Receives status callbacks for forward and reverse', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
List<double> valueLog = <double>[];
List<AnimationStatus> log = <AnimationStatus>[];
final List<double> valueLog = <double>[];
final List<AnimationStatus> log = <AnimationStatus>[];
controller
..addStatusListener((AnimationStatus status) {
log.add(status);
......@@ -108,12 +108,12 @@ void main() {
});
test('Forward and reverse from values', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
List<double> valueLog = <double>[];
List<AnimationStatus> statusLog = <AnimationStatus>[];
final List<double> valueLog = <double>[];
final List<AnimationStatus> statusLog = <AnimationStatus>[];
controller
..addStatusListener((AnimationStatus status) {
statusLog.add(status);
......@@ -136,12 +136,12 @@ void main() {
});
test('Forward only from value', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
List<double> valueLog = <double>[];
List<AnimationStatus> statusLog = <AnimationStatus>[];
final List<double> valueLog = <double>[];
final List<AnimationStatus> statusLog = <AnimationStatus>[];
controller
..addStatusListener((AnimationStatus status) {
statusLog.add(status);
......@@ -157,7 +157,7 @@ void main() {
});
test('Can fling to upper and lower bounds', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
......@@ -168,7 +168,7 @@ void main() {
expect(controller.value, 1.0);
controller.stop();
AnimationController largeRangeController = new AnimationController(
final AnimationController largeRangeController = new AnimationController(
duration: const Duration(milliseconds: 100),
lowerBound: -30.0,
upperBound: 45.0,
......@@ -187,7 +187,7 @@ void main() {
});
test('lastElapsedDuration control test', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
......@@ -200,7 +200,7 @@ void main() {
});
test('toString control test', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
......@@ -219,7 +219,7 @@ void main() {
});
test('velocity test - linear', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 1000),
vsync: const TestVSync(),
);
......@@ -262,7 +262,7 @@ void main() {
});
test('Disposed AnimationController toString works', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
......@@ -271,7 +271,7 @@ void main() {
});
test('AnimationController error handling', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
vsync: const TestVSync(),
);
......
......@@ -28,7 +28,7 @@ void main() {
expect(curvedAnimation, hasOneLineDescription);
curvedAnimation.reverseCurve = Curves.elasticOut;
expect(curvedAnimation, hasOneLineDescription);
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 500),
vsync: const TestVSync(),
);
......@@ -45,7 +45,7 @@ void main() {
});
test('ProxyAnimation.toString control test', () {
ProxyAnimation animation = new ProxyAnimation();
final ProxyAnimation animation = new ProxyAnimation();
expect(animation.value, 0.0);
expect(animation.status, AnimationStatus.dismissed);
expect(animation, hasOneLineDescription);
......@@ -54,12 +54,12 @@ void main() {
});
test('ProxyAnimation set parent generates value changed', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
vsync: const TestVSync(),
);
controller.value = 0.5;
bool didReceiveCallback = false;
ProxyAnimation animation = new ProxyAnimation()
final ProxyAnimation animation = new ProxyAnimation()
..addListener(() {
didReceiveCallback = true;
});
......@@ -73,7 +73,7 @@ void main() {
});
test('ReverseAnimation calls listeners', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
vsync: const TestVSync(),
);
controller.value = 0.5;
......@@ -81,7 +81,7 @@ void main() {
void listener() {
didReceiveCallback = true;
}
ReverseAnimation animation = new ReverseAnimation(controller)
final ReverseAnimation animation = new ReverseAnimation(controller)
..addListener(listener);
expect(didReceiveCallback, isFalse);
controller.value = 0.6;
......@@ -95,16 +95,16 @@ void main() {
});
test('TrainHoppingAnimation', () {
AnimationController currentTrain = new AnimationController(
final AnimationController currentTrain = new AnimationController(
vsync: const TestVSync(),
);
AnimationController nextTrain = new AnimationController(
final AnimationController nextTrain = new AnimationController(
vsync: const TestVSync(),
);
currentTrain.value = 0.5;
nextTrain.value = 0.75;
bool didSwitchTrains = false;
TrainHoppingAnimation animation = new TrainHoppingAnimation(
final TrainHoppingAnimation animation = new TrainHoppingAnimation(
currentTrain, nextTrain, onSwitchedTrain: () {
didSwitchTrains = true;
});
......@@ -119,20 +119,20 @@ void main() {
});
test('AnimationMean control test', () {
AnimationController left = new AnimationController(
final AnimationController left = new AnimationController(
value: 0.5,
vsync: const TestVSync(),
);
AnimationController right = new AnimationController(
final AnimationController right = new AnimationController(
vsync: const TestVSync(),
);
AnimationMean mean = new AnimationMean(left: left, right: right);
final AnimationMean mean = new AnimationMean(left: left, right: right);
expect(mean, hasOneLineDescription);
expect(mean.value, equals(0.25));
List<double> log = <double>[];
final List<double> log = <double>[];
void logValue() {
log.add(mean.value);
}
......@@ -154,10 +154,10 @@ void main() {
});
test('CurvedAnimation with bogus curve', () {
AnimationController controller = new AnimationController(
final AnimationController controller = new AnimationController(
vsync: const TestVSync(),
);
CurvedAnimation curved = new CurvedAnimation(parent: controller, curve: new BogusCurve());
final CurvedAnimation curved = new CurvedAnimation(parent: controller, curve: new BogusCurve());
expect(() { curved.value; }, throwsFlutterError);
});
......
......@@ -17,8 +17,8 @@ void main() {
});
test('Curve flipped control test', () {
Curve ease = Curves.ease;
Curve flippedEase = ease.flipped;
final Curve ease = Curves.ease;
final Curve flippedEase = ease.flipped;
expect(flippedEase.transform(0.0), lessThan(0.001));
expect(flippedEase.transform(0.5), lessThan(ease.transform(0.5)));
expect(flippedEase.transform(1.0), greaterThan(0.999));
......@@ -26,7 +26,7 @@ void main() {
});
test('Threshold has a threshold', () {
Curve step = const Threshold(0.25);
final Curve step = const Threshold(0.25);
expect(step.transform(0.0), 0.0);
expect(step.transform(0.24), 0.0);
expect(step.transform(0.25), 1.0);
......@@ -55,7 +55,7 @@ void main() {
});
List<double> estimateBounds(Curve curve) {
List<double> values = <double>[];
final List<double> values = <double>[];
values.add(curve.transform(0.0));
values.add(curve.transform(0.1));
......@@ -95,12 +95,12 @@ void main() {
test('Decelerate does so', () {
expect(Curves.decelerate, hasOneLineDescription);
List<double> bounds = estimateBounds(Curves.decelerate);
final List<double> bounds = estimateBounds(Curves.decelerate);
expect(bounds[0], greaterThanOrEqualTo(0.0));
expect(bounds[1], lessThanOrEqualTo(1.0));
double d1 = Curves.decelerate.transform(0.2) - Curves.decelerate.transform(0.0);
double d2 = Curves.decelerate.transform(1.0) - Curves.decelerate.transform(0.8);
final double d1 = Curves.decelerate.transform(0.2) - Curves.decelerate.transform(0.0);
final double d2 = Curves.decelerate.transform(1.0) - Curves.decelerate.transform(0.8);
expect(d2, lessThan(d1));
});
......
......@@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart';
void main() {
test('Can chain tweens', () {
Tween<double> tween = new Tween<double>(begin: 0.30, end: 0.50);
final Tween<double> tween = new Tween<double>(begin: 0.30, end: 0.50);
expect(tween, hasOneLineDescription);
Animatable<double> chain = tween.chain(new Tween<double>(begin: 0.50, end: 1.0));
AnimationController controller = new AnimationController(
final Animatable<double> chain = tween.chain(new Tween<double>(begin: 0.50, end: 1.0));
final AnimationController controller = new AnimationController(
vsync: const TestVSync(),
);
expect(chain.evaluate(controller), 0.40);
......@@ -19,11 +19,11 @@ void main() {
});
test('Can animated tweens', () {
Tween<double> tween = new Tween<double>(begin: 0.30, end: 0.50);
AnimationController controller = new AnimationController(
final Tween<double> tween = new Tween<double>(begin: 0.30, end: 0.50);
final AnimationController controller = new AnimationController(
vsync: const TestVSync(),
);
Animation<double> animation = tween.animate(controller);
final Animation<double> animation = tween.animate(controller);
controller.value = 0.50;
expect(animation.value, 0.40);
expect(animation, hasOneLineDescription);
......@@ -31,21 +31,21 @@ void main() {
});
test('SizeTween', () {
SizeTween tween = new SizeTween(begin: Size.zero, end: const Size(20.0, 30.0));
final SizeTween tween = new SizeTween(begin: Size.zero, end: const Size(20.0, 30.0));
expect(tween.lerp(0.5), equals(const Size(10.0, 15.0)));
expect(tween, hasOneLineDescription);
});
test('IntTween', () {
IntTween tween = new IntTween(begin: 5, end: 9);
final IntTween tween = new IntTween(begin: 5, end: 9);
expect(tween.lerp(0.5), 7);
expect(tween.lerp(0.7), 8);
});
test('RectTween', () {
Rect a = new Rect.fromLTWH(5.0, 3.0, 7.0, 11.0);
Rect b = new Rect.fromLTWH(8.0, 12.0, 14.0, 18.0);
RectTween tween = new RectTween(begin: a, end: b);
final Rect a = new Rect.fromLTWH(5.0, 3.0, 7.0, 11.0);
final Rect b = new Rect.fromLTWH(8.0, 12.0, 14.0, 18.0);
final RectTween tween = new RectTween(begin: a, end: b);
expect(tween.lerp(0.5), equals(Rect.lerp(a, b, 0.5)));
expect(tween, hasOneLineDescription);
});
......
......@@ -20,7 +20,7 @@ void main() {
onPressed: null,
))
);
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
final RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size,
// 1 10px character + 16px * 2 is smaller than the 48px minimum.
......@@ -35,7 +35,7 @@ void main() {
onPressed: null,
))
);
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
final RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size.width,
// 4 10px character + 16px * 2 = 72.
......@@ -49,7 +49,7 @@ void main() {
onPressed: null,
color: new Color(0xFFFFFFFF),
)));
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
final RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size.width,
// 1 10px character + 64 * 2 = 138 for buttons with background.
......@@ -63,7 +63,7 @@ void main() {
onPressed: null,
padding: new EdgeInsets.all(100.0),
)));
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
final RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size,
const Size.square(210.0),
......
......@@ -69,7 +69,7 @@ void main() {
child: new Text('Ok'),
));
DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.color.red, greaterThan(widget.style.color.blue));
expect(widget.style.color.alpha, lessThan(255));
......
......@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Switch can toggle on tap', (WidgetTester tester) async {
Key switchKey = new UniqueKey();
final Key switchKey = new UniqueKey();
bool value = false;
await tester.pumpWidget(
new StatefulBuilder(
......
......@@ -8,7 +8,7 @@ import 'package:test/test.dart';
void main() {
test("color accessors should work", () {
Color foo = const Color(0x12345678);
final Color foo = const Color(0x12345678);
expect(foo.alpha, equals(0x12));
expect(foo.red, equals(0x34));
expect(foo.green, equals(0x56));
......@@ -16,16 +16,16 @@ void main() {
});
test("paint set to black", () {
Color c = const Color(0x00000000);
Paint p = new Paint();
final Color c = const Color(0x00000000);
final Paint p = new Paint();
p.color = c;
expect(c.toString(), equals('Color(0x00000000)'));
});
test("color created with out of bounds value", () {
try {
Color c = const Color(0x100 << 24);
Paint p = new Paint();
final Color c = const Color(0x100 << 24);
final Paint p = new Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
......@@ -34,8 +34,8 @@ void main() {
test("color created with wildly out of bounds value", () {
try {
Color c = const Color(1 << 1000000);
Paint p = new Paint();
final Color c = const Color(1 << 1000000);
final Paint p = new Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
......
......@@ -8,9 +8,9 @@ import 'package:test/test.dart';
void main() {
test("Should be able to build and layout a paragraph", () {
ParagraphBuilder builder = new ParagraphBuilder(new ParagraphStyle());
final ParagraphBuilder builder = new ParagraphBuilder(new ParagraphStyle());
builder.addText('Hello');
Paragraph paragraph = builder.build();
final Paragraph paragraph = builder.build();
expect(paragraph, isNotNull);
paragraph.layout(new ParagraphConstraints(width: 800.0));
......
......@@ -8,7 +8,7 @@ import 'package:test/test.dart';
void main() {
test("rect accessors", () {
Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
final Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0);
expect(r.left, equals(1.0));
expect(r.top, equals(3.0));
expect(r.right, equals(5.0));
......@@ -16,7 +16,7 @@ void main() {
});
test("rect created by width and height", () {
Rect r = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
final Rect r = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0);
expect(r.left, equals(1.0));
expect(r.top, equals(3.0));
expect(r.right, equals(6.0));
......@@ -24,14 +24,14 @@ void main() {
});
test("rect intersection", () {
Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
Rect r3 = r1.intersect(r2);
final Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0);
final Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0);
final Rect r3 = r1.intersect(r2);
expect(r3.left, equals(50.0));
expect(r3.top, equals(50.0));
expect(r3.right, equals(100.0));
expect(r3.bottom, equals(100.0));
Rect r4 = r2.intersect(r1);
final Rect r4 = r2.intersect(r1);
expect(r4, equals(r3));
});
}
......@@ -11,7 +11,7 @@ enum _TestEnum {
void main() {
test('BitField control test', () {
BitField<_TestEnum> field = new BitField<_TestEnum>(8);
final BitField<_TestEnum> field = new BitField<_TestEnum>(8);
expect(field[_TestEnum.d], isFalse);
......@@ -42,11 +42,11 @@ void main() {
});
test('BitField.filed control test', () {
BitField<_TestEnum> field1 = new BitField<_TestEnum>.filled(8, true);
final BitField<_TestEnum> field1 = new BitField<_TestEnum>.filled(8, true);
expect(field1[_TestEnum.d], isTrue);
BitField<_TestEnum> field2 = new BitField<_TestEnum>.filled(8, false);
final BitField<_TestEnum> field2 = new BitField<_TestEnum>.filled(8, false);
expect(field2[_TestEnum.d], isFalse);
});
......
......@@ -21,7 +21,7 @@ void main() {
});
test('The Caching Iterable: length caches', () {
Iterable<int> i = new CachingIterable<int>(range(1, 5).iterator);
final Iterable<int> i = new CachingIterable<int>(range(1, 5).iterator);
expect(yieldCount, equals(0));
expect(i.length, equals(5));
expect(yieldCount, equals(5));
......@@ -37,7 +37,7 @@ void main() {
});
test('The Caching Iterable: laziness', () {
Iterable<int> i = new CachingIterable<int>(range(1, 5).iterator);
final Iterable<int> i = new CachingIterable<int>(range(1, 5).iterator);
expect(yieldCount, equals(0));
expect(i.first, equals(1));
......@@ -51,10 +51,10 @@ void main() {
});
test('The Caching Iterable: where and map', () {
Iterable<int> integers = new CachingIterable<int>(range(1, 5).iterator);
final Iterable<int> integers = new CachingIterable<int>(range(1, 5).iterator);
expect(yieldCount, equals(0));
Iterable<int> evens = integers.where((int i) => i % 2 == 0);
final Iterable<int> evens = integers.where((int i) => i % 2 == 0);
expect(yieldCount, equals(0));
expect(evens.first, equals(2));
......@@ -74,16 +74,16 @@ void main() {
});
test('The Caching Iterable: take and skip', () {
Iterable<int> integers = new CachingIterable<int>(range(1, 5).iterator);
final Iterable<int> integers = new CachingIterable<int>(range(1, 5).iterator);
expect(yieldCount, equals(0));
Iterable<int> secondTwo = integers.skip(1).take(2);
final Iterable<int> secondTwo = integers.skip(1).take(2);
expect(yieldCount, equals(0));
expect(secondTwo, equals(<int>[2, 3]));
expect(yieldCount, equals(3));
Iterable<int> result = integers.takeWhile((int i) => i < 4).skipWhile((int i) => i < 3);
final Iterable<int> result = integers.takeWhile((int i) => i < 4).skipWhile((int i) => i < 3);
expect(result, equals(<int>[3]));
expect(yieldCount, equals(4));
......@@ -92,16 +92,16 @@ void main() {
});
test('The Caching Iterable: expand', () {
Iterable<int> integers = new CachingIterable<int>(range(1, 5).iterator);
final Iterable<int> integers = new CachingIterable<int>(range(1, 5).iterator);
expect(yieldCount, equals(0));
Iterable<int> expanded1 = integers.expand((int i) => <int>[i, i]);
final Iterable<int> expanded1 = integers.expand((int i) => <int>[i, i]);
expect(yieldCount, equals(0));
expect(expanded1, equals(<int>[1, 1, 2, 2, 3, 3, 4, 4, 5, 5]));
expect(yieldCount, equals(5));
Iterable<int> expanded2 = integers.expand((int i) => <int>[i, i]);
final Iterable<int> expanded2 = integers.expand((int i) => <int>[i, i]);
expect(yieldCount, equals(5));
expect(expanded2, equals(<int>[1, 1, 2, 2, 3, 3, 4, 4, 5, 5]));
......
......@@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:ui' show VoidCallback;
List<String> captureOutput(VoidCallback fn) {
List<String> log = <String>[];
final List<String> log = <String>[];
runZoned<Null>(fn, zoneSpecification: new ZoneSpecification(
print: (Zone self,
......
......@@ -14,8 +14,8 @@ class A<U extends X> {
void main() {
test('Assignment through a covariant template throws exception', () {
A<Y> ay = new A<Y>();
A<X> ayAsAx = ay;
final A<Y> ay = new A<Y>();
final A<X> ayAsAx = ay;
expect(() {
ayAsAx.u = new X();
}, throwsAssertionError);
......
......@@ -9,7 +9,7 @@ void main() {
test('LicenseEntryWithLineBreaks - most cases', () {
// There's some trailing spaces in this string.
// To avoid IDEs stripping them, I've escaped them as \u0020.
List<LicenseParagraph> paragraphs = const LicenseEntryWithLineBreaks(null, '''
final List<LicenseParagraph> paragraphs = const LicenseEntryWithLineBreaks(null, '''
A
A
A
......@@ -183,7 +183,7 @@ S
yield const LicenseEntryWithLineBreaks(null, 'D');
});
expect(await LicenseRegistry.licenses.toList(), hasLength(4));
List<LicenseEntry> licenses = await LicenseRegistry.licenses.toList();
final List<LicenseEntry> licenses = await LicenseRegistry.licenses.toList();
expect(licenses, hasLength(4));
expect(licenses[0].paragraphs.single.text, 'A');
expect(licenses[1].paragraphs.single.text, 'B');
......
......@@ -57,7 +57,7 @@ class TestServiceExtensionsBinding extends BindingBase
}
Future<Null> flushMicrotasks() {
Completer<Null> completer = new Completer<Null>();
final Completer<Null> completer = new Completer<Null>();
new Timer(const Duration(), () {
completer.complete();
});
......@@ -82,7 +82,7 @@ Future<Map<String, String>> hasReassemble(Future<Map<String, String>> pendingRes
}
void main() {
List<String> console = <String>[];
final List<String> console = <String>[];
test('Service extensions - pretest', () async {
binding = new TestServiceExtensionsBinding();
......
......@@ -9,7 +9,7 @@ void main() {
// TODO(8128): These tests and the filtering mechanism should be revisited to account for causal async stack traces.
test('FlutterError.defaultStackFilter', () {
List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
final List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
expect(filtered.length, greaterThanOrEqualTo(4));
expect(filtered[0], matches(r'^#0 +main\.<anonymous closure> \(.*stack_trace_test\.dart:[0-9]+:[0-9]+\)$'));
expect(filtered[1], matches(r'^#1 +Declarer\.test\.<anonymous closure>.<anonymous closure> \(package:test/.+:[0-9]+:[0-9]+\)$'));
......@@ -18,7 +18,7 @@ void main() {
});
test('FlutterError.defaultStackFilter (async test body)', () async {
List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
final List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
expect(filtered.length, greaterThanOrEqualTo(3));
expect(filtered[0], matches(r'^#0 +main\.<anonymous closure> \(.*stack_trace_test\.dart:[0-9]+:[0-9]+\)$'));
expect(filtered[1], equals('<asynchronous suspension>'));
......
......@@ -9,7 +9,7 @@ import 'package:test/test.dart';
void main() {
test('SynchronousFuture control test', () async {
Future<int> future = new SynchronousFuture<int>(42);
final Future<int> future = new SynchronousFuture<int>(42);
int result;
future.then<Null>((int value) { result = value; });
......@@ -17,19 +17,19 @@ void main() {
expect(result, equals(42));
result = null;
Future<int> futureWithTimeout = future.timeout(const Duration(milliseconds: 1));
final Future<int> futureWithTimeout = future.timeout(const Duration(milliseconds: 1));
futureWithTimeout.then<Null>((int value) { result = value; });
expect(result, isNull);
await futureWithTimeout;
expect(result, equals(42));
result = null;
Stream<int> stream = future.asStream();
final Stream<int> stream = future.asStream();
expect(await stream.single, equals(42));
bool ranAction = false;
Future<int> completeResult = future.whenComplete(() {
final Future<int> completeResult = future.whenComplete(() {
ranAction = true;
return new Future<int>.value(31);
});
......
......@@ -65,7 +65,7 @@ class GestureTester {
void main() {
test('Should win by accepting', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.arena.close(primaryKey);
......@@ -75,7 +75,7 @@ void main() {
});
test('Should win by sweep', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.arena.close(primaryKey);
......@@ -85,7 +85,7 @@ void main() {
});
test('Should win on release after hold sweep release', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.arena.close(primaryKey);
......@@ -99,7 +99,7 @@ void main() {
});
test('Should win on sweep after hold release sweep', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.arena.close(primaryKey);
......@@ -113,7 +113,7 @@ void main() {
});
test('Only first winner should win', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.arena.close(primaryKey);
......@@ -124,7 +124,7 @@ void main() {
});
test('Only first winner should win, regardless of order', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.arena.close(primaryKey);
......@@ -135,7 +135,7 @@ void main() {
});
test('Win before close is delayed to close', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.expectNothing();
......@@ -146,7 +146,7 @@ void main() {
});
test('Win before close is delayed to close, and only first winner should win', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.expectNothing();
......@@ -158,7 +158,7 @@ void main() {
});
test('Win before close is delayed to close, and only first winner should win, regardless of order', () {
GestureTester tester = new GestureTester();
final GestureTester tester = new GestureTester();
tester.addFirst();
tester.addSecond();
tester.expectNothing();
......
......@@ -87,7 +87,7 @@ void main() {
);
testGesture('Should recognize double tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -120,7 +120,7 @@ void main() {
});
testGesture('Inter-tap distance cancels double tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -153,7 +153,7 @@ void main() {
});
testGesture('Intra-tap distance cancels double tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -188,7 +188,7 @@ void main() {
});
testGesture('Inter-tap delay cancels double tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -222,7 +222,7 @@ void main() {
});
testGesture('Inter-tap delay resets double tap, allowing third tap to be a double-tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -268,7 +268,7 @@ void main() {
});
testGesture('Intra-tap delay does not cancel double tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -302,7 +302,7 @@ void main() {
});
testGesture('Should not recognize two overlapping taps', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -335,7 +335,7 @@ void main() {
});
testGesture('Should recognize one tap of group followed by second tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -380,7 +380,7 @@ void main() {
});
testGesture('Should cancel on arena reject during first tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -388,8 +388,8 @@ void main() {
};
tap.addPointer(down1);
TestGestureArenaMember member = new TestGestureArenaMember();
GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final TestGestureArenaMember member = new TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
tester.closeArena(1);
expect(doubleTapRecognized, isFalse);
tester.route(down1);
......@@ -418,7 +418,7 @@ void main() {
});
testGesture('Should cancel on arena reject between taps', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -426,8 +426,8 @@ void main() {
};
tap.addPointer(down1);
TestGestureArenaMember member = new TestGestureArenaMember();
GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final TestGestureArenaMember member = new TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
tester.closeArena(1);
expect(doubleTapRecognized, isFalse);
tester.route(down1);
......@@ -456,7 +456,7 @@ void main() {
});
testGesture('Should cancel on arena reject during last tap', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -464,8 +464,8 @@ void main() {
};
tap.addPointer(down1);
TestGestureArenaMember member = new TestGestureArenaMember();
GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final TestGestureArenaMember member = new TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
tester.closeArena(1);
expect(doubleTapRecognized, isFalse);
tester.route(down1);
......@@ -494,7 +494,7 @@ void main() {
});
testGesture('Passive gesture should trigger on double tap cancel', (GestureTester tester) {
DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer();
bool doubleTapRecognized = false;
tap.onDoubleTap = () {
......@@ -503,7 +503,7 @@ void main() {
new FakeAsync().run((FakeAsync async) {
tap.addPointer(down1);
TestGestureArenaMember member = new TestGestureArenaMember();
final TestGestureArenaMember member = new TestGestureArenaMember();
GestureBinding.instance.gestureArena.add(1, member);
tester.closeArena(1);
expect(doubleTapRecognized, isFalse);
......
......@@ -11,8 +11,8 @@ void main() {
setUp(ensureGestureBinding);
testGesture('Should recognize pan', (GestureTester tester) {
PanGestureRecognizer pan = new PanGestureRecognizer();
TapGestureRecognizer tap = new TapGestureRecognizer();
final PanGestureRecognizer pan = new PanGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool didStartPan = false;
pan.onStart = (_) {
......@@ -34,8 +34,8 @@ void main() {
didTap = true;
};
TestPointer pointer = new TestPointer(5);
PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
pan.addPointer(down);
tap.addPointer(down);
tester.closeArena(5);
......@@ -77,7 +77,7 @@ void main() {
});
testGesture('Should recognize drag', (GestureTester tester) {
HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer();
final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer();
bool didStartDrag = false;
drag.onStart = (_) {
......@@ -94,8 +94,8 @@ void main() {
didEndDrag = true;
};
TestPointer pointer = new TestPointer(5);
PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
drag.addPointer(down);
tester.closeArena(5);
expect(didStartDrag, isFalse);
......@@ -130,7 +130,7 @@ void main() {
});
testGesture('Clamp max velocity', (GestureTester tester) {
HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer();
final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer();
Velocity velocity;
double primaryVelocity;
......@@ -139,8 +139,8 @@ void main() {
primaryVelocity = details.primaryVelocity;
};
TestPointer pointer = new TestPointer(5);
PointerDownEvent down = pointer.down(const Point(10.0, 25.0), timeStamp: const Duration(milliseconds: 10));
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 25.0), timeStamp: const Duration(milliseconds: 10));
drag.addPointer(down);
tester.closeArena(5);
tester.route(down);
......
......@@ -33,14 +33,14 @@ void main() {
setUp(ensureTestGestureBinding);
test('Pointer tap events', () {
ui.PointerDataPacket packet = const ui.PointerDataPacket(
final ui.PointerDataPacket packet = const ui.PointerDataPacket(
data: const <ui.PointerData>[
const ui.PointerData(change: ui.PointerChange.down),
const ui.PointerData(change: ui.PointerChange.up),
]
);
List<PointerEvent> events = <PointerEvent>[];
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event);
ui.window.onPointerDataPacket(packet);
......@@ -50,7 +50,7 @@ void main() {
});
test('Pointer move events', () {
ui.PointerDataPacket packet = const ui.PointerDataPacket(
final ui.PointerDataPacket packet = const ui.PointerDataPacket(
data: const <ui.PointerData>[
const ui.PointerData(change: ui.PointerChange.down),
const ui.PointerData(change: ui.PointerChange.move),
......@@ -58,7 +58,7 @@ void main() {
]
);
List<PointerEvent> events = <PointerEvent>[];
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event);
ui.window.onPointerDataPacket(packet);
......@@ -69,7 +69,7 @@ void main() {
});
test('Synthetic move events', () {
ui.PointerDataPacket packet = const ui.PointerDataPacket(
final ui.PointerDataPacket packet = const ui.PointerDataPacket(
data: const <ui.PointerData>[
const ui.PointerData(
change: ui.PointerChange.down,
......@@ -84,7 +84,7 @@ void main() {
]
);
List<PointerEvent> events = <PointerEvent>[];
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event);
ui.window.onPointerDataPacket(packet);
......@@ -96,14 +96,14 @@ void main() {
});
test('Pointer cancel events', () {
ui.PointerDataPacket packet = const ui.PointerDataPacket(
final ui.PointerDataPacket packet = const ui.PointerDataPacket(
data: const <ui.PointerData>[
const ui.PointerData(change: ui.PointerChange.down),
const ui.PointerData(change: ui.PointerChange.cancel),
]
);
List<PointerEvent> events = <PointerEvent>[];
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) => events.add(event);
ui.window.onPointerDataPacket(packet);
......@@ -113,14 +113,14 @@ void main() {
});
test('Can cancel pointers', () {
ui.PointerDataPacket packet = const ui.PointerDataPacket(
final ui.PointerDataPacket packet = const ui.PointerDataPacket(
data: const <ui.PointerData>[
const ui.PointerData(change: ui.PointerChange.down),
const ui.PointerData(change: ui.PointerChange.up),
]
);
List<PointerEvent> events = <PointerEvent>[];
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) {
events.add(event);
if (event is PointerDownEvent)
......@@ -134,7 +134,7 @@ void main() {
});
test('Can expand add and hover pointers', () {
ui.PointerDataPacket packet = const ui.PointerDataPacket(
final ui.PointerDataPacket packet = const ui.PointerDataPacket(
data: const <ui.PointerData>[
const ui.PointerData(change: ui.PointerChange.add, device: 24),
const ui.PointerData(change: ui.PointerChange.hover, device: 24),
......@@ -143,7 +143,7 @@ void main() {
]
);
List<PointerEvent> events = PointerEventConverter.expand(
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5);
......@@ -155,7 +155,7 @@ void main() {
});
test('Synthetic hover and cancel for misplaced down and remove', () {
ui.PointerDataPacket packet = const ui.PointerDataPacket(
final ui.PointerDataPacket packet = const ui.PointerDataPacket(
data: const <ui.PointerData>[
const ui.PointerData(change: ui.PointerChange.add, device: 25, physicalX: 10.0, physicalY: 10.0),
const ui.PointerData(change: ui.PointerChange.down, device: 25, physicalX: 15.0, physicalY: 17.0),
......@@ -163,7 +163,7 @@ void main() {
]
);
List<PointerEvent> events = PointerEventConverter.expand(
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5);
......
......@@ -21,7 +21,7 @@ void main() {
setUp(ensureGestureBinding);
testGesture('Should recognize long press', (GestureTester tester) {
LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
bool longPressRecognized = false;
longPress.onLongPress = () {
......@@ -42,7 +42,7 @@ void main() {
});
testGesture('Up cancels long press', (GestureTester tester) {
LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
bool longPressRecognized = false;
longPress.onLongPress = () {
......@@ -65,8 +65,8 @@ void main() {
});
testGesture('Should recognize both tap down and long press', (GestureTester tester) {
LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
TapGestureRecognizer tap = new TapGestureRecognizer();
final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool tapDownRecognized = false;
tap.onTapDown = (_) {
......@@ -98,8 +98,8 @@ void main() {
});
testGesture('Drag start delayed by microtask', (GestureTester tester) {
LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer();
final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer();
final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer();
bool isDangerousStack = false;
......
......@@ -13,12 +13,12 @@ void main() {
}
test('Least-squares fit: linear polynomial to line', () {
List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
List<double> y = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
final List<double> y = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
PolynomialFit fit = solver.solve(1);
final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(1);
expect(fit.coefficients.length, 2);
expect(approx(fit.coefficients[0], 1.0), isTrue);
......@@ -27,12 +27,12 @@ void main() {
});
test('Least-squares fit: linear polynomial to sloped line', () {
List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
List<double> y = <double>[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0];
List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
final List<double> y = <double>[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0];
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
PolynomialFit fit = solver.solve(1);
final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(1);
expect(fit.coefficients.length, 2);
expect(approx(fit.coefficients[0], 1.0), isTrue);
......@@ -41,12 +41,12 @@ void main() {
});
test('Least-squares fit: quadratic polynomial to line', () {
List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
List<double> y = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
final List<double> y = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
PolynomialFit fit = solver.solve(2);
final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(2);
expect(fit.coefficients.length, 3);
expect(approx(fit.coefficients[0], 1.0), isTrue);
......@@ -56,12 +56,12 @@ void main() {
});
test('Least-squares fit: quadratic polynomial to sloped line', () {
List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
List<double> y = <double>[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0];
List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final List<double> x = <double>[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
final List<double> y = <double>[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0];
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
PolynomialFit fit = solver.solve(2);
final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(2);
expect(fit.coefficients.length, 3);
expect(approx(fit.coefficients[0], 1.0), isTrue);
......
......@@ -14,7 +14,7 @@ void main() {
setUp(ensureGestureBinding);
testGesture('MultiDrag control test', (GestureTester tester) {
DelayedMultiDragGestureRecognizer drag = new DelayedMultiDragGestureRecognizer();
final DelayedMultiDragGestureRecognizer drag = new DelayedMultiDragGestureRecognizer();
bool didStartDrag = false;
drag.onStart = (Point position) {
......@@ -22,8 +22,8 @@ void main() {
return new TestDrag();
};
TestPointer pointer = new TestPointer(5);
PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(const Point(10.0, 10.0));
drag.addPointer(down);
tester.closeArena(5);
expect(didStartDrag, isFalse);
......
......@@ -14,9 +14,9 @@ void main() {
setUp(ensureGestureBinding);
testGesture('Should recognize pan', (GestureTester tester) {
MultiTapGestureRecognizer tap = new MultiTapGestureRecognizer(longTapDelay: kLongPressTimeout);
final MultiTapGestureRecognizer tap = new MultiTapGestureRecognizer(longTapDelay: kLongPressTimeout);
List<String> log = <String>[];
final List<String> log = <String>[];
tap.onTapDown = (int pointer, TapDownDetails details) { log.add('tap-down $pointer'); };
tap.onTapUp = (int pointer, TapUpDetails details) { log.add('tap-up $pointer'); };
......@@ -25,8 +25,8 @@ void main() {
tap.onTapCancel = (int pointer) { log.add('tap-cancel $pointer'); };
TestPointer pointer5 = new TestPointer(5);
PointerDownEvent down5 = pointer5.down(const Point(10.0, 10.0));
final TestPointer pointer5 = new TestPointer(5);
final PointerDownEvent down5 = pointer5.down(const Point(10.0, 10.0));
tap.addPointer(down5);
tester.closeArena(5);
expect(log, <String>['tap-down 5']);
......@@ -34,8 +34,8 @@ void main() {
tester.route(down5);
expect(log, isEmpty);
TestPointer pointer6 = new TestPointer(6);
PointerDownEvent down6 = pointer6.down(const Point(15.0, 15.0));
final TestPointer pointer6 = new TestPointer(6);
final PointerDownEvent down6 = pointer6.down(const Point(15.0, 15.0));
tap.addPointer(down6);
tester.closeArena(6);
expect(log, <String>['tap-down 6']);
......
......@@ -13,10 +13,10 @@ void main() {
callbackRan = true;
}
TestPointer pointer2 = new TestPointer(2);
TestPointer pointer3 = new TestPointer(3);
final TestPointer pointer2 = new TestPointer(2);
final TestPointer pointer3 = new TestPointer(3);
PointerRouter router = new PointerRouter();
final PointerRouter router = new PointerRouter();
router.addRoute(3, callback);
router.route(pointer2.down(Point.origin));
expect(callbackRan, isFalse);
......@@ -33,12 +33,12 @@ void main() {
void callback(PointerEvent event) {
callbackRan = true;
}
PointerRouter router = new PointerRouter();
final PointerRouter router = new PointerRouter();
router.addRoute(2, (PointerEvent event) {
router.removeRoute(2, callback);
});
router.addRoute(2, callback);
TestPointer pointer2 = new TestPointer(2);
final TestPointer pointer2 = new TestPointer(2);
router.route(pointer2.down(Point.origin));
expect(callbackRan, isFalse);
});
......@@ -50,13 +50,13 @@ void main() {
}
bool firstCallbackRan = false;
PointerRouter router = new PointerRouter();
final PointerRouter router = new PointerRouter();
router.addGlobalRoute((PointerEvent event) {
firstCallbackRan = true;
router.addGlobalRoute(secondCallback);
});
TestPointer pointer2 = new TestPointer(2);
final TestPointer pointer2 = new TestPointer(2);
router.route(pointer2.down(Point.origin));
expect(firstCallbackRan, isTrue);
expect(secondCallbackRan, isFalse);
......@@ -67,12 +67,12 @@ void main() {
void callback(PointerEvent event) {
callbackRan = true;
}
PointerRouter router = new PointerRouter();
final PointerRouter router = new PointerRouter();
router.addGlobalRoute((PointerEvent event) {
router.removeGlobalRoute(callback);
});
router.addGlobalRoute(callback);
TestPointer pointer2 = new TestPointer(2);
final TestPointer pointer2 = new TestPointer(2);
router.route(pointer2.down(Point.origin));
expect(callbackRan, isFalse);
});
......@@ -82,21 +82,21 @@ void main() {
void callback(PointerEvent event) {
callbackRan = true;
}
PointerRouter router = new PointerRouter();
final PointerRouter router = new PointerRouter();
bool perPointerCallbackRan = false;
router.addRoute(2, (PointerEvent event) {
perPointerCallbackRan = true;
router.addGlobalRoute(callback);
});
TestPointer pointer2 = new TestPointer(2);
final TestPointer pointer2 = new TestPointer(2);
router.route(pointer2.down(Point.origin));
expect(perPointerCallbackRan, isTrue);
expect(callbackRan, isFalse);
});
test('Per-pointer callbacks happen before global callbacks', () {
List<String> log = <String>[];
PointerRouter router = new PointerRouter();
final List<String> log = <String>[];
final PointerRouter router = new PointerRouter();
router.addGlobalRoute((PointerEvent event) {
log.add('global 1');
});
......@@ -109,7 +109,7 @@ void main() {
router.addRoute(2, (PointerEvent event) {
log.add('per-pointer 2');
});
TestPointer pointer2 = new TestPointer(2);
final TestPointer pointer2 = new TestPointer(2);
router.route(pointer2.down(Point.origin));
expect(log, equals(<String>[
'per-pointer 1',
......@@ -120,8 +120,8 @@ void main() {
});
test('Exceptions do not stop pointer routing', () {
List<String> log = <String>[];
PointerRouter router = new PointerRouter();
final List<String> log = <String>[];
final PointerRouter router = new PointerRouter();
router.addRoute(2, (PointerEvent event) {
log.add('per-pointer 1');
});
......@@ -133,12 +133,12 @@ void main() {
log.add('per-pointer 3');
});
FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) {
log.add('error report');
};
TestPointer pointer2 = new TestPointer(2);
final TestPointer pointer2 = new TestPointer(2);
router.route(pointer2.down(Point.origin));
expect(log, equals(<String>[
'per-pointer 1',
......
......@@ -21,7 +21,7 @@ class TestGestureRecognizer extends GestureRecognizer {
void main() {
test('GestureRecognizer.toStringShort defaults to toString', () {
TestGestureRecognizer recognizer = new TestGestureRecognizer();
final TestGestureRecognizer recognizer = new TestGestureRecognizer();
expect(recognizer.toStringShort(), equals(recognizer.toString()));
});
}
......@@ -11,8 +11,8 @@ void main() {
setUp(ensureGestureBinding);
testGesture('Should recognize scale gestures', (GestureTester tester) {
ScaleGestureRecognizer scale = new ScaleGestureRecognizer();
TapGestureRecognizer tap = new TapGestureRecognizer();
final ScaleGestureRecognizer scale = new ScaleGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool didStartScale = false;
Point updatedFocalPoint;
......@@ -37,9 +37,9 @@ void main() {
didTap = true;
};
TestPointer pointer1 = new TestPointer(1);
final TestPointer pointer1 = new TestPointer(1);
PointerDownEvent down = pointer1.down(const Point(10.0, 10.0));
final PointerDownEvent down = pointer1.down(const Point(10.0, 10.0));
scale.addPointer(down);
tap.addPointer(down);
......@@ -69,8 +69,8 @@ void main() {
expect(didTap, isFalse);
// Two-finger scaling
TestPointer pointer2 = new TestPointer(2);
PointerDownEvent down2 = pointer2.down(const Point(10.0, 20.0));
final TestPointer pointer2 = new TestPointer(2);
final PointerDownEvent down2 = pointer2.down(const Point(10.0, 20.0));
scale.addPointer(down2);
tap.addPointer(down2);
tester.closeArena(2);
......@@ -102,8 +102,8 @@ void main() {
expect(didTap, isFalse);
// Three-finger scaling
TestPointer pointer3 = new TestPointer(3);
PointerDownEvent down3 = pointer3.down(const Point(25.0, 35.0));
final TestPointer pointer3 = new TestPointer(3);
final PointerDownEvent down3 = pointer3.down(const Point(25.0, 35.0));
scale.addPointer(down3);
tap.addPointer(down3);
tester.closeArena(3);
......
......@@ -58,7 +58,7 @@ void main() {
);
testGesture('Should recognize tap', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool tapRecognized = false;
tap.onTap = () {
......@@ -80,7 +80,7 @@ void main() {
});
testGesture('No duplicate tap events', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
int tapsRecognized = 0;
tap.onTap = () {
......@@ -113,7 +113,7 @@ void main() {
});
testGesture('Should not recognize two overlapping taps', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
int tapsRecognized = 0;
tap.onTap = () {
......@@ -147,7 +147,7 @@ void main() {
});
testGesture('Distance cancels tap', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool tapRecognized = false;
tap.onTap = () {
......@@ -180,7 +180,7 @@ void main() {
});
testGesture('Timeout does not cancel tap', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool tapRecognized = false;
tap.onTap = () {
......@@ -204,7 +204,7 @@ void main() {
});
testGesture('Should yield to other arena members', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool tapRecognized = false;
tap.onTap = () {
......@@ -212,8 +212,8 @@ void main() {
};
tap.addPointer(down1);
TestGestureArenaMember member = new TestGestureArenaMember();
GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final TestGestureArenaMember member = new TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
GestureBinding.instance.gestureArena.hold(1);
tester.closeArena(1);
expect(tapRecognized, isFalse);
......@@ -232,7 +232,7 @@ void main() {
});
testGesture('Should trigger on release of held arena', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
bool tapRecognized = false;
tap.onTap = () {
......@@ -240,8 +240,8 @@ void main() {
};
tap.addPointer(down1);
TestGestureArenaMember member = new TestGestureArenaMember();
GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final TestGestureArenaMember member = new TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
GestureBinding.instance.gestureArena.hold(1);
tester.closeArena(1);
expect(tapRecognized, isFalse);
......@@ -261,13 +261,13 @@ void main() {
});
testGesture('Should log exceptions from callbacks', (GestureTester tester) {
TapGestureRecognizer tap = new TapGestureRecognizer();
final TapGestureRecognizer tap = new TapGestureRecognizer();
tap.onTap = () {
throw new Exception(test);
};
FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
bool gotError = false;
FlutterError.onError = (FlutterErrorDetails details) {
gotError = true;
......
......@@ -12,25 +12,25 @@ void main() {
testGesture('GestureArenaTeam rejection test', (GestureTester tester) {
GestureArenaTeam team = new GestureArenaTeam();
HorizontalDragGestureRecognizer horizontalDrag = new HorizontalDragGestureRecognizer()..team = team;
VerticalDragGestureRecognizer verticalDrag = new VerticalDragGestureRecognizer()..team = team;
TapGestureRecognizer tap = new TapGestureRecognizer();
final GestureArenaTeam team = new GestureArenaTeam();
final HorizontalDragGestureRecognizer horizontalDrag = new HorizontalDragGestureRecognizer()..team = team;
final VerticalDragGestureRecognizer verticalDrag = new VerticalDragGestureRecognizer()..team = team;
final TapGestureRecognizer tap = new TapGestureRecognizer();
expect(horizontalDrag.team, equals(team));
expect(verticalDrag.team, equals(team));
expect(tap.team, isNull);
List<String> log = <String>[];
final List<String> log = <String>[];
horizontalDrag.onStart = (DragStartDetails details) { log.add('hoizontal-drag-start'); };
verticalDrag.onStart = (DragStartDetails details) { log.add('vertical-drag-start'); };
tap.onTap = () { log.add('tap'); };
void test(Offset delta) {
Point origin = const Point(10.0, 10.0);
TestPointer pointer = new TestPointer(5);
PointerDownEvent down = pointer.down(origin);
final Point origin = const Point(10.0, 10.0);
final TestPointer pointer = new TestPointer(5);
final PointerDownEvent down = pointer.down(origin);
horizontalDrag.addPointer(down);
verticalDrag.addPointer(down);
tap.addPointer(down);
......
......@@ -8,7 +8,7 @@ import 'velocity_tracker_data.dart';
bool _withinTolerance(double actual, double expected) {
const double kTolerance = 0.001; // Within .1% of expected value
double diff = (actual - expected)/expected;
final double diff = (actual - expected)/expected;
return diff.abs() < kTolerance;
}
......@@ -19,7 +19,7 @@ bool _checkVelocity(Velocity actual, Offset expected) {
}
void main() {
List<Offset> expected = const <Offset>[
final List<Offset> expected = const <Offset>[
const Offset(219.5762939453125, 1304.6705322265625),
const Offset(355.6900939941406, 967.1700439453125),
const Offset(12.651158332824707, -36.9227180480957),
......@@ -36,7 +36,7 @@ void main() {
];
test('Velocity tracker gives expected results', () {
VelocityTracker tracker = new VelocityTracker();
final VelocityTracker tracker = new VelocityTracker();
int i = 0;
for (PointerEvent event in velocityEventData) {
if (event is PointerDownEvent || event is PointerMoveEvent)
......@@ -49,8 +49,8 @@ void main() {
});
test('Velocity control test', () {
Velocity velocity1 = const Velocity(pixelsPerSecond: const Offset(7.0, 0.0));
Velocity velocity2 = const Velocity(pixelsPerSecond: const Offset(12.0, 0.0));
final Velocity velocity1 = const Velocity(pixelsPerSecond: const Offset(7.0, 0.0));
final Velocity velocity2 = const Velocity(pixelsPerSecond: const Offset(12.0, 0.0));
expect(velocity1, equals(const Velocity(pixelsPerSecond: const Offset(7.0, 0.0))));
expect(velocity1, isNot(equals(velocity2)));
expect(velocity2 - velocity1, equals(const Velocity(pixelsPerSecond: const Offset(5.0, 0.0))));
......@@ -62,7 +62,7 @@ void main() {
test('Interrupted velocity estimation', () {
// Regression test for https://github.com/flutter/flutter/pull/7510
VelocityTracker tracker = new VelocityTracker();
final VelocityTracker tracker = new VelocityTracker();
for (PointerEvent event in interruptedVelocityEventData) {
if (event is PointerDownEvent || event is PointerMoveEvent)
tracker.addPosition(event.timeStamp, event.position);
......
......@@ -73,7 +73,7 @@ void main() {
});
testWidgets('AboutDrawerItem control test', (WidgetTester tester) async {
List<String> log = <String>[];
final List<String> log = <String>[];
Future<Null> licenseFuture;
LicenseRegistry.addLicense(() {
......
......@@ -66,7 +66,7 @@ void main() {
),
);
Finder title = find.text('X');
final Finder title = find.text('X');
Point center = tester.getCenter(title);
Size size = tester.getSize(title);
expect(center.x, lessThan(400 - size.width / 2.0));
......@@ -105,9 +105,9 @@ void main() {
);
Finder title = find.text('X');
Point center = tester.getCenter(title);
Size size = tester.getSize(title);
final Finder title = find.text('X');
final Point center = tester.getCenter(title);
final Size size = tester.getSize(title);
expect(center.x, greaterThan(400 - size.width / 2.0));
expect(center.x, lessThan(400 + size.width / 2.0));
});
......@@ -150,7 +150,7 @@ void main() {
// The app bar's title should be constrained to fit within the available space
// between the leading and actions widgets.
Key titleKey = new UniqueKey();
final Key titleKey = new UniqueKey();
Widget leading = new Container();
List<Widget> actions;
......@@ -172,7 +172,7 @@ void main() {
await tester.pumpWidget(buildApp());
Finder title = find.byKey(titleKey);
final Finder title = find.byKey(titleKey);
expect(tester.getTopLeft(title).x, 72.0);
// The toolbar's contents are padded on the right by 4.0
expect(tester.getSize(title).width, equals(800.0 - 72.0 - 4.0));
......@@ -199,7 +199,7 @@ void main() {
// between the leading and actions widgets. When it's also centered it may
// also be left or right justified if it doesn't fit in the overall center.
Key titleKey = new UniqueKey();
final Key titleKey = new UniqueKey();
double titleWidth = 700.0;
Widget leading = new Container();
List<Widget> actions;
......@@ -225,7 +225,7 @@ void main() {
// that the left edge of the title must be atleast 72.
await tester.pumpWidget(buildApp());
Finder title = find.byKey(titleKey);
final Finder title = find.byKey(titleKey);
expect(tester.getTopLeft(title).x, 72.0);
expect(tester.getSize(title).width, equals(700.0));
......@@ -261,16 +261,16 @@ void main() {
),
);
Finder title = find.text('X');
final Finder title = find.text('X');
expect(tester.getSize(title).isEmpty, isTrue);
});
testWidgets('AppBar actions are vertically centered', (WidgetTester tester) async {
UniqueKey appBarKey = new UniqueKey();
UniqueKey leadingKey = new UniqueKey();
UniqueKey titleKey = new UniqueKey();
UniqueKey action0Key = new UniqueKey();
UniqueKey action1Key = new UniqueKey();
final UniqueKey appBarKey = new UniqueKey();
final UniqueKey leadingKey = new UniqueKey();
final UniqueKey titleKey = new UniqueKey();
final UniqueKey action0Key = new UniqueKey();
final UniqueKey action1Key = new UniqueKey();
await tester.pumpWidget(
new MaterialApp(
......@@ -310,7 +310,7 @@ void main() {
),
);
Finder hamburger = find.byTooltip('Open navigation menu');
final Finder hamburger = find.byTooltip('Open navigation menu');
expect(tester.getTopLeft(hamburger), new Point(0.0, 0.0));
expect(tester.getSize(hamburger), new Size(56.0, 56.0));
});
......@@ -341,13 +341,13 @@ void main() {
),
);
Finder addButton = find.byTooltip('Add');
final Finder addButton = find.byTooltip('Add');
// Right padding is 4dp.
expect(tester.getTopRight(addButton), new Point(800.0 - 4.0, 0.0));
// It's still the size it was plus the 2 * 8dp padding from IconButton.
expect(tester.getSize(addButton), new Size(60.0 + 2 * 8.0, 56.0));
Finder shareButton = find.byTooltip('Share');
final Finder shareButton = find.byTooltip('Share');
// The 20dp icon is expanded to fill the IconButton's touch target to 48dp.
expect(tester.getSize(shareButton), new Size(48.0, 56.0));
});
......@@ -359,7 +359,7 @@ void main() {
expandedHeight: null,
));
ScrollController controller = primaryScrollController(tester);
final ScrollController controller = primaryScrollController(tester);
expect(controller.offset, 0.0);
expect(appBarIsVisible(tester), true);
......@@ -396,7 +396,7 @@ void main() {
expandedHeight: 128.0,
));
ScrollController controller = primaryScrollController(tester);
final ScrollController controller = primaryScrollController(tester);
expect(controller.offset, 0.0);
expect(appBarIsVisible(tester), true);
expect(appBarHeight(tester), 128.0);
......@@ -429,7 +429,7 @@ void main() {
expandedHeight: 128.0,
));
ScrollController controller = primaryScrollController(tester);
final ScrollController controller = primaryScrollController(tester);
expect(controller.offset, 0.0);
expect(appBarIsVisible(tester), true);
expect(appBarHeight(tester), 128.0);
......
......@@ -39,7 +39,7 @@ void main() {
});
testWidgets('Focus handling', (WidgetTester tester) async {
GlobalKey inputKey = new GlobalKey();
final GlobalKey inputKey = new GlobalKey();
await tester.pumpWidget(new MaterialApp(
home: new Material(
child: new Center(
......@@ -58,7 +58,7 @@ void main() {
)
);
StateMarkerState state1 = tester.state(find.byType(StateMarker));
final StateMarkerState state1 = tester.state(find.byType(StateMarker));
state1.marker = 'original';
await tester.pumpWidget(
......@@ -68,7 +68,7 @@ void main() {
)
);
StateMarkerState state2 = tester.state(find.byType(StateMarker));
final StateMarkerState state2 = tester.state(find.byType(StateMarker));
expect(state1, equals(state2));
expect(state2.marker, equals('original'));
});
......@@ -122,8 +122,8 @@ void main() {
expect(find.text('Home'), findsOneWidget);
NavigatorState navigator = tester.state(find.byType(Navigator));
bool result = await navigator.maybePop();
final NavigatorState navigator = tester.state(find.byType(Navigator));
final bool result = await navigator.maybePop();
expect(result, isFalse);
......
......@@ -7,12 +7,12 @@ import 'package:flutter/material.dart';
void main() {
test('MaterialPointArcTween control test', () {
MaterialPointArcTween a = new MaterialPointArcTween(
final MaterialPointArcTween a = new MaterialPointArcTween(
begin: Point.origin,
end: const Point(0.0, 10.0)
);
MaterialPointArcTween b = new MaterialPointArcTween(
final MaterialPointArcTween b = new MaterialPointArcTween(
begin: Point.origin,
end: const Point(0.0, 10.0)
);
......@@ -23,12 +23,12 @@ void main() {
});
test('MaterialRectArcTween control test', () {
MaterialRectArcTween a = new MaterialRectArcTween(
final MaterialRectArcTween a = new MaterialRectArcTween(
begin: new Rect.fromLTWH(0.0, 0.0, 10.0, 10.0),
end: new Rect.fromLTWH(0.0, 10.0, 10.0, 10.0)
);
MaterialRectArcTween b = new MaterialRectArcTween(
final MaterialRectArcTween b = new MaterialRectArcTween(
begin: new Rect.fromLTWH(0.0, 0.0, 10.0, 10.0),
end: new Rect.fromLTWH(0.0, 10.0, 10.0, 10.0)
);
......
......@@ -52,7 +52,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(BottomNavigationBar));
final RenderBox box = tester.renderObject(find.byType(BottomNavigationBar));
expect(box.size.height, 60.0);
expect(find.text('AC'), findsOneWidget);
expect(find.text('Alarm'), findsOneWidget);
......@@ -141,7 +141,7 @@ void main() {
// they grow.
Iterable<RenderBox> actions = tester.renderObjectList(find.byType(InkResponse));
Point originalOrigin = actions.elementAt(3).localToGlobal(Point.origin);
final Point originalOrigin = actions.elementAt(3).localToGlobal(Point.origin);
await tester.tap(find.text('AC'));
await tester.pump();
......@@ -269,7 +269,7 @@ void main() {
),
);
RenderBox box = tester.renderObject(find.byType(Icon));
final RenderBox box = tester.renderObject(find.byType(Icon));
expect(box.size.width, equals(12.0));
expect(box.size.height, equals(12.0));
expect(builderIconSize, 12.0);
......
......@@ -17,7 +17,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(CircleAvatar));
final RenderBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size.width, equals(100.0));
expect(box.size.height, equals(100.0));
......
......@@ -9,7 +9,7 @@ import 'data_table_test_utils.dart';
void main() {
testWidgets('DataTable control test', (WidgetTester tester) async {
List<String> log = <String>[];
final List<String> log = <String>[];
Widget buildTable({ int sortColumnIndex, bool sortAscending: true }) {
return new DataTable(
......
......@@ -20,7 +20,7 @@ void main() {
});
testWidgets('tap-select a day', (WidgetTester tester) async {
Key _datePickerKey = new UniqueKey();
final Key _datePickerKey = new UniqueKey();
DateTime _selectedDate = new DateTime(2016, DateTime.JULY, 26);
await tester.pumpWidget(
......@@ -136,7 +136,7 @@ void main() {
await tester.tap(find.text('Go'));
expect(buttonContext, isNotNull);
Future<DateTime> date = showDatePicker(
final Future<DateTime> date = showDatePicker(
context: buttonContext,
initialDate: initialDate,
firstDate: firstDate,
......@@ -196,7 +196,7 @@ void main() {
await tester.pump();
await tester.tap(find.text('2005'));
await tester.pump();
String dayLabel = new DateFormat('E, MMM\u00a0d').format(new DateTime(2005, DateTime.JANUARY, 15));
final String dayLabel = new DateFormat('E, MMM\u00a0d').format(new DateTime(2005, DateTime.JANUARY, 15));
await tester.tap(find.text(dayLabel));
await tester.pump();
await tester.tap(find.text('19'));
......
......@@ -89,8 +89,8 @@ void main() {
await tester.pump(); // start animation
await tester.pump(const Duration(seconds: 1));
StatefulElement widget = tester.element(find.byType(Material).last);
Material materialconfig = widget.state.config;
final StatefulElement widget = tester.element(find.byType(Material).last);
final Material materialconfig = widget.state.config;
//first and second expect check that the material is the dialog's one
expect(materialconfig.type, MaterialType.card);
expect(materialconfig.elevation, 24);
......@@ -111,9 +111,9 @@ void main() {
),
);
BuildContext context = tester.element(find.text('Go'));
final BuildContext context = tester.element(find.text('Go'));
Future<int> result = showDialog(
final Future<int> result = showDialog(
context: context,
child: new SimpleDialog(
title: new Text('Title'),
......@@ -152,7 +152,7 @@ void main() {
),
);
BuildContext context = tester.element(find.text('Go'));
final BuildContext context = tester.element(find.text('Go'));
showDialog<Null>(
context: context,
......
......@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Divider control test', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new Divider()));
RenderBox box = tester.firstRenderObject(find.byType(Divider));
final RenderBox box = tester.firstRenderObject(find.byType(Divider));
expect(box.size.height, 15.0);
});
}
......@@ -31,7 +31,7 @@ void main() {
);
expect(find.text('Archive'), findsNothing);
ScaffoldState state = tester.firstState(find.byType(Scaffold));
final ScaffoldState state = tester.firstState(find.byType(Scaffold));
state.openDrawer();
await tester.pump();
......
......@@ -153,7 +153,7 @@ void main() {
testWidgets('Dropdown screen edges', (WidgetTester tester) async {
int value = 4;
List<DropdownMenuItem<int>> items = <DropdownMenuItem<int>>[];
final List<DropdownMenuItem<int>> items = <DropdownMenuItem<int>>[];
for (int i = 0; i < 20; ++i)
items.add(new DropdownMenuItem<int>(value: i, child: new Text('$i')));
......@@ -161,7 +161,7 @@ void main() {
value = newValue;
}
DropdownButton<int> button = new DropdownButton<int>(
final DropdownButton<int> button = new DropdownButton<int>(
value: value,
onChanged: handleChanged,
items: items,
......@@ -204,15 +204,15 @@ void main() {
});
testWidgets('Dropdown button aligns selected menu item', (WidgetTester tester) async {
Key buttonKey = new UniqueKey();
String value = 'two';
final Key buttonKey = new UniqueKey();
final String value = 'two';
Widget build() => buildFrame(buttonKey: buttonKey, value: value);
await tester.pumpWidget(build());
RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
final RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
assert(buttonBox.attached);
Point buttonOriginBeforeTap = buttonBox.localToGlobal(Point.origin);
final Point buttonOriginBeforeTap = buttonBox.localToGlobal(Point.origin);
await tester.tap(find.text('two'));
await tester.pump();
......@@ -224,7 +224,7 @@ void main() {
// The selected dropdown item is both in menu we just popped up, and in
// the IndexedStack contained by the dropdown button. Both of them should
// have the same origin and height as the dropdown button.
List<RenderObject> itemBoxes = tester.renderObjectList(find.byKey(const ValueKey<String>('two'))).toList();
final List<RenderObject> itemBoxes = tester.renderObjectList(find.byKey(const ValueKey<String>('two'))).toList();
expect(itemBoxes.length, equals(2));
for(RenderBox itemBox in itemBoxes) {
assert(itemBox.attached);
......@@ -238,13 +238,13 @@ void main() {
});
testWidgets('Dropdown button with isDense:true aligns selected menu item', (WidgetTester tester) async {
Key buttonKey = new UniqueKey();
String value = 'two';
final Key buttonKey = new UniqueKey();
final String value = 'two';
Widget build() => buildFrame(buttonKey: buttonKey, value: value, isDense: true);
await tester.pumpWidget(build());
RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
final RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
assert(buttonBox.attached);
await tester.tap(find.text('two'));
......@@ -254,18 +254,18 @@ void main() {
// The selected dropdown item is both in menu we just popped up, and in
// the IndexedStack contained by the dropdown button. Both of them should
// have the same vertical center as the button.
List<RenderBox> itemBoxes = tester.renderObjectList(find.byKey(const ValueKey<String>('two'))).toList();
final List<RenderBox> itemBoxes = tester.renderObjectList(find.byKey(const ValueKey<String>('two'))).toList();
expect(itemBoxes.length, equals(2));
// When isDense is true, the button's height is reduced. The menu items'
// heights are not.
double menuItemHeight = itemBoxes.map((RenderBox box) => box.size.height).reduce(math.max);
final double menuItemHeight = itemBoxes.map((RenderBox box) => box.size.height).reduce(math.max);
expect(menuItemHeight, greaterThan(buttonBox.size.height));
for(RenderBox itemBox in itemBoxes) {
assert(itemBox.attached);
Point buttonBoxCenter = buttonBox.size.center(buttonBox.localToGlobal(Point.origin));
Point itemBoxCenter = itemBox.size.center(itemBox.localToGlobal(Point.origin));
final Point buttonBoxCenter = buttonBox.size.center(buttonBox.localToGlobal(Point.origin));
final Point itemBoxCenter = itemBox.size.center(itemBox.localToGlobal(Point.origin));
expect(buttonBoxCenter.y, equals(itemBoxCenter.y));
}
......@@ -275,19 +275,19 @@ void main() {
});
testWidgets('Size of DropdownButton with null value', (WidgetTester tester) async {
Key buttonKey = new UniqueKey();
final Key buttonKey = new UniqueKey();
String value;
Widget build() => buildFrame(buttonKey: buttonKey, value: value);
await tester.pumpWidget(build());
RenderBox buttonBoxNullValue = tester.renderObject(find.byKey(buttonKey));
final RenderBox buttonBoxNullValue = tester.renderObject(find.byKey(buttonKey));
assert(buttonBoxNullValue.attached);
value = 'three';
await tester.pumpWidget(build());
RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
final RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
assert(buttonBox.attached);
// A Dropdown button with a null value should be the same size as a
......@@ -297,7 +297,7 @@ void main() {
});
testWidgets('Layout of a DropdownButton with null value', (WidgetTester tester) async {
Key buttonKey = new UniqueKey();
final Key buttonKey = new UniqueKey();
String value;
void onChanged(String newValue) {
......@@ -307,7 +307,7 @@ void main() {
Widget build() => buildFrame(buttonKey: buttonKey, value: value, onChanged: onChanged);
await tester.pumpWidget(build());
RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
final RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
assert(buttonBox.attached);
// Show the menu.
......@@ -325,7 +325,7 @@ void main() {
});
testWidgets('Size of DropdownButton with null value and a hint', (WidgetTester tester) async {
Key buttonKey = new UniqueKey();
final Key buttonKey = new UniqueKey();
String value;
// The hint will define the dropdown's width
......@@ -333,13 +333,13 @@ void main() {
await tester.pumpWidget(build());
expect(find.text('onetwothree'), findsOneWidget);
RenderBox buttonBoxHintValue = tester.renderObject(find.byKey(buttonKey));
final RenderBox buttonBoxHintValue = tester.renderObject(find.byKey(buttonKey));
assert(buttonBoxHintValue.attached);
value = 'three';
await tester.pumpWidget(build());
RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
final RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
assert(buttonBox.attached);
// A Dropdown button with a null value and a hint should be the same size as a
......
......@@ -40,7 +40,7 @@ void main() {
)
);
IconTheme iconTheme = tester.firstWidget(find.byType(IconTheme));
final IconTheme iconTheme = tester.firstWidget(find.byType(IconTheme));
expect(iconTheme.data.color, equals(Colors.black26));
});
......
......@@ -32,7 +32,7 @@ void main() {
expect(find.text('A'), findsOneWidget);
expect(find.text('B'), findsNothing);
RenderBox box = tester.renderObject(find.byType(ExpansionPanelList));
double oldHeight = box.size.height;
final double oldHeight = box.size.height;
expect(find.byType(ExpandIcon), findsOneWidget);
await tester.tap(find.byType(ExpandIcon));
expect(index, 0);
......
......@@ -20,7 +20,7 @@ void main() {
)
);
Finder title = find.text('X');
final Finder title = find.text('X');
Point center = tester.getCenter(title);
Size size = tester.getSize(title);
expect(center.x, lessThan(400 - size.width / 2.0));
......
......@@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
void main() {
testWidgets('GridTile control test', (WidgetTester tester) async {
Key headerKey = new UniqueKey();
Key footerKey = new UniqueKey();
final Key headerKey = new UniqueKey();
final Key footerKey = new UniqueKey();
await tester.pumpWidget(new GridTile(
header: new GridTileBar(
......
......@@ -32,7 +32,7 @@ void main() {
),
);
RenderBox iconButton = tester.renderObject(find.byType(IconButton));
final RenderBox iconButton = tester.renderObject(find.byType(IconButton));
expect(iconButton.size, new Size(48.0, 48.0));
await tester.tap(find.byType(IconButton));
......@@ -52,7 +52,7 @@ void main() {
),
);
RenderBox iconButton = tester.renderObject(find.byType(IconButton));
final RenderBox iconButton = tester.renderObject(find.byType(IconButton));
expect(iconButton.size, new Size(48.0, 48.0));
});
......@@ -70,7 +70,7 @@ void main() {
),
);
RenderBox iconButton = tester.renderObject(find.byType(IconButton));
final RenderBox iconButton = tester.renderObject(find.byType(IconButton));
expect(iconButton.size, new Size(70.0, 70.0));
});
......@@ -88,7 +88,7 @@ void main() {
),
);
RenderBox box = tester.renderObject(find.byType(IconButton));
final RenderBox box = tester.renderObject(find.byType(IconButton));
expect(box.size, new Size(80.0, 80.0));
});
......@@ -109,7 +109,7 @@ void main() {
),
);
RenderBox box = tester.renderObject(find.byType(IconButton));
final RenderBox box = tester.renderObject(find.byType(IconButton));
expect(box.size, new Size(48.0, 600.0));
});
......@@ -126,7 +126,7 @@ void main() {
),
);
RenderBox box = tester.renderObject(find.byType(IconButton));
final RenderBox box = tester.renderObject(find.byType(IconButton));
expect(box.size, new Size(96.0, 96.0));
});
......@@ -185,8 +185,8 @@ void main() {
),
);
RenderBox barBox = tester.renderObject(find.byType(AppBar));
RenderBox iconBox = tester.renderObject(find.byType(IconButton));
final RenderBox barBox = tester.renderObject(find.byType(AppBar));
final RenderBox iconBox = tester.renderObject(find.byType(IconButton));
expect(iconBox.size.height, equals(barBox.size.height));
});
}
......@@ -15,7 +15,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(Icon));
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
expect(renderObject.size, equals(const Size.square(24.0)));
});
......@@ -29,7 +29,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(Icon));
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
expect(renderObject.size, equals(const Size.square(96.0)));
});
......@@ -43,7 +43,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(Icon));
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
expect(renderObject.size, equals(const Size.square(36.0)));
});
......@@ -60,7 +60,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(Icon));
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
expect(renderObject.size, equals(const Size.square(48.0)));
});
......@@ -74,7 +74,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(Icon));
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
expect(renderObject.size, equals(const Size.square(24.0)));
});
}
......@@ -7,13 +7,13 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('IconThemeData control test', () {
IconThemeData data = new IconThemeData(color: Colors.green[500], opacity: 0.5, size: 16.0);
final IconThemeData data = new IconThemeData(color: Colors.green[500], opacity: 0.5, size: 16.0);
expect(data, hasOneLineDescription);
expect(data, equals(data.copyWith()));
expect(data.hashCode, equals(data.copyWith().hashCode));
IconThemeData lerped = IconThemeData.lerp(data, const IconThemeData.fallback(), 0.25);
final IconThemeData lerped = IconThemeData.lerp(data, const IconThemeData.fallback(), 0.25);
expect(lerped.color, equals(Color.lerp(Colors.green[500], Colors.black, 0.25)));
expect(lerped.opacity, equals(0.625));
expect(lerped.size, equals(18.0));
......
......@@ -20,7 +20,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
final RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
expect(renderObject.size, equals(const Size.square(24.0)));
expect(find.byType(Image), findsOneWidget);
});
......@@ -35,7 +35,7 @@ void main() {
),
);
Image image = tester.widget(find.byType(Image));
final Image image = tester.widget(find.byType(Image));
expect(image, isNotNull);
expect(image.color.alpha, equals(128));
});
......@@ -50,7 +50,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
final RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
expect(renderObject.size, equals(const Size.square(96.0)));
});
......@@ -64,7 +64,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
final RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
expect(renderObject.size, equals(const Size.square(36.0)));
});
......@@ -81,7 +81,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
final RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
expect(renderObject.size, equals(const Size.square(48.0)));
});
......@@ -95,7 +95,7 @@ void main() {
)
);
RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
final RenderBox renderObject = tester.renderObject(find.byType(ImageIcon));
expect(renderObject.size, equals(const Size.square(24.0)));
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('InkWell gestures control test', (WidgetTester tester) async {
List<String> log = <String>[];
final List<String> log = <String>[];
await tester.pumpWidget(new Material(
child: new Center(
......
......@@ -26,7 +26,7 @@ void main() {
});
testWidgets('ListItem control test', (WidgetTester tester) async {
List<String> titles = <String>[ 'first', 'second', 'third' ];
final List<String> titles = <String>[ 'first', 'second', 'third' ];
await tester.pumpWidget(new MaterialApp(
home: new Material(
......
......@@ -39,7 +39,7 @@ void main() {
});
testWidgets('ListView scroll does not repaint', (WidgetTester tester) async {
List<Size> log = <Size>[];
final List<Size> log = <Size>[];
await tester.pumpWidget(
new Column(
......
......@@ -52,11 +52,11 @@ void matches(BorderRadius borderRadius, RadiusType top, RadiusType bottom) {
}
BorderRadius getBorderRadius(WidgetTester tester, int index) {
List<Element> containers = tester.elementList(find.byType(Container))
final List<Element> containers = tester.elementList(find.byType(Container))
.toList();
Container container = containers[index + 2].widget;
BoxDecoration boxDecoration = container.decoration;
final Container container = containers[index + 2].widget;
final BoxDecoration boxDecoration = container.decoration;
return boxDecoration.borderRadius;
}
......@@ -71,7 +71,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(0));
});
......@@ -242,7 +242,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(216));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -312,7 +312,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(200));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -384,7 +384,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(200));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -533,7 +533,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(200));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -608,7 +608,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(300));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -670,7 +670,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(200));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -767,7 +767,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(332));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -841,7 +841,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(216));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......@@ -939,7 +939,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
final RenderBox box = tester.renderObject(find.byType(MergeableMaterial));
expect(box.size.height, equals(332));
matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round);
......
......@@ -67,7 +67,7 @@ void main() {
});
testWidgets('Verify that a downwards fling dismisses a persistent BottomSheet', (WidgetTester tester) async {
GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
bool showBottomSheetThenCalled = false;
await tester.pumpWidget(new MaterialApp(
......@@ -121,7 +121,7 @@ void main() {
testWidgets('Verify that dragging past the bottom dismisses a persistent BottomSheet', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/5528
GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
await tester.pumpWidget(new MaterialApp(
home: new Scaffold(
......
......@@ -43,9 +43,9 @@ class TestDataSource extends DataTableSource {
void main() {
testWidgets('PaginatedDataTable paging', (WidgetTester tester) async {
TestDataSource source = new TestDataSource();
final TestDataSource source = new TestDataSource();
List<String> log = <String>[];
final List<String> log = <String>[];
await tester.pumpWidget(new MaterialApp(
home: new PaginatedDataTable(
......@@ -109,7 +109,7 @@ void main() {
TestDataSource source = new TestDataSource()
..generation = 42;
List<String> log = <String>[];
final List<String> log = <String>[];
Widget buildTable(TestDataSource source) {
return new PaginatedDataTable(
......@@ -172,7 +172,7 @@ void main() {
expect(find.text('43'), findsNothing);
expect(find.text('15'), findsNWidgets(10));
PaginatedDataTableState state = tester.state(find.byType(PaginatedDataTable));
final PaginatedDataTableState state = tester.state(find.byType(PaginatedDataTable));
expect(log, isEmpty);
state.pageTo(23);
......
......@@ -51,9 +51,9 @@ void main() {
testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async {
await tester.pumpWidget(new ListView(children: <Widget>[new LinearProgressIndicator(value: 0.0)]));
List<Layer> layers1 = tester.layers;
final List<Layer> layers1 = tester.layers;
await tester.pumpWidget(new ListView(children: <Widget>[new LinearProgressIndicator(value: 0.5)]));
List<Layer> layers2 = tester.layers;
final List<Layer> layers2 = tester.layers;
expect(layers1, isNot(equals(layers2)));
});
}
......@@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
void main() {
testWidgets('Radio control test', (WidgetTester tester) async {
Key key = new UniqueKey();
List<int> log = <int>[];
final Key key = new UniqueKey();
final List<int> log = <int>[];
await tester.pumpWidget(new Material(
child: new Center(
......
......@@ -8,7 +8,7 @@ import 'package:flutter/rendering.dart';
void main() {
testWidgets('Scaffold control test', (WidgetTester tester) async {
Key bodyKey = new UniqueKey();
final Key bodyKey = new UniqueKey();
await tester.pumpWidget(new Scaffold(
appBar: new AppBar(title: new Text('Title')),
body: new Container(key: bodyKey)
......@@ -42,7 +42,7 @@ void main() {
});
testWidgets('Scaffold large bottom padding test', (WidgetTester tester) async {
Key bodyKey = new UniqueKey();
final Key bodyKey = new UniqueKey();
await tester.pumpWidget(new MediaQuery(
data: new MediaQueryData(
padding: const EdgeInsets.only(bottom: 700.0),
......@@ -52,7 +52,7 @@ void main() {
),
));
RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
final RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
expect(bodyBox.size, equals(const Size(800.0, 0.0)));
await tester.pumpWidget(new MediaQuery(
......@@ -118,10 +118,10 @@ void main() {
});
testWidgets('Drawer scrolling', (WidgetTester tester) async {
Key drawerKey = new UniqueKey();
final Key drawerKey = new UniqueKey();
const double appBarHeight = 256.0;
ScrollController scrollOffset = new ScrollController();
final ScrollController scrollOffset = new ScrollController();
await tester.pumpWidget(
new MaterialApp(
......@@ -157,7 +157,7 @@ void main() {
)
);
ScaffoldState state = tester.firstState(find.byType(Scaffold));
final ScaffoldState state = tester.firstState(find.byType(Scaffold));
state.openDrawer();
await tester.pump();
......@@ -171,7 +171,7 @@ void main() {
expect(scrollOffset.offset, scrollDelta);
RenderBox renderBox = tester.renderObject(find.byType(AppBar));
final RenderBox renderBox = tester.renderObject(find.byType(AppBar));
expect(renderBox.size.height, equals(appBarHeight));
});
......@@ -222,7 +222,7 @@ void main() {
});
testWidgets('Bottom sheet cannot overlap app bar', (WidgetTester tester) async {
Key sheetKey = new UniqueKey();
final Key sheetKey = new UniqueKey();
await tester.pumpWidget(
new MaterialApp(
......@@ -254,11 +254,11 @@ void main() {
await tester.pump(); // start animation
await tester.pump(const Duration(seconds: 1));
RenderBox appBarBox = tester.renderObject(find.byType(AppBar));
RenderBox sheetBox = tester.renderObject(find.byKey(sheetKey));
final RenderBox appBarBox = tester.renderObject(find.byType(AppBar));
final RenderBox sheetBox = tester.renderObject(find.byKey(sheetKey));
Point appBarBottomRight = appBarBox.localToGlobal(appBarBox.size.bottomRight(Point.origin));
Point sheetTopRight = sheetBox.localToGlobal(sheetBox.size.topRight(Point.origin));
final Point appBarBottomRight = appBarBox.localToGlobal(appBarBox.size.bottomRight(Point.origin));
final Point sheetTopRight = sheetBox.localToGlobal(sheetBox.size.topRight(Point.origin));
expect(appBarBottomRight, equals(sheetTopRight));
});
......@@ -297,7 +297,7 @@ void main() {
group('back arrow', () {
Future<Null> expectBackIcon(WidgetTester tester, TargetPlatform platform, IconData expectedIcon) async {
GlobalKey rootKey = new GlobalKey();
final GlobalKey rootKey = new GlobalKey();
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (_) => new Container(key: rootKey, child: new Text('Home')),
'/scaffold': (_) => new Scaffold(
......@@ -313,7 +313,7 @@ void main() {
await tester.pump();
await tester.pump(const Duration(seconds: 1));
Icon icon = tester.widget(find.byType(Icon));
final Icon icon = tester.widget(find.byType(Icon));
expect(icon.icon, expectedIcon);
}
......@@ -332,7 +332,7 @@ void main() {
group('body size', () {
testWidgets('body size with container', (WidgetTester tester) async {
Key testKey = new UniqueKey();
final Key testKey = new UniqueKey();
await tester.pumpWidget(
new Scaffold(body: new Container(key: testKey))
);
......@@ -341,7 +341,7 @@ void main() {
});
testWidgets('body size with sized container', (WidgetTester tester) async {
Key testKey = new UniqueKey();
final Key testKey = new UniqueKey();
await tester.pumpWidget(
new Scaffold(body: new Container(key: testKey, height: 100.0))
);
......@@ -350,7 +350,7 @@ void main() {
});
testWidgets('body size with centered container', (WidgetTester tester) async {
Key testKey = new UniqueKey();
final Key testKey = new UniqueKey();
await tester.pumpWidget(
new Scaffold(body: new Center(child: new Container(key: testKey)))
);
......@@ -359,7 +359,7 @@ void main() {
});
testWidgets('body size with button', (WidgetTester tester) async {
Key testKey = new UniqueKey();
final Key testKey = new UniqueKey();
await tester.pumpWidget(
new Scaffold(body: new FlatButton(key: testKey, onPressed: () { }, child: new Text('')))
);
......
......@@ -10,7 +10,7 @@ import '../rendering/mock_canvas.dart';
void main() {
testWidgets('Slider can move when tapped', (WidgetTester tester) async {
Key sliderKey = new UniqueKey();
final Key sliderKey = new UniqueKey();
double value = 0.0;
await tester.pumpWidget(
......@@ -41,7 +41,7 @@ void main() {
});
testWidgets('Slider take on discrete values', (WidgetTester tester) async {
Key sliderKey = new UniqueKey();
final Key sliderKey = new UniqueKey();
double value = 0.0;
await tester.pumpWidget(
......@@ -147,8 +147,8 @@ void main() {
),
));
Point center = tester.getCenter(find.byType(Slider));
TestGesture gesture = await tester.startGesture(center);
final Point center = tester.getCenter(find.byType(Slider));
final TestGesture gesture = await tester.startGesture(center);
expect(value, equals(0.5));
......
......@@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
void main() {
testWidgets('SnackBar control test', (WidgetTester tester) async {
String helloSnackBar = 'Hello SnackBar';
Key tapTarget = const Key('tap-target');
final String helloSnackBar = 'Hello SnackBar';
final Key tapTarget = const Key('tap-target');
await tester.pumpWidget(new MaterialApp(
home: new Scaffold(
body: new Builder(
......@@ -53,7 +53,7 @@ void main() {
testWidgets('SnackBar twice test', (WidgetTester tester) async {
int snackBarCount = 0;
Key tapTarget = const Key('tap-target');
final Key tapTarget = const Key('tap-target');
await tester.pumpWidget(new MaterialApp(
home: new Scaffold(
body: new Builder(
......@@ -128,7 +128,7 @@ void main() {
testWidgets('SnackBar cancel test', (WidgetTester tester) async {
int snackBarCount = 0;
Key tapTarget = const Key('tap-target');
final Key tapTarget = const Key('tap-target');
int time;
ScaffoldFeatureController<SnackBar, SnackBarClosedReason> lastController;
await tester.pumpWidget(new MaterialApp(
......@@ -158,7 +158,7 @@ void main() {
expect(find.text('bar2'), findsNothing);
time = 1000;
await tester.tap(find.byKey(tapTarget)); // queue bar1
ScaffoldFeatureController<SnackBar, SnackBarClosedReason> firstController = lastController;
final ScaffoldFeatureController<SnackBar, SnackBarClosedReason> firstController = lastController;
time = 2;
await tester.tap(find.byKey(tapTarget)); // queue bar2
expect(find.text('bar1'), findsNothing);
......@@ -214,7 +214,7 @@ void main() {
testWidgets('SnackBar dismiss test', (WidgetTester tester) async {
int snackBarCount = 0;
Key tapTarget = const Key('tap-target');
final Key tapTarget = const Key('tap-target');
await tester.pumpWidget(new MaterialApp(
home: new Scaffold(
body: new Builder(
......@@ -319,16 +319,16 @@ void main() {
await tester.pump(); // start animation
await tester.pump(const Duration(milliseconds: 750));
RenderBox textBox = tester.firstRenderObject(find.text('I am a snack bar.'));
RenderBox actionTextBox = tester.firstRenderObject(find.text('ACTION'));
RenderBox snackBarBox = tester.firstRenderObject(find.byType(SnackBar));
final RenderBox textBox = tester.firstRenderObject(find.text('I am a snack bar.'));
final RenderBox actionTextBox = tester.firstRenderObject(find.text('ACTION'));
final RenderBox snackBarBox = tester.firstRenderObject(find.byType(SnackBar));
Point textBottomLeft = textBox.localToGlobal(textBox.size.bottomLeft(Point.origin));
Point textBottomRight = textBox.localToGlobal(textBox.size.bottomRight(Point.origin));
Point actionTextBottomLeft = actionTextBox.localToGlobal(actionTextBox.size.bottomLeft(Point.origin));
Point actionTextBottomRight = actionTextBox.localToGlobal(actionTextBox.size.bottomRight(Point.origin));
Point snackBarBottomLeft = snackBarBox.localToGlobal(snackBarBox.size.bottomLeft(Point.origin));
Point snackBarBottomRight = snackBarBox.localToGlobal(snackBarBox.size.bottomRight(Point.origin));
final Point textBottomLeft = textBox.localToGlobal(textBox.size.bottomLeft(Point.origin));
final Point textBottomRight = textBox.localToGlobal(textBox.size.bottomRight(Point.origin));
final Point actionTextBottomLeft = actionTextBox.localToGlobal(actionTextBox.size.bottomLeft(Point.origin));
final Point actionTextBottomRight = actionTextBox.localToGlobal(actionTextBox.size.bottomRight(Point.origin));
final Point snackBarBottomLeft = snackBarBox.localToGlobal(snackBarBox.size.bottomLeft(Point.origin));
final Point snackBarBottomRight = snackBarBox.localToGlobal(snackBarBox.size.bottomRight(Point.origin));
expect(textBottomLeft.x - snackBarBottomLeft.x, 24.0);
expect(actionTextBottomLeft.x - textBottomRight.x, 24.0);
......
......@@ -121,7 +121,7 @@ void main() {
)
);
RenderBox box = tester.renderObject(find.byType(Stepper));
final RenderBox box = tester.renderObject(find.byType(Stepper));
expect(box.size.height, 600.0);
});
......@@ -276,7 +276,7 @@ void main() {
)
);
ScrollableState scrollableState = tester.firstState(find.byType(Scrollable));
final ScrollableState scrollableState = tester.firstState(find.byType(Scrollable));
expect(scrollableState.position.pixels, 0.0);
await tester.tap(find.text('Step 3'));
......
......@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Switch can toggle on tap', (WidgetTester tester) async {
Key switchKey = new UniqueKey();
final Key switchKey = new UniqueKey();
bool value = false;
await tester.pumpWidget(
......
......@@ -7,14 +7,14 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('Theme data control test', () {
ThemeData dark = new ThemeData.dark();
final ThemeData dark = new ThemeData.dark();
expect(dark, hasOneLineDescription);
expect(dark, equals(dark.copyWith()));
expect(dark.hashCode, equals(dark.copyWith().hashCode));
ThemeData light = new ThemeData.light();
ThemeData dawn = ThemeData.lerp(dark, light, 0.25);
final ThemeData light = new ThemeData.light();
final ThemeData dawn = ThemeData.lerp(dark, light, 0.25);
expect(dawn.brightness, Brightness.dark);
expect(dawn.primaryColor, Color.lerp(dark.primaryColor, light.primaryColor, 0.25));
......@@ -22,61 +22,61 @@ void main() {
test('Defaults to the default typography for the platform', () {
for (TargetPlatform platform in TargetPlatform.values) {
ThemeData theme = new ThemeData(platform: platform);
Typography typography = new Typography(platform: platform);
final ThemeData theme = new ThemeData(platform: platform);
final Typography typography = new Typography(platform: platform);
expect(theme.textTheme, typography.black, reason: 'Not using default typography for $platform');
}
});
test('Default text theme contrasts with brightness', () {
ThemeData lightTheme = new ThemeData(brightness: Brightness.light);
ThemeData darkTheme = new ThemeData(brightness: Brightness.dark);
Typography typography = new Typography(platform: lightTheme.platform);
final ThemeData lightTheme = new ThemeData(brightness: Brightness.light);
final ThemeData darkTheme = new ThemeData(brightness: Brightness.dark);
final Typography typography = new Typography(platform: lightTheme.platform);
expect(lightTheme.textTheme.title.color, typography.black.title.color);
expect(darkTheme.textTheme.title.color, typography.white.title.color);
});
test('Default primary text theme contrasts with primary brightness', () {
ThemeData lightTheme = new ThemeData(primaryColorBrightness: Brightness.light);
ThemeData darkTheme = new ThemeData(primaryColorBrightness: Brightness.dark);
Typography typography = new Typography(platform: lightTheme.platform);
final ThemeData lightTheme = new ThemeData(primaryColorBrightness: Brightness.light);
final ThemeData darkTheme = new ThemeData(primaryColorBrightness: Brightness.dark);
final Typography typography = new Typography(platform: lightTheme.platform);
expect(lightTheme.primaryTextTheme.title.color, typography.black.title.color);
expect(darkTheme.primaryTextTheme.title.color, typography.white.title.color);
});
test('Default accent text theme contrasts with accent brightness', () {
ThemeData lightTheme = new ThemeData(accentColorBrightness: Brightness.light);
ThemeData darkTheme = new ThemeData(accentColorBrightness: Brightness.dark);
Typography typography = new Typography(platform: lightTheme.platform);
final ThemeData lightTheme = new ThemeData(accentColorBrightness: Brightness.light);
final ThemeData darkTheme = new ThemeData(accentColorBrightness: Brightness.dark);
final Typography typography = new Typography(platform: lightTheme.platform);
expect(lightTheme.accentTextTheme.title.color, typography.black.title.color);
expect(darkTheme.accentTextTheme.title.color, typography.white.title.color);
});
test('Default icon theme contrasts with brightness', () {
ThemeData lightTheme = new ThemeData(brightness: Brightness.light);
ThemeData darkTheme = new ThemeData(brightness: Brightness.dark);
Typography typography = new Typography(platform: lightTheme.platform);
final ThemeData lightTheme = new ThemeData(brightness: Brightness.light);
final ThemeData darkTheme = new ThemeData(brightness: Brightness.dark);
final Typography typography = new Typography(platform: lightTheme.platform);
expect(lightTheme.textTheme.title.color, typography.black.title.color);
expect(darkTheme.textTheme.title.color, typography.white.title.color);
});
test('Default primary icon theme contrasts with primary brightness', () {
ThemeData lightTheme = new ThemeData(primaryColorBrightness: Brightness.light);
ThemeData darkTheme = new ThemeData(primaryColorBrightness: Brightness.dark);
Typography typography = new Typography(platform: lightTheme.platform);
final ThemeData lightTheme = new ThemeData(primaryColorBrightness: Brightness.light);
final ThemeData darkTheme = new ThemeData(primaryColorBrightness: Brightness.dark);
final Typography typography = new Typography(platform: lightTheme.platform);
expect(lightTheme.primaryTextTheme.title.color, typography.black.title.color);
expect(darkTheme.primaryTextTheme.title.color, typography.white.title.color);
});
test('Default accent icon theme contrasts with accent brightness', () {
ThemeData lightTheme = new ThemeData(accentColorBrightness: Brightness.light);
ThemeData darkTheme = new ThemeData(accentColorBrightness: Brightness.dark);
Typography typography = new Typography(platform: lightTheme.platform);
final ThemeData lightTheme = new ThemeData(accentColorBrightness: Brightness.light);
final ThemeData darkTheme = new ThemeData(accentColorBrightness: Brightness.dark);
final Typography typography = new Typography(platform: lightTheme.platform);
expect(lightTheme.accentTextTheme.title.color, typography.black.title.color);
expect(darkTheme.accentTextTheme.title.color, typography.white.title.color);
......
......@@ -7,9 +7,9 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('ThemeDataTween control test', () {
ThemeData light = new ThemeData.light();
ThemeData dark = new ThemeData.light();
ThemeDataTween tween = new ThemeDataTween(begin: light, end: dark);
final ThemeData light = new ThemeData.light();
final ThemeData dark = new ThemeData.light();
final ThemeDataTween tween = new ThemeDataTween(begin: light, end: dark);
expect(tween.lerp(0.25), equals(ThemeData.lerp(light, dark, 0.25)));
});
......@@ -226,7 +226,7 @@ void main() {
await tester.tap(find.text('SHOW'));
await tester.pump(const Duration(seconds: 1));
List<Material> materials = tester.widgetList(find.byType(Material)).toList();
final List<Material> materials = tester.widgetList(find.byType(Material)).toList();
expect(materials.length, equals(2));
expect(materials[0].color, green); // app scaffold
expect(materials[1].color, green); // dialog scaffold
......
......@@ -76,11 +76,11 @@ void main() {
testWidgets('drag-select an hour', (WidgetTester tester) async {
TimeOfDay result;
Point center = await startPicker(tester, (TimeOfDay time) { result = time; });
Point hour0 = new Point(center.x, center.y - 50.0); // 12:00 AM
Point hour3 = new Point(center.x + 50.0, center.y);
Point hour6 = new Point(center.x, center.y + 50.0);
Point hour9 = new Point(center.x - 50.0, center.y);
final Point center = await startPicker(tester, (TimeOfDay time) { result = time; });
final Point hour0 = new Point(center.x, center.y - 50.0); // 12:00 AM
final Point hour3 = new Point(center.x + 50.0, center.y);
final Point hour6 = new Point(center.x, center.y + 50.0);
final Point hour9 = new Point(center.x - 50.0, center.y);
TestGesture gesture;
......@@ -129,14 +129,14 @@ void main() {
});
testWidgets('tap-select vibrates once', (WidgetTester tester) async {
Point center = await startPicker(tester, (TimeOfDay time) { });
final Point center = await startPicker(tester, (TimeOfDay time) { });
await tester.tapAt(new Point(center.x, center.y - 50.0));
await finishPicker(tester);
expect(hapticFeedbackCount, 1);
});
testWidgets('quick successive tap-selects vibrate once', (WidgetTester tester) async {
Point center = await startPicker(tester, (TimeOfDay time) { });
final Point center = await startPicker(tester, (TimeOfDay time) { });
await tester.tapAt(new Point(center.x, center.y - 50.0));
await tester.pump(kFastFeedbackInterval);
await tester.tapAt(new Point(center.x, center.y + 50.0));
......@@ -145,7 +145,7 @@ void main() {
});
testWidgets('slow successive tap-selects vibrate once per tap', (WidgetTester tester) async {
Point center = await startPicker(tester, (TimeOfDay time) { });
final Point center = await startPicker(tester, (TimeOfDay time) { });
await tester.tapAt(new Point(center.x, center.y - 50.0));
await tester.pump(kSlowFeedbackInterval);
await tester.tapAt(new Point(center.x, center.y + 50.0));
......@@ -156,11 +156,11 @@ void main() {
});
testWidgets('drag-select vibrates once', (WidgetTester tester) async {
Point center = await startPicker(tester, (TimeOfDay time) { });
Point hour0 = new Point(center.x, center.y - 50.0);
Point hour3 = new Point(center.x + 50.0, center.y);
final Point center = await startPicker(tester, (TimeOfDay time) { });
final Point hour0 = new Point(center.x, center.y - 50.0);
final Point hour3 = new Point(center.x + 50.0, center.y);
TestGesture gesture = await tester.startGesture(hour3);
final TestGesture gesture = await tester.startGesture(hour3);
await gesture.moveBy(hour0 - hour3);
await gesture.up();
await finishPicker(tester);
......@@ -168,11 +168,11 @@ void main() {
});
testWidgets('quick drag-select vibrates once', (WidgetTester tester) async {
Point center = await startPicker(tester, (TimeOfDay time) { });
Point hour0 = new Point(center.x, center.y - 50.0);
Point hour3 = new Point(center.x + 50.0, center.y);
final Point center = await startPicker(tester, (TimeOfDay time) { });
final Point hour0 = new Point(center.x, center.y - 50.0);
final Point hour3 = new Point(center.x + 50.0, center.y);
TestGesture gesture = await tester.startGesture(hour3);
final TestGesture gesture = await tester.startGesture(hour3);
await gesture.moveBy(hour0 - hour3);
await tester.pump(kFastFeedbackInterval);
await gesture.moveBy(hour3 - hour0);
......@@ -184,11 +184,11 @@ void main() {
});
testWidgets('slow drag-select vibrates once', (WidgetTester tester) async {
Point center = await startPicker(tester, (TimeOfDay time) { });
Point hour0 = new Point(center.x, center.y - 50.0);
Point hour3 = new Point(center.x + 50.0, center.y);
final Point center = await startPicker(tester, (TimeOfDay time) { });
final Point hour0 = new Point(center.x, center.y - 50.0);
final Point hour3 = new Point(center.x + 50.0, center.y);
TestGesture gesture = await tester.startGesture(hour3);
final TestGesture gesture = await tester.startGesture(hour3);
await gesture.moveBy(hour0 - hour3);
await tester.pump(kSlowFeedbackInterval);
await gesture.moveBy(hour3 - hour0);
......
......@@ -29,7 +29,7 @@ const String tooltipText = 'TIP';
void main() {
testWidgets('Does tooltip end up in the right place - center', (WidgetTester tester) async {
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......@@ -72,9 +72,9 @@ void main() {
* *
*********************/
RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent.parent;
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent.parent;
Point tipInGlobal = tip.localToGlobal(tip.size.topCenter(Point.origin));
final Point tipInGlobal = tip.localToGlobal(tip.size.topCenter(Point.origin));
// The exact position of the left side depends on the font the test framework
// happens to pick, so we don't test that.
expect(tipInGlobal.x, 300.0);
......@@ -82,7 +82,7 @@ void main() {
});
testWidgets('Does tooltip end up in the right place - top left', (WidgetTester tester) async {
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......@@ -125,13 +125,13 @@ void main() {
* *
*********************/
RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent.parent;
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent.parent;
expect(tip.size.height, equals(20.0)); // 10.0 height + 5.0 padding * 2 (top, bottom)
expect(tip.localToGlobal(tip.size.topLeft(Point.origin)), equals(const Point(10.0, 20.0)));
});
testWidgets('Does tooltip end up in the right place - center prefer above fits', (WidgetTester tester) async {
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......@@ -175,14 +175,14 @@ void main() {
* *
*********************/
RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
expect(tip.size.height, equals(100.0));
expect(tip.localToGlobal(tip.size.topLeft(Point.origin)).y, equals(100.0));
expect(tip.localToGlobal(tip.size.bottomRight(Point.origin)).y, equals(200.0));
});
testWidgets('Does tooltip end up in the right place - center prefer above does not fit', (WidgetTester tester) async {
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......@@ -237,14 +237,14 @@ void main() {
* * }- 10.0 margin
*********************/
RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
expect(tip.size.height, equals(190.0));
expect(tip.localToGlobal(tip.size.topLeft(Point.origin)).y, equals(399.0));
expect(tip.localToGlobal(tip.size.bottomRight(Point.origin)).y, equals(589.0));
});
testWidgets('Does tooltip end up in the right place - center prefer below fits', (WidgetTester tester) async {
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......@@ -287,14 +287,14 @@ void main() {
* * }- 10.0 margin
*********************/
RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
expect(tip.size.height, equals(190.0));
expect(tip.localToGlobal(tip.size.topLeft(Point.origin)).y, equals(400.0));
expect(tip.localToGlobal(tip.size.bottomRight(Point.origin)).y, equals(590.0));
});
testWidgets('Does tooltip end up in the right place - way off to the right', (WidgetTester tester) async {
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......@@ -338,7 +338,7 @@ void main() {
* * }-10.0 margin
*********************/
RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
expect(tip.size.height, equals(10.0));
expect(tip.localToGlobal(tip.size.topLeft(Point.origin)).y, equals(310.0));
expect(tip.localToGlobal(tip.size.bottomRight(Point.origin)).x, equals(790.0));
......@@ -346,7 +346,7 @@ void main() {
});
testWidgets('Does tooltip end up in the right place - near the edge', (WidgetTester tester) async {
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......@@ -390,7 +390,7 @@ void main() {
* * }-10.0 margin
*********************/
RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent;
expect(tip.size.height, equals(10.0));
expect(tip.localToGlobal(tip.size.topLeft(Point.origin)).y, equals(310.0));
expect(tip.localToGlobal(tip.size.bottomRight(Point.origin)).x, equals(790.0));
......@@ -415,7 +415,7 @@ void main() {
)
);
Finder tooltip = find.byType(Tooltip);
final Finder tooltip = find.byType(Tooltip);
TestGesture gesture = await tester.startGesture(tester.getCenter(tooltip));
await tester.pump(kLongPressTimeout);
await tester.pump(const Duration(milliseconds: 10));
......@@ -435,9 +435,9 @@ void main() {
});
testWidgets('Does tooltip contribute semantics', (WidgetTester tester) async {
SemanticsTester semantics = new SemanticsTester(tester);
final SemanticsTester semantics = new SemanticsTester(tester);
GlobalKey key = new GlobalKey();
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(
new Overlay(
initialEntries: <OverlayEntry>[
......
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('TextTheme control test', () {
Typography typography = new Typography(platform: TargetPlatform.android);
final Typography typography = new Typography(platform: TargetPlatform.android);
expect(typography.black, equals(typography.black.copyWith()));
expect(typography.black, equals(typography.black.apply()));
expect(typography.black.hashCode, equals(typography.black.copyWith().hashCode));
......@@ -16,7 +16,7 @@ void main() {
test('Typography is defined for all target platforms', () {
for (TargetPlatform platform in TargetPlatform.values) {
Typography typography = new Typography(platform: platform);
final Typography typography = new Typography(platform: platform);
expect(typography, isNotNull, reason: 'null typography for $platform');
expect(typography.black, isNotNull, reason: 'null black typography for $platform');
expect(typography.white, isNotNull, reason: 'null white typography for $platform');
......@@ -30,11 +30,11 @@ void main() {
test('Typography on iOS defaults to the correct SF font family based on size', () {
// Ref: https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/
Matcher hasCorrectFont = predicate((TextStyle s) {
final Matcher hasCorrectFont = predicate((TextStyle s) {
return s.fontFamily == (s.fontSize <= 19.0 ? '.SF UI Text' : '.SF UI Display');
}, 'Uses SF Display font for font sizes over 19.0, otherwise SF Text font');
Typography typography = new Typography(platform: TargetPlatform.iOS);
final Typography typography = new Typography(platform: TargetPlatform.iOS);
for (TextTheme textTheme in <TextTheme>[typography.black, typography.white]) {
expect(textTheme.display4, hasCorrectFont);
expect(textTheme.display3, hasCorrectFont);
......
......@@ -58,12 +58,12 @@ void main() {
expect(box.size.width, equals(40.0));
expect(box.size.height, equals(40.0));
Point topLeft = tester.getTopLeft(find.byType(UserAccountsDrawerHeader));
Point topRight = tester.getTopRight(find.byType(UserAccountsDrawerHeader));
final Point topLeft = tester.getTopLeft(find.byType(UserAccountsDrawerHeader));
final Point topRight = tester.getTopRight(find.byType(UserAccountsDrawerHeader));
Point avatarATopLeft = tester.getTopLeft(find.byKey(avatarA));
Point avatarDTopRight = tester.getTopRight(find.byKey(avatarD));
Point avatarCTopRight = tester.getTopRight(find.byKey(avatarC));
final Point avatarATopLeft = tester.getTopLeft(find.byKey(avatarA));
final Point avatarDTopRight = tester.getTopRight(find.byKey(avatarD));
final Point avatarCTopRight = tester.getTopRight(find.byKey(avatarC));
expect(avatarATopLeft.x - topLeft.x, equals(16.0));
expect(avatarATopLeft.y - topLeft.y, equals(16.0));
......
......@@ -269,7 +269,7 @@ void main() {
StateSetter contentsSetState; // call this to rebuild the route's SampleForm contents
bool contentsEmpty = false; // when true, don't include the SampleForm in the route
TestPageRoute<Null> route = new TestPageRoute<Null>(
final TestPageRoute<Null> route = new TestPageRoute<Null>(
builder: (BuildContext context) {
return new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
......
......@@ -7,8 +7,8 @@ import 'package:flutter/painting.dart';
void main() {
test("BorderSide control test", () {
BorderSide side1 = const BorderSide();
BorderSide side2 = side1.copyWith(
final BorderSide side1 = const BorderSide();
final BorderSide side2 = side1.copyWith(
color: const Color(0xFF00FFFF),
width: 2.0,
style: BorderStyle.solid,
......@@ -29,7 +29,7 @@ void main() {
style: BorderStyle.solid,
)));
BorderSide side3 = side2.copyWith(style: BorderStyle.none);
final BorderSide side3 = side2.copyWith(style: BorderStyle.none);
BorderSide interpolated = BorderSide.lerp(side2, side3, 0.2);
expect(interpolated.style, equals(BorderStyle.solid));
expect(interpolated.color, equals(side2.color.withOpacity(0.8)));
......@@ -40,9 +40,9 @@ void main() {
});
test("Border control test", () {
Border border1 = new Border.all(width: 4.0);
Border border2 = Border.lerp(null, border1, 0.25);
Border border3 = Border.lerp(border1, null, 0.25);
final Border border1 = new Border.all(width: 4.0);
final Border border2 = Border.lerp(null, border1, 0.25);
final Border border3 = Border.lerp(border1, null, 0.25);
expect(border1, hasOneLineDescription);
expect(border1.hashCode, isNot(equals(border2.hashCode)));
......@@ -50,14 +50,14 @@ void main() {
expect(border2.top.width, equals(1.0));
expect(border3.bottom.width, equals(3.0));
Border border4 = Border.lerp(border2, border3, 0.5);
final Border border4 = Border.lerp(border2, border3, 0.5);
expect(border4.left.width, equals(2.0));
});
test("BoxShadow control test", () {
BoxShadow shadow1 = const BoxShadow(blurRadius: 4.0);
BoxShadow shadow2 = BoxShadow.lerp(null, shadow1, 0.25);
BoxShadow shadow3 = BoxShadow.lerp(shadow1, null, 0.25);
final BoxShadow shadow1 = const BoxShadow(blurRadius: 4.0);
final BoxShadow shadow2 = BoxShadow.lerp(null, shadow1, 0.25);
final BoxShadow shadow3 = BoxShadow.lerp(shadow1, null, 0.25);
expect(shadow1, hasOneLineDescription);
expect(shadow1.hashCode, isNot(equals(shadow2.hashCode)));
......@@ -66,7 +66,7 @@ void main() {
expect(shadow2.blurRadius, equals(1.0));
expect(shadow3.blurRadius, equals(3.0));
BoxShadow shadow4 = BoxShadow.lerp(shadow2, shadow3, 0.5);
final BoxShadow shadow4 = BoxShadow.lerp(shadow2, shadow3, 0.5);
expect(shadow4.blurRadius, equals(2.0));
List<BoxShadow> shadowList = BoxShadow.lerpList(
......
......@@ -19,7 +19,7 @@ void main() {
expect(color.toColor(), const Color(0xb399816b));
HSVColor result = HSVColor.lerp(color, const HSVColor.fromAHSV(0.3, 128.0, 0.7, 0.2), 0.25);
final HSVColor result = HSVColor.lerp(color, const HSVColor.fromAHSV(0.3, 128.0, 0.7, 0.2), 0.25);
expect(result.alpha, 0.6);
expect(result.hue, 53.0);
expect(result.saturation, greaterThan(0.3999));
......
......@@ -91,8 +91,8 @@ class TestImage extends ui.Image {
void main() {
test("Decoration.lerp()", () {
BoxDecoration a = const BoxDecoration(backgroundColor: const Color(0xFFFFFFFF));
BoxDecoration b = const BoxDecoration(backgroundColor: const Color(0x00000000));
final BoxDecoration a = const BoxDecoration(backgroundColor: const Color(0xFFFFFFFF));
final BoxDecoration b = const BoxDecoration(backgroundColor: const Color(0x00000000));
BoxDecoration c = Decoration.lerp(a, b, 0.0);
expect(c.backgroundColor, equals(a.backgroundColor));
......@@ -105,17 +105,17 @@ void main() {
});
test("BoxDecorationImageListenerSync", () {
ImageProvider imageProvider = new SynchronousTestImageProvider();
BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider);
final ImageProvider imageProvider = new SynchronousTestImageProvider();
final BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider);
BoxDecoration boxDecoration = new BoxDecoration(backgroundImage: backgroundImage);
final BoxDecoration boxDecoration = new BoxDecoration(backgroundImage: backgroundImage);
bool onChangedCalled = false;
BoxPainter boxPainter = boxDecoration.createBoxPainter(() {
final BoxPainter boxPainter = boxDecoration.createBoxPainter(() {
onChangedCalled = true;
});
TestCanvas canvas = new TestCanvas();
ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero);
final TestCanvas canvas = new TestCanvas();
final ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero);
boxPainter.paint(canvas, Offset.zero, imageConfiguration);
// The onChanged callback should not be invoked during the call to boxPainter.paint
......@@ -124,17 +124,17 @@ void main() {
test("BoxDecorationImageListenerAsync", () {
new FakeAsync().run((FakeAsync async) {
ImageProvider imageProvider = new AsyncTestImageProvider();
BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider);
final ImageProvider imageProvider = new AsyncTestImageProvider();
final BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider);
BoxDecoration boxDecoration = new BoxDecoration(backgroundImage: backgroundImage);
final BoxDecoration boxDecoration = new BoxDecoration(backgroundImage: backgroundImage);
bool onChangedCalled = false;
BoxPainter boxPainter = boxDecoration.createBoxPainter(() {
final BoxPainter boxPainter = boxDecoration.createBoxPainter(() {
onChangedCalled = true;
});
TestCanvas canvas = new TestCanvas();
ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero);
final TestCanvas canvas = new TestCanvas();
final ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero);
boxPainter.paint(canvas, Offset.zero, imageConfiguration);
// The onChanged callback should be invoked asynchronously.
......@@ -149,22 +149,22 @@ void main() {
test("BoxDecoration backgroundImage clip", () {
void testDecoration({ BoxShape shape, BorderRadius borderRadius, bool expectClip}) {
new FakeAsync().run((FakeAsync async) {
BackgroundImageProvider imageProvider = new BackgroundImageProvider();
BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider);
final BackgroundImageProvider imageProvider = new BackgroundImageProvider();
final BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider);
BoxDecoration boxDecoration = new BoxDecoration(
final BoxDecoration boxDecoration = new BoxDecoration(
shape: shape,
borderRadius: borderRadius,
backgroundImage: backgroundImage,
);
List<Invocation> invocations = <Invocation>[];
TestCanvas canvas = new TestCanvas(invocations);
ImageConfiguration imageConfiguration = const ImageConfiguration(
final List<Invocation> invocations = <Invocation>[];
final TestCanvas canvas = new TestCanvas(invocations);
final ImageConfiguration imageConfiguration = const ImageConfiguration(
size: const Size(100.0, 100.0)
);
bool onChangedCalled = false;
BoxPainter boxPainter = boxDecoration.createBoxPainter(() {
final BoxPainter boxPainter = boxDecoration.createBoxPainter(() {
onChangedCalled = true;
});
......@@ -180,7 +180,7 @@ void main() {
boxPainter.paint(canvas, Offset.zero, imageConfiguration);
// We expect a clip to preceed the drawImageRect call.
List<Invocation> commands = canvas.invocations.where((Invocation invocation) {
final List<Invocation> commands = canvas.invocations.where((Invocation invocation) {
return invocation.memberName == #clipPath || invocation.memberName == #drawImageRect;
}).toList();
if (expectClip) { // We expect a clip to preceed the drawImageRect call.
......
......@@ -39,8 +39,8 @@ void main() {
});
test('EdgeInsets.lerp()', () {
EdgeInsets a = const EdgeInsets.all(10.0);
EdgeInsets b = const EdgeInsets.all(20.0);
final EdgeInsets a = const EdgeInsets.all(10.0);
final EdgeInsets b = const EdgeInsets.all(20.0);
expect(EdgeInsets.lerp(a, b, 0.25), equals(a * 1.25));
expect(EdgeInsets.lerp(a, b, 0.25), equals(b * 0.625));
expect(EdgeInsets.lerp(a, b, 0.25), equals(a + const EdgeInsets.all(2.5)));
......
......@@ -18,8 +18,8 @@ void main() {
});
test('FractionalOffset.lerp()', () {
FractionalOffset a = FractionalOffset.topLeft;
FractionalOffset b = FractionalOffset.topCenter;
final FractionalOffset a = FractionalOffset.topLeft;
final FractionalOffset b = FractionalOffset.topCenter;
expect(FractionalOffset.lerp(a, b, 0.25), equals(const FractionalOffset(0.125, 0.0)));
expect(FractionalOffset.lerp(null, null, 0.25), isNull);
......
......@@ -32,8 +32,8 @@ class TestCanvas implements Canvas {
void main() {
test("Cover and align", () {
TestImage image = new TestImage(width: 300, height: 300);
TestCanvas canvas = new TestCanvas();
final TestImage image = new TestImage(width: 300, height: 300);
final TestCanvas canvas = new TestCanvas();
paintImage(
canvas: canvas,
rect: new Rect.fromLTWH(50.0, 75.0, 200.0, 100.0),
......@@ -42,7 +42,7 @@ void main() {
alignment: const FractionalOffset(0.0, 0.5)
);
Invocation command = canvas.invocations.firstWhere((Invocation invocation) {
final Invocation command = canvas.invocations.firstWhere((Invocation invocation) {
return invocation.memberName == #drawImageRect;
});
......
......@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test("TextPainter caret test", () {
TextPainter painter = new TextPainter();
final TextPainter painter = new TextPainter();
String text = 'A';
painter.text = new TextSpan(text: text);
......@@ -30,7 +30,7 @@ void main() {
}, skip: io.Platform.isMacOS); // TODO(goderbauer): Disabled because of https://github.com/flutter/flutter/issues/4273
test("TextPainter error test", () {
TextPainter painter = new TextPainter();
final TextPainter painter = new TextPainter();
expect(() { painter.paint(null, Offset.zero); }, throwsFlutterError);
});
}
......@@ -8,14 +8,14 @@ import 'package:test/test.dart';
void main() {
test('TextSpan equals', () {
String text = 'a'; // we want these instances to be separate instances so that we're not just checking with a single object
TextSpan a1 = new TextSpan(text: text);
TextSpan a2 = new TextSpan(text: text);
TextSpan b1 = new TextSpan(children: <TextSpan>[ a1 ]);
TextSpan b2 = new TextSpan(children: <TextSpan>[ a2 ]);
final String text = 'a'; // we want these instances to be separate instances so that we're not just checking with a single object
final TextSpan a1 = new TextSpan(text: text);
final TextSpan a2 = new TextSpan(text: text);
final TextSpan b1 = new TextSpan(children: <TextSpan>[ a1 ]);
final TextSpan b2 = new TextSpan(children: <TextSpan>[ a2 ]);
String nullText; // we want these instances to be separate instances so that we're not just checking with a single object
TextSpan c1 = new TextSpan(text: nullText);
TextSpan c2 = new TextSpan(text: nullText);
final TextSpan c1 = new TextSpan(text: nullText);
final TextSpan c2 = new TextSpan(text: nullText);
expect(a1 == a2, isTrue);
expect(b1 == b2, isTrue);
......
......@@ -9,7 +9,7 @@ import 'package:test/test.dart';
void main() {
test("TextStyle control test", () {
TextStyle s1 = const TextStyle(
final TextStyle s1 = const TextStyle(
fontSize: 10.0,
fontWeight: FontWeight.w800,
height: 123.0,
......@@ -21,7 +21,7 @@ void main() {
expect(s1.height, 123.0);
expect(s1, equals(s1));
TextStyle s2 = s1.copyWith(color: const Color(0xFF00FF00), height: 100.0);
final TextStyle s2 = s1.copyWith(color: const Color(0xFF00FF00), height: 100.0);
expect(s1.fontFamily, isNull);
expect(s1.fontSize, 10.0);
expect(s1.fontWeight, FontWeight.w800);
......@@ -34,7 +34,7 @@ void main() {
expect(s2.color, const Color(0xFF00FF00));
expect(s2, isNot(equals(s1)));
TextStyle s3 = s1.apply(fontSizeFactor: 2.0, fontSizeDelta: -2.0, fontWeightDelta: -4);
final TextStyle s3 = s1.apply(fontSizeFactor: 2.0, fontSizeDelta: -2.0, fontWeightDelta: -4);
expect(s1.fontFamily, isNull);
expect(s1.fontSize, 10.0);
expect(s1.fontWeight, FontWeight.w800);
......@@ -51,7 +51,7 @@ void main() {
expect(s1.apply(fontWeightDelta: 2).fontWeight, FontWeight.w900);
expect(s1.merge(null), equals(s1));
TextStyle s4 = s2.merge(s1);
final TextStyle s4 = s2.merge(s1);
expect(s1.fontFamily, isNull);
expect(s1.fontSize, 10.0);
expect(s1.fontWeight, FontWeight.w800);
......@@ -70,7 +70,7 @@ void main() {
expect(s4.height, 123.0);
expect(s4.color, const Color(0xFF00FF00));
TextStyle s5 = TextStyle.lerp(s1, s3, 0.25);
final TextStyle s5 = TextStyle.lerp(s1, s3, 0.25);
expect(s1.fontFamily, isNull);
expect(s1.fontSize, 10.0);
expect(s1.fontWeight, FontWeight.w800);
......@@ -89,17 +89,17 @@ void main() {
expect(s5.height, 123.0);
expect(s5.color, isNull);
ui.TextStyle ts5 = s5.getTextStyle();
final ui.TextStyle ts5 = s5.getTextStyle();
expect(ts5, equals(new ui.TextStyle(fontWeight: FontWeight.w700, fontSize: 12.0, height: 123.0)));
expect(ts5.toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontSize: 12.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 123.0x)');
ui.TextStyle ts2 = s2.getTextStyle();
final ui.TextStyle ts2 = s2.getTextStyle();
expect(ts2, equals(new ui.TextStyle(color: const Color(0xFF00FF00), fontWeight: FontWeight.w800, fontSize: 10.0, height: 100.0)));
expect(ts2.toString(), 'TextStyle(color: Color(0xff00ff00), decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontSize: 10.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 100.0x)');
ui.ParagraphStyle ps2 = s2.getParagraphStyle(textAlign: TextAlign.center);
final ui.ParagraphStyle ps2 = s2.getParagraphStyle(textAlign: TextAlign.center);
expect(ps2, equals(new ui.ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontSize: 10.0, lineHeight: 100.0)));
expect(ps2.toString(), 'ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 10.0, lineHeight: 100.0x, ellipsis: unspecified)');
ui.ParagraphStyle ps5 = s5.getParagraphStyle();
final ui.ParagraphStyle ps5 = s5.getParagraphStyle();
expect(ps5, equals(new ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, lineHeight: 123.0)));
expect(ps5.toString(), 'ParagraphStyle(textAlign: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 12.0, lineHeight: 123.0x, ellipsis: unspecified)');
});
......
......@@ -7,8 +7,8 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('Clamped simulation', () {
GravitySimulation gravity = new GravitySimulation(9.81, 10.0, 0.0, 0.0);
ClampedSimulation clamped = new ClampedSimulation(gravity, xMin: 20.0, xMax: 100.0, dxMin: 7.0, dxMax: 11.0);
final GravitySimulation gravity = new GravitySimulation(9.81, 10.0, 0.0, 0.0);
final ClampedSimulation clamped = new ClampedSimulation(gravity, xMin: 20.0, xMax: 100.0, dxMin: 7.0, dxMax: 11.0);
expect(clamped.x(0.0), equals(20.0));
expect(clamped.dx(0.0), equals(7.0));
......
......@@ -9,7 +9,7 @@ import 'package:flutter/widgets.dart';
void main() {
test('test_friction', () {
FrictionSimulation friction = new FrictionSimulation(0.3, 100.0, 400.0);
final FrictionSimulation friction = new FrictionSimulation(0.3, 100.0, 400.0);
friction.tolerance = const Tolerance(velocity: 1.0);
......@@ -48,7 +48,7 @@ void main() {
expect(friction.x(0.0), 10.0);
expect(friction.dx(0.0), 600.0);
double epsilon = 1e-4;
final double epsilon = 1e-4;
expect(friction.isDone(1.0 + epsilon), true);
expect(friction.x(1.0), closeTo(endPosition, epsilon));
expect(friction.dx(1.0), closeTo(endVelocity, epsilon));
......@@ -71,7 +71,7 @@ void main() {
});
test('BoundedFrictionSimulation control test', () {
BoundedFrictionSimulation friction = new BoundedFrictionSimulation(0.3, 100.0, 400.0, 50.0, 150.0);
final BoundedFrictionSimulation friction = new BoundedFrictionSimulation(0.3, 100.0, 400.0, 50.0, 150.0);
friction.tolerance = const Tolerance(velocity: 1.0);
......@@ -85,7 +85,7 @@ void main() {
});
test('test_gravity', () {
GravitySimulation gravity = new GravitySimulation(200.0, 100.0, 600.0, 0.0);
final GravitySimulation gravity = new GravitySimulation(200.0, 100.0, 600.0, 0.0);
expect(gravity.isDone(0.0), false);
expect(gravity.x(0.0), 100.0);
......@@ -123,23 +123,23 @@ void main() {
mass: 1.0, springConstant: 100.0, ratio: 1.0), 0.0, 300.0, 0.0);
expect(crit.type, SpringType.criticallyDamped);
SpringSimulation under = new SpringSimulation(new SpringDescription.withDampingRatio(
final SpringSimulation under = new SpringSimulation(new SpringDescription.withDampingRatio(
mass: 1.0, springConstant: 100.0, ratio: 0.75), 0.0, 300.0, 0.0);
expect(under.type, SpringType.underDamped);
SpringSimulation over = new SpringSimulation(new SpringDescription.withDampingRatio(
final SpringSimulation over = new SpringSimulation(new SpringDescription.withDampingRatio(
mass: 1.0, springConstant: 100.0, ratio: 1.25), 0.0, 300.0, 0.0);
expect(over.type, SpringType.overDamped);
// Just so we don't forget how to create a desc without the ratio.
SpringSimulation other = new SpringSimulation(
final SpringSimulation other = new SpringSimulation(
const SpringDescription(mass: 1.0, springConstant: 100.0, damping: 20.0),
0.0, 20.0, 20.0);
expect(other.type, SpringType.criticallyDamped);
});
test('crit_spring', () {
SpringSimulation crit = new SpringSimulation(new SpringDescription.withDampingRatio(
final SpringSimulation crit = new SpringSimulation(new SpringDescription.withDampingRatio(
mass: 1.0, springConstant: 100.0, ratio: 1.0), 0.0, 500.0, 0.0);
crit.tolerance = const Tolerance(distance: 0.01, velocity: 0.01);
......@@ -164,7 +164,7 @@ void main() {
});
test('overdamped_spring', () {
SpringSimulation over = new SpringSimulation(new SpringDescription.withDampingRatio(
final SpringSimulation over = new SpringSimulation(new SpringDescription.withDampingRatio(
mass: 1.0, springConstant: 100.0, ratio: 1.25), 0.0, 500.0, 0.0);
over.tolerance = const Tolerance(distance: 0.01, velocity: 0.01);
......@@ -186,7 +186,7 @@ void main() {
});
test('underdamped_spring', () {
SpringSimulation under = new SpringSimulation(new SpringDescription.withDampingRatio(
final SpringSimulation under = new SpringSimulation(new SpringDescription.withDampingRatio(
mass: 1.0, springConstant: 100.0, ratio: 0.25), 0.0, 300.0, 0.0);
expect(under.type, SpringType.underDamped);
......@@ -203,10 +203,10 @@ void main() {
});
test('test_kinetic_scroll', () {
SpringDescription spring = new SpringDescription.withDampingRatio(
final SpringDescription spring = new SpringDescription.withDampingRatio(
mass: 1.0, springConstant: 50.0, ratio: 0.5);
BouncingScrollSimulation scroll = new BouncingScrollSimulation(
final BouncingScrollSimulation scroll = new BouncingScrollSimulation(
position: 100.0,
velocity: 800.0,
leadingExtent: 0.0,
......@@ -218,7 +218,7 @@ void main() {
expect(scroll.isDone(0.5), false); // switch from friction to spring
expect(scroll.isDone(3.5), true);
BouncingScrollSimulation scroll2 = new BouncingScrollSimulation(
final BouncingScrollSimulation scroll2 = new BouncingScrollSimulation(
position: 100.0,
velocity: -800.0,
leadingExtent: 0.0,
......@@ -232,10 +232,10 @@ void main() {
});
test('scroll_with_inf_edge_ends', () {
SpringDescription spring = new SpringDescription.withDampingRatio(
final SpringDescription spring = new SpringDescription.withDampingRatio(
mass: 1.0, springConstant: 50.0, ratio: 0.5);
BouncingScrollSimulation scroll = new BouncingScrollSimulation(
final BouncingScrollSimulation scroll = new BouncingScrollSimulation(
position: 100.0,
velocity: 400.0,
leadingExtent: 0.0,
......@@ -262,8 +262,8 @@ void main() {
});
test('over/under scroll spring', () {
SpringDescription spring = new SpringDescription.withDampingRatio(mass: 1.0, springConstant: 170.0, ratio: 1.1);
BouncingScrollSimulation scroll = new BouncingScrollSimulation(
final SpringDescription spring = new SpringDescription.withDampingRatio(mass: 1.0, springConstant: 170.0, ratio: 1.1);
final BouncingScrollSimulation scroll = new BouncingScrollSimulation(
position: 500.0,
velocity: -7500.0,
leadingExtent: 0.0,
......
......@@ -9,7 +9,7 @@ import 'rendering_tester.dart';
void main() {
test('RenderAspectRatio: Intrinsic sizing 2.0', () {
RenderAspectRatio box = new RenderAspectRatio(aspectRatio: 2.0);
final RenderAspectRatio box = new RenderAspectRatio(aspectRatio: 2.0);
expect(box.getMinIntrinsicWidth(200.0), 400.0);
expect(box.getMinIntrinsicWidth(400.0), 800.0);
......@@ -30,7 +30,7 @@ void main() {
});
test('RenderAspectRatio: Intrinsic sizing 0.5', () {
RenderAspectRatio box = new RenderAspectRatio(aspectRatio: 0.5);
final RenderAspectRatio box = new RenderAspectRatio(aspectRatio: 0.5);
expect(box.getMinIntrinsicWidth(200.0), 100.0);
expect(box.getMinIntrinsicWidth(400.0), 200.0);
......@@ -51,7 +51,7 @@ void main() {
});
test('RenderAspectRatio: Intrinsic sizing 2.0', () {
RenderAspectRatio box = new RenderAspectRatio(
final RenderAspectRatio box = new RenderAspectRatio(
aspectRatio: 2.0,
child: new RenderSizedBox(const Size(90.0, 70.0))
);
......@@ -75,7 +75,7 @@ void main() {
});
test('RenderAspectRatio: Intrinsic sizing 0.5', () {
RenderAspectRatio box = new RenderAspectRatio(
final RenderAspectRatio box = new RenderAspectRatio(
aspectRatio: 0.5,
child: new RenderSizedBox(const Size(90.0, 70.0))
);
......@@ -100,11 +100,11 @@ void main() {
test('RenderAspectRatio: Unbounded', () {
bool hadError = false;
FlutterExceptionHandler oldHandler = FlutterError.onError;
final FlutterExceptionHandler oldHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) {
hadError = true;
};
RenderBox box = new RenderConstrainedOverflowBox(
final RenderBox box = new RenderConstrainedOverflowBox(
maxWidth: double.INFINITY,
maxHeight: double.INFINITY,
child: new RenderAspectRatio(
......
......@@ -12,7 +12,7 @@ void main() {
test("RenderBaseline", () {
RenderBaseline parent;
RenderSizedBox child;
RenderBox root = new RenderPositionedBox(
final RenderBox root = new RenderPositionedBox(
alignment: FractionalOffset.topLeft,
child: parent = new RenderBaseline(
baseline: 0.0,
......@@ -20,7 +20,7 @@ void main() {
child: child = new RenderSizedBox(const Size(100.0, 100.0))
)
);
BoxParentData childParentData = child.parentData;
final BoxParentData childParentData = child.parentData;
layout(root, phase: EnginePhase.layout);
expect(childParentData.offset.dx, equals(0.0));
......
......@@ -13,7 +13,7 @@ void main() {
});
test('BoxConstraints copyWith', () {
BoxConstraints constraints = const BoxConstraints(
final BoxConstraints constraints = const BoxConstraints(
minWidth: 3.0,
maxWidth: 7.0,
minHeight: 11.0,
......@@ -36,7 +36,7 @@ void main() {
});
test('BoxConstraints operators', () {
BoxConstraints constraints = const BoxConstraints(
final BoxConstraints constraints = const BoxConstraints(
minWidth: 3.0,
maxWidth: 7.0,
minHeight: 11.0,
......@@ -62,7 +62,7 @@ void main() {
test('BoxConstraints lerp', () {
expect(BoxConstraints.lerp(null, null, 0.5), isNull);
BoxConstraints constraints = const BoxConstraints(
final BoxConstraints constraints = const BoxConstraints(
minWidth: 3.0,
maxWidth: 7.0,
minHeight: 11.0,
......@@ -91,13 +91,13 @@ void main() {
});
test('BoxConstraints normalize', () {
BoxConstraints constraints = const BoxConstraints(
final BoxConstraints constraints = const BoxConstraints(
minWidth: 3.0,
maxWidth: 2.0,
minHeight: 11.0,
maxHeight: 18.0
);
BoxConstraints copy = constraints.normalize();
final BoxConstraints copy = constraints.normalize();
expect(copy.minWidth, 3.0);
expect(copy.maxWidth, 3.0);
expect(copy.minHeight, 11.0);
......
......@@ -10,7 +10,7 @@ import 'rendering_tester.dart';
void main() {
test("should size to render view", () {
RenderBox root = new RenderDecoratedBox(
final RenderBox root = new RenderDecoratedBox(
decoration: new BoxDecoration(
backgroundColor: const Color(0xFF00FF00),
gradient: new RadialGradient(
......@@ -26,25 +26,25 @@ void main() {
});
test('Flex and padding', () {
RenderBox size = new RenderConstrainedBox(
final RenderBox size = new RenderConstrainedBox(
additionalConstraints: const BoxConstraints().tighten(height: 100.0),
);
RenderBox inner = new RenderDecoratedBox(
final RenderBox inner = new RenderDecoratedBox(
decoration: const BoxDecoration(
backgroundColor: const Color(0xFF00FF00),
),
child: size,
);
RenderBox padding = new RenderPadding(
final RenderBox padding = new RenderPadding(
padding: const EdgeInsets.all(50.0),
child: inner,
);
RenderBox flex = new RenderFlex(
final RenderBox flex = new RenderFlex(
children: <RenderBox>[padding],
direction: Axis.vertical,
crossAxisAlignment: CrossAxisAlignment.stretch,
);
RenderBox outer = new RenderDecoratedBox(
final RenderBox outer = new RenderDecoratedBox(
decoration: const BoxDecoration(
backgroundColor: const Color(0xFF0000FF)
),
......@@ -66,14 +66,14 @@ void main() {
});
test("should not have a 0 sized colored Box", () {
RenderBox coloredBox = new RenderDecoratedBox(
final RenderBox coloredBox = new RenderDecoratedBox(
decoration: const BoxDecoration(),
);
RenderBox paddingBox = new RenderPadding(
final RenderBox paddingBox = new RenderPadding(
padding: const EdgeInsets.all(10.0),
child: coloredBox,
);
RenderBox root = new RenderDecoratedBox(
final RenderBox root = new RenderDecoratedBox(
decoration: const BoxDecoration(),
child: paddingBox,
);
......@@ -83,20 +83,20 @@ void main() {
});
test("reparenting should clear position", () {
RenderDecoratedBox coloredBox = new RenderDecoratedBox(
final RenderDecoratedBox coloredBox = new RenderDecoratedBox(
decoration: const BoxDecoration(),
);
RenderPadding paddedBox = new RenderPadding(
final RenderPadding paddedBox = new RenderPadding(
child: coloredBox,
padding: const EdgeInsets.all(10.0),
);
layout(paddedBox);
BoxParentData parentData = coloredBox.parentData;
final BoxParentData parentData = coloredBox.parentData;
expect(parentData.offset.dx, isNot(equals(0.0)));
paddedBox.child = null;
RenderConstrainedBox constraintedBox = new RenderConstrainedBox(
final RenderConstrainedBox constraintedBox = new RenderConstrainedBox(
child: coloredBox,
additionalConstraints: const BoxConstraints(),
);
......
......@@ -16,7 +16,7 @@ class RenderTestBox extends RenderBox {
void main() {
test('Intrinsics cache', () {
RenderBox test = new RenderTestBox();
final RenderBox test = new RenderTestBox();
expect(test.getMinIntrinsicWidth(0.0), equals(1.0));
expect(test.getMinIntrinsicWidth(100.0), equals(2.0));
......
......@@ -36,7 +36,7 @@ void main() {
result = 'no exception';
try {
BoxConstraints constraints = const BoxConstraints(minWidth: double.NAN, maxWidth: double.NAN, minHeight: 2.0, maxHeight: double.NAN);
final BoxConstraints constraints = const BoxConstraints(minWidth: double.NAN, maxWidth: double.NAN, minHeight: 2.0, maxHeight: double.NAN);
assert(constraints.debugAssertIsValid());
} on FlutterError catch (e) {
result = '$e';
......@@ -49,7 +49,7 @@ void main() {
result = 'no exception';
try {
BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN);
final BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN);
assert(constraints.debugAssertIsValid());
} on FlutterError catch (e) {
result = '$e';
......@@ -62,7 +62,7 @@ void main() {
result = 'no exception';
try {
BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN, maxWidth: 0.0/0.0);
final BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN, maxWidth: 0.0/0.0);
assert(constraints.debugAssertIsValid());
} on FlutterError catch (e) {
result = '$e';
......
......@@ -11,8 +11,8 @@ import 'rendering_tester.dart';
void main() {
test('Describe transform control test', () {
Matrix4 identity = new Matrix4.identity();
List<String> description = debugDescribeTransform(identity);
final Matrix4 identity = new Matrix4.identity();
final List<String> description = debugDescribeTransform(identity);
expect(description, equals(<String>[
' [0] 1.0,0.0,0.0,0.0',
' [1] 0.0,1.0,0.0,0.0',
......@@ -37,7 +37,7 @@ void main() {
debugPaintSizeEnabled = true;
RenderSliver s;
RenderBox b;
RenderViewport root = new RenderViewport(
final RenderViewport root = new RenderViewport(
offset: new ViewportOffset.zero(),
children: <RenderSliver>[
s = new RenderSliverPadding(
......@@ -62,7 +62,7 @@ void main() {
test('debugPaintPadding from render objects', () {
debugPaintSizeEnabled = true;
RenderSliver s;
RenderBox b = new RenderPadding(
final RenderBox b = new RenderPadding(
padding: const EdgeInsets.all(10.0),
child: new RenderViewport(
offset: new ViewportOffset.zero(),
......
......@@ -9,8 +9,8 @@ import 'rendering_tester.dart';
void main() {
test('Overconstrained flex', () {
RenderDecoratedBox box = new RenderDecoratedBox(decoration: const BoxDecoration());
RenderFlex flex = new RenderFlex(children: <RenderBox>[box]);
final RenderDecoratedBox box = new RenderDecoratedBox(decoration: const BoxDecoration());
final RenderFlex flex = new RenderFlex(children: <RenderBox>[box]);
layout(flex, constraints: const BoxConstraints(
minWidth: 200.0, maxWidth: 200.0, minHeight: 200.0, maxHeight: 200.0)
);
......@@ -20,19 +20,19 @@ void main() {
});
test('Vertical Overflow', () {
RenderConstrainedBox flexible = new RenderConstrainedBox(
final RenderConstrainedBox flexible = new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.expand()
);
RenderFlex flex = new RenderFlex(
final RenderFlex flex = new RenderFlex(
direction: Axis.vertical,
children: <RenderBox>[
new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(height: 200.0)),
flexible,
]
);
FlexParentData flexParentData = flexible.parentData;
final FlexParentData flexParentData = flexible.parentData;
flexParentData.flex = 1;
BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0);
final BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0);
layout(flex, constraints: viewport);
expect(flexible.size.height, equals(0.0));
expect(flex.getMinIntrinsicHeight(100.0), equals(200.0));
......@@ -42,19 +42,19 @@ void main() {
});
test('Horizontal Overflow', () {
RenderConstrainedBox flexible = new RenderConstrainedBox(
final RenderConstrainedBox flexible = new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.expand()
);
RenderFlex flex = new RenderFlex(
final RenderFlex flex = new RenderFlex(
direction: Axis.horizontal,
children: <RenderBox>[
new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 200.0)),
flexible,
]
);
FlexParentData flexParentData = flexible.parentData;
final FlexParentData flexParentData = flexible.parentData;
flexParentData.flex = 1;
BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0);
final BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0);
layout(flex, constraints: viewport);
expect(flexible.size.width, equals(0.0));
expect(flex.getMinIntrinsicHeight(100.0), equals(0.0));
......@@ -64,13 +64,13 @@ void main() {
});
test('Vertical Flipped Constraints', () {
RenderFlex flex = new RenderFlex(
final RenderFlex flex = new RenderFlex(
direction: Axis.vertical,
children: <RenderBox>[
new RenderAspectRatio(aspectRatio: 1.0),
]
);
BoxConstraints viewport = const BoxConstraints(maxHeight: 200.0, maxWidth: 1000.0);
final BoxConstraints viewport = const BoxConstraints(maxHeight: 200.0, maxWidth: 1000.0);
layout(flex, constraints: viewport);
expect(flex.getMaxIntrinsicWidth(200.0), equals(0.0));
});
......@@ -79,15 +79,15 @@ void main() {
// RenderAspectRatio being height-in, width-out.
test('Defaults', () {
RenderFlex flex = new RenderFlex();
final RenderFlex flex = new RenderFlex();
expect(flex.crossAxisAlignment, equals(CrossAxisAlignment.center));
expect(flex.direction, equals(Axis.horizontal));
});
test('Parent data', () {
RenderDecoratedBox box1 = new RenderDecoratedBox(decoration: const BoxDecoration());
RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: const BoxDecoration());
RenderFlex flex = new RenderFlex(children: <RenderBox>[box1, box2]);
final RenderDecoratedBox box1 = new RenderDecoratedBox(decoration: const BoxDecoration());
final RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: const BoxDecoration());
final RenderFlex flex = new RenderFlex(children: <RenderBox>[box1, box2]);
layout(flex, constraints: const BoxConstraints(
minWidth: 0.0, maxWidth: 100.0, minHeight: 0.0, maxHeight: 100.0)
);
......@@ -107,9 +107,9 @@ void main() {
});
test('Stretch', () {
RenderDecoratedBox box1 = new RenderDecoratedBox(decoration: const BoxDecoration());
RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: const BoxDecoration());
RenderFlex flex = new RenderFlex();
final RenderDecoratedBox box1 = new RenderDecoratedBox(decoration: const BoxDecoration());
final RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: const BoxDecoration());
final RenderFlex flex = new RenderFlex();
flex.setupParentData(box2);
final FlexParentData box2ParentData = box2.parentData;
box2ParentData.flex = 2;
......@@ -138,16 +138,16 @@ void main() {
});
test('Space evenly', () {
RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderFlex flex = new RenderFlex(mainAxisAlignment: MainAxisAlignment.spaceEvenly);
final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderFlex flex = new RenderFlex(mainAxisAlignment: MainAxisAlignment.spaceEvenly);
flex.addAll(<RenderBox>[box1, box2, box3]);
layout(flex, constraints: const BoxConstraints(
minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0)
);
Offset getOffset(RenderBox box) {
FlexParentData parentData = box.parentData;
final FlexParentData parentData = box.parentData;
return parentData.offset;
}
expect(getOffset(box1).dx, equals(50.0));
......@@ -168,16 +168,16 @@ void main() {
});
test('Fit.loose', () {
RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderFlex flex = new RenderFlex(mainAxisAlignment: MainAxisAlignment.spaceBetween);
final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderFlex flex = new RenderFlex(mainAxisAlignment: MainAxisAlignment.spaceBetween);
flex.addAll(<RenderBox>[box1, box2, box3]);
layout(flex, constraints: const BoxConstraints(
minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0)
);
Offset getOffset(RenderBox box) {
FlexParentData parentData = box.parentData;
final FlexParentData parentData = box.parentData;
return parentData.offset;
}
expect(getOffset(box1).dx, equals(0.0));
......@@ -188,7 +188,7 @@ void main() {
expect(box3.size.width, equals(100.0));
void setFit(RenderBox box, FlexFit fit) {
FlexParentData parentData = box.parentData;
final FlexParentData parentData = box.parentData;
parentData.flex = 1;
parentData.fit = fit;
}
......@@ -216,10 +216,10 @@ void main() {
});
test('Flexible with MainAxisSize.min', () {
RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
RenderFlex flex = new RenderFlex(
final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0));
final RenderFlex flex = new RenderFlex(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween
);
......@@ -228,7 +228,7 @@ void main() {
minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0)
);
Offset getOffset(RenderBox box) {
FlexParentData parentData = box.parentData;
final FlexParentData parentData = box.parentData;
return parentData.offset;
}
expect(getOffset(box1).dx, equals(0.0));
......@@ -240,7 +240,7 @@ void main() {
expect(flex.size.width, equals(300.0));
void setFit(RenderBox box, FlexFit fit) {
FlexParentData parentData = box.parentData;
final FlexParentData parentData = box.parentData;
parentData.flex = 1;
parentData.fit = fit;
}
......
......@@ -37,15 +37,15 @@ void main() {
);
test('onscreen layout does not affect offscreen', () {
TestLayout onscreen = new TestLayout();
TestLayout offscreen = new TestLayout();
final TestLayout onscreen = new TestLayout();
final TestLayout offscreen = new TestLayout();
expect(onscreen.child.hasSize, isFalse);
expect(onscreen.painted, isFalse);
expect(offscreen.child.hasSize, isFalse);
expect(offscreen.painted, isFalse);
// Attach the offscreen to a custom render view and owner
RenderView renderView = new RenderView(configuration: testConfiguration);
PipelineOwner pipelineOwner = new PipelineOwner();
final RenderView renderView = new RenderView(configuration: testConfiguration);
final PipelineOwner pipelineOwner = new PipelineOwner();
renderView.attach(pipelineOwner);
renderView.child = offscreen.root;
renderView.scheduleInitialFrame();
......@@ -66,15 +66,15 @@ void main() {
expect(offscreen.painted, isTrue);
});
test('offscreen layout does not affect onscreen', () {
TestLayout onscreen = new TestLayout();
TestLayout offscreen = new TestLayout();
final TestLayout onscreen = new TestLayout();
final TestLayout offscreen = new TestLayout();
expect(onscreen.child.hasSize, isFalse);
expect(onscreen.painted, isFalse);
expect(offscreen.child.hasSize, isFalse);
expect(offscreen.painted, isFalse);
// Attach the offscreen to a custom render view and owner
RenderView renderView = new RenderView(configuration: testConfiguration);
PipelineOwner pipelineOwner = new PipelineOwner();
final RenderView renderView = new RenderView(configuration: testConfiguration);
final PipelineOwner pipelineOwner = new PipelineOwner();
renderView.attach(pipelineOwner);
renderView.child = offscreen.root;
renderView.scheduleInitialFrame();
......
......@@ -45,8 +45,8 @@ class RenderTestBox extends RenderBox {
void main() {
test('Shrink-wrapping width', () {
RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
RenderBox parent = new RenderIntrinsicWidth(child: child);
final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
final RenderBox parent = new RenderIntrinsicWidth(child: child);
layout(parent,
constraints: const BoxConstraints(
minWidth: 5.0,
......@@ -80,7 +80,7 @@ void main() {
});
test('IntrinsicWidth without a child', () {
RenderBox parent = new RenderIntrinsicWidth();
final RenderBox parent = new RenderIntrinsicWidth();
layout(parent,
constraints: const BoxConstraints(
minWidth: 5.0,
......@@ -114,8 +114,8 @@ void main() {
});
test('Shrink-wrapping width (stepped width)', () {
RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
RenderBox parent = new RenderIntrinsicWidth(child: child, stepWidth: 47.0);
final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
final RenderBox parent = new RenderIntrinsicWidth(child: child, stepWidth: 47.0);
layout(parent,
constraints: const BoxConstraints(
minWidth: 5.0,
......@@ -149,8 +149,8 @@ void main() {
});
test('Shrink-wrapping width (stepped height)', () {
RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
RenderBox parent = new RenderIntrinsicWidth(child: child, stepHeight: 47.0);
final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
final RenderBox parent = new RenderIntrinsicWidth(child: child, stepHeight: 47.0);
layout(parent,
constraints: const BoxConstraints(
minWidth: 5.0,
......@@ -184,8 +184,8 @@ void main() {
});
test('Shrink-wrapping width (stepped everything)', () {
RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
RenderBox parent = new RenderIntrinsicWidth(child: child, stepHeight: 47.0, stepWidth: 37.0);
final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
final RenderBox parent = new RenderIntrinsicWidth(child: child, stepHeight: 47.0, stepWidth: 37.0);
layout(parent,
constraints: const BoxConstraints(
minWidth: 5.0,
......@@ -219,8 +219,8 @@ void main() {
});
test('Shrink-wrapping height', () {
RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
RenderBox parent = new RenderIntrinsicHeight(child: child);
final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0));
final RenderBox parent = new RenderIntrinsicHeight(child: child);
layout(parent,
constraints: const BoxConstraints(
minWidth: 5.0,
......@@ -254,7 +254,7 @@ void main() {
});
test('IntrinsicHeight without a child', () {
RenderBox parent = new RenderIntrinsicHeight();
final RenderBox parent = new RenderIntrinsicHeight();
layout(parent,
constraints: const BoxConstraints(
minWidth: 5.0,
......@@ -288,7 +288,7 @@ void main() {
});
test('Padding and boring intrinsics', () {
RenderBox box = new RenderPadding(
final RenderBox box = new RenderPadding(
padding: const EdgeInsets.all(15.0),
child: new RenderSizedBox(const Size(20.0, 20.0))
);
......@@ -326,7 +326,7 @@ void main() {
});
test('Padding and interesting intrinsics', () {
RenderBox box = new RenderPadding(
final RenderBox box = new RenderPadding(
padding: const EdgeInsets.all(15.0),
child: new RenderAspectRatio(aspectRatio: 1.0)
);
......@@ -364,7 +364,7 @@ void main() {
});
test('Padding and boring intrinsics', () {
RenderBox box = new RenderPadding(
final RenderBox box = new RenderPadding(
padding: const EdgeInsets.all(15.0),
child: new RenderSizedBox(const Size(20.0, 20.0))
);
......@@ -402,7 +402,7 @@ void main() {
});
test('Padding and interesting intrinsics', () {
RenderBox box = new RenderPadding(
final RenderBox box = new RenderPadding(
padding: const EdgeInsets.all(15.0),
child: new RenderAspectRatio(aspectRatio: 1.0)
);
......
......@@ -10,10 +10,10 @@ import 'rendering_tester.dart';
void main() {
test('LimitedBox: parent max size is unconstrained', () {
RenderBox child = new RenderConstrainedBox(
final RenderBox child = new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 300.0, height: 400.0)
);
RenderBox parent = new RenderConstrainedOverflowBox(
final RenderBox parent = new RenderConstrainedOverflowBox(
minWidth: 0.0,
maxWidth: double.INFINITY,
minHeight: 0.0,
......@@ -30,10 +30,10 @@ void main() {
});
test('LimitedBox: parent maxWidth is unconstrained', () {
RenderBox child = new RenderConstrainedBox(
final RenderBox child = new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 300.0, height: 400.0)
);
RenderBox parent = new RenderConstrainedOverflowBox(
final RenderBox parent = new RenderConstrainedOverflowBox(
minWidth: 0.0,
maxWidth: double.INFINITY,
minHeight: 500.0,
......@@ -50,10 +50,10 @@ void main() {
});
test('LimitedBox: parent maxHeight is unconstrained', () {
RenderBox child = new RenderConstrainedBox(
final RenderBox child = new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 300.0, height: 400.0)
);
RenderBox parent = new RenderConstrainedOverflowBox(
final RenderBox parent = new RenderConstrainedOverflowBox(
minWidth: 500.0,
maxWidth: 500.0,
minHeight: 0.0,
......@@ -72,7 +72,7 @@ void main() {
test('LimitedBox: no child', () {
RenderBox box;
RenderBox parent = new RenderConstrainedOverflowBox(
final RenderBox parent = new RenderConstrainedOverflowBox(
minWidth: 10.0,
maxWidth: 500.0,
minHeight: 0.0,
......
......@@ -355,8 +355,8 @@ class _TestRecordingCanvasPatternMatcher extends Matcher implements PaintPattern
description.write('painted nothing.');
return false;
}
Iterator<_PaintPredicate> predicate = _predicates.iterator;
Iterator<Invocation> call = calls.iterator..moveNext();
final Iterator<_PaintPredicate> predicate = _predicates.iterator;
final Iterator<Invocation> call = calls.iterator..moveNext();
try {
while (predicate.moveNext()) {
if (call.current == null) {
......@@ -473,7 +473,7 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
@override
void match(Iterator<Invocation> call) {
int others = 0;
Invocation firstCall = call.current;
final Invocation firstCall = call.current;
while (!call.current.isMethod || call.current.memberName != symbol) {
others += 1;
if (!call.moveNext())
......@@ -506,7 +506,7 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
@override
String toString() {
List<String> description = <String>[];
final List<String> description = <String>[];
debugFillDescription(description);
String result = name;
if (description.isNotEmpty)
......@@ -680,7 +680,7 @@ class _FunctionPaintPredicate extends _PaintPredicate {
@override
void match(Iterator<Invocation> call) {
int others = 0;
Invocation firstCall = call.current;
final Invocation firstCall = call.current;
while (!call.current.isMethod || call.current.memberName != symbol) {
others += 1;
if (!call.moveNext())
......@@ -701,7 +701,7 @@ class _FunctionPaintPredicate extends _PaintPredicate {
@override
String toString() {
List<String> adjectives = <String>[];
final List<String> adjectives = <String>[];
for (int index = 0; index < arguments.length; index += 1)
adjectives.add(arguments[index] != null ? _valueName(arguments[index]) : '...');
return '${_symbolName(symbol)}(${adjectives.join(", ")})';
......@@ -712,7 +712,7 @@ class _SaveRestorePairPaintPredicate extends _PaintPredicate {
@override
void match(Iterator<Invocation> call) {
int others = 0;
Invocation firstCall = call.current;
final Invocation firstCall = call.current;
while (!call.current.isMethod || call.current.memberName != #save) {
others += 1;
if (!call.moveNext())
......
......@@ -36,7 +36,7 @@ void main() {
RenderBox child1, child2;
bool movedChild1 = false;
bool movedChild2 = false;
RenderFlex block = new RenderFlex();
final RenderFlex block = new RenderFlex();
block.add(child1 = new RenderLayoutTestBox(() { movedChild1 = true; }));
block.add(child2 = new RenderLayoutTestBox(() { movedChild2 = true; }));
......
......@@ -45,7 +45,7 @@ class RealRoot extends AbstractNode {
void main() {
test("non-RenderObject roots", () {
RenderPositionedBox child;
RealRoot root = new RealRoot(
final RealRoot root = new RealRoot(
child = new RenderPositionedBox(
alignment: FractionalOffset.center,
child: new RenderSizedBox(const Size(100.0, 100.0))
......
......@@ -13,7 +13,7 @@ void main() {
RenderBox child;
bool painted = false;
// incoming constraints are tight 800x600
RenderBox root = new RenderPositionedBox(
final RenderBox root = new RenderPositionedBox(
child: new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 800.0),
child: new RenderOffstage(
......
......@@ -13,37 +13,37 @@ const String _kText = 'I polished up that handle so carefullee\nThat now I am th
void main() {
test('getOffsetForCaret control test', () {
RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
final RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
layout(paragraph);
Rect caret = new Rect.fromLTWH(0.0, 0.0, 2.0, 20.0);
final Rect caret = new Rect.fromLTWH(0.0, 0.0, 2.0, 20.0);
Offset offset5 = paragraph.getOffsetForCaret(const TextPosition(offset: 5), caret);
final Offset offset5 = paragraph.getOffsetForCaret(const TextPosition(offset: 5), caret);
expect(offset5.dx, greaterThan(0.0));
Offset offset25 = paragraph.getOffsetForCaret(const TextPosition(offset: 25), caret);
final Offset offset25 = paragraph.getOffsetForCaret(const TextPosition(offset: 25), caret);
expect(offset25.dx, greaterThan(offset5.dx));
Offset offset50 = paragraph.getOffsetForCaret(const TextPosition(offset: 50), caret);
final Offset offset50 = paragraph.getOffsetForCaret(const TextPosition(offset: 50), caret);
expect(offset50.dy, greaterThan(offset5.dy));
});
test('getPositionForOffset control test', () {
RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
final RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
layout(paragraph);
TextPosition position20 = paragraph.getPositionForOffset(const Offset(20.0, 5.0));
final TextPosition position20 = paragraph.getPositionForOffset(const Offset(20.0, 5.0));
expect(position20.offset, greaterThan(0.0));
TextPosition position40 = paragraph.getPositionForOffset(const Offset(40.0, 5.0));
final TextPosition position40 = paragraph.getPositionForOffset(const Offset(40.0, 5.0));
expect(position40.offset, greaterThan(position20.offset));
TextPosition positionBelow = paragraph.getPositionForOffset(const Offset(5.0, 20.0));
final TextPosition positionBelow = paragraph.getPositionForOffset(const Offset(5.0, 20.0));
expect(positionBelow.offset, greaterThan(position40.offset));
});
test('getBoxesForSelection control test', () {
RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
final RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
layout(paragraph);
List<ui.TextBox> boxes = paragraph.getBoxesForSelection(
......@@ -60,21 +60,21 @@ void main() {
});
test('getWordBoundary control test', () {
RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
final RenderParagraph paragraph = new RenderParagraph(const TextSpan(text: _kText));
layout(paragraph);
TextRange range5 = paragraph.getWordBoundary(const TextPosition(offset: 5));
final TextRange range5 = paragraph.getWordBoundary(const TextPosition(offset: 5));
expect(range5.textInside(_kText), equals('polished'));
TextRange range50 = paragraph.getWordBoundary(const TextPosition(offset: 50));
final TextRange range50 = paragraph.getWordBoundary(const TextPosition(offset: 50));
expect(range50.textInside(_kText), equals(' '));
TextRange range85 = paragraph.getWordBoundary(const TextPosition(offset: 75));
final TextRange range85 = paragraph.getWordBoundary(const TextPosition(offset: 75));
expect(range85.textInside(_kText), equals('Queen\'s'));
});
test('overflow test', () {
RenderParagraph paragraph = new RenderParagraph(
final RenderParagraph paragraph = new RenderParagraph(
const TextSpan(text: 'This is\na wrapping test. It should wrap at manual newlines, and if softWrap is true, also at spaces.'),
maxLines: 1,
softWrap: true,
......@@ -90,7 +90,7 @@ void main() {
// Lay out in a narrow box to force wrapping.
layout(paragraph, constraints: const BoxConstraints(maxWidth: 50.0));
double lineHeight = paragraph.size.height;
final double lineHeight = paragraph.size.height;
relayoutWith(maxLines: 3, softWrap: true, overflow: TextOverflow.clip);
expect(paragraph.size.height, equals(3 * lineHeight));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment