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
5b41ee55
Unverified
Commit
5b41ee55
authored
Aug 31, 2021
by
Alexander Dahlberg
Committed by
GitHub
Aug 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed leak and removed no-shuffle tag in binding_test.dart (#88784)
parent
1f5a1f74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
34 deletions
+25
-34
binding_test.dart
packages/flutter/test/widgets/binding_test.dart
+25
-34
No files found.
packages/flutter/test/widgets/binding_test.dart
View file @
5b41ee55
...
...
@@ -2,12 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
// dependencies have been fixed.
// https://github.com/flutter/flutter/issues/85160
// Fails with "flutter test --test-randomize-ordering-seed=382757700"
@Tags
(<
String
>[
'no-shuffle'
])
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -56,6 +50,13 @@ void main() {
WidgetsFlutterBinding
.
ensureInitialized
();
});
Future
<
void
>
setAppLifeCycleState
(
AppLifecycleState
state
)
async
{
final
ByteData
?
message
=
const
StringCodec
().
encodeMessage
(
state
.
toString
());
await
ServicesBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{});
}
testWidgets
(
'didHaveMemoryPressure callback'
,
(
WidgetTester
tester
)
async
{
final
MemoryPressureObserver
observer
=
MemoryPressureObserver
();
WidgetsBinding
.
instance
!.
addObserver
(
observer
);
...
...
@@ -66,25 +67,22 @@ void main() {
});
testWidgets
(
'handleLifecycleStateChanged callback'
,
(
WidgetTester
tester
)
async
{
final
BinaryMessenger
defaultBinaryMessenger
=
ServicesBinding
.
instance
!.
defaultBinaryMessenger
;
final
AppLifecycleStateObserver
observer
=
AppLifecycleStateObserver
();
WidgetsBinding
.
instance
!.
addObserver
(
observer
);
ByteData
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.paused'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
paused
);
expect
(
observer
.
lifecycleState
,
AppLifecycleState
.
paused
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.resumed'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
resumed
);
expect
(
observer
.
lifecycleState
,
AppLifecycleState
.
resumed
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.inactive'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
inactive
);
expect
(
observer
.
lifecycleState
,
AppLifecycleState
.
inactive
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.detached'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
detached
);
expect
(
observer
.
lifecycleState
,
AppLifecycleState
.
detached
);
setAppLifeCycleState
(
AppLifecycleState
.
resumed
);
});
testWidgets
(
'didPushRoute callback'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -111,7 +109,8 @@ void main() {
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'pushRouteInformation'
,
testRouteInformation
),
);
await
ServicesBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
ServicesBinding
.
instance
!.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{});
expect
(
observer
.
pushedRoute
,
'testRouteName'
);
WidgetsBinding
.
instance
!.
removeObserver
(
observer
);
});
...
...
@@ -133,7 +132,6 @@ void main() {
WidgetsBinding
.
instance
!.
removeObserver
(
observer
);
});
testWidgets
(
'didPushRouteInformation callback with null state'
,
(
WidgetTester
tester
)
async
{
final
PushRouteInformationObserver
observer
=
PushRouteInformationObserver
();
WidgetsBinding
.
instance
!.
addObserver
(
observer
);
...
...
@@ -152,36 +150,28 @@ void main() {
});
testWidgets
(
'Application lifecycle affects frame scheduling'
,
(
WidgetTester
tester
)
async
{
final
BinaryMessenger
defaultBinaryMessenger
=
ServicesBinding
.
instance
!.
defaultBinaryMessenger
;
ByteData
message
;
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.paused'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
paused
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.resumed'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
resumed
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isTrue
);
await
tester
.
pump
();
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.inactive'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
inactive
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.detached'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
detached
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.inactive'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
inactive
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isTrue
);
await
tester
.
pump
();
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.paused'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
paused
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
tester
.
binding
.
scheduleFrame
();
...
...
@@ -193,7 +183,9 @@ void main() {
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
int
frameCount
=
0
;
tester
.
binding
.
addPostFrameCallback
((
Duration
duration
)
{
frameCount
+=
1
;
});
tester
.
binding
.
addPostFrameCallback
((
Duration
duration
)
{
frameCount
+=
1
;
});
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
expect
(
tester
.
binding
.
hasScheduledFrame
,
isFalse
);
...
...
@@ -204,8 +196,7 @@ void main() {
expect
(
frameCount
,
1
);
// Get the tester back to a resumed state for subsequent tests.
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.resumed'
)!;
await
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
setAppLifeCycleState
(
AppLifecycleState
.
resumed
);
expect
(
tester
.
binding
.
hasScheduledFrame
,
isTrue
);
await
tester
.
pump
();
});
...
...
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