OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 library file_apptests; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:convert'; |
| 9 import 'dart:io'; |
| 10 |
| 11 import 'package:mojo_apptest/apptest.dart'; |
| 12 import 'package:mojo/application.dart'; |
| 13 import 'package:mojo/bindings.dart'; |
| 14 import 'package:mojo/core.dart'; |
| 15 |
| 16 tests(Application application, String url) { |
| 17 group('File Apptests', () { |
| 18 test('Absolute path', () async { |
| 19 String current = Directory.current.path; |
| 20 for (String relative in ['abd', '..', '.', 'efg/hij', 'abc/']) { |
| 21 if (current.endsWith('/')) { |
| 22 expect(new File(relative).absolute.path, '$current$relative'); |
| 23 } else { |
| 24 expect(new File(relative).absolute.path, '$current/$relative'); |
| 25 } |
| 26 expect(new File(relative).absolute.isAbsolute, isTrue); |
| 27 expect(new Directory(relative).absolute.path, |
| 28 new Link(relative).absolute.path); |
| 29 expect(new File(relative).absolute is File, isTrue); |
| 30 expect(new Directory(relative).absolute is Directory, isTrue); |
| 31 expect(new Link(relative).absolute is Link, isTrue); |
| 32 } |
| 33 for (String absolute in ['/abd', '/', '/./..\\', '/efg/hij', '/abc/']) { |
| 34 expect(new File(absolute).absolute.path, absolute); |
| 35 expect(new File(absolute).absolute.isAbsolute, isTrue); |
| 36 } |
| 37 }); |
| 38 test('File Constructor', () async { |
| 39 expect(new File('blåbærgrød'), isNotNull); |
| 40 expect(new File('foo.txt'), isNotNull); |
| 41 }); |
| 42 test('Directory systemTemp', () async { |
| 43 expect(Directory.systemTemp, isNotNull); |
| 44 }); |
| 45 test('Directory create', () async { |
| 46 Directory directory = |
| 47 await Directory.systemTemp.createTemp('dart_directory_test'); |
| 48 Directory subDirectory = new Directory("${directory.path}/subdir"); |
| 49 expect('$directory'.contains(directory.path), isTrue); |
| 50 expect(await subDirectory.exists(), isFalse); |
| 51 await subDirectory.create(); |
| 52 expect(await subDirectory.exists(), isTrue); |
| 53 File f = new File('${subDirectory.path}/file.txt'); |
| 54 File fLong = new File('${directory.path}/subdir/../subdir/file.txt'); |
| 55 expect(await f.exists(), isFalse); |
| 56 await fLong.create(); |
| 57 expect(await f.exists(), isTrue); |
| 58 }); |
| 59 }); |
| 60 } |
OLD | NEW |