| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('blob_test'); | 5 #library('blob_test'); |
| 6 #import('../../pkg/unittest/unittest.dart'); | 6 #import('../../pkg/unittest/unittest.dart'); |
| 7 #import('../../pkg/unittest/html_config.dart'); | 7 #import('../../pkg/unittest/html_config.dart'); |
| 8 #import('dart:html'); | 8 #import('dart:html'); |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 useHtmlConfiguration(); | 11 useHtmlConfiguration(); |
| 12 | 12 |
| 13 test('basic', () { | 13 test('basic', () { |
| 14 var b = new Blob([]); | 14 var b = new Blob([]); |
| 15 expect(b.size, 0); | 15 expect(b.size, isZero); |
| 16 }); | 16 }); |
| 17 | 17 |
| 18 test('type1', () { | 18 test('type1', () { |
| 19 // OPTIONALS var b = new Blob(['Harry'], type: 'text'); | 19 // OPTIONALS var b = new Blob(['Harry'], type: 'text'); |
| 20 var b = new Blob(['Harry'], 'text'); | 20 var b = new Blob(['Harry'], 'text'); |
| 21 expect(b.size, 5); | 21 expect(b.size, 5); |
| 22 expect(b.type, 'text'); | 22 expect(b.type, 'text'); |
| 23 }); | 23 }); |
| 24 | 24 |
| 25 test('endings1', () { | 25 test('endings1', () { |
| 26 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'transparent'); | 26 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'transparent'); |
| 27 var b = new Blob(['A\nB\n'], null, 'transparent'); | 27 var b = new Blob(['A\nB\n'], null, 'transparent'); |
| 28 expect(b.size, 4); | 28 expect(b.size, 4); |
| 29 }); | 29 }); |
| 30 | 30 |
| 31 test('endings2', () { | 31 test('endings2', () { |
| 32 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'native'); | 32 // OPTIONALS var b = new Blob(['A\nB\n'], endings: 'native'); |
| 33 var b = new Blob(['A\nB\n'], null, 'native'); | 33 var b = new Blob(['A\nB\n'], null, 'native'); |
| 34 expect(b.size, (x) => x == 4 || x == 6); | 34 expect(b.size, (x) => x == 4 || x == 6, |
| 35 reason: "b.size should be 4 or 6"); |
| 35 }); | 36 }); |
| 36 | 37 |
| 37 test('twoStrings', () { | 38 test('twoStrings', () { |
| 38 // OPTIONALS var b = new Blob(['123', 'xyz'], type: 'text/plain;charset=UT
F-8'); | 39 // OPTIONALS var b = new Blob(['123', 'xyz'], type: 'text/plain;charset=UT
F-8'); |
| 39 var b = new Blob(['123', 'xyz'], 'text/plain;charset=UTF-8'); | 40 var b = new Blob(['123', 'xyz'], 'text/plain;charset=UTF-8'); |
| 40 expect(b.size, 6); | 41 expect(b.size, 6); |
| 41 }); | 42 }); |
| 42 | 43 |
| 43 test('fromBlob1', () { | 44 test('fromBlob1', () { |
| 44 var b1 = new Blob([]); | 45 var b1 = new Blob([]); |
| 45 var b2 = new Blob([b1]); | 46 var b2 = new Blob([b1]); |
| 46 expect(b2.size, 0); | 47 expect(b2.size, isZero); |
| 47 }); | 48 }); |
| 48 | 49 |
| 49 test('fromBlob2', () { | 50 test('fromBlob2', () { |
| 50 var b1 = new Blob(['x']); | 51 var b1 = new Blob(['x']); |
| 51 var b2 = new Blob([b1, b1]); | 52 var b2 = new Blob([b1, b1]); |
| 52 expect(b1.size, 1); | 53 expect(b1.size, 1); |
| 53 expect(b2.size, 2); | 54 expect(b2.size, 2); |
| 54 }); | 55 }); |
| 55 | 56 |
| 56 test('fromArrayBuffer', () { | 57 test('fromArrayBuffer', () { |
| 57 var a = new Uint8Array(100).buffer; // i.e. new ArrayBuffer(100); | 58 var a = new Uint8Array(100).buffer; // i.e. new ArrayBuffer(100); |
| 58 var b = new Blob([a, a]); | 59 var b = new Blob([a, a]); |
| 59 expect(b.size, 200); | 60 expect(b.size, 200); |
| 60 }); | 61 }); |
| 61 } | 62 } |
| OLD | NEW |