integration_tests.dart 4.38 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../framework/adb.dart';
import '../framework/framework.dart';
7
import '../framework/task_result.dart';
8 9 10
import '../framework/utils.dart';

TaskFunction createChannelsIntegrationTest() {
11
  return DriverTest(
12 13 14 15 16
    '${flutterDirectory.path}/dev/integration_tests/channels',
    'lib/main.dart',
  );
}

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

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

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

39
TaskFunction createPlatformChannelSampleTest() {
40
  return DriverTest(
41 42 43 44 45
    '${flutterDirectory.path}/examples/platform_channel',
    'test_driver/button_tap.dart',
  );
}

46 47 48 49 50 51 52
TaskFunction createPlatformChannelSwiftSampleTest() {
  return DriverTest(
    '${flutterDirectory.path}/examples/platform_channel_swift',
    'test_driver/button_tap.dart',
  );
}

53
TaskFunction createEmbeddedAndroidViewsIntegrationTest() {
54
  return DriverTest(
55 56 57 58 59
    '${flutterDirectory.path}/dev/integration_tests/android_views',
    'lib/main.dart',
  );
}

60 61 62 63 64 65 66
TaskFunction createHybridAndroidViewsIntegrationTest() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/hybrid_android_views',
    'lib/main.dart',
  );
}

67
TaskFunction createAndroidSemanticsIntegrationTest() {
68
  return DriverTest(
69 70 71 72 73
    '${flutterDirectory.path}/dev/integration_tests/android_semantics_testing',
    'lib/main.dart',
  );
}

74 75 76 77 78 79 80
TaskFunction createCodegenerationIntegrationTest() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/codegen',
    'lib/main.dart',
  );
}

81 82 83 84 85 86 87
TaskFunction createImageLoadingIntegrationTest() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/image_loading',
    'lib/main.dart',
  );
}

88 89 90 91 92 93 94
TaskFunction createAndroidSplashScreenKitchenSinkTest() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/android_splash_screens/splash_screen_kitchen_sink',
    'test_driver/main.dart',
  );
}

95
TaskFunction createIOSPlatformViewTests() {
96
  return DriverTest(
97
    '${flutterDirectory.path}/dev/integration_tests/ios_platform_view_tests',
98 99 100 101
    'lib/main.dart',
  );
}

102
TaskFunction createEndToEndKeyboardTest() {
103
  return DriverTest(
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
    '${flutterDirectory.path}/dev/integration_tests/ui',
    'lib/keyboard_resize.dart',
  );
}

TaskFunction createEndToEndDriverTest() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/ui',
    'lib/driver.dart',
  );
}

TaskFunction createEndToEndScreenshotTest() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/ui',
    'lib/screenshot.dart',
  );
}

TaskFunction createEndToEndKeyboardTextfieldTest() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/ui',
    'lib/keyboard_textfield.dart',
127 128 129
  );
}

130 131 132 133 134 135 136 137 138 139
TaskFunction dartDefinesTask() {
  return DriverTest(
    '${flutterDirectory.path}/dev/integration_tests/ui',
    'lib/defines.dart', extraOptions: <String>[
    '--dart-define=test.valueA=Example',
    '--dart-define=test.valueB=Value',
    ],
  );
}

140
class DriverTest {
141 142 143 144
  DriverTest(
    this.testDirectory,
    this.testTarget, {
      this.extraOptions = const <String>[],
145
      this.environment =  const <String, String>{},
146 147
    }
  );
148 149 150

  final String testDirectory;
  final String testTarget;
151
  final List<String> extraOptions;
152
  final Map<String, String> environment;
153 154

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

161
      final List<String> options = <String>[
162
        '--no-android-gradle-daemon',
163 164 165 166 167
        '-v',
        '-t',
        testTarget,
        '-d',
        deviceId,
168
        ...extraOptions,
169
      ];
170
      await flutter('drive', options: options, environment: Map<String, String>.from(environment));
171

172
      return TaskResult.success(null);
173 174 175
    });
  }
}