common.dart 1.19 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
import 'package:test_api/test_api.dart'; // ignore: deprecated_member_use
9

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

/// A matcher that compares the type of the actual value to the type argument T.
14
TypeMatcher<T> isInstanceOf<T>() => isA<T>();
15 16 17 18 19 20 21 22

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) {
23
    driverLog('test', 'Failed to delete ${directory.path}: $error');
24
  }
25
}
Dan Field's avatar
Dan Field committed
26 27 28

/// Matcher for functions that throw [DriverError].
final Matcher throwsDriverError = throwsA(isA<DriverError>());
29 30 31

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