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 canvas_rendering_context_2d_test; import '../../pkg/unittest/lib/unittes
t.dart'; | 5 library canvas_rendering_context_2d_test; import '../../pkg/unittest/lib/unittes
t.dart'; |
6 import '../../pkg/unittest/lib/html_individual_config.dart'; | 6 import '../../pkg/unittest/lib/html_individual_config.dart'; |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:math'; | 8 import 'dart:math'; |
9 | 9 |
10 // Some rounding errors in the browsers. | 10 // Some rounding errors in the browsers. |
11 checkPixel(List<int> pixel, List<int> expected) { | 11 checkPixel(List<int> pixel, List<int> expected) { |
12 expect(pixel[0], closeTo(expected[0], 2)); | 12 expect(pixel[0], closeTo(expected[0], 2)); |
13 expect(pixel[1], closeTo(expected[1], 2)); | 13 expect(pixel[1], closeTo(expected[1], 2)); |
14 expect(pixel[2], closeTo(expected[2], 2)); | 14 expect(pixel[2], closeTo(expected[2], 2)); |
15 expect(pixel[3], closeTo(expected[3], 2)); | 15 expect(pixel[3], closeTo(expected[3], 2)); |
16 } | 16 } |
17 | 17 |
18 var canvas; | 18 var canvas; |
19 var context; | 19 var context; |
20 var otherCanvas; | 20 var otherCanvas; |
21 var otherContext; | 21 var otherContext; |
22 var video; | 22 var video; |
23 | 23 |
24 void createCanvas() { | 24 void createCanvas() { |
25 canvas = new CanvasElement(); | 25 canvas = new CanvasElement(); |
26 canvas.width = 100; | 26 canvas.width = 100; |
27 canvas.height = 100; | 27 canvas.height = 100; |
28 | 28 |
29 context = canvas.context2d; | 29 context = canvas.context2D; |
30 } | 30 } |
31 | 31 |
32 void createOtherCanvas() { | 32 void createOtherCanvas() { |
33 otherCanvas = new CanvasElement(); | 33 otherCanvas = new CanvasElement(); |
34 otherCanvas.width = 10; | 34 otherCanvas.width = 10; |
35 otherCanvas.height = 10; | 35 otherCanvas.height = 10; |
36 otherContext = otherCanvas.context2d; | 36 otherContext = otherCanvas.context2D; |
37 otherContext.fillStyle = "red"; | 37 otherContext.fillStyle = "red"; |
38 otherContext.fillRect(0, 0, otherCanvas.width, otherCanvas.height); | 38 otherContext.fillRect(0, 0, otherCanvas.width, otherCanvas.height); |
39 } | 39 } |
40 | 40 |
41 void setupFunc() { | 41 void setupFunc() { |
42 createCanvas(); | 42 createCanvas(); |
43 createOtherCanvas(); | 43 createOtherCanvas(); |
44 video = new VideoElement(); | 44 video = new VideoElement(); |
45 } | 45 } |
46 | 46 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 var imageData = context.createImageData(15, 15); | 596 var imageData = context.createImageData(15, 15); |
597 expect(imageData.width, 15); | 597 expect(imageData.width, 15); |
598 expect(imageData.height, 15); | 598 expect(imageData.height, 15); |
599 | 599 |
600 var other = context.createImageDataFromImageData(imageData); | 600 var other = context.createImageDataFromImageData(imageData); |
601 expect(other.width, 15); | 601 expect(other.width, 15); |
602 expect(other.height, 15); | 602 expect(other.height, 15); |
603 }); | 603 }); |
604 }); | 604 }); |
605 } | 605 } |
OLD | NEW |