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

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

Issue 57943002: Add fromUri constructor to File, Directory and Link (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review commetns Created 7 years, 1 month 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/directory_uri_test.dart ('k') | tests/standalone/io/link_uri_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
(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
7 import "package:async_helper/async_helper.dart";
8 import "package:expect/expect.dart";
9
10 void testFromUri() {
11 asyncStart();
12 Directory.systemTemp.createTemp('file_uri').then((temp) {
13 String filename = temp.path + '/from_uri';
14 Uri fileUri = new Uri.file(filename);
15 File file = new File.fromUri(fileUri);
16 Expect.isTrue(fileUri.isAbsolute);
17 Expect.isTrue(fileUri.path.startsWith('/'));
18 file.createSync();
19 Expect.isTrue(new File.fromUri(fileUri).existsSync());
20 Expect.isTrue(new File.fromUri(Uri.base.resolveUri(fileUri)).existsSync());
21 Directory.current = temp.path;
22 Expect.isTrue(new File.fromUri(Uri.parse('from_uri')).existsSync());
23 Expect.isTrue(new File.fromUri(Uri.base.resolve('from_uri')).existsSync());
24 file.deleteSync();
25 temp.deleteSync(recursive: true);
26 asyncEnd();
27 });
28 }
29
30 void testFromUriUnsupported() {
31 Expect.throws(
32 () => new File.fromUri(
33 Uri.parse('http://localhost:8080/index.html')),
34 (e) => e is UnsupportedError);
35 Expect.throws(() => new File.fromUri(Uri.parse('ftp://localhost/tmp/xxx')),
36 (e) => e is UnsupportedError);
37 Expect.throws(() => new File.fromUri(Uri.parse('name#fragment')),
38 (e) => e is UnsupportedError);
39 }
40
41 void main() {
42 testFromUri();
43 testFromUriUnsupported();
44 }
OLDNEW
« no previous file with comments | « tests/standalone/io/directory_uri_test.dart ('k') | tests/standalone/io/link_uri_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698