OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 @license | 3 @license |
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 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 | 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 | 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 | 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 | 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 | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
10 --> | 10 --> |
11 | 11 |
12 <html> | 12 <html> |
13 <head> | 13 <head> |
14 | 14 |
15 <title>iron-icon</title> | 15 <title>iron-icon</title> |
16 <meta charset="utf-8"> | 16 <meta charset="utf-8"> |
17 <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 17 <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
18 | 18 |
19 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 19 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
20 <script src="../../web-component-tester/browser.js"></script> | 20 <script src="../../web-component-tester/browser.js"></script> |
21 <script src="../../test-fixture/test-fixture-mocha.js"></script> | 21 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
22 | 22 |
23 <link rel="import" href="../iron-icon.html"> | 23 <link rel="import" href="../iron-icon.html"> |
24 <link rel="import" href="../../iron-iconset/iron-iconset.html"> | 24 <link rel="import" href="../../iron-iconset/iron-iconset.html"> |
| 25 <link rel="import" href="../../promise-polyfill/promise-polyfill.html"> |
25 <link rel="import" href="../../test-fixture/test-fixture.html"> | 26 <link rel="import" href="../../test-fixture/test-fixture.html"> |
26 | 27 |
27 </head> | 28 </head> |
28 <body> | 29 <body> |
29 | 30 |
30 <test-fixture id="TrivialIcon"> | 31 <test-fixture id="TrivialIcon"> |
31 <template> | 32 <template> |
32 <iron-icon src="../demo/location.png"></iron-icon> | 33 <iron-icon src="../demo/location.png"></iron-icon> |
33 </template> | 34 </template> |
34 </test-fixture> | 35 </test-fixture> |
35 | 36 |
36 <test-fixture id="IconFromIconset"> | 37 <test-fixture id="IconFromIconset"> |
37 <template> | 38 <template> |
38 <iron-iconset name="example" icons="location blank" src="location.png" siz
e="24" width="48"></iron-iconset> | 39 <iron-iconset name="example" icons="location blank" src="location.png" siz
e="24" width="48"></iron-iconset> |
39 <iron-icon icon="example:location"></iron-icon> | 40 <iron-icon icon="example:location"></iron-icon> |
40 </template> | 41 </template> |
41 </test-fixture> | 42 </test-fixture> |
42 | 43 |
43 <test-fixture id="WithoutAnIconSource"> | 44 <test-fixture id="WithoutAnIconSource"> |
44 <template> | 45 <template> |
45 <iron-icon icon=""></iron-icon> | 46 <iron-icon icon=""></iron-icon> |
46 <iron-icon></iron-icon> | 47 <iron-icon></iron-icon> |
47 <iron-icon src=""></iron-icon> | 48 <iron-icon src=""></iron-icon> |
48 </template> | 49 </template> |
49 </test-fixture> | 50 </test-fixture> |
50 | 51 |
| 52 <test-fixture id="UsingAsyncIconset"> |
| 53 <template> |
| 54 <iron-icon icon="async:location"></iron-icon> |
| 55 </template> |
| 56 </test-fixture> |
| 57 |
| 58 <test-fixture id="AsyncIconset"> |
| 59 <template> |
| 60 <iron-iconset name="async" icons="location blank" src="location.png" size=
"24" width="48"></iron-iconset> |
| 61 </template> |
| 62 </test-fixture> |
| 63 |
51 <script> | 64 <script> |
52 function iconElementFor (node) { | 65 function iconElementFor (node) { |
53 var nodes = Polymer.dom(node.root).childNodes; | 66 var nodes = Polymer.dom(node.root).childNodes; |
54 | 67 |
55 for (var i = 0; i < nodes.length; ++i) { | 68 for (var i = 0; i < nodes.length; ++i) { |
56 if (nodes[i].nodeName.match(/DIV|IMG/)) { | 69 if (nodes[i].nodeName.match(/DIV|IMG/)) { |
57 return nodes[i]; | 70 return nodes[i]; |
58 } | 71 } |
59 } | 72 } |
60 } | 73 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 expect(style.backgroundPosition).to.match(/-24px 0(%|px)/); | 119 expect(style.backgroundPosition).to.match(/-24px 0(%|px)/); |
107 }); | 120 }); |
108 }); | 121 }); |
109 | 122 |
110 suite('when no icon source is provided', function() { | 123 suite('when no icon source is provided', function() { |
111 test('will politely wait for an icon source without throwing', function() { | 124 test('will politely wait for an icon source without throwing', function() { |
112 document.createElement('iron-icon'); | 125 document.createElement('iron-icon'); |
113 fixture('WithoutAnIconSource'); | 126 fixture('WithoutAnIconSource'); |
114 }); | 127 }); |
115 }) | 128 }) |
| 129 |
| 130 suite('when loading async', function() { |
| 131 test('will get icon after iconset is added', function() { |
| 132 var icon = fixture('UsingAsyncIconset'); |
| 133 expect(hasIcon(icon)).to.be.false; |
| 134 return new Promise(function(resolve, reject) { |
| 135 window.addEventListener('iron-iconset-added', function() { |
| 136 if (hasIcon(icon)) { |
| 137 resolve(); |
| 138 } else { |
| 139 reject(new Error('icon didn\'t load after iconset loaded')); |
| 140 } |
| 141 }); |
| 142 fixture('AsyncIconset'); |
| 143 }); |
| 144 }); |
| 145 }); |
116 }); | 146 }); |
117 </script> | 147 </script> |
118 | 148 |
119 </body> | 149 </body> |
120 </html> | 150 </html> |
OLD | NEW |