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

Side by Side Diff: tests/dom/canvas_test.dart

Issue 10441104: New expectation functions plus convert old tests to use these. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | « samples/tests/samples/lib/view/view_test.dart ('k') | tests/dom/history_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 #library('CanvasTest'); 1 #library('CanvasTest');
2 #import('../../lib/unittest/unittest.dart'); 2 #import('../../lib/unittest/unittest.dart');
3 #import('../../lib/unittest/dom_config.dart'); 3 #import('../../lib/unittest/dom_config.dart');
4 #import('dart:dom_deprecated'); 4 #import('dart:dom_deprecated');
5 5
6 main() { 6 main() {
7 HTMLCanvasElement canvas; 7 HTMLCanvasElement canvas;
8 CanvasRenderingContext2D context; 8 CanvasRenderingContext2D context;
9 int width = 100; 9 int width = 100;
10 int height = 100; 10 int height = 100;
(...skipping 16 matching lines...) Expand all
27 checkPixel(data, 10 + width * 10, [255, 0, 0, 255]); 27 checkPixel(data, 10 + width * 10, [255, 0, 0, 255]);
28 checkPixel(data, 29 + width * 10, [255, 0, 0, 255]); 28 checkPixel(data, 29 + width * 10, [255, 0, 0, 255]);
29 checkPixel(data, 30 + width * 10, [0, 0, 0, 0]); 29 checkPixel(data, 30 + width * 10, [0, 0, 0, 0]);
30 }); 30 });
31 test('FillStyleGradient', () { 31 test('FillStyleGradient', () {
32 var gradient = context.createLinearGradient(0,0,20,20); 32 var gradient = context.createLinearGradient(0,0,20,20);
33 gradient.addColorStop(0,'red'); 33 gradient.addColorStop(0,'red');
34 gradient.addColorStop(1,'blue'); 34 gradient.addColorStop(1,'blue');
35 context.fillStyle = gradient; 35 context.fillStyle = gradient;
36 context.fillRect(0, 0, 20, 20); 36 context.fillRect(0, 0, 20, 20);
37 expect(context.fillStyle is CanvasGradient).isTrue(); 37 expect(context.fillStyle is CanvasGradient, isTrue);
38 }); 38 });
39 test('SetFillColor', () { 39 test('SetFillColor', () {
40 // With floats. 40 // With floats.
41 context.setFillColor(10, 10, 10, 10); 41 context.setFillColor(10, 10, 10, 10);
42 context.fillRect(10, 10, 20, 20); 42 context.fillRect(10, 10, 20, 20);
43 43
44 // With rationals. 44 // With rationals.
45 context.setFillColor(10.0, 10.0, 10.0, 10.0); 45 context.setFillColor(10.0, 10.0, 10.0, 10.0);
46 context.fillRect(20, 20, 30, 30); 46 context.fillRect(20, 20, 30, 30);
47 47
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 }); 81 });
82 } 82 }
83 83
84 void checkPixel(Uint8ClampedArray data, int offset, List<int> rgba) 84 void checkPixel(Uint8ClampedArray data, int offset, List<int> rgba)
85 { 85 {
86 offset *= 4; 86 offset *= 4;
87 for (var i = 0; i < 4; ++i) { 87 for (var i = 0; i < 4; ++i) {
88 Expect.equals(rgba[i], data[offset + i]); 88 Expect.equals(rgba[i], data[offset + i]);
89 } 89 }
90 } 90 }
OLDNEW
« no previous file with comments | « samples/tests/samples/lib/view/view_test.dart ('k') | tests/dom/history_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698