sample_catalog_generator.dart 1.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// 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';
12 13
import 'save_catalog_screenshots.dart' show saveCatalogScreenshots;

14

15
Future<TaskResult> samplePageCatalogGenerator(String authorizationToken) async {
16 17 18 19 20
  final Device device = await devices.workingDevice;
  await device.unlock();
  final String deviceId = device.deviceId;

  final Directory catalogDirectory = dir('${flutterDirectory.path}/examples/catalog');
21
  await inDirectory<void>(catalogDirectory, () async {
22 23
    await flutter('packages', options: <String>['get']);

24 25
    final bool isIosDevice = deviceOperatingSystem == DeviceOperatingSystem.ios;
    if (isIosDevice)
26 27
      await prepareProvisioningCertificates(catalogDirectory.path);

28 29 30
    final String commit = await getCurrentFlutterRepoCommit();

    await dart(<String>['bin/sample_page.dart', commit]);
31 32

    await flutter('drive', options: <String>[
33
      '--target',
34
      'test_driver/screenshot.dart',
35
      '--device-id',
36 37
      deviceId,
    ]);
38

39 40
    await saveCatalogScreenshots(
      directory: dir('${flutterDirectory.path}/examples/catalog/.generated'),
41
      commit: commit,
42 43 44
      token: authorizationToken,
      prefix: isIosDevice ? 'ios_' : '',
    );
45 46
  });

47
  return TaskResult.success(null);
48
}