OLD | NEW |
| (Empty) |
1 #import('../../../../../dart/client/testing/unittest/unittest.dart'); | |
2 #import('dart:html', prefix: 'html'); | |
3 #import('dart:dom'); | |
4 | |
5 // Version of Canvas test that implicitly uses dart:html library via unittests. | |
6 | |
7 main() { | |
8 HTMLCanvasElement canvas; | |
9 CanvasRenderingContext2D context; | |
10 | |
11 // FIXME: once main is run on content loaded, this hack won't be necessary. | |
12 window.setTimeout(() { | |
13 canvas = document.createElement('canvas'); | |
14 canvas.setAttribute('width', '100'); | |
15 canvas.setAttribute('height', '100'); | |
16 document.body.appendChild(canvas); | |
17 context = canvas.getContext('2d'); | |
18 }, 0); | |
19 | |
20 forLayoutTests(); | |
21 test('FillStyle', () { | |
22 context.fillStyle = "red"; | |
23 context.fillRect(10, 10, 20, 20); | |
24 | |
25 // TODO(vsm): Verify the result once we have the ability to read pixels. | |
26 }); | |
27 test('SetFillColor', () { | |
28 // With floats. | |
29 context.setFillColor(10, 10, 10, 10); | |
30 context.fillRect(10, 10, 20, 20); | |
31 | |
32 // With rationals. | |
33 context.setFillColor(10.0, 10.0, 10.0, 10.0); | |
34 context.fillRect(20, 20, 30, 30); | |
35 | |
36 // With ints. | |
37 context.setFillColor(10, 10, 10, 10); | |
38 context.fillRect(30, 30, 40, 40); | |
39 | |
40 // TODO(vsm): Verify the result once we have the ability to read pixels. | |
41 }); | |
42 test('StrokeStyle', () { | |
43 context.strokeStyle = "blue"; | |
44 context.strokeRect(30, 30, 10, 20); | |
45 | |
46 // TODO(vsm): Verify the result once we have the ability to read pixels. | |
47 }); | |
48 test('CreateImageData', () { | |
49 ImageData image = context.createImageData(canvas.width, | |
50 canvas.height); | |
51 CanvasPixelArray bytes = image.data; | |
52 | |
53 // FIXME: uncomment when numeric index getters are supported. | |
54 //var byte = bytes[0]; | |
55 | |
56 Expect.equals(40000, bytes.length); | |
57 }); | |
58 } | |
OLD | NEW |