OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 8 Code distributed by Google as part of the polymer project is also |
| 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <title>iron-image</title> |
| 14 |
| 15 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 16 <script src="../../web-component-tester/browser.js"></script> |
| 17 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 18 |
| 19 <link rel="import" href="../../polymer/polymer.html"> |
| 20 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 21 <link rel="import" href="../iron-image.html"> |
| 22 </head> |
| 23 <body> |
| 24 <test-fixture id="TrivialImage"> |
| 25 <template> |
| 26 <iron-image></iron-image> |
| 27 </template> |
| 28 </test-fixture> |
| 29 <script> |
| 30 suite('<iron-image>', function() { |
| 31 function randomImageUrl () { |
| 32 return '../demo/polymer.svg?' + Math.random(); |
| 33 } |
| 34 |
| 35 var image; |
| 36 |
| 37 suite('basic behavior', function() { |
| 38 setup(function() { |
| 39 image = fixture('TrivialImage'); |
| 40 }); |
| 41 |
| 42 test('can load images given a src', function(done) { |
| 43 image.addEventListener('loaded-changed', function onLoadedChanged()
{ |
| 44 image.removeEventListener('loaded-changed', onLoadedChanged); |
| 45 |
| 46 try { |
| 47 expect(image.loaded).to.be.eql(true); |
| 48 done(); |
| 49 } catch (e) { |
| 50 done(e); |
| 51 } |
| 52 }); |
| 53 image.src = randomImageUrl(); |
| 54 }); |
| 55 |
| 56 test('will reload images when src changes', function(done) { |
| 57 var loadCount = 0; |
| 58 |
| 59 image.addEventListener('loaded-changed', function onLoadedChanged()
{ |
| 60 if (image.loaded === true) { |
| 61 loadCount++; |
| 62 |
| 63 if (loadCount === 2) { |
| 64 done(); |
| 65 } else { |
| 66 image.src = randomImageUrl(); |
| 67 image.removeEventListener('loaded-changed', onLoadedChanged); |
| 68 } |
| 69 } |
| 70 }); |
| 71 |
| 72 image.src = randomImageUrl(); |
| 73 }); |
| 74 }); |
| 75 }); |
| 76 </script> |
| 77 </body> |
| 78 </html> |
OLD | NEW |