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
ede575a9
Commit
ede575a9
authored
Jun 14, 2017
by
Hans Muller
Committed by
GitHub
Jun 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor sample catalog screenshot production (#10676)
parent
e5213b8e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
22 deletions
+30
-22
sample_catalog_generator.dart
dev/devicelab/lib/tasks/sample_catalog_generator.dart
+10
-6
save_catalog_screenshots.dart
dev/devicelab/lib/tasks/save_catalog_screenshots.dart
+17
-12
manifest.yaml
dev/devicelab/manifest.yaml
+1
-1
pubspec.yaml
dev/devicelab/pubspec.yaml
+1
-0
sample_page.dart
examples/catalog/bin/sample_page.dart
+1
-1
screenshot_test.dart.template
examples/catalog/bin/screenshot_test.dart.template
+0
-1
pubspec.yaml
examples/catalog/pubspec.yaml
+0
-1
No files found.
dev/devicelab/lib/tasks/sample_catalog_generator.dart
View file @
ede575a9
...
...
@@ -9,6 +9,8 @@ import '../framework/adb.dart';
import
'../framework/framework.dart'
;
import
'../framework/ios.dart'
;
import
'../framework/utils.dart'
;
import
'save_catalog_screenshots.dart'
show
saveCatalogScreenshots
;
Future
<
TaskResult
>
samplePageCatalogGenerator
(
String
authorizationToken
)
async
{
final
Device
device
=
await
devices
.
workingDevice
;
...
...
@@ -19,7 +21,8 @@ Future<TaskResult> samplePageCatalogGenerator(String authorizationToken) async {
await
inDirectory
(
catalogDirectory
,
()
async
{
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
if
(
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
)
final
bool
isIosDevice
=
deviceOperatingSystem
==
DeviceOperatingSystem
.
ios
;
if
(
isIosDevice
)
await
prepareProvisioningCertificates
(
catalogDirectory
.
path
);
await
dart
(<
String
>[
'bin/sample_page.dart'
]);
...
...
@@ -31,11 +34,12 @@ Future<TaskResult> samplePageCatalogGenerator(String authorizationToken) async {
deviceId
,
]);
await
dart
(<
String
>[
'bin/save_screenshots.dart'
,
await
getCurrentFlutterRepoCommit
(),
authorizationToken
,
]);
await
saveCatalogScreenshots
(
directory:
dir
(
'
${flutterDirectory.path}
/examples/catalog/.generated'
),
commit:
await
getCurrentFlutterRepoCommit
(),
token:
authorizationToken
,
prefix:
isIosDevice
?
'ios_'
:
''
,
);
});
return
new
TaskResult
.
success
(
null
);
...
...
examples/catalog/bin/save
_screenshots.dart
→
dev/devicelab/lib/tasks/save_catalog
_screenshots.dart
View file @
ede575a9
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:io'
;
...
...
@@ -56,6 +60,7 @@ class Upload {
final
HttpClientResponse
response
=
await
request
.
close
().
timeout
(
timeLimit
);
if
(
response
.
statusCode
==
HttpStatus
.
OK
)
{
logMessage
(
'Saved
$name
'
);
await
response
.
drain
<
Null
>();
}
else
{
// TODO(hansmuller): only retry on 5xx and 429 responses
...
...
@@ -96,40 +101,40 @@ Future<Null> saveScreenshots(List<String> fromPaths, List<String> largeNames, Li
for
(
int
index
=
0
;
index
<
uploads
.
length
;
index
+=
1
)
uploads
[
index
]
=
new
Upload
(
fromPaths
[
index
],
largeNames
[
index
],
smallNames
[
index
]);
final
HttpClient
client
=
new
HttpClient
();
while
(
uploads
.
any
(
Upload
.
isNotComplete
))
{
final
HttpClient
client
=
new
HttpClient
();
uploads
=
uploads
.
where
(
Upload
.
isNotComplete
).
toList
();
await
Future
.
wait
(
uploads
.
map
((
Upload
upload
)
=>
upload
.
run
(
client
)));
client
.
close
(
force:
true
);
}
client
.
close
();
}
// If path is lib/foo.png then screenshotName is foo.
String
screenshotName
(
String
path
)
=>
basenameWithoutExtension
(
path
);
Future
<
Null
>
main
(
List
<
String
>
args
)
async
{
if
(
args
.
length
!=
2
)
throw
new
UploadError
(
'Usage: dart bin/save_screenshots.dart commit authorization'
);
final
Directory
outputDirectory
=
new
Directory
(
'.generated'
);
Future
<
Null
>
saveCatalogScreenshots
({
Directory
directory
,
// Where the *.png screenshots are.
String
commit
,
// The commit hash to be used as a cloud storage "directory".
String
token
,
// Cloud storage authorization token.
String
prefix
,
// Prefix for all file names.
})
async
{
final
List
<
String
>
screenshots
=
<
String
>[];
outputD
irectory
.
listSync
().
forEach
((
FileSystemEntity
entity
)
{
d
irectory
.
listSync
().
forEach
((
FileSystemEntity
entity
)
{
if
(
entity
is
File
&&
entity
.
path
.
endsWith
(
'.png'
))
{
final
File
file
=
entity
;
screenshots
.
add
(
file
.
path
);
}
});
final
String
commit
=
args
[
0
];
final
List
<
String
>
largeNames
=
<
String
>[];
// Cloud storage names for the full res screenshots.
final
List
<
String
>
smallNames
=
<
String
>[];
// Likewise for the scaled down screenshots.
for
(
String
path
in
screenshots
)
{
final
String
name
=
screenshotName
(
path
);
largeNames
.
add
(
'
$commit
/
$name
.png'
);
smallNames
.
add
(
'
$commit
/
${name}
_small.png'
);
largeNames
.
add
(
'
$commit
/
$
prefix$
name
.png'
);
smallNames
.
add
(
'
$commit
/
$
prefix$
{name}
_small.png'
);
}
authorizationToken
=
args
[
1
]
;
authorizationToken
=
token
;
await
saveScreenshots
(
screenshots
,
largeNames
,
smallNames
);
}
dev/devicelab/manifest.yaml
View file @
ede575a9
...
...
@@ -118,7 +118,7 @@ tasks:
description
:
>
Builds sample catalog markdown pages and Android screenshots
stage
:
devicelab
required_agent_capabilities
:
[
"
linux/android
"
]
required_agent_capabilities
:
[
"
has-android-device
"
]
flaky
:
true
complex_layout_semantics_perf
:
...
...
dev/devicelab/pubspec.yaml
View file @
ede575a9
...
...
@@ -9,6 +9,7 @@ environment:
dependencies
:
args
:
^0.13.4
image
:
^1.1.27
meta
:
^1.0.5
path
:
^1.4.0
process
:
2.0.3
...
...
examples/catalog/bin/sample_page.dart
View file @
ede575a9
...
...
@@ -180,7 +180,7 @@ void generate() {
screenshotDriverTemplate
,
<
String
,
String
>{
'paths'
:
samples
.
map
((
SampleGenerator
sample
)
{
return
"'
${outputFile(
'\${prefix}
' +
sample.sourceName + '.png').path}'"
;
return
"'
${outputFile(sample.sourceName + '.png').path}
'"
;
}).
toList
().
join
(
',
\n
'
),
},
);
...
...
examples/catalog/bin/screenshot_test.dart.template
View file @
ede575a9
...
...
@@ -8,7 +8,6 @@ import 'package:test/test.dart';
void main() {
group('sample screenshots', () {
final String prefix = Platform.isMacOS ? 'ios_' : "";
FlutterDriver driver;
setUpAll(() async {
...
...
examples/catalog/pubspec.yaml
View file @
ede575a9
...
...
@@ -3,7 +3,6 @@ description: A collection of Flutter sample apps
dependencies
:
flutter
:
sdk
:
flutter
image
:
path
:
^1.4.0
dev_dependencies
:
...
...
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