Commit 8d68e88f authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[filesap] Make FMP test impl work with files SWA

Change chrome_file_manager_private_test_impl.js so that it can be used
in files SWA. No change in behavior.

When the code is used in SWA, simulate test.Event because code further
down in this chrome.fileManagerPrivate mock expects it to exist.

This code is also used by the file manager UITests and that code needs
a MockVolumeManager so we must create one in the UITests case.

Test: browser_tests --gtest_filter="FileManagerUITest*"
Tbr: alex
Bug: 1113981
Change-Id: I0adc6c15a9dfaf3ced49dd9ba34a9ed900218dd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526822Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825663}
parent 98f5be3b
...@@ -9,7 +9,40 @@ ...@@ -9,7 +9,40 @@
* running as a regular web page, we must provide test implementations. * running as a regular web page, we must provide test implementations.
*/ */
const mockVolumeManager = new MockVolumeManager(); /** @type {?MockVolumeManager} */
let mockVolumeManager = null;
if (window.test === undefined && window.isSWA) {
// eslint-disable-next-line
var test = test || {};
test.Event = class {
constructor() {
this.listeners_ = [];
}
/** @param {function()} callback */
addListener(callback) {
this.listeners_.push(callback);
}
/** @param {function()} callback */
removeListener(callback) {
this.listeners_ = this.listeners_.filter(l => l !== callback);
}
/** @param {...*} args */
dispatchEvent(...args) {
setTimeout(() => {
for (const listener of this.listeners_) {
listener(...args);
}
}, 0);
}
};
} else {
mockVolumeManager = new MockVolumeManager();
}
/** /**
* Suppress compiler warning for overwriting chrome.fileManagerPrivate. * Suppress compiler warning for overwriting chrome.fileManagerPrivate.
......
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