Index: chrome/test/data/extensions/api_test/file_system_provider/big_file/test.js |
diff --git a/chrome/test/data/extensions/api_test/file_system_provider/big_file/test.js b/chrome/test/data/extensions/api_test/file_system_provider/big_file/test.js |
index aefd000d324e2fb1a5fdc5bf1cf0c10250a95fda..28401a7d73a6081425b811ff972aeda5b77669e6 100644 |
--- a/chrome/test/data/extensions/api_test/file_system_provider/big_file/test.js |
+++ b/chrome/test/data/extensions/api_test/file_system_provider/big_file/test.js |
@@ -20,12 +20,6 @@ var openedFiles = {}; |
* @type {string} |
* @const |
*/ |
-var FILE_SYSTEM_ID = 'chocolate-id'; |
- |
-/** |
- * @type {string} |
- * @const |
- */ |
var TESTING_TEXT = 'We are bytes at the 5th GB of the file!'; |
/** |
@@ -58,26 +52,6 @@ var TESTING_6GB_FILE = Object.freeze({ |
}); |
/** |
- * Gets volume information for the provided file system. |
- * |
- * @param {string} fileSystemId Id of the provided file system. |
- * @param {function(Object)} callback Callback to be called on result, with the |
- * volume information object in case of success, or null if not found. |
- */ |
-function getVolumeInfo(fileSystemId, callback) { |
- chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { |
- for (var i = 0; i < volumeList.length; i++) { |
- if (volumeList[i].extensionId == chrome.runtime.id && |
- volumeList[i].fileSystemId == fileSystemId) { |
- callback(volumeList[i]); |
- return; |
- } |
- } |
- callback(null); |
- }); |
-} |
- |
-/** |
* Returns metadata for the requested entry. |
* |
* To successfully acquire a DirectoryEntry, or even a DOMFileSystem, this event |
@@ -89,7 +63,7 @@ function getVolumeInfo(fileSystemId, callback) { |
* @param {function(string)} onError Error callback with an error code. |
*/ |
function onGetMetadataRequested(options, onSuccess, onError) { |
- if (options.fileSystemId != FILE_SYSTEM_ID) { |
+ if (options.fileSystemId != test_util.FILE_SYSTEM_ID) { |
onError('INVALID_OPERATION'); // enum ProviderError. |
return; |
} |
@@ -116,7 +90,7 @@ function onGetMetadataRequested(options, onSuccess, onError) { |
* @param {function(string)} onError Error callback. |
*/ |
function onOpenFileRequested(options, onSuccess, onError) { |
- if (options.fileSystemId != FILE_SYSTEM_ID) { |
+ if (options.fileSystemId != test_util.FILE_SYSTEM_ID) { |
onError('INVALID_OPERATION'); // enum ProviderError. |
return; |
} |
@@ -143,7 +117,7 @@ function onOpenFileRequested(options, onSuccess, onError) { |
* @param {function(string)} onError Error callback. |
*/ |
function onCloseFileRequested(options, onSuccess, onError) { |
- if (options.fileSystemId != FILE_SYSTEM_ID || |
+ if (options.fileSystemId != test_util.FILE_SYSTEM_ID || |
!openedFiles[options.openRequestId]) { |
onError('INVALID_OPERATION'); // enum ProviderError. |
return; |
@@ -164,7 +138,7 @@ function onCloseFileRequested(options, onSuccess, onError) { |
*/ |
function onReadFileRequested(options, onSuccess, onError) { |
var filePath = openedFiles[options.openRequestId]; |
- if (options.fileSystemId != FILE_SYSTEM_ID || !filePath) { |
+ if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { |
onError('INVALID_OPERATION'); // enum ProviderError. |
return; |
} |
@@ -198,32 +172,15 @@ function onReadFileRequested(options, onSuccess, onError) { |
* @param {function()} callback Success callback. |
*/ |
function setUp(callback) { |
- chrome.fileSystemProvider.mount( |
- {fileSystemId: FILE_SYSTEM_ID, displayName: 'chocolate.zip'}, |
- function() { |
- chrome.fileSystemProvider.onGetMetadataRequested.addListener( |
- onGetMetadataRequested); |
- chrome.fileSystemProvider.onOpenFileRequested.addListener( |
- onOpenFileRequested); |
- chrome.fileSystemProvider.onReadFileRequested.addListener( |
- onReadFileRequested); |
- var volumeId = |
- 'provided:' + chrome.runtime.id + '-' + FILE_SYSTEM_ID + '-user'; |
- |
- getVolumeInfo(FILE_SYSTEM_ID, function(volumeInfo) { |
- chrome.test.assertTrue(!!volumeInfo); |
- chrome.fileBrowserPrivate.requestFileSystem( |
- volumeInfo.volumeId, |
- function(inFileSystem) { |
- chrome.test.assertTrue(!!inFileSystem); |
- |
- fileSystem = inFileSystem; |
- callback(); |
- }); |
- }); |
- }, function() { |
- chrome.test.fail(); |
- }); |
+ chrome.fileSystemProvider.onGetMetadataRequested.addListener( |
+ onGetMetadataRequested); |
+ chrome.fileSystemProvider.onOpenFileRequested.addListener( |
+ onOpenFileRequested); |
+ chrome.fileSystemProvider.onReadFileRequested.addListener( |
+ onReadFileRequested); |
+ chrome.fileSystemProvider.onCloseFileRequested.addListener( |
+ onCloseFileRequested); |
+ test_util.mountFileSystem(callback); |
} |
/** |
@@ -238,7 +195,7 @@ function runTests() { |
// with size greater or equal to 2^53. |
function readBigFileSuccess() { |
var onTestSuccess = chrome.test.callbackPass(); |
- fileSystem.root.getFile( |
+ test_util.fileSystem.root.getFile( |
TESTING_6GB_FILE.name, |
{create: false}, |
function(fileEntry) { |