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

import 'package:flutter_tools/src/test/coverage_collector.dart';
6
import 'package:vm_service/vm_service.dart' as vm_service;
7

8
import '../src/common.dart';
9 10

void main() {
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  testWithoutContext('Coverage collector Can handle coverage SentinelException', () async {
    final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(
      requests: <VmServiceExpectation>[
        FakeVmServiceRequest(
          method: 'getVM',
          jsonResponse: (vm_service.VM.parse(<String, Object>{})
            ..isolates = <vm_service.IsolateRef>[
              vm_service.IsolateRef.parse(<String, Object>{
                'id': '1'
              }),
            ]
          ).toJson(),
        ),
        const FakeVmServiceRequest(
          method: 'getScripts',
          args: <String, Object>{
            'isolateId': '1',
          },
          jsonResponse: <String, Object>{
            'type': 'Sentinel'
          }
        )
      ],
    );

    final Map<String, Object> result = await collect(
      null,
      (String predicate) => true,
      connector: (Uri uri) async {
        return fakeVmServiceHost.vmService;
      },
    );
43 44

    expect(result, <String, Object>{'type': 'CodeCoverage', 'coverage': <Object>[]});
45
    expect(fakeVmServiceHost.hasRemainingExpectations, false);
46 47
  });
}