OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, 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 library engine.java_io_test; |
| 6 |
| 7 import 'dart:io'; |
| 8 |
| 9 import 'package:analyzer/src/generated/java_io.dart'; |
| 10 import 'package:unittest/unittest.dart'; |
| 11 |
| 12 import '../utils.dart'; |
| 13 |
| 14 main() { |
| 15 initializeTestEnvironment(); |
| 16 group('JavaFile', () { |
| 17 group('toURI', () { |
| 18 test('forAbsolute', () { |
| 19 String tempPath = '/temp'; |
| 20 String path = JavaFile.pathContext.join(tempPath, 'foo.dart'); |
| 21 // we use an absolute path |
| 22 expect(JavaFile.pathContext.isAbsolute(path), isTrue, |
| 23 reason: '"$path" is not absolute'); |
| 24 // test that toURI() returns an absolute URI |
| 25 Uri uri = new JavaFile(path).toURI(); |
| 26 expect(uri.isAbsolute, isTrue); |
| 27 expect(uri.scheme, 'file'); |
| 28 }); |
| 29 test('forRelative', () { |
| 30 String tempPath = '/temp'; |
| 31 String path = JavaFile.pathContext.join(tempPath, 'foo.dart'); |
| 32 expect(JavaFile.pathContext.isAbsolute(path), isTrue, |
| 33 reason: '"$path" is not absolute'); |
| 34 // prepare a relative path |
| 35 // We should not check that "relPath" is actually relative - |
| 36 // it may be not on Windows, if "temp" is on other disk. |
| 37 String relPath = JavaFile.pathContext.relative(path); |
| 38 // test that toURI() returns an absolute URI |
| 39 Uri uri = new JavaFile(relPath).toURI(); |
| 40 expect(uri.isAbsolute, isTrue); |
| 41 expect(uri.scheme, 'file'); |
| 42 }); |
| 43 }); |
| 44 }); |
| 45 } |
OLD | NEW |