Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "dart:io"; | |
| 6 import "dart:isolate"; | |
| 7 | |
| 8 // Test the dart:io Link class. | |
| 9 | |
| 10 // Windows only supports absolute links to existing folders, so some tests will | |
| 11 // be excluded on Windows. | |
| 12 bool windows = false; | |
|
Søren Gjesse
2013/03/13 16:44:01
This is not used yet.
| |
| 13 | |
| 14 testCreateSync() { | |
| 15 Path base = new Path(new Directory('').createTempSync().path); | |
| 16 String link = base.append('link').toNativePath(); | |
| 17 String target = base.append('target').toNativePath(); | |
| 18 new Directory(target).createSync(); | |
| 19 print(target); | |
| 20 new Link(link).createSync(target); | |
| 21 | |
| 22 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 23 FileSystemEntity.typeSync(link)); | |
| 24 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 25 FileSystemEntity.typeSync(target)); | |
| 26 Expect.equals(FileSystemEntityType.LINK, | |
| 27 FileSystemEntity.typeSync(link, followLinks: false)); | |
| 28 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 29 FileSystemEntity.typeSync(target, followLinks: false)); | |
| 30 Expect.isTrue(FileSystemEntity.isLinkSync(link)); | |
| 31 Expect.isFalse(FileSystemEntity.isLinkSync(target)); | |
| 32 Expect.isTrue(new Directory(link).existsSync()); | |
| 33 Expect.isTrue(new Directory(target).existsSync()); | |
| 34 Expect.isTrue(new Link(link).existsSync()); | |
| 35 Expect.isFalse(new Link(target).existsSync()); | |
| 36 | |
| 37 String createdThroughLink = | |
| 38 base.append('link/createdThroughLink').toNativePath(); | |
| 39 String createdDirectly = base.append('target/createdDirectly').toNativePath(); | |
| 40 new Directory(createdThroughLink).createSync(); | |
| 41 new Directory(createdDirectly).createSync(); | |
| 42 Expect.isTrue(new Directory(createdThroughLink).existsSync()); | |
| 43 Expect.isTrue(new Directory(createdDirectly).existsSync()); | |
| 44 Expect.isTrue(new Directory.fromPath(base.append('link/createdDirectly')) | |
| 45 .existsSync()); | |
| 46 Expect.isTrue(new Directory.fromPath(base.append('target/createdThroughLink')) | |
| 47 .existsSync()); | |
| 48 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 49 FileSystemEntity.typeSync(createdThroughLink, | |
| 50 followLinks: false)); | |
| 51 Expect.equals(FileSystemEntityType.DIRECTORY, | |
| 52 FileSystemEntity.typeSync(createdDirectly, followLinks: false)); | |
| 53 | |
| 54 new Directory.fromPath(base).deleteSync(recursive: true); | |
| 55 } | |
| 56 | |
| 57 | |
| 58 main() { | |
| 59 if (Platform.operatingSystem == 'windows') windows = true; | |
| 60 | |
| 61 testCreateSync(); | |
| 62 } | |
| OLD | NEW |