From 76d323da605fa2be82eb96efb241d130cf08a087 Mon Sep 17 00:00:00 2001 From: Baha Date: Tue, 2 May 2017 17:45:48 -0400 Subject: [PATCH] QA: Test renderer#createThumbnail Bug: T133022 Change-Id: Ia6f4de8cbb7ba3b389fb326007db0f859ae1d80a --- tests/node-qunit/renderer.js | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/node-qunit/renderer.js b/tests/node-qunit/renderer.js index 19e28100b..56fbbce26 100644 --- a/tests/node-qunit/renderer.js +++ b/tests/node-qunit/renderer.js @@ -145,6 +145,58 @@ QUnit.test( 'createEmptyPreview', function ( assert ) { ); } ); +QUnit.test( 'createThumbnail - tall image', function ( assert ) { + var devicePixelRatio = $.bracketedDevicePixelRatio(), + rawThumbnail = { + source: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/8d/President_Barack_Obama.jpg/409px-President_Barack_Obama.jpg', + width: 409, + height: 512 + }, + thumbnail = renderer.createThumbnail( rawThumbnail ); + + assert.equal( + thumbnail.isTall, + true, + 'Thumbnail is tall.' + ); + assert.equal( + thumbnail.width, + thumbnail.width / devicePixelRatio, + 'Thumbnail width is correct.' + ); + assert.equal( + thumbnail.height, + thumbnail.height / devicePixelRatio, + 'Thumbnail height is correct.' + ); +} ); + +QUnit.test( 'createThumbnail - landscape image', function ( assert ) { + var devicePixelRatio = $.bracketedDevicePixelRatio(), + rawThumbnail = { + source: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/8d/President_Barack_Obama.jpg/500px-President_Barack_Obama.jpg', + width: 500, + height: 400 + }, + thumbnail = renderer.createThumbnail( rawThumbnail ); + + assert.equal( + thumbnail.isTall, + false, + 'Thumbnail is not tall.' + ); + assert.equal( + thumbnail.width, + thumbnail.width / devicePixelRatio, + 'Thumbnail width is correct.' + ); + assert.equal( + thumbnail.height, + thumbnail.height / devicePixelRatio, + 'Thumbnail height is correct.' + ); +} ); + QUnit.test( 'createThumbnailElement', function ( assert ) { var className = 'thumb-class', url = 'https://thumbnail.url',