diff --git a/dev/bots/check_code_samples.dart b/dev/bots/check_code_samples.dart index ad86ad037e..5bd22aa7fb 100644 --- a/dev/bots/check_code_samples.dart +++ b/dev/bots/check_code_samples.dart @@ -322,7 +322,6 @@ final Set _knownMissingTests = { 'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart', 'examples/api/test/material/chip/deletable_chip_attributes.on_deleted.0_test.dart', 'examples/api/test/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0_test.dart', - 'examples/api/test/material/scrollbar/scrollbar.1_test.dart', 'examples/api/test/material/search_anchor/search_anchor.0_test.dart', 'examples/api/test/material/search_anchor/search_anchor.1_test.dart', 'examples/api/test/material/search_anchor/search_anchor.2_test.dart', diff --git a/examples/api/test/material/scrollbar/scrollbar.0_test.dart b/examples/api/test/material/scrollbar/scrollbar.0_test.dart index 330f4f9408..0b5323714c 100644 --- a/examples/api/test/material/scrollbar/scrollbar.0_test.dart +++ b/examples/api/test/material/scrollbar/scrollbar.0_test.dart @@ -18,4 +18,22 @@ void main() { expect(tester.takeException(), isNull); }, variant: TargetPlatformVariant.all()); + + testWidgets('The scrollbar should be painted when the user scrolls', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScrollbarExampleApp(), + ); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 10)); // Wait for the thumb to start appearing. + + expect(find.text('item 0'), findsOne); + expect(find.text('item 9'), findsNothing); + expect(find.byType(Scrollbar), isNot(paints..rect())); + + await tester.fling(find.byType(Scrollbar).last, const Offset(0, -300), 10.0); + + expect(find.text('item 0'), findsNothing); + expect(find.text('item 9'), findsOne); + expect(find.byType(Scrollbar).last, paints..rect()); + }); } diff --git a/examples/api/test/material/scrollbar/scrollbar.1_test.dart b/examples/api/test/material/scrollbar/scrollbar.1_test.dart new file mode 100644 index 0000000000..6ad117f6e6 --- /dev/null +++ b/examples/api/test/material/scrollbar/scrollbar.1_test.dart @@ -0,0 +1,29 @@ +// Copyright 2014 The Flutter 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/material.dart'; +import 'package:flutter_api_samples/material/scrollbar/scrollbar.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('The scrollbar thumb should be visible at all time', (WidgetTester tester) async { + await tester.pumpWidget( + const example.ScrollbarExampleApp(), + ); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 10)); // Wait for the thumb to start appearing. + + expect(find.widgetWithText(AppBar, 'Scrollbar Sample'), findsOne); + + expect(find.text('item 0'), findsOne); + expect(find.text('item 9'), findsNothing); + expect(find.byType(Scrollbar), paints..rect()); + + await tester.fling(find.byType(Scrollbar).last, const Offset(0, -300), 10.0); + + expect(find.text('item 0'), findsNothing); + expect(find.text('item 9'), findsOne); + expect(find.byType(Scrollbar), paints..rect()); + }); +}