mirror of
https://github.com/flutter/flutter
synced 2024-10-14 04:02:56 +00:00
d927c93310
* enable lint unnecessary_new * fix tests * fix tests * fix tests
32 lines
1.3 KiB
Dart
32 lines
1.3 KiB
Dart
// Copyright 2017 The Chromium 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_gallery/demo/material/drawer_demo.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('Drawer header does not scroll', (WidgetTester tester) async {
|
|
await tester.pumpWidget(MaterialApp(
|
|
theme: ThemeData(platform: TargetPlatform.iOS),
|
|
home: DrawerDemo(),
|
|
));
|
|
|
|
await tester.tap(find.text('Tap here to open the drawer'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 500));
|
|
|
|
expect(tester.getTopLeft(find.byType(UserAccountsDrawerHeader)).dy, 0.0);
|
|
final double initialTopItemSaneY = tester.getTopLeft(find.text('Drawer item A')).dy;
|
|
expect(initialTopItemSaneY, greaterThan(0.0));
|
|
|
|
await tester.drag(find.text('Drawer item B'), const Offset(0.0, 400.0));
|
|
await tester.pump();
|
|
|
|
expect(tester.getTopLeft(find.byType(UserAccountsDrawerHeader)).dy, 0.0);
|
|
expect(tester.getTopLeft(find.text('Drawer item A')).dy, greaterThan(initialTopItemSaneY));
|
|
expect(tester.getTopLeft(find.text('Drawer item A')).dy, lessThanOrEqualTo(initialTopItemSaneY + 400.0));
|
|
});
|
|
}
|