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

Side by Side Diff: chrome/test/data/extensions/api_test/file_system_provider/thumbnail/test.js

Issue 985533004: Implement chrome.fileSystem.requestFileSystem(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed kiosk mode. Created 5 years, 9 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
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 {Object} 8 * @type {Object}
9 * @const 9 * @const
10 */ 10 */
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 chrome.test.assertEq('InvalidStateError', error.name); 154 chrome.test.assertEq('InvalidStateError', error.name);
155 })); 155 }));
156 }, 156 },
157 157
158 // Thumbnails should be returned when available for private API request. 158 // Thumbnails should be returned when available for private API request.
159 function getEntryPropertiesWithThumbnailSuccess() { 159 function getEntryPropertiesWithThumbnailSuccess() {
160 test_util.fileSystem.root.getFile( 160 test_util.fileSystem.root.getFile(
161 TESTING_WITH_VALID_THUMBNAIL_FILE.name, 161 TESTING_WITH_VALID_THUMBNAIL_FILE.name,
162 {create: false}, 162 {create: false},
163 chrome.test.callbackPass(function(fileEntry) { 163 chrome.test.callbackPass(function(fileEntry) {
164 chrome.fileManagerPrivate.getEntryProperties( 164 test_util.toExternalEntry(fileEntry).then(
165 [fileEntry.toURL()], 165 chrome.test.callbackPass(function(externalEntry) {
166 ['thumbnailUrl', 'size', 'modificationTime'], 166 chrome.test.assertTrue(!!externalEntry);
167 chrome.test.callbackPass(function(fileProperties) { 167 chrome.fileManagerPrivate.getEntryProperties(
168 chrome.test.assertEq(1, fileProperties.length); 168 [externalEntry.toURL()],
169 chrome.test.assertEq( 169 ['thumbnailUrl', 'size', 'modificationTime'],
170 TESTING_WITH_VALID_THUMBNAIL_FILE.thumbnail, 170 chrome.test.callbackPass(function(fileProperties) {
171 fileProperties[0].thumbnailUrl); 171 chrome.test.assertEq(1, fileProperties.length);
172 chrome.test.assertEq( 172 chrome.test.assertEq(
173 TESTING_WITH_VALID_THUMBNAIL_FILE.size, 173 TESTING_WITH_VALID_THUMBNAIL_FILE.thumbnail,
174 fileProperties[0].size); 174 fileProperties[0].thumbnailUrl);
175 chrome.test.assertEq( 175 chrome.test.assertEq(
176 TESTING_WITH_VALID_THUMBNAIL_FILE.modificationTime, 176 TESTING_WITH_VALID_THUMBNAIL_FILE.size,
177 new Date(fileProperties[0].modificationTime)); 177 fileProperties[0].size);
178 })); 178 chrome.test.assertEq(
179 TESTING_WITH_VALID_THUMBNAIL_FILE.modificationTime,
180 new Date(fileProperties[0].modificationTime));
181 }));
182 })).catch(chrome.test.fail);
179 }), 183 }),
180 function(error) { 184 function(error) {
181 chrome.test.fail(error.name); 185 chrome.test.fail(error.name);
182 }); 186 });
183 }, 187 },
184 188
185 // Confirm that extensions are not able to pass an invalid thumbnail url, 189 // Confirm that extensions are not able to pass an invalid thumbnail url,
186 // including evil urls. 190 // including evil urls.
187 function getEntryPropertiesWithInvalidThumbnail() { 191 function getEntryPropertiesWithInvalidThumbnail() {
188 test_util.fileSystem.root.getFile( 192 test_util.fileSystem.root.getFile(
189 TESTING_WITH_INVALID_THUMBNAIL_FILE.name, 193 TESTING_WITH_INVALID_THUMBNAIL_FILE.name,
190 {create: false}, 194 {create: false},
191 chrome.test.callbackPass(function(fileEntry) { 195 chrome.test.callbackPass(function(fileEntry) {
192 chrome.fileManagerPrivate.getEntryProperties( 196 test_util.toExternalEntry(fileEntry).then(
193 [fileEntry.toURL()], 197 chrome.test.callbackPass(function(externalEntry) {
194 ['thumbnailUrl'], 198 chrome.test.assertTrue(!!externalEntry);
195 chrome.test.callbackPass(function(fileProperties) { 199 chrome.fileManagerPrivate.getEntryProperties(
196 chrome.test.assertEq(1, fileProperties.length); 200 [externalEntry.toURL()],
197 // The results for an entry is an empty dictionary in case of 201 ['thumbnailUrl'],
198 // an error. 202 chrome.test.callbackPass(function(fileProperties) {
199 chrome.test.assertEq( 203 chrome.test.assertEq(1, fileProperties.length);
200 0, Object.keys(fileProperties[0]).length); 204 // The results for an entry is an empty dictionary in
201 })); 205 // case of an error.
206 chrome.test.assertEq(
207 0, Object.keys(fileProperties[0]).length);
208 }));
209 })).catch(chrome.test.fail);
202 }), 210 }),
203 function(error) { 211 function(error) {
204 chrome.test.fail(error.name); 212 chrome.test.fail(error.name);
205 }); 213 });
206 }, 214 },
207 215
208 // Confirm that the thumbnail is not requested when not needed. 216 // Confirm that the thumbnail is not requested when not needed.
209 function getEntryPropertiesWithoutThumbnail() { 217 function getEntryPropertiesWithoutThumbnail() {
210 test_util.fileSystem.root.getFile( 218 test_util.fileSystem.root.getFile(
211 TESTING_WITH_VALID_THUMBNAIL_FILE.name, 219 TESTING_WITH_VALID_THUMBNAIL_FILE.name,
212 {create: false}, 220 {create: false},
213 chrome.test.callbackPass(function(fileEntry) { 221 chrome.test.callbackPass(function(fileEntry) {
214 chrome.fileManagerPrivate.getEntryProperties( 222 test_util.toExternalEntry(fileEntry).then(
215 [fileEntry.toURL()], 223 chrome.test.callbackPass(function(externalEntry) {
216 ['size'], 224 chrome.test.assertTrue(!!externalEntry);
217 chrome.test.callbackPass(function(fileProperties) { 225 chrome.fileManagerPrivate.getEntryProperties(
218 chrome.test.assertEq(1, fileProperties.length); 226 [externalEntry.toURL()],
219 chrome.test.assertFalse( 227 ['size'],
220 'thumbnailUrl' in fileProperties[0]); 228 chrome.test.callbackPass(function(fileProperties) {
221 chrome.test.assertEq( 229 chrome.test.assertEq(1, fileProperties.length);
222 TESTING_WITH_VALID_THUMBNAIL_FILE.size, 230 chrome.test.assertFalse(
223 fileProperties[0].size); 231 'thumbnailUrl' in fileProperties[0]);
224 })); 232 chrome.test.assertEq(
233 TESTING_WITH_VALID_THUMBNAIL_FILE.size,
234 fileProperties[0].size);
235 }));
236 })).catch(chrome.test.fail);
225 }), 237 }),
226 function(error) { 238 function(error) {
227 chrome.test.fail(error.name); 239 chrome.test.fail(error.name);
228 }); 240 });
229 } 241 }
230 ]); 242 ]);
231 } 243 }
232 244
233 // Setup and run all of the test cases. 245 // Setup and run all of the test cases.
234 setUp(runTests); 246 setUp(runTests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698