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
8d3bc184
Unverified
Commit
8d3bc184
authored
Apr 26, 2021
by
Jenn Magder
Committed by
GitHub
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate analyze_size to null safety (#81002)
parent
b8833afc
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
82 deletions
+125
-82
analyze_size.dart
packages/flutter_tools/lib/src/base/analyze_size.dart
+82
-70
analyze_size_test.dart
...tter_tools/test/general.shard/base/analyze_size_test.dart
+41
-11
analyze_size_test.dart
...utter_tools/test/integration.shard/analyze_size_test.dart
+2
-1
No files found.
packages/flutter_tools/lib/src/base/analyze_size.dart
View file @
8d3bc184
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/base/analyze_size_test.dart
View file @
8d3bc184
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:archive/archive.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/analyze_size.dart'
;
...
...
@@ -43,15 +41,15 @@ const String aotSizeOutput = '''
'''
;
void
main
(
)
{
MemoryFileSystem
fileSystem
;
BufferLogger
logger
;
late
MemoryFileSystem
fileSystem
;
late
BufferLogger
logger
;
setUp
(()
{
fileSystem
=
MemoryFileSystem
.
test
();
logger
=
BufferLogger
.
test
();
});
test
(
'matchesPattern matches only entire strings'
,
()
{
test
WithoutContext
(
'matchesPattern matches only entire strings'
,
()
{
expect
(
matchesPattern
(
''
,
pattern:
''
),
isNotNull
);
expect
(
matchesPattern
(
''
,
pattern:
'foo'
),
null
);
expect
(
matchesPattern
(
'foo'
,
pattern:
''
),
null
);
...
...
@@ -62,7 +60,7 @@ void main() {
expect
(
matchesPattern
(
'foobar'
,
pattern:
RegExp
(
r'.*b'
)),
null
);
});
test
(
'builds APK analysis correctly'
,
()
async
{
test
WithoutContext
(
'builds APK analysis correctly'
,
()
async
{
final
SizeAnalyzer
sizeAnalyzer
=
SizeAnalyzer
(
fileSystem:
fileSystem
,
logger:
logger
,
...
...
@@ -78,7 +76,7 @@ void main() {
..
addFile
(
ArchiveFile
(
'lib/arm64-v8a/libflutter.so'
,
50
,
List
<
int
>.
filled
(
50
,
0
)));
final
File
apk
=
fileSystem
.
file
(
'test.apk'
)
..
writeAsBytesSync
(
ZipEncoder
().
encode
(
archive
));
..
writeAsBytesSync
(
ZipEncoder
().
encode
(
archive
)
!
);
final
File
aotSizeJson
=
fileSystem
.
file
(
'test.json'
)
..
createSync
()
..
writeAsStringSync
(
aotSizeOutput
);
...
...
@@ -139,7 +137,7 @@ void main() {
expect
(
result
[
'precompiler-trace'
],
<
String
,
Object
>{});
});
test
(
'outputs summary to command line correctly'
,
()
async
{
test
WithoutContext
(
'outputs summary to command line correctly'
,
()
async
{
final
SizeAnalyzer
sizeAnalyzer
=
SizeAnalyzer
(
fileSystem:
fileSystem
,
logger:
logger
,
...
...
@@ -155,7 +153,7 @@ void main() {
..
addFile
(
ArchiveFile
(
'lib/arm64-v8a/libflutter.so'
,
50
,
List
<
int
>.
filled
(
50
,
0
)));
final
File
apk
=
fileSystem
.
file
(
'test.apk'
)
..
writeAsBytesSync
(
ZipEncoder
().
encode
(
archive
));
..
writeAsBytesSync
(
ZipEncoder
().
encode
(
archive
)
!
);
final
File
aotSizeJson
=
fileSystem
.
file
(
'test.json'
)
..
writeAsStringSync
(
aotSizeOutput
);
final
File
precompilerTrace
=
fileSystem
.
file
(
'trace.json'
)
...
...
@@ -181,7 +179,7 @@ void main() {
);
});
test
(
'can analyze contents of output directory'
,
()
async
{
test
WithoutContext
(
'can analyze contents of output directory'
,
()
async
{
final
SizeAnalyzer
sizeAnalyzer
=
SizeAnalyzer
(
fileSystem:
fileSystem
,
logger:
logger
,
...
...
@@ -202,7 +200,7 @@ void main() {
final
File
precompilerTrace
=
fileSystem
.
file
(
'trace.json'
)
..
writeAsStringSync
(
'{}'
);
final
Map
<
String
,
Object
>
result
=
await
sizeAnalyzer
.
analyzeAotSnapshot
(
final
Map
<
String
,
Object
?
>
result
=
await
sizeAnalyzer
.
analyzeAotSnapshot
(
outputDirectory:
outputDirectory
,
aotSnapshot:
aotSizeJson
,
precompilerTrace:
precompilerTrace
,
...
...
@@ -223,4 +221,36 @@ void main() {
expect
(
result
[
'type'
],
'linux'
);
expect
(
result
[
'precompiler-trace'
],
<
String
,
Object
>{});
});
testWithoutContext
(
'handles null AOT snapshot json'
,
()
async
{
final
SizeAnalyzer
sizeAnalyzer
=
SizeAnalyzer
(
fileSystem:
fileSystem
,
logger:
logger
,
appFilenamePattern:
RegExp
(
r'lib.*app\.so'
),
flutterUsage:
TestUsage
(),
);
final
Directory
outputDirectory
=
fileSystem
.
directory
(
'example/out/foo.app'
)..
createSync
(
recursive:
true
);
final
File
invalidAotSizeJson
=
fileSystem
.
file
(
'test.json'
)..
writeAsStringSync
(
'null'
);
final
File
precompilerTrace
=
fileSystem
.
file
(
'trace.json'
);
await
expectLater
(
()
=>
sizeAnalyzer
.
analyzeAotSnapshot
(
outputDirectory:
outputDirectory
,
aotSnapshot:
invalidAotSizeJson
,
precompilerTrace:
precompilerTrace
,
type:
'linux'
,
),
throwsToolExit
());
final
File
apk
=
fileSystem
.
file
(
'test.apk'
)..
writeAsBytesSync
(
ZipEncoder
().
encode
(
Archive
())!);
await
expectLater
(
()
=>
sizeAnalyzer
.
analyzeZipSizeAndAotSnapshot
(
zipFile:
apk
,
aotSnapshot:
invalidAotSizeJson
,
precompilerTrace:
precompilerTrace
,
kind:
'apk'
,
),
throwsToolExit
());
});
}
packages/flutter_tools/test/integration.shard/analyze_size_test.dart
View file @
8d3bc184
...
...
@@ -9,6 +9,7 @@ import 'package:file_testing/file_testing.dart';
import
'package:flutter_tools/src/base/io.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'test_utils.dart'
;
const
String
apkDebugMessage
=
'A summary of your APK analysis can be found at: '
;
...
...
@@ -16,7 +17,7 @@ const String iosDebugMessage = 'A summary of your iOS bundle analysis can be fou
const
String
runDevToolsMessage
=
'flutter pub global activate devtools; flutter pub global run devtools '
;
void
main
(
)
{
test
Without
Context
(
'--analyze-size flag produces expected output on hello_world for Android'
,
()
async
{
test
Using
Context
(
'--analyze-size flag produces expected output on hello_world for Android'
,
()
async
{
final
String
workingDirectory
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'examples'
,
'hello_world'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
...
...
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