Extract TestBorder into a utility file (#25888)

This commit is contained in:
Mehmet Fidanboylu 2019-01-08 11:06:43 -08:00 committed by GitHub
parent 8049893f42
commit a67a2f6249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 33 deletions

View file

@ -8,7 +8,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
import '../widgets/shape_decoration_test.dart' show TestBorder; import '../widgets/test_border.dart' show TestBorder;
class NotifyMaterial extends StatelessWidget { class NotifyMaterial extends StatelessWidget {
@override @override

View file

@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
import 'shape_decoration_test.dart' show TestBorder; import 'test_border.dart' show TestBorder;
final List<String> log = <String>[]; final List<String> log = <String>[];

View file

@ -11,6 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../painting/image_data.dart'; import '../painting/image_data.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/mocks_for_image_cache.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
import 'test_border.dart' show TestBorder;
Future<void> main() async { Future<void> main() async {
final ui.Image rawImage = await decodeImageFromList(Uint8List.fromList(kTransparentImage)); final ui.Image rawImage = await decodeImageFromList(Uint8List.fromList(kTransparentImage));
@ -104,34 +105,3 @@ Future<void> main() async {
); );
}); });
} }
typedef Logger = void Function(String caller);
class TestBorder extends ShapeBorder {
const TestBorder(this.onLog) : assert(onLog != null);
final Logger onLog;
@override
EdgeInsetsGeometry get dimensions => const EdgeInsetsDirectional.only(start: 1.0);
@override
ShapeBorder scale(double t) => TestBorder(onLog);
@override
Path getInnerPath(Rect rect, { TextDirection textDirection }) {
onLog('getInnerPath $rect $textDirection');
return Path();
}
@override
Path getOuterPath(Rect rect, { TextDirection textDirection }) {
onLog('getOuterPath $rect $textDirection');
return Path();
}
@override
void paint(Canvas canvas, Rect rect, { TextDirection textDirection }) {
onLog('paint $rect $textDirection');
}
}

View file

@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
typedef Logger = void Function(String caller);
class TestBorder extends ShapeBorder {
const TestBorder(this.onLog) : assert(onLog != null);
final Logger onLog;
@override
EdgeInsetsGeometry get dimensions => const EdgeInsetsDirectional.only(start: 1.0);
@override
ShapeBorder scale(double t) => TestBorder(onLog);
@override
Path getInnerPath(Rect rect, { TextDirection textDirection }) {
onLog('getInnerPath $rect $textDirection');
return Path();
}
@override
Path getOuterPath(Rect rect, { TextDirection textDirection }) {
onLog('getOuterPath $rect $textDirection');
return Path();
}
@override
void paint(Canvas canvas, Rect rect, { TextDirection textDirection }) {
onLog('paint $rect $textDirection');
}
}