| 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 --> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // keep toast opened | 193 // keep toast opened |
| 194 toast.duration = 0; | 194 toast.duration = 0; |
| 195 toast.show(); | 195 toast.show(); |
| 196 setTimeout(function() { | 196 setTimeout(function() { |
| 197 assert.isTrue(toast.opened, 'toast is still open'); | 197 assert.isTrue(toast.opened, 'toast is still open'); |
| 198 done(); | 198 done(); |
| 199 }, 10); | 199 }, 10); |
| 200 }, 5); | 200 }, 5); |
| 201 }); | 201 }); |
| 202 | 202 |
| 203 test('toast is positioned according at the bottom left of its fitInto', fu
nction() { | 203 test('toast is positioned according at the bottom left of its fitInto', fu
nction(done) { |
| 204 var f = fixture('contained'); | 204 var f = fixture('contained'); |
| 205 var toast = f[0]; | 205 var toast = f[0]; |
| 206 var container = f[1]; | 206 var container = f[1]; |
| 207 toast.fitInto = container; | 207 toast.fitInto = container; |
| 208 toast.center(); | 208 toast.open(); |
| 209 var style = getComputedStyle(toast); | 209 // Wait for it to be opened, so it will be sized correctly. |
| 210 assert.equal(style.left, '50px', 'left'); | 210 toast.addEventListener('iron-overlay-opened', function() { |
| 211 // Should be 150px from top, (100px of height + 50px of margin-top) | 211 var rect = toast.getBoundingClientRect(); |
| 212 // aka window height - 150 from bottom. | 212 assert.equal(rect.left, 50, 'left ok'); |
| 213 assert.equal(style.bottom, (window.innerHeight - 150) + 'px', 'bottom'); | 213 // 150px from top, (100px of height + 50px of margin-top) |
| 214 assert.equal(rect.bottom, 150, 'bottom'); |
| 215 done(); |
| 216 }); |
| 214 }); | 217 }); |
| 215 | 218 |
| 216 suite('a11y', function() { | 219 suite('a11y', function() { |
| 217 test('show() will announce text', function() { | 220 test('show() will announce text', function() { |
| 218 toast = fixture('basic'); | 221 toast = fixture('basic'); |
| 219 var spy = sinon.spy(toast, 'fire'); | 222 var spy = sinon.spy(toast, 'fire'); |
| 220 toast.text = 'announce!'; | 223 toast.text = 'announce!'; |
| 221 toast.show(); | 224 toast.show(); |
| 222 assert.isTrue(spy.calledWith('iron-announce', { | 225 assert.isTrue(spy.calledWith('iron-announce', { |
| 223 text: 'announce!' | 226 text: 'announce!' |
| 224 }), 'text announced'); | 227 }), 'text announced'); |
| 225 }); | 228 }); |
| 226 | 229 |
| 227 test('hide() will not announce text', function() { | 230 test('hide() will not announce text', function() { |
| 228 toast = fixture('show'); | 231 toast = fixture('show'); |
| 229 var spy = sinon.spy(toast, 'fire'); | 232 var spy = sinon.spy(toast, 'fire'); |
| 230 toast.hide(); | 233 toast.hide(); |
| 231 assert.isFalse(spy.calledWith('iron-announce'), 'text not announced'); | 234 assert.isFalse(spy.calledWith('iron-announce'), 'text not announced'); |
| 232 }); | 235 }); |
| 233 }); | 236 }); |
| 234 | 237 |
| 235 }); | 238 }); |
| 236 </script> | 239 </script> |
| 237 | 240 |
| 238 </body> | 241 </body> |
| 239 | 242 |
| 240 </html> | 243 </html> |
| OLD | NEW |