| Index: chrome/test/data/webui/settings/focus_row_behavior_test.js
|
| diff --git a/chrome/test/data/webui/settings/focus_row_behavior_test.js b/chrome/test/data/webui/settings/focus_row_behavior_test.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dbaaee907013cf3e3e9eb7e99c867428f080fc33
|
| --- /dev/null
|
| +++ b/chrome/test/data/webui/settings/focus_row_behavior_test.js
|
| @@ -0,0 +1,76 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +suite('focus-row-behavior', function() {
|
| + /** @type {FocusableIronListItemElement} */ var testElement;
|
| +
|
| + suiteSetup(function() {
|
| + document.body.innerHTML = `
|
| + <dom-module is="focus-row-element">
|
| + <template>
|
| + <div id="container" focus-row-container>
|
| + <span>fake text</span>
|
| + <button id="control" focus-row-control focus-type='fake-btn'>
|
| + fake button
|
| + </button>
|
| + <button id="controlTwo" focus-row-control focus-type='fake-btn-two'>
|
| + fake button two
|
| + </button>
|
| + </div>
|
| + </template>
|
| + </dom-module>
|
| + `;
|
| +
|
| + Polymer({
|
| + is: 'focus-row-element',
|
| + behaviors: [FocusRowBehavior],
|
| + });
|
| + });
|
| +
|
| + setup(function(done) {
|
| + PolymerTest.clearBody();
|
| +
|
| + testElement = document.createElement('focus-row-element');
|
| + document.body.appendChild(testElement);
|
| +
|
| + // Block until FocusRowBehavior.attached finishes running async setup.
|
| + Polymer.RenderStatus.afterNextRender(this, function() {
|
| + done();
|
| + });
|
| + });
|
| +
|
| + test('item passes focus to first focusable child', function() {
|
| + var focused = false;
|
| + testElement.$.control.addEventListener('focus', function() {
|
| + focused = true;
|
| + });
|
| + testElement.fire('focus');
|
| + assertTrue(focused);
|
| + });
|
| +
|
| + test('will focus a similar item that was last focused', function() {
|
| + var lastButton = document.createElement('button');
|
| + lastButton.setAttribute('focus-type', 'fake-btn-two');
|
| + testElement.lastFocused = lastButton;
|
| +
|
| + var focused = false;
|
| + testElement.$.controlTwo.addEventListener('focus', function() {
|
| + focused = true;
|
| + });
|
| + testElement.fire('focus');
|
| + assertTrue(focused);
|
| + });
|
| +
|
| + test('mouse clicks on the row does not focus the controls', function() {
|
| + var focused = false;
|
| + testElement.$.control.addEventListener('focus', function() {
|
| + focused = true;
|
| + });
|
| + MockInteractions.tap(testElement);
|
| + // iron-list is responsible for firing 'focus' after taps, but is not used
|
| + // in the test, so its necessary to manually fire 'focus' after tap.
|
| + testElement.fire('focus');
|
| + assertFalse(focused);
|
| + });
|
| +});
|
|
|