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

5
import 'package:flutter_devicelab/framework/devices.dart';
6
import 'package:flutter_devicelab/framework/framework.dart';
7
import 'package:flutter_devicelab/framework/task_result.dart';
8
import 'package:flutter_devicelab/framework/utils.dart';
9
import 'package:flutter_devicelab/tasks/integration_tests.dart';
10
import 'package:path/path.dart' as path;
11

12
Future<void> main() async {
13
  deviceOperatingSystem = DeviceOperatingSystem.android;
14 15 16
  await task(() async {
    await createFlavorsTest().call();
    await createIntegrationTestFlavorsTest().call();
17

18 19 20 21 22 23 24 25 26 27 28
    final TaskResult installTestsResult = await inDirectory(
      '${flutterDirectory.path}/dev/integration_tests/flavors',
      () async {
        await flutter(
          'install',
          options: <String>['--debug', '--flavor', 'paid'],
        );
        await flutter(
          'install',
          options: <String>['--debug', '--flavor', 'paid', '--uninstall-only'],
        );
29

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
        final StringBuffer stderr = StringBuffer();
        await evalFlutter(
          'install',
          canFail: true,
          stderr: stderr,
          options: <String>['--flavor', 'bogus'],
        );

        final String stderrString = stderr.toString();
        final String expectedApkPath = path.join('build', 'app', 'outputs', 'flutter-apk', 'app-bogus-release.apk');
        if (!stderrString.contains('"$expectedApkPath" does not exist.')) {
          print(stderrString);
          return TaskResult.failure('Should not succeed with bogus flavor');
        }

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

    return installTestsResult;
50
  });
51
}