| 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 <title>paper-button-behavior</title> | 14 <title>paper-ripple-behavior</title> |
| 15 | 15 |
| 16 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 16 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 17 <script src="../../web-component-tester/browser.js"></script> | 17 <script src="../../web-component-tester/browser.js"></script> |
| 18 <script src="../../test-fixture/test-fixture-mocha.js"></script> | 18 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 19 <script src="../../iron-test-helpers/mock-interactions.js"></script> | 19 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 20 | 20 |
| 21 <link rel="import" href="../../polymer/polymer.html"> | 21 <link rel="import" href="../../polymer/polymer.html"> |
| 22 <link rel="import" href="../../test-fixture/test-fixture.html"> | 22 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 23 <link rel="import" href="test-button.html"> | 23 <link rel="import" href="../../iron-behaviors/iron-button-state.html"> |
| 24 <link rel="import" href="../paper-ripple-behavior.html"> |
| 24 </head> | 25 </head> |
| 25 <body> | 26 <body> |
| 26 | 27 |
| 28 <dom-module id="test-ripple"> |
| 29 <template> |
| 30 </template> |
| 31 <script> |
| 32 HTMLImports.whenReady(function() { |
| 33 Polymer({ |
| 34 is: 'test-ripple', |
| 35 behaviors: [ |
| 36 Polymer.IronButtonState, |
| 37 Polymer.IronControlState, |
| 38 Polymer.PaperRippleBehavior |
| 39 ] |
| 40 }); |
| 41 }); |
| 42 </script> |
| 43 </dom-module> |
| 44 |
| 27 <test-fixture id="basic"> | 45 <test-fixture id="basic"> |
| 28 <template> | 46 <template> |
| 29 <test-button></test-button> | 47 <test-ripple></test-ripple> |
| 30 </template> | 48 </template> |
| 31 </test-fixture> | 49 </test-fixture> |
| 32 | 50 |
| 33 <script> | 51 <script> |
| 34 suite('basic', function() { | 52 suite('PaperRippleBehavior', function() { |
| 35 var button; | 53 var ripple; |
| 36 | 54 |
| 37 setup(function() { | 55 setup(function() { |
| 38 button = fixture('basic'); | 56 ripple = fixture('basic'); |
| 39 }); | 57 }); |
| 40 | 58 |
| 41 test('normal (no states)', function() { | 59 test('no ripple at startup', function() { |
| 42 assert.equal(button._elevation, 1); | 60 assert.isFalse(ripple.hasRipple()); |
| 43 }); | 61 }); |
| 44 | 62 |
| 45 test('set disabled property', function() { | 63 test('calling getRipple returns ripple', function() { |
| 46 button.disabled = true; | 64 assert.ok(ripple.getRipple()); |
| 47 assert.equal(button._elevation, 0); | |
| 48 }); | 65 }); |
| 49 | 66 |
| 50 test('pressed and released', function() { | 67 test('focus generates ripple', function() { |
| 51 MockInteractions.down(button); | 68 MockInteractions.focus(ripple); |
| 52 assert.equal(button._elevation, 4); | 69 assert.ok(ripple.hasRipple()); |
| 53 MockInteractions.up(button); | |
| 54 assert.equal(button._elevation, 1); | |
| 55 }); | 70 }); |
| 56 | 71 |
| 57 suite('a button with toggles', function() { | 72 test('down generates ripple', function() { |
| 58 setup(function() { | 73 MockInteractions.down(ripple); |
| 59 button.toggles = true; | 74 assert.ok(ripple.hasRipple()); |
| 60 }); | 75 MockInteractions.up(ripple); |
| 61 | |
| 62 test('activated by tap', function(done) { | |
| 63 MockInteractions.downAndUp(button, function() { | |
| 64 try { | |
| 65 assert.equal(button._elevation, 4); | |
| 66 done(); | |
| 67 } catch (e) { | |
| 68 done(e); | |
| 69 } | |
| 70 }); | |
| 71 }); | |
| 72 }); | 76 }); |
| 73 | 77 |
| 74 test('receives focused', function() { | |
| 75 MockInteractions.focus(button); | |
| 76 assert.equal(button._elevation, 3); | |
| 77 }); | |
| 78 }); | 78 }); |
| 79 </script> | 79 </script> |
| 80 | 80 |
| 81 </body> | 81 </body> |
| 82 </html> | 82 </html> |
| OLD | NEW |