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
40d0c69f
Unverified
Commit
40d0c69f
authored
Jun 23, 2021
by
Kate Lovett
Committed by
GitHub
Jun 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make scrollbar assertions less aggressive (#84809)
parent
604c59e5
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
229 additions
and
71 deletions
+229
-71
scrollbar.dart
packages/flutter/lib/src/widgets/scrollbar.dart
+177
-31
scrollbar_test.dart
packages/flutter/test/cupertino/scrollbar_test.dart
+10
-4
scrollbar_test.dart
packages/flutter/test/material/scrollbar_test.dart
+4
-4
scrollbar_test.dart
packages/flutter/test/widgets/scrollbar_test.dart
+38
-32
No files found.
packages/flutter/lib/src/widgets/scrollbar.dart
View file @
40d0c69f
This diff is collapsed.
Click to expand it.
packages/flutter/test/cupertino/scrollbar_test.dart
View file @
40d0c69f
...
...
@@ -360,7 +360,7 @@ void main() {
}
await
tester
.
pumpWidget
(
viewWithScroll
());
final
dynamic
exception
=
tester
.
takeException
()
;
final
AssertionError
exception
=
tester
.
takeException
()
as
AssertionError
;
expect
(
exception
,
isAssertionError
);
},
);
...
...
@@ -390,7 +390,7 @@ void main() {
}
await
tester
.
pumpWidget
(
viewWithScroll
());
final
dynamic
exception
=
tester
.
takeException
()
;
final
AssertionError
exception
=
tester
.
takeException
()
as
AssertionError
;
expect
(
exception
,
isAssertionError
);
},
);
...
...
@@ -961,10 +961,16 @@ void main() {
await
tester
.
pumpAndSettle
();
final
dynamic
exception
=
tester
.
takeException
();
AssertionError
?
exception
=
tester
.
takeException
()
as
AssertionError
?;
// The scrollbar is not visible and cannot be interacted with, so no assertion.
expect
(
exception
,
isNull
);
// Scroll to trigger the scrollbar to come into view.
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
SingleChildScrollView
)));
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
20.0
));
exception
=
tester
.
takeException
()
as
AssertionError
;
expect
(
exception
,
isAssertionError
);
expect
(
(
exception
as
AssertionError
)
.
message
,
exception
.
message
,
contains
(
"The Scrollbar's ScrollController has no ScrollPosition attached."
),
);
});
...
...
packages/flutter/test/material/scrollbar_test.dart
View file @
40d0c69f
...
...
@@ -128,7 +128,7 @@ void main() {
of:
find
.
byType
(
Scrollbar
),
matching:
find
.
byType
(
CustomPaint
),
).
first
);
final
dynamic
scrollPainter
=
custom
.
foregroundPainter
;
final
ScrollbarPainter
?
scrollPainter
=
custom
.
foregroundPainter
as
ScrollbarPainter
?
;
// Dragging makes the scrollbar first appear.
await
tester
.
drag
(
find
.
text
(
'0'
),
const
Offset
(
0.0
,
-
10.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
...
...
@@ -141,7 +141,7 @@ void main() {
viewportDimension:
100.0
,
axisDirection:
AxisDirection
.
down
,
);
scrollPainter
.
update
(
metrics
,
AxisDirection
.
down
);
scrollPainter
!
.
update
(
metrics
,
AxisDirection
.
down
);
final
TestCanvas
canvas
=
TestCanvas
();
scrollPainter
.
paint
(
canvas
,
const
Size
(
10.0
,
100.0
));
...
...
@@ -171,7 +171,7 @@ void main() {
}
await
tester
.
pumpWidget
(
viewWithScroll
());
final
dynamic
exception
=
tester
.
takeException
()
;
final
AssertionError
exception
=
tester
.
takeException
()
as
AssertionError
;
expect
(
exception
,
isAssertionError
);
},
);
...
...
@@ -199,7 +199,7 @@ void main() {
}
await
tester
.
pumpWidget
(
viewWithScroll
());
final
dynamic
exception
=
tester
.
takeException
()
;
final
AssertionError
exception
=
tester
.
takeException
()
as
AssertionError
;
expect
(
exception
,
isAssertionError
);
},
);
...
...
packages/flutter/test/widgets/scrollbar_test.dart
View file @
40d0c69f
...
...
@@ -381,13 +381,13 @@ void main() {
axisDirection:
AxisDirection
.
down
,
);
final
ScrollbarPainter
p
=
_buildPainter
(
final
ScrollbarPainter
p
ainter
=
_buildPainter
(
padding:
padding
,
scrollMetrics:
metrics
,
);
testWidgets
(
'down'
,
(
WidgetTester
tester
)
async
{
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
height
,
pixels:
double
.
negativeInfinity
,
...
...
@@ -396,13 +396,13 @@ void main() {
);
// Top overscroll.
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect0
=
captureRect
();
expect
(
rect0
.
top
,
padding
.
top
);
expect
(
size
.
width
-
rect0
.
right
,
padding
.
right
);
// Bottom overscroll.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
height
,
pixels:
double
.
infinity
,
...
...
@@ -410,14 +410,14 @@ void main() {
AxisDirection
.
down
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect1
=
captureRect
();
expect
(
size
.
height
-
rect1
.
bottom
,
padding
.
bottom
);
expect
(
size
.
width
-
rect1
.
right
,
padding
.
right
);
});
testWidgets
(
'up'
,
(
WidgetTester
tester
)
async
{
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
height
,
pixels:
double
.
infinity
,
...
...
@@ -427,13 +427,13 @@ void main() {
);
// Top overscroll.
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect0
=
captureRect
();
expect
(
rect0
.
top
,
padding
.
top
);
expect
(
size
.
width
-
rect0
.
right
,
padding
.
right
);
// Bottom overscroll.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
height
,
pixels:
double
.
negativeInfinity
,
...
...
@@ -442,14 +442,14 @@ void main() {
AxisDirection
.
up
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect1
=
captureRect
();
expect
(
size
.
height
-
rect1
.
bottom
,
padding
.
bottom
);
expect
(
size
.
width
-
rect1
.
right
,
padding
.
right
);
});
testWidgets
(
'left'
,
(
WidgetTester
tester
)
async
{
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
width
,
pixels:
double
.
negativeInfinity
,
...
...
@@ -459,13 +459,13 @@ void main() {
);
// Right overscroll.
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect0
=
captureRect
();
expect
(
size
.
height
-
rect0
.
bottom
,
padding
.
bottom
);
expect
(
size
.
width
-
rect0
.
right
,
padding
.
right
);
// Left overscroll.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
width
,
pixels:
double
.
infinity
,
...
...
@@ -474,14 +474,14 @@ void main() {
AxisDirection
.
left
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect1
=
captureRect
();
expect
(
size
.
height
-
rect1
.
bottom
,
padding
.
bottom
);
expect
(
rect1
.
left
,
padding
.
left
);
});
testWidgets
(
'right'
,
(
WidgetTester
tester
)
async
{
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
width
,
pixels:
double
.
infinity
,
...
...
@@ -491,13 +491,13 @@ void main() {
);
// Right overscroll.
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect0
=
captureRect
();
expect
(
size
.
height
-
rect0
.
bottom
,
padding
.
bottom
);
expect
(
size
.
width
-
rect0
.
right
,
padding
.
right
);
// Left overscroll.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
viewportDimension:
size
.
width
,
pixels:
double
.
negativeInfinity
,
...
...
@@ -506,7 +506,7 @@ void main() {
AxisDirection
.
right
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
Rect
rect1
=
captureRect
();
expect
(
size
.
height
-
rect1
.
bottom
,
padding
.
bottom
);
expect
(
rect1
.
left
,
padding
.
left
);
...
...
@@ -525,7 +525,7 @@ void main() {
);
const
double
minOverscrollLength
=
8.0
;
final
ScrollbarPainter
p
=
_buildPainter
(
final
ScrollbarPainter
p
ainter
=
_buildPainter
(
padding:
padding
,
scrollMetrics:
metrics
,
minLength:
36.0
,
...
...
@@ -533,54 +533,54 @@ void main() {
);
// No overscroll gives a full sized thumb.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
pixels:
0.0
,
),
AxisDirection
.
down
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
final
double
fullThumbExtent
=
captureRect
().
height
;
expect
(
fullThumbExtent
,
greaterThan
(
_kMinThumbExtent
));
// Scrolling to the middle also gives a full sized thumb.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
pixels:
scrollExtent
/
2
,
),
AxisDirection
.
down
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
expect
(
captureRect
().
height
,
moreOrLessEquals
(
fullThumbExtent
,
epsilon:
1
e
-
6
));
// Scrolling just to the very end also gives a full sized thumb.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
pixels:
scrollExtent
,
),
AxisDirection
.
down
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
expect
(
captureRect
().
height
,
moreOrLessEquals
(
fullThumbExtent
,
epsilon:
1
e
-
6
));
// Scrolling just past the end shrinks the thumb slightly.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
pixels:
scrollExtent
*
1.001
,
),
AxisDirection
.
down
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
expect
(
captureRect
().
height
,
moreOrLessEquals
(
fullThumbExtent
,
epsilon:
2.0
));
// Scrolling way past the end shrinks the thumb to minimum.
p
.
update
(
p
ainter
.
update
(
metrics
.
copyWith
(
pixels:
double
.
infinity
,
),
AxisDirection
.
down
,
);
p
.
paint
(
testCanvas
,
size
);
p
ainter
.
paint
(
testCanvas
,
size
);
expect
(
captureRect
().
height
,
minOverscrollLength
);
});
...
...
@@ -1163,10 +1163,10 @@ void main() {
),
);
await
tester
.
pumpAndSettle
();
final
dynamic
exception
=
tester
.
takeException
()
;
final
AssertionError
exception
=
tester
.
takeException
()
as
AssertionError
;
expect
(
exception
,
isAssertionError
);
expect
(
(
exception
as
AssertionError
)
.
message
,
exception
.
message
,
contains
(
"The Scrollbar's ScrollController has no ScrollPosition attached."
),
);
});
...
...
@@ -1198,10 +1198,16 @@ void main() {
await
tester
.
pumpAndSettle
();
final
dynamic
exception
=
tester
.
takeException
();
AssertionError
?
exception
=
tester
.
takeException
()
as
AssertionError
?;
// The scrollbar is not visible and cannot be interacted with, so no assertion.
expect
(
exception
,
isNull
);
// Scroll to trigger the scrollbar to come into view.
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
SingleChildScrollView
)));
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
20.0
));
exception
=
tester
.
takeException
()
as
AssertionError
;
expect
(
exception
,
isAssertionError
);
expect
(
(
exception
as
AssertionError
)
.
message
,
exception
.
message
,
contains
(
"The Scrollbar's ScrollController has no ScrollPosition attached."
),
);
});
...
...
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