Add the ability to custom paint foregrounds

This commit is contained in:
Adam Barth
2015-12-04 10:27:45 -08:00
parent a2b8f8b996
commit 2a9de0aa97
4 changed files with 105 additions and 34 deletions

View File

@@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart';
import 'package:test/test.dart';
void main() {
test('Can be placed in an infinte box', () {
test('Can be placed in an infinite box', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new Block(<Widget>[new Center()]));
});

View File

@@ -0,0 +1,46 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
import 'package:test/test.dart';
class TestCustomPainter extends CustomPainter {
TestCustomPainter({ this.log, this.name });
List<String> log;
String name;
void paint(Canvas canvas, Size size) {
log.add(name);
}
bool shouldRepaint(TestCustomPainter oldPainter) => true;
}
void main() {
test('Control test for custom painting', () {
testWidgets((WidgetTester tester) {
List<String> log = <String>[];
tester.pumpWidget(new CustomPaint(
painter: new TestCustomPainter(
log: log,
name: 'background'
),
foregroundPainter: new TestCustomPainter(
log: log,
name: 'foreground'
),
child: new CustomPaint(
painter: new TestCustomPainter(
log: log,
name: 'child'
)
)
));
expect(log, equals(['background', 'child', 'foreground']));
});
});
}