fuchsia_workflow_test.dart 3.53 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:file/memory.dart';
6
import 'package:flutter_tools/src/base/file_system.dart';
7
import 'package:flutter_tools/src/base/platform.dart';
8
import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
9 10
import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart';

11
import '../../src/common.dart';
12
import '../../src/fakes.dart';
13 14

void main() {
15 16
  final FileSystem fileSystem = MemoryFileSystem.test();
  final File sshConfig = fileSystem.file('ssh_config');
17
  final File ffx = fileSystem.file('ffx');
18 19 20

  testWithoutContext('Fuchsia workflow does not apply to host platform if feature is disabled', () {
    final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow(
21
      featureFlags: TestFeatureFlags(),
22
      fuchsiaArtifacts: FuchsiaArtifacts(ffx: ffx, sshConfig: sshConfig),
23
      platform: FakePlatform(),
24 25 26 27 28 29 30 31
    );

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

  testWithoutContext('Fuchsia workflow does not apply to host platform on Windows', () {
    final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow(
      featureFlags: TestFeatureFlags(isFuchsiaEnabled: true),
32
      fuchsiaArtifacts: FuchsiaArtifacts(ffx: ffx, sshConfig: sshConfig),
33 34 35 36 37 38
      platform: FakePlatform(operatingSystem: 'windows'),
    );

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

39
  testWithoutContext('Fuchsia workflow can not list and launch devices if there is no ffx when using default workflow', () {
40 41
    final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow(
      featureFlags: TestFeatureFlags(),
42
      fuchsiaArtifacts: FuchsiaArtifacts(sshConfig: sshConfig),
43
      platform: FakePlatform(environment: <String, String>{}),
44 45 46 47 48 49 50
    );

    expect(fuchsiaWorkflow.canLaunchDevices, false);
    expect(fuchsiaWorkflow.canListDevices, false);
    expect(fuchsiaWorkflow.canListEmulators, false);
  });

51 52 53
  testWithoutContext('Fuchsia workflow can not launch devices if there is no ssh config when using default workflow', () {
    final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow(
      featureFlags: TestFeatureFlags(),
54 55
      fuchsiaArtifacts: FuchsiaArtifacts(ffx: ffx),
      platform: FakePlatform(environment: <String, String>{}),
56 57 58 59 60 61 62
    );

    expect(fuchsiaWorkflow.canLaunchDevices, false);
    expect(fuchsiaWorkflow.canListDevices, true);
    expect(fuchsiaWorkflow.canListEmulators, false);
  });

63 64 65
  testWithoutContext('Fuchsia workflow can list and launch devices supported with sufficient SDK artifacts when using default workflow', () {
    final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow(
      featureFlags: TestFeatureFlags(),
66 67
      fuchsiaArtifacts: FuchsiaArtifacts(sshConfig: sshConfig, ffx: ffx),
      platform: FakePlatform(environment: <String, String>{}),
68 69 70 71 72 73 74
    );

    expect(fuchsiaWorkflow.canLaunchDevices, true);
    expect(fuchsiaWorkflow.canListDevices, true);
    expect(fuchsiaWorkflow.canListEmulators, false);
  });

75 76 77
  testWithoutContext('Fuchsia workflow can list and launch devices supported with sufficient SDK artifacts on macOS', () {
    final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow(
      featureFlags: TestFeatureFlags(),
78
      fuchsiaArtifacts: FuchsiaArtifacts(sshConfig: sshConfig, ffx: ffx),
79
      platform: FakePlatform(operatingSystem: 'macOS', environment: <String, String>{}),
80 81 82 83 84
    );

    expect(fuchsiaWorkflow.canLaunchDevices, true);
    expect(fuchsiaWorkflow.canListDevices, true);
    expect(fuchsiaWorkflow.canListEmulators, false);
85 86
  });
}