~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-label/test/events.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 lang="en">
 
12
  <head>
 
13
    <meta charset="UTF-8">
 
14
    <title>iron-label event tests</title>
 
15
    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
 
16
    <script src="../../web-component-tester/browser.js"></script>
 
17
    <script src="../../test-fixture/test-fixture-mocha.js"></script>
 
18
    <link rel="import" href="../../test-fixture/test-fixture.html">
 
19
    <link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
 
20
 
 
21
    <link rel="import" href="../iron-label.html">
 
22
  </head>
 
23
  <body>
 
24
 
 
25
    <test-fixture id="Inside">
 
26
      <template>
 
27
        <iron-label id="inside">
 
28
          TEXT <input type="checkbox">
 
29
        </iron-label>
 
30
      </template>
 
31
    </test-fixture>
 
32
 
 
33
    <test-fixture id="Outside">
 
34
      <template>
 
35
        <iron-label id="outside" for="outside-checkbox">
 
36
          TEXT
 
37
        </iron-label>
 
38
        <input id="outside-checkbox" type="checkbox">
 
39
      </template>
 
40
    </test-fixture>
 
41
 
 
42
    <test-fixture id="Reordered">
 
43
      <template>
 
44
        <iron-label id="reordered">
 
45
          <span>TEXT</span>
 
46
          <input iron-label-target type="checkbox">
 
47
        </iron-label>
 
48
      </template>
 
49
    </test-fixture>
 
50
 
 
51
    <script>
 
52
      suite('event handling', function() {
 
53
 
 
54
        suite('target inside', function() {
 
55
          var inside, target;
 
56
          setup(function() {
 
57
            inside = fixture('Inside');
 
58
            target = inside.firstElementChild;
 
59
          });
 
60
 
 
61
          test('target has aria-labelledby', function() {
 
62
            var label = target.getAttribute('aria-labelledby');
 
63
            assert.equal(label, 'inside');
 
64
          });
 
65
 
 
66
          test('tap on label goes to the target', function() {
 
67
            var count = 0;
 
68
            Polymer.Gestures.add(target, 'tap', function() {
 
69
              count++;
 
70
            });
 
71
            MockInteractions.tap(inside);
 
72
            assert.equal(count, 1);
 
73
          });
 
74
 
 
75
          test('tap on target does not recurse', function() {
 
76
            var count = 0;
 
77
            Polymer.Gestures.add(target, 'tap', function() {
 
78
              count++;
 
79
            });
 
80
            MockInteractions.tap(target);
 
81
            assert.equal(count, 1);
 
82
          });
 
83
 
 
84
          test('tap on label will "activate" target', function() {
 
85
            target.checked = false;
 
86
            MockInteractions.tap(inside);
 
87
            assert.equal(target.checked, true);
 
88
          });
 
89
        });
 
90
 
 
91
        suite('target outside', function() {
 
92
          var outside, target;
 
93
          setup(function() {
 
94
            var temp = fixture('Outside');
 
95
            outside = temp[0];
 
96
            target = temp[1];
 
97
          });
 
98
 
 
99
          test('target has aria-labelledby', function() {
 
100
            var label = target.getAttribute('aria-labelledby');
 
101
            assert.equal(label, 'outside');
 
102
          });
 
103
 
 
104
          test('tap on label goes to the target', function() {
 
105
            var count = 0;
 
106
            Polymer.Gestures.add(target, 'tap', function() {
 
107
              count++;
 
108
            });
 
109
            MockInteractions.tap(outside);
 
110
            assert.equal(count, 1);
 
111
          });
 
112
 
 
113
          test('tap on label will "activate" target', function() {
 
114
            target.checked = false;
 
115
            MockInteractions.tap(outside);
 
116
            assert.equal(target.checked, true);
 
117
          });
 
118
        });
 
119
 
 
120
        suite('target by reordered', function() {
 
121
          var reordered, target;
 
122
          setup(function() {
 
123
            reordered = fixture('Reordered');
 
124
            target =
 
125
              Polymer.dom(reordered).querySelector('[iron-label-target]');
 
126
          });
 
127
 
 
128
          test('target has aria-labelledby', function() {
 
129
            var label = target.getAttribute('aria-labelledby');
 
130
            assert.equal(label, 'reordered');
 
131
          });
 
132
 
 
133
          test('tap on label goes to the target', function() {
 
134
            var count = 0;
 
135
            Polymer.Gestures.add(target, 'tap', function() {
 
136
              count++;
 
137
            });
 
138
            MockInteractions.tap(reordered);
 
139
            assert.equal(count, 1);
 
140
          });
 
141
 
 
142
          test('tap on label will "activate" target', function() {
 
143
            target.checked = false;
 
144
            MockInteractions.tap(reordered);
 
145
            assert.equal(target.checked, true);
 
146
          });
 
147
        });
 
148
 
 
149
      });
 
150
    </script>
 
151
 
 
152
  </body>
 
153
</html>