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
dbed575c
Commit
dbed575c
authored
Jan 08, 2020
by
Tong Mu
Committed by
Flutter GitHub Bot
Jan 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test of scrolling competition (#47492)
parent
07161e82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
2 deletions
+53
-2
scrollable_test.dart
packages/flutter/test/widgets/scrollable_test.dart
+53
-2
No files found.
packages/flutter/test/widgets/scrollable_test.dart
View file @
dbed575c
...
...
@@ -16,6 +16,7 @@ Future<void> pumpTest(
bool
scrollable
=
true
,
bool
reverse
=
false
,
ScrollController
controller
,
Widget
Function
(
Widget
)
wrapper
,
})
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
...
...
@@ -33,14 +34,46 @@ Future<void> pumpTest(
await
tester
.
pump
(
const
Duration
(
seconds:
5
));
// to let the theme animate
}
// Pump a nested scrollable. The outer scrollable contains a sliver of a
// 300-pixel-long scrollable followed by a 2000-pixel-long content.
Future
<
void
>
pumpDoubleScrollableTest
(
WidgetTester
tester
,
TargetPlatform
platform
,
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
platform
,
),
home:
CustomScrollView
(
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
Container
(
height:
300
,
child:
const
CustomScrollView
(
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
SizedBox
(
height:
2000.0
)),
],
),
),
),
const
SliverToBoxAdapter
(
child:
SizedBox
(
height:
2000.0
)),
],
),
));
await
tester
.
pump
(
const
Duration
(
seconds:
5
));
// to let the theme animate
}
const
double
dragOffset
=
200.0
;
final
LogicalKeyboardKey
modifierKey
=
defaultTargetPlatform
==
TargetPlatform
.
macOS
?
LogicalKeyboardKey
.
metaLeft
:
LogicalKeyboardKey
.
controlLeft
;
double
getScrollOffset
(
WidgetTester
tester
)
{
final
RenderViewport
viewport
=
tester
.
renderObject
(
find
.
byType
(
Viewport
));
double
getScrollOffset
(
WidgetTester
tester
,
{
bool
last
=
true
})
{
Finder
viewportFinder
=
find
.
byType
(
Viewport
);
if
(
last
)
viewportFinder
=
viewportFinder
.
last
;
final
RenderViewport
viewport
=
tester
.
renderObject
(
viewportFinder
);
return
viewport
.
offset
.
pixels
;
}
...
...
@@ -252,6 +285,24 @@ void main() {
expect
(
getScrollOffset
(
tester
),
0.0
);
});
testWidgets
(
'Scroll pointer signals are handled when there is competion'
,
(
WidgetTester
tester
)
async
{
// This is a regression test. When there are multiple scrollables listening
// to the same event, for example when scrollables are nested, there used
// to be exceptions at scrolling events.
await
pumpDoubleScrollableTest
(
tester
,
TargetPlatform
.
fuchsia
);
final
Offset
scrollEventLocation
=
tester
.
getCenter
(
find
.
byType
(
Viewport
).
last
);
final
TestPointer
testPointer
=
TestPointer
(
1
,
ui
.
PointerDeviceKind
.
mouse
);
// Create a hover event so that |testPointer| has a location when generating the scroll.
testPointer
.
hover
(
scrollEventLocation
);
final
HitTestResult
result
=
tester
.
hitTestOnBinding
(
scrollEventLocation
);
await
tester
.
sendEventToBinding
(
testPointer
.
scroll
(
const
Offset
(
0.0
,
20.0
)),
result
);
expect
(
getScrollOffset
(
tester
,
last:
true
),
20.0
);
// Pointer signals should not cause overscroll.
await
tester
.
sendEventToBinding
(
testPointer
.
scroll
(
const
Offset
(
0.0
,
-
30.0
)),
result
);
expect
(
getScrollOffset
(
tester
,
last:
true
),
0.0
);
});
testWidgets
(
'Scroll pointer signals are ignored when scrolling is disabled'
,
(
WidgetTester
tester
)
async
{
await
pumpTest
(
tester
,
TargetPlatform
.
fuchsia
,
scrollable:
false
);
final
Offset
scrollEventLocation
=
tester
.
getCenter
(
find
.
byType
(
Viewport
));
...
...
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