Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: ui/file_manager/file_manager/background/js/mock_media_scanner.js

Issue 795833002: MediaScanner improvements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pull 'n merge. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * A fake media scanner for testing. 6 * importer.MediaScanner and importer.ScanResult test double.
7 *
7 * @constructor 8 * @constructor
8 * @struct 9 * @struct
10 * @implements {importer.MediaScanner}
11 * @implements {importer.ScanResult}
9 */ 12 */
10 function MockMediaScanner() { 13 function TestMediaScanner() {
11 /** @private {!Array<!FileEntry>} */ 14 /**
12 this.results_ = []; 15 * List of file entries found while scanning.
16 * @type {!Array.<!FileEntry>}
17 */
18 this.fileEntries = [];
19
20 /** @type {number} */
21 this.totalBytes = 100;
22
23 /** @type {number} */
24 this.scanDuration = 100;
25
26 /** @type {!Promise.<!importer.ScanResult>} */
27 this.whenFinished;
13 } 28 }
14 29
15 /** 30 /** @override */
16 * Returns scan "results". 31 TestMediaScanner.prototype.scan = function(entries) {
17 * @return {!Promise<!Array<!FileEntry>>} 32 var result = new TestScanResult(this);
18 */ 33 this.whenFinished = Promise.resolve(result);
19 MockMediaScanner.prototype.scan = function(entries) { 34 return result;
20 return Promise.resolve(this.results_);
21 }; 35 };
22 36
23 /** 37 /**
24 * Sets the entries that the scanner will return. 38 * importer.MediaScanner and importer.ScanResult test double.
25 * @param {!Array<!FileEntry>} entries 39 *
40 * @constructor
41 * @struct
42 * @implements {importer.MediaScanner}
43 * @implements {importer.ScanResult}
44 *
45 * @param {!TestMediaScanner} scanner
26 */ 46 */
27 MockMediaScanner.prototype.setScanResults = function(entries) { 47 function TestScanResult(scanner) {
28 this.results_ = entries; 48 /** @private {!TestMediaScanner} */
49 this.scanner_ = scanner;
50 }
51
52 /** @override */
53 TestScanResult.prototype.getFileEntries = function() {
54 return this.scanner_.fileEntries;
29 }; 55 };
56
57 /** @override */
58 TestScanResult.prototype.getTotalBytes = function() {
59 return this.scanner_.totalBytes;
60 };
61
62 /** @override */
63 TestScanResult.prototype.getScanDurationMs = function() {
64 return this.scanner_.scanDuration;
65 };
66
67 /** @override */
68 TestScanResult.prototype.whenFinished = function() {
69 return this.scanner_.whenFinished;
70 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698