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 | 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 | 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 | 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 | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
10 --> | 10 --> |
11 <html> | 11 <html> |
12 <head> | 12 <head> |
13 <meta charset="UTF-8"> | 13 <meta charset="UTF-8"> |
14 <title>iron-range-behavior</title> | 14 <title>iron-range-behavior</title> |
15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> | 15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
16 | 16 |
17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
18 <script src="../../web-component-tester/browser.js"></script> | 18 <script src="../../web-component-tester/browser.js"></script> |
19 <script src="../../test-fixture/test-fixture-mocha.js"></script> | 19 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
20 | 20 |
21 <link rel="import" href="../iron-range-behavior.html"> | 21 <link rel="import" href="x-progressbar.html"> |
22 <link rel="import" href="../../test-fixture/test-fixture.html"> | 22 <link rel="import" href="../../test-fixture/test-fixture.html"> |
23 </head> | 23 </head> |
24 <body> | 24 <body> |
25 | 25 |
26 <script> | |
27 Polymer({ | |
28 is: 'x-progressbar', | |
29 | |
30 behaviors: [Polymer.IronRangeBehavior] | |
31 }); | |
32 </script> | |
33 | |
34 <test-fixture id="trivialRange"> | 26 <test-fixture id="trivialRange"> |
35 <template> | 27 <template> |
36 <x-progressbar></x-progressbar> | 28 <x-progressbar></x-progressbar> |
37 </template> | 29 </template> |
38 </test-fixture> | 30 </test-fixture> |
39 | 31 |
40 <script> | 32 <script> |
41 suite('<x-progressbar>', function() { | 33 suite('<x-progressbar>', function() { |
42 var range; | 34 var range; |
43 | 35 |
44 setup(function() { | 36 setup(function() { |
45 range = fixture('trivialRange'); | 37 range = fixture('trivialRange'); |
46 }); | 38 }); |
47 | 39 |
48 test('check default', function() { | 40 test('check default', function() { |
49 assert.equal(range.min, 0); | 41 assert.equal(range.min, 0); |
50 assert.equal(range.max, 100); | 42 assert.equal(range.max, 100); |
51 assert.equal(range.value, 0); | 43 assert.equal(range.value, 0); |
52 }); | 44 }); |
53 | 45 |
54 test('set value', function(done) { | 46 test('set value', function(done) { |
55 range.value = 50; | 47 range.value = 50; |
56 asyncPlatformFlush(function() { | 48 flush(function() { |
57 assert.equal(range.value, 50); | 49 assert.equal(range.value, 50); |
58 // test clamp value | 50 // test clamp value |
59 range.value = 60.1; | 51 range.value = 60.1; |
60 asyncPlatformFlush(function() { | 52 flush(function() { |
61 assert.equal(range.value, 60); | 53 assert.equal(range.value, 60); |
62 done(); | 54 done(); |
63 }); | 55 }); |
64 }); | 56 }); |
65 }); | 57 }); |
66 | 58 |
67 test('set max', function(done) { | 59 test('set max', function(done) { |
68 range.max = 10; | 60 range.max = 10; |
69 range.value = 11; | 61 range.value = 11; |
70 asyncPlatformFlush(function() { | 62 flush(function() { |
71 assert.equal(range.value, range.max); | 63 assert.equal(range.value, range.max); |
72 done(); | 64 done(); |
73 }); | 65 }); |
74 }); | 66 }); |
75 | 67 |
76 test('test ratio', function(done) { | 68 test('test ratio', function(done) { |
77 range.max = 10; | 69 range.max = 10; |
78 range.value = 5; | 70 range.value = 5; |
79 asyncPlatformFlush(function() { | 71 flush(function() { |
80 assert.equal(range.ratio, 50); | 72 assert.equal(range.ratio, 50); |
81 done(); | 73 done(); |
82 }); | 74 }); |
83 }); | 75 }); |
84 | 76 |
85 test('set min', function(done) { | 77 test('set min', function(done) { |
86 range.min = 10 | 78 range.min = 10 |
87 range.max = 50; | 79 range.max = 50; |
88 range.value = 30; | 80 range.value = 30; |
89 asyncPlatformFlush(function() { | 81 flush(function() { |
90 assert.equal(range.ratio, 50); | 82 assert.equal(range.ratio, 50); |
91 range.value = 0; | 83 range.value = 0; |
92 asyncPlatformFlush(function() { | 84 flush(function() { |
93 assert.equal(range.value, range.min); | 85 assert.equal(range.value, range.min); |
94 done(); | 86 done(); |
95 }); | 87 }); |
96 }); | 88 }); |
97 }); | 89 }); |
98 | 90 |
99 test('set step', function(done) { | 91 test('set step', function(done) { |
100 range.min = 0; | 92 range.min = 0; |
101 range.max = 10; | 93 range.max = 10; |
102 range.value = 5.1; | 94 range.value = 5.1; |
103 asyncPlatformFlush(function() { | 95 flush(function() { |
104 assert.equal(range.value, 5); | 96 assert.equal(range.value, 5); |
105 range.step = 0.1; | 97 range.step = 0.1; |
106 range.value = 5.1; | 98 range.value = 5.1; |
107 asyncPlatformFlush(function() { | 99 flush(function() { |
108 assert.equal(range.value, 5.1); | 100 assert.equal(range.value, 5.1); |
109 done(); | 101 done(); |
110 }); | 102 }); |
111 }); | 103 }); |
112 }); | 104 }); |
113 | 105 |
| 106 test('odd values', function(done) { |
| 107 range.min = 1; |
| 108 range.max = 7; |
| 109 range.step = 2; |
| 110 range.value = 3; |
| 111 |
| 112 flush(function() { |
| 113 assert.equal(range.value, 3); |
| 114 |
| 115 range.value += range.step; |
| 116 assert.equal(range.value, 5); |
| 117 |
| 118 range.value += range.step; |
| 119 assert.equal(range.value, 7); |
| 120 done(); |
| 121 }); |
| 122 }); |
| 123 |
| 124 test('negative values should round up', function(done) { |
| 125 range.min = -10; |
| 126 range.max = 10; |
| 127 range.step = 0.1; |
| 128 range.value = -8.4252; |
| 129 |
| 130 flush(function() { |
| 131 assert.equal(range.value, -8.4); |
| 132 done(); |
| 133 }); |
| 134 }); |
| 135 |
| 136 test('positive values should round up', function(done) { |
| 137 range.min = 10; |
| 138 range.max = 100; |
| 139 range.step = 0.25; |
| 140 range.value = 19.34567; |
| 141 |
| 142 flush(function() { |
| 143 assert.equal(range.value, 19.25); |
| 144 done(); |
| 145 }); |
| 146 }); |
| 147 |
114 }); | 148 }); |
115 | 149 |
116 </script> | 150 </script> |
117 | 151 |
118 </body> | 152 </body> |
119 </html> | 153 </html> |
OLD | NEW |