blob: e5987b02b12dc267a0571088a9a55d8ef475cdef [file] [log] [blame]
Ian Hickson449f4a62019-11-27 15:04:02 -08001// Copyright 2014 The Flutter Authors. All rights reserved.
Ian Hickson686d8f82018-08-14 20:33:58 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ian Hickson3dec6a62018-08-17 13:17:23 -07005import 'dart:io';
6
Dan Field8b299332020-01-27 14:36:02 -08007import 'package:flutter_driver/src/common/error.dart';
Jonah Williamse77c24e2019-11-14 09:31:36 -08008import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use
9import 'package:test_api/test_api.dart' as test_package show TypeMatcher; // ignore: deprecated_member_use
Ian Hickson686d8f82018-08-14 20:33:58 -070010
Jonah Williamse77c24e2019-11-14 09:31:36 -080011export 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use
Ian Hickson686d8f82018-08-14 20:33:58 -070012
13// Defines a 'package:test' shim.
Ian Hickson3dec6a62018-08-17 13:17:23 -070014// TODO(ianh): Clean this up once https://github.com/dart-lang/matcher/issues/98 is fixed
Ian Hickson686d8f82018-08-14 20:33:58 -070015
16/// A matcher that compares the type of the actual value to the type argument T.
Dan Field8b299332020-01-27 14:36:02 -080017test_package.TypeMatcher<T> isInstanceOf<T>() => isA<T>();
Ian Hickson3dec6a62018-08-17 13:17:23 -070018
19void tryToDelete(Directory directory) {
20 // This should not be necessary, but it turns out that
21 // on Windows it's common for deletions to fail due to
22 // bogus (we think) "access denied" errors.
23 try {
24 directory.deleteSync(recursive: true);
25 } on FileSystemException catch (error) {
26 print('Failed to delete ${directory.path}: $error');
27 }
Alexandre Ardhuin32d65fe2018-12-18 10:05:12 +010028}
Dan Field8b299332020-01-27 14:36:02 -080029
30/// Matcher for functions that throw [DriverError].
31final Matcher throwsDriverError = throwsA(isA<DriverError>());