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

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

Issue 11275054: Modified unittest to use new argument syntax. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 #library('CanvasTest'); 1 #library('CanvasTest');
2 #import('../../pkg/unittest/unittest.dart'); 2 #import('../../pkg/unittest/unittest.dart');
3 #import('../../pkg/unittest/html_config.dart'); 3 #import('../../pkg/unittest/html_config.dart');
4 #import('dart:html'); 4 #import('dart:html');
5 5
6 // We have aliased the legacy type CanvasPixelArray with the new type 6 // We have aliased the legacy type CanvasPixelArray with the new type
7 // Uint8ClampedArray by mapping the CanvasPixelArray type tag to 7 // Uint8ClampedArray by mapping the CanvasPixelArray type tag to
8 // Uint8ClampedArray. It is not a perfect match since CanvasPixelArray is 8 // Uint8ClampedArray. It is not a perfect match since CanvasPixelArray is
9 // missing the ArrayBufferView members. These should appear to be null. 9 // missing the ArrayBufferView members. These should appear to be null.
10 10
(...skipping 13 matching lines...) Expand all
24 context = canvas.getContext('2d'); 24 context = canvas.getContext('2d');
25 25
26 useHtmlConfiguration(); 26 useHtmlConfiguration();
27 27
28 test('CreateImageData', () { 28 test('CreateImageData', () {
29 ImageData image = context.createImageData(canvas.width, 29 ImageData image = context.createImageData(canvas.width,
30 canvas.height); 30 canvas.height);
31 Uint8ClampedArray data = image.data; 31 Uint8ClampedArray data = image.data;
32 // It is legal for the dart2js compiler to believe the type of the native 32 // It is legal for the dart2js compiler to believe the type of the native
33 // ImageData.data and elides the check, so check the type explicitly: 33 // ImageData.data and elides the check, so check the type explicitly:
34 expect(confuseType(data) is Uint8ClampedArray, isTrue, 'canvas array type'); 34 expect(confuseType(data) is Uint8ClampedArray, isTrue,
35 reason: 'canvas array type');
35 36
36 expect(data, hasLength(40000)); 37 expect(data, hasLength(40000));
37 checkPixel(data, 0, [0, 0, 0, 0]); 38 checkPixel(data, 0, [0, 0, 0, 0]);
38 checkPixel(data, width * height - 1, [0, 0, 0, 0]); 39 checkPixel(data, width * height - 1, [0, 0, 0, 0]);
39 40
40 data[100] = 200; 41 data[100] = 200;
41 expect(data[100], equals(200)); 42 expect(data[100], equals(200));
42 }); 43 });
43 } 44 }
44 45
45 void checkPixel(Uint8ClampedArray data, int offset, List<int> rgba) 46 void checkPixel(Uint8ClampedArray data, int offset, List<int> rgba)
46 { 47 {
47 offset *= 4; 48 offset *= 4;
48 for (var i = 0; i < 4; ++i) { 49 for (var i = 0; i < 4; ++i) {
49 Expect.equals(rgba[i], data[offset + i]); 50 expect(rgba[i], equals(data[offset + i]));
50 } 51 }
51 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698