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
4 found in the LICENSE file.
7 <link rel="import" href="../ct-results-comparison-zoomer.html">
9 <link rel="import" href="../../base/ct-canvas-2d-context-mock.html">
14 var assert = chai.assert;
16 describe('ct-results-comparison-zoomer', function() {
19 beforeEach(function(done) {
20 zoomer = document.createElement('ct-results-comparison-zoomer');
24 it('should draw after position is changed', function(done) {
25 // FIXME: This should set zoomer.position instead, but there's no way
26 // to get between the microtask and requestAnimationFrame to verify the
28 zoomer.positionChanged();
29 assert(zoomer._drawScheduled);
31 requestAnimationFrame(function() {
32 assert(!zoomer._drawScheduled);
37 it('draw', function() {
40 // FIXME: Use a proper model class instead of a dumb object.
41 zoomer.position = {x: 0, y: 0};
44 zoomer._draw(zoomer.$.diffZoomer);
47 it('drawCanvas', function(done) {
48 zoomer.position = {x: 0.2, y: 0.5};
50 setTimeout(function() {
51 var canvasContext = new CTCanvas2dContextMock();
52 zoomer._drawCanvas(canvasContext, zoomer.$.diffZoomer);
54 var expectedContext = new CTCanvas2dContextMock();
55 expectedContext.imageSmoothingEnabled = false;
56 expectedContext.translate(-960, -1800);
57 expectedContext.strokeRect(-1.5, -1.5, 4802, 3602);
58 expectedContext.scale(6, 6);
59 expectedContext.drawImage(zoomer.shadowRoot.querySelector('img'), 0, 0);
60 assert.deepEqual(canvasContext, expectedContext);