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

Side by Side Diff: chrome/test/data/extensions/api_test/file_system_provider/unmount/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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/extensions/api_test/file_system_provider/unmount/manifest.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @type {string} 8 * @type {string}
9 * @const 9 * @const
10 */ 10 */
11 var FIRST_FILE_SYSTEM_ID = 'vanilla'; 11 var FIRST_FILE_SYSTEM_ID = 'vanilla';
12 12
13 /** 13 /**
14 * @type {string} 14 * @type {string}
15 * @const 15 * @const
16 */ 16 */
17 var SECOND_FILE_SYSTEM_ID = 'ice-cream'; 17 var SECOND_FILE_SYSTEM_ID = 'ice-cream';
18 18
19 /** 19 /**
20 * Gets volume information for the provided file system.
21 *
22 * @param {string} fileSystemId Id of the provided file system.
23 * @param {function(Object)} callback Callback to be called on result, with the
24 * volume information object in case of success, or null if not found.
25 */
26 function getVolumeInfo(fileSystemId, callback) {
27 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
28 for (var i = 0; i < volumeList.length; i++) {
29 if (volumeList[i].extensionId == chrome.runtime.id &&
30 volumeList[i].fileSystemId == fileSystemId) {
31 callback(volumeList[i]);
32 return;
33 }
34 }
35 callback(null);
36 });
37 }
38
39 /**
40 * Sets up the tests. Called once per all test cases. In case of a failure, 20 * Sets up the tests. Called once per all test cases. In case of a failure,
41 * the callback is not called. 21 * the callback is not called.
42 * 22 *
43 * @param {function()} callback Success callback. 23 * @param {function()} callback Success callback.
44 */ 24 */
45 function setUp(callback) { 25 function setUp(callback) {
46 Promise.race([ 26 Promise.race([
47 new Promise(function(fulfill, reject) { 27 new Promise(function(fulfill, reject) {
48 chrome.fileSystemProvider.mount( 28 chrome.fileSystemProvider.mount(
49 {fileSystemId: FIRST_FILE_SYSTEM_ID, displayName: 'vanilla.zip'}, 29 {fileSystemId: FIRST_FILE_SYSTEM_ID, displayName: 'vanilla.zip'},
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Not calling fileSystemProvider.unmount(), so the onMountCompleted 101 // Not calling fileSystemProvider.unmount(), so the onMountCompleted
122 // event will not be raised. 102 // event will not be raised.
123 chrome.fileSystemProvider.onUnmountRequested.removeListener( 103 chrome.fileSystemProvider.onUnmountRequested.removeListener(
124 onUnmountRequested); 104 onUnmountRequested);
125 onTestSuccess(); 105 onTestSuccess();
126 }; 106 };
127 107
128 chrome.fileSystemProvider.onUnmountRequested.addListener( 108 chrome.fileSystemProvider.onUnmountRequested.addListener(
129 onUnmountRequested); 109 onUnmountRequested);
130 110
131 getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) { 111 test_util.getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) {
132 chrome.test.assertTrue(!!volumeInfo); 112 chrome.test.assertTrue(!!volumeInfo);
133 chrome.fileBrowserPrivate.removeMount(volumeInfo.volumeId); 113 chrome.fileBrowserPrivate.removeMount(volumeInfo.volumeId);
134 }); 114 });
135 }, 115 },
136 116
137 // End to end test with a failure. Invokes fileSystemProvider.removeMount() 117 // End to end test with a failure. Invokes fileSystemProvider.removeMount()
138 // on a provided file system, and verifies (1) if the onMountRequested() 118 // on a provided file system, and verifies (1) if the onMountRequested()
139 // event is called with correct aguments, and (2) if calling onError(), 119 // event is called with correct aguments, and (2) if calling onError(),
140 // results in an unmount event fired from the VolumeManager instance. 120 // results in an unmount event fired from the VolumeManager instance.
141 function requestUnmountError() { 121 function requestUnmountError() {
(...skipping 22 matching lines...) Expand all
164 chrome.fileBrowserPrivate.removeMount(SECOND_FILE_SYSTEM_ID); 144 chrome.fileBrowserPrivate.removeMount(SECOND_FILE_SYSTEM_ID);
165 chrome.fileBrowserPrivate.onMountCompleted.removeListener( 145 chrome.fileBrowserPrivate.onMountCompleted.removeListener(
166 onMountCompleted); 146 onMountCompleted);
167 onTestSuccess(); 147 onTestSuccess();
168 }; 148 };
169 149
170 chrome.fileSystemProvider.onUnmountRequested.addListener( 150 chrome.fileSystemProvider.onUnmountRequested.addListener(
171 onUnmountRequested); 151 onUnmountRequested);
172 chrome.fileBrowserPrivate.onMountCompleted.addListener(onMountCompleted); 152 chrome.fileBrowserPrivate.onMountCompleted.addListener(onMountCompleted);
173 153
174 getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) { 154 test_util.getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) {
175 chrome.test.assertTrue(!!volumeInfo); 155 chrome.test.assertTrue(!!volumeInfo);
176 chrome.fileBrowserPrivate.removeMount(volumeInfo.volumeId); 156 chrome.fileBrowserPrivate.removeMount(volumeInfo.volumeId);
177 }); 157 });
178 } 158 }
179 ]); 159 ]);
180 } 160 }
181 161
182 // Setup and run all of the test cases. 162 // Setup and run all of the test cases.
183 setUp(runTests); 163 setUp(runTests);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/file_system_provider/unmount/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698