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

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

Issue 294073007: [fsp] Let extensions decide about the file system id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 * Runs all of the test cases, one by one. 8 * Runs all of the test cases, one by one.
9 */ 9 */
10 chrome.test.runTests([ 10 chrome.test.runTests([
11 // Tests whether mounting succeeds, when a non-empty name is provided. 11 // Tests whether mounting succeeds, when a non-empty name is provided.
12 function goodDisplayName() { 12 function goodDisplayName() {
13 var onTestSuccess = chrome.test.callbackPass(function() {}); 13 var onTestSuccess = chrome.test.callbackPass();
14 chrome.fileSystemProvider.mount( 14 chrome.fileSystemProvider.mount(
15 'test file system', 15 'file-system-id',
16 function(fileSystemId) { 16 'File System Name',
17 chrome.test.assertEq('number', typeof(fileSystemId)); 17 function() {
18 chrome.test.assertEq(1, fileSystemId); 18 onTestSuccess();
19 onTestSuccess(); 19 },
20 }, 20 function(error) {
21 function(error) { 21 chrome.test.fail();
22 chrome.test.fail(); 22 });
23 }
24 );
25 }, 23 },
26 24
27 // Verifies that mounting fails, when an empty string is provided as a name. 25 // Verifies that mounting fails, when an empty string is provided as a name.
28 function emptyDisplayName() { 26 function emptyDisplayName() {
29 var onTestSuccess = chrome.test.callbackPass(function() {}); 27 var onTestSuccess = chrome.test.callbackPass();
30 chrome.fileSystemProvider.mount( 28 chrome.fileSystemProvider.mount(
31 '', 29 'file-system-id',
32 function(fileSystemId) { 30 '',
33 chrome.test.fail(); 31 function() {
34 }, 32 chrome.test.fail();
35 function(error) { 33 },
36 chrome.test.assertEq('SecurityError', error.name); 34 function(error) {
37 onTestSuccess(); 35 chrome.test.assertEq('SecurityError', error.name);
38 } 36 onTestSuccess();
39 ); 37 });
38 },
39 // Verifies that mounting fails, when an empty string is provided as an Id
40 function emptyFileSystemId() {
41 var onTestSuccess = chrome.test.callbackPass();
42 chrome.fileSystemProvider.mount(
43 '',
44 'File System Name',
45 function() {
46 chrome.test.fail();
47 },
48 function(error) {
49 chrome.test.assertEq('SecurityError', error.name);
50 onTestSuccess();
51 }
52 );
40 }, 53 },
41 54
42 // End to end test. Mounts a volume using fileSystemProvider.mount(), then 55 // End to end test. Mounts a volume using fileSystemProvider.mount(), then
43 // checks if the mounted volume is added to VolumeManager, by querying 56 // checks if the mounted volume is added to VolumeManager, by querying
44 // fileBrowserPrivate.getVolumeMetadataList(). 57 // fileBrowserPrivate.getVolumeMetadataList().
45 function successfulMount() { 58 function successfulMount() {
46 var onTestSuccess = chrome.test.callbackPass(function() {}); 59 var onTestSuccess = chrome.test.callbackPass();
60 var fileSystemId = 'caramel-candy';
47 chrome.fileSystemProvider.mount( 61 chrome.fileSystemProvider.mount(
48 'caramel-candy.zip', 62 fileSystemId,
49 function(fileSystemId) { 63 'caramel-candy.zip',
50 chrome.test.assertTrue(fileSystemId > 0); 64 function() {
51 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { 65 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
52 var found = volumeList.filter(function(volumeInfo) { 66 var found = false;
53 return volumeInfo.volumeId == 67 volumeList.forEach(function(volumeInfo) {
54 'provided:' + chrome.runtime.id + '-' + fileSystemId + '-user'; 68 if (volumeInfo.extensionId == chrome.runtime.id &&
69 volumeInfo.fileSystemId == fileSystemId) {
70 found = true;
71 }
72 });
73 chrome.test.assertTrue(found);
74 onTestSuccess();
55 }); 75 });
56 chrome.test.assertEq(1, found.length); 76 },
57 onTestSuccess(); 77 function(error) {
78 chrome.test.fail();
58 }); 79 });
59 },
60 function(error) {
61 chrome.test.fail();
62 });
63 }, 80 },
64 81
65 // Checks is limit for mounted file systems per profile works correctly. 82 // Checks is limit for mounted file systems per profile works correctly.
66 // Tries to create more than allowed number of file systems. All of the mount 83 // Tries to create more than allowed number of file systems. All of the mount
67 // requests should succeed, except the last one which should fail with a 84 // requests should succeed, except the last one which should fail with a
68 // security error. 85 // security error.
69 function stressMountTest() { 86 function stressMountTest() {
70 var onTestSuccess = chrome.test.callbackPass(function() {}); 87 var onTestSuccess = chrome.test.callbackPass();
71 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests. 88 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests.
72 var MAX_FILE_SYSTEMS = 16; 89 var MAX_FILE_SYSTEMS = 16;
73 var index = 0; 90 var index = 0;
74 var tryNextOne = function() { 91 var tryNextOne = function() {
75 index++; 92 index++;
76 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { 93 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) {
94 var fileSystemId = index + '-stress-test';
77 chrome.fileSystemProvider.mount( 95 chrome.fileSystemProvider.mount(
78 index + 'th file system', 96 fileSystemId,
79 function(fileSystemId) { 97 index + 'th File System',
80 chrome.test.assertTrue(fileSystemId > 0); 98 function() {
81 tryNextOne(); 99 tryNextOne();
82 }, 100 },
83 chrome.test.fail); 101 function(error) {
102 chrome.test.fail(error.name);
103 });
84 } else { 104 } else {
85 chrome.fileSystemProvider.mount( 105 chrome.fileSystemProvider.mount(
86 'over the limit fs', 106 'over-the-limit-fs-id',
87 chrome.test.fail, 107 'Over The Limit File System',
108 function() {
109 chrome.test.fail();
110 },
88 function(error) { 111 function(error) {
89 chrome.test.assertEq('SecurityError', error.name); 112 chrome.test.assertEq('SecurityError', error.name);
90 onTestSuccess(); 113 onTestSuccess();
91 }); 114 });
92 } 115 }
93 }; 116 };
94 tryNextOne(); 117 tryNextOne();
95 } 118 }
96 ]); 119 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698