| 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 |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS |
| 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 |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <meta charset="UTF-8"> |
| 14 <title>paper-slider test</title> |
| 15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
| 16 |
| 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 18 <script src="../../web-component-tester/browser.js"></script> |
| 19 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 20 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 21 |
| 22 <link rel="import" href="../paper-slider.html"> |
| 23 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 24 </head> |
| 25 <body> |
| 26 |
| 27 |
| 28 <test-fixture id="trivialProgress"> |
| 29 <template> |
| 30 <paper-slider></paper-slider> |
| 31 </template> |
| 32 </test-fixture> |
| 33 |
| 34 <script> |
| 35 suite('<paper-slider>', function() { |
| 36 var slider; |
| 37 |
| 38 setup(function() { |
| 39 slider = fixture('trivialProgress'); |
| 40 }); |
| 41 |
| 42 test('check default', function() { |
| 43 assert.equal(slider.min, 0); |
| 44 assert.equal(slider.max, 100); |
| 45 assert.equal(slider.value, 0); |
| 46 }); |
| 47 |
| 48 test('set value', function(done) { |
| 49 slider.value = 50; |
| 50 flush(function() { |
| 51 assert.equal(slider.value, 50); |
| 52 // test clamp value |
| 53 slider.value = 60.1; |
| 54 flush(function() { |
| 55 assert.equal(slider.value, 60); |
| 56 done(); |
| 57 }); |
| 58 }); |
| 59 }); |
| 60 |
| 61 test('set max', function(done) { |
| 62 slider.max = 10; |
| 63 slider.value = 11; |
| 64 flush(function() { |
| 65 assert.equal(slider.value, slider.max); |
| 66 done(); |
| 67 }); |
| 68 }); |
| 69 |
| 70 test('ratio', function(done) { |
| 71 slider.max = 10; |
| 72 slider.value = 5; |
| 73 flush(function() { |
| 74 assert.equal(slider.ratio, 0.5); |
| 75 done(); |
| 76 }); |
| 77 }); |
| 78 |
| 79 test('snaps', function(done) { |
| 80 slider.snaps = true; |
| 81 slider.step = 10; |
| 82 slider.max = 100; |
| 83 slider.value = 25; |
| 84 flush(function() { |
| 85 assert.equal(slider.value, 30); |
| 86 |
| 87 slider.value = 51.1; |
| 88 |
| 89 flush(function() { |
| 90 assert.equal(slider.value, 50); |
| 91 slider.snaps = false; |
| 92 slider.step = 1; |
| 93 done(); |
| 94 }); |
| 95 }); |
| 96 }); |
| 97 |
| 98 test('secondary progress', function(done) { |
| 99 slider.max = 10; |
| 100 slider.secondaryProgress = 50; |
| 101 flush(function() { |
| 102 assert.equal(slider.secondaryProgress, slider.max); |
| 103 done(); |
| 104 }); |
| 105 }); |
| 106 |
| 107 test('increment', function(done) { |
| 108 slider.min = 0; |
| 109 slider.max = 10; |
| 110 slider.step = 2; |
| 111 slider.value = 0; |
| 112 slider.increment(); |
| 113 |
| 114 flush(function() { |
| 115 assert.equal(slider.value, slider.step); |
| 116 slider.step = 1; |
| 117 done(); |
| 118 }); |
| 119 }); |
| 120 |
| 121 test('decrement', function(done) { |
| 122 slider.min = 0; |
| 123 slider.max = 10; |
| 124 slider.step = 2; |
| 125 slider.value = 8; |
| 126 slider.decrement(); |
| 127 |
| 128 flush(function() { |
| 129 assert.equal(slider.value, 6); |
| 130 slider.step = 1; |
| 131 done(); |
| 132 }); |
| 133 }); |
| 134 |
| 135 test('editable', function(done) { |
| 136 slider.min = 0; |
| 137 slider.max = 10; |
| 138 slider.step = 1; |
| 139 slider.editable = true; |
| 140 |
| 141 flush(function() { |
| 142 slider.value = 2; |
| 143 assert.equal(slider.$$('#input').value, slider.value); |
| 144 done(); |
| 145 }); |
| 146 }); |
| 147 |
| 148 test('decimal values', function(done) { |
| 149 slider.min = 0; |
| 150 slider.max = 1; |
| 151 slider.value = slider.min; |
| 152 slider.step = 0.1; |
| 153 |
| 154 slider.increment(); |
| 155 |
| 156 flush(function() { |
| 157 assert.equal(slider.value, slider.step); |
| 158 assert.equal(slider.$.sliderBar.value, slider.step); |
| 159 done(); |
| 160 }); |
| 161 }); |
| 162 |
| 163 test('snap to the correct value on tapping', function(done) { |
| 164 var cursor = MockInteractions.topLeftOfNode(slider.$.sliderBar); |
| 165 cursor.x += slider.$.sliderBar.getBoundingClientRect().width * 0.9; |
| 166 |
| 167 slider.min = 0; |
| 168 slider.max = 2; |
| 169 slider.step = 1; |
| 170 slider.value = 0; |
| 171 |
| 172 MockInteractions.down(slider.$.sliderBar, cursor); |
| 173 |
| 174 flush(function() { |
| 175 assert.equal(slider.value, slider.max); |
| 176 slider.step = 1; |
| 177 done(); |
| 178 }); |
| 179 }); |
| 180 |
| 181 }); |
| 182 |
| 183 </script> |
| 184 |
| 185 </body> |
| 186 </html> |
| OLD | NEW |