Chromium Code Reviews| 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' show Encoding, UTF8, LATIN1; | 8 import 'dart:convert' show Encoding, UTF8, LATIN1; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:utf'; | |
| 11 | 10 |
| 12 import 'package:barback/barback.dart'; | 11 import 'package:barback/barback.dart'; |
| 13 import 'package:path/path.dart' as pathos; | 12 import 'package:path/path.dart' as pathos; |
| 14 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
| 14 import 'package:utf/utf.dart'; | |
|
floitsch
2013/08/26 18:21:16
We could remove this and the `show` above if we re
| |
| 15 | 15 |
| 16 import 'utils.dart'; | 16 import 'utils.dart'; |
| 17 | 17 |
| 18 /// The contents of the test binary file. | 18 /// The contents of the test binary file. |
| 19 final binaryContents = [0, 1, 2, 3, 4]; | 19 final binaryContents = [0, 1, 2, 3, 4]; |
| 20 | 20 |
| 21 main() { | 21 main() { |
| 22 initConfig(); | 22 initConfig(); |
| 23 | 23 |
| 24 Directory tempDir; | 24 Directory tempDir; |
| 25 String binaryFilePath; | 25 String binaryFilePath; |
| 26 String textFilePath; | 26 String textFilePath; |
| 27 String utf32FilePath; | 27 String utf32FilePath; |
| 28 | 28 |
| 29 setUp(() { | 29 setUp(() { |
| 30 // Create a temp file we can use for assets. | 30 // Create a temp file we can use for assets. |
| 31 tempDir = new Directory("").createTempSync(); | 31 tempDir = new Directory("").createTempSync(); |
| 32 binaryFilePath = pathos.join(tempDir.path, "file.bin"); | 32 binaryFilePath = pathos.join(tempDir.path, "file.bin"); |
| 33 new File(binaryFilePath).writeAsBytesSync(binaryContents); | 33 new File(binaryFilePath).writeAsBytesSync(binaryContents); |
| 34 | 34 |
| 35 textFilePath = pathos.join(tempDir.path, "file.txt"); | 35 textFilePath = pathos.join(tempDir.path, "file.txt"); |
| 36 new File(textFilePath).writeAsStringSync("çøñ†éℵ™"); | 36 new File(textFilePath).writeAsStringSync("çøñ†éℵ™"); |
| 37 | 37 |
| 38 utf32FilePath = pathos.join(tempDir.path, "file.utf32"); | 38 utf32FilePath = pathos.join(tempDir.path, "file.utf32"); |
| 39 new File(utf32FilePath).writeAsBytesSync(encodeUtf32("çøñ†éℵ™")); | 39 new File(utf32FilePath).writeAsBytesSync(encodeUtf32("çøñ†éℵ™")); |
|
floitsch
2013/08/26 18:21:16
the "encodeUtf32" is only provided by package:utf.
| |
| 40 }); | 40 }); |
| 41 | 41 |
| 42 tearDown(() { | 42 tearDown(() { |
| 43 if (tempDir != null) tempDir.deleteSync(recursive: true); | 43 if (tempDir != null) tempDir.deleteSync(recursive: true); |
| 44 }); | 44 }); |
| 45 | 45 |
| 46 var id = new AssetId.parse("package|path/to/asset.txt"); | 46 var id = new AssetId.parse("package|path/to/asset.txt"); |
| 47 | 47 |
| 48 group("Asset.fromBytes", () { | 48 group("Asset.fromBytes", () { |
| 49 test("returns an asset with the given ID", () { | 49 test("returns an asset with the given ID", () { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 }); | 172 }); |
| 173 | 173 |
| 174 group("file asset", () { | 174 group("file asset", () { |
| 175 test("shows the file path", () { | 175 test("shows the file path", () { |
| 176 var asset = new Asset.fromPath(id, "path.txt"); | 176 var asset = new Asset.fromPath(id, "path.txt"); |
| 177 expect(asset.toString(), equals('File "path.txt"')); | 177 expect(asset.toString(), equals('File "path.txt"')); |
| 178 }); | 178 }); |
| 179 }); | 179 }); |
| 180 }); | 180 }); |
| 181 } | 181 } |
| OLD | NEW |