windows_workflow_test.dart 2.35 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_tools/src/base/platform.dart';
6 7
import 'package:flutter_tools/src/windows/windows_workflow.dart';

8
import '../../src/common.dart';
9
import '../../src/fakes.dart';
10 11

void main() {
12
  final FakePlatform windows = FakePlatform(operatingSystem: 'windows');
13
  final FakePlatform notWindows = FakePlatform();
14 15 16 17 18

  testWithoutContext('Windows workflow configuration when feature is enabled on Windows host machine', () {
    final WindowsWorkflow windowsWorkflow = WindowsWorkflow(
      platform: windows,
      featureFlags: TestFeatureFlags(isWindowsEnabled: true),
19 20 21 22 23 24
    );

    expect(windowsWorkflow.appliesToHostPlatform, true);
    expect(windowsWorkflow.canListDevices, true);
    expect(windowsWorkflow.canLaunchDevices, true);
    expect(windowsWorkflow.canListEmulators, false);
25 26 27 28 29
  });

  testWithoutContext('Windows workflow configuration when feature is disabled on Windows host machine', () {
    final WindowsWorkflow windowsWorkflow = WindowsWorkflow(
      platform: windows,
30
      featureFlags: TestFeatureFlags(),
31
    );
32 33 34 35 36

    expect(windowsWorkflow.appliesToHostPlatform, false);
    expect(windowsWorkflow.canListDevices, false);
    expect(windowsWorkflow.canLaunchDevices, false);
    expect(windowsWorkflow.canListEmulators, false);
37 38 39 40 41 42 43
  });

  testWithoutContext('Windows workflow configuration when feature is enabled on non-Windows host machine', () {
    final WindowsWorkflow windowsWorkflow = WindowsWorkflow(
      platform: notWindows,
      featureFlags: TestFeatureFlags(isWindowsEnabled: true),
    );
44 45 46 47 48

    expect(windowsWorkflow.appliesToHostPlatform, false);
    expect(windowsWorkflow.canListDevices, false);
    expect(windowsWorkflow.canLaunchDevices, false);
    expect(windowsWorkflow.canListEmulators, false);
49 50 51 52 53
  });

  testWithoutContext('Windows workflow configuration when feature is disabled on non-Windows host machine', () {
    final WindowsWorkflow windowsWorkflow = WindowsWorkflow(
      platform: notWindows,
54
      featureFlags: TestFeatureFlags(),
55 56 57 58 59 60 61
    );

    expect(windowsWorkflow.appliesToHostPlatform, false);
    expect(windowsWorkflow.canListDevices, false);
    expect(windowsWorkflow.canLaunchDevices, false);
    expect(windowsWorkflow.canListEmulators, false);
  });
62
}