flutter/packages/flutter_tools/test/base/io_test.dart
Alan Russian 30720bd148 Change async stubbing to use thenAnswer. (#13521)
* Change async stubbing to use thenAnswer.

Mockito now prohibits calling thenReturn with Futures and Streams. dart-lang/mockito#79

* Update all Mockito deps to 3.0.0.

* Revert "Update all Mockito deps to 3.0.0."

This reverts commit e8ab9d37c3.

I did not correctly update the mockito dep, and there's no easy way to update to 3.0 alpha right now.

* Change thenAnswer((_) => to thenAnswer((invocation) =>

* Add Invocation type to thenAnswer lambdas
2017-12-19 13:13:57 -08:00

35 lines
1.1 KiB
Dart

// Copyright 2017 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 'dart:async';
import 'dart:io' as io;
import 'package:flutter_tools/src/base/io.dart';
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
import '../src/context.dart';
void main() {
group('ProcessSignal', () {
testUsingContext('signals are properly delegated', () async {
final MockIoProcessSignal mockSignal = new MockIoProcessSignal();
final ProcessSignal signalUnderTest = new ProcessSignal(mockSignal);
final StreamController<io.ProcessSignal> controller = new StreamController<io.ProcessSignal>();
when(mockSignal.watch()).thenAnswer((Invocation invocation) => controller.stream);
controller.add(mockSignal);
expect(signalUnderTest, await signalUnderTest.watch().first);
});
testUsingContext('toString() works', () async {
expect(io.ProcessSignal.SIGINT.toString(), ProcessSignal.SIGINT.toString());
});
});
}
class MockIoProcessSignal extends Mock implements io.ProcessSignal {}