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
4204f07d
Unverified
Commit
4204f07d
authored
Sep 21, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Sep 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RestorationManager disposals in test/services/restoration_test.dart. (#135218)
parent
77718845
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
restoration_test.dart
packages/flutter/test/services/restoration_test.dart
+14
-11
No files found.
packages/flutter/test/services/restoration_test.dart
View file @
4204f07d
...
@@ -30,6 +30,7 @@ void main() {
...
@@ -30,6 +30,7 @@ void main() {
});
});
final
RestorationManager
manager
=
RestorationManager
();
final
RestorationManager
manager
=
RestorationManager
();
addTearDown
(
manager
.
dispose
);
final
Future
<
RestorationBucket
?>
rootBucketFuture
=
manager
.
rootBucket
;
final
Future
<
RestorationBucket
?>
rootBucketFuture
=
manager
.
rootBucket
;
RestorationBucket
?
rootBucket
;
RestorationBucket
?
rootBucket
;
rootBucketFuture
.
then
((
RestorationBucket
?
bucket
)
{
rootBucketFuture
.
then
((
RestorationBucket
?
bucket
)
{
...
@@ -65,13 +66,9 @@ void main() {
...
@@ -65,13 +66,9 @@ void main() {
});
});
expect
(
synchronousBucket
,
isNotNull
);
expect
(
synchronousBucket
,
isNotNull
);
expect
(
synchronousBucket
,
same
(
rootBucket
));
expect
(
synchronousBucket
,
same
(
rootBucket
));
},
});
// TODO(NobodyForNothing): Remove after fixing and cover remaining file
// with leak tests https://github.com/flutter/flutter/issues/134831
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
notDisposedAllowList:
<
String
,
int
?>{
'RestorationManager'
:
1
}));
testWidgets
(
'root bucket received from engine before retrieval'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'root bucket received from engine before retrieval'
,
(
WidgetTester
tester
)
async
{
SystemChannels
.
restoration
.
setMethodCallHandler
(
null
);
SystemChannels
.
restoration
.
setMethodCallHandler
(
null
);
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
async
{
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
async
{
...
@@ -79,6 +76,7 @@ void main() {
...
@@ -79,6 +76,7 @@ void main() {
return
null
;
return
null
;
});
});
final
RestorationManager
manager
=
RestorationManager
();
final
RestorationManager
manager
=
RestorationManager
();
addTearDown
(
manager
.
dispose
);
await
_pushDataFromEngine
(
_createEncodedRestorationData1
());
await
_pushDataFromEngine
(
_createEncodedRestorationData1
());
...
@@ -90,7 +88,7 @@ void main() {
...
@@ -90,7 +88,7 @@ void main() {
expect
(
callsToEngine
,
isEmpty
);
expect
(
callsToEngine
,
isEmpty
);
});
});
testWidgets
(
'root bucket received while engine retrieval is pending'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'root bucket received while engine retrieval is pending'
,
(
WidgetTester
tester
)
async
{
SystemChannels
.
restoration
.
setMethodCallHandler
(
null
);
SystemChannels
.
restoration
.
setMethodCallHandler
(
null
);
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
...
@@ -99,6 +97,7 @@ void main() {
...
@@ -99,6 +97,7 @@ void main() {
return
result
.
future
;
return
result
.
future
;
});
});
final
RestorationManager
manager
=
RestorationManager
();
final
RestorationManager
manager
=
RestorationManager
();
addTearDown
(
manager
.
dispose
);
RestorationBucket
?
rootBucket
;
RestorationBucket
?
rootBucket
;
manager
.
rootBucket
.
then
((
RestorationBucket
?
bucket
)
=>
rootBucket
=
bucket
);
manager
.
rootBucket
.
then
((
RestorationBucket
?
bucket
)
=>
rootBucket
=
bucket
);
...
@@ -120,11 +119,12 @@ void main() {
...
@@ -120,11 +119,12 @@ void main() {
expect
(
rootBucket2
!.
contains
(
'foo'
),
isFalse
);
expect
(
rootBucket2
!.
contains
(
'foo'
),
isFalse
);
});
});
testWidgets
(
'root bucket is properly replaced when new data is available'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'root bucket is properly replaced when new data is available'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
async
{
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
async
{
return
_createEncodedRestorationData1
();
return
_createEncodedRestorationData1
();
});
});
final
RestorationManager
manager
=
RestorationManager
();
final
RestorationManager
manager
=
RestorationManager
();
addTearDown
(
manager
.
dispose
);
RestorationBucket
?
rootBucket
;
RestorationBucket
?
rootBucket
;
manager
.
rootBucket
.
then
((
RestorationBucket
?
bucket
)
{
manager
.
rootBucket
.
then
((
RestorationBucket
?
bucket
)
{
rootBucket
=
bucket
;
rootBucket
=
bucket
;
...
@@ -160,7 +160,7 @@ void main() {
...
@@ -160,7 +160,7 @@ void main() {
expect
(
newChild
.
read
<
String
>(
'bar'
),
'Hello'
);
expect
(
newChild
.
read
<
String
>(
'bar'
),
'Hello'
);
});
});
testWidgets
(
'returns null as root bucket when restoration is disabled'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'returns null as root bucket when restoration is disabled'
,
(
WidgetTester
tester
)
async
{
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
{
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
{
...
@@ -171,6 +171,7 @@ void main() {
...
@@ -171,6 +171,7 @@ void main() {
final
RestorationManager
manager
=
RestorationManager
()..
addListener
(()
{
final
RestorationManager
manager
=
RestorationManager
()..
addListener
(()
{
listenerCount
++;
listenerCount
++;
});
});
addTearDown
(
manager
.
dispose
);
RestorationBucket
?
rootBucket
;
RestorationBucket
?
rootBucket
;
bool
rootBucketResolved
=
false
;
bool
rootBucketResolved
=
false
;
manager
.
rootBucket
.
then
((
RestorationBucket
?
bucket
)
{
manager
.
rootBucket
.
then
((
RestorationBucket
?
bucket
)
{
...
@@ -203,7 +204,7 @@ void main() {
...
@@ -203,7 +204,7 @@ void main() {
expect
(
rootBucket
,
isNull
);
expect
(
rootBucket
,
isNull
);
});
});
testWidgets
(
'flushData'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'flushData'
,
(
WidgetTester
tester
)
async
{
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
final
List
<
MethodCall
>
callsToEngine
=
<
MethodCall
>[];
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
{
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
{
...
@@ -212,6 +213,7 @@ void main() {
...
@@ -212,6 +213,7 @@ void main() {
});
});
final
RestorationManager
manager
=
RestorationManager
();
final
RestorationManager
manager
=
RestorationManager
();
addTearDown
(
manager
.
dispose
);
final
Future
<
RestorationBucket
?>
rootBucketFuture
=
manager
.
rootBucket
;
final
Future
<
RestorationBucket
?>
rootBucketFuture
=
manager
.
rootBucket
;
RestorationBucket
?
rootBucket
;
RestorationBucket
?
rootBucket
;
rootBucketFuture
.
then
((
RestorationBucket
?
bucket
)
{
rootBucketFuture
.
then
((
RestorationBucket
?
bucket
)
{
...
@@ -239,13 +241,14 @@ void main() {
...
@@ -239,13 +241,14 @@ void main() {
expect
(
callsToEngine
,
hasLength
(
1
));
expect
(
callsToEngine
,
hasLength
(
1
));
});
});
testWidgets
(
'isReplacing'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'isReplacing'
,
(
WidgetTester
tester
)
async
{
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
final
Completer
<
Map
<
dynamic
,
dynamic
>>
result
=
Completer
<
Map
<
dynamic
,
dynamic
>>();
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
{
tester
.
binding
.
defaultBinaryMessenger
.
setMockMethodCallHandler
(
SystemChannels
.
restoration
,
(
MethodCall
call
)
{
return
result
.
future
;
return
result
.
future
;
});
});
final
TestRestorationManager
manager
=
TestRestorationManager
();
final
TestRestorationManager
manager
=
TestRestorationManager
();
addTearDown
(
manager
.
dispose
);
expect
(
manager
.
isReplacing
,
isFalse
);
expect
(
manager
.
isReplacing
,
isFalse
);
RestorationBucket
?
rootBucket
;
RestorationBucket
?
rootBucket
;
...
...
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