windows_workflow_test.dart 1.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:mockito/mockito.dart';

import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/windows/windows_workflow.dart';

import '../src/common.dart';
import '../src/context.dart';

void main() {
  group(WindowsWorkflow, () {
    final MockPlatform windows = MockPlatform();
16
    final MockPlatform windowsWithFde = MockPlatform()
17
      ..environment['ENABLE_FLUTTER_DESKTOP'] = 'true';
18 19
    final MockPlatform notWindows = MockPlatform();
    when(windows.isWindows).thenReturn(true);
20
    when(windowsWithFde.isWindows).thenReturn(true);
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
    when(notWindows.isWindows).thenReturn(false);

    testUsingContext('Applies to windows platform', () {
      expect(windowsWorkflow.appliesToHostPlatform, true);
    }, overrides: <Type, Generator>{
      Platform: () => windows,
    });
    testUsingContext('Does not apply to non-windows platform', () {
      expect(windowsWorkflow.appliesToHostPlatform, false);
    }, overrides: <Type, Generator>{
      Platform: () => notWindows,
    });

    testUsingContext('defaults', () {
      expect(windowsWorkflow.canListEmulators, false);
      expect(windowsWorkflow.canLaunchDevices, true);
      expect(windowsWorkflow.canListDevices, true);
    }, overrides: <Type, Generator>{
39
      Platform: () => windowsWithFde,
40 41 42 43 44 45
    });
  });
}

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