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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 </test-fixture> | 56 </test-fixture> |
57 | 57 |
58 <test-fixture id="NoinkTarget"> | 58 <test-fixture id="NoinkTarget"> |
59 <template> | 59 <template> |
60 <div id="RippleContainer"> | 60 <div id="RippleContainer"> |
61 <paper-ripple noink></paper-ripple> | 61 <paper-ripple noink></paper-ripple> |
62 </div> | 62 </div> |
63 </template> | 63 </template> |
64 </test-fixture> | 64 </test-fixture> |
65 | 65 |
| 66 <test-fixture id="NoRipple"> |
| 67 <template> |
| 68 <div id="RippleContainer"> |
| 69 </div> |
| 70 </template> |
| 71 </test-fixture> |
| 72 |
66 <script> | 73 <script> |
67 suite('<paper-ripple>', function () { | 74 suite('<paper-ripple>', function () { |
68 var mouseEvent; | 75 var mouseEvent; |
69 var rippleContainer; | 76 var rippleContainer; |
70 var ripple; | 77 var ripple; |
71 | 78 |
72 suite('when tapped', function () { | 79 suite('when tapped', function () { |
73 setup(function () { | 80 setup(function () { |
74 rippleContainer = fixture('TrivialRipple'); | 81 rippleContainer = fixture('TrivialRipple'); |
75 ripple = rippleContainer.firstElementChild; | 82 ripple = rippleContainer.firstElementChild; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 expect(ripple.ripples.length).to.be.eql(0); | 130 expect(ripple.ripples.length).to.be.eql(0); |
124 }); | 131 }); |
125 | 132 |
126 test('ripples can be manually created', function () { | 133 test('ripples can be manually created', function () { |
127 expect(ripple.ripples.length).to.be.eql(0); | 134 expect(ripple.ripples.length).to.be.eql(0); |
128 ripple.simulatedRipple() | 135 ripple.simulatedRipple() |
129 expect(ripple.ripples.length).to.be.eql(1); | 136 expect(ripple.ripples.length).to.be.eql(1); |
130 }); | 137 }); |
131 }); | 138 }); |
132 | 139 |
133 | |
134 | |
135 suite('with the `center` attribute set to true', function () { | 140 suite('with the `center` attribute set to true', function () { |
136 setup(function () { | 141 setup(function () { |
137 rippleContainer = fixture('CenteringRipple'); | 142 rippleContainer = fixture('CenteringRipple'); |
138 ripple = rippleContainer.firstElementChild; | 143 ripple = rippleContainer.firstElementChild; |
139 }); | 144 }); |
140 | 145 |
141 test('ripples will center', function (done) { | 146 test('ripples will center', function (done) { |
142 var waveContainerElement; | 147 var waveContainerElement; |
143 // let's ask the browser what `translate3d(0px, 0px, 0)` will actually
look like | 148 // let's ask the browser what `translate3d(0px, 0px, 0)` will actually
look like |
144 var div = document.createElement('div'); | 149 var div = document.createElement('div'); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 expect(waveContainerElement.style.transform).to.be.ok; | 189 expect(waveContainerElement.style.transform).to.be.ok; |
185 expect(waveContainerElement.style.transform).to.not.be.eql(waveTra
nslateString); | 190 expect(waveContainerElement.style.transform).to.not.be.eql(waveTra
nslateString); |
186 done(); | 191 done(); |
187 } catch (e) { | 192 } catch (e) { |
188 done(e); | 193 done(e); |
189 } | 194 } |
190 }); | 195 }); |
191 }); | 196 }); |
192 }); | 197 }); |
193 | 198 |
| 199 suite('remove a paper ripple', function () { |
| 200 setup(function () { |
| 201 rippleContainer = fixture('NoRipple'); |
| 202 }); |
| 203 test('add and remove a paper-ripple', function (done) { |
| 204 var ripple = document.createElement('paper-ripple'); |
| 205 ripple.addEventListener('transitionend', function() { |
| 206 expect(ripple.parentNode).to.be.ok; |
| 207 Polymer.dom(rippleContainer).removeChild(ripple); |
| 208 done(); |
| 209 }); |
| 210 Polymer.dom(rippleContainer).appendChild(ripple); |
| 211 ripple.downAction(); |
| 212 ripple.upAction(); |
| 213 }); |
| 214 test('reuse a paper-ripple', function (done) { |
| 215 var ripple = document.createElement('paper-ripple'); |
| 216 Polymer.dom(rippleContainer).appendChild(ripple); |
| 217 Polymer.dom(rippleContainer).removeChild(ripple); |
| 218 |
| 219 ripple.addEventListener('transitionend', function() { |
| 220 expect(ripple.parentNode).to.be.ok; |
| 221 Polymer.dom(document.body).removeChild(ripple); |
| 222 done(); |
| 223 }); |
| 224 Polymer.dom(document.body).appendChild(ripple); |
| 225 ripple.downAction(); |
| 226 ripple.upAction(); |
| 227 }); |
| 228 }); |
| 229 |
| 230 suite('avoid double transitionend event', function () { |
| 231 setup(function () { |
| 232 rippleContainer = fixture('NoRipple'); |
| 233 }); |
| 234 test('the transitionend event should only fire once', function (done) { |
| 235 var ripple = document.createElement('paper-ripple'); |
| 236 var transitionedEventCount = 0; |
| 237 ripple.addEventListener('transitionend', function() { |
| 238 ++transitionedEventCount; |
| 239 expect(transitionedEventCount).to.be.eql(1); |
| 240 Polymer.dom(rippleContainer).removeChild(ripple); |
| 241 setTimeout(function() { done(); }); |
| 242 }); |
| 243 Polymer.dom(rippleContainer).appendChild(ripple); |
| 244 ripple.downAction(); |
| 245 ripple.upAction(); |
| 246 }); |
| 247 }); |
| 248 |
194 }); | 249 }); |
195 </script> | 250 </script> |
196 | 251 |
197 </body> | 252 </body> |
198 </html> | 253 </html> |
OLD | NEW |