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

5 6
import 'dart:io';

Dan Field's avatar
Dan Field committed
7
import 'package:flutter_driver/src/common/error.dart';
8 9
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use
import 'package:test_api/test_api.dart' as test_package show TypeMatcher; // ignore: deprecated_member_use
10

11
export 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use
12
export 'package:test_api/fake.dart'; // ignore: deprecated_member_use
13 14

// Defines a 'package:test' shim.
15
// TODO(ianh): Clean this up once https://github.com/dart-lang/matcher/issues/98 is fixed
16 17

/// A matcher that compares the type of the actual value to the type argument T.
Dan Field's avatar
Dan Field committed
18
test_package.TypeMatcher<T> isInstanceOf<T>() => isA<T>();
19 20 21 22 23 24 25 26 27 28

void tryToDelete(Directory directory) {
  // This should not be necessary, but it turns out that
  // on Windows it's common for deletions to fail due to
  // bogus (we think) "access denied" errors.
  try {
    directory.deleteSync(recursive: true);
  } on FileSystemException catch (error) {
    print('Failed to delete ${directory.path}: $error');
  }
29
}
Dan Field's avatar
Dan Field committed
30 31 32

/// Matcher for functions that throw [DriverError].
final Matcher throwsDriverError = throwsA(isA<DriverError>());
33 34 35

/// Matcher for functions that throw [AssertionError].
final Matcher throwsAssertionError = throwsA(isA<AssertionError>());