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
e9e36f39
Unverified
Commit
e9e36f39
authored
Jul 29, 2020
by
Ming Lyu (CareF)
Committed by
GitHub
Jul 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WidgetController.pump use optional duration (#62091)
parent
aeedd71e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
4 deletions
+42
-4
controller.dart
packages/flutter_test/lib/src/controller.dart
+7
-3
live_widget_controller_test.dart
packages/flutter_test/test/live_widget_controller_test.dart
+35
-1
No files found.
packages/flutter_test/lib/src/controller.dart
View file @
e9e36f39
...
...
@@ -423,7 +423,11 @@ abstract class WidgetController {
/// See [PointerEventRecord].
Future
<
List
<
Duration
>>
handlePointerEventRecord
(
List
<
PointerEventRecord
>
records
);
/// Called to indicate that time should advance.
/// Called to indicate that there should be a new frame after an optional
/// delay.
///
/// The frame is pumped after a delay of [duration] if [duration] is not null,
/// or immediately otherwise.
///
/// This is invoked by [flingFrom], for instance, so that the sequence of
/// pointer events occurs over time.
...
...
@@ -432,7 +436,7 @@ abstract class WidgetController {
///
/// See also [SchedulerBinding.endOfFrame], which returns a future that could
/// be appropriate to return in the implementation of this method.
Future
<
void
>
pump
(
Duration
duration
);
Future
<
void
>
pump
(
[
Duration
duration
]
);
/// Attempts to drag the given widget by the given offset, by
/// starting a drag in the middle of the widget.
...
...
@@ -755,7 +759,7 @@ class LiveWidgetController extends WidgetController {
LiveWidgetController
(
WidgetsBinding
binding
)
:
super
(
binding
);
@override
Future
<
void
>
pump
(
Duration
duration
)
async
{
Future
<
void
>
pump
(
[
Duration
duration
]
)
async
{
if
(
duration
!=
null
)
await
Future
<
void
>.
delayed
(
duration
);
binding
.
scheduleFrame
();
...
...
packages/flutter_test/test/live_widget_controller_test.dart
View file @
e9e36f39
...
...
@@ -9,7 +9,41 @@ import 'package:flutter/gestures.dart';
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
Future
<
void
>
main
()
async
{
class
CountButton
extends
StatefulWidget
{
@override
_CountButtonState
createState
()
=>
_CountButtonState
();
}
class
_CountButtonState
extends
State
<
CountButton
>
{
int
counter
=
0
;
@override
Widget
build
(
BuildContext
context
)
{
return
RaisedButton
(
child:
Text
(
'Counter
$counter
'
),
onPressed:
()
{
setState
(()
{
counter
+=
1
;
});
},
);
}
}
void
main
(
)
{
test
(
'Test pump on LiveWidgetController'
,
()
async
{
runApp
(
MaterialApp
(
home:
Center
(
child:
CountButton
())));
await
SchedulerBinding
.
instance
.
endOfFrame
;
final
WidgetController
controller
=
LiveWidgetController
(
WidgetsBinding
.
instance
);
await
controller
.
tap
(
find
.
text
(
'Counter 0'
));
expect
(
find
.
text
(
'Counter 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Counter 1'
),
findsNothing
);
await
controller
.
pump
();
expect
(
find
.
text
(
'Counter 0'
),
findsNothing
);
expect
(
find
.
text
(
'Counter 1'
),
findsOneWidget
);
});
test
(
'Input event array on LiveWidgetController'
,
()
async
{
final
List
<
String
>
logs
=
<
String
>[];
runApp
(
...
...
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