| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library watcher.test.utils; | 5 library watcher.test.utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 void initConfig() { | 39 void initConfig() { |
| 40 useCompactVMConfiguration(); | 40 useCompactVMConfiguration(); |
| 41 filterStacks = true; | 41 filterStacks = true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 /// Creates the sandbox directory the other functions in this library use and | 44 /// Creates the sandbox directory the other functions in this library use and |
| 45 /// ensures it's deleted when the test ends. | 45 /// ensures it's deleted when the test ends. |
| 46 /// | 46 /// |
| 47 /// This should usually be called by [setUp]. | 47 /// This should usually be called by [setUp]. |
| 48 void createSandbox() { | 48 void createSandbox() { |
| 49 var dir = new Directory("").createTempSync(); | 49 var dir = Directory.systemTemp.createTempSync('watcher_test_'); |
| 50 _sandboxDir = dir.path; | 50 _sandboxDir = dir.path; |
| 51 | 51 |
| 52 _mockFileModificationTimes = new Map<String, int>(); | 52 _mockFileModificationTimes = new Map<String, int>(); |
| 53 mockGetModificationTime((path) { | 53 mockGetModificationTime((path) { |
| 54 path = p.normalize(p.relative(path, from: _sandboxDir)); | 54 path = p.normalize(p.relative(path, from: _sandboxDir)); |
| 55 | 55 |
| 56 // Make sure we got a path in the sandbox. | 56 // Make sure we got a path in the sandbox. |
| 57 assert(p.isRelative(path) && !path.startsWith("..")); | 57 assert(p.isRelative(path) && !path.startsWith("..")); |
| 58 | 58 |
| 59 return new DateTime.fromMillisecondsSinceEpoch( | 59 return new DateTime.fromMillisecondsSinceEpoch( |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 Description describe(Description description) { | 221 Description describe(Description description) { |
| 222 description.add("$type $path"); | 222 description.add("$type $path"); |
| 223 } | 223 } |
| 224 | 224 |
| 225 bool matches(item, Map matchState) => | 225 bool matches(item, Map matchState) => |
| 226 item is WatchEvent && | 226 item is WatchEvent && |
| 227 item.type == type && | 227 item.type == type && |
| 228 p.normalize(item.path) == p.normalize(path); | 228 p.normalize(item.path) == p.normalize(path); |
| 229 } | 229 } |
| OLD | NEW |