Commit 292d5aab authored by Ian Hickson's avatar Ian Hickson

Merge pull request #2550 from Hixie/not-as

Not as
parents 778c3a05 5810cd80
......@@ -27,7 +27,8 @@ void main() {
);
RenderBox stack = new RenderStack(children: <RenderBox>[red, green]);
(green.parentData as StackParentData)
StackParentData greenParentData = green.parentData;
greenParentData
..top = 0.0
..right = 0.0
..bottom = 0.0
......
......@@ -69,7 +69,7 @@ class TestAssetBundle extends AssetBundle {
}
Future<ui.Image> testDecodeImageFromDataPipe(core.MojoDataPipeConsumer pipe) {
TestMojoDataPipeConsumer testPipe = pipe as TestMojoDataPipeConsumer;
TestMojoDataPipeConsumer testPipe = pipe;
assert(testPipe != null);
ui.Image image = new TestImage(testPipe.scale);
return (new Completer<ui.Image>()..complete(image)).future;
......@@ -108,11 +108,11 @@ Widget buildImageAtRatio(String image, Key key, double ratio, bool inferSize) {
}
RenderImage getRenderImage(tester, Key key) {
return tester.findElementByKey(key).renderObject as RenderImage;
return tester.findElementByKey(key).renderObject;
}
TestImage getTestImage(tester, Key key) {
return getRenderImage(tester, key).image as TestImage;
return getRenderImage(tester, key).image;
}
void pumpTreeToLayout(WidgetTester tester, Widget widget) {
......
......@@ -104,10 +104,12 @@ void main() {
right: new ProbeWidget()
));
expect(ProbeWidgetState.buildCount, equals(2));
(flipKey.currentState as FlipComponentState).flip();
FlipComponentState flipState1 = flipKey.currentState;
flipState1.flip();
tester.pump();
expect(ProbeWidgetState.buildCount, equals(3));
(flipKey.currentState as FlipComponentState).flip();
FlipComponentState flipState2 = flipKey.currentState;
flipState2.flip();
tester.pump();
expect(ProbeWidgetState.buildCount, equals(3));
tester.pumpWidget(new Container());
......
......@@ -38,14 +38,12 @@ void main() {
)
);
expect((tester.findElementByKey(keyA).renderObject as RenderBox).localToGlobal(const Point(0.0, 0.0)),
equals(const Point(100.0, 100.0)));
RenderBox boxA = tester.findElementByKey(keyA).renderObject;
expect(boxA.localToGlobal(const Point(0.0, 0.0)), equals(const Point(100.0, 100.0)));
expect((tester.findElementByKey(keyB).renderObject as RenderBox).localToGlobal(const Point(0.0, 0.0)),
equals(const Point(100.0, 200.0)));
expect((tester.findElementByKey(keyB).renderObject as RenderBox).globalToLocal(const Point(110.0, 205.0)),
equals(const Point(10.0, 5.0)));
RenderBox boxB = tester.findElementByKey(keyB).renderObject;
expect(boxB.localToGlobal(const Point(0.0, 0.0)), equals(const Point(100.0, 200.0)));
expect(boxB.globalToLocal(const Point(110.0, 205.0)), equals(const Point(10.0, 5.0)));
});
});
}
......@@ -48,7 +48,8 @@ void main() {
tester.pumpWidget(builder());
Element input = tester.findElementByKey(inputKey);
Size emptyInputSize = (input.renderObject as RenderBox).size;
RenderBox inputBox = input.renderObject;
Size emptyInputSize = inputBox.size;
void enterText(String testValue) {
// Simulate entry of text through the keyboard.
......@@ -65,10 +66,12 @@ void main() {
}
enterText(' ');
expect((input.renderObject as RenderBox).size, equals(emptyInputSize));
expect(input.renderObject, equals(inputBox));
expect(inputBox.size, equals(emptyInputSize));
enterText('Test');
expect((input.renderObject as RenderBox).size, equals(emptyInputSize));
expect(input.renderObject, equals(inputBox));
expect(inputBox.size, equals(emptyInputSize));
});
});
......
......@@ -35,7 +35,8 @@ 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 as StackParentData).nextSibling;
StackParentData decoratedBoxParentData = decoratedBox.parentData;
child = decoratedBoxParentData.nextSibling;
}
expect(child, isNull);
} catch (e) {
......
......@@ -47,8 +47,10 @@ void main() {
)
);
(left.currentState as StateMarkerState).marker = "left";
(right.currentState as StateMarkerState).marker = "right";
StateMarkerState leftState = left.currentState;
leftState.marker = "left";
StateMarkerState rightState = right.currentState;
rightState.marker = "right";
StateMarkerState grandchildState = tester.findStateByConfig(grandchild);
expect(grandchildState, isNotNull);
......@@ -71,8 +73,10 @@ void main() {
)
);
expect((left.currentState as StateMarkerState).marker, equals("left"));
expect((right.currentState as StateMarkerState).marker, equals("right"));
expect(left.currentState, equals(leftState));
expect(leftState.marker, equals("left"));
expect(right.currentState, equals(rightState));
expect(rightState.marker, equals("right"));
StateMarkerState newGrandchildState = tester.findStateByConfig(newGrandchild);
expect(newGrandchildState, isNotNull);
......@@ -90,7 +94,8 @@ void main() {
)
);
expect((left.currentState as StateMarkerState).marker, equals("left"));
expect(left.currentState, equals(leftState));
expect(leftState.marker, equals("left"));
expect(right.currentState, isNull);
});
});
......@@ -113,8 +118,10 @@ void main() {
)
);
(left.currentState as StateMarkerState).marker = "left";
(right.currentState as StateMarkerState).marker = "right";
StateMarkerState leftState = left.currentState;
leftState.marker = "left";
StateMarkerState rightState = right.currentState;
rightState.marker = "right";
StateMarkerState grandchildState = tester.findStateByConfig(grandchild);
expect(grandchildState, isNotNull);
......@@ -133,8 +140,10 @@ void main() {
)
);
expect((left.currentState as StateMarkerState).marker, equals("left"));
expect((right.currentState as StateMarkerState).marker, equals("right"));
expect(left.currentState, equals(leftState));
expect(leftState.marker, equals("left"));
expect(right.currentState, equals(rightState));
expect(rightState.marker, equals("right"));
StateMarkerState newGrandchildState = tester.findStateByConfig(newGrandchild);
expect(newGrandchildState, isNotNull);
......@@ -152,7 +161,8 @@ void main() {
)
);
expect((left.currentState as StateMarkerState).marker, equals("left"));
expect(left.currentState, equals(leftState));
expect(leftState.marker, equals("left"));
expect(right.currentState, isNull);
});
});
......@@ -163,7 +173,8 @@ void main() {
tester.pumpWidget(new StateMarker(key: key));
(key.currentState as StateMarkerState).marker = "marked";
StateMarkerState keyState = key.currentState;
keyState.marker = "marked";
tester.pumpWidget(new ScrollableList(
itemExtent: 100.0,
......@@ -176,11 +187,13 @@ void main() {
]
));
expect((key.currentState as StateMarkerState).marker, equals("marked"));
expect(key.currentState, equals(keyState));
expect(keyState.marker, equals("marked"));
tester.pumpWidget(new StateMarker(key: key));
expect((key.currentState as StateMarkerState).marker, equals("marked"));
expect(key.currentState, equals(keyState));
expect(keyState.marker, equals("marked"));
});
});
}
......@@ -138,14 +138,14 @@ class Instrumentation {
/// the element's render object has been laid out at least once.
Size getSize(Element element) {
assert(element != null);
RenderBox box = element.renderObject as RenderBox;
RenderBox box = element.renderObject;
assert(box != null);
return box.size;
}
Point _getElementPoint(Element element, SizeToPointFunction sizeToPoint) {
assert(element != null);
RenderBox box = element.renderObject as RenderBox;
RenderBox box = element.renderObject;
assert(box != null);
return box.localToGlobal(sizeToPoint(box.size));
}
......
......@@ -68,7 +68,7 @@ class AndroidApk extends ApplicationPackage {
String launchActivity;
for (xml.XmlElement category in document.findAllElements('category')) {
if (category.getAttribute('android:name') == 'android.intent.category.LAUNCHER') {
xml.XmlElement activity = category.parent.parent as xml.XmlElement;
xml.XmlElement activity = category.parent.parent;
String activityName = activity.getAttribute('android:name');
launchActivity = "$id/$activityName";
break;
......
......@@ -294,9 +294,10 @@ class AnalyzeCommand extends FlutterCommand {
for (String package in packages.keys)
packagesBody.writeln('$package:${path.toUri(packages[package])}');
/// specify analysis options
/// note that until there is a default "all-in" lint rule-set we need
/// to opt-in to all desired lints (https://github.com/dart-lang/sdk/issues/25843)
/// Specify analysis options.
/// Note that until there is a default "all-in" lint rule-set we need
/// to opt-in to all desired lints (https://github.com/dart-lang/sdk/issues/25843).
/// For a list of lints, see: http://dart-lang.github.io/linter/lints/
String optionsBody = '''
analyzer:
errors:
......@@ -307,6 +308,8 @@ analyzer:
todo: ignore
linter:
rules:
# we'll turn on avoid_as as soon as it doesn't complain about "as dynamic"
# - avoid_as
- camel_case_types
# sometimes we have no choice (e.g. when matching other platforms)
# - constant_identifier_names
......
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