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

Unified Diff: Tools/GardeningServer/ui/test/ct-results-comparison-zoomer-tests.html

Issue 464163002: Sheriff-o-Matic: Convert some more ui tests to mocha (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Tools/GardeningServer/ui/test/ct-results-comparison-zoomer-tests.html
diff --git a/Tools/GardeningServer/ui/test/ct-results-comparison-zoomer-tests.html b/Tools/GardeningServer/ui/test/ct-results-comparison-zoomer-tests.html
new file mode 100644
index 0000000000000000000000000000000000000000..746c828273ee56985f9916fed1e8a8c301184f0f
--- /dev/null
+++ b/Tools/GardeningServer/ui/test/ct-results-comparison-zoomer-tests.html
@@ -0,0 +1,68 @@
+<!--
+Copyright 2014 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<link rel="import" href="../ct-results-comparison-zoomer.html">
+
+<link rel="import" href="../../base/ct-canvas-2d-context-mock.html">
+
+<script>
+(function () {
+
+var assert = chai.assert;
+
+describe('ct-results-comparison-zoomer', function() {
+ var zoomer;
+
+ beforeEach(function(done) {
+ zoomer = document.createElement('ct-results-comparison-zoomer');
+ setTimeout(done);
+ });
+
+ it('should draw after position is changed', function(done) {
+ // FIXME: This should set zoomer.position instead, but there's no way
+ // to get between the microtask and requestAnimationFrame to verify the
+ // behavior.
+ zoomer.positionChanged();
+ assert(zoomer._drawScheduled);
+
+ requestAnimationFrame(function() {
+ assert(!zoomer._drawScheduled);
+ done();
+ });
+ });
+
+ it('draw', function() {
+ zoomer._drawAll();
+
+ // FIXME: Use a proper model class instead of a dumb object.
+ zoomer.position = {x: 0, y: 0};
+ zoomer._drawAll();
+
+ zoomer._draw(zoomer.$.diffZoomer);
+ });
+
+ it('drawCanvas', function(done) {
+ zoomer.position = {x: 0.2, y: 0.5};
+
+ setTimeout(function() {
+ var canvasContext = new CTCanvas2dContextMock();
+ zoomer._drawCanvas(canvasContext, zoomer.$.diffZoomer);
+
+ var expectedContext = new CTCanvas2dContextMock();
+ expectedContext.imageSmoothingEnabled = false;
+ expectedContext.translate(-960, -1800);
+ expectedContext.strokeRect(-1.5, -1.5, 4802, 3602);
+ expectedContext.scale(6, 6);
+ expectedContext.drawImage(zoomer.shadowRoot.querySelector('img'), 0, 0);
+ assert.deepEqual(canvasContext, expectedContext);
+
+ done();
+ });
+ });
+});
+
+})();
+</script>

Powered by Google App Engine
This is Rietveld 408576698