Add test for flexible_space_bar.0.dart
(#157107)
Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart`
This commit is contained in:
parent
bcc3146185
commit
3405f11e5c
@ -312,7 +312,6 @@ final Set<String> _knownMissingTests = <String>{
|
|||||||
'examples/api/test/material/selectable_region/selectable_region.0_test.dart',
|
'examples/api/test/material/selectable_region/selectable_region.0_test.dart',
|
||||||
'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart',
|
'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart',
|
||||||
'examples/api/test/material/platform_menu_bar/platform_menu_bar.0_test.dart',
|
'examples/api/test/material/platform_menu_bar/platform_menu_bar.0_test.dart',
|
||||||
'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart',
|
|
||||||
'examples/api/test/material/navigation_rail/navigation_rail.extended_animation.0_test.dart',
|
'examples/api/test/material/navigation_rail/navigation_rail.extended_animation.0_test.dart',
|
||||||
'examples/api/test/painting/star_border/star_border.0_test.dart',
|
'examples/api/test/painting/star_border/star_border.0_test.dart',
|
||||||
'examples/api/test/widgets/navigator/navigator.restorable_push_and_remove_until.0_test.dart',
|
'examples/api/test/widgets/navigator/navigator.restorable_push_and_remove_until.0_test.dart',
|
||||||
|
@ -2,18 +2,23 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Flutter code sample for [FlexibleSpaceBar].
|
/// Flutter code sample for [FlexibleSpaceBar].
|
||||||
|
|
||||||
void main() => runApp(const MaterialApp(home: FlexibleSpaceBarExampleApp()));
|
void main() => runApp(const FlexibleSpaceBarExampleApp());
|
||||||
|
|
||||||
class FlexibleSpaceBarExampleApp extends StatelessWidget {
|
class FlexibleSpaceBarExampleApp extends StatelessWidget {
|
||||||
const FlexibleSpaceBarExampleApp({super.key});
|
const FlexibleSpaceBarExampleApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return MaterialApp(
|
||||||
|
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
||||||
|
dragDevices: PointerDeviceKind.values.toSet(),
|
||||||
|
),
|
||||||
|
home: Scaffold(
|
||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
|
physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
|
||||||
slivers: <Widget>[
|
slivers: <Widget>[
|
||||||
@ -74,6 +79,7 @@ class FlexibleSpaceBarExampleApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
// 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 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_api_samples/material/flexible_space_bar/flexible_space_bar.0.dart' as example;
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// The app being tested loads images via HTTP which the test
|
||||||
|
// framework defeats by default.
|
||||||
|
setUpAll(() {
|
||||||
|
HttpOverrides.global = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('The app bar stretches when over-scrolled', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const example.FlexibleSpaceBarExampleApp(),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(find.text('Flight Report'), findsOne);
|
||||||
|
|
||||||
|
expect(find.widgetWithText(ListTile, 'Sunday'), findsOne);
|
||||||
|
expect(find.widgetWithText(ListTile, 'Monday'), findsOne);
|
||||||
|
expect(find.text('sunny, h: 80, l: 65'), findsExactly(2));
|
||||||
|
expect(find.byIcon(Icons.wb_sunny), findsExactly(2));
|
||||||
|
|
||||||
|
final Finder appBarContainer = find.byType(Image);
|
||||||
|
final Size sizeBeforeScroll = tester.getSize(appBarContainer);
|
||||||
|
final Offset target = tester.getCenter(find.byType(ListTile).first);
|
||||||
|
final TestGesture gesture = await tester.startGesture(target);
|
||||||
|
await gesture.moveBy(const Offset(0.0, 100.0));
|
||||||
|
await tester.pump(const Duration(milliseconds: 10));
|
||||||
|
await gesture.up();
|
||||||
|
final Size sizeAfterScroll = tester.getSize(appBarContainer);
|
||||||
|
|
||||||
|
expect(sizeBeforeScroll.height, lessThan(sizeAfterScroll.height));
|
||||||
|
// Verifies ScrollBehavior.dragDevices is correctly set.
|
||||||
|
}, variant: TargetPlatformVariant.all());
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user