forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed TrackingScrollController cleaning offset on position's detach (f…
…lutter#11798) * Fixed TrackingScrollController cleaning stored offset on position's detach * Fixed format. * Fixed format.
- Loading branch information
Showing
3 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ Alexandre Ardhuin <[email protected]> | |
Luke Freeman <[email protected]> | ||
Vincent Le Quéméner <[email protected]> | ||
Mike Hoolehan <[email protected]> | ||
German Saprykin <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/flutter/test/widgets/tracking_scroll_controller_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// 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/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('TrackingScrollController saves offset', | ||
(WidgetTester tester) async { | ||
final TrackingScrollController controller = new TrackingScrollController(); | ||
|
||
await tester.pumpWidget( | ||
new PageView.builder( | ||
itemBuilder: (BuildContext context, int index) { | ||
return new ListView( | ||
controller: controller, | ||
children: new List<Widget>.generate( | ||
10, | ||
(int i) => new Container( | ||
height: 100.0, child: new Text("Page$index-Item$i")), | ||
).toList()); | ||
}, | ||
), | ||
); | ||
|
||
expect(find.text('Page0-Item1'), findsOneWidget); | ||
expect(find.text('Page1-Item1'), findsNothing); | ||
expect(find.text('Page2-Item0'), findsNothing); | ||
expect(find.text('Page2-Item1'), findsNothing); | ||
|
||
controller.jumpTo(110.0); | ||
await (tester.pumpAndSettle()); | ||
|
||
await tester.fling( | ||
find.text('Page0-Item1'), const Offset(-100.0, 0.0), 10000.0); | ||
await (tester.pumpAndSettle()); | ||
|
||
expect(find.text('Page0-Item1'), findsNothing); | ||
expect(find.text('Page1-Item1'), findsOneWidget); | ||
expect(find.text('Page2-Item0'), findsNothing); | ||
expect(find.text('Page2-Item1'), findsNothing); | ||
|
||
await tester.fling( | ||
find.text('Page1-Item1'), const Offset(-100.0, 0.0), 10000.0); | ||
await (tester.pumpAndSettle()); | ||
|
||
expect(find.text('Page0-Item1'), findsNothing); | ||
expect(find.text('Page1-Item1'), findsNothing); | ||
expect(find.text('Page2-Item0'), findsNothing); | ||
expect(find.text('Page2-Item1'), findsOneWidget); | ||
|
||
await tester.pumpWidget(new Text("Another page")); | ||
|
||
expect(controller.initialScrollOffset, 0.0); | ||
}); | ||
} |