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

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: add tests for new focusRowBehavior 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 <style></style>
hcarmona 2017/03/16 21:31:54 Nit: style is optional, it can be removed when emp
scottchen 2017/03/17 21:26:58 Done.
13 <div id="container" focus-row-container>
14 <span>fake text</span>
15 <button id="control" focus-row-control type='fake-button'>
16 fake button
17 </button>
18 <button id="controlTwo" focus-row-control type='fake-button-two'>
19 fake button two
20 </button>
21 </div>
22 </template>
23 </dom-module>
24 `;
25
26 Polymer({
27 is: 'focus-row-element',
28 behaviors: [FocusRowBehavior],
29 });
30 });
31
32 setup(function(done) {
33 PolymerTest.clearBody();
34
35 testElement = document.createElement('focus-row-element');
36 document.body.appendChild(testElement);
37
38 // Block until FocusRowBehavior.attached finishes running async setup.
39 Polymer.RenderStatus.afterNextRender(this, function() {
40 done();
41 });
42 });
43
44 test('item passes focus to first focusable child', function() {
45 var focused = false;
46 testElement.$.control.addEventListener('focus', function() {
47 focused = true;
48 });
49 testElement.fire('focus');
hcarmona 2017/03/16 21:31:54 I think events are async. This test might need to
scottchen 2017/03/17 21:26:58 This was a surprise to me too, but apparently even
hcarmona 2017/03/17 23:55:50 Acknowledged.
50 assertTrue(focused);
51 });
52
53 test('will focus a similar item that was last focused', function() {
hcarmona 2017/03/16 21:31:54 This test can be updated in a similar manner to wh
scottchen 2017/03/17 21:26:58 same as above
54 var lastButton = document.createElement('button');
55 lastButton.setAttribute('focus-type', 'fake-button-two');
56 testElement.lastFocused = lastButton;
57
58 var focused = false;
59 testElement.$.controlTwo.addEventListener('focus', function() {
60 focused = true;
61 });
62 testElement.fire('focus');
63 assertTrue(focused);
64 });
65
66 test('mouse clicks on the row does not focus the controls', function() {
67 var focused = false;
68 testElement.$.control.addEventListener('focus', function() {
69 focused = true;
70 });
71 MockInteractions.tap(testElement);
72 // iron-list is responsible for firing 'focus' after taps, but is not used
hcarmona 2017/03/16 21:31:54 Does this apply to the other tests above? Maybe mo
scottchen 2017/03/17 21:26:59 This is only relevant to testing mouse taps.
hcarmona 2017/03/17 23:55:50 Acknowledged.
73 // in the test, so its necessary to manually fire 'focus' after tap.
74 testElement.fire('focus');
75 assertFalse(focused);
76 });
hcarmona 2017/03/16 21:31:54 Lists can be empty, how should focus be handled in
scottchen 2017/03/17 21:26:58 I think that's for iron-list to test - the FocusRo
hcarmona 2017/03/17 23:55:50 Acknowledged.
77 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698