Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: tests/html/canvasrenderingcontext2d_test.dart

Issue 12036013: Initial work on ImageData.data. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/canvas_test.dart ('k') | tests/html/instance_of_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 url_test; 5 library url_test;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_config.dart'; 7 import '../../pkg/unittest/lib/html_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 9
10 // Some rounding errors in the browsers. 10 // Some rounding errors in the browsers.
11 checkPixel(Uint8ClampedArray pixel, List<int> expected) { 11 checkPixel(List<int> pixel, List<int> expected) {
12 expect(pixel[0], closeTo(expected[0], 1)); 12 expect(pixel[0], closeTo(expected[0], 1));
13 expect(pixel[1], closeTo(expected[1], 1)); 13 expect(pixel[1], closeTo(expected[1], 1));
14 expect(pixel[2], closeTo(expected[2], 1)); 14 expect(pixel[2], closeTo(expected[2], 1));
15 expect(pixel[3], closeTo(expected[3], 1)); 15 expect(pixel[3], closeTo(expected[3], 1));
16 } 16 }
17 17
18 main() { 18 main() {
19 useHtmlConfiguration(); 19 useHtmlConfiguration();
20 var canvas = new CanvasElement(); 20 var canvas = new CanvasElement();
21 canvas.width = 100; 21 canvas.width = 100;
22 canvas.height = 100; 22 canvas.height = 100;
23 23
24 var context = canvas.context2d; 24 var context = canvas.context2d;
25 25
26 Uint8ClampedArray readPixel() { 26 List<int> readPixel() {
27 var imageData = context.getImageData(2, 2, 1, 1); 27 var imageData = context.getImageData(2, 2, 1, 1);
28 return imageData.data; 28 return imageData.data;
29 } 29 }
30 30
31 test('setFillColorRgb', () { 31 test('setFillColorRgb', () {
32 context.setFillColorRgb(255, 0, 255, 1); 32 context.setFillColorRgb(255, 0, 255, 1);
33 context.fillRect(0, 0, canvas.width, canvas.height); 33 context.fillRect(0, 0, canvas.width, canvas.height);
34 expect(readPixel(), [255, 0, 255, 255]); 34 expect(readPixel(), [255, 0, 255, 255]);
35 }); 35 });
36 36
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 context.fillStyle = 'green'; 109 context.fillStyle = 'green';
110 context.fillRect(0, 0, canvas.width, canvas.height); 110 context.fillRect(0, 0, canvas.width, canvas.height);
111 111
112 context.putImageData(expectedData, 0, 0); 112 context.putImageData(expectedData, 0, 0);
113 113
114 var resultingData = context.getImageData(0, 0, 10, 10); 114 var resultingData = context.getImageData(0, 0, 10, 10);
115 // Make sure that we read back what we wrote. 115 // Make sure that we read back what we wrote.
116 expect(resultingData.data, expectedData.data); 116 expect(resultingData.data, expectedData.data);
117 }); 117 });
118 } 118 }
OLDNEW
« no previous file with comments | « tests/html/canvas_test.dart ('k') | tests/html/instance_of_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698