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
6c97dd2c
Commit
6c97dd2c
authored
Mar 04, 2017
by
Chris Bracken
Committed by
GitHub
Mar 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare locals as final where not reassigned (dev) (#8574)
parent
7a52fb67
Changes
35
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
215 additions
and
215 deletions
+215
-215
main.dart
dev/benchmarks/complex_layout/lib/main.dart
+1
-1
scroll_perf_test.dart
...nchmarks/complex_layout/test_driver/scroll_perf_test.dart
+3
-3
common.dart
dev/benchmarks/microbenchmarks/lib/common.dart
+1
-1
velocity_tracker_bench.dart
.../microbenchmarks/lib/gestures/velocity_tracker_bench.dart
+1
-1
animation_bench.dart
...enchmarks/microbenchmarks/lib/stocks/animation_bench.dart
+1
-1
build_bench.dart
dev/benchmarks/microbenchmarks/lib/stocks/build_bench.dart
+2
-2
layout_bench.dart
dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart
+2
-2
test.dart
dev/bots/test.dart
+8
-8
run.dart
dev/devicelab/bin/run.dart
+7
-7
analyzer_cli__analysis_time.dart
dev/devicelab/bin/tasks/analyzer_cli__analysis_time.dart
+3
-3
analyzer_server__analysis_time.dart
dev/devicelab/bin/tasks/analyzer_server__analysis_time.dart
+3
-3
hot_mode_dev_cycle__benchmark.dart
dev/devicelab/bin/tasks/hot_mode_dev_cycle__benchmark.dart
+3
-3
technical_debt__cost.dart
dev/devicelab/bin/tasks/technical_debt__cost.dart
+2
-2
adb.dart
dev/devicelab/lib/framework/adb.dart
+17
-17
benchmarks.dart
dev/devicelab/lib/framework/benchmarks.dart
+2
-2
framework.dart
dev/devicelab/lib/framework/framework.dart
+6
-6
manifest.dart
dev/devicelab/lib/framework/manifest.dart
+4
-4
runner.dart
dev/devicelab/lib/framework/runner.dart
+13
-13
utils.dart
dev/devicelab/lib/framework/utils.dart
+20
-20
gallery.dart
dev/devicelab/lib/tasks/gallery.dart
+8
-8
microbenchmarks.dart
dev/devicelab/lib/tasks/microbenchmarks.dart
+7
-7
perf_tests.dart
dev/devicelab/lib/tasks/perf_tests.dart
+23
-23
size_tests.dart
dev/devicelab/lib/tasks/size_tests.dart
+1
-1
adb_test.dart
dev/devicelab/test/adb_test.dart
+2
-2
manifest_test.dart
dev/devicelab/test/manifest_test.dart
+2
-2
run_test.dart
dev/devicelab/test/run_test.dart
+2
-2
card_collection.dart
dev/manual_tests/card_collection.dart
+6
-6
drag_and_drop.dart
dev/manual_tests/drag_and_drop.dart
+3
-3
overlay_geometry.dart
dev/manual_tests/overlay_geometry.dart
+8
-8
page_view.dart
dev/manual_tests/page_view.dart
+3
-3
card_collection_test.dart
dev/manual_tests/test/card_collection_test.dart
+1
-1
dartdoc.dart
dev/tools/dartdoc.dart
+14
-14
javadoc.dart
dev/tools/javadoc.dart
+7
-7
mega_gallery.dart
dev/tools/mega_gallery.dart
+15
-15
update_icons.dart
dev/tools/update_icons.dart
+14
-14
No files found.
dev/benchmarks/complex_layout/lib/main.dart
View file @
6c97dd2c
...
@@ -449,7 +449,7 @@ class ItemGalleryBox extends StatelessWidget {
...
@@ -449,7 +449,7 @@ class ItemGalleryBox extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
List
<
String
>
tabNames
=
<
String
>[
final
List
<
String
>
tabNames
=
<
String
>[
'A'
,
'B'
,
'C'
,
'D'
'A'
,
'B'
,
'C'
,
'D'
];
];
...
...
dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart
View file @
6c97dd2c
...
@@ -20,9 +20,9 @@ void main() {
...
@@ -20,9 +20,9 @@ void main() {
});
});
test
(
'measure'
,
()
async
{
test
(
'measure'
,
()
async
{
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
final
Timeline
timeline
=
await
driver
.
traceAction
(()
async
{
// Find the scrollable stock list
// Find the scrollable stock list
SerializableFinder
stockList
=
find
.
byValueKey
(
'main-scroll'
);
final
SerializableFinder
stockList
=
find
.
byValueKey
(
'main-scroll'
);
expect
(
stockList
,
isNotNull
);
expect
(
stockList
,
isNotNull
);
// Scroll down
// Scroll down
...
@@ -38,7 +38,7 @@ void main() {
...
@@ -38,7 +38,7 @@ void main() {
}
}
});
});
TimelineSummary
summary
=
new
TimelineSummary
.
summarize
(
timeline
);
final
TimelineSummary
summary
=
new
TimelineSummary
.
summarize
(
timeline
);
summary
.
writeSummaryToFile
(
'complex_layout_scroll_perf'
,
pretty:
true
);
summary
.
writeSummaryToFile
(
'complex_layout_scroll_perf'
,
pretty:
true
);
summary
.
writeTimelineToFile
(
'complex_layout_scroll_perf'
,
pretty:
true
);
summary
.
writeTimelineToFile
(
'complex_layout_scroll_perf'
,
pretty:
true
);
});
});
...
...
dev/benchmarks/microbenchmarks/lib/common.dart
View file @
6c97dd2c
...
@@ -54,7 +54,7 @@ class BenchmarkResultPrinter {
...
@@ -54,7 +54,7 @@ class BenchmarkResultPrinter {
}
}
String
_printPlainText
()
{
String
_printPlainText
()
{
StringBuffer
buf
=
new
StringBuffer
();
final
StringBuffer
buf
=
new
StringBuffer
();
for
(
_BenchmarkResult
result
in
_results
)
{
for
(
_BenchmarkResult
result
in
_results
)
{
buf
.
writeln
(
'
${result.description}
:
${result.value.toStringAsFixed(1)}
${result.unit}
'
);
buf
.
writeln
(
'
${result.description}
:
${result.value.toStringAsFixed(1)}
${result.unit}
'
);
}
}
...
...
dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart
View file @
6c97dd2c
...
@@ -24,7 +24,7 @@ void main() {
...
@@ -24,7 +24,7 @@ void main() {
}
}
watch
.
stop
();
watch
.
stop
();
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
final
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
printer
.
addResult
(
printer
.
addResult
(
description:
'Velocity tracker'
,
description:
'Velocity tracker'
,
value:
watch
.
elapsedMicroseconds
/
_kNumIters
,
value:
watch
.
elapsedMicroseconds
/
_kNumIters
,
...
...
dev/benchmarks/microbenchmarks/lib/stocks/animation_bench.dart
View file @
6c97dd2c
...
@@ -75,7 +75,7 @@ Future<Null> main() async {
...
@@ -75,7 +75,7 @@ Future<Null> main() async {
}
}
});
});
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
final
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
printer
.
addResult
(
printer
.
addResult
(
description:
'Stock animation'
,
description:
'Stock animation'
,
value:
wallClockWatch
.
elapsedMicroseconds
/
(
1000
*
1000
),
value:
wallClockWatch
.
elapsedMicroseconds
/
(
1000
*
1000
),
...
...
dev/benchmarks/microbenchmarks/lib/stocks/build_bench.dart
View file @
6c97dd2c
...
@@ -21,7 +21,7 @@ Future<Null> main() async {
...
@@ -21,7 +21,7 @@ Future<Null> main() async {
// This allows us to call onBeginFrame even when the engine didn't request it,
// This allows us to call onBeginFrame even when the engine didn't request it,
// and have it actually do something:
// and have it actually do something:
LiveTestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
final
LiveTestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
binding
.
allowAllFrames
=
true
;
binding
.
allowAllFrames
=
true
;
final
Stopwatch
watch
=
new
Stopwatch
();
final
Stopwatch
watch
=
new
Stopwatch
();
...
@@ -50,7 +50,7 @@ Future<Null> main() async {
...
@@ -50,7 +50,7 @@ Future<Null> main() async {
watch
.
stop
();
watch
.
stop
();
});
});
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
final
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
printer
.
addResult
(
printer
.
addResult
(
description:
'Stock build'
,
description:
'Stock build'
,
value:
watch
.
elapsedMicroseconds
/
iterations
,
value:
watch
.
elapsedMicroseconds
/
iterations
,
...
...
dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart
View file @
6c97dd2c
...
@@ -20,7 +20,7 @@ Future<Null> main() async {
...
@@ -20,7 +20,7 @@ Future<Null> main() async {
// This allows us to call onBeginFrame even when the engine didn't request it,
// This allows us to call onBeginFrame even when the engine didn't request it,
// and have it actually do something:
// and have it actually do something:
LiveTestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
final
LiveTestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
binding
.
allowAllFrames
=
true
;
binding
.
allowAllFrames
=
true
;
final
Stopwatch
watch
=
new
Stopwatch
();
final
Stopwatch
watch
=
new
Stopwatch
();
...
@@ -51,7 +51,7 @@ Future<Null> main() async {
...
@@ -51,7 +51,7 @@ Future<Null> main() async {
watch
.
stop
();
watch
.
stop
();
});
});
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
final
BenchmarkResultPrinter
printer
=
new
BenchmarkResultPrinter
();
printer
.
addResult
(
printer
.
addResult
(
description:
'Stock layout'
,
description:
'Stock layout'
,
value:
watch
.
elapsedMicroseconds
/
iterations
,
value:
watch
.
elapsedMicroseconds
/
iterations
,
...
...
dev/bots/test.dart
View file @
6c97dd2c
...
@@ -31,7 +31,7 @@ Future<Null> main() async {
...
@@ -31,7 +31,7 @@ Future<Null> main() async {
print
(
'
\
x1B[32mDONE: Analysis successful.
\
x1B[0m'
);
print
(
'
\
x1B[32mDONE: Analysis successful.
\
x1B[0m'
);
}
else
{
}
else
{
// Verify that the tests actually return failure on failure and success on success.
// Verify that the tests actually return failure on failure and success on success.
String
automatedTests
=
p
.
join
(
flutterRoot
,
'dev'
,
'automated_tests'
);
final
String
automatedTests
=
p
.
join
(
flutterRoot
,
'dev'
,
'automated_tests'
);
await
_runFlutterTest
(
automatedTests
,
await
_runFlutterTest
(
automatedTests
,
script:
p
.
join
(
'test_smoke_test'
,
'fail_test.dart'
),
script:
p
.
join
(
'test_smoke_test'
,
'fail_test.dart'
),
expectFailure:
true
,
expectFailure:
true
,
...
@@ -67,7 +67,7 @@ Future<Null> main() async {
...
@@ -67,7 +67,7 @@ Future<Null> main() async {
printOutput:
false
,
printOutput:
false
,
);
);
List
<
String
>
coverageFlags
=
<
String
>[];
final
List
<
String
>
coverageFlags
=
<
String
>[];
if
(
Platform
.
environment
[
'TRAVIS'
]
!=
null
&&
Platform
.
environment
[
'TRAVIS_PULL_REQUEST'
]
==
'false'
)
if
(
Platform
.
environment
[
'TRAVIS'
]
!=
null
&&
Platform
.
environment
[
'TRAVIS_PULL_REQUEST'
]
==
'false'
)
coverageFlags
.
add
(
'--coverage'
);
coverageFlags
.
add
(
'--coverage'
);
...
@@ -100,15 +100,15 @@ Future<Null> _runCmd(String executable, List<String> arguments, {
...
@@ -100,15 +100,15 @@ Future<Null> _runCmd(String executable, List<String> arguments, {
bool
printOutput:
true
,
bool
printOutput:
true
,
bool
skip:
false
,
bool
skip:
false
,
})
async
{
})
async
{
String
cmd
=
'
${p.relative(executable)}
${arguments.join(' ')}
'
;
final
String
cmd
=
'
${p.relative(executable)}
${arguments.join(' ')}
'
;
String
relativeWorkingDir
=
p
.
relative
(
workingDirectory
);
final
String
relativeWorkingDir
=
p
.
relative
(
workingDirectory
);
if
(
skip
)
{
if
(
skip
)
{
_printProgress
(
'SKIPPING'
,
relativeWorkingDir
,
cmd
);
_printProgress
(
'SKIPPING'
,
relativeWorkingDir
,
cmd
);
return
null
;
return
null
;
}
}
_printProgress
(
'RUNNING'
,
relativeWorkingDir
,
cmd
);
_printProgress
(
'RUNNING'
,
relativeWorkingDir
,
cmd
);
Process
process
=
await
Process
.
start
(
executable
,
arguments
,
final
Process
process
=
await
Process
.
start
(
executable
,
arguments
,
workingDirectory:
workingDirectory
,
workingDirectory:
workingDirectory
,
environment:
environment
,
environment:
environment
,
);
);
...
@@ -118,7 +118,7 @@ Future<Null> _runCmd(String executable, List<String> arguments, {
...
@@ -118,7 +118,7 @@ Future<Null> _runCmd(String executable, List<String> arguments, {
stderr
.
addStream
(
process
.
stderr
);
stderr
.
addStream
(
process
.
stderr
);
}
}
int
exitCode
=
await
process
.
exitCode
;
final
int
exitCode
=
await
process
.
exitCode
;
if
((
exitCode
==
0
)
==
expectFailure
)
{
if
((
exitCode
==
0
)
==
expectFailure
)
{
print
(
print
(
'
\
x1B[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
\
x1B[0m
\n
'
'
\
x1B[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
\
x1B[0m
\n
'
...
@@ -136,7 +136,7 @@ Future<Null> _runFlutterTest(String workingDirectory, {
...
@@ -136,7 +136,7 @@ Future<Null> _runFlutterTest(String workingDirectory, {
List
<
String
>
options:
const
<
String
>[],
List
<
String
>
options:
const
<
String
>[],
bool
skip:
false
,
bool
skip:
false
,
})
{
})
{
List
<
String
>
args
=
<
String
>[
'test'
]..
addAll
(
options
);
final
List
<
String
>
args
=
<
String
>[
'test'
]..
addAll
(
options
);
if
(
flutterTestArgs
!=
null
)
if
(
flutterTestArgs
!=
null
)
args
.
add
(
flutterTestArgs
);
args
.
add
(
flutterTestArgs
);
if
(
script
!=
null
)
if
(
script
!=
null
)
...
@@ -152,7 +152,7 @@ Future<Null> _runFlutterTest(String workingDirectory, {
...
@@ -152,7 +152,7 @@ Future<Null> _runFlutterTest(String workingDirectory, {
Future
<
Null
>
_runAllDartTests
(
String
workingDirectory
,
{
Future
<
Null
>
_runAllDartTests
(
String
workingDirectory
,
{
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
environment
,
})
{
})
{
List
<
String
>
args
=
<
String
>[
'--checked'
,
p
.
join
(
'test'
,
'all.dart'
)];
final
List
<
String
>
args
=
<
String
>[
'--checked'
,
p
.
join
(
'test'
,
'all.dart'
)];
return
_runCmd
(
dart
,
args
,
return
_runCmd
(
dart
,
args
,
workingDirectory:
workingDirectory
,
workingDirectory:
workingDirectory
,
environment:
environment
,
environment:
environment
,
...
...
dev/devicelab/bin/run.dart
View file @
6c97dd2c
...
@@ -33,14 +33,14 @@ Future<Null> main(List<String> rawArgs) async {
...
@@ -33,14 +33,14 @@ Future<Null> main(List<String> rawArgs) async {
if
(!
args
.
wasParsed
(
'task'
))
{
if
(!
args
.
wasParsed
(
'task'
))
{
if
(
args
.
wasParsed
(
'stage'
))
{
if
(
args
.
wasParsed
(
'stage'
))
{
String
stageName
=
args
[
'stage'
];
final
String
stageName
=
args
[
'stage'
];
List
<
ManifestTask
>
tasks
=
loadTaskManifest
().
tasks
;
final
List
<
ManifestTask
>
tasks
=
loadTaskManifest
().
tasks
;
for
(
ManifestTask
task
in
tasks
)
{
for
(
ManifestTask
task
in
tasks
)
{
if
(
task
.
stage
==
stageName
)
if
(
task
.
stage
==
stageName
)
_taskNames
.
add
(
task
.
name
);
_taskNames
.
add
(
task
.
name
);
}
}
}
else
if
(
args
.
wasParsed
(
'all'
))
{
}
else
if
(
args
.
wasParsed
(
'all'
))
{
List
<
ManifestTask
>
tasks
=
loadTaskManifest
().
tasks
;
final
List
<
ManifestTask
>
tasks
=
loadTaskManifest
().
tasks
;
for
(
ManifestTask
task
in
tasks
)
{
for
(
ManifestTask
task
in
tasks
)
{
_taskNames
.
add
(
task
.
name
);
_taskNames
.
add
(
task
.
name
);
}
}
...
@@ -53,11 +53,11 @@ Future<Null> main(List<String> rawArgs) async {
...
@@ -53,11 +53,11 @@ Future<Null> main(List<String> rawArgs) async {
return
null
;
return
null
;
}
}
bool
silent
=
args
[
'silent'
];
final
bool
silent
=
args
[
'silent'
];
for
(
String
taskName
in
_taskNames
)
{
for
(
String
taskName
in
_taskNames
)
{
section
(
'Running task "
$taskName
"'
);
section
(
'Running task "
$taskName
"'
);
Map
<
String
,
dynamic
>
result
=
await
runTask
(
taskName
,
silent:
silent
);
final
Map
<
String
,
dynamic
>
result
=
await
runTask
(
taskName
,
silent:
silent
);
if
(!
result
[
'success'
])
if
(!
result
[
'success'
])
exitCode
=
1
;
exitCode
=
1
;
...
@@ -82,8 +82,8 @@ final ArgParser _argParser = new ArgParser()
...
@@ -82,8 +82,8 @@ final ArgParser _argParser = new ArgParser()
'This option may be repeated to specify multiple tasks.'
,
'This option may be repeated to specify multiple tasks.'
,
callback:
(
List
<
String
>
value
)
{
callback:
(
List
<
String
>
value
)
{
for
(
String
nameOrPath
in
value
)
{
for
(
String
nameOrPath
in
value
)
{
List
<
String
>
fragments
=
path
.
split
(
nameOrPath
);
final
List
<
String
>
fragments
=
path
.
split
(
nameOrPath
);
bool
isDartFile
=
fragments
.
last
.
endsWith
(
'.dart'
);
final
bool
isDartFile
=
fragments
.
last
.
endsWith
(
'.dart'
);
if
(
fragments
.
length
==
1
&&
!
isDartFile
)
{
if
(
fragments
.
length
==
1
&&
!
isDartFile
)
{
// Not a path
// Not a path
...
...
dev/devicelab/bin/tasks/analyzer_cli__analysis_time.dart
View file @
6c97dd2c
...
@@ -9,9 +9,9 @@ import 'package:flutter_devicelab/framework/framework.dart';
...
@@ -9,9 +9,9 @@ import 'package:flutter_devicelab/framework/framework.dart';
import
'package:flutter_devicelab/framework/utils.dart'
;
import
'package:flutter_devicelab/framework/utils.dart'
;
Future
<
Null
>
main
()
async
{
Future
<
Null
>
main
()
async
{
String
revision
=
await
getCurrentFlutterRepoCommit
();
final
String
revision
=
await
getCurrentFlutterRepoCommit
();
DateTime
revisionTimestamp
=
await
getFlutterRepoCommitTimestamp
(
revision
);
final
DateTime
revisionTimestamp
=
await
getFlutterRepoCommitTimestamp
(
revision
);
String
dartSdkVersion
=
await
getDartVersion
();
final
String
dartSdkVersion
=
await
getDartVersion
();
await
task
(
createAnalyzerCliTest
(
await
task
(
createAnalyzerCliTest
(
sdk:
dartSdkVersion
,
sdk:
dartSdkVersion
,
commit:
revision
,
commit:
revision
,
...
...
dev/devicelab/bin/tasks/analyzer_server__analysis_time.dart
View file @
6c97dd2c
...
@@ -9,9 +9,9 @@ import 'package:flutter_devicelab/framework/framework.dart';
...
@@ -9,9 +9,9 @@ import 'package:flutter_devicelab/framework/framework.dart';
import
'package:flutter_devicelab/framework/utils.dart'
;
import
'package:flutter_devicelab/framework/utils.dart'
;
Future
<
Null
>
main
()
async
{
Future
<
Null
>
main
()
async
{
String
revision
=
await
getCurrentFlutterRepoCommit
();
final
String
revision
=
await
getCurrentFlutterRepoCommit
();
DateTime
revisionTimestamp
=
await
getFlutterRepoCommitTimestamp
(
revision
);
final
DateTime
revisionTimestamp
=
await
getFlutterRepoCommitTimestamp
(
revision
);
String
dartSdkVersion
=
await
getDartVersion
();
final
String
dartSdkVersion
=
await
getDartVersion
();
await
task
(
createAnalyzerServerTest
(
await
task
(
createAnalyzerServerTest
(
sdk:
dartSdkVersion
,
sdk:
dartSdkVersion
,
commit:
revision
,
commit:
revision
,
...
...
dev/devicelab/bin/tasks/hot_mode_dev_cycle__benchmark.dart
View file @
6c97dd2c
...
@@ -12,11 +12,11 @@ import 'package:flutter_devicelab/framework/utils.dart';
...
@@ -12,11 +12,11 @@ import 'package:flutter_devicelab/framework/utils.dart';
void
main
(
)
{
void
main
(
)
{
task
(()
async
{
task
(()
async
{
Device
device
=
await
devices
.
workingDevice
;
final
Device
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
await
device
.
unlock
();
Directory
appDir
=
final
Directory
appDir
=
dir
(
path
.
join
(
flutterDirectory
.
path
,
'examples/flutter_gallery'
));
dir
(
path
.
join
(
flutterDirectory
.
path
,
'examples/flutter_gallery'
));
File
benchmarkFile
=
file
(
path
.
join
(
appDir
.
path
,
'hot_benchmark.json'
));
final
File
benchmarkFile
=
file
(
path
.
join
(
appDir
.
path
,
'hot_benchmark.json'
));
rm
(
benchmarkFile
);
rm
(
benchmarkFile
);
await
inDirectory
(
appDir
,
()
async
{
await
inDirectory
(
appDir
,
()
async
{
return
await
flutter
(
'run'
,
return
await
flutter
(
'run'
,
...
...
dev/devicelab/bin/tasks/technical_debt__cost.dart
View file @
6c97dd2c
...
@@ -39,7 +39,7 @@ const String _kBenchmarkKey = 'technical_debt_in_dollars';
...
@@ -39,7 +39,7 @@ const String _kBenchmarkKey = 'technical_debt_in_dollars';
Future
<
Null
>
main
()
async
{
Future
<
Null
>
main
()
async
{
await
task
(()
async
{
await
task
(()
async
{
Process
git
=
await
startProcess
(
final
Process
git
=
await
startProcess
(
'git'
,
'git'
,
<
String
>[
'ls-files'
,
'--full-name'
,
flutterDirectory
.
path
],
<
String
>[
'ls-files'
,
'--full-name'
,
flutterDirectory
.
path
],
workingDirectory:
flutterDirectory
.
path
,
workingDirectory:
flutterDirectory
.
path
,
...
@@ -47,7 +47,7 @@ Future<Null> main() async {
...
@@ -47,7 +47,7 @@ Future<Null> main() async {
double
total
=
0.0
;
double
total
=
0.0
;
await
for
(
String
entry
in
git
.
stdout
.
transform
(
UTF8
.
decoder
).
transform
(
const
LineSplitter
()))
await
for
(
String
entry
in
git
.
stdout
.
transform
(
UTF8
.
decoder
).
transform
(
const
LineSplitter
()))
total
+=
await
findCostsForFile
(
new
File
(
path
.
join
(
flutterDirectory
.
path
,
entry
)));
total
+=
await
findCostsForFile
(
new
File
(
path
.
join
(
flutterDirectory
.
path
,
entry
)));
int
gitExitCode
=
await
git
.
exitCode
;
final
int
gitExitCode
=
await
git
.
exitCode
;
if
(
gitExitCode
!=
0
)
if
(
gitExitCode
!=
0
)
throw
new
Exception
(
'git exit with unexpected error code
$gitExitCode
'
);
throw
new
Exception
(
'git exit with unexpected error code
$gitExitCode
'
);
return
new
TaskResult
.
success
(
return
new
TaskResult
.
success
(
...
...
dev/devicelab/lib/framework/adb.dart
View file @
6c97dd2c
...
@@ -118,7 +118,7 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
...
@@ -118,7 +118,7 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
/// [workingDevice].
/// [workingDevice].
@override
@override
Future
<
Null
>
chooseWorkingDevice
()
async
{
Future
<
Null
>
chooseWorkingDevice
()
async
{
List
<
Device
>
allDevices
=
(
await
discoverDevices
())
final
List
<
Device
>
allDevices
=
(
await
discoverDevices
())
.
map
((
String
id
)
=>
new
AndroidDevice
(
deviceId:
id
))
.
map
((
String
id
)
=>
new
AndroidDevice
(
deviceId:
id
))
.
toList
();
.
toList
();
...
@@ -131,9 +131,9 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
...
@@ -131,9 +131,9 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
@override
@override
Future
<
List
<
String
>>
discoverDevices
()
async
{
Future
<
List
<
String
>>
discoverDevices
()
async
{
List
<
String
>
output
=
(
await
eval
(
adbPath
,
<
String
>[
'devices'
,
'-l'
],
canFail:
false
))
final
List
<
String
>
output
=
(
await
eval
(
adbPath
,
<
String
>[
'devices'
,
'-l'
],
canFail:
false
))
.
trim
().
split
(
'
\n
'
);
.
trim
().
split
(
'
\n
'
);
List
<
String
>
results
=
<
String
>[];
final
List
<
String
>
results
=
<
String
>[];
for
(
String
line
in
output
)
{
for
(
String
line
in
output
)
{
// Skip lines like: * daemon started successfully *
// Skip lines like: * daemon started successfully *
if
(
line
.
startsWith
(
'* daemon '
))
if
(
line
.
startsWith
(
'* daemon '
))
...
@@ -143,10 +143,10 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
...
@@ -143,10 +143,10 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
continue
;
continue
;
if
(
_kDeviceRegex
.
hasMatch
(
line
))
{
if
(
_kDeviceRegex
.
hasMatch
(
line
))
{
Match
match
=
_kDeviceRegex
.
firstMatch
(
line
);
final
Match
match
=
_kDeviceRegex
.
firstMatch
(
line
);
String
deviceID
=
match
[
1
];
final
String
deviceID
=
match
[
1
];
String
deviceState
=
match
[
2
];
final
String
deviceState
=
match
[
2
];
if
(!
const
<
String
>[
'unauthorized'
,
'offline'
].
contains
(
deviceState
))
{
if
(!
const
<
String
>[
'unauthorized'
,
'offline'
].
contains
(
deviceState
))
{
results
.
add
(
deviceID
);
results
.
add
(
deviceID
);
...
@@ -161,10 +161,10 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
...
@@ -161,10 +161,10 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
@override
@override
Future
<
Map
<
String
,
HealthCheckResult
>>
checkDevices
()
async
{
Future
<
Map
<
String
,
HealthCheckResult
>>
checkDevices
()
async
{
Map
<
String
,
HealthCheckResult
>
results
=
<
String
,
HealthCheckResult
>{};
final
Map
<
String
,
HealthCheckResult
>
results
=
<
String
,
HealthCheckResult
>{};
for
(
String
deviceId
in
await
discoverDevices
())
{
for
(
String
deviceId
in
await
discoverDevices
())
{
try
{
try
{
AndroidDevice
device
=
new
AndroidDevice
(
deviceId:
deviceId
);
final
AndroidDevice
device
=
new
AndroidDevice
(
deviceId:
deviceId
);
// Just a smoke test that we can read wakefulness state
// Just a smoke test that we can read wakefulness state
// TODO(yjbanov): check battery level
// TODO(yjbanov): check battery level
await
device
.
_getWakefulness
();
await
device
.
_getWakefulness
();
...
@@ -240,8 +240,8 @@ class AndroidDevice implements Device {
...
@@ -240,8 +240,8 @@ class AndroidDevice implements Device {
///
///
/// See: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/PowerManagerInternal.java
/// See: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/PowerManagerInternal.java
Future
<
String
>
_getWakefulness
()
async
{
Future
<
String
>
_getWakefulness
()
async
{
String
powerInfo
=
await
shellEval
(
'dumpsys'
,
<
String
>[
'power'
]);
final
String
powerInfo
=
await
shellEval
(
'dumpsys'
,
<
String
>[
'power'
]);
String
wakefulness
=
grep
(
'mWakefulness='
,
from:
powerInfo
).
single
.
split
(
'='
)[
1
].
trim
();
final
String
wakefulness
=
grep
(
'mWakefulness='
,
from:
powerInfo
).
single
.
split
(
'='
)[
1
].
trim
();
return
wakefulness
;
return
wakefulness
;
}
}
...
@@ -257,8 +257,8 @@ class AndroidDevice implements Device {
...
@@ -257,8 +257,8 @@ class AndroidDevice implements Device {
@override
@override
Future
<
Map
<
String
,
dynamic
>>
getMemoryStats
(
String
packageName
)
async
{
Future
<
Map
<
String
,
dynamic
>>
getMemoryStats
(
String
packageName
)
async
{
String
meminfo
=
await
shellEval
(
'dumpsys'
,
<
String
>[
'meminfo'
,
packageName
]);
final
String
meminfo
=
await
shellEval
(
'dumpsys'
,
<
String
>[
'meminfo'
,
packageName
]);
Match
match
=
new
RegExp
(
r'TOTAL\s+(\d+)'
).
firstMatch
(
meminfo
);
final
Match
match
=
new
RegExp
(
r'TOTAL\s+(\d+)'
).
firstMatch
(
meminfo
);
return
<
String
,
dynamic
>{
return
<
String
,
dynamic
>{
'total_kb'
:
int
.
parse
(
match
.
group
(
1
)),
'total_kb'
:
int
.
parse
(
match
.
group
(
1
)),
};
};
...
@@ -295,7 +295,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
...
@@ -295,7 +295,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
/// [workingDevice].
/// [workingDevice].
@override
@override
Future
<
Null
>
chooseWorkingDevice
()
async
{
Future
<
Null
>
chooseWorkingDevice
()
async
{
List
<
IosDevice
>
allDevices
=
(
await
discoverDevices
())
final
List
<
IosDevice
>
allDevices
=
(
await
discoverDevices
())
.
map
((
String
id
)
=>
new
IosDevice
(
deviceId:
id
))
.
map
((
String
id
)
=>
new
IosDevice
(
deviceId:
id
))
.
toList
();
.
toList
();
...
@@ -309,7 +309,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
...
@@ -309,7 +309,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
@override
@override
Future
<
List
<
String
>>
discoverDevices
()
async
{
Future
<
List
<
String
>>
discoverDevices
()
async
{
// TODO: use the -k UniqueDeviceID option, which requires much less parsing.
// TODO: use the -k UniqueDeviceID option, which requires much less parsing.
List
<
String
>
iosDeviceIds
=
grep
(
'UniqueDeviceID'
,
from:
await
eval
(
'ideviceinfo'
,
<
String
>[]))
final
List
<
String
>
iosDeviceIds
=
grep
(
'UniqueDeviceID'
,
from:
await
eval
(
'ideviceinfo'
,
<
String
>[]))
.
map
((
String
line
)
=>
line
.
split
(
' '
).
last
).
toList
();
.
map
((
String
line
)
=>
line
.
split
(
' '
).
last
).
toList
();
if
(
iosDeviceIds
.
isEmpty
)
if
(
iosDeviceIds
.
isEmpty
)
...
@@ -320,7 +320,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
...
@@ -320,7 +320,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
@override
@override
Future
<
Map
<
String
,
HealthCheckResult
>>
checkDevices
()
async
{
Future
<
Map
<
String
,
HealthCheckResult
>>
checkDevices
()
async
{
Map
<
String
,
HealthCheckResult
>
results
=
<
String
,
HealthCheckResult
>{};
final
Map
<
String
,
HealthCheckResult
>
results
=
<
String
,
HealthCheckResult
>{};
for
(
String
deviceId
in
await
discoverDevices
())
{
for
(
String
deviceId
in
await
discoverDevices
())
{
// TODO: do a more meaningful connectivity check than just recording the ID
// TODO: do a more meaningful connectivity check than just recording the ID
results
[
'ios-device-
$deviceId
'
]
=
new
HealthCheckResult
.
success
();
results
[
'ios-device-
$deviceId
'
]
=
new
HealthCheckResult
.
success
();
...
@@ -376,13 +376,13 @@ class IosDevice implements Device {
...
@@ -376,13 +376,13 @@ class IosDevice implements Device {
/// Path to the `adb` executable.
/// Path to the `adb` executable.
String
get
adbPath
{
String
get
adbPath
{
String
androidHome
=
Platform
.
environment
[
'ANDROID_HOME'
];
final
String
androidHome
=
Platform
.
environment
[
'ANDROID_HOME'
];
if
(
androidHome
==
null
)
if
(
androidHome
==
null
)
throw
'ANDROID_HOME environment variable missing. This variable must '
throw
'ANDROID_HOME environment variable missing. This variable must '
'point to the Android SDK directory containing platform-tools.'
;
'point to the Android SDK directory containing platform-tools.'
;
File
adbPath
=
file
(
path
.
join
(
androidHome
,
'platform-tools/adb'
));
final
File
adbPath
=
file
(
path
.
join
(
androidHome
,
'platform-tools/adb'
));
if
(!
adbPath
.
existsSync
())
throw
'adb not found at:
$adbPath
'
;
if
(!
adbPath
.
existsSync
())
throw
'adb not found at:
$adbPath
'
;
...
...
dev/devicelab/lib/framework/benchmarks.dart
View file @
6c97dd2c
...
@@ -33,7 +33,7 @@ Future<num> runBenchmark(Benchmark benchmark, {
...
@@ -33,7 +33,7 @@ Future<num> runBenchmark(Benchmark benchmark, {
})
async
{
})
async
{
await
benchmark
.
init
();
await
benchmark
.
init
();
List
<
num
>
allRuns
=
<
num
>[];
final
List
<
num
>
allRuns
=
<
num
>[];
num
minValue
;
num
minValue
;
...
@@ -46,7 +46,7 @@ Future<num> runBenchmark(Benchmark benchmark, {
...
@@ -46,7 +46,7 @@ Future<num> runBenchmark(Benchmark benchmark, {
print
(
''
);
print
(
''
);
try
{
try
{
num
result
=
await
benchmark
.
run
();
final
num
result
=
await
benchmark
.
run
();
allRuns
.
add
(
result
);
allRuns
.
add
(
result
);
if
(
minValue
==
null
||
result
<
minValue
)
{
if
(
minValue
==
null
||
result
<
minValue
)
{
...
...
dev/devicelab/lib/framework/framework.dart
View file @
6c97dd2c
...
@@ -43,7 +43,7 @@ Future<TaskResult> task(TaskFunction task) {
...
@@ -43,7 +43,7 @@ Future<TaskResult> task(TaskFunction task) {
print
(
'
${rec.level.name}
:
${rec.time}
:
${rec.message}
'
);
print
(
'
${rec.level.name}
:
${rec.time}
:
${rec.message}
'
);
});
});
_TaskRunner
runner
=
new
_TaskRunner
(
task
);
final
_TaskRunner
runner
=
new
_TaskRunner
(
task
);
runner
.
keepVmAliveUntilTaskRunRequested
();
runner
.
keepVmAliveUntilTaskRunRequested
();
return
runner
.
whenDone
;
return
runner
.
whenDone
;
}
}
...
@@ -63,7 +63,7 @@ class _TaskRunner {
...
@@ -63,7 +63,7 @@ class _TaskRunner {
_TaskRunner
(
this
.
task
)
{
_TaskRunner
(
this
.
task
)
{
registerExtension
(
'ext.cocoonRunTask'
,
registerExtension
(
'ext.cocoonRunTask'
,
(
String
method
,
Map
<
String
,
String
>
parameters
)
async
{
(
String
method
,
Map
<
String
,
String
>
parameters
)
async
{
TaskResult
result
=
await
run
();
final
TaskResult
result
=
await
run
();
return
new
ServiceExtensionResponse
.
result
(
JSON
.
encode
(
result
.
toJson
()));
return
new
ServiceExtensionResponse
.
result
(
JSON
.
encode
(
result
.
toJson
()));
});
});
registerExtension
(
'ext.cocoonRunnerReady'
,
registerExtension
(
'ext.cocoonRunnerReady'
,
...
@@ -78,7 +78,7 @@ class _TaskRunner {
...
@@ -78,7 +78,7 @@ class _TaskRunner {
Future
<
TaskResult
>
run
()
async
{
Future
<
TaskResult
>
run
()
async
{
try
{
try
{
_taskStarted
=
true
;
_taskStarted
=
true
;
TaskResult
result
=
await
_performTask
().
timeout
(
taskTimeout
);
final
TaskResult
result
=
await
_performTask
().
timeout
(
taskTimeout
);
_completer
.
complete
(
result
);
_completer
.
complete
(
result
);
return
result
;
return
result
;
}
on
TimeoutException
catch
(
_
)
{
}
on
TimeoutException
catch
(
_
)
{
...
@@ -117,11 +117,11 @@ class _TaskRunner {
...
@@ -117,11 +117,11 @@ class _TaskRunner {
}
}
Future
<
TaskResult
>
_performTask
()
{
Future
<
TaskResult
>
_performTask
()
{
Completer
<
TaskResult
>
completer
=
new
Completer
<
TaskResult
>();
final
Completer
<
TaskResult
>
completer
=
new
Completer
<
TaskResult
>();
Chain
.
capture
(()
async
{
Chain
.
capture
(()
async
{
completer
.
complete
(
await
task
());
completer
.
complete
(
await
task
());
},
onError:
(
dynamic
taskError
,
Chain
taskErrorStack
)
{
},
onError:
(
dynamic
taskError
,
Chain
taskErrorStack
)
{
String
message
=
'Task failed:
$taskError
'
;
final
String
message
=
'Task failed:
$taskError
'
;
stderr
stderr
..
writeln
(
message
)
..
writeln
(
message
)
..
writeln
(
'
\n
Stack trace:'
)
..
writeln
(
'
\n
Stack trace:'
)
...
@@ -210,7 +210,7 @@ class TaskResult {
...
@@ -210,7 +210,7 @@ class TaskResult {
/// "reason": failure reason string valid only for unsuccessful results
/// "reason": failure reason string valid only for unsuccessful results
/// }
/// }
Map
<
String
,
dynamic
>
toJson
()
{
Map
<
String
,
dynamic
>
toJson
()
{
Map
<
String
,
dynamic
>
json
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
json
=
<
String
,
dynamic
>{
'success'
:
succeeded
,
'success'
:
succeeded
,
};
};
...
...
dev/devicelab/lib/framework/manifest.dart
View file @
6c97dd2c
...
@@ -9,7 +9,7 @@ import 'utils.dart';
...
@@ -9,7 +9,7 @@ import 'utils.dart';
/// Loads manifest data from `manifest.yaml` file or from [yaml], if present.
/// Loads manifest data from `manifest.yaml` file or from [yaml], if present.
Manifest
loadTaskManifest
(
[
String
yaml
])
{
Manifest
loadTaskManifest
(
[
String
yaml
])
{
dynamic
manifestYaml
=
yaml
==
null
final
dynamic
manifestYaml
=
yaml
==
null
?
loadYaml
(
file
(
'manifest.yaml'
).
readAsStringSync
())
?
loadYaml
(
file
(
'manifest.yaml'
).
readAsStringSync
())
:
loadYamlNode
(
yaml
);
:
loadYamlNode
(
yaml
);
...
@@ -33,7 +33,7 @@ class ManifestTask {
...
@@ -33,7 +33,7 @@ class ManifestTask {
@required
this
.
stage
,
@required
this
.
stage
,
@required
this
.
requiredAgentCapabilities
,
@required
this
.
requiredAgentCapabilities
,
})
{
})
{
String
taskName
=
'task "
$name
"'
;
final
String
taskName
=
'task "
$name
"'
;
_checkIsNotBlank
(
name
,
'Task name'
,
taskName
);
_checkIsNotBlank
(
name
,
'Task name'
,
taskName
);
_checkIsNotBlank
(
description
,
'Task description'
,
taskName
);
_checkIsNotBlank
(
description
,
'Task description'
,
taskName
);
_checkIsNotBlank
(
stage
,
'Task stage'
,
taskName
);
_checkIsNotBlank
(
stage
,
'Task stage'
,
taskName
);
...
@@ -84,7 +84,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) {
...
@@ -84,7 +84,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) {
'required_agent_capabilities'
,
'required_agent_capabilities'
,
]);
]);
List
<
String
>
capabilities
=
_validateAndParseCapabilities
(
taskName
,
taskYaml
[
'required_agent_capabilities'
]);
final
List
<
String
>
capabilities
=
_validateAndParseCapabilities
(
taskName
,
taskYaml
[
'required_agent_capabilities'
]);
return
new
ManifestTask
.
_
(
return
new
ManifestTask
.
_
(
name:
taskName
,
name:
taskName
,
description:
taskYaml
[
'description'
],
description:
taskYaml
[
'description'
],
...
@@ -96,7 +96,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) {
...
@@ -96,7 +96,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) {
List
<
String
>
_validateAndParseCapabilities
(
String
taskName
,
dynamic
capabilitiesYaml
)
{
List
<
String
>
_validateAndParseCapabilities
(
String
taskName
,
dynamic
capabilitiesYaml
)
{
_checkType
(
capabilitiesYaml
is
List
,
capabilitiesYaml
,
'required_agent_capabilities'
,
'list'
);
_checkType
(
capabilitiesYaml
is
List
,
capabilitiesYaml
,
'required_agent_capabilities'
,
'list'
);
for
(
int
i
=
0
;
i
<
capabilitiesYaml
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
capabilitiesYaml
.
length
;
i
++)
{
dynamic
capability
=
capabilitiesYaml
[
i
];
final
dynamic
capability
=
capabilitiesYaml
[
i
];
_checkType
(
capability
is
String
,
capability
,
'required_agent_capabilities[
$i
]'
,
'string'
);
_checkType
(
capability
is
String
,
capability
,
'required_agent_capabilities[
$i
]'
,
'string'
);
}
}
return
capabilitiesYaml
;
return
capabilitiesYaml
;
...
...
dev/devicelab/lib/framework/runner.dart
View file @
6c97dd2c
...
@@ -23,13 +23,13 @@ const Duration taskTimeoutWithGracePeriod = const Duration(minutes: 11);
...
@@ -23,13 +23,13 @@ const Duration taskTimeoutWithGracePeriod = const Duration(minutes: 11);
/// Running the task in [silent] mode will suppress standard output from task
/// Running the task in [silent] mode will suppress standard output from task
/// processes and only print standard errors.
/// processes and only print standard errors.
Future
<
Map
<
String
,
dynamic
>>
runTask
(
String
taskName
,
{
bool
silent:
false
})
async
{
Future
<
Map
<
String
,
dynamic
>>
runTask
(
String
taskName
,
{
bool
silent:
false
})
async
{
String
taskExecutable
=
'bin/tasks/
$taskName
.dart'
;
final
String
taskExecutable
=
'bin/tasks/
$taskName
.dart'
;
if
(!
file
(
taskExecutable
).
existsSync
())
if
(!
file
(
taskExecutable
).
existsSync
())
throw
'Executable Dart file not found:
$taskExecutable
'
;
throw
'Executable Dart file not found:
$taskExecutable
'
;
int
vmServicePort
=
await
findAvailablePort
();
final
int
vmServicePort
=
await
findAvailablePort
();
Process
runner
=
await
startProcess
(
dartBin
,
<
String
>[
final
Process
runner
=
await
startProcess
(
dartBin
,
<
String
>[
'--enable-vm-service=
$vmServicePort
'
,
'--enable-vm-service=
$vmServicePort
'
,
'--no-pause-isolates-on-exit'
,
'--no-pause-isolates-on-exit'
,
taskExecutable
,
taskExecutable
,
...
@@ -41,7 +41,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
...
@@ -41,7 +41,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
runnerFinished
=
true
;
runnerFinished
=
true
;
});
});
StreamSubscription
<
String
>
stdoutSub
=
runner
.
stdout
final
StreamSubscription
<
String
>
stdoutSub
=
runner
.
stdout
.
transform
(
const
Utf8Decoder
())
.
transform
(
const
Utf8Decoder
())
.
transform
(
const
LineSplitter
())
.
transform
(
const
LineSplitter
())
.
listen
((
String
line
)
{
.
listen
((
String
line
)
{
...
@@ -50,7 +50,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
...
@@ -50,7 +50,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
}
}
});
});
StreamSubscription
<
String
>
stderrSub
=
runner
.
stderr
final
StreamSubscription
<
String
>
stderrSub
=
runner
.
stderr
.
transform
(
const
Utf8Decoder
())
.
transform
(
const
Utf8Decoder
())
.
transform
(
const
LineSplitter
())
.
transform
(
const
LineSplitter
())
.
listen
((
String
line
)
{
.
listen
((
String
line
)
{
...
@@ -59,9 +59,9 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
...
@@ -59,9 +59,9 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
String
waitingFor
=
'connection'
;
String
waitingFor
=
'connection'
;
try
{
try
{
VMIsolateRef
isolate
=
await
_connectToRunnerIsolate
(
vmServicePort
);
final
VMIsolateRef
isolate
=
await
_connectToRunnerIsolate
(
vmServicePort
);
waitingFor
=
'task completion'
;
waitingFor
=
'task completion'
;
Map
<
String
,
dynamic
>
taskResult
=
final
Map
<
String
,
dynamic
>
taskResult
=
await
isolate
.
invokeExtension
(
'ext.cocoonRunTask'
).
timeout
(
taskTimeoutWithGracePeriod
);
await
isolate
.
invokeExtension
(
'ext.cocoonRunTask'
).
timeout
(
taskTimeoutWithGracePeriod
);
waitingFor
=
'task process to exit'
;
waitingFor
=
'task process to exit'
;
await
runner
.
exitCode
.
timeout
(
const
Duration
(
seconds:
1
));
await
runner
.
exitCode
.
timeout
(
const
Duration
(
seconds:
1
));
...
@@ -81,8 +81,8 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
...
@@ -81,8 +81,8 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
}
}
Future
<
VMIsolateRef
>
_connectToRunnerIsolate
(
int
vmServicePort
)
async
{
Future
<
VMIsolateRef
>
_connectToRunnerIsolate
(
int
vmServicePort
)
async
{
String
url
=
'ws://localhost:
$vmServicePort
/ws'
;
final
String
url
=
'ws://localhost:
$vmServicePort
/ws'
;
DateTime
started
=
new
DateTime
.
now
();
final
DateTime
started
=
new
DateTime
.
now
();
// TODO(yjbanov): due to lack of imagination at the moment the handshake with
// TODO(yjbanov): due to lack of imagination at the moment the handshake with
// the task process is very rudimentary and requires this small
// the task process is very rudimentary and requires this small
...
@@ -97,10 +97,10 @@ Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
...
@@ -97,10 +97,10 @@ Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
await
(
await
WebSocket
.
connect
(
url
)).
close
();
await
(
await
WebSocket
.
connect
(
url
)).
close
();
// Look up the isolate.
// Look up the isolate.
VMServiceClient
client
=
new
VMServiceClient
.
connect
(
url
);
final
VMServiceClient
client
=
new
VMServiceClient
.
connect
(
url
);
VM
vm
=
await
client
.
getVM
();
final
VM
vm
=
await
client
.
getVM
();
VMIsolateRef
isolate
=
vm
.
isolates
.
single
;
final
VMIsolateRef
isolate
=
vm
.
isolates
.
single
;
String
response
=
await
isolate
.
invokeExtension
(
'ext.cocoonRunnerReady'
);
final
String
response
=
await
isolate
.
invokeExtension
(
'ext.cocoonRunnerReady'
);
if
(
response
!=
'ready'
)
throw
'not ready yet'
;
if
(
response
!=
'ready'
)
throw
'not ready yet'
;
return
isolate
;
return
isolate
;
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
dev/devicelab/lib/framework/utils.dart
View file @
6c97dd2c
...
@@ -46,7 +46,7 @@ class HealthCheckResult {
...
@@ -46,7 +46,7 @@ class HealthCheckResult {
@override
@override
String
toString
()
{
String
toString
()
{
StringBuffer
buf
=
new
StringBuffer
(
succeeded
?
'succeeded'
:
'failed'
);
final
StringBuffer
buf
=
new
StringBuffer
(
succeeded
?
'succeeded'
:
'failed'
);
if
(
details
!=
null
&&
details
.
trim
().
isNotEmpty
)
{
if
(
details
!=
null
&&
details
.
trim
().
isNotEmpty
)
{
buf
.
writeln
();
buf
.
writeln
();
// Indent details by 4 spaces
// Indent details by 4 spaces
...
@@ -89,7 +89,7 @@ Directory dir(String path) => new Directory(path);
...
@@ -89,7 +89,7 @@ Directory dir(String path) => new Directory(path);
File
file
(
String
path
)
=>
new
File
(
path
);
File
file
(
String
path
)
=>
new
File
(
path
);
void
copy
(
File
sourceFile
,
Directory
targetDirectory
,
{
String
name
})
{
void
copy
(
File
sourceFile
,
Directory
targetDirectory
,
{
String
name
})
{
File
target
=
file
(
final
File
target
=
file
(
path
.
join
(
targetDirectory
.
path
,
name
??
path
.
basename
(
sourceFile
.
path
)));
path
.
join
(
targetDirectory
.
path
,
name
??
path
.
basename
(
sourceFile
.
path
)));
target
.
writeAsBytesSync
(
sourceFile
.
readAsBytesSync
());
target
.
writeAsBytesSync
(
sourceFile
.
readAsBytesSync
());
}
}
...
@@ -118,7 +118,7 @@ void section(String title) {
...
@@ -118,7 +118,7 @@ void section(String title) {
Future
<
String
>
getDartVersion
()
async
{
Future
<
String
>
getDartVersion
()
async
{
// The Dart VM returns the version text to stderr.
// The Dart VM returns the version text to stderr.
ProcessResult
result
=
Process
.
runSync
(
dartBin
,
<
String
>[
'--version'
]);
final
ProcessResult
result
=
Process
.
runSync
(
dartBin
,
<
String
>[
'--version'
]);
String
version
=
result
.
stderr
.
trim
();
String
version
=
result
.
stderr
.
trim
();
// Convert:
// Convert:
...
@@ -146,13 +146,13 @@ Future<String> getCurrentFlutterRepoCommit() {
...
@@ -146,13 +146,13 @@ Future<String> getCurrentFlutterRepoCommit() {
Future
<
DateTime
>
getFlutterRepoCommitTimestamp
(
String
commit
)
{
Future
<
DateTime
>
getFlutterRepoCommitTimestamp
(
String
commit
)
{
// git show -s --format=%at 4b546df7f0b3858aaaa56c4079e5be1ba91fbb65
// git show -s --format=%at 4b546df7f0b3858aaaa56c4079e5be1ba91fbb65
return
inDirectory
(
flutterDirectory
,
()
async
{
return
inDirectory
(
flutterDirectory
,
()
async
{
String
unixTimestamp
=
await
eval
(
'git'
,
<
String
>[
final
String
unixTimestamp
=
await
eval
(
'git'
,
<
String
>[
'show'
,
'show'
,
'-s'
,
'-s'
,
'--format=%at'
,
'--format=%at'
,
commit
,
commit
,
]);
]);
int
secondsSinceEpoch
=
int
.
parse
(
unixTimestamp
);
final
int
secondsSinceEpoch
=
int
.
parse
(
unixTimestamp
);
return
new
DateTime
.
fromMillisecondsSinceEpoch
(
secondsSinceEpoch
*
1000
);
return
new
DateTime
.
fromMillisecondsSinceEpoch
(
secondsSinceEpoch
*
1000
);
});
});
}
}
...
@@ -163,17 +163,17 @@ Future<Process> startProcess(
...
@@ -163,17 +163,17 @@ Future<Process> startProcess(
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
environment
,
String
workingDirectory
,
String
workingDirectory
,
})
async
{
})
async
{
String
command
=
'
$executable
${arguments?.join(" ") ?? ""}
'
;
final
String
command
=
'
$executable
${arguments?.join(" ") ?? ""}
'
;
print
(
'Executing:
$command
'
);
print
(
'Executing:
$command
'
);
environment
??=
<
String
,
String
>{};
environment
??=
<
String
,
String
>{};
environment
[
'BOT'
]
=
'true'
;
environment
[
'BOT'
]
=
'true'
;
Process
process
=
await
Process
.
start
(
final
Process
process
=
await
Process
.
start
(
executable
,
executable
,
arguments
,
arguments
,
environment:
environment
,
environment:
environment
,
workingDirectory:
workingDirectory
??
cwd
,
workingDirectory:
workingDirectory
??
cwd
,
);
);
ProcessInfo
processInfo
=
new
ProcessInfo
(
command
,
process
);
final
ProcessInfo
processInfo
=
new
ProcessInfo
(
command
,
process
);
_runningProcesses
.
add
(
processInfo
);
_runningProcesses
.
add
(
processInfo
);
process
.
exitCode
.
whenComplete
(()
{
process
.
exitCode
.
whenComplete
(()
{
...
@@ -207,7 +207,7 @@ Future<int> exec(
...
@@ -207,7 +207,7 @@ Future<int> exec(
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
environment
,
bool
canFail:
false
,
bool
canFail:
false
,
})
async
{
})
async
{
Process
process
=
await
startProcess
(
executable
,
arguments
,
environment:
environment
);
final
Process
process
=
await
startProcess
(
executable
,
arguments
,
environment:
environment
);
process
.
stdout
process
.
stdout
.
transform
(
UTF8
.
decoder
)
.
transform
(
UTF8
.
decoder
)
...
@@ -218,7 +218,7 @@ Future<int> exec(
...
@@ -218,7 +218,7 @@ Future<int> exec(
.
transform
(
const
LineSplitter
())
.
transform
(
const
LineSplitter
())
.
listen
(
stderr
.
writeln
);
.
listen
(
stderr
.
writeln
);
int
exitCode
=
await
process
.
exitCode
;
final
int
exitCode
=
await
process
.
exitCode
;
if
(
exitCode
!=
0
&&
!
canFail
)
if
(
exitCode
!=
0
&&
!
canFail
)
fail
(
'Executable failed with exit code
$exitCode
.'
);
fail
(
'Executable failed with exit code
$exitCode
.'
);
...
@@ -235,12 +235,12 @@ Future<String> eval(
...
@@ -235,12 +235,12 @@ Future<String> eval(
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
environment
,
bool
canFail:
false
,
bool
canFail:
false
,
})
async
{
})
async
{
Process
process
=
await
startProcess
(
executable
,
arguments
,
environment:
environment
);
final
Process
process
=
await
startProcess
(
executable
,
arguments
,
environment:
environment
);
process
.
stderr
.
listen
((
List
<
int
>
data
)
{
process
.
stderr
.
listen
((
List
<
int
>
data
)
{
stderr
.
add
(
data
);
stderr
.
add
(
data
);
});
});
String
output
=
await
UTF8
.
decodeStream
(
process
.
stdout
);
final
String
output
=
await
UTF8
.
decodeStream
(
process
.
stdout
);
int
exitCode
=
await
process
.
exitCode
;
final
int
exitCode
=
await
process
.
exitCode
;
if
(
exitCode
!=
0
&&
!
canFail
)
if
(
exitCode
!=
0
&&
!
canFail
)
fail
(
'Executable failed with exit code
$exitCode
.'
);
fail
(
'Executable failed with exit code
$exitCode
.'
);
...
@@ -253,7 +253,7 @@ Future<int> flutter(String command, {
...
@@ -253,7 +253,7 @@ Future<int> flutter(String command, {
bool
canFail:
false
,
bool
canFail:
false
,
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
environment
,
})
{
})
{
List
<
String
>
args
=
<
String
>[
command
]..
addAll
(
options
);
final
List
<
String
>
args
=
<
String
>[
command
]..
addAll
(
options
);
return
exec
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
return
exec
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
canFail:
canFail
,
environment:
environment
);
canFail:
canFail
,
environment:
environment
);
}
}
...
@@ -264,7 +264,7 @@ Future<String> evalFlutter(String command, {
...
@@ -264,7 +264,7 @@ Future<String> evalFlutter(String command, {
bool
canFail:
false
,
bool
canFail:
false
,
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
environment
,
})
{
})
{
List
<
String
>
args
=
<
String
>[
command
]..
addAll
(
options
);
final
List
<
String
>
args
=
<
String
>[
command
]..
addAll
(
options
);
return
eval
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
return
eval
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
canFail:
canFail
,
environment:
environment
);
canFail:
canFail
,
environment:
environment
);
}
}
...
@@ -275,7 +275,7 @@ String get dartBin =>
...
@@ -275,7 +275,7 @@ String get dartBin =>
Future
<
int
>
dart
(
List
<
String
>
args
)
=>
exec
(
dartBin
,
args
);
Future
<
int
>
dart
(
List
<
String
>
args
)
=>
exec
(
dartBin
,
args
);
Future
<
dynamic
>
inDirectory
(
dynamic
directory
,
Future
<
dynamic
>
action
())
async
{
Future
<
dynamic
>
inDirectory
(
dynamic
directory
,
Future
<
dynamic
>
action
())
async
{
String
previousCwd
=
cwd
;
final
String
previousCwd
=
cwd
;
try
{
try
{
cd
(
directory
);
cd
(
directory
);
return
await
action
();
return
await
action
();
...
@@ -303,7 +303,7 @@ void cd(dynamic directory) {
...
@@ -303,7 +303,7 @@ void cd(dynamic directory) {
Directory
get
flutterDirectory
=>
dir
(
'../..'
).
absolute
;
Directory
get
flutterDirectory
=>
dir
(
'../..'
).
absolute
;
String
requireEnvVar
(
String
name
)
{
String
requireEnvVar
(
String
name
)
{
String
value
=
Platform
.
environment
[
name
];
final
String
value
=
Platform
.
environment
[
name
];
if
(
value
==
null
)
fail
(
'
$name
environment variable is missing. Quitting.'
);
if
(
value
==
null
)
fail
(
'
$name
environment variable is missing. Quitting.'
);
...
@@ -313,7 +313,7 @@ String requireEnvVar(String name) {
...
@@ -313,7 +313,7 @@ String requireEnvVar(String name) {
T
requireConfigProperty
<
T
>(
Map
<
String
,
dynamic
>
map
,
String
propertyName
)
{
T
requireConfigProperty
<
T
>(
Map
<
String
,
dynamic
>
map
,
String
propertyName
)
{
if
(!
map
.
containsKey
(
propertyName
))
if
(!
map
.
containsKey
(
propertyName
))
fail
(
'Configuration property not found:
$propertyName
'
);
fail
(
'Configuration property not found:
$propertyName
'
);
T
result
=
map
[
propertyName
];
final
T
result
=
map
[
propertyName
];
return
result
;
return
result
;
}
}
...
@@ -426,7 +426,7 @@ Iterable<String> grep(Pattern pattern, {@required String from}) {
...
@@ -426,7 +426,7 @@ Iterable<String> grep(Pattern pattern, {@required String from}) {
///
///
/// }
/// }
Future
<
Null
>
runAndCaptureAsyncStacks
(
Future
<
Null
>
callback
())
{
Future
<
Null
>
runAndCaptureAsyncStacks
(
Future
<
Null
>
callback
())
{
Completer
<
Null
>
completer
=
new
Completer
<
Null
>();
final
Completer
<
Null
>
completer
=
new
Completer
<
Null
>();
Chain
.
capture
(()
async
{
Chain
.
capture
(()
async
{
await
callback
();
await
callback
();
completer
.
complete
();
completer
.
complete
();
...
@@ -441,7 +441,7 @@ Future<int> findAvailablePort() async {
...
@@ -441,7 +441,7 @@ Future<int> findAvailablePort() async {
int
port
=
20000
;
int
port
=
20000
;
while
(
true
)
{
while
(
true
)
{
try
{
try
{
ServerSocket
socket
=
final
ServerSocket
socket
=
await
ServerSocket
.
bind
(
InternetAddress
.
LOOPBACK_IP_V4
,
port
);
await
ServerSocket
.
bind
(
InternetAddress
.
LOOPBACK_IP_V4
,
port
);
await
socket
.
close
();
await
socket
.
close
();
return
port
;
return
port
;
...
...
dev/devicelab/lib/tasks/gallery.dart
View file @
6c97dd2c
...
@@ -18,10 +18,10 @@ TaskFunction createGalleryTransitionTest() {
...
@@ -18,10 +18,10 @@ TaskFunction createGalleryTransitionTest() {
class
GalleryTransitionTest
{
class
GalleryTransitionTest
{
Future
<
TaskResult
>
call
()
async
{
Future
<
TaskResult
>
call
()
async
{
Device
device
=
await
devices
.
workingDevice
;
final
Device
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
await
device
.
unlock
();
String
deviceId
=
device
.
deviceId
;
final
String
deviceId
=
device
.
deviceId
;
Directory
galleryDirectory
=
final
Directory
galleryDirectory
=
dir
(
'
${flutterDirectory.path}
/examples/flutter_gallery'
);
dir
(
'
${flutterDirectory.path}
/examples/flutter_gallery'
);
await
inDirectory
(
galleryDirectory
,
()
async
{
await
inDirectory
(
galleryDirectory
,
()
async
{
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
...
@@ -43,17 +43,17 @@ class GalleryTransitionTest {
...
@@ -43,17 +43,17 @@ class GalleryTransitionTest {
// Route paths contains slashes, which Firebase doesn't accept in keys, so we
// Route paths contains slashes, which Firebase doesn't accept in keys, so we
// remove them.
// remove them.
Map
<
String
,
List
<
int
>>
original
=
JSON
.
decode
(
file
(
final
Map
<
String
,
List
<
int
>>
original
=
JSON
.
decode
(
file
(
'
${galleryDirectory.path}
/build/transition_durations.timeline.json'
)
'
${galleryDirectory.path}
/build/transition_durations.timeline.json'
)
.
readAsStringSync
());
.
readAsStringSync
());
Map
<
String
,
List
<
int
>>
transitions
=
new
Map
<
String
,
List
<
int
>>.
fromIterable
(
final
Map
<
String
,
List
<
int
>>
transitions
=
new
Map
<
String
,
List
<
int
>>.
fromIterable
(
original
.
keys
,
original
.
keys
,
key:
(
String
key
)
=>
key
.
replaceAll
(
'/'
,
''
),
key:
(
String
key
)
=>
key
.
replaceAll
(
'/'
,
''
),
value:
(
String
key
)
=>
original
[
key
]);
value:
(
String
key
)
=>
original
[
key
]);
Map
<
String
,
dynamic
>
summary
=
JSON
.
decode
(
file
(
'
${galleryDirectory.path}
/build/transitions.timeline_summary.json'
).
readAsStringSync
());
final
Map
<
String
,
dynamic
>
summary
=
JSON
.
decode
(
file
(
'
${galleryDirectory.path}
/build/transitions.timeline_summary.json'
).
readAsStringSync
());
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{
'transitions'
:
transitions
,
'transitions'
:
transitions
,
'missed_transition_count'
:
_countMissedTransitions
(
transitions
),
'missed_transition_count'
:
_countMissedTransitions
(
transitions
),
};
};
...
@@ -75,7 +75,7 @@ int _countMissedTransitions(Map<String, List<int>> transitions) {
...
@@ -75,7 +75,7 @@ int _countMissedTransitions(Map<String, List<int>> transitions) {
const
int
_kTransitionBudget
=
100000
;
// µs
const
int
_kTransitionBudget
=
100000
;
// µs
int
count
=
0
;
int
count
=
0
;
transitions
.
forEach
((
String
demoName
,
List
<
int
>
durations
)
{
transitions
.
forEach
((
String
demoName
,
List
<
int
>
durations
)
{
int
longestDuration
=
durations
.
reduce
(
math
.
max
);
final
int
longestDuration
=
durations
.
reduce
(
math
.
max
);
if
(
longestDuration
>
_kTransitionBudget
)
{
if
(
longestDuration
>
_kTransitionBudget
)
{
print
(
'
$demoName
missed transition time budget (
$longestDuration
µs >
$_kTransitionBudget
µs)'
);
print
(
'
$demoName
missed transition time budget (
$longestDuration
µs >
$_kTransitionBudget
µs)'
);
count
++;
count
++;
...
...
dev/devicelab/lib/tasks/microbenchmarks.dart
View file @
6c97dd2c
...
@@ -16,13 +16,13 @@ import 'package:flutter_devicelab/framework/utils.dart';
...
@@ -16,13 +16,13 @@ import 'package:flutter_devicelab/framework/utils.dart';
/// `dev/benchmarks/microbenchmarks` reports results to the dashboard.
/// `dev/benchmarks/microbenchmarks` reports results to the dashboard.
TaskFunction
createMicrobenchmarkTask
(
)
{
TaskFunction
createMicrobenchmarkTask
(
)
{
return
()
async
{
return
()
async
{
Device
device
=
await
devices
.
workingDevice
;
final
Device
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
await
device
.
unlock
();
Future
<
Map
<
String
,
double
>>
_runMicrobench
(
String
benchmarkPath
)
async
{
Future
<
Map
<
String
,
double
>>
_runMicrobench
(
String
benchmarkPath
)
async
{
print
(
'Running
$benchmarkPath
'
);
print
(
'Running
$benchmarkPath
'
);
Directory
appDir
=
dir
(
path
.
join
(
flutterDirectory
.
path
,
'dev/benchmarks/microbenchmarks'
));
final
Directory
appDir
=
dir
(
path
.
join
(
flutterDirectory
.
path
,
'dev/benchmarks/microbenchmarks'
));
Process
flutterProcess
=
await
inDirectory
(
appDir
,
()
async
{
final
Process
flutterProcess
=
await
inDirectory
(
appDir
,
()
async
{
return
await
_startFlutter
(
return
await
_startFlutter
(
options:
<
String
>[
options:
<
String
>[
'--profile'
,
// --release doesn't work on iOS due to code signing issues
'--profile'
,
// --release doesn't work on iOS due to code signing issues
...
@@ -37,7 +37,7 @@ TaskFunction createMicrobenchmarkTask() {
...
@@ -37,7 +37,7 @@ TaskFunction createMicrobenchmarkTask() {
return
await
_readJsonResults
(
flutterProcess
);
return
await
_readJsonResults
(
flutterProcess
);
}
}
Map
<
String
,
double
>
allResults
=
<
String
,
double
>{};
final
Map
<
String
,
double
>
allResults
=
<
String
,
double
>{};
allResults
.
addAll
(
await
_runMicrobench
(
'lib/stocks/layout_bench.dart'
));
allResults
.
addAll
(
await
_runMicrobench
(
'lib/stocks/layout_bench.dart'
));
allResults
.
addAll
(
await
_runMicrobench
(
'lib/stocks/build_bench.dart'
));
allResults
.
addAll
(
await
_runMicrobench
(
'lib/stocks/build_bench.dart'
));
allResults
.
addAll
(
await
_runMicrobench
(
'lib/gestures/velocity_tracker_bench.dart'
));
allResults
.
addAll
(
await
_runMicrobench
(
'lib/gestures/velocity_tracker_bench.dart'
));
...
@@ -53,7 +53,7 @@ Future<Process> _startFlutter({
...
@@ -53,7 +53,7 @@ Future<Process> _startFlutter({
bool
canFail:
false
,
bool
canFail:
false
,
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
environment
,
})
{
})
{
List
<
String
>
args
=
<
String
>[
'run'
]..
addAll
(
options
);
final
List
<
String
>
args
=
<
String
>[
'run'
]..
addAll
(
options
);
return
startProcess
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
environment:
environment
);
return
startProcess
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
environment:
environment
);
}
}
...
@@ -62,8 +62,8 @@ Future<Map<String, double>> _readJsonResults(Process process) {
...
@@ -62,8 +62,8 @@ Future<Map<String, double>> _readJsonResults(Process process) {
const
String
jsonStart
=
'================ RESULTS ================'
;
const
String
jsonStart
=
'================ RESULTS ================'
;
const
String
jsonEnd
=
'================ FORMATTED =============='
;
const
String
jsonEnd
=
'================ FORMATTED =============='
;
bool
jsonStarted
=
false
;
bool
jsonStarted
=
false
;
StringBuffer
jsonBuf
=
new
StringBuffer
();
final
StringBuffer
jsonBuf
=
new
StringBuffer
();
Completer
<
Map
<
String
,
double
>>
completer
=
new
Completer
<
Map
<
String
,
double
>>();
final
Completer
<
Map
<
String
,
double
>>
completer
=
new
Completer
<
Map
<
String
,
double
>>();
StreamSubscription
<
String
>
stdoutSub
;
StreamSubscription
<
String
>
stdoutSub
;
int
prefixLength
=
0
;
int
prefixLength
=
0
;
...
...
dev/devicelab/lib/tasks/perf_tests.dart
View file @
6c97dd2c
...
@@ -77,7 +77,7 @@ class StartupTest {
...
@@ -77,7 +77,7 @@ class StartupTest {
Future
<
TaskResult
>
call
()
async
{
Future
<
TaskResult
>
call
()
async
{
return
await
inDirectory
(
testDirectory
,
()
async
{
return
await
inDirectory
(
testDirectory
,
()
async
{
String
deviceId
=
(
await
devices
.
workingDevice
).
deviceId
;
final
String
deviceId
=
(
await
devices
.
workingDevice
).
deviceId
;
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
if
(
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
)
{
if
(
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
)
{
...
@@ -91,7 +91,7 @@ class StartupTest {
...
@@ -91,7 +91,7 @@ class StartupTest {
'-d'
,
'-d'
,
deviceId
,
deviceId
,
]).
timeout
(
_startupTimeout
);
]).
timeout
(
_startupTimeout
);
Map
<
String
,
dynamic
>
data
=
JSON
.
decode
(
file
(
'
$testDirectory
/build/start_up_info.json'
).
readAsStringSync
());
final
Map
<
String
,
dynamic
>
data
=
JSON
.
decode
(
file
(
'
$testDirectory
/build/start_up_info.json'
).
readAsStringSync
());
return
new
TaskResult
.
success
(
data
,
benchmarkScoreKeys:
<
String
>[
return
new
TaskResult
.
success
(
data
,
benchmarkScoreKeys:
<
String
>[
'timeToFirstFrameMicros'
,
'timeToFirstFrameMicros'
,
]);
]);
...
@@ -111,9 +111,9 @@ class PerfTest {
...
@@ -111,9 +111,9 @@ class PerfTest {
Future
<
TaskResult
>
call
()
{
Future
<
TaskResult
>
call
()
{
return
inDirectory
(
testDirectory
,
()
async
{
return
inDirectory
(
testDirectory
,
()
async
{
Device
device
=
await
devices
.
workingDevice
;
final
Device
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
await
device
.
unlock
();
String
deviceId
=
device
.
deviceId
;
final
String
deviceId
=
device
.
deviceId
;
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
if
(
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
)
{
if
(
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
)
{
...
@@ -130,7 +130,7 @@ class PerfTest {
...
@@ -130,7 +130,7 @@ class PerfTest {
'-d'
,
'-d'
,
deviceId
,
deviceId
,
]);
]);
Map
<
String
,
dynamic
>
data
=
JSON
.
decode
(
file
(
'
$testDirectory
/build/
$timelineFileName
.timeline_summary.json'
).
readAsStringSync
());
final
Map
<
String
,
dynamic
>
data
=
JSON
.
decode
(
file
(
'
$testDirectory
/build/
$timelineFileName
.timeline_summary.json'
).
readAsStringSync
());
if
(
data
[
'frame_count'
]
<
5
)
{
if
(
data
[
'frame_count'
]
<
5
)
{
return
new
TaskResult
.
failure
(
return
new
TaskResult
.
failure
(
...
@@ -159,12 +159,12 @@ class BuildTest {
...
@@ -159,12 +159,12 @@ class BuildTest {
Future
<
TaskResult
>
call
()
async
{
Future
<
TaskResult
>
call
()
async
{
return
await
inDirectory
(
testDirectory
,
()
async
{
return
await
inDirectory
(
testDirectory
,
()
async
{
Device
device
=
await
devices
.
workingDevice
;
final
Device
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
await
device
.
unlock
();
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
Stopwatch
watch
=
new
Stopwatch
()..
start
();
final
Stopwatch
watch
=
new
Stopwatch
()..
start
();
String
buildLog
=
await
evalFlutter
(
'build'
,
options:
<
String
>[
final
String
buildLog
=
await
evalFlutter
(
'build'
,
options:
<
String
>[
'aot'
,
'aot'
,
'-v'
,
'-v'
,
'--profile'
,
'--profile'
,
...
@@ -173,9 +173,9 @@ class BuildTest {
...
@@ -173,9 +173,9 @@ class BuildTest {
]);
]);
watch
.
stop
();
watch
.
stop
();
RegExp
metricExpression
=
new
RegExp
(
r'([a-zA-Z]+)\(CodeSize\)\: (\d+)'
);
final
RegExp
metricExpression
=
new
RegExp
(
r'([a-zA-Z]+)\(CodeSize\)\: (\d+)'
);
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>.
fromIterable
(
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>.
fromIterable
(
metricExpression
.
allMatches
(
buildLog
),
metricExpression
.
allMatches
(
buildLog
),
key:
(
Match
m
)
=>
_sdkNameToMetricName
(
m
.
group
(
1
)),
key:
(
Match
m
)
=>
_sdkNameToMetricName
(
m
.
group
(
1
)),
value:
(
Match
m
)
=>
int
.
parse
(
m
.
group
(
2
)),
value:
(
Match
m
)
=>
int
.
parse
(
m
.
group
(
2
)),
...
@@ -216,9 +216,9 @@ class MemoryTest {
...
@@ -216,9 +216,9 @@ class MemoryTest {
Future
<
TaskResult
>
call
()
{
Future
<
TaskResult
>
call
()
{
return
inDirectory
(
testDirectory
,
()
async
{
return
inDirectory
(
testDirectory
,
()
async
{
Device
device
=
await
devices
.
workingDevice
;
final
Device
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
await
device
.
unlock
();
String
deviceId
=
device
.
deviceId
;
final
String
deviceId
=
device
.
deviceId
;
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
if
(
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
)
{
if
(
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
)
{
...
@@ -226,9 +226,9 @@ class MemoryTest {
...
@@ -226,9 +226,9 @@ class MemoryTest {
await
flutter
(
'build'
,
options:
<
String
>[
'ios'
,
'--profile'
]);
await
flutter
(
'build'
,
options:
<
String
>[
'ios'
,
'--profile'
]);
}
}
int
observatoryPort
=
await
findAvailablePort
();
final
int
observatoryPort
=
await
findAvailablePort
();
List
<
String
>
runOptions
=
<
String
>[
final
List
<
String
>
runOptions
=
<
String
>[
'-v'
,
'-v'
,
'--profile'
,
'--profile'
,
'--trace-startup'
,
// wait for the first frame to render
'--trace-startup'
,
// wait for the first frame to render
...
@@ -241,9 +241,9 @@ class MemoryTest {
...
@@ -241,9 +241,9 @@ class MemoryTest {
runOptions
.
addAll
(<
String
>[
'-t'
,
testTarget
]);
runOptions
.
addAll
(<
String
>[
'-t'
,
testTarget
]);
await
flutter
(
'run'
,
options:
runOptions
);
await
flutter
(
'run'
,
options:
runOptions
);
Map
<
String
,
dynamic
>
startData
=
await
device
.
getMemoryStats
(
packageName
);
final
Map
<
String
,
dynamic
>
startData
=
await
device
.
getMemoryStats
(
packageName
);
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{
'start_total_kb'
:
startData
[
'total_kb'
],
'start_total_kb'
:
startData
[
'total_kb'
],
};
};
...
@@ -257,7 +257,7 @@ class MemoryTest {
...
@@ -257,7 +257,7 @@ class MemoryTest {
'--use-existing-app=http://localhost:
$observatoryPort
'
,
'--use-existing-app=http://localhost:
$observatoryPort
'
,
]);
]);
Map
<
String
,
dynamic
>
endData
=
await
device
.
getMemoryStats
(
packageName
);
final
Map
<
String
,
dynamic
>
endData
=
await
device
.
getMemoryStats
(
packageName
);
data
[
'end_total_kb'
]
=
endData
[
'total_kb'
];
data
[
'end_total_kb'
]
=
endData
[
'total_kb'
];
data
[
'diff_total_kb'
]
=
endData
[
'total_kb'
]
-
startData
[
'total_kb'
];
data
[
'diff_total_kb'
]
=
endData
[
'total_kb'
]
-
startData
[
'total_kb'
];
}
}
...
@@ -283,9 +283,9 @@ class AndroidBackButtonMemoryTest {
...
@@ -283,9 +283,9 @@ class AndroidBackButtonMemoryTest {
throw
'This test is only supported on Android'
;
throw
'This test is only supported on Android'
;
}
}
AndroidDevice
device
=
await
devices
.
workingDevice
;
final
AndroidDevice
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
await
device
.
unlock
();
String
deviceId
=
device
.
deviceId
;
final
String
deviceId
=
device
.
deviceId
;
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
flutter
(
'run'
,
options:
<
String
>[
await
flutter
(
'run'
,
options:
<
String
>[
...
@@ -296,9 +296,9 @@ class AndroidBackButtonMemoryTest {
...
@@ -296,9 +296,9 @@ class AndroidBackButtonMemoryTest {
deviceId
,
deviceId
,
]);
]);
Map
<
String
,
dynamic
>
startData
=
await
device
.
getMemoryStats
(
packageName
);
final
Map
<
String
,
dynamic
>
startData
=
await
device
.
getMemoryStats
(
packageName
);
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{
'start_total_kb'
:
startData
[
'total_kb'
],
'start_total_kb'
:
startData
[
'total_kb'
],
};
};
...
@@ -306,14 +306,14 @@ class AndroidBackButtonMemoryTest {
...
@@ -306,14 +306,14 @@ class AndroidBackButtonMemoryTest {
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
await
device
.
shellExec
(
'input'
,
<
String
>[
'keyevent'
,
'KEYCODE_BACK'
]);
await
device
.
shellExec
(
'input'
,
<
String
>[
'keyevent'
,
'KEYCODE_BACK'
]);
await
new
Future
<
Null
>.
delayed
(
const
Duration
(
milliseconds:
1000
));
await
new
Future
<
Null
>.
delayed
(
const
Duration
(
milliseconds:
1000
));
String
output
=
await
device
.
shellEval
(
'am'
,
<
String
>[
'start'
,
'-n'
,
'io.flutter.examples.gallery/io.flutter.app.FlutterActivity'
]);
final
String
output
=
await
device
.
shellEval
(
'am'
,
<
String
>[
'start'
,
'-n'
,
'io.flutter.examples.gallery/io.flutter.app.FlutterActivity'
]);
print
(
output
);
print
(
output
);
if
(
output
.
contains
(
'Error'
))
if
(
output
.
contains
(
'Error'
))
return
new
TaskResult
.
failure
(
'unable to launch activity'
);
return
new
TaskResult
.
failure
(
'unable to launch activity'
);
await
new
Future
<
Null
>.
delayed
(
const
Duration
(
milliseconds:
1000
));
await
new
Future
<
Null
>.
delayed
(
const
Duration
(
milliseconds:
1000
));
}
}
Map
<
String
,
dynamic
>
endData
=
await
device
.
getMemoryStats
(
packageName
);
final
Map
<
String
,
dynamic
>
endData
=
await
device
.
getMemoryStats
(
packageName
);
data
[
'end_total_kb'
]
=
endData
[
'total_kb'
];
data
[
'end_total_kb'
]
=
endData
[
'total_kb'
];
data
[
'diff_total_kb'
]
=
endData
[
'total_kb'
]
-
startData
[
'total_kb'
];
data
[
'diff_total_kb'
]
=
endData
[
'total_kb'
]
-
startData
[
'total_kb'
];
...
...
dev/devicelab/lib/tasks/size_tests.dart
View file @
6c97dd2c
...
@@ -12,7 +12,7 @@ import '../framework/utils.dart';
...
@@ -12,7 +12,7 @@ import '../framework/utils.dart';
TaskFunction
createBasicMaterialAppSizeTest
(
)
{
TaskFunction
createBasicMaterialAppSizeTest
(
)
{
return
()
async
{
return
()
async
{
const
String
sampleAppName
=
'sample_flutter_app'
;
const
String
sampleAppName
=
'sample_flutter_app'
;
Directory
sampleDir
=
dir
(
'
${Directory.systemTemp.path}
/
$sampleAppName
'
);
final
Directory
sampleDir
=
dir
(
'
${Directory.systemTemp.path}
/
$sampleAppName
'
);
if
(
await
sampleDir
.
exists
())
if
(
await
sampleDir
.
exists
())
rmTree
(
sampleDir
);
rmTree
(
sampleDir
);
...
...
dev/devicelab/test/adb_test.dart
View file @
6c97dd2c
...
@@ -129,7 +129,7 @@ class CommandArgs {
...
@@ -129,7 +129,7 @@ class CommandArgs {
if
(
other
.
runtimeType
!=
CommandArgs
)
if
(
other
.
runtimeType
!=
CommandArgs
)
return
false
;
return
false
;
CommandArgs
otherCmd
=
other
;
final
CommandArgs
otherCmd
=
other
;
return
otherCmd
.
command
==
this
.
command
&&
return
otherCmd
.
command
==
this
.
command
&&
const
ListEquality
<
String
>().
equals
(
otherCmd
.
arguments
,
this
.
arguments
)
&&
const
ListEquality
<
String
>().
equals
(
otherCmd
.
arguments
,
this
.
arguments
)
&&
const
MapEquality
<
String
,
String
>().
equals
(
otherCmd
.
environment
,
this
.
environment
);
const
MapEquality
<
String
,
String
>().
equals
(
otherCmd
.
environment
,
this
.
environment
);
...
@@ -188,7 +188,7 @@ class FakeDevice extends AndroidDevice {
...
@@ -188,7 +188,7 @@ class FakeDevice extends AndroidDevice {
arguments:
arguments
,
arguments:
arguments
,
environment:
environment
,
environment:
environment
,
));
));
dynamic
exitError
=
exitErrorFactory
();
final
dynamic
exitError
=
exitErrorFactory
();
if
(
exitError
!=
null
)
if
(
exitError
!=
null
)
throw
exitError
;
throw
exitError
;
}
}
...
...
dev/devicelab/test/manifest_test.dart
View file @
6c97dd2c
...
@@ -9,10 +9,10 @@ import 'package:flutter_devicelab/framework/manifest.dart';
...
@@ -9,10 +9,10 @@ import 'package:flutter_devicelab/framework/manifest.dart';
void
main
(
)
{
void
main
(
)
{
group
(
'production manifest'
,
()
{
group
(
'production manifest'
,
()
{
test
(
'must be valid'
,
()
{
test
(
'must be valid'
,
()
{
Manifest
manifest
=
loadTaskManifest
();
final
Manifest
manifest
=
loadTaskManifest
();
expect
(
manifest
.
tasks
,
isNotEmpty
);
expect
(
manifest
.
tasks
,
isNotEmpty
);
ManifestTask
task
=
manifest
.
tasks
.
firstWhere
((
ManifestTask
task
)
=>
task
.
name
==
'flutter_gallery__start_up'
);
final
ManifestTask
task
=
manifest
.
tasks
.
firstWhere
((
ManifestTask
task
)
=>
task
.
name
==
'flutter_gallery__start_up'
);
expect
(
task
.
description
,
'Measures the startup time of the Flutter Gallery app on Android.
\n
'
);
expect
(
task
.
description
,
'Measures the startup time of the Flutter Gallery app on Android.
\n
'
);
expect
(
task
.
stage
,
'devicelab'
);
expect
(
task
.
stage
,
'devicelab'
);
expect
(
task
.
requiredAgentCapabilities
,
<
String
>[
'has-android-device'
]);
expect
(
task
.
requiredAgentCapabilities
,
<
String
>[
'has-android-device'
]);
...
...
dev/devicelab/test/run_test.dart
View file @
6c97dd2c
...
@@ -10,11 +10,11 @@ import 'package:test/test.dart';
...
@@ -10,11 +10,11 @@ import 'package:test/test.dart';
void
main
(
)
{
void
main
(
)
{
group
(
'run.dart script'
,
()
{
group
(
'run.dart script'
,
()
{
Future
<
int
>
runScript
(
List
<
String
>
testNames
)
async
{
Future
<
int
>
runScript
(
List
<
String
>
testNames
)
async
{
List
<
String
>
options
=
<
String
>[
'bin/run.dart'
];
final
List
<
String
>
options
=
<
String
>[
'bin/run.dart'
];
for
(
String
testName
in
testNames
)
{
for
(
String
testName
in
testNames
)
{
options
..
addAll
(<
String
>[
'-t'
,
testName
]);
options
..
addAll
(<
String
>[
'-t'
,
testName
]);
}
}
ProcessResult
scriptProcess
=
Process
.
runSync
(
final
ProcessResult
scriptProcess
=
Process
.
runSync
(
'../../bin/cache/dart-sdk/bin/dart'
,
'../../bin/cache/dart-sdk/bin/dart'
,
options
,
options
,
);
);
...
...
dev/manual_tests/card_collection.dart
View file @
6c97dd2c
...
@@ -42,7 +42,7 @@ class CardCollectionState extends State<CardCollection> {
...
@@ -42,7 +42,7 @@ class CardCollectionState extends State<CardCollection> {
bool
_varyFontSizes
=
false
;
bool
_varyFontSizes
=
false
;
void
_initVariableSizedCardModels
()
{
void
_initVariableSizedCardModels
()
{
List
<
double
>
cardHeights
=
<
double
>[
final
List
<
double
>
cardHeights
=
<
double
>[
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
...
@@ -119,7 +119,7 @@ class CardCollectionState extends State<CardCollection> {
...
@@ -119,7 +119,7 @@ class CardCollectionState extends State<CardCollection> {
}
}
String
_dismissDirectionText
(
DismissDirection
direction
)
{
String
_dismissDirectionText
(
DismissDirection
direction
)
{
String
s
=
direction
.
toString
();
final
String
s
=
direction
.
toString
();
return
"dismiss
${s.substring(s.indexOf('.') + 1)}
"
;
return
"dismiss
${s.substring(s.indexOf('.') + 1)}
"
;
}
}
...
@@ -247,8 +247,8 @@ class CardCollectionState extends State<CardCollection> {
...
@@ -247,8 +247,8 @@ class CardCollectionState extends State<CardCollection> {
}
}
Widget
_buildCard
(
BuildContext
context
,
int
index
)
{
Widget
_buildCard
(
BuildContext
context
,
int
index
)
{
CardModel
cardModel
=
_cardModels
[
index
];
final
CardModel
cardModel
=
_cardModels
[
index
];
Widget
card
=
new
Dismissable
(
final
Widget
card
=
new
Dismissable
(
key:
new
ObjectKey
(
cardModel
),
key:
new
ObjectKey
(
cardModel
),
direction:
_dismissDirection
,
direction:
_dismissDirection
,
onDismissed:
(
DismissDirection
direction
)
{
dismissCard
(
cardModel
);
},
onDismissed:
(
DismissDirection
direction
)
{
dismissCard
(
cardModel
);
},
...
@@ -318,7 +318,7 @@ class CardCollectionState extends State<CardCollection> {
...
@@ -318,7 +318,7 @@ class CardCollectionState extends State<CardCollection> {
// size of the background,card Stack will be based only on the card. The
// size of the background,card Stack will be based only on the card. The
// Viewport ensures that when the card's resize animation occurs, the
// Viewport ensures that when the card's resize animation occurs, the
// background (text and icons) will just be clipped, not resized.
// background (text and icons) will just be clipped, not resized.
Widget
background
=
new
Positioned
.
fill
(
final
Widget
background
=
new
Positioned
.
fill
(
child:
new
Container
(
child:
new
Container
(
margin:
const
EdgeInsets
.
all
(
4.0
),
margin:
const
EdgeInsets
.
all
(
4.0
),
child:
new
SingleChildScrollView
(
child:
new
SingleChildScrollView
(
...
@@ -376,7 +376,7 @@ class CardCollectionState extends State<CardCollection> {
...
@@ -376,7 +376,7 @@ class CardCollectionState extends State<CardCollection> {
);
);
}
}
Widget
body
=
new
Container
(
final
Widget
body
=
new
Container
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
12.0
,
horizontal:
8.0
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
12.0
,
horizontal:
8.0
),
color:
_primaryColor
[
50
],
color:
_primaryColor
[
50
],
child:
cardCollection
,
child:
cardCollection
,
...
...
dev/manual_tests/drag_and_drop.dart
View file @
6c97dd2c
...
@@ -97,7 +97,7 @@ class ExampleDragSource extends StatelessWidget {
...
@@ -97,7 +97,7 @@ class ExampleDragSource extends StatelessWidget {
if
(
heavy
)
if
(
heavy
)
size
*=
kHeavyMultiplier
;
size
*=
kHeavyMultiplier
;
Widget
contents
=
new
DefaultTextStyle
(
final
Widget
contents
=
new
DefaultTextStyle
(
style:
Theme
.
of
(
context
).
textTheme
.
body1
,
style:
Theme
.
of
(
context
).
textTheme
.
body1
,
textAlign:
TextAlign
.
center
,
textAlign:
TextAlign
.
center
,
child:
new
Dot
(
child:
new
Dot
(
...
@@ -185,7 +185,7 @@ class MovableBall extends StatelessWidget {
...
@@ -185,7 +185,7 @@ class MovableBall extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
Widget
ball
=
new
DefaultTextStyle
(
final
Widget
ball
=
new
DefaultTextStyle
(
style:
Theme
.
of
(
context
).
primaryTextTheme
.
body1
,
style:
Theme
.
of
(
context
).
primaryTextTheme
.
body1
,
textAlign:
TextAlign
.
center
,
textAlign:
TextAlign
.
center
,
child:
new
Dot
(
child:
new
Dot
(
...
@@ -196,7 +196,7 @@ class MovableBall extends StatelessWidget {
...
@@ -196,7 +196,7 @@ class MovableBall extends StatelessWidget {
child:
new
Center
(
child:
new
Text
(
'BALL'
))
child:
new
Center
(
child:
new
Text
(
'BALL'
))
)
)
);
);
Widget
dashedBall
=
new
Container
(
final
Widget
dashedBall
=
new
Container
(
width:
kBallSize
,
width:
kBallSize
,
height:
kBallSize
,
height:
kBallSize
,
child:
new
CustomPaint
(
child:
new
CustomPaint
(
...
...
dev/manual_tests/overlay_geometry.dart
View file @
6c97dd2c
...
@@ -31,8 +31,8 @@ class _MarkerPainter extends CustomPainter {
...
@@ -31,8 +31,8 @@ class _MarkerPainter extends CustomPainter {
@override
@override
void
paint
(
Canvas
canvas
,
_
)
{
void
paint
(
Canvas
canvas
,
_
)
{
Paint
paint
=
new
Paint
()..
color
=
const
Color
(
0x8000FF00
);
final
Paint
paint
=
new
Paint
()..
color
=
const
Color
(
0x8000FF00
);
double
r
=
size
/
2.0
;
final
double
r
=
size
/
2.0
;
canvas
.
drawCircle
(
new
Point
(
r
,
r
),
r
,
paint
);
canvas
.
drawCircle
(
new
Point
(
r
,
r
),
r
,
paint
);
paint
paint
...
@@ -107,7 +107,7 @@ class CardBuilder extends SliverChildDelegate {
...
@@ -107,7 +107,7 @@ class CardBuilder extends SliverChildDelegate {
Widget
build
(
BuildContext
context
,
int
index
)
{
Widget
build
(
BuildContext
context
,
int
index
)
{
if
(
index
>=
cardModels
.
length
)
if
(
index
>=
cardModels
.
length
)
return
null
;
return
null
;
CardModel
cardModel
=
cardModels
[
index
];
final
CardModel
cardModel
=
cardModels
[
index
];
return
new
GestureDetector
(
return
new
GestureDetector
(
key:
cardModel
.
key
,
key:
cardModel
.
key
,
onTapUp:
(
TapUpDetails
details
)
{
onTapUp
(
cardModel
.
targetKey
,
details
.
globalPosition
);
},
onTapUp:
(
TapUpDetails
details
)
{
onTapUp
(
cardModel
.
targetKey
,
details
.
globalPosition
);
},
...
@@ -140,13 +140,13 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
...
@@ -140,13 +140,13 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
List
<
double
>
cardHeights
=
<
double
>[
final
List
<
double
>
cardHeights
=
<
double
>[
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
48.0
,
63.0
,
82.0
,
146.0
,
60.0
,
55.0
,
84.0
,
96.0
,
50.0
,
];
];
cardModels
=
new
List
<
CardModel
>.
generate
(
cardHeights
.
length
,
(
int
i
)
{
cardModels
=
new
List
<
CardModel
>.
generate
(
cardHeights
.
length
,
(
int
i
)
{
Color
color
=
Color
.
lerp
(
Colors
.
red
[
300
],
Colors
.
blue
[
900
],
i
/
cardHeights
.
length
);
final
Color
color
=
Color
.
lerp
(
Colors
.
red
[
300
],
Colors
.
blue
[
900
],
i
/
cardHeights
.
length
);
return
new
CardModel
(
i
,
cardHeights
[
i
],
color
);
return
new
CardModel
(
i
,
cardHeights
[
i
],
color
);
});
});
}
}
...
@@ -154,10 +154,10 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
...
@@ -154,10 +154,10 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
bool
handleScrollNotification
(
ScrollNotification
notification
)
{
bool
handleScrollNotification
(
ScrollNotification
notification
)
{
if
(
notification
is
ScrollUpdateNotification
&&
notification
.
depth
==
1
)
{
if
(
notification
is
ScrollUpdateNotification
&&
notification
.
depth
==
1
)
{
setState
(()
{
setState
(()
{
double
dy
=
markersScrollOffset
-
notification
.
metrics
.
extentBefore
;
final
double
dy
=
markersScrollOffset
-
notification
.
metrics
.
extentBefore
;
markersScrollOffset
=
notification
.
metrics
.
extentBefore
;
markersScrollOffset
=
notification
.
metrics
.
extentBefore
;
for
(
MarkerType
type
in
markers
.
keys
)
{
for
(
MarkerType
type
in
markers
.
keys
)
{
Point
oldPosition
=
markers
[
type
];
final
Point
oldPosition
=
markers
[
type
];
markers
[
type
]
=
new
Point
(
oldPosition
.
x
,
oldPosition
.
y
+
dy
);
markers
[
type
]
=
new
Point
(
oldPosition
.
x
,
oldPosition
.
y
+
dy
);
}
}
});
});
...
@@ -179,7 +179,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
...
@@ -179,7 +179,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
layers
=
<
Widget
>[
final
List
<
Widget
>
layers
=
<
Widget
>[
new
Scaffold
(
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
'Tap a Card'
)),
appBar:
new
AppBar
(
title:
new
Text
(
'Tap a Card'
)),
body:
new
Container
(
body:
new
Container
(
...
...
dev/manual_tests/page_view.dart
View file @
6c97dd2c
...
@@ -31,7 +31,7 @@ class PageViewAppState extends State<PageViewApp> {
...
@@ -31,7 +31,7 @@ class PageViewAppState extends State<PageViewApp> {
];
];
cardModels
=
new
List
<
CardModel
>.
generate
(
cardSizes
.
length
,
(
int
i
)
{
cardModels
=
new
List
<
CardModel
>.
generate
(
cardSizes
.
length
,
(
int
i
)
{
Color
color
=
Color
.
lerp
(
Colors
.
red
[
300
],
Colors
.
blue
[
900
],
i
/
cardSizes
.
length
);
final
Color
color
=
Color
.
lerp
(
Colors
.
red
[
300
],
Colors
.
blue
[
900
],
i
/
cardSizes
.
length
);
return
new
CardModel
(
i
,
cardSizes
[
i
],
color
);
return
new
CardModel
(
i
,
cardSizes
[
i
],
color
);
});
});
}
}
...
@@ -45,7 +45,7 @@ class PageViewAppState extends State<PageViewApp> {
...
@@ -45,7 +45,7 @@ class PageViewAppState extends State<PageViewApp> {
bool
itemsWrap
=
false
;
bool
itemsWrap
=
false
;
Widget
buildCard
(
CardModel
cardModel
)
{
Widget
buildCard
(
CardModel
cardModel
)
{
Widget
card
=
new
Card
(
final
Widget
card
=
new
Card
(
color:
cardModel
.
color
,
color:
cardModel
.
color
,
child:
new
Container
(
child:
new
Container
(
width:
cardModel
.
size
.
width
,
width:
cardModel
.
size
.
width
,
...
@@ -55,7 +55,7 @@ class PageViewAppState extends State<PageViewApp> {
...
@@ -55,7 +55,7 @@ class PageViewAppState extends State<PageViewApp> {
),
),
);
);
BoxConstraints
constraints
=
(
scrollDirection
==
Axis
.
vertical
)
final
BoxConstraints
constraints
=
(
scrollDirection
==
Axis
.
vertical
)
?
new
BoxConstraints
.
tightFor
(
height:
pageSize
.
height
)
?
new
BoxConstraints
.
tightFor
(
height:
pageSize
.
height
)
:
new
BoxConstraints
.
tightFor
(
width:
pageSize
.
width
);
:
new
BoxConstraints
.
tightFor
(
width:
pageSize
.
width
);
...
...
dev/manual_tests/test/card_collection_test.dart
View file @
6c97dd2c
...
@@ -13,7 +13,7 @@ void main() {
...
@@ -13,7 +13,7 @@ void main() {
await
tester
.
pump
();
// see https://github.com/flutter/flutter/issues/1865
await
tester
.
pump
();
// see https://github.com/flutter/flutter/issues/1865
await
tester
.
pump
();
// triggers a frame
await
tester
.
pump
();
// triggers a frame
Finder
navigationMenu
=
find
.
byWidgetPredicate
((
Widget
widget
)
{
final
Finder
navigationMenu
=
find
.
byWidgetPredicate
((
Widget
widget
)
{
if
(
widget
is
Tooltip
)
if
(
widget
is
Tooltip
)
return
widget
.
message
==
'Open navigation menu'
;
return
widget
.
message
==
'Open navigation menu'
;
return
false
;
return
false
;
...
...
dev/tools/dartdoc.dart
View file @
6c97dd2c
...
@@ -25,7 +25,7 @@ Future<Null> main(List<String> args) async {
...
@@ -25,7 +25,7 @@ Future<Null> main(List<String> args) async {
Directory
.
current
=
Directory
.
current
.
parent
.
parent
;
Directory
.
current
=
Directory
.
current
.
parent
.
parent
;
// Create the pubspec.yaml file.
// Create the pubspec.yaml file.
StringBuffer
buf
=
new
StringBuffer
(
'''
final
StringBuffer
buf
=
new
StringBuffer
(
'''
name: Flutter
name: Flutter
dependencies:
dependencies:
'''
);
'''
);
...
@@ -40,10 +40,10 @@ dependencies:
...
@@ -40,10 +40,10 @@ dependencies:
new
File
(
'dev/docs/pubspec.yaml'
).
writeAsStringSync
(
buf
.
toString
());
new
File
(
'dev/docs/pubspec.yaml'
).
writeAsStringSync
(
buf
.
toString
());
// Create the library file.
// Create the library file.
Directory
libDir
=
new
Directory
(
'dev/docs/lib'
);
final
Directory
libDir
=
new
Directory
(
'dev/docs/lib'
);
libDir
.
createSync
();
libDir
.
createSync
();
StringBuffer
contents
=
new
StringBuffer
(
'library temp_doc;
\n\n
'
);
final
StringBuffer
contents
=
new
StringBuffer
(
'library temp_doc;
\n\n
'
);
for
(
String
libraryRef
in
libraryRefs
())
{
for
(
String
libraryRef
in
libraryRefs
())
{
contents
.
writeln
(
'import
\'
package:
$libraryRef
\'
;'
);
contents
.
writeln
(
'import
\'
package:
$libraryRef
\'
;'
);
}
}
...
@@ -58,14 +58,14 @@ dependencies:
...
@@ -58,14 +58,14 @@ dependencies:
);
);
printStream
(
process
.
stdout
);
printStream
(
process
.
stdout
);
printStream
(
process
.
stderr
);
printStream
(
process
.
stderr
);
int
code
=
await
process
.
exitCode
;
final
int
code
=
await
process
.
exitCode
;
if
(
code
!=
0
)
if
(
code
!=
0
)
exit
(
code
);
exit
(
code
);
createFooter
(
'dev/docs/lib/footer.html'
);
createFooter
(
'dev/docs/lib/footer.html'
);
// Generate the documentation.
// Generate the documentation.
List
<
String
>
args
=
<
String
>[
final
List
<
String
>
args
=
<
String
>[
'global'
,
'run'
,
'dartdoc'
,
'global'
,
'run'
,
'dartdoc'
,
'--header'
,
'styles.html'
,
'--header'
,
'styles.html'
,
'--header'
,
'analytics.html'
,
'--header'
,
'analytics.html'
,
...
@@ -84,7 +84,7 @@ dependencies:
...
@@ -84,7 +84,7 @@ dependencies:
process
=
await
Process
.
start
(
'pub'
,
args
,
workingDirectory:
'dev/docs'
);
process
=
await
Process
.
start
(
'pub'
,
args
,
workingDirectory:
'dev/docs'
);
printStream
(
process
.
stdout
);
printStream
(
process
.
stdout
);
printStream
(
process
.
stderr
);
printStream
(
process
.
stderr
);
int
exitCode
=
await
process
.
exitCode
;
final
int
exitCode
=
await
process
.
exitCode
;
if
(
exitCode
!=
0
)
if
(
exitCode
!=
0
)
exit
(
exitCode
);
exit
(
exitCode
);
...
@@ -95,10 +95,10 @@ dependencies:
...
@@ -95,10 +95,10 @@ dependencies:
}
}
void
createFooter
(
String
footerPath
)
{
void
createFooter
(
String
footerPath
)
{
ProcessResult
gitResult
=
Process
.
runSync
(
'git'
,
<
String
>[
'rev-parse'
,
'HEAD'
]);
final
ProcessResult
gitResult
=
Process
.
runSync
(
'git'
,
<
String
>[
'rev-parse'
,
'HEAD'
]);
String
gitHead
=
(
gitResult
.
exitCode
==
0
)
?
gitResult
.
stdout
.
trim
()
:
'unknown'
;
final
String
gitHead
=
(
gitResult
.
exitCode
==
0
)
?
gitResult
.
stdout
.
trim
()
:
'unknown'
;
String
timestamp
=
new
DateFormat
(
'yyyy-MM-dd HH:mm'
).
format
(
new
DateTime
.
now
());
final
String
timestamp
=
new
DateFormat
(
'yyyy-MM-dd HH:mm'
).
format
(
new
DateTime
.
now
());
new
File
(
footerPath
).
writeAsStringSync
(
new
File
(
footerPath
).
writeAsStringSync
(
'<p class="text-center" style="font-size: 10px">'
'<p class="text-center" style="font-size: 10px">'
...
@@ -107,7 +107,7 @@ void createFooter(String footerPath) {
...
@@ -107,7 +107,7 @@ void createFooter(String footerPath) {
}
}
void
sanityCheckDocs
(
)
{
void
sanityCheckDocs
(
)
{
List
<
String
>
canaries
=
<
String
>[
final
List
<
String
>
canaries
=
<
String
>[
'
$kDocRoot
/api/dart-io/File-class.html'
,
'
$kDocRoot
/api/dart-io/File-class.html'
,
'
$kDocRoot
/api/dart-ui/Canvas-class.html'
,
'
$kDocRoot
/api/dart-ui/Canvas-class.html'
,
'
$kDocRoot
/api/dart-ui/Canvas/drawRect.html'
,
'
$kDocRoot
/api/dart-ui/Canvas/drawRect.html'
,
...
@@ -151,7 +151,7 @@ void copyIndexToRootOfDocs() {
...
@@ -151,7 +151,7 @@ void copyIndexToRootOfDocs() {
}
}
void
addHtmlBaseToIndex
(
)
{
void
addHtmlBaseToIndex
(
)
{
File
indexFile
=
new
File
(
'
$kDocRoot
/index.html'
);
final
File
indexFile
=
new
File
(
'
$kDocRoot
/index.html'
);
String
indexContents
=
indexFile
.
readAsStringSync
();
String
indexContents
=
indexFile
.
readAsStringSync
();
indexContents
=
indexContents
.
replaceFirst
(
'</title>
\n
'
,
indexContents
=
indexContents
.
replaceFirst
(
'</title>
\n
'
,
'</title>
\n
<base href="./flutter/">
\n
'
);
'</title>
\n
<base href="./flutter/">
\n
'
);
...
@@ -163,7 +163,7 @@ void addHtmlBaseToIndex() {
...
@@ -163,7 +163,7 @@ void addHtmlBaseToIndex() {
}
}
void
putRedirectInOldIndexLocation
(
)
{
void
putRedirectInOldIndexLocation
(
)
{
String
metaTag
=
'<meta http-equiv="refresh" content="0;URL=../index.html">'
;
final
String
metaTag
=
'<meta http-equiv="refresh" content="0;URL=../index.html">'
;
new
File
(
'
$kDocRoot
/flutter/index.html'
).
writeAsStringSync
(
metaTag
);
new
File
(
'
$kDocRoot
/flutter/index.html'
).
writeAsStringSync
(
metaTag
);
}
}
...
@@ -178,7 +178,7 @@ List<Directory> findPackages() {
...
@@ -178,7 +178,7 @@ List<Directory> findPackages() {
.
where
((
FileSystemEntity
entity
)
{
.
where
((
FileSystemEntity
entity
)
{
if
(
entity
is
!
Directory
)
if
(
entity
is
!
Directory
)
return
false
;
return
false
;
File
pubspec
=
new
File
(
'
${entity.path}
/pubspec.yaml'
);
final
File
pubspec
=
new
File
(
'
${entity.path}
/pubspec.yaml'
);
// TODO(ianh): Use a real YAML parser here
// TODO(ianh): Use a real YAML parser here
return
!
pubspec
.
readAsStringSync
().
contains
(
'nodoc: true'
);
return
!
pubspec
.
readAsStringSync
().
contains
(
'nodoc: true'
);
})
})
...
@@ -190,7 +190,7 @@ List<Directory> findPackages() {
...
@@ -190,7 +190,7 @@ List<Directory> findPackages() {
/// diskPath toggles between import paths vs. disk paths.
/// diskPath toggles between import paths vs. disk paths.
Iterable
<
String
>
libraryRefs
({
bool
diskPath:
false
})
sync
*
{
Iterable
<
String
>
libraryRefs
({
bool
diskPath:
false
})
sync
*
{
for
(
Directory
dir
in
findPackages
())
{
for
(
Directory
dir
in
findPackages
())
{
String
dirName
=
path
.
basename
(
dir
.
path
);
final
String
dirName
=
path
.
basename
(
dir
.
path
);
for
(
FileSystemEntity
file
in
new
Directory
(
'
${dir.path}
/lib'
).
listSync
())
{
for
(
FileSystemEntity
file
in
new
Directory
(
'
${dir.path}
/lib'
).
listSync
())
{
if
(
file
is
File
&&
file
.
path
.
endsWith
(
'.dart'
))
{
if
(
file
is
File
&&
file
.
path
.
endsWith
(
'.dart'
))
{
if
(
diskPath
)
if
(
diskPath
)
...
...
dev/tools/javadoc.dart
View file @
6c97dd2c
...
@@ -13,26 +13,26 @@ const String kDocRoot = 'dev/docs/doc';
...
@@ -13,26 +13,26 @@ const String kDocRoot = 'dev/docs/doc';
/// This script downloads an archive of Javadoc for the engine from the
/// This script downloads an archive of Javadoc for the engine from the
/// artifact store and extracts it to the location used for Dartdoc.
/// artifact store and extracts it to the location used for Dartdoc.
Future
<
Null
>
main
(
List
<
String
>
args
)
async
{
Future
<
Null
>
main
(
List
<
String
>
args
)
async
{
String
engineVersion
=
new
File
(
'bin/internal/engine.version'
).
readAsStringSync
().
trim
();
final
String
engineVersion
=
new
File
(
'bin/internal/engine.version'
).
readAsStringSync
().
trim
();
String
url
=
'https://storage.googleapis.com/flutter_infra/flutter/
$engineVersion
/android-javadoc.zip'
;
final
String
url
=
'https://storage.googleapis.com/flutter_infra/flutter/
$engineVersion
/android-javadoc.zip'
;
http
.
Response
response
=
await
http
.
get
(
url
);
final
http
.
Response
response
=
await
http
.
get
(
url
);
Archive
archive
=
new
ZipDecoder
().
decodeBytes
(
response
.
bodyBytes
);
final
Archive
archive
=
new
ZipDecoder
().
decodeBytes
(
response
.
bodyBytes
);
Directory
output
=
new
Directory
(
'
$kDocRoot
/javadoc'
);
final
Directory
output
=
new
Directory
(
'
$kDocRoot
/javadoc'
);
print
(
'Extracing javadoc to
${output.path}
'
);
print
(
'Extracing javadoc to
${output.path}
'
);
output
.
createSync
(
recursive:
true
);
output
.
createSync
(
recursive:
true
);
for
(
ArchiveFile
af
in
archive
)
{
for
(
ArchiveFile
af
in
archive
)
{
if
(
af
.
isFile
)
{
if
(
af
.
isFile
)
{
File
file
=
new
File
(
'
${output.path}
/
${af.name}
'
);
final
File
file
=
new
File
(
'
${output.path}
/
${af.name}
'
);
file
.
createSync
(
recursive:
true
);
file
.
createSync
(
recursive:
true
);
file
.
writeAsBytesSync
(
af
.
content
);
file
.
writeAsBytesSync
(
af
.
content
);
}
}
}
}
File
testFile
=
new
File
(
'
${output.path}
/io/flutter/view/FlutterView.html'
);
final
File
testFile
=
new
File
(
'
${output.path}
/io/flutter/view/FlutterView.html'
);
if
(!
testFile
.
existsSync
())
{
if
(!
testFile
.
existsSync
())
{
print
(
'Expected file
${testFile.path}
not found'
);
print
(
'Expected file
${testFile.path}
not found'
);
exit
(
1
);
exit
(
1
);
...
...
dev/tools/mega_gallery.dart
View file @
6c97dd2c
...
@@ -17,14 +17,14 @@ void main(List<String> args) {
...
@@ -17,14 +17,14 @@ void main(List<String> args) {
if
(
path
.
basename
(
Directory
.
current
.
path
)
==
'tools'
)
if
(
path
.
basename
(
Directory
.
current
.
path
)
==
'tools'
)
Directory
.
current
=
Directory
.
current
.
parent
.
parent
;
Directory
.
current
=
Directory
.
current
.
parent
.
parent
;
ArgParser
argParser
=
new
ArgParser
();
final
ArgParser
argParser
=
new
ArgParser
();
// ../mega_gallery? dev/benchmarks/mega_gallery?
// ../mega_gallery? dev/benchmarks/mega_gallery?
argParser
.
addOption
(
'out'
,
defaultsTo:
_normalize
(
'dev/benchmarks/mega_gallery'
));
argParser
.
addOption
(
'out'
,
defaultsTo:
_normalize
(
'dev/benchmarks/mega_gallery'
));
argParser
.
addOption
(
'copies'
);
argParser
.
addOption
(
'copies'
);
argParser
.
addFlag
(
'delete'
,
negatable:
false
);
argParser
.
addFlag
(
'delete'
,
negatable:
false
);
argParser
.
addFlag
(
'help'
,
abbr:
'h'
,
negatable:
false
);
argParser
.
addFlag
(
'help'
,
abbr:
'h'
,
negatable:
false
);
ArgResults
results
=
argParser
.
parse
(
args
);
final
ArgResults
results
=
argParser
.
parse
(
args
);
if
(
results
[
'help'
])
{
if
(
results
[
'help'
])
{
print
(
'Generate n copies of flutter_gallery.
\n
'
);
print
(
'Generate n copies of flutter_gallery.
\n
'
);
...
@@ -33,8 +33,8 @@ void main(List<String> args) {
...
@@ -33,8 +33,8 @@ void main(List<String> args) {
exit
(
0
);
exit
(
0
);
}
}
Directory
source
=
new
Directory
(
_normalize
(
'examples/flutter_gallery'
));
final
Directory
source
=
new
Directory
(
_normalize
(
'examples/flutter_gallery'
));
Directory
out
=
new
Directory
(
_normalize
(
results
[
'out'
]));
final
Directory
out
=
new
Directory
(
_normalize
(
results
[
'out'
]));
if
(
results
[
'delete'
])
{
if
(
results
[
'delete'
])
{
if
(
out
.
existsSync
())
{
if
(
out
.
existsSync
())
{
...
@@ -47,7 +47,7 @@ void main(List<String> args) {
...
@@ -47,7 +47,7 @@ void main(List<String> args) {
int
copies
;
int
copies
;
if
(!
results
.
wasParsed
(
'copies'
))
{
if
(!
results
.
wasParsed
(
'copies'
))
{
SourceStats
stats
=
getStatsFor
(
_dir
(
source
,
'lib'
));
final
SourceStats
stats
=
getStatsFor
(
_dir
(
source
,
'lib'
));
copies
=
(
kTargetLineCount
/
stats
.
lines
).
round
();
copies
=
(
kTargetLineCount
/
stats
.
lines
).
round
();
}
else
{
}
else
{
copies
=
int
.
parse
(
results
[
'copies'
]);
copies
=
int
.
parse
(
results
[
'copies'
]);
...
@@ -59,7 +59,7 @@ void main(List<String> args) {
...
@@ -59,7 +59,7 @@ void main(List<String> args) {
print
(
' packages/flutter :
${getStatsFor(new Directory("packages/flutter"))}
'
);
print
(
' packages/flutter :
${getStatsFor(new Directory("packages/flutter"))}
'
);
print
(
' examples/flutter_gallery :
${getStatsFor(new Directory("examples/flutter_gallery"))}
'
);
print
(
' examples/flutter_gallery :
${getStatsFor(new Directory("examples/flutter_gallery"))}
'
);
Directory
lib
=
_dir
(
out
,
'lib'
);
final
Directory
lib
=
_dir
(
out
,
'lib'
);
if
(
lib
.
existsSync
())
if
(
lib
.
existsSync
())
lib
.
deleteSync
(
recursive:
true
);
lib
.
deleteSync
(
recursive:
true
);
...
@@ -86,15 +86,15 @@ void main(List<String> args) {
...
@@ -86,15 +86,15 @@ void main(List<String> args) {
// TODO(devoncarew): Create an entry-point that builds a UI with all `n` copies.
// TODO(devoncarew): Create an entry-point that builds a UI with all `n` copies.
void
_createEntry
(
File
mainFile
,
int
copies
)
{
void
_createEntry
(
File
mainFile
,
int
copies
)
{
StringBuffer
imports
=
new
StringBuffer
();
final
StringBuffer
imports
=
new
StringBuffer
();
StringBuffer
importRefs
=
new
StringBuffer
();
final
StringBuffer
importRefs
=
new
StringBuffer
();
for
(
int
i
=
1
;
i
<
copies
;
i
++)
{
for
(
int
i
=
1
;
i
<
copies
;
i
++)
{
imports
.
writeln
(
"import 'gallery_
$i
/main.dart' as main_
$i
;"
);
imports
.
writeln
(
"import 'gallery_
$i
/main.dart' as main_
$i
;"
);
importRefs
.
writeln
(
" main_
$i
.main;"
);
importRefs
.
writeln
(
" main_
$i
.main;"
);
}
}
String
contents
=
'''
final
String
contents
=
'''
// Copyright 2016 The Chromium Authors. All rights reserved.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
...
@@ -116,8 +116,8 @@ void main() {
...
@@ -116,8 +116,8 @@ void main() {
}
}
void
_copyGallery
(
Directory
galleryDir
,
int
index
)
{
void
_copyGallery
(
Directory
galleryDir
,
int
index
)
{
Directory
lib
=
_dir
(
galleryDir
,
'lib'
);
final
Directory
lib
=
_dir
(
galleryDir
,
'lib'
);
Directory
dest
=
_dir
(
lib
,
'gallery_
$index
'
);
final
Directory
dest
=
_dir
(
lib
,
'gallery_
$index
'
);
dest
.
createSync
();
dest
.
createSync
();
// Copy demo/, gallery/, and main.dart.
// Copy demo/, gallery/, and main.dart.
...
@@ -131,7 +131,7 @@ void _copy(Directory source, Directory target) {
...
@@ -131,7 +131,7 @@ void _copy(Directory source, Directory target) {
target
.
createSync
();
target
.
createSync
();
for
(
FileSystemEntity
entity
in
source
.
listSync
(
followLinks:
false
))
{
for
(
FileSystemEntity
entity
in
source
.
listSync
(
followLinks:
false
))
{
String
name
=
path
.
basename
(
entity
.
path
);
final
String
name
=
path
.
basename
(
entity
.
path
);
if
(
entity
is
Directory
)
{
if
(
entity
is
Directory
)
{
if
(
name
==
'build'
||
name
.
startsWith
(
'.'
))
if
(
name
==
'build'
||
name
.
startsWith
(
'.'
))
...
@@ -140,7 +140,7 @@ void _copy(Directory source, Directory target) {
...
@@ -140,7 +140,7 @@ void _copy(Directory source, Directory target) {
}
else
if
(
entity
is
File
)
{
}
else
if
(
entity
is
File
)
{
if
(
name
==
'.packages'
||
name
==
'pubspec.lock'
)
if
(
name
==
'.packages'
||
name
==
'pubspec.lock'
)
continue
;
continue
;
File
dest
=
new
File
(
path
.
join
(
target
.
path
,
name
));
final
File
dest
=
new
File
(
path
.
join
(
target
.
path
,
name
));
dest
.
writeAsBytesSync
(
entity
.
readAsBytesSync
());
dest
.
writeAsBytesSync
(
entity
.
readAsBytesSync
());
}
}
}
}
...
@@ -162,7 +162,7 @@ SourceStats getStatsFor(Directory dir, [SourceStats stats]) {
...
@@ -162,7 +162,7 @@ SourceStats getStatsFor(Directory dir, [SourceStats stats]) {
stats
??=
new
SourceStats
();
stats
??=
new
SourceStats
();
for
(
FileSystemEntity
entity
in
dir
.
listSync
(
recursive:
false
,
followLinks:
false
))
{
for
(
FileSystemEntity
entity
in
dir
.
listSync
(
recursive:
false
,
followLinks:
false
))
{
String
name
=
path
.
basename
(
entity
.
path
);
final
String
name
=
path
.
basename
(
entity
.
path
);
if
(
entity
is
File
&&
name
.
endsWith
(
'.dart'
))
{
if
(
entity
is
File
&&
name
.
endsWith
(
'.dart'
))
{
stats
.
files
+=
1
;
stats
.
files
+=
1
;
stats
.
lines
+=
_lineCount
(
entity
);
stats
.
lines
+=
_lineCount
(
entity
);
...
@@ -184,7 +184,7 @@ int _lineCount(File file) {
...
@@ -184,7 +184,7 @@ int _lineCount(File file) {
}
}
String
_comma
(
int
count
)
{
String
_comma
(
int
count
)
{
String
str
=
count
.
toString
();
final
String
str
=
count
.
toString
();
if
(
str
.
length
>
3
)
if
(
str
.
length
>
3
)
return
str
.
substring
(
0
,
str
.
length
-
3
)
+
','
+
str
.
substring
(
str
.
length
-
3
);
return
str
.
substring
(
0
,
str
.
length
-
3
)
+
','
+
str
.
substring
(
str
.
length
-
3
);
return
str
;
return
str
;
...
...
dev/tools/update_icons.dart
View file @
6c97dd2c
...
@@ -33,26 +33,26 @@ void main(List<String> args) {
...
@@ -33,26 +33,26 @@ void main(List<String> args) {
if
(
path
.
basename
(
Directory
.
current
.
path
)
==
'tools'
)
if
(
path
.
basename
(
Directory
.
current
.
path
)
==
'tools'
)
Directory
.
current
=
Directory
.
current
.
parent
.
parent
;
Directory
.
current
=
Directory
.
current
.
parent
.
parent
;
ArgParser
argParser
=
new
ArgParser
();
final
ArgParser
argParser
=
new
ArgParser
();
argParser
.
addOption
(
kOptionCodepointsPath
,
defaultsTo:
kDefaultCodepointsPath
);
argParser
.
addOption
(
kOptionCodepointsPath
,
defaultsTo:
kDefaultCodepointsPath
);
argParser
.
addOption
(
kOptionIconsPath
,
defaultsTo:
kDefaultIconsPath
);
argParser
.
addOption
(
kOptionIconsPath
,
defaultsTo:
kDefaultIconsPath
);
argParser
.
addFlag
(
kOptionDryRun
,
defaultsTo:
false
);
argParser
.
addFlag
(
kOptionDryRun
,
defaultsTo:
false
);
ArgResults
argResults
=
argParser
.
parse
(
args
);
final
ArgResults
argResults
=
argParser
.
parse
(
args
);
File
iconFile
=
new
File
(
path
.
absolute
(
argResults
[
kOptionIconsPath
]));
final
File
iconFile
=
new
File
(
path
.
absolute
(
argResults
[
kOptionIconsPath
]));
if
(!
iconFile
.
existsSync
())
{
if
(!
iconFile
.
existsSync
())
{
stderr
.
writeln
(
'Icons file not found:
${iconFile.path}
'
);
stderr
.
writeln
(
'Icons file not found:
${iconFile.path}
'
);
exit
(
1
);
exit
(
1
);
}
}
File
codepointsFile
=
new
File
(
path
.
absolute
(
argResults
[
kOptionCodepointsPath
]));
final
File
codepointsFile
=
new
File
(
path
.
absolute
(
argResults
[
kOptionCodepointsPath
]));
if
(!
codepointsFile
.
existsSync
())
{
if
(!
codepointsFile
.
existsSync
())
{
stderr
.
writeln
(
'Codepoints file not found:
${codepointsFile.path}
'
);
stderr
.
writeln
(
'Codepoints file not found:
${codepointsFile.path}
'
);
exit
(
1
);
exit
(
1
);
}
}
String
iconData
=
iconFile
.
readAsStringSync
();
final
String
iconData
=
iconFile
.
readAsStringSync
();
String
codepointData
=
codepointsFile
.
readAsStringSync
();
final
String
codepointData
=
codepointsFile
.
readAsStringSync
();
String
newIconData
=
regenerateIconsFile
(
iconData
,
codepointData
);
final
String
newIconData
=
regenerateIconsFile
(
iconData
,
codepointData
);
if
(
argResults
[
kOptionDryRun
])
if
(
argResults
[
kOptionDryRun
])
stdout
.
writeln
(
newIconData
);
stdout
.
writeln
(
newIconData
);
...
@@ -61,14 +61,14 @@ void main(List<String> args) {
...
@@ -61,14 +61,14 @@ void main(List<String> args) {
}
}
String
regenerateIconsFile
(
String
iconData
,
String
codepointData
)
{
String
regenerateIconsFile
(
String
iconData
,
String
codepointData
)
{
StringBuffer
buf
=
new
StringBuffer
();
final
StringBuffer
buf
=
new
StringBuffer
();
bool
generating
=
false
;
bool
generating
=
false
;
for
(
String
line
in
LineSplitter
.
split
(
iconData
))
{
for
(
String
line
in
LineSplitter
.
split
(
iconData
))
{
if
(!
generating
)
if
(!
generating
)
buf
.
writeln
(
line
);
buf
.
writeln
(
line
);
if
(
line
.
contains
(
kBeginGeneratedMark
))
{
if
(
line
.
contains
(
kBeginGeneratedMark
))
{
generating
=
true
;
generating
=
true
;
String
iconDeclarations
=
generateIconDeclarations
(
codepointData
);
final
String
iconDeclarations
=
generateIconDeclarations
(
codepointData
);
buf
.
write
(
iconDeclarations
);
buf
.
write
(
iconDeclarations
);
}
else
if
(
line
.
contains
(
kEndGeneratedMark
))
{
}
else
if
(
line
.
contains
(
kEndGeneratedMark
))
{
generating
=
false
;
generating
=
false
;
...
@@ -87,13 +87,13 @@ String generateIconDeclarations(String codepointData) {
...
@@ -87,13 +87,13 @@ String generateIconDeclarations(String codepointData) {
}
}
String
getIconDeclaration
(
String
line
)
{
String
getIconDeclaration
(
String
line
)
{
List
<
String
>
tokens
=
line
.
split
(
' '
);
final
List
<
String
>
tokens
=
line
.
split
(
' '
);
if
(
tokens
.
length
!=
2
)
if
(
tokens
.
length
!=
2
)
throw
new
FormatException
(
'Unexpected codepoint data:
$line
'
);
throw
new
FormatException
(
'Unexpected codepoint data:
$line
'
);
String
name
=
tokens
[
0
];
final
String
name
=
tokens
[
0
];
String
codepoint
=
tokens
[
1
];
final
String
codepoint
=
tokens
[
1
];
String
identifier
=
kIdentifierRewrites
[
name
]
??
name
;
final
String
identifier
=
kIdentifierRewrites
[
name
]
??
name
;
String
description
=
name
.
replaceAll
(
'_'
,
' '
);
final
String
description
=
name
.
replaceAll
(
'_'
,
' '
);
return
'''
return
'''
/// <p><i class="material-icons md-36">
$name
</i> — material icon named "
$description
".</p>
/// <p><i class="material-icons md-36">
$name
</i> — material icon named "
$description
".</p>
...
...
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