mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Extract TestBorder into a utility file (#25888)
This commit is contained in:
parent
8049893f42
commit
a67a2f6249
|
@ -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
|
||||||
|
|
|
@ -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>[];
|
||||||
|
|
||||||
|
|
|
@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
33
packages/flutter/test/widgets/test_border.dart
Normal file
33
packages/flutter/test/widgets/test_border.dart
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue