integration_tests.dart 2.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// Copyright (c) 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 '../framework/adb.dart';
import '../framework/framework.dart';
import '../framework/ios.dart';
import '../framework/utils.dart';

TaskFunction createChannelsIntegrationTest() {
  return new DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/channels',
    'lib/main.dart',
  );
}

19 20 21 22 23 24 25
TaskFunction createPlatformInteractionTest() {
  return new DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/platform_interaction',
    'lib/main.dart',
  );
}

26 27 28 29 30 31 32 33
TaskFunction createFlavorsTest() {
  return new DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/flavors',
    'lib/main.dart',
    extraOptions: <String>['--flavor', 'paid']
  );
}

34 35 36 37 38 39 40
TaskFunction createExternalUiIntegrationTest() {
  return new DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/external_ui',
    'lib/main.dart',
  );
}

41 42 43 44 45 46 47 48 49
TaskFunction createPlatformChannelSampleTest() {
  return new DriverTest(
    '${flutterDirectory.path}/examples/platform_channel',
    'test_driver/button_tap.dart',
  );
}

class DriverTest {

50 51 52 53 54 55
  DriverTest(
    this.testDirectory,
    this.testTarget, {
      this.extraOptions = const <String>[],
    }
  );
56 57 58

  final String testDirectory;
  final String testTarget;
59
  final List<String> extraOptions;
60 61 62 63 64 65 66 67

  Future<TaskResult> call() {
    return inDirectory(testDirectory, () async {
      final Device device = await devices.workingDevice;
      await device.unlock();
      final String deviceId = device.deviceId;
      await flutter('packages', options: <String>['get']);

68
      if (deviceOperatingSystem == DeviceOperatingSystem.ios)
69
        await prepareProvisioningCertificates(testDirectory);
70
      final List<String> options = <String>[
71 72 73 74 75
        '-v',
        '-t',
        testTarget,
        '-d',
        deviceId,
76 77 78
      ];
      options.addAll(extraOptions);
      await flutter('drive', options: options);
79 80 81 82 83

      return new TaskResult.success(null);
    });
  }
}