ios_workflow_test.dart 2.79 KB
Newer Older
1 2 3 4
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// @dart = 2.8

7 8
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/ios/ios_workflow.dart';
9
import 'package:flutter_tools/src/ios/xcodeproj.dart';
10 11 12
import 'package:flutter_tools/src/macos/xcode.dart';

import '../../src/common.dart';
13
import '../../src/context.dart';
14 15 16 17 18 19
import '../../src/testbed.dart';

void main() {
  testWithoutContext('iOS workflow is disabled if feature is disabled', () {
    final IOSWorkflow iosWorkflow = IOSWorkflow(
      platform: FakePlatform(operatingSystem: 'macOS'),
20
      xcode: Xcode.test(processManager: FakeProcessManager.any()),
21 22 23 24 25 26 27 28 29
      featureFlags: TestFeatureFlags(isIOSEnabled: false),
    );

    expect(iosWorkflow.appliesToHostPlatform, false);
  });

  testWithoutContext('iOS workflow is disabled on Linux', () {
    final IOSWorkflow iosWorkflow = IOSWorkflow(
      platform: FakePlatform(operatingSystem: 'linux'),
30
      xcode: Xcode.test(processManager: FakeProcessManager.any()),
31 32 33 34 35 36 37 38 39
      featureFlags: TestFeatureFlags(isIOSEnabled: true),
    );

    expect(iosWorkflow.appliesToHostPlatform, false);
  });

  testWithoutContext('iOS workflow is disabled on windows', () {
    final IOSWorkflow iosWorkflow = IOSWorkflow(
      platform: FakePlatform(operatingSystem: 'windows'),
40
      xcode: Xcode.test(processManager: FakeProcessManager.any()),
41 42 43 44 45 46 47 48 49
      featureFlags: TestFeatureFlags(isIOSEnabled: true),
    );

    expect(iosWorkflow.appliesToHostPlatform, false);
  });

  testWithoutContext('iOS workflow is enabled on macOS', () {
    final IOSWorkflow iosWorkflow = IOSWorkflow(
      platform: FakePlatform(operatingSystem: 'macos'),
50
      xcode: Xcode.test(processManager: FakeProcessManager.any()),
51 52 53 54 55 56 57 58
      featureFlags: TestFeatureFlags(isIOSEnabled: true),
    );

    expect(iosWorkflow.appliesToHostPlatform, true);
    expect(iosWorkflow.canListEmulators, false);
  });

  testWithoutContext('iOS workflow can launch and list devices when Xcode is set up', () {
59 60 61 62 63 64 65 66 67 68
    final Xcode xcode = Xcode.test(
      processManager: FakeProcessManager.any(),
      xcodeProjectInterpreter: XcodeProjectInterpreter.test(
        processManager: FakeProcessManager.any(),
        majorVersion: 1000,
        minorVersion: 0,
        patchVersion: 0,
      ),
    );

69 70 71 72 73 74
    final IOSWorkflow iosWorkflow = IOSWorkflow(
      platform: FakePlatform(operatingSystem: 'macos'),
      xcode: xcode,
      featureFlags: TestFeatureFlags(isIOSEnabled: true),
    );

75 76 77
    // Make sure we're testing the right Xcode state.
    expect(xcode.isInstalledAndMeetsVersionCheck, true);
    expect(xcode.isSimctlInstalled, true);
78 79 80 81
    expect(iosWorkflow.canLaunchDevices, true);
    expect(iosWorkflow.canListDevices, true);
  });
}