Merge remote-tracking branch 'upstream/master' into doubletap

This commit is contained in:
Kris Giesing 2015-10-15 14:30:56 -07:00
commit af92062569
51 changed files with 614 additions and 249 deletions

View File

@ -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';

View File

@ -11,6 +11,7 @@ import 'dart:ui' as ui;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/rendering.dart';
import 'stock_data.dart';

View File

@ -112,7 +112,7 @@ class StockHomeState extends State<StockHome> {
),
new DrawerItem(
icon: 'device/dvr',
onPressed: () { debugDumpApp(); },
onPressed: () { debugDumpApp(); debugDumpRenderTree(); },
child: new Text('Dump App to Console')
),
new DrawerDivider(),

View File

@ -45,6 +45,8 @@ class GestureArenaEntry {
class _GestureArenaState {
final List<GestureArenaMember> members = new List<GestureArenaMember>();
bool isOpen = true;
bool isHeld = false;
bool hasPendingSweep = false;
void add(GestureArenaMember member) {
assert(isOpen);
@ -72,6 +74,46 @@ class GestureArena {
_tryToResolveArena(key, state);
}
/// Force resolution on this arena, giving the win to the first member
void sweep(Object key) {
_GestureArenaState state = _arenas[key];
if (state == null)
return; // This arena either never existed or has been resolved.
assert(!state.isOpen);
if (state.isHeld) {
state.hasPendingSweep = true;
return; // This arena is being held for a long-lived member
}
_arenas.remove(key);
if (!state.members.isEmpty) {
// First member wins
state.members.first.acceptGesture(key);
// Give all the other members the bad news
for (int i = 1; i < state.members.length; i++)
state.members[i].rejectGesture(key);
}
}
/// Prevent the arena from being swept
void hold(Object key) {
_GestureArenaState state = _arenas[key];
if (state == null)
return; // This arena either never existed or has been resolved.
state.isHeld = true;
}
/// Release a hold, allowing the arena to be swept
/// If a sweep was attempted on a held arena, the sweep will be done
/// on release
void release(Object key) {
_GestureArenaState state = _arenas[key];
if (state == null)
return; // This arena either never existed or has been resolved.
state.isHeld = false;
if (state.hasPendingSweep)
sweep(key);
}
void _tryToResolveArena(Object key, _GestureArenaState state) {
assert(_arenas[key] == state);
assert(!state.isOpen);

View File

@ -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';

View File

@ -252,25 +252,131 @@ class TextStyle {
List<String> result = <String>[];
if (color != null)
result.add('${prefix}color: $color');
// TODO(hansmuller): escape the fontFamily string.
if (fontFamily != null)
result.add('${prefix}fontFamily: "$fontFamily"');
result.add('${prefix}family: "$fontFamily"');
if (fontSize != null)
result.add('${prefix}fontSize: $fontSize');
if (fontWeight != null)
result.add('${prefix}fontWeight: $fontWeight');
if (fontStyle != null)
result.add('${prefix}fontStyle: $fontStyle');
if (textAlign != null)
result.add('${prefix}textAlign: $textAlign');
if (textBaseline != null)
result.add('${prefix}textBaseline: $textBaseline');
if (decoration != null)
result.add('${prefix}decoration: $decoration');
if (decorationColor != null)
result.add('${prefix}decorationColor: $decorationColor');
if (decorationStyle != null)
result.add('${prefix}decorationStyle: $decorationStyle');
result.add('${prefix}size: $fontSize');
if (fontWeight != null) {
switch (fontWeight) {
case FontWeight.w100:
result.add('${prefix}weight: 100');
break;
case FontWeight.w200:
result.add('${prefix}weight: 200');
break;
case FontWeight.w300:
result.add('${prefix}weight: 300');
break;
case FontWeight.w400:
result.add('${prefix}weight: 400');
break;
case FontWeight.w500:
result.add('${prefix}weight: 500');
break;
case FontWeight.w600:
result.add('${prefix}weight: 600');
break;
case FontWeight.w700:
result.add('${prefix}weight: 700');
break;
case FontWeight.w800:
result.add('${prefix}weight: 800');
break;
case FontWeight.w900:
result.add('${prefix}weight: 900');
break;
}
}
if (fontStyle != null) {
switch (fontStyle) {
case FontStyle.normal:
result.add('${prefix}style: normal');
break;
case FontStyle.italic:
result.add('${prefix}style: italic');
break;
}
}
if (textAlign != null) {
switch (textAlign) {
case TextAlign.left:
result.add('${prefix}align: left');
break;
case TextAlign.right:
result.add('${prefix}align: right');
break;
case TextAlign.center:
result.add('${prefix}align: center');
break;
}
}
if (textBaseline != null) {
switch (textBaseline) {
case TextBaseline.alphabetic:
result.add('${prefix}baseline: alphabetic');
break;
case TextBaseline.ideographic:
result.add('${prefix}baseline: ideographic');
break;
}
}
if (decoration != null || decorationColor != null || decorationStyle != null) {
String decorationDescription = '${prefix}decoration: ';
bool haveDecorationDescription = false;
if (decorationStyle != null) {
switch (decorationStyle) {
case TextDecorationStyle.solid:
decorationDescription += 'solid';
break;
case TextDecorationStyle.double:
decorationDescription += 'double';
break;
case TextDecorationStyle.dotted:
decorationDescription += 'dotted';
break;
case TextDecorationStyle.dashed:
decorationDescription += 'dashed';
break;
case TextDecorationStyle.wavy:
decorationDescription += 'wavy';
break;
}
haveDecorationDescription = true;
}
if (decorationColor != null) {
if (haveDecorationDescription)
decorationDescription += ' ';
decorationDescription += '$decorationColor';
haveDecorationDescription = true;
}
if (decoration != null) {
if (haveDecorationDescription)
decorationDescription += ' ';
bool multipleDecorations = false;
for (TextDecoration value in decoration) {
if (multipleDecorations)
decorationDescription += '+';
switch (value) {
case TextDecoration.none:
decorationDescription += 'none';
break;
case TextDecoration.underline:
decorationDescription += 'underline';
break;
case TextDecoration.overline:
decorationDescription += 'overline';
break;
case TextDecoration.lineThrough:
decorationDescription += 'line-through';
break;
}
multipleDecorations = true;
}
haveDecorationDescription = true;
}
assert(haveDecorationDescription);
result.add(decorationDescription);
}
if (result.isEmpty)
return '$prefix<no style specified>';
return result.join('\n');

View File

@ -244,6 +244,8 @@ class FlutterBinding extends HitTestTarget {
pointerRouter.route(event);
if (event.type == 'pointerdown')
GestureArena.instance.close(event.pointer);
else if (event.type == 'pointerup')
GestureArena.instance.sweep(event.pointer);
}
}
}

View File

@ -1139,11 +1139,18 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// Returns a description of the tree rooted at this node.
/// If the prefix argument is provided, then every line in the output
/// will be prefixed by that string.
String toStringDeep([String prefix = '']) {
String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) {
RenderObject debugPreviousActiveLayout = _debugActiveLayout;
_debugActiveLayout = null;
prefix += ' ';
String result = '$this\n${debugDescribeSettings(prefix)}${debugDescribeChildren(prefix)}';
String result = '$prefixLineOne$this\n';
final String childrenDescription = debugDescribeChildren(prefixOtherLines);
final String settingsPrefix = childrenDescription != '' ? '$prefixOtherLines \u2502 ' : '$prefixOtherLines ';
result += debugDescribeSettings(settingsPrefix);
if (childrenDescription != '')
result += '$prefixOtherLines \u2502\n';
else
result += '$prefixOtherLines\n';
result += childrenDescription;
_debugActiveLayout = debugPreviousActiveLayout;
return result;
}
@ -1198,7 +1205,7 @@ abstract class RenderObjectWithChildMixin<ChildType extends RenderObject> implem
}
String debugDescribeChildren(String prefix) {
if (child != null)
return '${prefix}child: ${child.toStringDeep(prefix)}';
return '${child.toStringDeep("$prefix \u2514\u2500child: ", "$prefix ")}';
return '';
}
}
@ -1442,13 +1449,19 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
String debugDescribeChildren(String prefix) {
String result = '';
int count = 1;
ChildType child = _firstChild;
while (child != null) {
result += '${prefix}child $count: ${child.toStringDeep(prefix)}';
count += 1;
final ParentDataType childParentData = child.parentData;
child = childParentData.nextSibling;
if (_firstChild != null) {
ChildType child = _firstChild;
int count = 1;
while (child != _lastChild) {
result += '${child.toStringDeep("$prefix \u251C\u2500child $count: ", "$prefix \u2502")}';
count += 1;
final ParentDataType childParentData = child.parentData;
child = childParentData.nextSibling;
}
if (child != null) {
assert(child == _lastChild);
result += '${child.toStringDeep("$prefix \u2514\u2500child $count: ", "$prefix ")}';
}
}
return result;
}

View File

@ -883,6 +883,7 @@ class FractionalOffset {
value = 37 * value + y.hashCode;
return value;
}
String toString() => '$runtimeType($x, $y)';
}
/// Applies a transformation before painting its child
@ -1016,7 +1017,7 @@ class RenderTransform extends RenderProxyBox {
String debugDescribeSettings(String prefix) {
List<String> result = _transform.toString().split('\n').map((String s) => '$prefix $s\n').toList();
result.removeLast();
return '${super.debugDescribeSettings(prefix)}${prefix}transform matrix:\n${result.join()}\n${prefix}origin: $origin\n';
return '${super.debugDescribeSettings(prefix)}${prefix}transform matrix:\n${result.join()}\n${prefix}origin: $origin\nalignment: $alignment\n';
}
}

View File

@ -92,6 +92,9 @@ void runApp(Widget app) {
void debugDumpApp() {
assert(WidgetFlutterBinding.instance != null);
assert(WidgetFlutterBinding.instance.renderViewElement != null);
String mode = 'RELEASE MODE';
assert(() { mode = 'CHECKED MODE'; return true; });
print('${WidgetFlutterBinding.instance.runtimeType} - $mode');
WidgetFlutterBinding.instance.renderViewElement.toStringDeep().split('\n').forEach(print);
}

View File

@ -394,8 +394,11 @@ abstract class State<T extends StatefulComponent> {
void debugFillDescription(List<String> description) {
description.add('$hashCode');
if (_debugLifecycleState != _StateLifecycle.ready)
description.add('$_debugLifecycleState');
assert(() {
if (_debugLifecycleState != _StateLifecycle.ready)
description.add('$_debugLifecycleState');
return true;
});
if (_config == null)
description.add('no config');
if (_element == null)
@ -829,9 +832,7 @@ abstract class Element<T extends Widget> implements BuildContext {
String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) {
String result = '$prefixLineOne$this\n';
List<Element> children = <Element>[];
visitChildren((Element child) {
children.add(child);
});
visitChildren(children.add);
if (children.length > 0) {
Element last = children.removeLast();
for (Element child in children)

View File

@ -4,14 +4,22 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
_PhysicsDebugDraw(
box2d.ViewportTransform transform,
this.physicsNode
) : super(transform);
) : super(transform) {
appendFlags(
box2d.DebugDraw.JOINT_BIT |
box2d.DebugDraw.CENTER_OF_MASS_BIT |
box2d.DebugDraw.WIREFRAME_DRAWING_BIT
);
}
PhysicsNode physicsNode;
PaintingCanvas canvas;
void drawSegment(Vector2 p1, Vector2 p2, box2d.Color3i color) {
Paint paint = new Paint()..color = _toColor(color);
Paint paint = new Paint()
..color = _toColor(color)
..strokeWidth = 1.0;
canvas.drawLine(_toPoint(p1), _toPoint(p2), paint);
}
@ -33,7 +41,6 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
}
void drawCircle(Vector2 center, num radius, box2d.Color3i color, [Vector2 axis]) {
print("drawCircle: $center");
Paint paint = new Paint()
..color = _toColor(color)
..setStyle(ui.PaintingStyle.stroke)

View File

@ -32,8 +32,10 @@ class SpriteBox extends RenderBox {
if (value == _rootNode) return;
// Ensure that the root node has a size
assert(value.size.width > 0);
assert(value.size.height > 0);
assert(_transformMode == SpriteBoxTransformMode.nativePoints
|| value.size.width > 0);
assert(_transformMode == SpriteBoxTransformMode.nativePoints
|| value.size.height > 0);
// Remove sprite box references
if (_rootNode != null) _removeSpriteBoxReference(_rootNode);
@ -101,11 +103,11 @@ class SpriteBox extends RenderBox {
assert(rootNode != null);
assert(rootNode._spriteBox == null);
// Setup root node
this.rootNode = rootNode;
// Setup transform mode
this.transformMode = mode;
// Setup root node
this.rootNode = rootNode;
}
void _removeSpriteBoxReference(Node node) {
@ -310,6 +312,8 @@ class SpriteBox extends RenderBox {
rootNode.size = new Size(systemWidth, systemHeight);
break;
case SpriteBoxTransformMode.nativePoints:
systemWidth = size.width;
systemHeight = size.height;
break;
default:
assert(false);

View File

@ -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);
});

View File

@ -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));

View File

@ -66,4 +66,176 @@ void main() {
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isTrue);
});
test('Should win by sweep', () {
GestureArena arena = new GestureArena();
int primaryKey = 4;
bool firstAcceptRan = false;
bool firstRejectRan = false;
bool secondAcceptRan = false;
bool secondRejectRan = false;
TestGestureArenaMember first = new TestGestureArenaMember(
onAcceptGesture: (int key) {
expect(key, equals(primaryKey));
firstAcceptRan = true;
},
onRejectGesture: (int key) {
expect(key, equals(primaryKey));
firstRejectRan = true;
}
);
TestGestureArenaMember second = new TestGestureArenaMember(
onAcceptGesture: (int key) {
expect(key, equals(primaryKey));
secondAcceptRan = true;
},
onRejectGesture: (int key) {
expect(key, equals(primaryKey));
secondRejectRan = true;
}
);
arena.add(primaryKey, first);
arena.add(primaryKey, second);
arena.close(primaryKey);
expect(firstAcceptRan, isFalse);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isFalse);
arena.sweep(primaryKey);
expect(firstAcceptRan, isTrue);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isTrue);
});
test('Should win on release after hold sweep release', () {
GestureArena arena = new GestureArena();
int primaryKey = 4;
bool firstAcceptRan = false;
bool firstRejectRan = false;
bool secondAcceptRan = false;
bool secondRejectRan = false;
TestGestureArenaMember first = new TestGestureArenaMember(
onAcceptGesture: (int key) {
expect(key, equals(primaryKey));
firstAcceptRan = true;
},
onRejectGesture: (int key) {
expect(key, equals(primaryKey));
firstRejectRan = true;
}
);
TestGestureArenaMember second = new TestGestureArenaMember(
onAcceptGesture: (int key) {
expect(key, equals(primaryKey));
secondAcceptRan = true;
},
onRejectGesture: (int key) {
expect(key, equals(primaryKey));
secondRejectRan = true;
}
);
arena.add(primaryKey, first);
arena.add(primaryKey, second);
arena.close(primaryKey);
expect(firstAcceptRan, isFalse);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isFalse);
arena.hold(primaryKey);
expect(firstAcceptRan, isFalse);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isFalse);
arena.sweep(primaryKey);
expect(firstAcceptRan, isFalse);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isFalse);
arena.release(primaryKey);
expect(firstAcceptRan, isTrue);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isTrue);
});
test('Should win on sweep after hold release sweep', () {
GestureArena arena = new GestureArena();
int primaryKey = 4;
bool firstAcceptRan = false;
bool firstRejectRan = false;
bool secondAcceptRan = false;
bool secondRejectRan = false;
TestGestureArenaMember first = new TestGestureArenaMember(
onAcceptGesture: (int key) {
expect(key, equals(primaryKey));
firstAcceptRan = true;
},
onRejectGesture: (int key) {
expect(key, equals(primaryKey));
firstRejectRan = true;
}
);
TestGestureArenaMember second = new TestGestureArenaMember(
onAcceptGesture: (int key) {
expect(key, equals(primaryKey));
secondAcceptRan = true;
},
onRejectGesture: (int key) {
expect(key, equals(primaryKey));
secondRejectRan = true;
}
);
arena.add(primaryKey, first);
arena.add(primaryKey, second);
arena.close(primaryKey);
expect(firstAcceptRan, isFalse);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isFalse);
arena.hold(primaryKey);
expect(firstAcceptRan, isFalse);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isFalse);
arena.release(primaryKey);
expect(firstAcceptRan, isFalse);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isFalse);
arena.sweep(primaryKey);
expect(firstAcceptRan, isTrue);
expect(firstRejectRan, isFalse);
expect(secondAcceptRan, isFalse);
expect(secondRejectRan, isTrue);
});
}

View File

@ -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);

View File

@ -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);

View File

@ -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
);

View File

@ -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)
);

View File

@ -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");
});

View File

@ -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

View File

@ -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')

View File

@ -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()]));
});
});
}

View File

@ -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,

View File

@ -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),

View File

@ -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')
])

View File

@ -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,

View File

@ -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();

View File

@ -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)
]);

View File

@ -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;

View File

@ -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),

View File

@ -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]));

View File

@ -37,7 +37,7 @@ void main() {
child: new Input(
key: inputKey,
placeholder: 'Placeholder',
onChanged: (value) { inputValue = value; }
onChanged: (String value) { inputValue = value; }
)
);
}

View File

@ -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]));

View File

@ -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]);
});
});
}

View File

@ -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>[]);
});
});
}

View File

@ -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)));

View File

@ -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);

View File

@ -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(

View File

@ -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 {

View File

@ -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();
}

View File

@ -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)
)
));

View File

@ -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: () {

View File

@ -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
)

View File

@ -1,3 +1,4 @@
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));

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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,

View File

@ -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);