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
63964f48
Commit
63964f48
authored
Feb 10, 2017
by
Adam Barth
Committed by
GitHub
Feb 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port ScrollNotification tests (#8057)
These now test ScrollNotification2.
parent
67462b43
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
100 deletions
+111
-100
scroll_events_test.dart
packages/flutter/test/widgets/scroll_events_test.dart
+67
-58
scroll_notification_test.dart
packages/flutter/test/widgets/scroll_notification_test.dart
+44
-42
No files found.
packages/flutter/test/widgets/scroll_events_test.dart
View file @
63964f48
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/scroll_notification_test.dart
View file @
63964f48
...
...
@@ -7,71 +7,69 @@ import 'package:flutter/widgets.dart';
void
main
(
)
{
testWidgets
(
'Scroll notification basics'
,
(
WidgetTester
tester
)
async
{
ScrollNotification
notification
;
ScrollNotification
2
notification
;
await
tester
.
pumpWidget
(
new
NotificationListener
<
ScrollNotification
>(
onNotification:
(
ScrollNotification
value
)
{
notification
=
value
;
await
tester
.
pumpWidget
(
new
NotificationListener
<
ScrollNotification2
>(
onNotification:
(
ScrollNotification2
value
)
{
if
(
value
is
ScrollStartNotification
||
value
is
ScrollUpdateNotification
||
value
is
ScrollEndNotification
)
notification
=
value
;
return
false
;
},
child:
new
S
crollableViewport
(
child:
new
S
ingleChildScrollView
(
child:
const
SizedBox
(
height:
1200.0
)
)
));
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Point
(
100.0
,
100.0
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
notification
.
kind
,
equals
(
ScrollNotificationKind
.
started
));
expect
(
notification
.
depth
,
equals
(
0
));
expect
(
notification
.
dragStartDetails
,
isNotNull
);
expect
(
notification
.
dragStartDetails
.
globalPosition
,
equals
(
const
Point
(
100.0
,
100.0
)));
expect
(
notification
.
dragUpdateDetails
,
isNull
);
expect
(
notification
.
dragEndDetails
,
isNull
);
expect
(
notification
,
const
isInstanceOf
<
ScrollStartNotification
>());
expect
(
notification
.
depth
,
equals
(
1
));
ScrollStartNotification
start
=
notification
;
expect
(
start
.
dragDetails
,
isNotNull
);
expect
(
start
.
dragDetails
.
globalPosition
,
equals
(
const
Point
(
100.0
,
100.0
)));
await
gesture
.
moveBy
(
const
Offset
(-
10.0
,
-
10.0
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
notification
.
kind
,
equals
(
ScrollNotificationKind
.
updated
));
expect
(
notification
.
depth
,
equals
(
0
));
expect
(
notification
.
dragStartDetails
,
isNull
);
expect
(
notification
.
dragUpdateDetails
,
isNotNull
);
expect
(
notification
.
dragUpdateDetails
.
globalPosition
,
equals
(
const
Point
(
90.0
,
90.0
)));
expect
(
notification
.
dragUpdateDetails
.
delta
,
equals
(
const
Offset
(
0.0
,
-
10.0
)));
expect
(
notification
.
dragEndDetails
,
isNull
);
expect
(
notification
,
const
isInstanceOf
<
ScrollUpdateNotification
>());
expect
(
notification
.
depth
,
equals
(
1
));
ScrollUpdateNotification
update
=
notification
;
expect
(
update
.
dragDetails
,
isNotNull
);
expect
(
update
.
dragDetails
.
globalPosition
,
equals
(
const
Point
(
90.0
,
90.0
)));
expect
(
update
.
dragDetails
.
delta
,
equals
(
const
Offset
(
0.0
,
-
10.0
)));
await
gesture
.
up
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
notification
.
kind
,
equals
(
ScrollNotificationKind
.
ended
));
expect
(
notification
.
depth
,
equals
(
0
));
expect
(
notification
.
dragStartDetails
,
isNull
);
expect
(
notification
.
dragUpdateDetails
,
isNull
);
expect
(
notification
.
dragEndDetails
,
isNotNull
);
expect
(
notification
.
dragEndDetails
.
velocity
,
equals
(
Velocity
.
zero
));
expect
(
notification
,
const
isInstanceOf
<
ScrollEndNotification
>());
expect
(
notification
.
depth
,
equals
(
1
));
ScrollEndNotification
end
=
notification
;
expect
(
end
.
dragDetails
,
isNotNull
);
expect
(
end
.
dragDetails
.
velocity
,
equals
(
Velocity
.
zero
));
});
testWidgets
(
'Scroll notification depth'
,
(
WidgetTester
tester
)
async
{
final
List
<
ScrollNotificationKind
>
depth0Kinds
=
<
ScrollNotificationKind
>[];
final
List
<
ScrollNotificationKind
>
depth1Kinds
=
<
ScrollNotificationKind
>[];
final
List
<
Type
>
depth0Types
=
<
Type
>[];
final
List
<
Type
>
depth1Types
=
<
Type
>[];
final
List
<
int
>
depth0Values
=
<
int
>[];
final
List
<
int
>
depth1Values
=
<
int
>[];
await
tester
.
pumpWidget
(
new
NotificationListener
<
ScrollNotification
>(
onNotification:
(
ScrollNotification
value
)
{
depth1
Kinds
.
add
(
value
.
kind
);
await
tester
.
pumpWidget
(
new
NotificationListener
<
ScrollNotification
2
>(
onNotification:
(
ScrollNotification
2
value
)
{
depth1
Types
.
add
(
value
.
runtimeType
);
depth1Values
.
add
(
value
.
depth
);
return
false
;
},
child:
new
S
crollableViewport
(
child:
new
S
ingleChildScrollView
(
child:
new
SizedBox
(
height:
1200.0
,
child:
new
NotificationListener
<
ScrollNotification
>(
onNotification:
(
ScrollNotification
value
)
{
depth0
Kinds
.
add
(
value
.
kind
);
child:
new
NotificationListener
<
ScrollNotification
2
>(
onNotification:
(
ScrollNotification
2
value
)
{
depth0
Types
.
add
(
value
.
runtimeType
);
depth0Values
.
add
(
value
.
depth
);
return
false
;
},
child:
new
Container
(
padding:
const
EdgeInsets
.
all
(
50.0
),
child:
new
S
crollableViewport
(
child:
const
SizedBox
(
height:
1200.0
))
child:
new
S
ingleChildScrollView
(
child:
const
SizedBox
(
height:
1200.0
))
)
)
)
...
...
@@ -85,15 +83,19 @@ void main() {
await
gesture
.
up
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
final
List
<
ScrollNotificationKind
>
kinds
=
<
ScrollNotificationKind
>[
ScrollNotificationKind
.
started
,
ScrollNotificationKind
.
updated
,
ScrollNotificationKind
.
ended
final
List
<
Type
>
types
=
<
Type
>[
ScrollStartNotification
,
UserScrollNotification
,
ScrollUpdateNotification
,
ScrollEndNotification
,
UserScrollNotification
,
];
expect
(
depth0
Kinds
,
equals
(
kind
s
));
expect
(
depth1
Kinds
,
equals
(
kind
s
));
expect
(
depth0
Types
,
equals
(
type
s
));
expect
(
depth1
Types
,
equals
(
type
s
));
expect
(
depth0Values
,
equals
(<
int
>[
0
,
0
,
0
]));
expect
(
depth1Values
,
equals
(<
int
>[
1
,
1
,
1
]));
// These values might not be what we want in the end.
// See <https://github.com/flutter/flutter/issues/8017>.
expect
(
depth0Values
,
equals
(<
int
>[
1
,
1
,
1
,
1
,
1
]));
expect
(
depth1Values
,
equals
(<
int
>[
2
,
2
,
2
,
2
,
2
]));
});
}
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