| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 library barback.test.asset_test; | 5 library barback.test.asset_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 import 'package:barback/barback.dart'; | 11 import 'package:barback/barback.dart'; |
| 12 import 'package:path/path.dart' as pathos; | 12 import 'package:path/path.dart' as pathos; |
| 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 /// The contents of the test binary file. | 17 /// The contents of the test binary file. |
| 18 final binaryContents = [0, 1, 2, 3, 4]; | 18 final binaryContents = [0, 1, 2, 3, 4]; |
| 19 | 19 |
| 20 main() { | 20 main() { |
| 21 initConfig(); | 21 initConfig(); |
| 22 | 22 |
| 23 Directory tempDir; | 23 Directory tempDir; |
| 24 String binaryFilePath; | 24 String binaryFilePath; |
| 25 String textFilePath; | 25 String textFilePath; |
| 26 String latin1FilePath; | 26 String latin1FilePath; |
| 27 | 27 |
| 28 setUp(() { | 28 setUp(() { |
| 29 // Create a temp file we can use for assets. | 29 // Create a temp file we can use for assets. |
| 30 tempDir = new Directory("").createTempSync(); | 30 tempDir = Directory.systemTemp.createTempSync('barback_asset_test_'); |
| 31 binaryFilePath = pathos.join(tempDir.path, "file.bin"); | 31 binaryFilePath = pathos.join(tempDir.path, "file.bin"); |
| 32 new File(binaryFilePath).writeAsBytesSync(binaryContents); | 32 new File(binaryFilePath).writeAsBytesSync(binaryContents); |
| 33 | 33 |
| 34 textFilePath = pathos.join(tempDir.path, "file.txt"); | 34 textFilePath = pathos.join(tempDir.path, "file.txt"); |
| 35 new File(textFilePath).writeAsStringSync("çøñ†éℵ™"); | 35 new File(textFilePath).writeAsStringSync("çøñ†éℵ™"); |
| 36 | 36 |
| 37 latin1FilePath = pathos.join(tempDir.path, "file.latin1"); | 37 latin1FilePath = pathos.join(tempDir.path, "file.latin1"); |
| 38 new File(latin1FilePath).writeAsBytesSync(LATIN1.encode("blåbærgrød")); | 38 new File(latin1FilePath).writeAsBytesSync(LATIN1.encode("blåbærgrød")); |
| 39 }); | 39 }); |
| 40 | 40 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 }); | 209 }); |
| 210 | 210 |
| 211 group("file asset", () { | 211 group("file asset", () { |
| 212 test("shows the file path", () { | 212 test("shows the file path", () { |
| 213 var asset = new Asset.fromPath(id, "path.txt"); | 213 var asset = new Asset.fromPath(id, "path.txt"); |
| 214 expect(asset.toString(), equals('File "path.txt"')); | 214 expect(asset.toString(), equals('File "path.txt"')); |
| 215 }); | 215 }); |
| 216 }); | 216 }); |
| 217 }); | 217 }); |
| 218 } | 218 } |
| OLD | NEW |