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

Unified 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 side-by-side diff with in-line comments
Download patch
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);
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698