~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-menu-behavior/test/iron-menubar-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
<html>
 
12
  <head>
 
13
 
 
14
    <title>iron-menubar-behavior tests</title>
 
15
 
 
16
    <meta charset="utf-8">
 
17
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 
18
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
 
19
 
 
20
    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
 
21
    <script src="../../web-component-tester/browser.js"></script>
 
22
    <link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
 
23
    <link rel="import" href="test-menubar.html">
 
24
 
 
25
  </head>
 
26
  <body>
 
27
 
 
28
    <test-fixture id="basic">
 
29
      <template>
 
30
        <test-menubar>
 
31
          <div>item 1</div>
 
32
          <div>item 2</div>
 
33
          <div>item 3</div>
 
34
        </test-menubar>
 
35
      </template>
 
36
    </test-fixture>
 
37
 
 
38
    <test-fixture id="multi">
 
39
      <template>
 
40
        <test-menubar multi>
 
41
          <div>item 1</div>
 
42
          <div>item 2</div>
 
43
          <div>item 3</div>
 
44
        </test-menubar>
 
45
      </template>
 
46
    </test-fixture>
 
47
 
 
48
    <test-fixture id="rtl">
 
49
      <template>
 
50
        <div dir="rtl">
 
51
          <test-menubar>
 
52
            <div>item 1</div>
 
53
            <div>item 2</div>
 
54
            <div>item 3</div>
 
55
          </test-menubar>
 
56
        </div>
 
57
      </template>
 
58
    </test-fixture>
 
59
 
 
60
    <script>
 
61
 
 
62
      suite('menubar a11y tests', function() {
 
63
 
 
64
        test('menubar has role="menubar"', function() {
 
65
          var menubar = fixture('basic');
 
66
          assert.equal(menubar.getAttribute('role'), 'menubar', 'has role="menubar"');
 
67
        });
 
68
 
 
69
        test('first item gets focus when menubar is focused', function(done) {
 
70
          var menubar = fixture('basic');
 
71
          MockInteractions.focus(menubar);
 
72
          Polymer.Base.async(function() {
 
73
            assert.equal(Polymer.dom(document).activeElement, menubar.firstElementChild, 'document.activeElement is first item')
 
74
            done();
 
75
          });
 
76
        });
 
77
 
 
78
        test('selected item gets focus when menubar is focused', function(done) {
 
79
          var menubar = fixture('basic');
 
80
          menubar.selected = 1;
 
81
          MockInteractions.focus(menubar);
 
82
          Polymer.Base.async(function() {
 
83
            assert.equal(Polymer.dom(document).activeElement, menubar.selectedItem, 'document.activeElement is selected item');
 
84
            done();
 
85
          });
 
86
        });
 
87
 
 
88
        test('focusing non-item content does not auto-focus an item', function(done) {
 
89
          var menubar = fixture('basic');
 
90
          menubar.extraContent.focus();
 
91
          Polymer.Base.async(function() {
 
92
            var ownerRoot = Polymer.dom(menubar.extraContent).getOwnerRoot() || document;
 
93
            var activeElement = Polymer.dom(ownerRoot).activeElement;
 
94
            assert.equal(activeElement, menubar.extraContent, 'menubar.extraContent is focused');
 
95
            assert.equal(Polymer.dom(document).activeElement, menubar, 'menubar is document.activeElement');
 
96
            done();
 
97
          });
 
98
        });
 
99
 
 
100
        test('last activated item in a multi select menubar is focused', function(done) {
 
101
          var menubar = fixture('multi');
 
102
          menubar.selected = 0;
 
103
          menubar.items[1].click();
 
104
          Polymer.Base.async(function() {
 
105
            assert.equal(Polymer.dom(document).activeElement, menubar.items[1], 'document.activeElement is last activated item');
 
106
            done();
 
107
          });
 
108
        });
 
109
 
 
110
        test('deselection in a multi select menubar focuses deselected item', function(done) {
 
111
          var menubar = fixture('multi');
 
112
          menubar.selected = 0;
 
113
          menubar.items[0].click();
 
114
          Polymer.Base.async(function() {
 
115
            assert.equal(Polymer.dom(document).activeElement, menubar.items[0], 'document.activeElement is last activated item');
 
116
            done();
 
117
          });
 
118
        });
 
119
 
 
120
        suite('left / right keys are reversed when the menubar has RTL directionality', function() {
 
121
          var LEFT = 37;
 
122
          var RIGHT = 39;
 
123
 
 
124
          test('left key moves to the next item', function() {
 
125
            var rtlContainer = fixture('rtl');
 
126
            var menubar = rtlContainer.querySelector('test-menubar');
 
127
            menubar.selected = 0;
 
128
            menubar.items[1].click();
 
129
 
 
130
            assert.equal(Polymer.dom(document).activeElement, menubar.items[1]);
 
131
 
 
132
            MockInteractions.pressAndReleaseKeyOn(menubar, LEFT);
 
133
 
 
134
            assert.equal(Polymer.dom(document).activeElement, menubar.items[2],
 
135
                '`document.activeElement` should be the next item.');
 
136
            assert.equal(menubar.selected, 1,
 
137
                '`menubar.selected` should not change.');
 
138
          });
 
139
 
 
140
          test('right key moves to the previous item', function() {
 
141
            var rtlContainer = fixture('rtl');
 
142
            var menubar = rtlContainer.querySelector('test-menubar');
 
143
            menubar.selected = 0;
 
144
            menubar.items[1].click();
 
145
 
 
146
            assert.equal(Polymer.dom(document).activeElement, menubar.items[1]);
 
147
 
 
148
            MockInteractions.pressAndReleaseKeyOn(menubar, RIGHT);
 
149
 
 
150
            assert.equal(Polymer.dom(document).activeElement, menubar.items[0],
 
151
                '`document.activeElement` should be the previous item');
 
152
            assert.equal(menubar.selected, 1,
 
153
                '`menubar.selected` should not change.');
 
154
          });
 
155
        });
 
156
 
 
157
      });
 
158
 
 
159
    </script>
 
160
 
 
161
  </body>
 
162
</html>