1// Copyright 2017 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5import 'dart:async'; 6 7import 'package:flutter_tools/src/cache.dart'; 8import 'package:flutter_tools/src/reporting/reporting.dart'; 9import 'package:flutter_tools/src/runner/flutter_command.dart'; 10import 'package:mockito/mockito.dart'; 11 12typedef CommandFunction = Future<FlutterCommandResult> Function(); 13 14class DummyFlutterCommand extends FlutterCommand { 15 16 DummyFlutterCommand({ 17 this.shouldUpdateCache = false, 18 this.noUsagePath = false, 19 this.commandFunction, 20 }); 21 22 final bool noUsagePath; 23 final CommandFunction commandFunction; 24 25 @override 26 final bool shouldUpdateCache; 27 28 @override 29 String get description => 'does nothing'; 30 31 @override 32 Future<String> get usagePath => noUsagePath ? null : super.usagePath; 33 34 @override 35 String get name => 'dummy'; 36 37 @override 38 Future<FlutterCommandResult> runCommand() async { 39 return commandFunction == null ? null : await commandFunction(); 40 } 41} 42 43class MockitoCache extends Mock implements Cache {} 44 45class MockitoUsage extends Mock implements Usage {} 46