Unverified Commit 7aa8c2ab authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[null-safety] remove mockito from scrollbar test (#64493)

More work towards #62886
parent 15d18b9e
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
import 'package:flutter/src/physics/utils.dart' show nearEqual; import 'package:flutter/src/physics/utils.dart' show nearEqual;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import '../flutter_test_alternative.dart' show Fake;
const Color _kScrollbarColor = Color(0xFF123456); const Color _kScrollbarColor = Color(0xFF123456);
const double _kThickness = 2.5; const double _kThickness = 2.5;
...@@ -39,14 +40,25 @@ ScrollbarPainter _buildPainter({ ...@@ -39,14 +40,25 @@ ScrollbarPainter _buildPainter({
)..update(scrollMetrics, scrollMetrics.axisDirection); )..update(scrollMetrics, scrollMetrics.axisDirection);
} }
class _DrawRectOnceCanvas extends Mock implements Canvas { } class _DrawRectOnceCanvas extends Fake implements Canvas {
List<Rect> rects = <Rect>[];
@override
void drawRect(Rect rect, Paint paint) {
rects.add(rect);
}
}
void main() { void main() {
final _DrawRectOnceCanvas testCanvas = _DrawRectOnceCanvas(); final _DrawRectOnceCanvas testCanvas = _DrawRectOnceCanvas();
ScrollbarPainter painter; ScrollbarPainter painter;
Rect captureRect() => verify(testCanvas.drawRect(captureAny, any)).captured.single as Rect;
tearDown(() => painter = null); Rect captureRect() => testCanvas.rects.removeLast();
tearDown(() {
painter = null;
testCanvas.rects.clear();
});
final ScrollMetrics defaultMetrics = FixedScrollMetrics( final ScrollMetrics defaultMetrics = FixedScrollMetrics(
minScrollExtent: 0, minScrollExtent: 0,
......
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