Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/polymer/components/paper-menu/test/paper-submenu.html

Issue 3010683002: Update Polymer components. (Closed)
Patch Set: Rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <!-- 2 <!--
3 @license 3 @license
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 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.g ithub.io/LICENSE.txt 5 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.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/CONTRI BUTORS.txt 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
8 Code distributed by Google as part of the polymer project is also 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/PATEN TS.txt 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
10 --> 10 -->
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 <paper-menu class="menu-content"> 58 <paper-menu class="menu-content">
59 <paper-item>item 3.1</paper-item> 59 <paper-item>item 3.1</paper-item>
60 <paper-item>item 3.2</paper-item> 60 <paper-item>item 3.2</paper-item>
61 <paper-item>item 3.3</paper-item> 61 <paper-item>item 3.3</paper-item>
62 </paper-menu> 62 </paper-menu>
63 </paper-submenu> 63 </paper-submenu>
64 </paper-menu> 64 </paper-menu>
65 </template> 65 </template>
66 </test-fixture> 66 </test-fixture>
67 67
68 <test-fixture id="opened">
69 <template>
70 <paper-menu>
71 <paper-submenu class="menu-content" opened>
72 <paper-item class="menu-trigger">My submenu is opened to start!</pap er-item>
73 <paper-menu class="menu-content">
74 <paper-item>Triggered item</paper-item>
75 </paper-menu>
76 </paper-submenu>
77 </paper-menu>
78 </template>
79 </test-fixture>
80
68 <script> 81 <script>
69 82
70 suite('<paper-submenu>', function() { 83 suite('<paper-submenu>', function() {
71 var menu, 84 var menu,
72 sub1, sub2, sub3, 85 sub1, sub2, sub3,
73 collapse1, collapse2, collapse3, 86 collapse1, collapse2, collapse3,
74 trigger1, trigger2, trigger3; 87 trigger1, trigger2, trigger3;
75 88
76 setup(function() { 89 setup(function() {
77 menu = fixture('basic'); 90 menu = fixture('basic');
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 test('focus a submenu should redirect focus to the trigger', function(do ne) { 203 test('focus a submenu should redirect focus to the trigger', function(do ne) {
191 MockInteractions.focus(sub1); 204 MockInteractions.focus(sub1);
192 flush(function() { 205 flush(function() {
193 assert.equal(sub1.shadowRoot ? sub1.shadowRoot.activeElement : 206 assert.equal(sub1.shadowRoot ? sub1.shadowRoot.activeElement :
194 document.activeElement, sub1.__trigger); 207 document.activeElement, sub1.__trigger);
195 done(); 208 done();
196 }); 209 });
197 }); 210 });
198 }); 211 });
199 212
213 suite('<paper-submenu opened>', function() {
214 var opened;
215 var submenu;
216 var collapse;
217
218 var fail = function(msg) {
219 return function() {
220 throw new Error(msg);
221 };
222 };
223
224 setup(function() {
225 opened = fixture('opened');
226 submenu = opened.querySelector('paper-submenu');
227 collapse = Polymer.dom(submenu.root).querySelector('iron-collapse');
228 });
229
230 test('opened binding + .menu-trigger tap', function() {
231 assert.isTrue(submenu.opened);
232
233 var trigger = submenu.querySelector('.menu-trigger');
234 MockInteractions.tap(trigger);
235 assert.isFalse(submenu.opened);
236
237 MockInteractions.tap(trigger);
238 assert.isTrue(submenu.opened);
239 });
240
241 test('opened binding + open()/close()', function() {
242 assert.isTrue(submenu.opened);
243
244 submenu.close();
245 assert.isFalse(submenu.opened);
246 assert.isFalse(collapse.opened);
247
248 submenu.open();
249 assert.isTrue(submenu.opened);
250 assert.isTrue(collapse.opened);
251 });
252
253 test('opened binding + toggle()', function() {
254 assert.isTrue(submenu.opened);
255
256 submenu.toggle();
257 assert.isFalse(submenu.opened);
258 assert.isFalse(collapse.opened);
259
260 submenu.toggle();
261 assert.isTrue(submenu.opened);
262 assert.isTrue(collapse.opened);
263 });
264
265 test('opened binding + open() x 2', function() {
266 assert.isTrue(submenu.opened);
267
268 opened.addEventListener('paper-submenu-open', fail('duplicate open'));
269
270 submenu.open(); // Opening when already opened should not fire().
271 });
272
273 test('opened binding + close() x 2', function() {
274 submenu.close();
275 assert.isFalse(submenu.opened);
276
277 opened.addEventListener('paper-submenu-close', fail('duplicate close') );
278
279 submenu.close(); // Closing again when !opened should not fire().
280 });
281 });
200 </script> 282 </script>
201 283
202 </body> 284 </body>
203 </html> 285 </html>
OLDNEW
« no previous file with comments | « third_party/polymer/components/paper-menu/paper-submenu.html ('k') | third_party/polymer/components/paper-styles/.bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698