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
3895786f
Unverified
Commit
3895786f
authored
Nov 11, 2022
by
Dan Field
Committed by
GitHub
Nov 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Load assets in flutter_test without turning event loop. (#115123)" (#115156)
This reverts commit
88e49ed2
.
parent
229b39ed
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
30 deletions
+13
-30
synchronous_future.dart
packages/flutter/lib/src/foundation/synchronous_future.dart
+2
-2
asset_bundle.dart
packages/flutter/lib/src/services/asset_bundle.dart
+8
-15
_binding_io.dart
packages/flutter_test/lib/src/_binding_io.dart
+3
-3
bindings_test.dart
packages/flutter_test/test/bindings_test.dart
+0
-10
No files found.
packages/flutter/lib/src/foundation/synchronous_future.dart
View file @
3895786f
...
...
@@ -38,11 +38,11 @@ class SynchronousFuture<T> implements Future<T> {
@override
Future
<
R
>
then
<
R
>(
FutureOr
<
R
>
Function
(
T
value
)
onValue
,
{
Function
?
onError
})
{
final
FutureOr
<
R
>
result
=
onValue
(
_value
);
final
dynamic
result
=
onValue
(
_value
);
if
(
result
is
Future
<
R
>)
{
return
result
;
}
return
SynchronousFuture
<
R
>(
result
);
return
SynchronousFuture
<
R
>(
result
as
R
);
}
@override
...
...
packages/flutter/lib/src/services/asset_bundle.dart
View file @
3895786f
...
...
@@ -247,9 +247,10 @@ abstract class CachingAssetBundle extends AssetBundle {
/// An [AssetBundle] that loads resources using platform messages.
class
PlatformAssetBundle
extends
CachingAssetBundle
{
@override
Future
<
ByteData
>
load
(
String
key
)
{
Future
<
ByteData
>
load
(
String
key
)
async
{
final
Uint8List
encoded
=
utf8
.
encoder
.
convert
(
Uri
(
path:
Uri
.
encodeFull
(
key
)).
path
);
final
Future
<
ByteData
>?
future
=
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
send
(
'flutter/assets'
,
encoded
.
buffer
.
asByteData
())?.
then
((
ByteData
?
asset
)
{
final
ByteData
?
asset
=
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
send
(
'flutter/assets'
,
encoded
.
buffer
.
asByteData
());
if
(
asset
==
null
)
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
_errorSummaryWithKey
(
key
),
...
...
@@ -257,14 +258,6 @@ class PlatformAssetBundle extends CachingAssetBundle {
]);
}
return
asset
;
});
if
(
future
==
null
)
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
_errorSummaryWithKey
(
key
),
ErrorDescription
(
'The asset does not exist or has empty data.'
),
]);
}
return
future
;
}
@override
...
...
packages/flutter_test/lib/src/_binding_io.dart
View file @
3895786f
...
...
@@ -6,8 +6,8 @@ import 'dart:async';
import
'dart:convert'
;
import
'dart:io'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:path/path.dart'
as
path
;
// ignore: deprecated_member_use
import
'package:test_api/test_api.dart'
as
test_package
;
...
...
@@ -42,7 +42,7 @@ void mockFlutterAssets() {
/// platform messages.
SystemChannels
.
navigation
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{});
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
setMockMessageHandler
(
'flutter/assets'
,
(
ByteData
?
message
)
{
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
setMockMessageHandler
(
'flutter/assets'
,
(
ByteData
?
message
)
async
{
assert
(
message
!=
null
);
String
key
=
utf8
.
decode
(
message
!.
buffer
.
asUint8List
());
File
asset
=
File
(
path
.
join
(
assetFolderPath
,
key
));
...
...
@@ -62,7 +62,7 @@ void mockFlutterAssets() {
}
final
Uint8List
encoded
=
Uint8List
.
fromList
(
asset
.
readAsBytesSync
());
return
SynchronousFuture
<
ByteData
>
(
encoded
.
buffer
.
asByteData
());
return
Future
<
ByteData
>.
value
(
encoded
.
buffer
.
asByteData
());
});
}
...
...
packages/flutter_test/test/bindings_test.dart
View file @
3895786f
...
...
@@ -10,7 +10,6 @@
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -91,13 +90,4 @@ void main() {
binding
.
idle
();
});
});
testWidgets
(
'Assets in the tester can be loaded without turning event loop'
,
(
WidgetTester
tester
)
async
{
bool
responded
=
false
;
// The particular asset does not matter, as long as it exists.
rootBundle
.
load
(
'AssetManifest.json'
).
then
((
ByteData
data
)
{
responded
=
true
;
});
expect
(
responded
,
true
);
});
}
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