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

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

Issue 15832003: Change File.directory to not do any IO (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « tests/standalone/io/file_non_ascii_sync_test.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 8
9 main() { 9 main() {
10 ReceivePort port = new ReceivePort(); 10 ReceivePort port = new ReceivePort();
11 11
12 // On MacOS you get the decomposed utf8 form of file and directory 12 // On MacOS you get the decomposed utf8 form of file and directory
13 // names from the system. Therefore, we have to check for both here. 13 // names from the system. Therefore, we have to check for both here.
14 var precomposed = 'æøå'; 14 var precomposed = 'æøå';
15 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]); 15 var decomposed = new String.fromCharCodes([47, 230, 248, 97, 778]);
16 16
17 new Directory('').createTemp().then((tempDir) { 17 new Directory('').createTemp().then((tempDir) {
18 Directory nonAsciiDir = new Directory('${tempDir.path}/æøå'); 18 Directory nonAsciiDir = new Directory('${tempDir.path}/æøå');
19 nonAsciiDir.create().then((nonAsciiDir) { 19 nonAsciiDir.create().then((nonAsciiDir) {
20 nonAsciiDir.exists().then((result) { 20 nonAsciiDir.exists().then((result) {
21 Expect.isTrue(result); 21 Expect.isTrue(result);
22 File nonAsciiFile = new File('${nonAsciiDir.path}/æøå.txt'); 22 File nonAsciiFile = new File('${nonAsciiDir.path}/æøå.txt');
23 nonAsciiFile.writeAsString('æøå').then((_) { 23 nonAsciiFile.writeAsString('æøå').then((_) {
24 nonAsciiFile.exists().then((result) { 24 nonAsciiFile.exists().then((result) {
25 Expect.isTrue(result); 25 Expect.isTrue(result);
26 nonAsciiFile.readAsString().then((contents) { 26 nonAsciiFile.readAsString().then((contents) {
27 // The contents of the file is precomposed utf8. 27 // The contents of the file is precomposed utf8.
28 Expect.equals(precomposed, contents); 28 Expect.equals(precomposed, contents);
29 nonAsciiFile.create().then((_) { 29 nonAsciiFile.create().then((_) {
30 nonAsciiFile.directory().then((d) { 30 var d = nonAsciiFile.directory;
31 Expect.isTrue(d.path.endsWith(precomposed) || 31 Expect.isTrue(d.path.endsWith(precomposed) ||
32 d.path.endsWith(decomposed)); 32 d.path.endsWith(decomposed));
33 nonAsciiFile.length().then((length) { 33 nonAsciiFile.length().then((length) {
34 Expect.equals(6, length); 34 Expect.equals(6, length);
35 nonAsciiFile.lastModified().then((_) { 35 nonAsciiFile.lastModified().then((_) {
36 nonAsciiFile.fullPath().then((path) { 36 nonAsciiFile.fullPath().then((path) {
37 Expect.isTrue(path.endsWith('${precomposed}.txt') || 37 Expect.isTrue(path.endsWith('${precomposed}.txt') ||
38 path.endsWith('${decomposed}.txt')); 38 path.endsWith('${decomposed}.txt'));
39 tempDir.delete(recursive: true).then((_) { 39 tempDir.delete(recursive: true).then((_) {
40 port.close(); 40 port.close();
41 });
42 }); 41 });
43 }); 42 });
44 }); 43 });
45 }); 44 });
46 }); 45 });
47 }); 46 });
48 }); 47 });
49 }); 48 });
50 }); 49 });
51 }); 50 });
52 }).catchError((e) { 51 }).catchError((e) {
53 port.close(); 52 port.close();
54 Expect.fail("File not found"); 53 Expect.fail("File not found");
55 }); 54 });
56 } 55 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_non_ascii_sync_test.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698