Commit 42ec88d1 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Chromium LUCI CQ

Files app: Generate JS module for //u/f/f/b/j/import_history.js

Generate JS modules for:
//ui/file_manager/externs/background/import_history.js
//ui/file_manager/file_manager/background/js/import_history.js
//ui/file_manager/file_manager/background/js/test_import_history.js

Because Closure doesn't deal well importing the same namespace from
different files, I started splitting the "importer" namespace so each
file will have its own namespace.  Files in the "externs" directory will
have the suffix "Interface" on their namespace.  I'll use this logic for
all files related to "importer" namespace.

Bug: 1133186
Change-Id: Iec2851ea28cdf8b4b079a997e74d99b2dfbf92f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592854
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837934}
parent d33c15ae
......@@ -165,7 +165,7 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImporterCommonTest) {
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ImportHistoryTest) {
RunTestURL("background/js/import_history_unittest_gen.html");
RunTestURL("background/js/import_history_unittest.m_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, InstallLinuxPackageDialogTest) {
......
......@@ -60,6 +60,14 @@ js_library("file_operation_manager.m") {
extra_deps = [ ":modulize" ]
}
js_library("import_history.m") {
sources =
[ "$root_gen_dir/ui/file_manager/externs/background/import_history.m.js" ]
deps = [ "//ui/file_manager/file_manager/common/js:importer_common.m" ]
extra_deps = [ ":modulize" ]
}
js_library("progress_center.m") {
sources = [
"$root_gen_dir/ui/file_manager/externs/background/progress_center.m.js",
......@@ -86,6 +94,7 @@ js_modulizer("modulize") {
"crostini.js",
"drive_sync_handler.js",
"file_operation_manager.js",
"import_history.js",
"progress_center.js",
"task_queue.js",
]
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
// Namespace
// eslint-disable-next-line no-var
var importer = importer || {};
/**
......@@ -13,7 +14,7 @@ importer.DispositionChecker = class {
/**
* Factory for a function that returns a file entry's content disposition.
*
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
*
* @return {!importer.DispositionChecker.CheckerFunction}
*/
......
......@@ -39,7 +39,7 @@ class FileBrowserBackgroundFull extends BackgroundBase {
this.mediaScanner;
/**
* @type {!importer.HistoryLoader}
* @type {!importerHistoryInterfaces.HistoryLoader}
*/
this.historyLoader;
......
......@@ -2,18 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview
* @suppress {uselessCode, externsValidation} Temporary suppress because of the
* line exporting.
*/
// #import {importer} from '../../file_manager/common/js/importer_common.m.js';
// Namespace
var importer = importer || {};
// eslint-disable-next-line no-var
var importerHistoryInterfaces = {};
/**
* A persistent data store for Cloud Import history information.
*
* @interface
*/
importer.ImportHistory = class {
importerHistoryInterfaces.ImportHistory = class {
/**
* @return {!Promise<!importer.ImportHistory>} Resolves when history
* has been fully loaded.
* @return {!Promise<!importerHistoryInterfaces.ImportHistory>} Resolves when
* history has been fully loaded.
*/
whenReady() {}
......@@ -37,6 +46,7 @@ importer.ImportHistory = class {
* @param {!FileEntry} entry
* @param {!importer.Destination} destination
* @param {string} destinationUrl
* @return {!Promise}
*/
markCopied(entry, destination, destinationUrl) {}
......@@ -63,14 +73,14 @@ importer.ImportHistory = class {
/**
* Adds an observer, which will be notified when cloud import history changes.
*
* @param {!importer.ImportHistory.Observer} observer
* @param {!importerHistoryInterfaces.ImportHistory.Observer} observer
*/
addObserver(observer) {}
/**
* Remove a previously registered observer.
*
* @param {!importer.ImportHistory.Observer} observer
* @param {!importerHistoryInterfaces.ImportHistory.Observer} observer
*/
removeObserver(observer) {}
};
......@@ -78,7 +88,7 @@ importer.ImportHistory = class {
/**
* @enum {string} Import history changed event |state| values.
*/
importer.ImportHistoryState = {
importerHistoryInterfaces.ImportHistoryState = {
'COPIED': 'copied',
'IMPORTED': 'imported'
};
......@@ -87,33 +97,36 @@ importer.ImportHistoryState = {
* Import history changed event (sent to ImportHistory.Observer's).
*
* @typedef {{
* state: !importer.ImportHistoryState,
* state: !importerHistoryInterfaces.ImportHistoryState,
* entry: !FileEntry,
* destination: !importer.Destination,
* destinationUrl: (string|undefined)
* }}
*/
importer.ImportHistory.ChangedEvent;
importerHistoryInterfaces.ImportHistory.ChangedEvent;
/** @typedef {function(!importer.ImportHistory.ChangedEvent)} */
importer.ImportHistory.Observer;
/**
* @typedef {function(!importerHistoryInterfaces.ImportHistory.ChangedEvent)}
*/
importerHistoryInterfaces.ImportHistory.Observer;
/**
* Provider of lazy loaded importer.ImportHistory. This is the main
* access point for a fully prepared {@code importer.ImportHistory} object.
* Provider of lazy loaded importerHistoryInterfaces.ImportHistory. This is the
* main access point for a fully prepared {@code
* importerHistoryInterfaces.ImportHistory} object.
*
* @interface
*/
importer.HistoryLoader = class {
importerHistoryInterfaces.HistoryLoader = class {
/**
* Instantiates an {@code importer.ImportHistory} object and manages any
* necessary ongoing maintenance of the object with respect to
* its external dependencies.
* Instantiates an {@code importerHistoryInterfaces.ImportHistory} object and
* manages any necessary ongoing maintenance of the object with respect to its
* external dependencies.
*
* @see importer.SynchronizedHistoryLoader for an example.
* @see importerHistory.SynchronizedHistoryLoader for an example.
*
* @return {!Promise<!importer.ImportHistory>} Resolves when history instance
* is ready.
* @return {!Promise<!importerHistoryInterfaces.ImportHistory>} Resolves when
* history instance is ready.
*/
getHistory() {}
......@@ -121,7 +134,10 @@ importer.HistoryLoader = class {
* Adds a listener to be notified when history is fully loaded for the first
* time. If history is already loaded...will be called immediately.
*
* @param {function(!importer.ImportHistory)} listener
* @param {function(!importerHistoryInterfaces.ImportHistory)} listener
*/
addHistoryLoadedListener(listener) {}
};
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {importerHistoryInterfaces};
......@@ -20,7 +20,7 @@ var importer = importer || {};
importer.MediaImportHandler = class extends importer.ImportRunner {
/**
* @param {!ProgressCenter} progressCenter
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
* @param {!importer.DispositionChecker.CheckerFunction} dispositionChecker
* @param {!DriveSyncHandler} driveSyncHandler
*/
......@@ -41,7 +41,7 @@ importer.MediaImportHandler = class extends importer.ImportRunner {
importer.MediaImportHandler.ImportTask = class {
/**
* @param {string} taskId
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
* @param {!importer.ScanResult} scanResult
* @param {!Promise<!DirectoryEntry>} directoryPromise
* @param {!importer.Destination} destination The logical destination.
......
......@@ -79,6 +79,7 @@ js_type_check("closure_compile_jsmodules") {
":crostini.m",
":entry_location_impl.m",
":file_operation_util.m",
":import_history.m",
":metadata_proxy.m",
":mock_drive_sync_handler.m",
":mock_file_operation_manager.m",
......@@ -93,11 +94,13 @@ js_type_check("closure_compile_jsmodules") {
":volume_manager_util.m",
]
closure_flags = strict_error_checking_closure_args + [
"js_module_root=./gen/ui",
"js_module_root=../../ui",
"hide_warnings_for=third_party/",
]
closure_flags =
strict_error_checking_closure_args + [
"js_module_root=./gen/ui",
"js_module_root=../../ui",
"browser_resolver_prefix_replacements=\"chrome://test/=./\"",
"hide_warnings_for=third_party/",
]
}
js_type_check("test_support_modules_type_check") {
......@@ -106,7 +109,15 @@ js_type_check("test_support_modules_type_check") {
deps = [
":mock_crostini.m",
":mock_volume_manager.m",
":test_import_history.m",
]
closure_flags =
strict_error_checking_closure_args + [
"js_module_root=./gen/ui",
"js_module_root=../../ui",
"browser_resolver_prefix_replacements=\"chrome://test/=./\"",
"hide_warnings_for=third_party/",
]
}
js_type_check("test_support_type_check") {
......@@ -501,11 +512,29 @@ js_library("import_history") {
externs_list = [ "//ui/file_manager/externs/background/import_history.js" ]
}
js_unittest("import_history_unittest") {
js_library("import_history.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/import_history.m.js" ]
deps = [
":import_history",
"//ui/file_manager/file_manager/common/js:mock_entry",
"//ui/file_manager/file_manager/common/js:test_importer_common",
":metadata_proxy.m",
"//ui/file_manager/externs/background:import_history.m",
"//ui/file_manager/file_manager/common/js:importer_common.m",
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js:assert.m",
]
extra_deps = [ ":modulize" ]
}
js_unittest("import_history_unittest.m") {
deps = [
":import_history.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/base/js:mock_chrome.m",
"//ui/file_manager/base/js:test_error_reporting.m",
"//ui/file_manager/externs/background:import_history.m",
"//ui/file_manager/file_manager/common/js:mock_entry.m",
"//ui/file_manager/file_manager/common/js:test_importer_common.m",
"//ui/file_manager/file_manager/common/js:unittest_util.m",
]
}
......@@ -757,6 +786,17 @@ js_library("test_import_history") {
]
}
js_library("test_import_history.m") {
sources = [ "$root_gen_dir/ui/file_manager/file_manager/background/js/test_import_history.m.js" ]
deps = [
":import_history.m",
"//chrome/test/data/webui:chai_assert",
"//ui/file_manager/file_manager/common/js:importer_common.m",
]
extra_deps = [ ":modulize" ]
}
js_library("trash") {
deps = [
":file_operation_util",
......@@ -894,6 +934,7 @@ js_library("volume_manager_util.m") {
js_test_gen_html("js_test_gen_html_modules") {
deps = [
":crostini_unittest.m",
":import_history_unittest.m",
":metadata_proxy_unittest.m",
":mount_metrics_unittest.m",
":task_queue_unittest.m",
......@@ -916,7 +957,6 @@ js_test_gen_html("js_test_gen_html") {
":duplicate_finder_unittest",
":file_operation_handler_unittest",
":file_operation_manager_unittest",
":import_history_unittest",
":media_import_handler_unittest",
":media_scanner_unittest",
":trash_unittest",
......@@ -946,6 +986,8 @@ js_modulizer("modulize") {
"mock_progress_center.js",
"mount_metrics.js",
"task_queue.js",
"test_import_history.js",
"import_history.js",
]
namespace_rewrites = cr_namespace_rewrites
......
......@@ -27,10 +27,10 @@ class FileBrowserBackgroundImpl extends BackgroundBaseImpl {
* Class providing loading of import history, used in
* cloud import.
*
* @type {!importer.HistoryLoader}
* @type {!importerHistoryInterfaces.HistoryLoader}
*/
this.historyLoader =
new importer.SynchronizedHistoryLoader(importer.getHistoryFiles);
new importerHistory.SynchronizedHistoryLoader(importer.getHistoryFiles);
/**
* Event handler for progress center.
......@@ -66,7 +66,7 @@ class FileBrowserBackgroundImpl extends BackgroundBaseImpl {
* @type {!importer.MediaScanner}
*/
this.mediaScanner = new importer.DefaultMediaScanner(
importer.createMetadataHashcode, this.dispositionChecker_,
importerHistory.createMetadataHashcode, this.dispositionChecker_,
importer.DefaultDirectoryWatcher.create);
/**
......
......@@ -46,7 +46,7 @@ importer.DriveDuplicateFinder = class DriveDuplicateFinder {
* @private
*/
computeHash_(entry) {
return importer.createMetadataHashcode(entry).then(hashcode => {
return importerHistory.createMetadataHashcode(entry).then(hashcode => {
// Cache key is the concatenation of metadata hashcode and URL.
const cacheKey = hashcode + '|' + entry.toURL();
if (this.hashCache_.hasKey(cacheKey)) {
......@@ -177,11 +177,11 @@ importer.DriveDuplicateFinder.MAX_CACHED_HASHCODES_ = 10000;
*/
importer.DispositionCheckerImpl = class {
/**
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
* @param {!importer.DriveDuplicateFinder} contentMatcher
*/
constructor(historyLoader, contentMatcher) {
/** @private {!importer.HistoryLoader} */
/** @private {!importerHistoryInterfaces.HistoryLoader} */
this.historyLoader_ = historyLoader;
/** @private {!importer.DriveDuplicateFinder} */
......@@ -239,7 +239,7 @@ importer.DispositionCheckerImpl = class {
hasHistoryDuplicate_(entry, destination) {
return this.historyLoader_.getHistory().then(
/**
* @param {!importer.ImportHistory} history
* @param {!importerHistoryInterfaces.ImportHistory} history
* @return {!Promise}
*/
history => {
......@@ -262,7 +262,7 @@ importer.DispositionCheckerImpl = class {
/**
* Factory for a function that returns an entry's disposition.
*
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
*
* @return {!importer.DispositionChecker.CheckerFunction}
*/
......
......@@ -23,7 +23,7 @@ const fileUrls = {};
/** @type {!MockFileSystem} */
let fileSystem;
/** @type {!importer.TestImportHistory} */
/** @type {!importerTestHistory.TestImportHistory} */
let testHistory;
/** @type {importer.DispositionChecker.CheckerFunction} */
......@@ -35,7 +35,7 @@ window.metrics = {
function setUp() {
window.loadTimeData.getString = id => id;
let mockChrome = {
const mockChrome = {
fileManagerPrivate: {
/**
* @param {!Entry} entry
......@@ -74,7 +74,7 @@ function setUp() {
MockVolumeManager.installMockSingleton(volumeManager);
testHistory = new importer.TestImportHistory();
testHistory = new importerTestHistory.TestImportHistory();
duplicateFinder = new importer.DriveDuplicateFinder();
getDisposition = importer.DispositionCheckerImpl.createChecker(testHistory);
}
......
......@@ -2,6 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
import { assertEquals,assertFalse, assertTrue} from 'chrome://test/chai_assert.js';
import {MockChromeStorageAPI} from '../../../base/js/mock_chrome.m.js';
import {reportPromise} from '../../../base/js/test_error_reporting.m.js';
import {importerHistoryInterfaces} from '../../../externs/background/import_history.m.js';
import { MockFileEntry,MockFileSystem} from '../../common/js/mock_entry.m.js';
import {importer} from '../../common/js/test_importer_common.m.js';
import {TestCallRecorder} from '../../common/js/unittest_util.m.js';
import {importerHistory} from './import_history.m.js';
// clang-format on
/** @const {string} */
const FILE_LAST_MODIFIED = new Date('Dec 4 1968').toString();
......@@ -32,17 +45,17 @@ let testFileEntry;
/** @type {!importer.TestLogger} */
let testLogger;
/** @type {!importer.RecordStorage} */
/** @type {!importerHistory.RecordStorage} */
let storage;
/** @type {!Promise<!importer.ImportHistory>} */
/** @type {!Promise<!importerHistoryInterfaces.ImportHistory>} */
let historyProvider;
/** @type {Promise} */
let testPromise;
// Set up the test components.
function setUp() {
export function setUp() {
setupChromeApis();
installTestLogger();
......@@ -59,8 +72,8 @@ function setUp() {
storage = new TestRecordStorage();
const history = new importer.PersistentImportHistory(
importer.createMetadataHashcode, storage);
const history = new importerHistory.PersistentImportHistory(
importerHistory.createMetadataHashcode, storage);
historyProvider = history.whenReady();
}
......@@ -70,7 +83,7 @@ function tearDown() {
testPromise = null;
}
function testWasCopied_FalseForUnknownEntry(callback) {
export function testWasCopied_FalseForUnknownEntry(callback) {
// TestRecordWriter is pre-configured with a Space Cloud entry
// but not for this file.
testPromise = historyProvider.then(history => {
......@@ -80,7 +93,7 @@ function testWasCopied_FalseForUnknownEntry(callback) {
reportPromise(testPromise, callback);
}
function testWasCopied_TrueForKnownEntryLoadedFromStorage(callback) {
export function testWasCopied_TrueForKnownEntryLoadedFromStorage(callback) {
// TestRecordWriter is pre-configured with this entry.
testPromise = historyProvider.then(history => {
return history.wasCopied(testFileEntry, GOOGLE_DRIVE).then(assertTrue);
......@@ -90,7 +103,7 @@ function testWasCopied_TrueForKnownEntryLoadedFromStorage(callback) {
}
function testMarkCopied_FiresChangedEvent(callback) {
export function testMarkCopied_FiresChangedEvent(callback) {
testPromise = historyProvider.then(history => {
const recorder = new TestCallRecorder();
history.addObserver(recorder.callback);
......@@ -98,7 +111,7 @@ function testMarkCopied_FiresChangedEvent(callback) {
return Promise.resolve().then(() => {
recorder.assertCallCount(1);
assertEquals(
importer.ImportHistoryState.COPIED,
importerHistory.ImportHistoryState.COPIED,
recorder.getLastArguments()[0]['state']);
});
});
......@@ -107,7 +120,7 @@ function testMarkCopied_FiresChangedEvent(callback) {
reportPromise(testPromise, callback);
}
function testMarkImported_ByUrl(callback) {
export function testMarkImported_ByUrl(callback) {
const destinationUrl =
'filesystem:chrome-extension://abc/photos/splosion.jpg';
testPromise = historyProvider.then(history => {
......@@ -123,7 +136,7 @@ function testMarkImported_ByUrl(callback) {
reportPromise(testPromise, callback);
}
function testWasImported_FalseForUnknownEntry(callback) {
export function testWasImported_FalseForUnknownEntry(callback) {
// TestRecordWriter is pre-configured with a Space Cloud entry
// but not for this file.
testPromise = historyProvider.then(history => {
......@@ -133,7 +146,7 @@ function testWasImported_FalseForUnknownEntry(callback) {
reportPromise(testPromise, callback);
}
function testWasImported_TrueForKnownEntryLoadedFromStorage(callback) {
export function testWasImported_TrueForKnownEntryLoadedFromStorage(callback) {
// TestRecordWriter is pre-configured with this entry.
testPromise = historyProvider.then(history => {
return history.wasImported(testFileEntry, GOOGLE_DRIVE).then(assertTrue);
......@@ -142,7 +155,7 @@ function testWasImported_TrueForKnownEntryLoadedFromStorage(callback) {
reportPromise(testPromise, callback);
}
function testWasImported_TrueForKnownEntrySetAtRuntime(callback) {
export function testWasImported_TrueForKnownEntrySetAtRuntime(callback) {
testPromise = historyProvider.then(history => {
return history.markImported(testFileEntry, SPACE_CAMP).then(() => {
return history.wasImported(testFileEntry, SPACE_CAMP).then(assertTrue);
......@@ -152,7 +165,7 @@ function testWasImported_TrueForKnownEntrySetAtRuntime(callback) {
reportPromise(testPromise, callback);
}
function testMarkImport_FiresChangedEvent(callback) {
export function testMarkImport_FiresChangedEvent(callback) {
testPromise = historyProvider.then(history => {
const recorder = new TestCallRecorder();
history.addObserver(recorder.callback);
......@@ -160,7 +173,7 @@ function testMarkImport_FiresChangedEvent(callback) {
return Promise.resolve().then(() => {
recorder.assertCallCount(1);
assertEquals(
importer.ImportHistoryState.IMPORTED,
importerHistory.ImportHistoryState.IMPORTED,
recorder.getLastArguments()[0]['state']);
});
});
......@@ -169,7 +182,7 @@ function testMarkImport_FiresChangedEvent(callback) {
reportPromise(testPromise, callback);
}
function testHistoryObserver_Unsubscribe(callback) {
export function testHistoryObserver_Unsubscribe(callback) {
testPromise = historyProvider.then(history => {
const recorder = new TestCallRecorder();
history.addObserver(recorder.callback);
......@@ -188,7 +201,7 @@ function testHistoryObserver_Unsubscribe(callback) {
reportPromise(testPromise, callback);
}
function testRecordStorage_RemembersPreviouslyWrittenRecords(callback) {
export function testRecordStorage_RemembersPreviouslyWrittenRecords(callback) {
const recorder = new TestCallRecorder();
testPromise = createRealStorage(['recordStorageTest.data']).then(storage => {
return storage.write(['abc', '123']).then(() => {
......@@ -201,7 +214,8 @@ function testRecordStorage_RemembersPreviouslyWrittenRecords(callback) {
reportPromise(testPromise, callback);
}
function testRecordStorage_LoadsRecordsFromMultipleHistoryFiles(callback) {
export function testRecordStorage_LoadsRecordsFromMultipleHistoryFiles(
callback) {
const recorder = new TestCallRecorder();
const remoteData =
......@@ -235,7 +249,7 @@ function testRecordStorage_LoadsRecordsFromMultipleHistoryFiles(callback) {
reportPromise(testPromise, callback);
}
function testRecordStorage_SerializingOperations(callback) {
export function testRecordStorage_SerializingOperations(callback) {
const recorder = new TestCallRecorder();
testPromise = createRealStorage([
'recordStorageTestForSerializing.data'
......@@ -257,9 +271,9 @@ function testRecordStorage_SerializingOperations(callback) {
reportPromise(testPromise, callback);
}
function testCreateMetadataHashcode(callback) {
export function testCreateMetadataHashcode(callback) {
const promise =
importer.createMetadataHashcode(testFileEntry).then(hashcode => {
importerHistory.createMetadataHashcode(testFileEntry).then(hashcode => {
// Note that the expression matches at least 4 numbers
// in the last segment, since we hard code the byte
// size in our test file to a four digit size.
......@@ -291,12 +305,12 @@ function installTestLogger() {
/**
* @param {!Array<string>} fileNames
* @return {!Promise<!importer.RecordStorage>}
* @return {!Promise<!importerHistory.RecordStorage>}
*/
function createRealStorage(fileNames) {
const filePromises = fileNames.map(createFileEntry);
return Promise.all(filePromises).then(fileEntries => {
return new importer.FileBasedRecordStorage(fileEntries);
return new importerHistory.FileBasedRecordStorage(fileEntries);
});
}
......@@ -321,7 +335,7 @@ function createFileEntry(fileName) {
/**
* In-memory test implementation of {@code RecordStorage}.
*
* @implements {importer.RecordStorage}
* @implements {importerHistory.RecordStorage}
*/
class TestRecordStorage {
constructor() {
......
......@@ -18,7 +18,7 @@ importer.MediaImportHandler.ImportTask =
importer.MediaImportHandlerImpl = class {
/**
* @param {!ProgressCenter} progressCenter
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
* @param {!importer.DispositionChecker.CheckerFunction} dispositionChecker
* @param {!DriveSyncHandler} driveSyncHandler
*/
......@@ -27,7 +27,7 @@ importer.MediaImportHandlerImpl = class {
/** @private {!ProgressCenter} */
this.progressCenter_ = progressCenter;
/** @private {!importer.HistoryLoader} */
/** @private {!importerHistoryInterfaces.HistoryLoader} */
this.historyLoader_ = historyLoader;
/** @private {!taskQueueInterfaces.TaskQueue} */
......@@ -204,7 +204,7 @@ importer.MediaImportHandler.ImportTaskImpl =
class extends taskQueue.BaseTaskImpl {
/**
* @param {string} taskId
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
* @param {!importer.ScanResult} scanResult
* @param {!Promise<!DirectoryEntry>} directoryPromise
* @param {!importer.Destination} destination The logical destination.
......@@ -227,7 +227,7 @@ importer.MediaImportHandler.ImportTaskImpl =
/** @private {!importer.ScanResult} */
this.scanResult_ = scanResult;
/** @private {!importer.HistoryLoader} */
/** @private {!importerHistoryInterfaces.HistoryLoader} */
this.historyLoader_ = historyLoader;
/** @private {number} */
......@@ -375,7 +375,7 @@ importer.MediaImportHandler.ImportTaskImpl =
this.historyLoader_.getHistory()
.then(
/**
* @param {!importer.ImportHistory} history
* @param {!importerHistoryInterfaces.ImportHistory} history
*/
history => {
this.scanResult_.getDuplicateFileEntries().forEach(
......@@ -544,7 +544,7 @@ importer.MediaImportHandler.ImportTaskImpl =
this.remainingFilesCount_--;
this.historyLoader_.getHistory()
.then(
/** @param {!importer.ImportHistory} history */
/** @param {!importerHistoryInterfaces.ImportHistory} history */
history => {
history.markImported(entry, this.destination_);
})
......
......@@ -10,7 +10,7 @@ let progressCenter;
/** @type {!importer.MediaImportHandler} */
let mediaImporter;
/** @type {!importer.TestImportHistory} */
/** @type {!importerTestHistory.TestImportHistory} */
let importHistory;
/** @type {!importer.DispositionChecker.CheckerFunction} */
......@@ -91,7 +91,7 @@ function setUp() {
// Setup MediaImporter.
progressCenter = new MockProgressCenter();
importHistory = new importer.TestImportHistory();
importHistory = new importerTestHistory.TestImportHistory();
driveSyncHandler = new MockDriveSyncHandler();
importer.setupTestLogger();
mediaImporter = new importer.MediaImportHandlerImpl(
......
......@@ -19,7 +19,7 @@ let scanner;
*/
const scanMode = importer.ScanMode.HISTORY;
/** @type {!importer.TestImportHistory} */
/** @type {!importerTestHistory.TestImportHistory} */
let importHistory;
/** @type {!TestDirectoryWatcher} */
......@@ -33,7 +33,7 @@ let dispositionChecker;
// Set up the test components.
function setUp() {
importHistory = new importer.TestImportHistory();
importHistory = new importerTestHistory.TestImportHistory();
// Setup a default disposition checker. Tests can replace it at runtime
// if they need specialized disposition check behavior.
......
......@@ -2,17 +2,29 @@
// 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.
*/
// clang-format off
// #import {assertTrue} from 'chrome://test/chai_assert.js';
// #import {importer} from '../../common/js/importer_common.m.js';
// #import {importerHistoryInterfaces} from '../../../externs/background/import_history.m.js';
// clang-format on
// Namespace
var importer = importer || {};
// eslint-disable-next-line no-var
var importerTestHistory = {};
/**
* importer.ImportHistory and importer.HistoryLoader test double.
* ONE STOP SHOPPING!
* importerHistoryInterfaces.ImportHistory and
* importerHistoryInterfaces.HistoryLoader test double. ONE STOP SHOPPING!
*
* @implements {importer.HistoryLoader}
* @implements {importer.ImportHistory}
* @implements {importerHistoryInterfaces.HistoryLoader}
* @implements {importerHistoryInterfaces.ImportHistory}
*/
importer.TestImportHistory = class {
importerTestHistory.TestImportHistory = class {
constructor() {
/** @type {!Object<!Object<!importer.Destination, string>>} */
this.copiedPaths = {};
......@@ -23,7 +35,7 @@ importer.TestImportHistory = class {
/**
* If null, history has been loaded and listeners notified.
*
* @private {Array<!function(!importer.ImportHistory)>}
* @private {Array<!function(!importerHistoryInterfaces.ImportHistory)>}
*/
this.loadListeners_ = [];
}
......@@ -145,3 +157,6 @@ importer.TestImportHistory = class {
/** @override */
removeObserver() {}
};
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {importerTestHistory};
......@@ -23,7 +23,7 @@ class FileManager extends cr.EventTarget {
*/
this.volumeManager_;
/** @private {?importer.HistoryLoader} */
/** @private {?importerHistoryInterfaces.HistoryLoader} */
this.historyLoader_ = null;
/** @private {?Crostini} */
......@@ -35,16 +35,18 @@ class FileManager extends cr.EventTarget {
/**
* ImportHistory. Non-null only once history observer is added in
* {@code addHistoryObserver}.
* @private {?importer.ImportHistory}
* @private {?importerHistoryInterfaces.ImportHistory}
*/
this.importHistory_ = null;
/**
* Bound observer for use with {@code importer.ImportHistory.Observer}.
* The instance is bound once here as {@code ImportHistory.removeObserver}
* uses object equivilency to remove observers.
* Bound observer for use with {@code
* importerHistoryInterfaces.ImportHistory.Observer}. The instance is bound
* once here as {@code ImportHistory.removeObserver} uses object equivilency
* to remove observers.
*
* @private @const {function(!importer.ImportHistory.ChangedEvent)}
* @private
* @const {function(!importerHistoryInterfaces.ImportHistory.ChangedEvent)}
*/
this.onHistoryChangedBound_ = this.onHistoryChanged_.bind(this);
......@@ -471,7 +473,7 @@ class FileManager extends cr.EventTarget {
}
/**
* @return {importer.HistoryLoader}
* @return {importerHistoryInterfaces.HistoryLoader}
*/
get historyLoader() {
return this.historyLoader_;
......@@ -1009,7 +1011,7 @@ class FileManager extends cr.EventTarget {
// we want to update grid/list view when it changes.
this.historyLoader_.addHistoryLoadedListener(
/**
* @param {!importer.ImportHistory} history
* @param {!importerHistoryInterfaces.ImportHistory} history
* @this {FileManager}
*/
history => {
......@@ -1021,7 +1023,7 @@ class FileManager extends cr.EventTarget {
/**
* Handles events when import history changed.
*
* @param {!importer.ImportHistory.ChangedEvent} event
* @param {!importerHistoryInterfaces.ImportHistory.ChangedEvent} event
* @private
*/
onHistoryChanged_(event) {
......
......@@ -105,11 +105,12 @@ function setUp() {
selectionHandler = new FakeFileSelectionHandler();
// Fake HistoryLoader.
const historyLoader = /** @type {!importer.HistoryLoader} */ ({
getHistory: () => {
return Promise.resolve();
},
});
const historyLoader =
/** @type {!importerHistoryInterfaces.HistoryLoader} */ ({
getHistory: () => {
return Promise.resolve();
},
});
// Fake A11yAnnounce.
const a11Messages = [];
......
......@@ -58,7 +58,7 @@ class FileGrid extends cr.ui.Grid {
/** @private {?VolumeManager} */
this.volumeManager_ = null;
/** @private {?importer.HistoryLoader} */
/** @private {?importerHistoryInterfaces.HistoryLoader} */
this.historyLoader_ = null;
/** @private {?AsyncUtil.RateLimiter} */
......@@ -104,7 +104,7 @@ class FileGrid extends cr.ui.Grid {
* @param {!Element} element The grid to decorate.
* @param {!MetadataModel} metadataModel File system metadata.
* @param {!VolumeManager} volumeManager Volume manager instance.
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
* @param {!A11yAnnounce} a11y
*/
static decorate(element, metadataModel, volumeManager, historyLoader, a11y) {
......@@ -856,7 +856,7 @@ class FileGrid extends cr.ui.Grid {
*
* @param {!FileEntry} entry
* @param {Element} box Box to decorate.
* @param {!importer.ImportHistory} history
* @param {!importerHistoryInterfaces.ImportHistory} history
*
* @private
*/
......
......@@ -380,7 +380,7 @@ class FileTable extends cr.ui.Table {
/** @private {boolean} */
this.useModificationByMeTime_ = false;
/** @private {?importer.HistoryLoader} */
/** @private {?importerHistoryInterfaces.HistoryLoader} */
this.historyLoader_ = null;
/** @private {boolean} */
......@@ -406,7 +406,7 @@ class FileTable extends cr.ui.Table {
* @param {!Element} self Table to decorate.
* @param {!MetadataModel} metadataModel To retrieve metadata.
* @param {!VolumeManager} volumeManager To retrieve volume info.
* @param {!importer.HistoryLoader} historyLoader
* @param {!importerHistoryInterfaces.HistoryLoader} historyLoader
* @param {!A11yAnnounce} a11y FileManagerUI to be able to announce a11y
* messages.
* @param {boolean} fullPage True if it's full page File Manager, False if a
......@@ -937,7 +937,7 @@ class FileTable extends cr.ui.Table {
return this.historyLoader_.getHistory()
.then(
/** @param {!importer.ImportHistory} history */
/** @param {!importerHistoryInterfaces.ImportHistory} history */
history => {
return Promise.all([
history.wasImported(fileEntry, destination),
......
......@@ -13,7 +13,7 @@ let directoryModel;
/** @type {!MetadataModel} */
let metadataModel;
/** @type {!importer.HistoryLoader} */
/** @type {!importerHistoryInterfaces.HistoryLoader} */
let historyLoader;
/** @type {!HTMLElement} */
......@@ -31,7 +31,7 @@ function setUp() {
// Setup mock components.
volumeManager = new MockVolumeManager();
metadataModel = new MockMetadataModel({});
historyLoader = /** @type {!importer.HistoryLoader} */ ({
historyLoader = /** @type {!importerHistoryInterfaces.HistoryLoader} */ ({
getHistory: () => {
return Promise.resolve();
},
......
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