Commit 3b682c00 authored by Jérémie Boulic's avatar Jérémie Boulic Committed by Commit Bot

Files app: Generate more //ui/file_manager/base/ JS modules

Modules in base/js on which the Audio Player depends.

mock_chrome.js and test_error_reporting.js are used by unittests that
need to be converted.

Bug: 1133186
Change-Id: Id580a741b03971474dd31b9fe9fe30c3ce5895cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507300Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822485}
parent 09381322
......@@ -95,6 +95,7 @@ preprocess_grit("preprocess_generated") {
in_files = [
"base/js/app_util.m.js",
"base/js/volume_manager_types.m.js",
"base/js/mediasession_types.m.js",
]
deps = [ "//ui/file_manager/base/js:modulize" ]
......
......@@ -16,6 +16,7 @@ group("closure_compile") {
":closure_compile_module",
":js_test_gen_html_type_check_auto",
":test_support_type_check",
":test_support_type_check_jsmodules",
]
}
......@@ -43,6 +44,15 @@ js_type_check("test_support_type_check") {
]
}
js_type_check("test_support_type_check_jsmodules") {
uses_js_modules = true
testonly = true
deps = [
":mock_chrome.m",
":test_error_reporting.m",
]
}
js_library("app_util") {
externs_list = [ "//ui/file_manager/externs/app_window_common.js" ]
}
......@@ -76,6 +86,13 @@ js_library("mock_chrome") {
testonly = true
}
js_library("mock_chrome.m") {
testonly = true
sources = [ "$root_gen_dir/ui/file_manager/base/js/mock_chrome.m.js" ]
extra_deps = [ ":modulize" ]
}
js_library("test_error_reporting") {
testonly = true
deps = [
......@@ -85,6 +102,14 @@ js_library("test_error_reporting") {
]
}
js_library("test_error_reporting.m") {
testonly = true
sources =
[ "$root_gen_dir/ui/file_manager/base/js/test_error_reporting.m.js" ]
extra_deps = [ ":modulize" ]
}
js_library("volume_manager_types") {
deps = [
"//ui/file_manager/externs:file_manager_private",
......@@ -123,9 +148,18 @@ js_test_gen_html("js_test_gen_html") {
js_library("mediasession_types") {
}
js_library("mediasession_types.m") {
sources = [ "$root_gen_dir/ui/file_manager/base/js/mediasession_types.m.js" ]
extra_deps = [ ":modulize" ]
}
js_modulizer("modulize") {
input_files = [
"app_util.js",
"volume_manager_types.js",
"mock_chrome.js",
"mediasession_types.js",
"test_error_reporting.js",
]
}
......@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview
* @suppress {uselessCode} Temporary suppress because of the line exporting.
*/
/**
* @see https://wicg.github.io/mediasession/#enumdef-mediasessionplaybackstate
* @enum {string}
......@@ -11,3 +16,6 @@ const MediaSessionPlaybackState = {
PAUSED: 'paused',
PLAYING: 'playing'
};
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {MediaSessionPlaybackState};
......@@ -6,7 +6,7 @@
* Installs a mock object to replace window.chrome in a unit test.
* @param {Object} mockChrome
*/
function installMockChrome(mockChrome) {
/* #export */ function installMockChrome(mockChrome) {
/** @suppress {const|checkTypes} */
chrome = mockChrome;
}
......@@ -14,7 +14,7 @@ function installMockChrome(mockChrome) {
/**
* Mocks chrome.commandLinePrivate.
*/
class MockCommandLinePrivate {
/* #export */ class MockCommandLinePrivate {
constructor() {
this.flags_ = {};
if (!chrome) {
......@@ -44,7 +44,7 @@ class MockCommandLinePrivate {
/**
* Stubs the chrome.storage API.
*/
class MockChromeStorageAPI {
/* #export */ class MockChromeStorageAPI {
constructor() {
/** @type {Object<?>} */
this.state = {};
......@@ -68,8 +68,8 @@ class MockChromeStorageAPI {
* @private
*/
get_(keys, callback) {
var keys = keys instanceof Array ? keys : [keys];
var result = {};
keys = keys instanceof Array ? keys : [keys];
const result = {};
keys.forEach((key) => {
if (key in this.state) {
result[key] = this.state[key];
......@@ -84,7 +84,7 @@ class MockChromeStorageAPI {
* @private
*/
set_(values, opt_callback) {
for (var key in values) {
for (const key in values) {
this.state[key] = values[key];
}
if (opt_callback) {
......
......@@ -6,7 +6,7 @@
* Asserts that promise gets rejected.
* @param {Promise} promise
*/
async function assertRejected(promise) {
/* #export */ async function assertRejected(promise) {
let triggeredError = false;
try {
await promise;
......@@ -26,7 +26,7 @@ async function assertRejected(promise) {
* @param {function(boolean)} callback Callback function. True is passed if the
* test failed.
*/
function reportPromise(promise, callback) {
/* #export */ function reportPromise(promise, callback) {
promise.then(
() => {
callback(/* error */ false);
......@@ -43,11 +43,11 @@ function reportPromise(promise, callback) {
* @return {!Promise} A promise which is fulfilled when the testFunction
* becomes true.
*/
function waitUntil(testFunction) {
/* #export */ function waitUntil(testFunction) {
const INTERVAL_FOR_WAIT_UNTIL = 100; // ms
return new Promise((resolve) => {
let tryTestFunction = () => {
const tryTestFunction = () => {
if (testFunction()) {
resolve();
} else {
......
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