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
21841d7e
Unverified
Commit
21841d7e
authored
Jun 27, 2022
by
Dan Field
Committed by
GitHub
Jun 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement frameData for TestWindow (#105537)
parent
f9468d36
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
4 deletions
+56
-4
binding.dart
packages/flutter_test/lib/src/binding.dart
+6
-3
window.dart
packages/flutter_test/lib/src/window.dart
+21
-1
bindings_test.dart
packages/flutter_test/test/bindings_test.dart
+29
-0
No files found.
packages/flutter_test/lib/src/binding.dart
View file @
21841d7e
...
...
@@ -156,6 +156,12 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
debugDisableShadows
=
disableShadows
;
}
@override
void
handleBeginFrame
(
Duration
?
rawTimeStamp
)
{
_window
.
incrementFrameNumber
();
super
.
handleBeginFrame
(
rawTimeStamp
);
}
@override
TestWindow
get
window
=>
_window
;
final
TestWindow
_window
;
...
...
@@ -1048,7 +1054,6 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
}
_phase
=
newPhase
;
if
(
hasScheduledFrame
)
{
addTime
(
const
Duration
(
milliseconds:
500
));
_currentFakeAsync
!.
flushMicrotasks
();
handleBeginFrame
(
Duration
(
milliseconds:
_clock
!.
now
().
millisecondsSinceEpoch
,
...
...
@@ -1093,8 +1098,6 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
),
);
addTime
(
additionalTime
);
return
realAsyncZone
.
run
<
Future
<
T
?>>(()
async
{
_pendingAsyncTasks
=
Completer
<
void
>();
T
?
result
;
...
...
packages/flutter_test/lib/src/window.dart
View file @
21841d7e
...
...
@@ -59,6 +59,14 @@ class TestWindow implements ui.SingletonFlutterWindow {
})
:
_window
=
window
,
platformDispatcher
=
TestPlatformDispatcher
(
platformDispatcher:
window
.
platformDispatcher
);
int
_frameNumber
=
0
;
/// Indicates that the test binding has pumped a frame.
void
incrementFrameNumber
()
{
_frameNumber
+=
1
;
platformDispatcher
.
frameData
=
_TestFrameData
(
_frameNumber
);
}
/// The [dart:ui.SingletonFlutterWindow] that is wrapped by this [TestWindow].
final
ui
.
SingletonFlutterWindow
_window
;
...
...
@@ -491,6 +499,9 @@ class TestWindow implements ui.SingletonFlutterWindow {
platformDispatcher
.
onPlatformMessage
=
callback
;
}
@override
ui
.
FrameData
get
frameData
=>
platformDispatcher
.
frameData
;
/// Delete any test value properties that have been set on this [TestWindow]
/// as well as its [platformDispatcher].
///
...
...
@@ -505,6 +516,7 @@ class TestWindow implements ui.SingletonFlutterWindow {
clearDisplayFeaturesTestValue
();
clearPhysicalSizeTestValue
();
clearViewInsetsTestValue
();
_frameNumber
=
0
;
platformDispatcher
.
clearAllTestValues
();
}
...
...
@@ -882,6 +894,7 @@ class TestPlatformDispatcher implements ui.PlatformDispatcher {
clearLocalesTestValue
();
clearSemanticsEnabledTestValue
();
clearTextScaleFactorTestValue
();
frameData
=
const
_TestFrameData
(
0
);
}
@override
...
...
@@ -914,7 +927,7 @@ class TestPlatformDispatcher implements ui.PlatformDispatcher {
ui
.
PlatformConfiguration
get
configuration
=>
_platformDispatcher
.
configuration
;
@override
ui
.
FrameData
get
frameData
=>
_platformDispatcher
.
frameData
;
ui
.
FrameData
frameData
=
const
_TestFrameData
(
0
)
;
@override
ByteData
?
getPersistentIsolateData
()
=>
_platformDispatcher
.
getPersistentIsolateData
();
...
...
@@ -930,3 +943,10 @@ class TestPlatformDispatcher implements ui.PlatformDispatcher {
return
null
;
}
}
class
_TestFrameData
implements
ui
.
FrameData
{
const
_TestFrameData
(
this
.
frameNumber
);
@override
final
int
frameNumber
;
}
packages/flutter_test/test/bindings_test.dart
View file @
21841d7e
...
...
@@ -33,6 +33,35 @@ void main() {
});
});
test
(
'frameNumber'
,
()
async
{
binding
.
window
.
clearAllTestValues
();
expect
(
binding
.
window
.
frameData
.
frameNumber
,
0
);
await
binding
.
runTest
(()
async
{
// runTest pumps a frame.
expect
(
binding
.
window
.
frameData
.
frameNumber
,
1
);
// Scheduling should not pump
binding
.
scheduleFrame
();
expect
(
binding
.
window
.
frameData
.
frameNumber
,
1
);
binding
.
handleBeginFrame
(
null
);
expect
(
binding
.
window
.
frameData
.
frameNumber
,
2
);
binding
.
handleDrawFrame
();
expect
(
binding
.
window
.
frameData
.
frameNumber
,
2
);
// Pump with no scheduled frame.
await
binding
.
pump
();
expect
(
binding
.
window
.
frameData
.
frameNumber
,
2
);
// Schedule and pump, similar to handleBeginFrame.
binding
.
scheduleFrame
();
await
binding
.
pump
();
expect
(
binding
.
window
.
frameData
.
frameNumber
,
3
);
},
()
{});
binding
.
postTest
();
binding
.
window
.
clearAllTestValues
();
expect
(
binding
.
window
.
frameData
.
frameNumber
,
0
);
});
// The next three tests must run in order -- first using `test`, then `testWidgets`, then `test` again.
int
order
=
0
;
...
...
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