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

Side by Side Diff: chrome/test/data/webui/settings/focus_row_behavior_test.js

Issue 2749513004: MD Settings: adjust iron-list focus row behaviors. (Closed)
Patch Set: fix test Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 suite('focus-row-behavior', function() {
6 /** @type {FocusableIronListItemElement} */ var testElement;
7
8 suiteSetup(function() {
9 document.body.innerHTML = `
10 <dom-module is="focus-row-element">
11 <template>
12 <div id="container" focus-row-container>
13 <span>fake text</span>
14 <button id="control" focus-row-control focus-type='fake-btn'>
15 fake button
16 </button>
17 <button id="controlTwo" focus-row-control focus-type='fake-btn-two'>
18 fake button two
19 </button>
20 </div>
21 </template>
22 </dom-module>
23 `;
24
25 Polymer({
26 is: 'focus-row-element',
27 behaviors: [FocusRowBehavior],
28 });
29 });
30
31 setup(function(done) {
32 PolymerTest.clearBody();
33
34 testElement = document.createElement('focus-row-element');
35 document.body.appendChild(testElement);
36
37 // Block until FocusRowBehavior.attached finishes running async setup.
38 Polymer.RenderStatus.afterNextRender(this, function() {
39 done();
40 });
41 });
42
43 test('item passes focus to first focusable child', function() {
44 var focused = false;
45 testElement.$.control.addEventListener('focus', function() {
46 focused = true;
47 });
48 testElement.fire('focus');
49 assertTrue(focused);
50 });
51
52 test('will focus a similar item that was last focused', function() {
53 var lastButton = document.createElement('button');
54 lastButton.setAttribute('focus-type', 'fake-btn-two');
55 testElement.lastFocused = lastButton;
56
57 var focused = false;
58 testElement.$.controlTwo.addEventListener('focus', function() {
59 focused = true;
60 });
61 testElement.fire('focus');
62 assertTrue(focused);
63 });
64
65 test('mouse clicks on the row does not focus the controls', function() {
66 var focused = false;
67 testElement.$.control.addEventListener('focus', function() {
68 focused = true;
69 });
70 MockInteractions.tap(testElement);
71 // iron-list is responsible for firing 'focus' after taps, but is not used
72 // in the test, so its necessary to manually fire 'focus' after tap.
73 testElement.fire('focus');
74 assertFalse(focused);
75 });
76 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698