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
445505d6
Unverified
Commit
445505d6
authored
May 30, 2019
by
Jonah Williams
Committed by
GitHub
May 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Devfs cleanup and testing (#33374)
parent
e810512b
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
169 additions
and
284 deletions
+169
-284
fuchsia_asset_builder.dart
packages/flutter_tools/bin/fuchsia_asset_builder.dart
+3
-6
bundle.dart
packages/flutter_tools/lib/src/bundle.dart
+11
-12
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+1
-1
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+48
-85
fuchsia_build.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
+1
-1
resident_web_runner.dart
packages/flutter_tools/lib/src/resident_web_runner.dart
+1
-2
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+1
-1
asset_bundle_package_fonts_test.dart
...s/flutter_tools/test/asset_bundle_package_fonts_test.dart
+3
-3
asset_bundle_package_test.dart
packages/flutter_tools/test/asset_bundle_package_test.dart
+6
-6
asset_bundle_test.dart
packages/flutter_tools/test/asset_bundle_test.dart
+1
-1
asset_bundle_variant_test.dart
packages/flutter_tools/test/asset_bundle_variant_test.dart
+2
-2
asset_test.dart
packages/flutter_tools/test/asset_test.dart
+2
-1
devfs_test.dart
packages/flutter_tools/test/devfs_test.dart
+89
-138
mocks.dart
packages/flutter_tools/test/src/mocks.dart
+0
-25
No files found.
packages/flutter_tools/bin/fuchsia_asset_builder.dart
View file @
445505d6
...
...
@@ -36,10 +36,9 @@ Future<void> main(List<String> args) {
});
}
Future
<
void
>
writeFile
(
libfs
.
File
outputFile
,
DevFSContent
content
)
async
{
void
writeFile
(
libfs
.
File
outputFile
,
DevFSContent
content
)
{
outputFile
.
createSync
(
recursive:
true
);
final
List
<
int
>
data
=
await
content
.
contentsAsBytes
();
outputFile
.
writeAsBytesSync
(
data
);
content
.
copyToFile
(
outputFile
);
}
Future
<
void
>
run
(
List
<
String
>
args
)
async
{
...
...
@@ -71,12 +70,10 @@ Future<void> run(List<String> args) async {
exit
(
1
);
}
final
List
<
Future
<
void
>>
calls
=
<
Future
<
void
>>[];
assets
.
entries
.
forEach
((
String
fileName
,
DevFSContent
content
)
{
final
libfs
.
File
outputFile
=
libfs
.
fs
.
file
(
libfs
.
fs
.
path
.
join
(
assetDir
,
fileName
));
calls
.
add
(
writeFile
(
outputFile
,
content
)
);
writeFile
(
outputFile
,
content
);
});
await
Future
.
wait
<
void
>(
calls
);
final
String
outputMan
=
argResults
[
_kOptionAssetManifestOut
];
await
writeFuchsiaManifest
(
assets
,
argResults
[
_kOptionAsset
],
outputMan
,
argResults
[
_kOptionComponentName
]);
...
...
packages/flutter_tools/lib/src/bundle.dart
View file @
445505d6
...
...
@@ -147,7 +147,7 @@ Future<void> build({
if
(
assets
==
null
)
throwToolExit
(
'Error building assets'
,
exitCode:
1
);
a
wait
a
ssemble
(
assemble
(
buildMode:
buildMode
,
assetBundle:
assets
,
kernelContent:
kernelContent
,
...
...
@@ -182,14 +182,14 @@ Future<AssetBundle> buildAssets({
return
assetBundle
;
}
Future
<
void
>
assemble
({
void
assemble
(
{
BuildMode
buildMode
,
AssetBundle
assetBundle
,
DevFSContent
kernelContent
,
String
privateKeyPath
=
defaultPrivateKeyPath
,
String
assetDirPath
,
String
compilationTraceFilePath
,
})
async
{
})
{
assetDirPath
??=
getAssetBuildDirectory
();
printTrace
(
'Building bundle'
);
...
...
@@ -214,22 +214,21 @@ Future<void> assemble({
printTrace
(
'Writing asset files to
$assetDirPath
'
);
ensureDirectoryExists
(
assetDirPath
);
await
writeBundle
(
fs
.
directory
(
assetDirPath
),
assetEntries
);
writeBundle
(
fs
.
directory
(
assetDirPath
),
assetEntries
);
printTrace
(
'Wrote
$assetDirPath
'
);
}
Future
<
void
>
writeBundle
(
void
writeBundle
(
Directory
bundleDir
,
Map
<
String
,
DevFSContent
>
assetEntries
,
)
async
{
)
{
if
(
bundleDir
.
existsSync
())
bundleDir
.
deleteSync
(
recursive:
true
);
bundleDir
.
createSync
(
recursive:
true
);
await
Future
.
wait
<
void
>(
assetEntries
.
entries
.
map
<
Future
<
void
>>((
MapEntry
<
String
,
DevFSContent
>
entry
)
async
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
bundleDir
.
path
,
entry
.
key
));
file
.
parent
.
createSync
(
recursive:
true
);
await
file
.
writeAsBytes
(
await
entry
.
value
.
contentsAsBytes
());
}));
for
(
MapEntry
<
String
,
DevFSContent
>
entry
in
assetEntries
.
entries
)
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
bundleDir
.
path
,
entry
.
key
));
file
.
parent
.
createSync
(
recursive:
true
);
entry
.
value
.
copyToFile
(
file
);
}
}
packages/flutter_tools/lib/src/commands/test.dart
View file @
445505d6
...
...
@@ -242,7 +242,7 @@ class TestCommand extends FastFlutterCommand {
throwToolExit
(
'Error: Failed to build asset bundle'
);
}
if
(
_needRebuild
(
assetBundle
.
entries
))
{
await
writeBundle
(
fs
.
directory
(
fs
.
path
.
join
(
'build'
,
'unit_test_assets'
)),
writeBundle
(
fs
.
directory
(
fs
.
path
.
join
(
'build'
,
'unit_test_assets'
)),
assetBundle
.
entries
);
}
}
...
...
packages/flutter_tools/lib/src/devfs.dart
View file @
445505d6
...
...
@@ -38,21 +38,25 @@ abstract class DevFSContent {
/// or if the given time is null.
bool
isModifiedAfter
(
DateTime
time
);
/// The number of bytes in this file.
int
get
size
;
Future
<
List
<
int
>>
contentsAsBytes
();
/// Returns the raw bytes of this file.
List
<
int
>
contentsAsBytes
();
Stream
<
List
<
int
>>
contentsAsStream
();
Stream
<
List
<
int
>>
contentsAsCompressedStream
()
{
return
contentsAsStream
().
cast
<
List
<
int
>>().
transform
<
List
<
int
>>(
gzip
.
encoder
);
/// Returns a gzipped representation of the contents of this file.
List
<
int
>
contentsAsCompressedBytes
()
{
return
gzip
.
encode
(
contentsAsBytes
());
}
/// Return the list of files this content depends on.
List
<
String
>
get
fileDependencies
=>
<
String
>[];
/// Copies the content into the provided file.
///
/// Requires that the `destination` directory already exists, but the target
/// file need not.
void
copyToFile
(
File
destination
);
}
// File content to be copied to the device.
//
/
File content to be copied to the device.
class
DevFSFileContent
extends
DevFSContent
{
DevFSFileContent
(
this
.
file
);
...
...
@@ -102,9 +106,6 @@ class DevFSFileContent extends DevFSContent {
}
}
@override
List
<
String
>
get
fileDependencies
=>
<
String
>[
_getFile
().
path
];
@override
bool
get
isModified
{
final
FileStat
_oldFileStat
=
_fileStat
;
...
...
@@ -135,10 +136,12 @@ class DevFSFileContent extends DevFSContent {
}
@override
Future
<
List
<
int
>>
contentsAsBytes
()
=>
_getFile
().
readAsBytes
();
List
<
int
>
contentsAsBytes
()
=>
_getFile
().
readAsBytesSync
().
cast
<
int
>
();
@override
Stream
<
List
<
int
>>
contentsAsStream
()
=>
_getFile
().
openRead
();
void
copyToFile
(
File
destination
)
{
_getFile
().
copySync
(
destination
.
path
);
}
}
/// Byte content to be copied to the device.
...
...
@@ -175,14 +178,15 @@ class DevFSByteContent extends DevFSContent {
int
get
size
=>
_bytes
.
length
;
@override
Future
<
List
<
int
>>
contentsAsBytes
()
async
=>
_bytes
;
List
<
int
>
contentsAsBytes
()
=>
_bytes
;
@override
Stream
<
List
<
int
>>
contentsAsStream
()
=>
Stream
<
List
<
int
>>.
fromIterable
(<
List
<
int
>>[
_bytes
]);
void
copyToFile
(
File
destination
)
{
destination
.
writeAsBytesSync
(
contentsAsBytes
());
}
}
/// String content to be copied to the device.
/// String content to be copied to the device
encoded as utf8
.
class
DevFSStringContent
extends
DevFSByteContent
{
DevFSStringContent
(
String
string
)
:
_string
=
string
,
...
...
@@ -203,75 +207,29 @@ class DevFSStringContent extends DevFSByteContent {
}
}
/// Abstract DevFS operations interface.
abstract
class
DevFSOperations
{
Future
<
Uri
>
create
(
String
fsName
);
Future
<
dynamic
>
destroy
(
String
fsName
);
Future
<
dynamic
>
writeFile
(
String
fsName
,
Uri
deviceUri
,
DevFSContent
content
);
}
/// An implementation of [DevFSOperations] that speaks to the
/// vm service.
class
ServiceProtocolDevFSOperations
implements
DevFSOperations
{
ServiceProtocolDevFSOperations
(
this
.
vmService
);
class
DevFSOperations
{
DevFSOperations
(
this
.
vmService
,
this
.
fsName
)
:
httpAddress
=
vmService
.
httpAddress
;
final
VMService
vmService
;
@override
Future
<
Uri
>
create
(
String
fsName
)
async
{
final
Map
<
String
,
dynamic
>
response
=
await
vmService
.
vm
.
createDevFS
(
fsName
);
return
Uri
.
parse
(
response
[
'uri'
]);
}
@override
Future
<
dynamic
>
destroy
(
String
fsName
)
async
{
await
vmService
.
vm
.
deleteDevFS
(
fsName
);
}
@override
Future
<
dynamic
>
writeFile
(
String
fsName
,
Uri
deviceUri
,
DevFSContent
content
)
async
{
List
<
int
>
bytes
;
try
{
bytes
=
await
content
.
contentsAsBytes
();
}
catch
(
e
)
{
return
e
;
}
final
String
fileContents
=
base64
.
encode
(
bytes
);
try
{
return
await
vmService
.
vm
.
invokeRpcRaw
(
'_writeDevFSFile'
,
params:
<
String
,
dynamic
>{
'fsName'
:
fsName
,
'uri'
:
deviceUri
.
toString
(),
'fileContents'
:
fileContents
,
},
);
}
catch
(
error
)
{
printTrace
(
'DevFS: Failed to write
$deviceUri
:
$error
'
);
}
}
}
class
DevFSException
implements
Exception
{
DevFSException
(
this
.
message
,
[
this
.
error
,
this
.
stackTrace
]);
final
String
message
;
final
dynamic
error
;
final
StackTrace
stackTrace
;
}
class
_DevFSHttpWriter
{
_DevFSHttpWriter
(
this
.
fsName
,
VMService
serviceProtocol
)
:
httpAddress
=
serviceProtocol
.
httpAddress
;
final
String
fsName
;
final
Uri
httpAddress
;
final
HttpClient
_client
=
HttpClient
();
static
const
int
kMaxInFlight
=
6
;
int
_inFlight
=
0
;
Map
<
Uri
,
DevFSContent
>
_outstanding
;
Completer
<
void
>
_completer
;
final
HttpClient
_client
=
HttpClient
();
Future
<
Uri
>
create
(
String
fsName
)
async
{
final
Map
<
String
,
dynamic
>
response
=
await
vmService
.
vm
.
createDevFS
(
fsName
);
return
Uri
.
parse
(
response
[
'uri'
]);
}
Future
<
void
>
destroy
(
String
fsName
)
async
{
await
vmService
.
vm
.
deleteDevFS
(
fsName
);
}
Future
<
void
>
write
(
Map
<
Uri
,
DevFSContent
>
entries
)
async
{
_client
.
maxConnectionsPerHost
=
kMaxInFlight
;
...
...
@@ -301,9 +259,9 @@ class _DevFSHttpWriter {
final
HttpClientRequest
request
=
await
_client
.
putUrl
(
httpAddress
);
request
.
headers
.
removeAll
(
HttpHeaders
.
acceptEncodingHeader
);
request
.
headers
.
add
(
'dev_fs_name'
,
fsName
);
request
.
headers
.
add
(
'dev_fs_uri_b64'
,
base64
.
encode
(
utf8
.
encode
(
'
$deviceUri
'
)));
final
Stream
<
List
<
int
>>
contents
=
content
.
contentsAsCompressedStream
(
);
await
request
.
addStream
(
contents
);
request
.
headers
.
add
(
'dev_fs_uri_b64'
,
base64
.
encode
(
utf8
.
encode
(
deviceUri
.
toString
()))
);
request
.
add
(
content
.
contentsAsCompressedBytes
()
);
final
HttpClientResponse
response
=
await
request
.
close
();
await
response
.
drain
<
void
>();
}
catch
(
error
,
trace
)
{
...
...
@@ -317,6 +275,14 @@ class _DevFSHttpWriter {
}
}
class
DevFSException
implements
Exception
{
DevFSException
(
this
.
message
,
[
this
.
error
,
this
.
stackTrace
]);
final
String
message
;
final
dynamic
error
;
final
StackTrace
stackTrace
;
}
// Basic statistics for DevFS update operation.
class
UpdateFSReport
{
UpdateFSReport
({
...
...
@@ -353,8 +319,7 @@ class DevFS {
this
.
fsName
,
this
.
rootDirectory
,
{
String
packagesFilePath
,
})
:
_operations
=
ServiceProtocolDevFSOperations
(
serviceProtocol
),
_httpWriter
=
_DevFSHttpWriter
(
fsName
,
serviceProtocol
),
})
:
_operations
=
DevFSOperations
(
serviceProtocol
,
fsName
),
_packagesFilePath
=
packagesFilePath
??
fs
.
path
.
join
(
rootDirectory
.
path
,
kPackagesFileName
);
DevFS
.
operations
(
...
...
@@ -362,11 +327,9 @@ class DevFS {
this
.
fsName
,
this
.
rootDirectory
,
{
String
packagesFilePath
,
})
:
_httpWriter
=
null
,
_packagesFilePath
=
packagesFilePath
??
fs
.
path
.
join
(
rootDirectory
.
path
,
kPackagesFileName
);
})
:
_packagesFilePath
=
packagesFilePath
??
fs
.
path
.
join
(
rootDirectory
.
path
,
kPackagesFileName
);
final
DevFSOperations
_operations
;
final
_DevFSHttpWriter
_httpWriter
;
final
String
fsName
;
final
Directory
rootDirectory
;
String
_packagesFilePath
;
...
...
@@ -489,7 +452,7 @@ class DevFS {
printTrace
(
'Updating files'
);
if
(
dirtyEntries
.
isNotEmpty
)
{
try
{
await
_
httpWriter
.
write
(
dirtyEntries
);
await
_
operations
.
write
(
dirtyEntries
);
}
on
SocketException
catch
(
socketException
,
stackTrace
)
{
printTrace
(
'DevFS sync failed. Lost connection to device:
$socketException
'
);
throw
DevFSException
(
'Lost connection to device.'
,
socketException
,
stackTrace
);
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
View file @
445505d6
...
...
@@ -52,7 +52,7 @@ Future<void> _buildAssets(
final
Map
<
String
,
DevFSContent
>
assetEntries
=
Map
<
String
,
DevFSContent
>.
from
(
assets
.
entries
);
await
writeBundle
(
fs
.
directory
(
assetDir
),
assetEntries
);
writeBundle
(
fs
.
directory
(
assetDir
),
assetEntries
);
final
String
appName
=
fuchsiaProject
.
project
.
manifest
.
appName
;
final
String
outDir
=
getFuchsiaBuildDirectory
();
...
...
packages/flutter_tools/lib/src/resident_web_runner.dart
View file @
445505d6
...
...
@@ -120,8 +120,7 @@ class ResidentWebRunner extends ResidentRunner {
if
(
build
!=
0
)
{
throwToolExit
(
'Error: Failed to build asset bundle'
);
}
await
writeBundle
(
fs
.
directory
(
getAssetBuildDirectory
()),
assetBundle
.
entries
);
writeBundle
(
fs
.
directory
(
getAssetBuildDirectory
()),
assetBundle
.
entries
);
// Step 2: Start an HTTP server
_server
=
WebAssetServer
(
flutterProject
,
target
,
ipv6
);
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
445505d6
...
...
@@ -119,7 +119,7 @@ class WebDevice extends Device {
if
(
build
!=
0
)
{
throwToolExit
(
'Error: Failed to build asset bundle'
);
}
await
writeBundle
(
fs
.
directory
(
getAssetBuildDirectory
()),
assetBundle
.
entries
);
writeBundle
(
fs
.
directory
(
getAssetBuildDirectory
()),
assetBundle
.
entries
);
_package
=
package
;
_server
=
await
HttpServer
.
bind
(
InternetAddress
.
loopbackIPv4
,
0
);
...
...
packages/flutter_tools/test/asset_bundle_package_fonts_test.dart
View file @
445505d6
...
...
@@ -74,7 +74,7 @@ $fontsSection
final
String
entryKey
=
'packages/
$packageName
/
$packageFont
'
;
expect
(
bundle
.
entries
.
containsKey
(
entryKey
),
true
);
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
entryKey
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
entryKey
].
contentsAsBytes
()),
packageFont
,
);
}
...
...
@@ -82,14 +82,14 @@ $fontsSection
for
(
String
localFont
in
localFonts
)
{
expect
(
bundle
.
entries
.
containsKey
(
localFont
),
true
);
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
localFont
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
localFont
].
contentsAsBytes
()),
localFont
,
);
}
}
expect
(
json
.
decode
(
utf8
.
decode
(
await
bundle
.
entries
[
'FontManifest.json'
].
contentsAsBytes
())),
json
.
decode
(
utf8
.
decode
(
bundle
.
entries
[
'FontManifest.json'
].
contentsAsBytes
())),
json
.
decode
(
expectedAssetManifest
),
);
}
...
...
packages/flutter_tools/test/asset_bundle_package_test.dart
View file @
445505d6
...
...
@@ -79,14 +79,14 @@ $assetsSection
final
String
entryKey
=
Uri
.
encodeFull
(
'packages/
$packageName
/
$asset
'
);
expect
(
bundle
.
entries
.
containsKey
(
entryKey
),
true
,
reason:
'Cannot find key on bundle:
$entryKey
'
);
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
entryKey
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
entryKey
].
contentsAsBytes
()),
asset
,
);
}
}
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
expectedAssetManifest
,
);
}
...
...
@@ -126,11 +126,11 @@ $assetsSection
expect
(
bundle
.
entries
.
length
,
3
);
// LICENSE, AssetManifest, FontManifest
const
String
expectedAssetManifest
=
'{}'
;
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
expectedAssetManifest
,
);
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
'FontManifest.json'
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
'FontManifest.json'
].
contentsAsBytes
()),
'[]'
,
);
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -153,11 +153,11 @@ $assetsSection
expect
(
bundle
.
entries
.
length
,
3
);
// LICENSE, AssetManifest, FontManifest
const
String
expectedAssetManifest
=
'{}'
;
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
expectedAssetManifest
,
);
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
'FontManifest.json'
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
'FontManifest.json'
].
contentsAsBytes
()),
'[]'
,
);
},
overrides:
<
Type
,
Generator
>{
...
...
packages/flutter_tools/test/asset_bundle_test.dart
View file @
445505d6
...
...
@@ -50,7 +50,7 @@ void main() {
expect
(
bundle
.
entries
.
length
,
1
);
const
String
expectedAssetManifest
=
'{}'
;
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
utf8
.
decode
(
bundle
.
entries
[
'AssetManifest.json'
].
contentsAsBytes
()),
expectedAssetManifest
,
);
},
overrides:
<
Type
,
Generator
>{
...
...
packages/flutter_tools/test/asset_bundle_variant_test.dart
View file @
445505d6
...
...
@@ -76,7 +76,7 @@ flutter:
// The main asset file, /a/b/c/foo, and its variants exist.
for
(
String
asset
in
assets
)
{
expect
(
bundle
.
entries
.
containsKey
(
asset
),
true
);
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
asset
].
contentsAsBytes
()),
asset
);
expect
(
utf8
.
decode
(
bundle
.
entries
[
asset
].
contentsAsBytes
()),
asset
);
}
fs
.
file
(
fixPath
(
'a/b/c/foo'
)).
deleteSync
();
...
...
@@ -88,7 +88,7 @@ flutter:
expect
(
bundle
.
entries
.
containsKey
(
'a/b/c/foo'
),
false
);
for
(
String
asset
in
assets
.
skip
(
1
))
{
expect
(
bundle
.
entries
.
containsKey
(
asset
),
true
);
expect
(
utf8
.
decode
(
await
bundle
.
entries
[
asset
].
contentsAsBytes
()),
asset
);
expect
(
utf8
.
decode
(
bundle
.
entries
[
asset
].
contentsAsBytes
()),
asset
);
}
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
testFileSystem
,
...
...
packages/flutter_tools/test/asset_test.dart
View file @
445505d6
...
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'package:flutter_tools/src/asset.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
import
'src/common.dart'
;
import
'src/context.dart'
;
...
...
@@ -65,5 +66,5 @@ void main() {
}
Future
<
String
>
getValueAsString
(
String
key
,
AssetBundle
asset
)
async
{
return
String
.
fromCharCodes
(
await
asset
.
entries
[
key
].
contentsAsBytes
());
return
utf8
.
decode
(
asset
.
entries
[
key
].
contentsAsBytes
());
}
packages/flutter_tools/test/devfs_test.dart
View file @
445505d6
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/src/mocks.dart
View file @
445505d6
...
...
@@ -14,7 +14,6 @@ import 'package:flutter_tools/src/base/io.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/compile.dart'
;
import
'package:flutter_tools/src/devfs.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/ios/simulators.dart'
;
...
...
@@ -478,30 +477,6 @@ class BasicMock {
}
}
class
MockDevFSOperations
extends
BasicMock
implements
DevFSOperations
{
Map
<
Uri
,
DevFSContent
>
devicePathToContent
=
<
Uri
,
DevFSContent
>{};
@override
Future
<
Uri
>
create
(
String
fsName
)
async
{
messages
.
add
(
'create
$fsName
'
);
return
Uri
.
parse
(
'file:///
$fsName
'
);
}
@override
Future
<
dynamic
>
destroy
(
String
fsName
)
async
{
messages
.
add
(
'destroy
$fsName
'
);
}
@override
Future
<
dynamic
>
writeFile
(
String
fsName
,
Uri
deviceUri
,
DevFSContent
content
)
async
{
String
message
=
'writeFile
$fsName
$deviceUri
'
;
if
(
content
is
DevFSFileContent
)
{
message
+=
'
${content.file.path}
'
;
}
messages
.
add
(
message
);
devicePathToContent
[
deviceUri
]
=
content
;
}
}
class
MockResidentCompiler
extends
BasicMock
implements
ResidentCompiler
{
@override
...
...
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