Commit 21d74257 authored by Jason Simmons's avatar Jason Simmons

Merge pull request #1610 from jason-simmons/slice_border_warning

Fix warnings seen when running skyanalyzer in strong mode
parents 1f40d96f 5b72a2fd
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/rendering.dart';
import 'lib/sector_layout.dart';
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:ui' as ui;
import 'package:flutter/animation.dart';
import 'package:flutter/rendering.dart';
......
......@@ -6,15 +6,15 @@ void main() {
Document document = new Document();
test("should throw with invalid arguments", () {
var parent = document.createElement("div");
var child = document.createElement("div");
Element parent = document.createElement("div");
Element child = document.createElement("div");
parent.appendChild(child);
// TODO(eseidel): This should throw!
// expect(() {
// parent.insertBefore([parent]);
// }, throws);
expect(() {
child.insertBefore([parent]);
child.insertBefore(<Node>[parent]);
}, throws);
});
......
......@@ -5,36 +5,36 @@ import 'package:test/test.dart';
import 'dom_utils.dart';
void main() {
var document = new Document();
Document document = new Document();
test("should replace elements", () {
var parent = document.createElement("div");
var oldChild = parent.appendChild(document.createElement("div"));
var newChild = document.createElement("div");
oldChild.replaceWith([newChild]);
Element parent = document.createElement("div");
Element oldChild = parent.appendChild(document.createElement("div"));
Element newChild = document.createElement("div");
oldChild.replaceWith(<Node>[newChild]);
expect(oldChild.parentNode, isNull);
expect(newChild.parentNode, equals(parent));
});
test("should replace text", () {
var parent = document.createElement("div");
var oldChild = parent.appendChild(document.createText(" it's a text "));
var newChild = document.createElement("div");
oldChild.replaceWith([newChild]);
Element parent = document.createElement("div");
Node oldChild = parent.appendChild(document.createText(" it's a text "));
Element newChild = document.createElement("div");
oldChild.replaceWith(<Node>[newChild]);
expect(oldChild.parentNode, isNull);
expect(newChild.parentNode, equals(parent));
});
test("should replace children with a fragment", () {
var fragment = document.createDocumentFragment();
var child1 = fragment.appendChild(document.createElement("div"));
var child2 = fragment.appendChild(document.createText(" text "));
var child3 = fragment.appendChild(document.createText(" "));
var child4 = fragment.appendChild(document.createElement("div"));
var parent = document.createElement("div");
var oldChild = parent.appendChild(document.createElement("div"));
var lastChild = parent.appendChild(document.createElement("div"));
oldChild.replaceWith([fragment]);
DocumentFragment fragment = document.createDocumentFragment();
Element child1 = fragment.appendChild(document.createElement("div"));
Node child2 = fragment.appendChild(document.createText(" text "));
Node child3 = fragment.appendChild(document.createText(" "));
Element child4 = fragment.appendChild(document.createElement("div"));
Element parent = document.createElement("div");
Element oldChild = parent.appendChild(document.createElement("div"));
Element lastChild = parent.appendChild(document.createElement("div"));
oldChild.replaceWith(<Node>[fragment]);
expect(child1.parentNode, equals(parent));
expect(child2.parentNode, equals(parent));
expect(child3.parentNode, equals(parent));
......
......@@ -26,7 +26,7 @@ void main() {
longPressRecognized = true;
};
new FakeAsync().run((async) {
new FakeAsync().run((FakeAsync async) {
longPress.addPointer(down);
GestureArena.instance.close(5);
expect(longPressRecognized, isFalse);
......@@ -50,7 +50,7 @@ void main() {
longPressRecognized = true;
};
new FakeAsync().run((async) {
new FakeAsync().run((FakeAsync async) {
longPress.addPointer(down);
GestureArena.instance.close(5);
expect(longPressRecognized, isFalse);
......@@ -82,7 +82,7 @@ void main() {
longPressRecognized = true;
};
new FakeAsync().run((async) {
new FakeAsync().run((FakeAsync async) {
showPress.addPointer(down);
longPress.addPointer(down);
GestureArena.instance.close(5);
......
......@@ -26,7 +26,7 @@ void main() {
showPressRecognized = true;
};
new FakeAsync().run((async) {
new FakeAsync().run((FakeAsync async) {
showPress.addPointer(down);
GestureArena.instance.close(5);
expect(showPressRecognized, isFalse);
......@@ -48,7 +48,7 @@ void main() {
showPressRecognized = true;
};
new FakeAsync().run((async) {
new FakeAsync().run((FakeAsync async) {
showPress.addPointer(down);
GestureArena.instance.close(5);
expect(showPressRecognized, isFalse);
......
......@@ -11,7 +11,7 @@ void main() {
backgroundColor: const Color(0xFF00FF00),
gradient: new RadialGradient(
center: Point.origin, radius: 500.0,
colors: [Colors.yellow[500], Colors.blue[500]]),
colors: <Color>[Colors.yellow[500], Colors.blue[500]]),
boxShadow: shadows[3])
);
layout(root);
......@@ -34,7 +34,7 @@ void main() {
child: inner
);
RenderBox flex = new RenderFlex(
children: [padding],
children: <RenderBox>[padding],
direction: FlexDirection.vertical,
alignItems: FlexAlignItems.stretch
);
......
......@@ -6,7 +6,7 @@ import 'rendering_tester.dart';
void main() {
test('Overconstrained flex', () {
RenderDecoratedBox box = new RenderDecoratedBox(decoration: new BoxDecoration());
RenderFlex flex = new RenderFlex(children: [ box ]);
RenderFlex flex = new RenderFlex(children: <RenderBox>[box]);
layout(flex, constraints: const BoxConstraints(
minWidth: 200.0, maxWidth: 100.0, minHeight: 200.0, maxHeight: 100.0)
);
......@@ -24,7 +24,7 @@ void main() {
test('Parent data', () {
RenderDecoratedBox box1 = new RenderDecoratedBox(decoration: new BoxDecoration());
RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: new BoxDecoration());
RenderFlex flex = new RenderFlex(children: [ box1, box2 ]);
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)
);
......@@ -33,7 +33,8 @@ void main() {
expect(box2.size.width, equals(0.0));
expect(box2.size.height, equals(0.0));
box2.parentData.flex = 1;
final FlexParentData box2ParentData = box2.parentData;
box2ParentData.flex = 1;
flex.markNeedsLayout();
pumpFrame();
expect(box1.size.width, equals(0.0));
......@@ -47,8 +48,9 @@ void main() {
RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: new BoxDecoration());
RenderFlex flex = new RenderFlex();
flex.setupParentData(box2);
box2.parentData.flex = 2;
flex.addAll([box1, box2]);
final FlexParentData box2ParentData = box2.parentData;
box2ParentData.flex = 2;
flex.addAll(<RenderBox>[box1, box2]);
layout(flex, constraints: const BoxConstraints(
minWidth: 0.0, maxWidth: 100.0, minHeight: 0.0, maxHeight: 100.0)
);
......
......@@ -5,7 +5,7 @@ import 'rendering_tester.dart';
void main() {
test('Basic grid layout test', () {
List<RenderBox> children = [
List<RenderBox> children = <RenderBox>[
new RenderDecoratedBox(decoration: new BoxDecoration()),
new RenderDecoratedBox(decoration: new BoxDecoration()),
new RenderDecoratedBox(decoration: new BoxDecoration()),
......@@ -15,7 +15,7 @@ void main() {
RenderGrid grid = new RenderGrid(children: children, maxChildExtent: 100.0);
layout(grid, constraints: const BoxConstraints(maxWidth: 200.0));
children.forEach((child) {
children.forEach((RenderBox child) {
expect(child.size.width, equals(100.0), reason: "child width");
expect(child.size.height, equals(100.0), reason: "child height");
});
......@@ -29,7 +29,7 @@ void main() {
pumpFrame();
children.forEach((child) {
children.forEach((RenderBox child) {
expect(child.size.width, equals(50.0), reason: "child width");
expect(child.size.height, equals(50.0), reason: "child height");
});
......
......@@ -19,7 +19,7 @@ void main() {
backgroundColor: const Color(0xFFFF0000)
));
RenderBox stack = new RenderStack(children: [red, green]);
RenderBox stack = new RenderStack(children: <RenderBox>[red, green]);
(green.parentData as StackParentData)
..top = 0.0
..right = 0.0
......
......@@ -10,7 +10,7 @@ void main() {
test('Cannot scroll a non-overflowing block', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new Block([
new Block(<Widget>[
new Container(
height: 200.0, // less than 600, the height of the test area
child: new Text('Hello')
......@@ -37,7 +37,7 @@ void main() {
test('Can scroll an overflowing block', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new Block([
new Block(<Widget>[
new Container(
height: 2000.0, // more than 600, the height of the test area
child: new Text('Hello')
......
......@@ -6,7 +6,7 @@ import 'widget_tester.dart';
void main() {
test('Can be placed in an infinte box', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new Block([new Center()]));
tester.pumpWidget(new Block(<Widget>[new Center()]));
});
});
}
......@@ -11,7 +11,7 @@ void main() {
Key keyB = new GlobalKey();
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
top: 100.0,
left: 100.0,
......
......@@ -8,7 +8,7 @@ void main() {
testWidgets((WidgetTester tester) {
DateTime currentValue;
Widget widget = new Block([
Widget widget = new Block(<Widget>[
new DatePicker(
selectedDate: new DateTime.utc(2015, 6, 9, 7, 12),
firstDate: new DateTime.utc(2013),
......
......@@ -8,7 +8,7 @@ import 'widget_tester.dart';
const double itemExtent = 100.0;
ScrollDirection scrollDirection = ScrollDirection.vertical;
DismissDirection dismissDirection = DismissDirection.horizontal;
List<int> dismissedItems = [];
List<int> dismissedItems = <int>[];
void handleOnResized(item) {
expect(dismissedItems.contains(item), isFalse);
......@@ -117,7 +117,7 @@ void main() {
testWidgets((WidgetTester tester) {
scrollDirection = ScrollDirection.vertical;
dismissDirection = DismissDirection.horizontal;
dismissedItems = [];
dismissedItems = <int>[];
tester.pumpWidget(widgetBuilder());
expect(dismissedItems, isEmpty);
......@@ -136,7 +136,7 @@ void main() {
testWidgets((WidgetTester tester) {
scrollDirection = ScrollDirection.horizontal;
dismissDirection = DismissDirection.vertical;
dismissedItems = [];
dismissedItems = <int>[];
tester.pumpWidget(widgetBuilder());
expect(dismissedItems, isEmpty);
......@@ -155,7 +155,7 @@ void main() {
testWidgets((WidgetTester tester) {
scrollDirection = ScrollDirection.vertical;
dismissDirection = DismissDirection.left;
dismissedItems = [];
dismissedItems = <int>[];
tester.pumpWidget(widgetBuilder());
expect(dismissedItems, isEmpty);
......@@ -174,7 +174,7 @@ void main() {
testWidgets((WidgetTester tester) {
scrollDirection = ScrollDirection.vertical;
dismissDirection = DismissDirection.right;
dismissedItems = [];
dismissedItems = <int>[];
tester.pumpWidget(widgetBuilder());
expect(dismissedItems, isEmpty);
......@@ -193,7 +193,7 @@ void main() {
testWidgets((WidgetTester tester) {
scrollDirection = ScrollDirection.horizontal;
dismissDirection = DismissDirection.up;
dismissedItems = [];
dismissedItems = <int>[];
tester.pumpWidget(widgetBuilder());
expect(dismissedItems, isEmpty);
......@@ -212,7 +212,7 @@ void main() {
testWidgets((WidgetTester tester) {
scrollDirection = ScrollDirection.horizontal;
dismissDirection = DismissDirection.down;
dismissedItems = [];
dismissedItems = <int>[];
tester.pumpWidget(widgetBuilder());
expect(dismissedItems, isEmpty);
......@@ -233,7 +233,7 @@ void main() {
testWidgets((WidgetTester tester) {
scrollDirection = ScrollDirection.horizontal;
dismissDirection = DismissDirection.down;
dismissedItems = [];
dismissedItems = <int>[];
tester.pumpWidget(widgetBuilder());
Element itemElement = tester.findText('0');
......@@ -261,7 +261,7 @@ void main() {
child: new Container(
width: 100.0,
height: 1000.0,
child: new Column([
child: new Column(<Widget>[
new Test1215DismissableComponent('1'),
new Test1215DismissableComponent('2')
])
......
......@@ -12,8 +12,8 @@ void main() {
List accepted = [];
tester.pumpWidget(new Navigator(
routes: {
'/': (RouteArguments args) { return new Column([
routes: <String, RouteBuilder>{
'/': (RouteArguments args) { return new Column(<Widget>[
new Draggable(
navigator: args.navigator,
data: 1,
......
......@@ -11,7 +11,7 @@ void main() {
NavigatorState navigator;
tester.pumpWidget(
new MaterialApp(
routes: {
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
navigator = args.navigator;
new Container();
......@@ -40,7 +40,7 @@ void main() {
tester.pumpWidget(new Container()); // throw away the old App and its Navigator
tester.pumpWidget(
new MaterialApp(
routes: {
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
navigator = args.navigator;
new Container();
......
......@@ -8,7 +8,7 @@ class Item {
GlobalKey key2 = new GlobalKey();
String toString() => "Item($key1, $key2)";
}
List<Item> items = [new Item(), new Item()];
List<Item> items = <Item>[new Item(), new Item()];
class StatefulLeaf extends StatefulComponent {
StatefulLeaf({ GlobalKey key }) : super(key: key);
......@@ -34,7 +34,7 @@ class KeyedWrapper extends StatelessComponent {
}
Widget builder() {
return new Column([
return new Column(<Widget>[
new KeyedWrapper(items[1].key1, items[1].key2),
new KeyedWrapper(items[0].key1, items[0].key2)
]);
......
......@@ -12,11 +12,11 @@ void main() {
decoration: const BoxDecoration(
backgroundColor: const Color(0xFF00FF00)
),
child: new Stack([
child: new Stack(<Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new Column([
child: new Column(<Widget>[
new GestureDetector(
onTap: () {
didReceiveTap = true;
......
......@@ -23,7 +23,7 @@ void main() {
GlobalKey keyB = new GlobalKey();
tester.pumpWidget(
new Focus(
child: new Column([
child: new Column(<Widget>[
// reverse these when you fix https://github.com/flutter/engine/issues/1495
new TestFocusable('b', 'B FOCUSED', keyB),
new TestFocusable('a', 'A FOCUSED', keyA),
......
......@@ -36,7 +36,7 @@ void main() {
tester.pumpWidget(builder());
StatefulComponentElement element = tester.findElement((element) => element.widget is FlipComponent);
StatefulComponentElement element = tester.findElement((Element element) => element.widget is FlipComponent);
FlipComponentState testComponent = element.state;
expect(callbackTracker, equals([0, 1, 2, 3, 4, 5]));
......
......@@ -37,7 +37,7 @@ void main() {
child: new Input(
key: inputKey,
placeholder: 'Placeholder',
onChanged: (value) { inputValue = value; }
onChanged: (String value) { inputValue = value; }
)
);
}
......
......@@ -31,7 +31,7 @@ void main() {
tester.pumpWidget(builder());
StatefulComponentElement element = tester.findElement((element) => element.widget is FlipComponent);
StatefulComponentElement element = tester.findElement((Element element) => element.widget is FlipComponent);
FlipComponentState testComponent = element.state;
expect(callbackTracker, equals([0, 1, 2, 3, 4, 5]));
......
......@@ -7,7 +7,7 @@ import 'widget_tester.dart';
void checkTree(WidgetTester tester, List<BoxDecoration> expectedDecorations) {
MultiChildRenderObjectElement element =
tester.findElement((element) => element is MultiChildRenderObjectElement);
tester.findElement((Element element) => element is MultiChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderStack, isTrue);
RenderStack renderObject = element.renderObject;
......@@ -17,7 +17,8 @@ void checkTree(WidgetTester tester, List<BoxDecoration> expectedDecorations) {
expect(child is RenderDecoratedBox, isTrue);
RenderDecoratedBox decoratedBox = child;
expect(decoratedBox.decoration, equals(decoration));
child = decoratedBox.parentData.nextSibling;
final StackParentData decoratedBoxParentData = decoratedBox.parentData;
child = decoratedBoxParentData.nextSibling;
}
expect(child, isNull);
} catch (e) {
......@@ -31,67 +32,67 @@ void main() {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new DecoratedBox(decoration: kBoxDecorationB),
new DecoratedBox(decoration: kBoxDecorationC),
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new DecoratedBox(decoration: kBoxDecorationC),
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB),
new DecoratedBox(decoration: kBoxDecorationC),
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB),
new DecoratedBox(decoration: kBoxDecorationC),
new DecoratedBox(key: new Key('a'), decoration: kBoxDecorationA),
])
);
checkTree(tester, [kBoxDecorationB, kBoxDecorationC, kBoxDecorationA]);
checkTree(tester, <BoxDecoration>[kBoxDecorationB, kBoxDecorationC, kBoxDecorationA]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(key: new Key('a'), decoration: kBoxDecorationA),
new DecoratedBox(decoration: kBoxDecorationC),
new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB),
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationC, kBoxDecorationB]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationC, kBoxDecorationB]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationC),
])
);
checkTree(tester, [kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationC]);
tester.pumpWidget(
new Stack([])
new Stack(<Widget>[])
);
checkTree(tester, []);
checkTree(tester, <BoxDecoration>[]);
});
});
......@@ -100,17 +101,17 @@ void main() {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new DecoratedBox(decoration: kBoxDecorationB),
new DecoratedBox(decoration: kBoxDecorationC),
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new Container(
child: new DecoratedBox(decoration: kBoxDecorationB)
......@@ -119,10 +120,10 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new Container(
child: new Container(
......@@ -133,10 +134,10 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Container(
child: new Container(
child: new DecoratedBox(decoration: kBoxDecorationB)
......@@ -149,10 +150,10 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Container(
child: new DecoratedBox(decoration: kBoxDecorationB)
),
......@@ -163,10 +164,10 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Container(
key: new Key('b'),
child: new DecoratedBox(decoration: kBoxDecorationB)
......@@ -178,10 +179,10 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationB, kBoxDecorationA]);
checkTree(tester, <BoxDecoration>[kBoxDecorationB, kBoxDecorationA]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Container(
key: new Key('a'),
child: new DecoratedBox(decoration: kBoxDecorationA)
......@@ -193,29 +194,29 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationB]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationB]);
tester.pumpWidget(
new Stack([ ])
new Stack(<Widget>[])
);
checkTree(tester, []);
checkTree(tester, <BoxDecoration>[]);
});
});
test('MultiChildRenderObjectElement with stateful components', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new DecoratedBox(decoration: kBoxDecorationB),
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationB]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationB]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new FlipComponent(
left: new DecoratedBox(decoration: kBoxDecorationA),
right: new DecoratedBox(decoration: kBoxDecorationB)
......@@ -224,15 +225,15 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationA, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA, kBoxDecorationC]);
flipStatefulComponent(tester);
tester.pump();
checkTree(tester, [kBoxDecorationB, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationB, kBoxDecorationC]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new FlipComponent(
left: new DecoratedBox(decoration: kBoxDecorationA),
right: new DecoratedBox(decoration: kBoxDecorationB)
......@@ -240,15 +241,15 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationB]);
checkTree(tester, <BoxDecoration>[kBoxDecorationB]);
flipStatefulComponent(tester);
tester.pump();
checkTree(tester, [kBoxDecorationA]);
checkTree(tester, <BoxDecoration>[kBoxDecorationA]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new FlipComponent(
key: new Key('flip'),
left: new DecoratedBox(decoration: kBoxDecorationA),
......@@ -258,7 +259,7 @@ void main() {
);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(key: new Key('c'), decoration: kBoxDecorationC),
new FlipComponent(
key: new Key('flip'),
......@@ -268,15 +269,15 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationC, kBoxDecorationA]);
checkTree(tester, <BoxDecoration>[kBoxDecorationC, kBoxDecorationA]);
flipStatefulComponent(tester);
tester.pump();
checkTree(tester, [kBoxDecorationC, kBoxDecorationB]);
checkTree(tester, <BoxDecoration>[kBoxDecorationC, kBoxDecorationB]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new FlipComponent(
key: new Key('flip'),
left: new DecoratedBox(decoration: kBoxDecorationA),
......@@ -286,7 +287,7 @@ void main() {
])
);
checkTree(tester, [kBoxDecorationB, kBoxDecorationC]);
checkTree(tester, <BoxDecoration>[kBoxDecorationB, kBoxDecorationC]);
});
});
}
......@@ -16,7 +16,7 @@ class TestParentData {
void checkTree(WidgetTester tester, List<TestParentData> expectedParentData) {
MultiChildRenderObjectElement element =
tester.findElement((element) => element is MultiChildRenderObjectElement);
tester.findElement((Element element) => element is MultiChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderStack, isTrue);
RenderStack renderObject = element.renderObject;
......@@ -31,7 +31,7 @@ void checkTree(WidgetTester tester, List<TestParentData> expectedParentData) {
expect(parentData.right, equals(expected.right));
expect(parentData.bottom, equals(expected.bottom));
expect(parentData.left, equals(expected.left));
child = decoratedBox.parentData.nextSibling;
child = (decoratedBox.parentData as StackParentData).nextSibling;
}
expect(child, isNull);
} catch (e) {
......@@ -61,7 +61,7 @@ void main() {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new Positioned(
top: 10.0,
......@@ -72,14 +72,14 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
kNonPositioned,
new TestParentData(top: 10.0, left: 10.0),
kNonPositioned,
]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
bottom: 5.0,
right: 7.0,
......@@ -94,7 +94,7 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
new TestParentData(bottom: 5.0, right: 7.0),
new TestParentData(top: 10.0, left: 10.0),
kNonPositioned,
......@@ -105,7 +105,7 @@ void main() {
DecoratedBox kDecoratedBoxC = new DecoratedBox(decoration: kBoxDecorationC);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
bottom: 5.0,
right: 7.0,
......@@ -120,14 +120,14 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
new TestParentData(bottom: 5.0, right: 7.0),
new TestParentData(top: 10.0, left: 10.0),
kNonPositioned,
]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
bottom: 6.0,
right: 8.0,
......@@ -142,14 +142,14 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
new TestParentData(bottom: 6.0, right: 8.0),
new TestParentData(left: 10.0, right: 10.0),
kNonPositioned,
]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
kDecoratedBoxA,
new Positioned(
left: 11.0,
......@@ -160,14 +160,14 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
kNonPositioned,
new TestParentData(left: 11.0, right: 12.0),
kNonPositioned,
]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
kDecoratedBoxA,
new Positioned(
right: 10.0,
......@@ -182,14 +182,14 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
kNonPositioned,
new TestParentData(right: 10.0),
new TestParentData(top: 8.0),
]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
right: 10.0,
child: new FlipComponent(left: kDecoratedBoxA, right: kDecoratedBoxB)
......@@ -197,19 +197,19 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
new TestParentData(right: 10.0),
]);
flipStatefulComponent(tester);
tester.pump();
checkTree(tester, [
checkTree(tester, <TestParentData>[
new TestParentData(right: 10.0),
]);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
top: 7.0,
child: new FlipComponent(left: kDecoratedBoxA, right: kDecoratedBoxB)
......@@ -217,22 +217,22 @@ void main() {
])
);
checkTree(tester, [
checkTree(tester, <TestParentData>[
new TestParentData(top: 7.0),
]);
flipStatefulComponent(tester);
tester.pump();
checkTree(tester, [
checkTree(tester, <TestParentData>[
new TestParentData(top: 7.0),
]);
tester.pumpWidget(
new Stack([])
new Stack(<Widget>[])
);
checkTree(tester, []);
checkTree(tester, <TestParentData>[]);
});
});
......@@ -241,7 +241,7 @@ void main() {
expect(cachedException, isNull);
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
top: 5.0,
bottom: 8.0,
......@@ -257,14 +257,14 @@ void main() {
expect(cachedException, isNotNull);
cachedException = null;
tester.pumpWidget(new Stack([]));
tester.pumpWidget(new Stack(<Widget>[]));
checkTree(tester, []);
checkTree(tester, <TestParentData>[]);
expect(cachedException, isNull);
tester.pumpWidget(
new Container(
child: new Flex([
child: new Flex(<Widget>[
new Positioned(
top: 6.0,
left: 7.0,
......@@ -278,10 +278,10 @@ void main() {
cachedException = null;
tester.pumpWidget(
new Stack([])
new Stack(<Widget>[])
);
checkTree(tester, []);
checkTree(tester, <TestParentData>[]);
});
});
}
......@@ -8,11 +8,11 @@ import 'widget_tester.dart';
void main() {
test('LinearProgressIndicator changes when its value changes', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new Block([new LinearProgressIndicator(value: 0.0)]));
tester.pumpWidget(new Block(<Widget>[new LinearProgressIndicator(value: 0.0)]));
List<Layer> layers1 = tester.layers;
tester.pumpWidget(new Block([new LinearProgressIndicator(value: 0.5)]));
tester.pumpWidget(new Block(<Widget>[new LinearProgressIndicator(value: 0.5)]));
List<Layer> layers2 = tester.layers;
expect(layers1, isNot(equals(layers2)));
......
......@@ -19,7 +19,7 @@ void main() {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new DecoratedBox(decoration: kBoxDecorationA));
OneChildRenderObjectElement element =
tester.findElement((element) => element is OneChildRenderObjectElement);
tester.findElement((Element element) => element is OneChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......@@ -27,7 +27,7 @@ void main() {
expect(renderObject.position, equals(BoxDecorationPosition.background));
tester.pumpWidget(new DecoratedBox(decoration: kBoxDecorationB));
element = tester.findElement((element) => element is OneChildRenderObjectElement);
element = tester.findElement((Element element) => element is OneChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
renderObject = element.renderObject;
......@@ -41,7 +41,7 @@ void main() {
void checkFullTree() {
OneChildRenderObjectElement element =
tester.findElement((element) => element is OneChildRenderObjectElement);
tester.findElement((Element element) => element is OneChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......@@ -57,7 +57,7 @@ void main() {
void childBareTree() {
OneChildRenderObjectElement element =
tester.findElement((element) => element is OneChildRenderObjectElement);
tester.findElement((Element element) => element is OneChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......@@ -136,7 +136,7 @@ void main() {
));
OneChildRenderObjectElement element =
tester.findElement((element) => element is OneChildRenderObjectElement);
tester.findElement((Element element) => element is OneChildRenderObjectElement);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox parent = element.renderObject;
expect(parent.child is RenderDecoratedBox, isTrue);
......@@ -152,7 +152,7 @@ void main() {
));
element =
tester.findElement((element) => element is OneChildRenderObjectElement);
tester.findElement((Element element) => element is OneChildRenderObjectElement);
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, equals(parent));
expect(parent.child, isNull);
......
......@@ -33,7 +33,7 @@ void main() {
StateMarker grandchild = new StateMarker();
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Container(
child: new StateMarker(key: left)
),
......@@ -55,7 +55,7 @@ void main() {
StateMarker newGrandchild = new StateMarker();
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Container(
child: new StateMarker(
key: right,
......@@ -101,7 +101,7 @@ void main() {
(key.currentState as StateMarkerState).marker = "marked";
tester.pumpWidget(new ScrollableList<int>(
items: [0],
items: <int>[0],
itemExtent: 100.0,
itemBuilder: (BuildContext context, int item) {
return new Container(
......
......@@ -27,7 +27,7 @@ class ChangerState extends State<Changer> {
void test() { setState(() { _state = true; }); }
Widget build(BuildContext) => _state ? new Wrapper(config.child) : config.child;
Widget build(BuildContext context) => _state ? new Wrapper(config.child) : config.child;
}
class Wrapper extends StatelessComponent {
......
......@@ -10,8 +10,8 @@ ui.Shader createShader(Rect bounds) {
return new LinearGradient(
begin: Point.origin,
end: new Point(0.0, bounds.height),
colors: [const Color(0x00FFFFFF), const Color(0xFFFFFFFF)],
stops: [0.1, 0.35]
colors: <Color>[const Color(0x00FFFFFF), const Color(0xFFFFFFFF)],
stops: <double>[0.1, 0.35]
)
.createShader();
}
......
......@@ -8,10 +8,10 @@ import 'widget_tester.dart';
void main() {
test('SizeObserver notices zero size', () {
testWidgets((WidgetTester tester) {
List results = [];
List<Size> results = <Size>[];
tester.pumpWidget(new Center(
child: new SizeObserver(
callback: (size) { results.add(size); },
callback: (Size size) { results.add(size); },
child: new Container(width:0.0, height:0.0)
)
));
......@@ -20,7 +20,7 @@ void main() {
expect(results, equals([Size.zero]));
tester.pumpWidget(new Center(
child: new SizeObserver(
callback: (size) { results.add(size); },
callback: (Size size) { results.add(size); },
child: new Container(width:100.0, height:0.0)
)
));
......@@ -29,7 +29,7 @@ void main() {
expect(results, equals([Size.zero, const Size(100.0, 0.0)]));
tester.pumpWidget(new Center(
child: new SizeObserver(
callback: (size) { results.add(size); },
callback: (Size size) { results.add(size); },
child: new Container(width:0.0, height:0.0)
)
));
......@@ -38,7 +38,7 @@ void main() {
expect(results, equals([Size.zero, const Size(100.0, 0.0), Size.zero]));
tester.pumpWidget(new Center(
child: new SizeObserver(
callback: (size) { results.add(size); },
callback: (Size size) { results.add(size); },
child: new Container(width:0.0, height:0.0)
)
));
......
......@@ -11,7 +11,7 @@ void main() {
Key tapTarget = new Key('tap-target');
tester.pumpWidget(new MaterialApp(
routes: {
routes: <String, RouteBuilder>{
'/': (RouteArguments args) {
return new GestureDetector(
onTap: () {
......
......@@ -35,7 +35,7 @@ Widget buildFrame() {
key: scrollableListKey,
snapOffsetCallback: snapOffsetCallback,
scrollDirection: scrollDirection,
items: [0, 1, 2, 3, 4, 5, 7, 8, 9],
items: <int>[0, 1, 2, 3, 4, 5, 7, 8, 9],
itemBuilder: buildItem,
itemExtent: itemExtent
)
......
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:test/test.dart';
......@@ -6,13 +7,13 @@ import 'widget_tester.dart';
void main() {
test('Can construct an empty Stack', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new Stack([]));
tester.pumpWidget(new Stack(<Widget>[]));
});
});
test('Can construct an empty Centered Stack', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new Center(child: new Stack([])));
tester.pumpWidget(new Center(child: new Stack(<Widget>[])));
});
});
......@@ -21,7 +22,7 @@ void main() {
Key key = new Key('container');
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
left: 10.0,
child: new Container(
......@@ -33,14 +34,18 @@ void main() {
])
);
Element container = tester.findElementByKey(key);
expect(container.renderObject.parentData.top, isNull);
expect(container.renderObject.parentData.right, isNull);
expect(container.renderObject.parentData.bottom, isNull);
expect(container.renderObject.parentData.left, equals(10.0));
Element container;
StackParentData parentData;
container = tester.findElementByKey(key);
parentData = container.renderObject.parentData;
expect(parentData.top, isNull);
expect(parentData.right, isNull);
expect(parentData.bottom, isNull);
expect(parentData.left, equals(10.0));
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
right: 10.0,
child: new Container(
......@@ -53,10 +58,11 @@ void main() {
);
container = tester.findElementByKey(key);
expect(container.renderObject.parentData.top, isNull);
expect(container.renderObject.parentData.right, equals(10.0));
expect(container.renderObject.parentData.bottom, isNull);
expect(container.renderObject.parentData.left, isNull);
parentData = container.renderObject.parentData;
expect(parentData.top, isNull);
expect(parentData.right, equals(10.0));
expect(parentData.bottom, isNull);
expect(parentData.left, isNull);
});
});
......@@ -65,21 +71,24 @@ void main() {
Key key = new Key('container');
Container container = new Container(key: key, width: 10.0, height: 10.0);
tester.pumpWidget(new Stack([ new Positioned(left: 10.0, child: container) ]));
tester.pumpWidget(new Stack(<Widget>[ new Positioned(left: 10.0, child: container) ]));
Element containerElement = tester.findElementByKey(key);
expect(containerElement.renderObject.parentData.top, isNull);
expect(containerElement.renderObject.parentData.right, isNull);
expect(containerElement.renderObject.parentData.bottom, isNull);
expect(containerElement.renderObject.parentData.left, equals(10.0));
StackParentData parentData;
parentData = containerElement.renderObject.parentData;
expect(parentData.top, isNull);
expect(parentData.right, isNull);
expect(parentData.bottom, isNull);
expect(parentData.left, equals(10.0));
tester.pumpWidget(new Stack([ container ]));
tester.pumpWidget(new Stack(<Widget>[ container ]));
containerElement = tester.findElementByKey(key);
expect(containerElement.renderObject.parentData.top, isNull);
expect(containerElement.renderObject.parentData.right, isNull);
expect(containerElement.renderObject.parentData.bottom, isNull);
expect(containerElement.renderObject.parentData.left, isNull);
parentData = containerElement.renderObject.parentData;
expect(parentData.top, isNull);
expect(parentData.right, isNull);
expect(parentData.bottom, isNull);
expect(parentData.left, isNull);
});
});
......@@ -90,7 +99,7 @@ void main() {
tester.pumpWidget(
new Center(
child: new Stack([
child: new Stack(<Widget>[
new Container(key: child0Key, width: 20.0, height: 20.0),
new Container(key: child1Key, width: 10.0, height: 10.0)
],
......@@ -101,22 +110,24 @@ void main() {
);
Element child0 = tester.findElementByKey(child0Key);
expect(child0.renderObject.parentData.position, equals(const Point(0.0, 0.0)));
final StackParentData child0RenderObjectParentData = child0.renderObject.parentData;
expect(child0RenderObjectParentData.position, equals(const Point(0.0, 0.0)));
Element child1 = tester.findElementByKey(child1Key);
expect(child1.renderObject.parentData.position, equals(const Point(5.0, 5.0)));
final StackParentData child1RenderObjectParentData = child1.renderObject.parentData;
expect(child1RenderObjectParentData.position, equals(const Point(5.0, 5.0)));
});
});
test('Can construct an empty IndexedStack', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new IndexedStack([]));
tester.pumpWidget(new IndexedStack(<Widget>[]));
});
});
test('Can construct an empty Centered IndexedStack', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new Center(child: new IndexedStack([])));
tester.pumpWidget(new Center(child: new IndexedStack(<Widget>[])));
});
});
......@@ -126,9 +137,9 @@ void main() {
List<int> itemsPainted;
Widget buildFrame(int index) {
itemsPainted = [];
List<Widget> items = new List.generate(itemCount, (i) {
return new CustomPaint(child: new Text('$i'), callback: (_0, _1) { itemsPainted.add(i); });
itemsPainted = <int>[];
List<Widget> items = new List<Widget>.generate(itemCount, (i) {
return new CustomPaint(child: new Text('$i'), callback: (_, __) { itemsPainted.add(i); });
});
return new Center(child: new IndexedStack(items, index: index));
}
......@@ -154,8 +165,8 @@ void main() {
List<int> itemsTapped;
Widget buildFrame(int index) {
itemsTapped = [];
List<Widget> items = new List.generate(itemCount, (i) {
itemsTapped = <int>[];
List<Widget> items = new List<Widget>.generate(itemCount, (i) {
return new GestureDetector(child: new Text('$i'), onTap: () { itemsTapped.add(i); });
});
return new Center(child: new IndexedStack(items, key: key, index: index));
......
......@@ -11,7 +11,7 @@ void main() {
void checkTree(BoxDecoration expectedDecoration) {
OneChildRenderObjectElement element =
tester.findElement((element) => element is OneChildRenderObjectElement);
tester.findElement((Element element) => element is OneChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......
......@@ -112,13 +112,13 @@ void main() {
testWidgets((WidgetTester tester) {
Widget a = new TestWidget(persistentState: 0x61, syncedState: 0x41, child: new Text('apple'));
Widget b = new TestWidget(persistentState: 0x62, syncedState: 0x42, child: new Text('banana'));
tester.pumpWidget(new Column([]));
tester.pumpWidget(new Column(<Widget>[]));
GlobalKey keyA = new GlobalKey();
GlobalKey keyB = new GlobalKey();
tester.pumpWidget(
new Column([
new Column(<Widget>[
new Container(
key: keyA,
child: a
......@@ -143,7 +143,7 @@ void main() {
expect(second.syncedState, equals(0x42));
tester.pumpWidget(
new Column([
new Column(<Widget>[
new Container(
key: keyA,
child: a
......@@ -170,7 +170,7 @@ void main() {
// since they are both "old" nodes, they shouldn't sync with each other even though they look alike
tester.pumpWidget(
new Column([
new Column(<Widget>[
new Container(
key: keyA,
child: b
......
......@@ -49,7 +49,7 @@ class TestBuildCounter extends StatelessComponent {
void flipStatefulComponent(WidgetTester tester) {
StatefulComponentElement stateElement =
tester.findElement((element) => element is StatefulComponentElement);
tester.findElement((Element element) => element is StatefulComponentElement);
expect(stateElement, isNotNull);
expect(stateElement.state is FlipComponentState, isTrue);
FlipComponentState state = stateElement.state;
......
......@@ -8,7 +8,7 @@ void main() {
testWidgets((WidgetTester tester) {
bool didReceiveTap = false;
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
top: 100.0,
left: 100.0,
......@@ -53,7 +53,7 @@ void main() {
testWidgets((WidgetTester tester) {
bool didReceiveTap = false;
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
top: 100.0,
left: 100.0,
......@@ -98,7 +98,7 @@ void main() {
testWidgets((WidgetTester tester) {
bool didReceiveTap = false;
tester.pumpWidget(
new Stack([
new Stack(<Widget>[
new Positioned(
top: 100.0,
left: 100.0,
......
......@@ -24,11 +24,12 @@ class RootComponentState extends State<RootComponent> {
Widget build(BuildContext context) => child;
}
typedef Point SizeToPointFunction(Size size);
class WidgetTester {
WidgetTester._(FakeAsync async)
: async = async,
clock = async.getClock(new DateTime.utc(2015, 1, 1)) {
}
clock = async.getClock(new DateTime.utc(2015, 1, 1));
final FakeAsync async;
final Clock clock;
......@@ -46,7 +47,7 @@ class WidgetTester {
}
List<Layer> _layers(Layer layer) {
List<Layer> result = [layer];
List<Layer> result = <Layer>[layer];
if (layer is ContainerLayer) {
ContainerLayer root = layer;
Layer child = root.firstChild;
......@@ -124,7 +125,7 @@ class WidgetTester {
return _getElementPoint(element, (Size size) => size.bottomRight(Point.origin));
}
Point _getElementPoint(Element element, Function sizeToPoint) {
Point _getElementPoint(Element element, SizeToPointFunction sizeToPoint) {
assert(element != null);
RenderBox box = element.renderObject as RenderBox;
assert(box != null);
......
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