Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9c15407b
Commit
9c15407b
authored
Aug 11, 2016
by
Ian Hickson
Committed by
GitHub
Aug 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When a list is scrolling, children can't be tapped (#5222) (#5348)
parent
cab7c8d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
15 deletions
+72
-15
smoke_test.dart
examples/flutter_gallery/test/smoke_test.dart
+12
-9
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+15
-6
scrollable_fling_test.dart
packages/flutter/test/widget/scrollable_fling_test.dart
+45
-0
No files found.
examples/flutter_gallery/test/smoke_test.dart
View file @
9c15407b
...
...
@@ -9,6 +9,8 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter_gallery/gallery/item.dart'
show
GalleryItem
,
kAllGalleryItems
;
import
'package:flutter_gallery/main.dart'
as
flutter_gallery_main
;
const
String
kCaption
=
'Flutter Gallery'
;
final
List
<
String
>
demoCategories
=
new
LinkedHashSet
<
String
>.
from
(
kAllGalleryItems
.
map
((
GalleryItem
item
)
=>
item
.
category
)
).
toList
();
...
...
@@ -43,8 +45,9 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
await
tester
.
tap
(
menuItem
);
await
tester
.
pump
();
// Launch the demo.
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Wait until the demo has opened.
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Wait until the demo has opened.
expect
(
find
.
text
(
kCaption
),
findsNothing
);
// Go back
if
(
routeName
==
'/pesto'
)
{
...
...
@@ -64,16 +67,14 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
}
void
main
(
)
{
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
if
(
binding
is
LiveTestWidgetsFlutterBinding
)
binding
.
allowAllFrames
=
true
;
testWidgets
(
'Flutter Gallery app smoke test'
,
(
WidgetTester
tester
)
async
{
flutter_gallery_main
.
main
();
// builds the app and schedules a frame but doesn't trigger one
await
tester
.
pump
();
// see https://github.com/flutter/flutter/issues/1865
await
tester
.
pump
();
// triggers a frame
expect
(
find
.
text
(
kCaption
),
findsOneWidget
);
final
List
<
double
>
scrollDeltas
=
new
List
<
double
>();
double
previousY
=
tester
.
getTopRight
(
find
.
text
(
demoCategories
[
0
])).
y
;
for
(
String
routeName
in
routeNames
)
{
...
...
@@ -87,15 +88,17 @@ void main() {
final
String
routeName
=
routeNames
[
i
];
await
smokeDemo
(
tester
,
routeName
);
await
tester
.
scroll
(
findGalleryItemByRouteName
(
tester
,
routeName
),
new
Offset
(
0.0
,
scrollDeltas
[
i
]));
await
tester
.
pump
();
await
tester
.
pump
();
// start the scroll
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
// wait for overscroll to timeout, if necessary
await
tester
.
pump
(
const
Duration
(
milliseconds:
2000
));
// wait for overscroll to fade away, if necessary
tester
.
binding
.
debugAssertNoTransientCallbacks
(
'A transient callback was still active after leaving route
$routeName
'
);
}
Finder
navigationMenuButton
=
findNavigationMenuButton
(
tester
);
expect
(
navigationMenuButton
,
findsOneWidget
);
await
tester
.
tap
(
navigationMenuButton
);
await
tester
.
pump
();
// Start opening drawer.
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Wait until it's really opened.
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Wait until it's really opened.
// switch theme
await
tester
.
tap
(
find
.
text
(
'Dark'
));
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
9c15407b
...
...
@@ -259,7 +259,8 @@ class ScrollableState<T extends Scrollable> extends State<T> {
@override
void
dispose
()
{
_stop
();
_controller
.
dispose
();
_simulation
=
null
;
super
.
dispose
();
}
...
...
@@ -367,8 +368,10 @@ class ScrollableState<T extends Scrollable> extends State<T> {
}
void
_handleAnimationStatusChanged
(
AnimationStatus
status
)
{
if
(!
_controller
.
isAnimating
)
_simulation
=
null
;
setState
(()
{
if
(!
_controller
.
isAnimating
)
_simulation
=
null
;
});
}
void
_setScrollOffset
(
double
newScrollOffset
,
{
DragUpdateDetails
details
})
{
...
...
@@ -579,9 +582,12 @@ class ScrollableState<T extends Scrollable> extends State<T> {
}
void
_stop
()
{
assert
(
mounted
);
assert
(
_controller
.
isAnimating
||
_simulation
==
null
);
_controller
.
stop
();
_simulation
=
null
;
setState
(()
{
_controller
.
stop
();
_simulation
=
null
;
});
}
void
_handleDragStart
(
DragStartDetails
details
)
{
...
...
@@ -652,7 +658,10 @@ class ScrollableState<T extends Scrollable> extends State<T> {
key:
_gestureDetectorKey
,
gestures:
buildGestureDetectors
(),
behavior:
HitTestBehavior
.
opaque
,
child:
buildContent
(
context
)
child:
new
IgnorePointer
(
ignoring:
_controller
.
isAnimating
,
child:
buildContent
(
context
)
)
);
}
...
...
packages/flutter/test/widget/scrollable_fling_test.dart
View file @
9c15407b
...
...
@@ -58,4 +58,49 @@ void main() {
expect
(
result1
,
lessThan
(
result2
));
// iOS (result2) is slipperier than Android (result1)
});
testWidgets
(
'fling and tap to stop'
,
(
WidgetTester
tester
)
async
{
List
<
String
>
log
=
<
String
>[];
List
<
Widget
>
textWidgets
=
<
Widget
>[];
for
(
int
i
=
0
;
i
<
250
;
i
++)
textWidgets
.
add
(
new
GestureDetector
(
onTap:
()
{
log
.
add
(
'tap
$i
'
);
},
child:
new
Text
(
'
$i
'
)));
await
tester
.
pumpWidget
(
new
Block
(
children:
textWidgets
));
expect
(
log
,
equals
(<
String
>[]));
await
tester
.
tap
(
find
.
byType
(
Scrollable
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
]));
await
tester
.
fling
(
find
.
byType
(
Scrollable
),
new
Offset
(
0.0
,
-
200.0
),
1000.0
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
]));
await
tester
.
tap
(
find
.
byType
(
Scrollable
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
]));
await
tester
.
tap
(
find
.
byType
(
Scrollable
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
,
'tap 31'
]));
});
testWidgets
(
'fling and wait and tap'
,
(
WidgetTester
tester
)
async
{
List
<
String
>
log
=
<
String
>[];
List
<
Widget
>
textWidgets
=
<
Widget
>[];
for
(
int
i
=
0
;
i
<
250
;
i
++)
textWidgets
.
add
(
new
GestureDetector
(
onTap:
()
{
log
.
add
(
'tap
$i
'
);
},
child:
new
Text
(
'
$i
'
)));
await
tester
.
pumpWidget
(
new
Block
(
children:
textWidgets
));
expect
(
log
,
equals
(<
String
>[]));
await
tester
.
tap
(
find
.
byType
(
Scrollable
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
]));
await
tester
.
fling
(
find
.
byType
(
Scrollable
),
new
Offset
(
0.0
,
-
200.0
),
1000.0
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
]));
await
tester
.
pump
(
const
Duration
(
seconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
]));
await
tester
.
tap
(
find
.
byType
(
Scrollable
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
log
,
equals
(<
String
>[
'tap 18'
,
'tap 48'
]));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment