Add the ability to custom paint foregrounds
This commit is contained in:
@@ -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()]));
|
||||
});
|
||||
|
||||
46
packages/unit/test/widget/custom_paint_test.dart
Normal file
46
packages/unit/test/widget/custom_paint_test.dart
Normal 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']));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user