Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: tests/standalone/io/windows_file_system_async_links_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:async"; 5 import "dart:async";
6 import "dart:io"; 6 import "dart:io";
7 7
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
11
12 class FutureExpect { 11 class FutureExpect {
13 static Future isTrue(Future<bool> result) => 12 static Future isTrue(Future<bool> result) =>
14 result.then((value) => Expect.isTrue(value)); 13 result.then((value) => Expect.isTrue(value));
15 static Future isFalse(Future<bool> result) => 14 static Future isFalse(Future<bool> result) =>
16 result.then((value) => Expect.isFalse(value)); 15 result.then((value) => Expect.isFalse(value));
17 static Future equals(expected, Future result) => 16 static Future equals(expected, Future result) =>
18 result.then((value) => Expect.equals(expected, value)); 17 result.then((value) => Expect.equals(expected, value));
19 static Future listEquals(expected, Future result) => 18 static Future listEquals(expected, Future result) =>
20 result.then((value) => Expect.listEquals(expected, value)); 19 result.then((value) => Expect.listEquals(expected, value));
21 static Future throws(Future result) => 20 static Future throws(Future result) => result.then((value) {
22 result.then((value) {
23 throw new ExpectException( 21 throw new ExpectException(
24 "FutureExpect.throws received $value instead of an exception"); 22 "FutureExpect.throws received $value instead of an exception");
25 }, onError: (_) => null); 23 }, onError: (_) => null);
26 } 24 }
27 25
28
29 Future testJunctionTypeDelete() { 26 Future testJunctionTypeDelete() {
30 return Directory.systemTemp 27 return Directory.systemTemp
31 .createTemp('dart_windows_file_system_async_links') 28 .createTemp('dart_windows_file_system_async_links')
32 .then((temp) { 29 .then((temp) {
33 var x = '${temp.path}${Platform.pathSeparator}x'; 30 var x = '${temp.path}${Platform.pathSeparator}x';
34 var y = '${temp.path}${Platform.pathSeparator}y'; 31 var y = '${temp.path}${Platform.pathSeparator}y';
35 return new Directory(x).create() 32 return new Directory(x)
36 .then((_) => new Link(y).create(x)) 33 .create()
37 .then((_) => FutureExpect.isTrue(new Directory(y).exists())) 34 .then((_) => new Link(y).create(x))
38 .then((_) => FutureExpect.isTrue(new Directory(x).exists())) 35 .then((_) => FutureExpect.isTrue(new Directory(y).exists()))
39 .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y))) 36 .then((_) => FutureExpect.isTrue(new Directory(x).exists()))
40 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x))) 37 .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y)))
41 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(y))) 38 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x)))
42 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(x))) 39 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(y)))
43 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY, 40 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(x)))
44 FileSystemEntity.type(y))) 41 .then((_) => FutureExpect.equals(
45 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY, 42 FileSystemEntityType.DIRECTORY, FileSystemEntity.type(y)))
46 FileSystemEntity.type(x))) 43 .then((_) => FutureExpect.equals(
47 .then((_) => FutureExpect.equals(FileSystemEntityType.LINK, 44 FileSystemEntityType.DIRECTORY, FileSystemEntity.type(x)))
48 FileSystemEntity.type(y, followLinks: false))) 45 .then((_) => FutureExpect.equals(FileSystemEntityType.LINK,
49 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY, 46 FileSystemEntity.type(y, followLinks: false)))
50 FileSystemEntity.type(x, followLinks: false))) 47 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
51 .then((_) => FutureExpect.equals(x, new Link(y).target())) 48 FileSystemEntity.type(x, followLinks: false)))
49 .then((_) => FutureExpect.equals(x, new Link(y).target()))
52 50
53 // Test Junction pointing to a missing directory. 51 // Test Junction pointing to a missing directory.
54 .then((_) => new Directory(x).delete()) 52 .then((_) => new Directory(x).delete())
55 .then((_) => FutureExpect.isTrue(new Link(y).exists())) 53 .then((_) => FutureExpect.isTrue(new Link(y).exists()))
56 .then((_) => FutureExpect.isFalse(new Directory(x).exists())) 54 .then((_) => FutureExpect.isFalse(new Directory(x).exists()))
57 .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y))) 55 .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y)))
58 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x))) 56 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x)))
59 .then((_) => FutureExpect.isFalse(FileSystemEntity.isDirectory(y))) 57 .then((_) => FutureExpect.isFalse(FileSystemEntity.isDirectory(y)))
60 .then((_) => FutureExpect.isFalse(FileSystemEntity.isDirectory(x))) 58 .then((_) => FutureExpect.isFalse(FileSystemEntity.isDirectory(x)))
61 .then((_) => FutureExpect.equals(FileSystemEntityType.LINK, 59 .then((_) => FutureExpect.equals(
62 FileSystemEntity.type(y))) 60 FileSystemEntityType.LINK, FileSystemEntity.type(y)))
63 .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND, 61 .then((_) => FutureExpect.equals(
64 FileSystemEntity.type(x))) 62 FileSystemEntityType.NOT_FOUND, FileSystemEntity.type(x)))
65 .then((_) => FutureExpect.equals(FileSystemEntityType.LINK, 63 .then((_) => FutureExpect.equals(FileSystemEntityType.LINK,
66 FileSystemEntity.type(y, followLinks: false))) 64 FileSystemEntity.type(y, followLinks: false)))
67 .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND, 65 .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
68 FileSystemEntity.type(x, followLinks: false))) 66 FileSystemEntity.type(x, followLinks: false)))
69 .then((_) => FutureExpect.equals(x, new Link(y).target())) 67 .then((_) => FutureExpect.equals(x, new Link(y).target()))
70 68
71 // Delete Junction pointing to a missing directory. 69 // Delete Junction pointing to a missing directory.
72 .then((_) => new Link(y).delete()) 70 .then((_) => new Link(y).delete())
73 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(y))) 71 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(y)))
74 .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND, 72 .then((_) => FutureExpect.equals(
75 FileSystemEntity.type(y))) 73 FileSystemEntityType.NOT_FOUND, FileSystemEntity.type(y)))
76 .then((_) => FutureExpect.throws(new Link(y).target())) 74 .then((_) => FutureExpect.throws(new Link(y).target()))
75 .then((_) => new Directory(x).create())
76 .then((_) => new Link(y).create(x))
77 .then((_) => FutureExpect.equals(FileSystemEntityType.LINK,
78 FileSystemEntity.type(y, followLinks: false)))
79 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
80 FileSystemEntity.type(x, followLinks: false)))
81 .then((_) => FutureExpect.equals(x, new Link(y).target()))
77 82
78 .then((_) => new Directory(x).create()) 83 // Delete Junction pointing to an existing directory.
79 .then((_) => new Link(y).create(x)) 84 .then((_) => new Directory(y).delete())
80 .then((_) => FutureExpect.equals(FileSystemEntityType.LINK, 85 .then((_) => FutureExpect.equals(
81 FileSystemEntity.type(y, followLinks: false))) 86 FileSystemEntityType.NOT_FOUND, FileSystemEntity.type(y)))
82 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY, 87 .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
83 FileSystemEntity.type(x, followLinks: false))) 88 FileSystemEntity.type(y, followLinks: false)))
84 .then((_) => FutureExpect.equals(x, new Link(y).target())) 89 .then((_) => FutureExpect.equals(
85 90 FileSystemEntityType.DIRECTORY, FileSystemEntity.type(x)))
86 // Delete Junction pointing to an existing directory. 91 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
87 .then((_) => new Directory(y).delete()) 92 FileSystemEntity.type(x, followLinks: false)))
88 .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND, 93 .then((_) => FutureExpect.throws(new Link(y).target()))
89 FileSystemEntity.type(y))) 94 .then((_) => temp.delete(recursive: true));
90 .then((_) => FutureExpect.equals(FileSystemEntityType.NOT_FOUND,
91 FileSystemEntity.type(y, followLinks: false)))
92 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
93 FileSystemEntity.type(x)))
94 .then((_) => FutureExpect.equals(FileSystemEntityType.DIRECTORY,
95 FileSystemEntity.type(x, followLinks: false)))
96 .then((_) => FutureExpect.throws(new Link(y).target()))
97 .then((_) => temp.delete(recursive: true));
98 }); 95 });
99 } 96 }
100 97
101
102 main() { 98 main() {
103 // Links on other platforms are tested by file_system_[async_]links_test. 99 // Links on other platforms are tested by file_system_[async_]links_test.
104 if (Platform.operatingSystem == 'windows') { 100 if (Platform.operatingSystem == 'windows') {
105 asyncStart(); 101 asyncStart();
106 testJunctionTypeDelete().then((_) => asyncEnd()); 102 testJunctionTypeDelete().then((_) => asyncEnd());
107 } 103 }
108 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698