| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.java_io_test; | 8 library engine.java_io_test; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| 11 | 11 |
| 12 import 'package:analyzer/src/generated/java_io.dart'; | 12 import 'package:analyzer/src/generated/java_io.dart'; |
| 13 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
| 14 | 14 |
| 15 import '../utils.dart'; | 15 import '../utils.dart'; |
| 16 | 16 |
| 17 main() { | 17 main() { |
| 18 initializeTestEnvironment(); | 18 initializeTestEnvironment(); |
| 19 group('JavaFile', () { | 19 group('JavaFile', () { |
| 20 group('toURI', () { | 20 group('toURI', () { |
| 21 test('forAbsolute', () { | 21 test('forAbsolute', () { |
| 22 var tempDir = Directory.systemTemp.createTempSync('java_io_test'); | 22 var tempDir = Directory.systemTemp.createTempSync('java_io_test'); |
| 23 try { | 23 try { |
| 24 String tempPath = JavaFile.pathContext | 24 String tempPath = JavaFile.pathContext |
| 25 .normalize(JavaFile.pathContext.absolute(tempDir.path)); | 25 .normalize(JavaFile.pathContext.absolute(tempDir.path)); |
| 26 String path = JavaFile.pathContext.join(tempPath, 'foo.dart'); | 26 String path = JavaFile.pathContext.join(tempPath, 'foo.dart'); |
| 27 // we use an absolute path | 27 // we use an absolute path |
| 28 expect(JavaFile.pathContext.isAbsolute(path), isTrue); | 28 expect(JavaFile.pathContext.isAbsolute(path), isTrue, reason: '"$path"
is not absolute'); |
| 29 // test that toURI() returns an absolute URI | 29 // test that toURI() returns an absolute URI |
| 30 Uri uri = new JavaFile(path).toURI(); | 30 Uri uri = new JavaFile(path).toURI(); |
| 31 expect(uri.isAbsolute, isTrue); | 31 expect(uri.isAbsolute, isTrue); |
| 32 expect(uri.scheme, 'file'); | 32 expect(uri.scheme, 'file'); |
| 33 } finally { | 33 } finally { |
| 34 tempDir.deleteSync(recursive: true); | 34 tempDir.deleteSync(recursive: true); |
| 35 } | 35 } |
| 36 }); | 36 }); |
| 37 test('forRelative', () { | 37 test('forRelative', () { |
| 38 var tempDir = Directory.systemTemp.createTempSync('java_io_test'); | 38 var tempDir = Directory.systemTemp.createTempSync('java_io_test'); |
| 39 try { | 39 try { |
| 40 String tempPath = JavaFile.pathContext | 40 String tempPath = JavaFile.pathContext |
| 41 .normalize(JavaFile.pathContext.absolute(tempDir.path)); | 41 .normalize(JavaFile.pathContext.absolute(tempDir.path)); |
| 42 String path = JavaFile.pathContext.join(tempPath, 'foo.dart'); | 42 String path = JavaFile.pathContext.join(tempPath, 'foo.dart'); |
| 43 expect(JavaFile.pathContext.isAbsolute(path), isTrue); | 43 expect(JavaFile.pathContext.isAbsolute(path), isTrue, reason: '"$path"
is not absolute'); |
| 44 // prepare a relative path | 44 // prepare a relative path |
| 45 // We should not check that "relPath" is actually relative - | 45 // We should not check that "relPath" is actually relative - |
| 46 // it may be not on Windows, if "temp" is on other disk. | 46 // it may be not on Windows, if "temp" is on other disk. |
| 47 String relPath = JavaFile.pathContext.relative(path); | 47 String relPath = JavaFile.pathContext.relative(path); |
| 48 // test that toURI() returns an absolute URI | 48 // test that toURI() returns an absolute URI |
| 49 Uri uri = new JavaFile(relPath).toURI(); | 49 Uri uri = new JavaFile(relPath).toURI(); |
| 50 expect(uri.isAbsolute, isTrue); | 50 expect(uri.isAbsolute, isTrue); |
| 51 expect(uri.scheme, 'file'); | 51 expect(uri.scheme, 'file'); |
| 52 } finally { | 52 } finally { |
| 53 tempDir.deleteSync(recursive: true); | 53 tempDir.deleteSync(recursive: true); |
| 54 } | 54 } |
| 55 }); | 55 }); |
| 56 }); | 56 }); |
| 57 }); | 57 }); |
| 58 } | 58 } |
| OLD | NEW |