Commit bc0c372f authored by Martin Šrámek's avatar Martin Šrámek Committed by Commit Bot

Revert "WebUI: Add JS type checking for more cr_elements/ tests, part 8."

This reverts commit 140fc3a1.

Reason for revert: Tests fail on Mac. crbug.com/1091201

Original change's description:
> WebUI: Add JS type checking for more cr_elements/ tests, part 8.
> 
> Specifically:
>  - cr_toast_manager_test.js
>  - cr_toast_test.js
>  - cr_toggle_test.js
>  - cr_toolbar_search_field_tests.js
> 
> Bug: 1000989
> Change-Id: I9d745caca24c46945e64faca96d9b87fcecd1af9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227238
> Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
> Auto-Submit: dpapad <dpapad@chromium.org>
> Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#775025}

TBR=dpapad@chromium.org,rbpotter@chromium.org

Change-Id: I09e760dabd5e609c968239a5e052134128434efe
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1000989, 1091201
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2230466Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Commit-Queue: Martin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775071}
parent b7055f10
...@@ -363,18 +363,12 @@ js_type_check("closure_compile_local") { ...@@ -363,18 +363,12 @@ js_type_check("closure_compile_local") {
] ]
deps = [ deps = [
":chai_assert", ":chai_assert",
":mock_timer.m",
":test_browser_proxy.m", ":test_browser_proxy.m",
":test_plural_string_proxy", ":test_plural_string_proxy",
":test_util.m", ":test_util.m",
] ]
} }
js_library("mock_timer.m") {
sources = [ "$root_gen_dir/chrome/test/data/webui/mock_timer.m.js" ]
extra_deps = [ ":modulize_local" ]
}
js_library("test_util.m") { js_library("test_util.m") {
sources = [ "$root_gen_dir/chrome/test/data/webui/test_util.m.js" ] sources = [ "$root_gen_dir/chrome/test/data/webui/test_util.m.js" ]
deps = [ deps = [
......
...@@ -81,11 +81,11 @@ js_type_check("closure_compile") { ...@@ -81,11 +81,11 @@ js_type_check("closure_compile") {
":cr_slider_test.m", ":cr_slider_test.m",
":cr_splitter_test", ":cr_splitter_test",
":cr_tabs_test.m", ":cr_tabs_test.m",
":cr_toast_manager_test.m",
":cr_toast_test.m",
":cr_toggle_test.m",
":cr_toolbar_search_field_tests.m",
#":cr_toast_manager_test",
#":cr_toast_test",
#":cr_toggle_test",
#":cr_toolbar_search_field_tests",
#":cr_view_manager_test", #":cr_view_manager_test",
#":iron_list_focus_test", #":iron_list_focus_test",
#":settings_private_test_constants", #":settings_private_test_constants",
...@@ -422,52 +422,3 @@ js_library("cr_tabs_test.m") { ...@@ -422,52 +422,3 @@ js_library("cr_tabs_test.m") {
externs_list = [ "$externs_path/mocha-2.5.js" ] externs_list = [ "$externs_path/mocha-2.5.js" ]
extra_deps = [ ":modulize" ] extra_deps = [ ":modulize" ]
} }
js_library("cr_toast_manager_test.m") {
sources = [ "$root_gen_dir/chrome/test/data/webui/cr_elements/cr_toast_manager_test.m.js" ]
deps = [
"..:chai_assert",
"..:test_util.m",
"//ui/webui/resources/cr_elements/cr_toast:cr_toast.m",
"//ui/webui/resources/cr_elements/cr_toast:cr_toast_manager.m",
]
externs_list = [ "$externs_path/mocha-2.5.js" ]
extra_deps = [ ":modulize" ]
}
js_library("cr_toast_test.m") {
sources =
[ "$root_gen_dir/chrome/test/data/webui/cr_elements/cr_toast_test.m.js" ]
deps = [
"..:chai_assert",
"..:mock_timer.m",
"//ui/webui/resources/cr_elements/cr_toast:cr_toast.m",
]
externs_list = [ "$externs_path/mocha-2.5.js" ]
extra_deps = [ ":modulize" ]
}
js_library("cr_toggle_test.m") {
sources =
[ "$root_gen_dir/chrome/test/data/webui/cr_elements/cr_toggle_test.m.js" ]
deps = [
"..:chai_assert",
"..:test_util.m",
"//third_party/polymer/v3_0/components-chromium/iron-test-helpers:mock-interactions",
"//ui/webui/resources/cr_elements/cr_toggle:cr_toggle.m",
]
externs_list = [ "$externs_path/mocha-2.5.js" ]
extra_deps = [ ":modulize" ]
}
js_library("cr_toolbar_search_field_tests.m") {
sources = [ "$root_gen_dir/chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.m.js" ]
deps = [
"..:chai_assert",
"//third_party/polymer/v3_0/components-chromium/iron-test-helpers:mock-interactions",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_toolbar:cr_toolbar_search_field.m",
]
externs_list = [ "$externs_path/mocha-2.5.js" ]
extra_deps = [ ":modulize" ]
}
...@@ -5,17 +5,14 @@ ...@@ -5,17 +5,14 @@
// clang-format off // clang-format off
// #import {getToastManager} from 'chrome://resources/cr_elements/cr_toast/cr_toast_manager.m.js'; // #import {getToastManager} from 'chrome://resources/cr_elements/cr_toast/cr_toast_manager.m.js';
// #import {eventToPromise} from '../test_util.m.js'; // #import {eventToPromise} from '../test_util.m.js';
// #import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
// clang-format on // clang-format on
suite('cr-toast-manager', () => { suite('cr-toast-manager', () => {
/** @type {!CrToastManagerElement} */
let toastManager; let toastManager;
suiteSetup(() => { suiteSetup(() => {
document.body.innerHTML = ''; PolymerTest.clearBody();
toastManager = /** @type {!CrToastManagerElement} */ ( toastManager = document.createElement('cr-toast-manager');
document.createElement('cr-toast-manager'));
document.body.appendChild(toastManager); document.body.appendChild(toastManager);
}); });
...@@ -48,7 +45,6 @@ suite('cr-toast-manager', () => { ...@@ -48,7 +45,6 @@ suite('cr-toast-manager', () => {
test('duration passed through to toast', () => { test('duration passed through to toast', () => {
toastManager.duration = 3; toastManager.duration = 3;
assertEquals( assertEquals(3, toastManager.$.toast.duration);
3, /** @type {!CrToastElement} */ (toastManager.$$('#toast').duration));
}); });
}); });
...@@ -5,19 +5,15 @@ ...@@ -5,19 +5,15 @@
// clang-format off // clang-format off
// #import 'chrome://resources/cr_elements/cr_toast/cr_toast.m.js'; // #import 'chrome://resources/cr_elements/cr_toast/cr_toast.m.js';
// #import {MockTimer} from '../mock_timer.m.js'; // #import {MockTimer} from '../mock_timer.m.js';
// #import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
// clang-format on // clang-format on
suite('cr-toast', function() { suite('cr-toast', function() {
/** @type {!CrToastElement} */
let toast; let toast;
/** @type {!MockTimer} */
let mockTimer; let mockTimer;
setup(function() { setup(function() {
document.body.innerHTML = ''; PolymerTest.clearBody();
toast = /** @type {!CrToastElement} */ (document.createElement('cr-toast')); toast = document.createElement('cr-toast');
document.body.appendChild(toast); document.body.appendChild(toast);
mockTimer = new MockTimer(); mockTimer = new MockTimer();
mockTimer.install(); mockTimer.install();
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
// #import 'chrome://resources/cr_elements/cr_toggle/cr_toggle.m.js'; // #import 'chrome://resources/cr_elements/cr_toggle/cr_toggle.m.js';
// #import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; // #import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
// #import {eventToPromise} from '../test_util.m.js'; // #import {eventToPromise} from '../test_util.m.js';
// #import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
// clang-format on // clang-format on
suite('cr-toggle', function() { suite('cr-toggle', function() {
/** @type {!CrToggleElement} */
let toggle; let toggle;
setup(function() { setup(function() {
document.body.innerHTML = ''; PolymerTest.clearBody();
toggle = document.body.innerHTML = `
/** @type {!CrToggleElement} */ (document.createElement('cr-toggle')); <cr-toggle id="toggle"></cr-toggle>
document.body.appendChild(toggle); `;
toggle = document.getElementById('toggle');
assertNotChecked(); assertNotChecked();
}); });
...@@ -26,8 +26,7 @@ suite('cr-toggle', function() { ...@@ -26,8 +26,7 @@ suite('cr-toggle', function() {
assertTrue(toggle.hasAttribute('checked')); assertTrue(toggle.hasAttribute('checked'));
assertEquals('true', toggle.getAttribute('aria-pressed')); assertEquals('true', toggle.getAttribute('aria-pressed'));
// Asserting that the toggle button has actually moved. // Asserting that the toggle button has actually moved.
assertTrue( assertTrue(getComputedStyle(toggle.$.knob).transform.includes('matrix'));
getComputedStyle(toggle.$$('#knob')).transform.includes('matrix'));
} }
function assertNotChecked() { function assertNotChecked() {
...@@ -35,7 +34,7 @@ suite('cr-toggle', function() { ...@@ -35,7 +34,7 @@ suite('cr-toggle', function() {
assertEquals(null, toggle.getAttribute('checked')); assertEquals(null, toggle.getAttribute('checked'));
assertEquals('false', toggle.getAttribute('aria-pressed')); assertEquals('false', toggle.getAttribute('aria-pressed'));
// Asserting that the toggle button has not moved. // Asserting that the toggle button has not moved.
assertEquals('none', getComputedStyle(toggle.$$('#knob')).transform); assertEquals('none', getComputedStyle(toggle.$.knob).transform);
} }
function assertDisabled() { function assertDisabled() {
......
...@@ -6,29 +6,27 @@ ...@@ -6,29 +6,27 @@
// #import 'chrome://resources/cr_elements/cr_toolbar/cr_toolbar_search_field.m.js'; // #import 'chrome://resources/cr_elements/cr_toolbar/cr_toolbar_search_field.m.js';
// //
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {pressAndReleaseKeyOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; // #import {blur, pressAndReleaseKeyOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
// #import {assertEquals, assertDeepEquals, assertFalse, assertNotEquals, assertTrue} from '../chai_assert.js';
// clang-format on // clang-format on
/** @fileoverview Suite of tests for cr-toolbar-search-field. */ /** @fileoverview Suite of tests for cr-toolbar-search-field. */
suite('cr-toolbar-search-field', function() { suite('cr-toolbar-search-field', function() {
/** @type {!CrToolbarSearchFieldElement} */ /** @type {?CrToolbarSearchFieldElement} */
let field; let field = null;
/** @type {?Array<string>} */ /** @type {?Array<string>} */
let searches = null; let searches = null;
/** @param {string} term */ /** @param {string} term */
function simulateSearch(term) { function simulateSearch(term) {
field.$$('#searchInput').value = term; field.$.searchInput.value = term;
field.onSearchTermInput(); field.onSearchTermInput();
field.onSearchTermSearch(); field.onSearchTermSearch();
} }
setup(function() { setup(function() {
document.body.innerHTML = ''; PolymerTest.clearBody();
field = /** @type {!CrToolbarSearchFieldElement} */ ( field = document.createElement('cr-toolbar-search-field');
document.createElement('cr-toolbar-search-field'));
searches = []; searches = [];
field.addEventListener('search-changed', function(event) { field.addEventListener('search-changed', function(event) {
searches.push(event.detail); searches.push(event.detail);
...@@ -38,6 +36,8 @@ suite('cr-toolbar-search-field', function() { ...@@ -38,6 +36,8 @@ suite('cr-toolbar-search-field', function() {
teardown(function() { teardown(function() {
field.remove(); field.remove();
field = null;
searches = null;
}); });
// Test that no initial 'search-changed' event is fired during // Test that no initial 'search-changed' event is fired during
...@@ -63,19 +63,18 @@ suite('cr-toolbar-search-field', function() { ...@@ -63,19 +63,18 @@ suite('cr-toolbar-search-field', function() {
assertFalse(field.showingSearch); assertFalse(field.showingSearch);
field.click(); field.click();
assertTrue(field.showingSearch); assertTrue(field.showingSearch);
assertEquals(field.$$('#searchInput'), field.root.activeElement); assertEquals(field.$.searchInput, field.root.activeElement);
field.$$('#searchInput').blur(); MockInteractions.blur(field.$.searchInput);
assertFalse(field.showingSearch); assertFalse(field.showingSearch);
field.click(); field.click();
assertEquals(field.$$('#searchInput'), field.root.activeElement); assertEquals(field.$.searchInput, field.root.activeElement);
MockInteractions.pressAndReleaseKeyOn( MockInteractions.pressAndReleaseKeyOn(
/** @type {!HTMLElement} */ (field.$$('#searchInput')), 27, '', field.$.searchInput, 27, '', 'Escape');
'Escape');
assertFalse(field.showingSearch, 'Pressing escape closes field.'); assertFalse(field.showingSearch, 'Pressing escape closes field.');
assertNotEquals(field.$$('#searchInput'), field.root.activeElement); assertNotEquals(field.$.searchInput, field.root.activeElement);
}); });
test('clear search button clears and refocuses input', function() { test('clear search button clears and refocuses input', function() {
...@@ -89,7 +88,7 @@ suite('cr-toolbar-search-field', function() { ...@@ -89,7 +88,7 @@ suite('cr-toolbar-search-field', function() {
clearSearch.click(); clearSearch.click();
assertTrue(field.showingSearch); assertTrue(field.showingSearch);
assertEquals('', field.getValue()); assertEquals('', field.getValue());
assertEquals(field.$$('#searchInput'), field.root.activeElement); assertEquals(field.$.searchInput, field.root.activeElement);
assertFalse(field.hasSearchText); assertFalse(field.hasSearchText);
assertFalse(field.spinnerActive); assertFalse(field.spinnerActive);
}); });
...@@ -198,7 +197,7 @@ suite('cr-toolbar-search-field', function() { ...@@ -198,7 +197,7 @@ suite('cr-toolbar-search-field', function() {
test('blur does not close field when a search is active', function() { test('blur does not close field when a search is active', function() {
field.click(); field.click();
simulateSearch('test'); simulateSearch('test');
field.$$('#searchInput').blur(); MockInteractions.blur(field.$.searchInput);
assertTrue(field.showingSearch); assertTrue(field.showingSearch);
}); });
...@@ -218,7 +217,7 @@ suite('cr-toolbar-search-field', function() { ...@@ -218,7 +217,7 @@ suite('cr-toolbar-search-field', function() {
}); });
test('closes when value is cleared while unfocused', function() { test('closes when value is cleared while unfocused', function() {
field.$$('#searchInput').focus(); MockInteractions.focus(field.$.searchInput);
simulateSearch('test'); simulateSearch('test');
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -229,7 +228,7 @@ suite('cr-toolbar-search-field', function() { ...@@ -229,7 +228,7 @@ suite('cr-toolbar-search-field', function() {
// Does close the field if it is blurred before being cleared. // Does close the field if it is blurred before being cleared.
simulateSearch('test'); simulateSearch('test');
field.$$('#searchInput').blur(); MockInteractions.blur(field.$.searchInput);
field.setValue(''); field.setValue('');
assertFalse(field.showingSearch); assertFalse(field.showingSearch);
}); });
......
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
/** /**
* Details for active timers. * Details for active timers.
* @type {!Array<{callback: Function, * @type {Array<{callback: Function,
* delay: number, * delay: number,
* key: number, * key: number,
* repeats: boolean}|undefined>} * repeats: boolean}>}
* @private * @private
*/ */
this.timers_ = []; this.timers_ = [];
......
...@@ -42,7 +42,10 @@ polymer_modulizer("cr_toast_manager") { ...@@ -42,7 +42,10 @@ polymer_modulizer("cr_toast_manager") {
html_file = "cr_toast_manager.html" html_file = "cr_toast_manager.html"
html_type = "dom-module" html_type = "dom-module"
auto_imports = [ "ui/webui/resources/html/assert.html|assert" ] auto_imports = [ "ui/webui/resources/html/assert.html|assert" ]
namespace_rewrites = [ "cr.toastManager.getToastManager|getToastManager" ] namespace_rewrites = [
"cr.toastManager.CrToastManagerElement|CrToastManagerElement",
"cr.toastManager.getToastManager|getToastManager",
]
} }
js_type_check("closure_compile_module") { js_type_check("closure_compile_module") {
......
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
cr.define('cr.toastManager', () => { cr.define('cr.toastManager', () => {
/* eslint-disable */ /* eslint-disable */
/** @private {?CrToastManagerElement} */ /** @private {?cr.toastManager.CrToastManagerElement} */
let toastManagerInstance = null; let toastManagerInstance = null;
/* eslint-enable */ /* eslint-enable */
/** @return {!CrToastManagerElement} */ /** @return {!cr.toastManager.CrToastManagerElement} */
/* #export */ function getToastManager() { /* #export */ function getToastManager() {
return assert(toastManagerInstance); return assert(toastManagerInstance);
} }
/** @param {?CrToastManagerElement} instance */ /** @param {?cr.toastManager.CrToastManagerElement} instance */
function setInstance(instance) { function setInstance(instance) {
assert(!instance || !toastManagerInstance); assert(!instance || !toastManagerInstance);
toastManagerInstance = instance; toastManagerInstance = instance;
...@@ -23,7 +23,7 @@ cr.define('cr.toastManager', () => { ...@@ -23,7 +23,7 @@ cr.define('cr.toastManager', () => {
* @fileoverview Element which shows toasts with optional undo button. * @fileoverview Element which shows toasts with optional undo button.
*/ */
// eslint-disable-next-line // eslint-disable-next-line
Polymer({ /* #export */ let CrToastManagerElement = Polymer({
is: 'cr-toast-manager', is: 'cr-toast-manager',
properties: { properties: {
...@@ -94,6 +94,7 @@ cr.define('cr.toastManager', () => { ...@@ -94,6 +94,7 @@ cr.define('cr.toastManager', () => {
// #cr_define_end // #cr_define_end
return { return {
CrToastManagerElement: CrToastManagerElement,
getToastManager: getToastManager, getToastManager: getToastManager,
}; };
}); });
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