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

Unified Diff: chrome/test/data/extensions/api_test/file_system_provider/read_directory/test.js

Issue 374543002: [fsp] Simplify browser tests by extracting the common code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/file_system_provider/read_directory/test.js
diff --git a/chrome/test/data/extensions/api_test/file_system_provider/read_directory/test.js b/chrome/test/data/extensions/api_test/file_system_provider/read_directory/test.js
index 1a4703cec2d583ff5bab8a8d045f658151c95d68..c62755820c1ba19369e0272cd871e9fdd0d5eda2 100644
--- a/chrome/test/data/extensions/api_test/file_system_provider/read_directory/test.js
+++ b/chrome/test/data/extensions/api_test/file_system_provider/read_directory/test.js
@@ -10,12 +10,6 @@
var fileSystem = null;
/**
- * @type {string}
- * @const
- */
-var FILE_SYSTEM_ID = 'vanilla';
-
-/**
* @type {Object}
* @const
*/
@@ -60,26 +54,6 @@ var TESTING_TIRAMISU_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 entries in the requested directory.
*
* @param {ReadDirectoryRequestedOptions} options Options.
@@ -88,7 +62,7 @@ function getVolumeInfo(fileSystemId, callback) {
* @param {function(string)} onError Error callback with an error code.
*/
function onReadDirectoryRequested(options, onSuccess, onError) {
- if (options.fileSystemId != FILE_SYSTEM_ID) {
+ if (options.fileSystemId != test_util.FILE_SYSTEM_ID) {
onError('SECURITY'); // enum ProviderError.
return;
}
@@ -114,7 +88,7 @@ function onReadDirectoryRequested(options, onSuccess, onError) {
* @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('SECURITY'); // enum ProviderError.
return;
}
@@ -139,31 +113,11 @@ function onGetMetadataRequested(options, onSuccess, onError) {
* @param {function()} callback Success callback.
*/
function setUp(callback) {
- chrome.fileSystemProvider.mount(
- {
- fileSystemId: FILE_SYSTEM_ID,
- displayName: 'chocolate.zip'
- },
- function() {
- chrome.fileSystemProvider.onReadDirectoryRequested.addListener(
- onReadDirectoryRequested);
- chrome.fileSystemProvider.onGetMetadataRequested.addListener(
- onGetMetadataRequested);
- 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.onReadDirectoryRequested.addListener(
+ onReadDirectoryRequested);
+ test_util.mountFileSystem(callback);
}
/**
@@ -175,7 +129,7 @@ function runTests() {
// should succeed.
function readEntriesSuccess() {
var onTestSuccess = chrome.test.callbackPass();
- fileSystem.root.getDirectory(
+ test_util.fileSystem.root.getDirectory(
'hello',
{create: false},
function(dirEntry) {
@@ -212,7 +166,7 @@ function runTests() {
// error.
function readEntriesError() {
var onTestSuccess = chrome.test.callbackPass();
- fileSystem.root.getDirectory(
+ test_util.fileSystem.root.getDirectory(
'cranberries',
{create: false},
function(dirEntry) {

Powered by Google App Engine
This is Rietveld 408576698