From 6bcb3932327c91db524071766f34142223329b05 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sun, 17 Mar 2013 16:34:05 +0100 Subject: [PATCH] Improve Raster comparison in compareItems test helper. --- test/lib/helpers.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/lib/helpers.js b/test/lib/helpers.js index f0f1f865..4c4cf666 100644 --- a/test/lib/helpers.js +++ b/test/lib/helpers.js @@ -324,21 +324,18 @@ function compareItems(item, item2, cloned, checkIdentity, dontShareProject) { // Raster specific if (item instanceof Raster) { - // TODO: remove access of private fields: - if (item._canvas) { - if (checkIdentity) { - equals(function() { - return item._canvas !== item2._canvas; - }, true); - } + equals(item.size.toString(), item2.size.toString(), + 'Compare Raster#size'); + compareNumbers(item.width, item2.width, 'Compare Raster#width'); + compareNumbers(item.height, item2.height, 'Compare Raster#height'); + compareNumbers(item.ppi, item2.ppi, 'Compare Raster#ppi'); + equals(item.source, item2.source, 'Compare Raster#source'); + if (checkIdentity) { + equals(item.image, item2.image, 'Compare Raster#image'); } - if (item._image) { - equals(function() { - return item._image == item2._image; - }, true); - } - equals(item._size.toString(), item2._size.toString(), - 'Compare Item#size'); + equals(item.size.toString(), item2.size.toString(), + 'Compare Raster#size'); + equals(item.toDataURL() == item2.toDataURL(), true, 'Compare Raster#toDataUrl()') } // TextItem specific: @@ -402,7 +399,7 @@ function testExportImportJson(project) { var project2 = new Project(); project2.activeLayer.remove(); project2.importJson(json); - compareProjects(project, project2); + compareProjects(project2, project); } // SVG