fuchsia_reload_test.dart 1.44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
// 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:convert';
import 'dart:io';

import 'package:flutter_tools/src/commands/fuchsia_reload.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';

13
import '../src/common.dart';
14 15 16 17 18 19
import '../src/context.dart';

void main() {
  group('FuchsiaDeviceCommandRunner', () {
    testUsingContext('a test', () async {
      final FuchsiaDeviceCommandRunner commandRunner =
20
          FuchsiaDeviceCommandRunner('8.8.9.9',
21
                                         '~/fuchsia/out/release-x86-64');
22 23 24 25 26 27
      final List<String> ports = await commandRunner.run('ls /tmp');
      expect(ports, hasLength(3));
      expect(ports[0], equals('1234'));
      expect(ports[1], equals('5678'));
      expect(ports[2], equals('5'));
    }, overrides: <Type, Generator>{
28
      ProcessManager: () => MockProcessManager(),
29 30 31 32 33 34 35 36 37 38
    });
  });
}

class MockProcessManager extends Mock implements ProcessManager {
  @override
  Future<ProcessResult> run(
    List<dynamic> command, {
    String workingDirectory,
    Map<String, String> environment,
39 40
    bool includeParentEnvironment = true,
    bool runInShell = false,
41 42
    Encoding stdoutEncoding = systemEncoding,
    Encoding stderrEncoding = systemEncoding,
43
  }) async {
44
    return ProcessResult(0, 0, '1234\n5678\n5', '');
45 46
  }
}