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

Side by Side Diff: test/codegen/expect/lib/html/url_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « test/codegen/expect/lib/html/uri_test.js ('k') | test/codegen/expect/lib/html/webgl_1_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 dart_library.library('lib/html/url_test', null, /* Imports */[
2 'dart_sdk',
3 'unittest'
4 ], function load__url_test(exports, dart_sdk, unittest) {
5 'use strict';
6 const core = dart_sdk.core;
7 const html = dart_sdk.html;
8 const typed_data = dart_sdk.typed_data;
9 const _interceptors = dart_sdk._interceptors;
10 const dart = dart_sdk.dart;
11 const dartx = dart_sdk.dartx;
12 const html_config = unittest.html_config;
13 const unittest$ = unittest.unittest;
14 const src__matcher__expect = unittest.src__matcher__expect;
15 const src__matcher__numeric_matchers = unittest.src__matcher__numeric_matchers ;
16 const src__matcher__string_matchers = unittest.src__matcher__string_matchers;
17 const url_test = Object.create(null);
18 let JSArrayOfUint8List = () => (JSArrayOfUint8List = dart.constFn(_interceptor s.JSArray$(typed_data.Uint8List)))();
19 let EventTovoid = () => (EventTovoid = dart.constFn(dart.functionType(dart.voi d, [html.Event])))();
20 let VoidToBlob = () => (VoidToBlob = dart.constFn(dart.definiteFunctionType(ht ml.Blob, [])))();
21 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun ctionType(dart.dynamic, [dart.dynamic])))();
22 let EventTovoid$ = () => (EventTovoid$ = dart.constFn(dart.definiteFunctionTyp e(dart.void, [html.Event])))();
23 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
24 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
25 url_test.main = function() {
26 html_config.useHtmlConfiguration();
27 function createImageBlob() {
28 let canvas = html.CanvasElement.new();
29 canvas[dartx.width] = 100;
30 canvas[dartx.height] = 100;
31 let context = canvas[dartx.context2D];
32 context[dartx.fillStyle] = 'red';
33 context[dartx.fillRect](0, 0, canvas[dartx.width], canvas[dartx.height]);
34 let dataUri = canvas[dartx.toDataUrl]('image/png');
35 let byteString = html.window[dartx.atob](dataUri[dartx.split](',')[dartx.g et](1));
36 let mimeString = dataUri[dartx.split](',')[dartx.get](0)[dartx.split](':') [dartx.get](1)[dartx.split](';')[dartx.get](0);
37 let arrayBuffer = typed_data.Uint8List.new(byteString[dartx.length]);
38 let dataArray = typed_data.Uint8List.view(arrayBuffer[dartx.buffer]);
39 for (let i = 0; i < dart.notNull(byteString[dartx.length]); i++) {
40 dataArray[dartx.set](i, byteString[dartx.codeUnitAt](i));
41 }
42 let blob = html.Blob.new(JSArrayOfUint8List().of([arrayBuffer]), 'image/pn g');
43 return blob;
44 }
45 dart.fn(createImageBlob, VoidToBlob());
46 unittest$.group('blob', dart.fn(() => {
47 unittest$.test('createObjectUrlFromBlob', dart.fn(() => {
48 let blob = createImageBlob();
49 let url = html.Url.createObjectUrlFromBlob(blob);
50 src__matcher__expect.expect(url[dartx.length], src__matcher__numeric_mat chers.greaterThan(0));
51 src__matcher__expect.expect(url, src__matcher__string_matchers.startsWit h('blob:'));
52 let img = html.ImageElement.new();
53 img[dartx.onLoad].listen(EventTovoid()._check(unittest$.expectAsync(dart .fn(_ => {
54 src__matcher__expect.expect(img[dartx.complete], true);
55 }, dynamicTodynamic()))));
56 img[dartx.onError].listen(dart.fn(_ => {
57 src__matcher__expect.fail('URL failed to load.');
58 }, EventTovoid$()));
59 img[dartx.src] = url;
60 }, VoidTodynamic()));
61 unittest$.test('revokeObjectUrl', dart.fn(() => {
62 let blob = createImageBlob();
63 let url = html.Url.createObjectUrlFromBlob(blob);
64 src__matcher__expect.expect(url, src__matcher__string_matchers.startsWit h('blob:'));
65 html.Url.revokeObjectUrl(url);
66 let img = html.ImageElement.new();
67 img[dartx.onError].listen(EventTovoid()._check(unittest$.expectAsync(dar t.fn(_ => {
68 }, dynamicTodynamic()))));
69 img[dartx.onLoad].listen(dart.fn(_ => {
70 src__matcher__expect.fail('URL should not have loaded.');
71 }, EventTovoid$()));
72 img[dartx.src] = url;
73 }, VoidTodynamic()));
74 }, VoidTovoid()));
75 };
76 dart.fn(url_test.main, VoidTodynamic());
77 // Exports:
78 exports.url_test = url_test;
79 });
OLDNEW
« no previous file with comments | « test/codegen/expect/lib/html/uri_test.js ('k') | test/codegen/expect/lib/html/webgl_1_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698