| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <link rel="import" href="ct-results-comparison-zoomer.html"> | 7 <link rel="import" href="ct-results-comparison-zoomer.html"> |
| 8 | 8 |
| 9 <link rel="import" href="../base/ct-canvas-2d-context-mock.html"> |
| 10 |
| 9 <script> | 11 <script> |
| 10 (function () { | 12 (function () { |
| 11 | 13 |
| 12 module("ct-results-comparison-zoomer"); | 14 module("ct-results-comparison-zoomer"); |
| 13 | 15 |
| 14 asyncTest("no-position", 2, function() { | 16 asyncTest("no-position", 2, function() { |
| 15 var zoomer = document.createElement('ct-results-comparison-zoomer'); | 17 var zoomer = document.createElement('ct-results-comparison-zoomer'); |
| 16 // FIXME: This should set zoomer.position instead, but there's no way | 18 // FIXME: This should set zoomer.position instead, but there's no way |
| 17 // to get between the microtask and requestAnimationFrame to verify the | 19 // to get between the microtask and requestAnimationFrame to verify the |
| 18 // behavior. | 20 // behavior. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 48 } | 50 } |
| 49 | 51 |
| 50 try { | 52 try { |
| 51 zoomer._draw(zoomer.$.diffZoomer); | 53 zoomer._draw(zoomer.$.diffZoomer); |
| 52 ok(true); | 54 ok(true); |
| 53 } catch(e) { | 55 } catch(e) { |
| 54 ok(false); | 56 ok(false); |
| 55 } | 57 } |
| 56 }); | 58 }); |
| 57 | 59 |
| 60 asyncTest("drawCanvas", 1, function() { |
| 61 var zoomer = document.createElement('ct-results-comparison-zoomer'); |
| 62 zoomer.position = {x: 0.2, y: 0.5}; |
| 63 |
| 64 requestAnimationFrame(function() { |
| 65 var canvasContext = new CTCanvas2dContextMock(); |
| 66 zoomer._drawCanvas(canvasContext, zoomer.$.diffZoomer); |
| 67 |
| 68 var expectedContext = new CTCanvas2dContextMock(); |
| 69 expectedContext.imageSmoothingEnabled = false; |
| 70 expectedContext.translate(-960, -1800); |
| 71 expectedContext.strokeRect(-1.5, -1.5, 4802, 3602); |
| 72 expectedContext.scale(6, 6); |
| 73 expectedContext.drawImage(zoomer.shadowRoot.querySelector('img'), 0, 0); |
| 74 deepEqual(canvasContext, expectedContext); |
| 75 start(); |
| 76 }); |
| 77 }); |
| 78 |
| 58 })() | 79 })() |
| 59 </script> | 80 </script> |
| OLD | NEW |