Files
packages/script/tool/test/mocks.dart
stuartmorgan b98034dd76 [flutter_plugin_tools] Migrate more commands to NNBD (#4026)
Migrates:
- `all_plugins_app`
- `podspecs`
- `firebase-test-lab`

Minor functional changes to `firebase-test-lab` based on issues highlighted by the migration:
- The build ID used in the path is now a) passable, and b) given a fallback value in the path that
  isn't "null"
- Flag setup will no longer assume that `$HOME` must be set in the environment.
- Adds a --build-id flag to `firebase-test-lab` instead of hard-coding the use of  `CIRRUS_BUILD_ID`.
  The default is still `CIRRUS_BUILD_ID` so no CI changes are needed.

Part of https://github.com/flutter/flutter/issues/81912
2021-06-09 11:00:04 -07:00

49 lines
1.2 KiB
Dart

// Copyright 2013 The Flutter 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 'dart:async';
import 'dart:io' as io;
import 'package:file/file.dart';
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
class MockPlatform extends Mock implements Platform {
MockPlatform({this.isMacOS = false});
@override
bool isMacOS;
}
class MockProcess extends Mock implements io.Process {
final Completer<int> exitCodeCompleter = Completer<int>();
final StreamController<List<int>> stdoutController =
StreamController<List<int>>();
final StreamController<List<int>> stderrController =
StreamController<List<int>>();
final MockIOSink stdinMock = MockIOSink();
@override
int get pid => 99;
@override
Future<int> get exitCode => exitCodeCompleter.future;
@override
Stream<List<int>> get stdout => stdoutController.stream;
@override
Stream<List<int>> get stderr => stderrController.stream;
@override
IOSink get stdin => stdinMock;
}
class MockIOSink extends Mock implements IOSink {
List<String> lines = <String>[];
@override
void writeln([Object? obj = '']) => lines.add(obj.toString());
}