(file, sketch)
| 10 | * and checks that they are exactly the same. Sends result to the callback. |
| 11 | */ |
| 12 | var testImageRender = function(file, sketch) { |
| 13 | sketch.loadPixels(); |
| 14 | var p = sketch.pixels; |
| 15 | var ctx = sketch; |
| 16 | |
| 17 | sketch.clear(); |
| 18 | |
| 19 | return new Promise(function(resolve, reject) { |
| 20 | sketch.loadImage(file, resolve, reject); |
| 21 | }).then(function(img) { |
| 22 | ctx.image(img, 0, 0); |
| 23 | |
| 24 | ctx.loadPixels(); |
| 25 | var n = 0; |
| 26 | for (var i = 0; i < p.length; i++) { |
| 27 | var diff = Math.abs(p[i] - ctx.pixels[i]); |
| 28 | n += diff; |
| 29 | } |
| 30 | var same = n === 0 && ctx.pixels.length === p.length; |
| 31 | return same; |
| 32 | }); |
| 33 | }; |
| 34 | |
| 35 | suite('loading images', function() { |
| 36 | const imagePath = '/test/unit/assets/cat.jpg'; |
nothing calls this directly
no test coverage detected