windows_workflow_test.dart 2.05 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
import 'package:flutter_tools/src/features.dart';
7
import 'package:flutter_tools/src/windows/windows_workflow.dart';
8
import 'package:mockito/mockito.dart';
9

10 11
import '../../src/common.dart';
import '../../src/context.dart';
12
import '../../src/testbed.dart';
13 14

void main() {
15 16 17 18 19 20 21
  Testbed testbed;
  MockPlatform windows;
  MockPlatform notWindows;

  setUp(() {
    windows = MockPlatform();
    notWindows = MockPlatform();
22 23
    when(windows.isWindows).thenReturn(true);
    when(notWindows.isWindows).thenReturn(false);
24 25 26 27
    testbed = Testbed(
      overrides: <Type, Generator>{
        Platform: () => windows,
        FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
28
      },
29
    );
30
  });
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

  test('Windows default workflow values', () => testbed.run(() {
    expect(windowsWorkflow.appliesToHostPlatform, true);
    expect(windowsWorkflow.canListDevices, true);
    expect(windowsWorkflow.canLaunchDevices, true);
    expect(windowsWorkflow.canListEmulators, false);
  }));

  test('Windows defaults on non-windows platform', () => testbed.run(() {
    expect(windowsWorkflow.appliesToHostPlatform, false);
    expect(windowsWorkflow.canListDevices, false);
    expect(windowsWorkflow.canLaunchDevices, false);
    expect(windowsWorkflow.canListEmulators, false);
  }, overrides: <Type, Generator>{
    Platform: () => notWindows,
  }));

  test('Windows defaults on non-windows platform', () => testbed.run(() {
    expect(windowsWorkflow.appliesToHostPlatform, false);
    expect(windowsWorkflow.canListDevices, false);
    expect(windowsWorkflow.canLaunchDevices, false);
    expect(windowsWorkflow.canListEmulators, false);
  }, overrides: <Type, Generator>{
    FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: false),
  }));
56 57 58 59
}

class MockPlatform extends Mock implements Platform {
  @override
60
  final Map<String, String> environment = <String, String>{};
61
}