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

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

Issue 11705002: Marking canvas test as pass so I can figure out what tolerances need to be adjusted. (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 | « no previous file | tests/html/html.status » ('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.
11 checkPixel(Uint8ClampedArray pixel, List<int> expected) {
12 expect(pixel[0], closeTo(expected[0], 1));
13 expect(pixel[1], closeTo(expected[1], 1));
14 expect(pixel[2], closeTo(expected[2], 1));
15 expect(pixel[3], closeTo(expected[3], 1));
16 }
17
10 main() { 18 main() {
11 useHtmlConfiguration(); 19 useHtmlConfiguration();
12 var canvas = new CanvasElement(); 20 var canvas = new CanvasElement();
13 canvas.width = 100; 21 canvas.width = 100;
14 canvas.height = 100; 22 canvas.height = 100;
15 23
16 var context = canvas.context2d; 24 var context = canvas.context2d;
17 25
18 Uint8ClampedArray readPixel() { 26 Uint8ClampedArray readPixel() {
19 var imageData = context.getImageData(2, 2, 1, 1); 27 var imageData = context.getImageData(2, 2, 1, 1);
(...skipping 14 matching lines...) Expand all
34 42
35 test('setFillColorHsl hue 2', () { 43 test('setFillColorHsl hue 2', () {
36 context.setFillColorHsl(240, 100, 50); 44 context.setFillColorHsl(240, 100, 50);
37 context.fillRect(0, 0, canvas.width, canvas.height); 45 context.fillRect(0, 0, canvas.width, canvas.height);
38 expect(readPixel(), [0, 0, 255, 255]); 46 expect(readPixel(), [0, 0, 255, 255]);
39 }); 47 });
40 48
41 test('setFillColorHsl sat', () { 49 test('setFillColorHsl sat', () {
42 context.setFillColorHsl(0, 0, 50); 50 context.setFillColorHsl(0, 0, 50);
43 context.fillRect(0, 0, canvas.width, canvas.height); 51 context.fillRect(0, 0, canvas.width, canvas.height);
44 var pixel = readPixel(); 52 checkPixel(readPixel(), [127, 127, 127, 255]);
45 // Some rounding errors in the browsers.
46 expect(pixel[0], closeTo(127, 1));
47 expect(pixel[1], closeTo(127, 1));
48 expect(pixel[2], closeTo(127, 1));
49 expect(pixel[3], 255);
50 }); 53 });
51 54
52 test('setStrokeColorRgb', () { 55 test('setStrokeColorRgb', () {
53 context.setStrokeColorRgb(255, 0, 255, 1); 56 context.setStrokeColorRgb(255, 0, 255, 1);
54 context.lineWidth = 10; 57 context.lineWidth = 10;
55 context.strokeRect(0, 0, canvas.width, canvas.height); 58 context.strokeRect(0, 0, canvas.width, canvas.height);
56 expect(readPixel(), [255, 0, 255, 255]); 59 expect(readPixel(), [255, 0, 255, 255]);
57 }); 60 });
58 61
59 test('setStrokeColorHsl hue', () { 62 test('setStrokeColorHsl hue', () {
60 context.setStrokeColorHsl(0, 100, 50); 63 context.setStrokeColorHsl(0, 100, 50);
61 context.lineWidth = 10; 64 context.lineWidth = 10;
62 context.strokeRect(0, 0, canvas.width, canvas.height); 65 context.strokeRect(0, 0, canvas.width, canvas.height);
63 expect(readPixel(), [255, 0, 0, 255]); 66 expect(readPixel(), [255, 0, 0, 255]);
64 }); 67 });
65 68
66 test('setStrokeColorHsl hue 2', () { 69 test('setStrokeColorHsl hue 2', () {
67 context.setStrokeColorHsl(240, 100, 50); 70 context.setStrokeColorHsl(240, 100, 50);
68 context.lineWidth = 10; 71 context.lineWidth = 10;
69 context.strokeRect(0, 0, canvas.width, canvas.height); 72 context.strokeRect(0, 0, canvas.width, canvas.height);
70 expect(readPixel(), [0, 0, 255, 255]); 73 expect(readPixel(), [0, 0, 255, 255]);
71 }); 74 });
72 75
73 test('setStrokeColorHsl sat', () { 76 test('setStrokeColorHsl sat', () {
74 context.setStrokeColorHsl(0, 0, 50); 77 context.setStrokeColorHsl(0, 0, 50);
75 context.lineWidth = 10; 78 context.lineWidth = 10;
76 context.strokeRect(0, 0, canvas.width, canvas.height); 79 context.strokeRect(0, 0, canvas.width, canvas.height);
77 var pixel = readPixel(); 80 checkPixel(readPixel(), [127, 127, 127, 255]);
78 // Some rounding errors in the browsers.
79 expect(pixel[0], closeTo(127, 1));
80 expect(pixel[1], closeTo(127, 1));
81 expect(pixel[2], closeTo(127, 1));
82 expect(pixel[3], 255);
83 }); 81 });
84 82
85 test('fillStyle', () { 83 test('fillStyle', () {
86 context.fillStyle = "red"; 84 context.fillStyle = "red";
87 context.fillRect(0, 0, canvas.width, canvas.height); 85 context.fillRect(0, 0, canvas.width, canvas.height);
88 expect(readPixel(), [255, 0, 0, 255]); 86 expect(readPixel(), [255, 0, 0, 255]);
89 }); 87 });
90 88
91 test('strokeStyle', () { 89 test('strokeStyle', () {
92 context.strokeStyle = "blue"; 90 context.strokeStyle = "blue";
(...skipping 18 matching lines...) Expand all
111 context.fillStyle = 'green'; 109 context.fillStyle = 'green';
112 context.fillRect(0, 0, canvas.width, canvas.height); 110 context.fillRect(0, 0, canvas.width, canvas.height);
113 111
114 context.putImageData(expectedData, 0, 0); 112 context.putImageData(expectedData, 0, 0);
115 113
116 var resultingData = context.getImageData(0, 0, 10, 10); 114 var resultingData = context.getImageData(0, 0, 10, 10);
117 // Make sure that we read back what we wrote. 115 // Make sure that we read back what we wrote.
118 expect(resultingData.data, expectedData.data); 116 expect(resultingData.data, expectedData.data);
119 }); 117 });
120 } 118 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698