Ian Hickson | 449f4a6 | 2019-11-27 15:04:02 -0800 | [diff] [blame] | 1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
Ian Hickson | 686d8f8 | 2018-08-14 20:33:58 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Ian Hickson | 3dec6a6 | 2018-08-17 13:17:23 -0700 | [diff] [blame] | 5 | import 'dart:io'; |
| 6 | |
Dan Field | 8b29933 | 2020-01-27 14:36:02 -0800 | [diff] [blame] | 7 | import 'package:flutter_driver/src/common/error.dart'; |
Jonah Williams | e77c24e | 2019-11-14 09:31:36 -0800 | [diff] [blame] | 8 | import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use |
| 9 | import 'package:test_api/test_api.dart' as test_package show TypeMatcher; // ignore: deprecated_member_use |
Ian Hickson | 686d8f8 | 2018-08-14 20:33:58 -0700 | [diff] [blame] | 10 | |
Jonah Williams | e77c24e | 2019-11-14 09:31:36 -0800 | [diff] [blame] | 11 | export 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use |
Ian Hickson | 686d8f8 | 2018-08-14 20:33:58 -0700 | [diff] [blame] | 12 | |
| 13 | // Defines a 'package:test' shim. |
Ian Hickson | 3dec6a6 | 2018-08-17 13:17:23 -0700 | [diff] [blame] | 14 | // TODO(ianh): Clean this up once https://github.com/dart-lang/matcher/issues/98 is fixed |
Ian Hickson | 686d8f8 | 2018-08-14 20:33:58 -0700 | [diff] [blame] | 15 | |
| 16 | /// A matcher that compares the type of the actual value to the type argument T. |
Dan Field | 8b29933 | 2020-01-27 14:36:02 -0800 | [diff] [blame] | 17 | test_package.TypeMatcher<T> isInstanceOf<T>() => isA<T>(); |
Ian Hickson | 3dec6a6 | 2018-08-17 13:17:23 -0700 | [diff] [blame] | 18 | |
| 19 | void 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 Ardhuin | 32d65fe | 2018-12-18 10:05:12 +0100 | [diff] [blame] | 28 | } |
Dan Field | 8b29933 | 2020-01-27 14:36:02 -0800 | [diff] [blame] | 29 | |
| 30 | /// Matcher for functions that throw [DriverError]. |
| 31 | final Matcher throwsDriverError = throwsA(isA<DriverError>()); |