utils.dart 1.18 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter_tools/src/cache.dart';
8
import 'package:flutter_tools/src/reporting/reporting.dart';
9 10 11 12 13 14 15 16
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:mockito/mockito.dart';

typedef CommandFunction = Future<FlutterCommandResult> Function();

class DummyFlutterCommand extends FlutterCommand {

  DummyFlutterCommand({
17
    this.shouldUpdateCache = false,
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
    this.noUsagePath  = false,
    this.commandFunction,
  });

  final bool noUsagePath;
  final CommandFunction commandFunction;

  @override
  final bool shouldUpdateCache;

  @override
  String get description => 'does nothing';

  @override
  Future<String> get usagePath => noUsagePath ? null : super.usagePath;

  @override
  String get name => 'dummy';

  @override
  Future<FlutterCommandResult> runCommand() async {
39
    return commandFunction == null ? FlutterCommandResult.fail() : await commandFunction();
40 41 42 43 44 45
  }
}

class MockitoCache extends Mock implements Cache {}

class MockitoUsage extends Mock implements Usage {}