mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add a devicelab task that generates sample app screenshots, etc (#10303)
This commit is contained in:
parent
9452a3448c
commit
b4e41ff7d3
@ -0,0 +1,14 @@
|
|||||||
|
// 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 'package:flutter_devicelab/framework/adb.dart';
|
||||||
|
import 'package:flutter_devicelab/framework/framework.dart';
|
||||||
|
import 'package:flutter_devicelab/tasks/sample_catalog_generator.dart';
|
||||||
|
|
||||||
|
Future<Null> main() async {
|
||||||
|
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||||
|
await task(samplePageCatalogGenerator);
|
||||||
|
}
|
14
dev/devicelab/bin/tasks/ios_sample_catalog_generator.dart
Normal file
14
dev/devicelab/bin/tasks/ios_sample_catalog_generator.dart
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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 'package:flutter_devicelab/framework/adb.dart';
|
||||||
|
import 'package:flutter_devicelab/framework/framework.dart';
|
||||||
|
import 'package:flutter_devicelab/tasks/sample_catalog_generator.dart';
|
||||||
|
|
||||||
|
Future<Null> main() async {
|
||||||
|
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||||
|
await task(samplePageCatalogGenerator);
|
||||||
|
}
|
38
dev/devicelab/lib/tasks/sample_catalog_generator.dart
Normal file
38
dev/devicelab/lib/tasks/sample_catalog_generator.dart
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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:io';
|
||||||
|
|
||||||
|
import '../framework/adb.dart';
|
||||||
|
import '../framework/framework.dart';
|
||||||
|
import '../framework/ios.dart';
|
||||||
|
import '../framework/utils.dart';
|
||||||
|
|
||||||
|
Future<TaskResult> samplePageCatalogGenerator() async {
|
||||||
|
final Device device = await devices.workingDevice;
|
||||||
|
await device.unlock();
|
||||||
|
final String deviceId = device.deviceId;
|
||||||
|
|
||||||
|
final Directory catalogDirectory = dir('${flutterDirectory.path}/examples/catalog');
|
||||||
|
await inDirectory(catalogDirectory, () async {
|
||||||
|
await flutter('packages', options: <String>['get']);
|
||||||
|
|
||||||
|
if (deviceOperatingSystem == DeviceOperatingSystem.ios) {
|
||||||
|
await prepareProvisioningCertificates(catalogDirectory.path);
|
||||||
|
// This causes an Xcode project to be created.
|
||||||
|
await flutter('build', options: <String>['ios', '--profile']);
|
||||||
|
}
|
||||||
|
|
||||||
|
await dart(<String>['bin/sample_page.dart']);
|
||||||
|
|
||||||
|
await flutter('drive', options: <String>[
|
||||||
|
'test_driver/screenshot.dart',
|
||||||
|
'-d',
|
||||||
|
deviceId,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new TaskResult.success(null);
|
||||||
|
}
|
@ -171,6 +171,13 @@ tasks:
|
|||||||
stage: devicelab
|
stage: devicelab
|
||||||
required_agent_capabilities: ["has-android-device"]
|
required_agent_capabilities: ["has-android-device"]
|
||||||
|
|
||||||
|
android_sample_catalog_generator:
|
||||||
|
description: >
|
||||||
|
Builds sample catalog markdown pages and Android screenshots
|
||||||
|
stage: devicelab
|
||||||
|
required_agent_capabilities: ["has-android-device"]
|
||||||
|
flaky: true
|
||||||
|
|
||||||
# iOS on-device tests
|
# iOS on-device tests
|
||||||
|
|
||||||
channels_integration_test_ios:
|
channels_integration_test_ios:
|
||||||
@ -240,6 +247,13 @@ tasks:
|
|||||||
stage: devicelab_ios
|
stage: devicelab_ios
|
||||||
required_agent_capabilities: ["has-ios-device"]
|
required_agent_capabilities: ["has-ios-device"]
|
||||||
|
|
||||||
|
ios_sample_catalog_generator:
|
||||||
|
description: >
|
||||||
|
Builds sample catalog markdown pages and iOS screenshots
|
||||||
|
stage: devicelab_ios
|
||||||
|
required_agent_capabilities: ["has-ios-device"]
|
||||||
|
flaky: true
|
||||||
|
|
||||||
# Tests running on Windows host
|
# Tests running on Windows host
|
||||||
|
|
||||||
channels_integration_test_win:
|
channels_integration_test_win:
|
||||||
|
@ -135,6 +135,8 @@ class SampleGenerator {
|
|||||||
);
|
);
|
||||||
commentValues[keyword.toLowerCase()] = value.trim();
|
commentValues[keyword.toLowerCase()] = value.trim();
|
||||||
}
|
}
|
||||||
|
commentValues['name'] = sourceName;
|
||||||
|
commentValues['path'] = 'examples/catalog/${sourceFile.path}';
|
||||||
commentValues['source'] = sourceCode.trim();
|
commentValues['source'] = sourceCode.trim();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -177,14 +179,12 @@ void generate() {
|
|||||||
screenshotDriverTemplate,
|
screenshotDriverTemplate,
|
||||||
<String, String>{
|
<String, String>{
|
||||||
'paths': samples.map((SampleGenerator sample) {
|
'paths': samples.map((SampleGenerator sample) {
|
||||||
return "'${outputFile(sample.sourceName + '.png').path}'";
|
return "'${outputFile('\${prefix}' + sample.sourceName + '.png').path}'";
|
||||||
}).toList().join(',\n'),
|
}).toList().join(',\n'),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
final List<String> flutterDriveArgs = <String>['drive', 'test_driver/screenshot.dart'];
|
// To generate the screenshots: flutter drive test_driver/screenshot.dart
|
||||||
logMessage('Generating screenshots with: flutter ${flutterDriveArgs.join(" ")}');
|
|
||||||
Process.runSync('flutter', flutterDriveArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(List<String> args) {
|
void main(List<String> args) {
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
@(title)
|
---
|
||||||
=============
|
catalog: @(name)
|
||||||
|
title: "@(title)"
|
||||||
|
|
||||||
|
permalink: /catalog/@(name)/
|
||||||
|
---
|
||||||
|
|
||||||
@(summary)
|
@(summary)
|
||||||
|
|
||||||
@ -8,6 +12,7 @@
|
|||||||
See also:
|
See also:
|
||||||
@(see also)
|
@(see also)
|
||||||
|
|
||||||
```
|
```dart
|
||||||
@(source)
|
@(source)
|
||||||
```
|
```
|
||||||
|
The source code is based on [@(path)](https://github.com/flutter/flutter/blob/master/@(path)).
|
||||||
|
@ -36,5 +36,6 @@ class SampleScreenshotsState extends State<SampleScreenshots> {
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
enableFlutterDriverExtension();
|
enableFlutterDriverExtension();
|
||||||
|
WidgetsApp.debugAllowBannerOverride = false; // No "slow mode" banner.
|
||||||
runApp(new SampleScreenshots());
|
runApp(new SampleScreenshots());
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import 'package:flutter_driver/flutter_driver.dart';
|
|||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('sample screenshots', () async {
|
group('sample screenshots', () {
|
||||||
FlutterDriver driver;
|
FlutterDriver driver;
|
||||||
|
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
@ -19,6 +19,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('take sample screenshots', () async {
|
test('take sample screenshots', () async {
|
||||||
|
String prefix = Platform.isMacOS ? 'ios_' : "";
|
||||||
final List<String> paths = <String>[
|
final List<String> paths = <String>[
|
||||||
@(paths)
|
@(paths)
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user