OLD | NEW |
1 library CanvasTest; | 1 library CanvasTest; |
2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
4 import 'dart:html'; | 4 import 'dart:html'; |
5 | 5 |
6 main() { | 6 main() { |
7 CanvasElement canvas; | 7 CanvasElement canvas; |
8 CanvasRenderingContext2D context; | 8 CanvasRenderingContext2D context; |
9 int width = 100; | 9 int width = 100; |
10 int height = 100; | 10 int height = 100; |
(...skipping 23 matching lines...) Expand all Loading... |
34 context.fillStyle = 'red'; | 34 context.fillStyle = 'red'; |
35 context.fill(); | 35 context.fill(); |
36 | 36 |
37 var url = canvas.toDataUrl(); | 37 var url = canvas.toDataUrl(); |
38 | 38 |
39 var img = new ImageElement(); | 39 var img = new ImageElement(); |
40 img.onLoad.listen(expectAsync((_) { | 40 img.onLoad.listen(expectAsync((_) { |
41 expect(img.complete, true); | 41 expect(img.complete, true); |
42 })); | 42 })); |
43 img.onError.listen((_) { | 43 img.onError.listen((_) { |
44 guardAsync(() { | 44 fail('URL failed to load.'); |
45 expect(true, isFalse, reason: 'URL failed to load.'); | |
46 }); | |
47 }); | 45 }); |
48 img.src = url; | 46 img.src = url; |
49 }); | 47 }); |
50 } | 48 } |
51 | 49 |
52 void checkPixel(List<int> data, int offset, List<int> rgba) | 50 void checkPixel(List<int> data, int offset, List<int> rgba) |
53 { | 51 { |
54 offset *= 4; | 52 offset *= 4; |
55 for (var i = 0; i < 4; ++i) { | 53 for (var i = 0; i < 4; ++i) { |
56 expect(data[offset + i], equals(rgba[i])); | 54 expect(data[offset + i], equals(rgba[i])); |
57 } | 55 } |
58 } | 56 } |
OLD | NEW |