~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/paper-behaviors/test/paper-button-behavior.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
 
 
12
<html>
 
13
<head>
 
14
  <title>paper-button-behavior</title>
 
15
 
 
16
  <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
 
17
  <script src="../../web-component-tester/browser.js"></script>
 
18
  <script src="../../test-fixture/test-fixture-mocha.js"></script>
 
19
  <script src="../../iron-test-helpers/mock-interactions.js"></script>
 
20
 
 
21
  <link rel="import" href="../../polymer/polymer.html">
 
22
  <link rel="import" href="../../test-fixture/test-fixture.html">
 
23
  <link rel="import" href="test-button.html">
 
24
</head>
 
25
<body>
 
26
 
 
27
  <test-fixture id="basic">
 
28
    <template>
 
29
      <test-button></test-button>
 
30
    </template>
 
31
  </test-fixture>
 
32
 
 
33
  <script>
 
34
    suite('basic', function() {
 
35
      var button;
 
36
 
 
37
      setup(function() {
 
38
        button = fixture('basic');
 
39
      });
 
40
 
 
41
      test('normal (no states)', function() {
 
42
        assert.equal(button.elevation, 1);
 
43
      });
 
44
 
 
45
      test('set disabled property', function() {
 
46
        button.disabled = true;
 
47
        assert.equal(button.elevation, 0);
 
48
      });
 
49
 
 
50
      test('pressed and released', function() {
 
51
        MockInteractions.down(button);
 
52
        assert.equal(button.elevation, 4);
 
53
        MockInteractions.up(button);
 
54
        assert.equal(button.elevation, 1);
 
55
        assert.ok(button.hasRipple());
 
56
      });
 
57
 
 
58
      suite('a button with toggles', function() {
 
59
        setup(function() {
 
60
          button.toggles = true;
 
61
        });
 
62
 
 
63
        test('activated by tap', function(done) {
 
64
          MockInteractions.downAndUp(button, function() {
 
65
            try {
 
66
              assert.equal(button.elevation, 4);
 
67
              assert.ok(button.hasRipple());
 
68
              done();
 
69
            } catch (e) {
 
70
              done(e);
 
71
            }
 
72
          });
 
73
        });
 
74
      });
 
75
 
 
76
      test('receives focused', function() {
 
77
        MockInteractions.focus(button);
 
78
        assert.equal(button.elevation, 3);
 
79
        assert.ok(button.hasRipple());
 
80
      });
 
81
 
 
82
      test('space key', function(done) {
 
83
        const SPACE_KEY_CODE = 32;
 
84
        var ripple;
 
85
        MockInteractions.focus(button);
 
86
 
 
87
        assert.ok(button.hasRipple());
 
88
 
 
89
        ripple = button.getRipple();
 
90
        MockInteractions.keyDownOn(button, SPACE_KEY_CODE);
 
91
 
 
92
        assert.equal(ripple.ripples.length, 1);
 
93
 
 
94
        MockInteractions.keyDownOn(button, SPACE_KEY_CODE);
 
95
 
 
96
        assert.equal(ripple.ripples.length, 1);
 
97
 
 
98
        MockInteractions.keyUpOn(button, SPACE_KEY_CODE);
 
99
 
 
100
        var transitionEndCalled = false;
 
101
        ripple.addEventListener('transitionend', function() {
 
102
          if (!transitionEndCalled) {
 
103
            transitionEndCalled = true;
 
104
            assert.equal(ripple.ripples.length, 0);
 
105
            done();
 
106
          }
 
107
        });
 
108
      });
 
109
    });
 
110
  </script>
 
111
 
 
112
</body>
 
113
</html>