Commit 17389244 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Fix BorderSide rendering (#7705)

parent 743be674
......@@ -433,7 +433,7 @@ class Border {
path = new Path();
path.moveTo(rect.left, rect.bottom);
path.lineTo(rect.left, rect.top);
if (right.width == 0.0) {
if (left.width == 0.0) {
paint.style = PaintingStyle.stroke;
} else {
paint.style = PaintingStyle.fill;
......
......@@ -6,6 +6,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import '../rendering/mock_canvas.dart';
void main() {
testWidgets('Circles can have uniform borders', (WidgetTester tester) async {
await tester.pumpWidget(
......@@ -36,4 +38,52 @@ void main() {
);
expect(tester.getSize(find.byKey(key)), equals(const Size(45.0, 45.0)));
});
testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/7672
final Key key = new Key('Container with BoxDecoration');
Widget buildFrame(Border border) {
return new Center(
child: new Container(
key: key,
width: 100.0,
height: 50.0,
decoration: new BoxDecoration(border: border),
),
);
}
final Color black = const Color(0xFF000000);
await tester.pumpWidget(buildFrame(new Border.all()));
expect(find.byKey(key), paints
..path(color: black, style: PaintingStyle.fill)
..path(color: black, style: PaintingStyle.fill)
..path(color: black, style: PaintingStyle.fill)
..path(color: black, style: PaintingStyle.fill));
await tester.pumpWidget(buildFrame(new Border.all(width: 0.0)));
expect(find.byKey(key), paints
..path(color: black, style: PaintingStyle.stroke)
..path(color: black, style: PaintingStyle.stroke)
..path(color: black, style: PaintingStyle.stroke)
..path(color: black, style: PaintingStyle.stroke));
final Color green = const Color(0xFF000000);
final BorderSide greenSide = new BorderSide(color: green, width: 10.0);
await tester.pumpWidget(buildFrame(new Border(top: greenSide)));
expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill));
await tester.pumpWidget(buildFrame(new Border(left: greenSide)));
expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill));
await tester.pumpWidget(buildFrame(new Border(right: greenSide)));
expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill));
await tester.pumpWidget(buildFrame(new Border(bottom: greenSide)));
expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill));
});
}
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