From 39bd3709309616ed8240dacc453f56e2813b221a Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Mon, 27 Apr 2015 19:28:18 -0400 Subject: [PATCH] Add opacity test in tiledimage. --- test/modules/tiledimage.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/modules/tiledimage.js b/test/modules/tiledimage.js index 704f4773..07f23f55 100644 --- a/test/modules/tiledimage.js +++ b/test/modules/tiledimage.js @@ -220,4 +220,41 @@ }); }); + // ---------- + asyncTest('opacity', function() { + + function testDefaultOpacity() { + viewer.removeHandler('open', testDefaultOpacity); + var image = viewer.world.getItemAt(0); + strictEqual(image.getOpacity(), 0.5, 'image has default opacity'); + + image.setOpacity(1); + strictEqual(image.getOpacity(), 1, 'opacity is set correctly'); + + viewer.addHandler('open', testTileSourceOpacity); + viewer.open({ + tileSource: '/test/data/testpattern.dzi', + opacity: 0.25 + }); + } + + function testTileSourceOpacity() { + viewer.removeHandler('open', testTileSourceOpacity); + var image = viewer.world.getItemAt(0); + strictEqual(image.getOpacity(), 0.25, 'image has correct opacity'); + + image.setOpacity(0); + strictEqual(image.getOpacity(), 0, 'opacity is set correctly'); + + start(); + } + + viewer.addHandler('open', testDefaultOpacity); + + viewer.opacity = 0.5; + viewer.open({ + tileSource: '/test/data/testpattern.dzi', + }); + }); + })();