Blame view

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