~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-swipeable-container/test/basic.html

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.github.io/LICENSE.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/CONTRIBUTORS.txt
 
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/PATENTS.txt
 
10
-->
 
11
<html>
 
12
<head>
 
13
  <meta charset="UTF-8">
 
14
  <title>iron-swipeable-container tests</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="../../iron-test-helpers/mock-interactions.js"></script>
 
20
 
 
21
  <link rel="import" href="../iron-swipeable-container.html">
 
22
  <link rel="import" href="test-element.html">
 
23
 
 
24
</head>
 
25
<style>
 
26
  div {
 
27
    width: 100px;
 
28
    height: 100px;
 
29
    background-color: blue;
 
30
  }
 
31
</style>
 
32
<body>
 
33
 
 
34
  <test-fixture id="basic">
 
35
    <template>
 
36
      <iron-swipeable-container>
 
37
        <div id="native">Hello</div>
 
38
        <test-element id="custom"></test-element>
 
39
      </iron-swipeable-container>
 
40
    </template>
 
41
  </test-fixture>
 
42
 
 
43
  <test-fixture id="child-no-swipe">
 
44
    <template>
 
45
      <iron-swipeable-container>
 
46
        <div id="native" class="disable-swipe">Hello</div>
 
47
        <test-element id="custom" class="disable-swipe"></test-element>
 
48
      </iron-swipeable-container>
 
49
    </template>
 
50
  </test-fixture>
 
51
 
 
52
 
 
53
  <test-fixture id="no-swipe">
 
54
    <template>
 
55
      <iron-swipeable-container disabled>
 
56
        <div id="native">Hello</div>
 
57
        <test-element id="custom"></test-element>
 
58
      </iron-swipeable-container>
 
59
    </template>
 
60
  </test-fixture>
 
61
 
 
62
  <script>
 
63
 
 
64
    suite('native elements', function() {
 
65
      test('dragging less than halfway does not swipe', function(done) {
 
66
        var container = fixture('basic');
 
67
        var element = container.querySelector('#native');
 
68
 
 
69
        Polymer.Base.async(function() {
 
70
          var swipeEventHandler = sinon.spy();
 
71
          container.addEventListener('iron-swipe', swipeEventHandler);
 
72
 
 
73
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
74
          MockInteractions.track(element, 10, 0);
 
75
 
 
76
          Polymer.Base.async(function(){
 
77
            expect(swipeEventHandler.callCount).to.be.equal(0);
 
78
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
79
            done();
 
80
          }, 1);
 
81
        });
 
82
      });
 
83
 
 
84
      test('dragging more than halfway swipes it', function(done) {
 
85
        var container = fixture('basic');
 
86
        var element = container.querySelector('#native');
 
87
 
 
88
        Polymer.Base.async(function() {
 
89
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
90
 
 
91
          container.addEventListener('iron-swipe', function(event) {
 
92
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(1);
 
93
            done();
 
94
          });
 
95
 
 
96
          MockInteractions.track(element, 60, 0);
 
97
        });
 
98
      });
 
99
 
 
100
      test('an element with disable-swipe cannot be swiped', function(done) {
 
101
        var container = fixture('child-no-swipe');
 
102
        var element = container.querySelector('#native');
 
103
 
 
104
        Polymer.Base.async(function() {
 
105
          var swipeEventHandler = sinon.spy();
 
106
          container.addEventListener('iron-swipe', swipeEventHandler);
 
107
 
 
108
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
109
          MockInteractions.track(element, 60, 0);  // this amount would normally swipe.
 
110
 
 
111
          Polymer.Base.async(function(){
 
112
            expect(swipeEventHandler.callCount).to.be.equal(0);
 
113
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
114
            done();
 
115
          }, 1);
 
116
        });
 
117
      });
 
118
    });
 
119
 
 
120
    suite('custom elements', function() {
 
121
      test('dragging less than halfway does not swipe', function(done) {
 
122
        var container = fixture('basic');
 
123
        var element = container.querySelector('#custom');
 
124
 
 
125
        var swipeEventHandler = sinon.spy();
 
126
        container.addEventListener('iron-swipe', swipeEventHandler);
 
127
 
 
128
        Polymer.Base.async(function() {
 
129
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
130
          MockInteractions.track(element, 10, 0);
 
131
 
 
132
          Polymer.Base.async(function(){
 
133
            expect(swipeEventHandler.callCount).to.be.equal(0);
 
134
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
135
            done();
 
136
          }, 1);
 
137
        });
 
138
      });
 
139
 
 
140
      test('dragging more than halfway swipes it', function(done) {
 
141
        var container = fixture('basic');
 
142
        var element = container.querySelector('#custom');
 
143
 
 
144
        Polymer.Base.async(function() {
 
145
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
146
 
 
147
          container.addEventListener('iron-swipe', function(event) {
 
148
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(1);
 
149
            done();
 
150
          });
 
151
 
 
152
          MockInteractions.track(element, 60, 0);
 
153
        });
 
154
      });
 
155
 
 
156
      test('an element with disable-swipe cannot be swiped', function(done) {
 
157
        var container = fixture('child-no-swipe');
 
158
        var element = container.querySelector('#custom');
 
159
 
 
160
        Polymer.Base.async(function() {
 
161
          var swipeEventHandler = sinon.spy();
 
162
          container.addEventListener('iron-swipe', swipeEventHandler);
 
163
 
 
164
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
165
          MockInteractions.track(element, 60, 0);  // this amount would normally swipe.
 
166
 
 
167
          Polymer.Base.async(function(){
 
168
            expect(swipeEventHandler.callCount).to.be.equal(0);
 
169
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
170
            done();
 
171
          }, 1);
 
172
        });
 
173
      });
 
174
    });
 
175
 
 
176
    suite('no swipe', function() {
 
177
      test('dragging a native element more than halfway does not swipe', function(done) {
 
178
        var container = fixture('no-swipe');
 
179
        var element = container.querySelector('#native');
 
180
 
 
181
        var swipeEventHandler = sinon.spy();
 
182
        container.addEventListener('iron-swipe', swipeEventHandler);
 
183
 
 
184
        Polymer.Base.async(function() {
 
185
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
186
          MockInteractions.track(element, 60, 0);
 
187
 
 
188
          Polymer.Base.async(function(){
 
189
            expect(swipeEventHandler.callCount).to.be.equal(0);
 
190
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
191
            done();
 
192
          }, 1);
 
193
        });
 
194
      });
 
195
 
 
196
      test('dragging a custom element more than halfway does not swipe', function(done) {
 
197
        var container = fixture('no-swipe');
 
198
        var element = container.querySelector('#custom');
 
199
 
 
200
        var swipeEventHandler = sinon.spy();
 
201
        container.addEventListener('iron-swipe', swipeEventHandler);
 
202
 
 
203
        Polymer.Base.async(function() {
 
204
          expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
205
          MockInteractions.track(element, 60, 0);
 
206
 
 
207
          Polymer.Base.async(function(){
 
208
            expect(swipeEventHandler.callCount).to.be.equal(0);
 
209
            expect(Polymer.dom(container).queryDistributedElements('*').length).to.be.equal(2);
 
210
            done();
 
211
          }, 1);
 
212
        });
 
213
      });
 
214
    });
 
215
  </script>
 
216
</body>
 
217
</html>