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

Side by Side Diff: pkg/dev_compiler/test/codegen/lib/html/instance_of_test.dart

Issue 2413073002: Start cleaning up the HTML tests. (Closed)
Patch Set: Unfork expect.dart. Created 4 years, 2 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
OLDNEW
1 library InstanceOfTest;
2 import 'package:unittest/unittest.dart';
3 import 'package:unittest/html_config.dart';
4 import 'dart:html'; 1 import 'dart:html';
5 2
3 import 'package:minitest/minitest.dart';
4
6 main() { 5 main() {
7 CanvasElement canvas; 6 CanvasElement canvas;
8 7
9 canvas = new Element.tag('canvas'); 8 canvas = new Element.tag('canvas');
10 canvas.attributes['width'] = '100'; 9 canvas.attributes['width'] = '100';
11 canvas.attributes['height'] = '100'; 10 canvas.attributes['height'] = '100';
12 document.body.append(canvas); 11 document.body.append(canvas);
13 12
14 var isCanvasRenderingContext = predicate((x) => x is CanvasRenderingContext, 13 var isCanvasRenderingContext = predicate((x) => x is CanvasRenderingContext,
15 'is a CanvasRenderingContext'); 14 'is a CanvasRenderingContext');
15 var isNotCanvasRenderingContext = predicate((x) => x is! CanvasRenderingContex t,
16 'is not a CanvasRenderingContext');
16 var isCanvasRenderingContext2D = 17 var isCanvasRenderingContext2D =
17 predicate((x) => x is CanvasRenderingContext2D, 18 predicate((x) => x is CanvasRenderingContext2D,
18 'is a CanvasRenderingContext2D'); 19 'is a CanvasRenderingContext2D');
20 var isNotCanvasRenderingContext2D =
21 predicate((x) => x is! CanvasRenderingContext2D,
22 'is not a CanvasRenderingContext2D');
19 var isElement = predicate((x) => x is Element, 'is an Element'); 23 var isElement = predicate((x) => x is Element, 'is an Element');
24 var isNotElement = predicate((x) => x is! Element, 'is not an Element');
20 var isCanvasElement = 25 var isCanvasElement =
21 predicate((x) => x is CanvasElement, 'is a CanvasElement'); 26 predicate((x) => x is CanvasElement, 'is a CanvasElement');
27 var isNotCanvasElement =
28 predicate((x) => x is! CanvasElement, 'is not a CanvasElement');
22 var isImageData = predicate((x) => x is ImageData, 'is an ImageData'); 29 var isImageData = predicate((x) => x is ImageData, 'is an ImageData');
30 var isNotImageData = predicate((x) => x is! ImageData, 'is not an ImageData');
23 //var isUint8ClampedArray = 31 //var isUint8ClampedArray =
24 // predicate((x) => x is Uint8ClampedArray, 'is a Uint8ClampedArray'); 32 // predicate((x) => x is Uint8ClampedArray, 'is a Uint8ClampedArray');
25 var isIntList = 33 var isIntList =
26 predicate((x) => x is List<int>, 'is a List<int>'); 34 predicate((x) => x is List<int>, 'is a List<int>');
27 35
28 useHtmlConfiguration();
29 test('Instanceof', () { 36 test('Instanceof', () {
30 expect(canvas, isNot(isCanvasRenderingContext)); 37 expect(canvas, isNotCanvasRenderingContext);
31 expect(canvas, isNot(isCanvasRenderingContext2D)); 38 expect(canvas, isNotCanvasRenderingContext2D);
32 expect(canvas, isElement); 39 expect(canvas, isElement);
33 expect(canvas, isCanvasElement); 40 expect(canvas, isCanvasElement);
34 expect(canvas, isNot(isImageData)); 41 expect(canvas, isNotImageData);
35 // expect(canvas, isNot(isCanvasPixelArray)); 42 // expect(canvas, isNot(isCanvasPixelArray));
36 43
37 CanvasRenderingContext2D context = canvas.getContext('2d'); 44 CanvasRenderingContext2D context = canvas.getContext('2d');
38 expect(context, isCanvasRenderingContext); 45 expect(context, isCanvasRenderingContext);
39 expect(context, isCanvasRenderingContext2D); 46 expect(context, isCanvasRenderingContext2D);
40 expect(context, isNot(isElement)); 47 expect(context, isNotElement);
41 expect(context, isNot(isCanvasElement)); 48 expect(context, isNotCanvasElement);
42 expect(context, isNot(isImageData)); 49 expect(context, isNotImageData);
43 // expect(context, isNot(isCanvasPixelArray)); 50 // expect(context, isNot(isCanvasPixelArray));
44 51
45 // FIXME(b/5286633): Interface injection type check workaround. 52 // FIXME(b/5286633): Interface injection type check workaround.
46 var image = context.createImageData(canvas.width as dynamic, 53 var image = context.createImageData(canvas.width as dynamic,
47 canvas.height as dynamic); 54 canvas.height as dynamic);
48 expect(image, isNot(isCanvasRenderingContext)); 55 expect(image, isNotCanvasRenderingContext);
49 expect(image, isNot(isCanvasRenderingContext2D)); 56 expect(image, isNotCanvasRenderingContext2D);
50 expect(image, isNot(isElement)); 57 expect(image, isNotElement);
51 expect(image, isNot(isCanvasElement)); 58 expect(image, isNotCanvasElement);
52 expect(image, isImageData); 59 expect(image, isImageData);
53 // expect(image, isNot(isCanvasPixelArray)); 60 // expect(image, isNot(isCanvasPixelArray));
54 61
55 // Include CanvasPixelArray since constructor and prototype are not 62 // Include CanvasPixelArray since constructor and prototype are not
56 // available until one is created. 63 // available until one is created.
57 var bytes = image.data; 64 var bytes = image.data;
58 expect(bytes, isNot(isCanvasRenderingContext)); 65 expect(bytes, isNotCanvasRenderingContext);
59 expect(bytes, isNot(isCanvasRenderingContext2D)); 66 expect(bytes, isNotCanvasRenderingContext2D);
60 expect(bytes, isNot(isElement)); 67 expect(bytes, isNotElement);
61 expect(bytes, isNot(isCanvasElement)); 68 expect(bytes, isNotCanvasElement);
62 expect(bytes, isNot(isImageData)); 69 expect(bytes, isNotImageData);
63 expect(bytes, isIntList); 70 expect(bytes, isIntList);
64 71
65 // FIXME: Ensure this is an SpanElement when we next update 72 // FIXME: Ensure this is an SpanElement when we next update
66 // WebKit IDL. 73 // WebKit IDL.
67 var span = new Element.tag('span'); 74 var span = new Element.tag('span');
68 expect(span, isElement); 75 expect(span, isElement);
69 }); 76 });
70 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698