1<!doctype html>
2<!--
3@license
4Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8Code distributed by Google as part of the polymer project is also
9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10-->
11<html>
12<head>
13  <meta charset="UTF-8">
14  <title>paper-progress 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
21  <link rel="import" href="../paper-progress.html">
22  <link rel="import" href="../../test-fixture/test-fixture.html">
23</head>
24<body>
25
26
27  <test-fixture id="trivialProgress">
28    <template>
29      <paper-progress></paper-progress>
30    </template>
31  </test-fixture>
32
33  <test-fixture id="transitingProgress">
34    <template>
35      <paper-progress class="transiting"></paper-progress>
36    </template>
37  </test-fixture>
38
39  <script>
40    suite('basic features', function() {
41      var progress;
42
43      setup(function() {
44        progress = fixture('trivialProgress');
45      });
46
47      test('check default', function() {
48        assert.equal(progress.min, 0);
49        assert.equal(progress.max, 100);
50        assert.equal(progress.value, 0);
51      });
52
53      test('set value', function(done) {
54        progress.value = 50;
55        asyncPlatformFlush(function() {
56          assert.equal(progress.value, 50);
57          // test clamp value
58          progress.value = 60.1;
59          asyncPlatformFlush(function() {
60            assert.equal(progress.value, 60);
61            done();
62          });
63        });
64      });
65
66      test('set max', function(done) {
67        progress.max = 10;
68        progress.value = 11;
69        asyncPlatformFlush(function() {
70          assert.equal(progress.value, progress.max);
71          done();
72        });
73      });
74
75      test('test ratio', function(done) {
76        progress.max = 10;
77        progress.value = 5;
78        asyncPlatformFlush(function() {
79          assert.equal(progress.ratio, 50);
80          done();
81        });
82      });
83
84      test('test secondary ratio', function(done) {
85        progress.max = 10;
86        progress.secondaryProgress = 5;
87        asyncPlatformFlush(function() {
88          assert.equal(progress.secondaryRatio, 50);
89          done();
90        });
91      });
92
93      test('set min', function(done) {
94        progress.min = 10
95        progress.max = 50;
96        progress.value = 30;
97        asyncPlatformFlush(function() {
98          assert.equal(progress.ratio, 50);
99          progress.value = 0;
100          asyncPlatformFlush(function() {
101            assert.equal(progress.value, progress.min);
102            done();
103          });
104        });
105      });
106
107      test('set step', function(done) {
108        progress.min = 0;
109        progress.max = 10;
110        progress.value = 5.1;
111        asyncPlatformFlush(function() {
112          assert.equal(progress.value, 5);
113          progress.step = 0.1;
114          progress.value = 5.1;
115          asyncPlatformFlush(function() {
116            assert.equal(progress.value, 5.1);
117            done();
118          });
119        });
120      });
121    });
122
123    suite('transiting class', function() {
124      var progress;
125
126      setup(function() {
127        progress = fixture('transitingProgress');
128      });
129
130      test('progress bars', function() {
131        var stylesForPrimaryProgress = window.getComputedStyle(progress.$.primaryProgress);
132        var stylesForSecondaryProgress = window.getComputedStyle(progress.$.secondaryProgress);
133        var transitionProp = stylesForPrimaryProgress['transition-property'];
134
135        assert.isTrue(transitionProp === 'transform' || transitionProp === '-webkit-transform');
136        assert.equal(stylesForPrimaryProgress['transition-duration'], '0.08s');
137
138        transitionProp = stylesForSecondaryProgress['transition-property'];
139
140        assert.isTrue(transitionProp === 'transform' || transitionProp === '-webkit-transform');
141        assert.equal(stylesForSecondaryProgress['transition-duration'], '0.08s');
142      });
143    });
144
145  </script>
146
147</body>
148</html>
149