Commit fef4af49 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI: Replace remaining usages of MockInteractions.tap()

In most cases it is replaced with native click(), and in one case
replaced with MockInteractions.down().

Fixed: 812035
Change-Id: I977d3f920a37dc494c78d22ab901c9a4f61b12c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2468178
Commit-Queue: John Lee <johntlee@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817081}
parent 0b926446
......@@ -5,7 +5,16 @@
module.exports = {
'env': {'browser': true, 'es6': true},
'rules': {
'no-restricted-properties': 'off',
'no-restricted-properties': [
'error',
{
'object': 'MockInteractions',
'property': 'tap',
'message': 'Do not use on-tap handlers in prod code, and use the ' +
'native click() method in tests. See more context at ' +
'crbug.com/812035.',
},
],
'no-var': 'off',
'prefer-const': 'off',
'eqeqeq': ['error', 'always', {'null': 'ignore'}],
......
......@@ -5,7 +5,7 @@
import {HIDE_FOCUS_RING_ATTRIBUTE, LOCAL_STORAGE_FOLDER_STATE_KEY, LOCAL_STORAGE_TREE_WIDTH_KEY} from 'chrome://bookmarks/bookmarks.js';
import {isMac} from 'chrome://resources/js/cr.m.js';
import {getDeepActiveElement} from 'chrome://resources/js/util.m.js';
import {keyDownOn, pressAndReleaseKeyOn, tap} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {down, keyDownOn, pressAndReleaseKeyOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {TestStore} from 'chrome://test/bookmarks/test_store.js';
import {createFolder, normalizeIterable, replaceBody} from 'chrome://test/bookmarks/test_util.js';
import {flushTasks} from 'chrome://test/test_util.m.js';
......@@ -85,7 +85,7 @@ suite('<bookmarks-app>', function() {
assertEquals(null, getFocusAttribute());
tap(item);
down(item);
assertEquals('', getFocusAttribute());
keyDownOn(item, 16, [], 'Shift');
......
......@@ -4,7 +4,7 @@
import {Command, CommandManager, createBookmark, DialogFocusManager, getDisplayedList, MenuSource, selectFolder} from 'chrome://bookmarks/bookmarks.js';
import {isMac} from 'chrome://resources/js/cr.m.js';
import {pressAndReleaseKeyOn, tap} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {pressAndReleaseKeyOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {TestCommandManager} from 'chrome://test/bookmarks/test_command_manager.js';
import {TestStore} from 'chrome://test/bookmarks/test_store.js';
......@@ -322,7 +322,7 @@ suite('<bookmarks-command-manager>', function() {
assertTrue(dialog.open);
// Pressing 'cancel' should not open the window.
tap(dialog.querySelector('.cancel-button'));
dialog.querySelector('.cancel-button').click();
assertFalse(dialog.open);
assertEquals(null, lastCreate);
......@@ -330,7 +330,7 @@ suite('<bookmarks-command-manager>', function() {
assertTrue(dialog.open);
// Pressing 'yes' will open all the URLs.
tap(dialog.querySelector('.action-button'));
dialog.querySelector('.action-button').click();
assertFalse(dialog.open);
assertEquals(20, lastCreate.url.length);
});
......@@ -394,13 +394,13 @@ suite('<bookmarks-command-manager>', function() {
commandManager.root.querySelectorAll('.dropdown-item').forEach(element => {
commandItem[element.getAttribute('command')] = element;
});
tap(commandItem[Command.EDIT]);
commandItem[Command.EDIT].click();
testCommandManager.assertLastCommand(null);
});
test('keyboard shortcuts are disabled while a dialog is open', function() {
assertFalse(DialogFocusManager.getInstance().hasOpenDialog());
let items = new Set(['12']);
const items = new Set(['12']);
store.data.selection.items = items;
store.notifyObservers();
......@@ -590,8 +590,8 @@ suite('<bookmarks-item> CommandManager integration', function() {
});
test('copy/cut/paste for folder nodes independent of selection', function() {
let bmpCopyFunction = chrome.bookmarkManagerPrivate.copy;
let bmpCutFunction = chrome.bookmarkManagerPrivate.cut;
const bmpCopyFunction = chrome.bookmarkManagerPrivate.copy;
const bmpCutFunction = chrome.bookmarkManagerPrivate.cut;
let lastCut;
let lastCopy;
......
......@@ -6,7 +6,6 @@
import {navigation, Page} from 'chrome://extensions/extensions.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {tap} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {isChildVisible} from '../test_util.m.js';
......@@ -177,14 +176,14 @@ suite(extension_item_tests.suiteName, function() {
currentPage = newPage;
});
tap(item.$$('#detailsButton'));
item.$$('#detailsButton').click();
expectDeepEquals(
currentPage, {page: Page.DETAILS, extensionId: item.data.id});
// Reset current page and test inspect-view navigation.
navigation.navigateTo({page: Page.LIST});
currentPage = null;
tap(item.$$('#inspect-views a[is="action-link"]:nth-of-type(2)'));
item.$$('#inspect-views a[is="action-link"]:nth-of-type(2)').click();
expectDeepEquals(
currentPage, {page: Page.DETAILS, extensionId: item.data.id});
......@@ -239,7 +238,7 @@ suite(extension_item_tests.suiteName, function() {
});
};
tap(item.$$('#dev-reload-button'));
item.$$('#dev-reload-button').click();
return proxyDelegate.whenCalled('reloadItem')
.then(function(id) {
expectEquals(item.data.id, id);
......@@ -248,7 +247,7 @@ suite(extension_item_tests.suiteName, function() {
.then(function() {
proxyDelegate.resetResolver('reloadItem');
proxyDelegate.setForceReloadItemError(true);
tap(item.$$('#dev-reload-button'));
item.$$('#dev-reload-button').click();
return proxyDelegate.whenCalled('reloadItem');
})
.then(function(id) {
......
......@@ -5,7 +5,6 @@
/** @fileoverview Suite of tests for extension-sidebar. */
import {navigation, Page} from 'chrome://extensions/extensions.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {tap} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {eventToPromise} from '../test_util.m.js';
......@@ -72,14 +71,14 @@ suite(extension_sidebar_tests.suiteName, function() {
currentPage = newPage;
});
tap(sidebar.$$('#sections-shortcuts'));
sidebar.$$('#sections-shortcuts').click();
expectDeepEquals(currentPage, {page: Page.SHORTCUTS});
tap(sidebar.$$('#sections-extensions'));
sidebar.$$('#sections-extensions').click();
expectDeepEquals(currentPage, {page: Page.LIST});
// Clicking on the link for the current page should close the dialog.
sidebar.addEventListener('close-drawer', () => done());
tap(sidebar.$$('#sections-extensions'));
sidebar.$$('#sections-extensions').click();
});
});
......@@ -3,9 +3,9 @@
// found in the LICENSE file.
import {ensureLazyLoaded} from 'chrome://history/history.js';
import {pressAndReleaseKeyOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {createSession, createWindow, polymerSelectAll} from 'chrome://test/history/test_util.js';
import {flushTasks} from 'chrome://test/test_util.m.js';
import {pressAndReleaseKeyOn, tap} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
suite('<history-synced-device-manager>', function() {
let element;
......@@ -61,7 +61,7 @@ suite('<history-synced-device-manager>', function() {
pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
focused = cards[0].$['collapse-button'];
assertEquals(focused, lastFocused);
tap(focused);
focused.click();
await flushTasks();
// Pressing down goes to the next card.
......@@ -73,7 +73,7 @@ suite('<history-synced-device-manager>', function() {
pressAndReleaseKeyOn(focused, 38, [], 'ArrowUp');
focused = cards[0].$['collapse-button'];
assertEquals(focused, lastFocused);
tap(focused);
focused.click();
await flushTasks();
// First card's urls are focusable again.
......
......@@ -75,7 +75,7 @@ cr.define('multidevice_setup', () => {
startSetupPageElement.$.deviceDropdown.querySelectorAll('option');
for (option of optionNodeList.values()) {
if (option.textContent.trim() === optionText) {
MockInteractions.tap(option);
option.click();
return;
}
}
......
......@@ -4,16 +4,6 @@
module.exports = {
'rules': {
'no-restricted-properties': [
'error',
{
'object': 'MockInteractions',
'property': 'tap',
'message': 'Do not use on-tap handlers in prod code, and use the ' +
'native click() method in tests. See more context at ' +
'crbug.com/812035.',
},
],
'no-var': 'error',
'prefer-const': 'error',
'eqeqeq': ['error', 'always', {'null': 'ignore'}],
......
......@@ -30,7 +30,7 @@ suite('SettingsCheckbox', function() {
document.body.appendChild(testElement);
});
test('value changes on tap', function() {
test('value changes on click', function() {
assertTrue(testElement.checked);
testElement.$.checkbox.click();
......
......@@ -34,7 +34,7 @@ suite('SettingsToggleButton', () => {
document.body.appendChild(testElement);
});
test('value changes on tap', () => {
test('value changes on click', () => {
assertTrue(testElement.checked);
assertTrue(testElement.pref.value);
......
......@@ -20,17 +20,17 @@ LineChartTest.Menu = function() {
assertEquals(menu.buttons_.length, 3);
const buttons = menu.buttons_;
MockInteractions.tap(buttons[0]);
buttons[0].click();
assertFalse(data1.isVisible());
MockInteractions.tap(buttons[2]);
buttons[2].click();
assertFalse(data3.isVisible());
MockInteractions.tap(buttons[0]);
buttons[0].click();
assertTrue(data1.isVisible());
assertFalse(menu.buttonOuterDiv_.hasAttribute('hidden'));
MockInteractions.tap(menu.handleDiv_);
menu.handleDiv_.click();
assertTrue(menu.buttonOuterDiv_.hasAttribute('hidden'));
MockInteractions.tap(menu.handleDiv_);
menu.handleDiv_.click();
assertFalse(menu.buttonOuterDiv_.hasAttribute('hidden'));
menu.removeDataSeries(data1);
......
......@@ -47,16 +47,16 @@ PageTest.Drawer = function() {
});
function openByButton() {
MockInteractions.tap($('nav-menu-btn'));
$('nav-menu-btn').click();
}
function closeByClickBackground() {
MockInteractions.tap($('sys-internals-drawer'));
$('sys-internals-drawer').click();
}
function closeByClickInfoPageButton() {
const infoPageBtn = document.getElementsByClassName('drawer-item')[0];
MockInteractions.tap(infoPageBtn);
infoPageBtn.click();
}
test('Tap to open and close', function() {
......
......@@ -58,9 +58,9 @@ PageTest.Switch = function() {
}
function clickDrawerBtn(btnIndex) {
MockInteractions.tap($('nav-menu-btn'));
$('nav-menu-btn').click();
const infoBtn = document.getElementsByClassName('drawer-item')[btnIndex];
MockInteractions.tap(infoBtn);
infoBtn.click();
}
function goPage(hash, btnIndex) {
......
......@@ -54,13 +54,13 @@ cr.define('user_manager.control_bar_tests', function() {
});
// Simulate clicking 'Create Profile'.
MockInteractions.tap(controlBarElement.$.addUser);
controlBarElement.$.addUser.click();
});
});
test('Can launch guest profile', function() {
// Simulate clicking 'Browse as guest'.
MockInteractions.tap(controlBarElement.$.launchGuest);
controlBarElement.$.launchGuest.click();
return browserProxy.whenCalled('launchGuestUser');
});
});
......@@ -93,7 +93,7 @@ cr.define('user_manager.control_bar_tests', function() {
test('Cannot create profile', function() {
// Simulate clicking 'Create Profile'.
MockInteractions.tap(controlBarElement.$.addUser);
controlBarElement.$.addUser.click();
return browserProxy.whenCalled('areAllProfilesLocked').then(function() {
// Make sure DOM is up to date.
......@@ -106,7 +106,7 @@ cr.define('user_manager.control_bar_tests', function() {
test('Cannot launch guest profile', function() {
// Simulate clicking 'Browse as guest'.
MockInteractions.tap(controlBarElement.$.launchGuest);
controlBarElement.$.launchGuest.click();
return browserProxy.whenCalled('areAllProfilesLocked').then(function() {
// Make sure DOM is up to date.
......@@ -129,14 +129,14 @@ cr.define('user_manager.control_bar_tests', function() {
});
// Simulate clicking 'Create Profile'.
MockInteractions.tap(controlBarElement.$.addUser);
controlBarElement.$.addUser.click();
});
});
test('Can launch guest profile with force sign in', function() {
controlBarElement.isForceSigninEnabled_ = true;
Polymer.dom.flush();
MockInteractions.tap(controlBarElement.$.launchGuest);
controlBarElement.$.launchGuest.click();
return browserProxy.whenCalled('launchGuestUser');
});
});
......
......@@ -72,7 +72,7 @@ cr.define('user_manager.create_profile_tests', function() {
createProfileElement.$.nameInput.value = 'profile name';
// Simulate clicking 'Create'.
MockInteractions.tap(createProfileElement.$.save);
createProfileElement.$.save.click();
return browserProxy.whenCalled('createProfile').then(function(args) {
assertEquals('profile name', args.profileName);
......@@ -91,7 +91,7 @@ cr.define('user_manager.create_profile_tests', function() {
});
// Simulate clicking 'Cancel'.
MockInteractions.tap(createProfileElement.$.cancel);
createProfileElement.$.cancel.click();
});
});
......@@ -108,7 +108,7 @@ cr.define('user_manager.create_profile_tests', function() {
createProfileElement.$.nameInput.value = 'profile name';
// Simulate clicking 'Create'.
MockInteractions.tap(createProfileElement.$.save);
createProfileElement.$.save.click();
browserProxy.whenCalled('createProfile').then(function(args) {
// The paper-spinner is active when create is in progress.
......@@ -129,7 +129,7 @@ cr.define('user_manager.create_profile_tests', function() {
createProfileElement.$.nameInput.value = 'profile name';
// Simulate clicking 'Create'.
MockInteractions.tap(createProfileElement.$.save);
createProfileElement.$.save.click();
return browserProxy.whenCalled('createProfile').then(function(args) {
cr.webUIListenerCallback('create-profile-error', 'Error Message');
......@@ -147,7 +147,7 @@ cr.define('user_manager.create_profile_tests', function() {
createProfileElement.$.nameInput.value = 'foo';
// Simulate clicking 'Create'.
MockInteractions.tap(createProfileElement.$.save);
createProfileElement.$.save.click();
return browserProxy.whenCalled('createProfile').then(function(args) {
cr.webUIListenerCallback('create-profile-warning', 'Warning Message');
......@@ -222,10 +222,10 @@ cr.define('user_manager.create_profile_tests', function() {
assertTrue(createShortcutCheckbox.checked);
// Simulate unchecking the create shortcut checkbox.
MockInteractions.tap(createShortcutCheckbox);
createShortcutCheckbox.click();
// Simulate clicking 'Create'.
MockInteractions.tap(createProfileElement.$.save);
createProfileElement.$.save.click();
return browserProxy.whenCalled('createProfile').then(function(args) {
assertEquals('profile name', args.profileName);
......@@ -244,7 +244,7 @@ cr.define('user_manager.create_profile_tests', function() {
assertTrue(createShortcutCheckbox.checked);
// Simulate clicking 'Create'.
MockInteractions.tap(createProfileElement.$.save);
createProfileElement.$.save.click();
return browserProxy.whenCalled('createProfile').then(function(args) {
assertEquals('profile name', args.profileName);
......
......@@ -4,16 +4,6 @@
module.exports = {
'rules': {
'no-restricted-properties': [
'error',
{
'object': 'MockInteractions',
'property': 'tap',
'message': 'Do not use on-tap handlers in prod code, and use the ' +
'native click() method in tests. See more context at ' +
'crbug.com/812035.',
},
],
'no-var': 'error',
'prefer-const': 'error',
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment