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

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

Issue 824753003: [fsp] Wire limiting number of opened files to FSP API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 5 years, 11 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 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 chrome.fileSystemProvider.mount( 13 chrome.fileSystemProvider.mount(
14 {fileSystemId: 'file-system-id', displayName: 'file-system-name'}, 14 {fileSystemId: 'file-system-id', displayName: 'file-system-name'},
15 chrome.test.callbackPass()); 15 chrome.test.callbackPass());
16 }, 16 },
17 17
18 // Verifies that mounting fails, when an empty string is provided as a name. 18 // Verifies that mounting fails, when an empty string is provided as a name.
19 function emptyDisplayName() { 19 function emptyDisplayName() {
20 chrome.fileSystemProvider.mount( 20 chrome.fileSystemProvider.mount(
21 {fileSystemId: 'file-system-id', displayName: ''}, 21 {fileSystemId: 'file-system-id-2', displayName: ''},
22 chrome.test.callbackFail('INVALID_OPERATION')); 22 chrome.test.callbackFail('INVALID_OPERATION'));
23 }, 23 },
24 24
25 // Verifies that mounting fails, when an empty string is provided as an Id 25 // Verifies that mounting fails, when an empty string is provided as an Id
26 function emptyFileSystemId() { 26 function emptyFileSystemId() {
27 chrome.fileSystemProvider.mount( 27 chrome.fileSystemProvider.mount(
28 {fileSystemId: '', displayName: 'File System Name'}, 28 {fileSystemId: '', displayName: 'File System Name'},
29 chrome.test.callbackFail('INVALID_OPERATION')); 29 chrome.test.callbackFail('INVALID_OPERATION'));
30 }, 30 },
31 31
32 // Verifies that mounting succeeds, when a positive limit for opened files is
33 // provided.
34 function goodOpenedFilesLimit() {
35 chrome.fileSystemProvider.mount({
36 fileSystemId: 'file-system-id-3',
37 displayName: 'File System Name',
38 openedFilesLimit: 10
39 }, chrome.test.callbackPass());
40 },
41
42 // Verifies that mounting succeeds, when limit for number of opened files is
43 // set to 0. It means no limit.
44 function goodOpenedFilesLimit() {
45 chrome.fileSystemProvider.mount({
46 fileSystemId: 'file-system-id-4',
47 displayName: 'File System Name',
48 openedFilesLimit: 0
49 }, chrome.test.callbackPass());
50 },
51
52 // Verifies that mounting fails, when a negative limit for opened files is
53 // provided.
54 function illegalOpenedFilesLimit() {
55 chrome.fileSystemProvider.mount({
56 fileSystemId: 'file-system-id-5',
57 displayName: 'File System Name',
58 openedFilesLimit: -1
59 }, chrome.test.callbackFail('INVALID_OPERATION'));
60 },
61
32 // End to end test. Mounts a volume using fileSystemProvider.mount(), then 62 // End to end test. Mounts a volume using fileSystemProvider.mount(), then
33 // checks if the mounted volume is added to VolumeManager, by querying 63 // checks if the mounted volume is added to VolumeManager, by querying
34 // fileManagerPrivate.getVolumeMetadataList(). 64 // fileManagerPrivate.getVolumeMetadataList().
35 function successfulMount() { 65 function successfulMount() {
36 var fileSystemId = 'caramel-candy'; 66 var fileSystemId = 'caramel-candy';
37 chrome.fileSystemProvider.mount( 67 chrome.fileSystemProvider.mount(
38 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'}, 68 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'},
39 chrome.test.callbackPass(function() { 69 chrome.test.callbackPass(function() {
40 chrome.fileManagerPrivate.getVolumeMetadataList(function(volumeList) { 70 chrome.fileManagerPrivate.getVolumeMetadataList(function(volumeList) {
41 var volumeInfo; 71 var volumeInfo;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 chrome.test.assertFalse(volumeInfo.isReadOnly); 104 chrome.test.assertFalse(volumeInfo.isReadOnly);
75 }); 105 });
76 })); 106 }));
77 }, 107 },
78 108
79 // Checks is limit for mounted file systems per profile works correctly. 109 // Checks is limit for mounted file systems per profile works correctly.
80 // Tries to create more than allowed number of file systems. All of the mount 110 // Tries to create more than allowed number of file systems. All of the mount
81 // requests should succeed, except the last one which should fail with a 111 // requests should succeed, except the last one which should fail with a
82 // security error. 112 // security error.
83 function stressMountTest() { 113 function stressMountTest() {
84 var ALREADY_MOUNTED_FILE_SYSTEMS = 3; // By previous tests. 114 var ALREADY_MOUNTED_FILE_SYSTEMS = 5; // By previous tests.
85 var MAX_FILE_SYSTEMS = 16; 115 var MAX_FILE_SYSTEMS = 16;
86 var index = 0; 116 var index = 0;
87 var tryNextOne = function() { 117 var tryNextOne = function() {
88 index++; 118 index++;
89 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { 119 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) {
90 var fileSystemId = index + '-stress-test'; 120 var fileSystemId = index + '-stress-test';
91 chrome.fileSystemProvider.mount( 121 chrome.fileSystemProvider.mount(
92 {fileSystemId: fileSystemId, displayName: index + 'th File System'}, 122 {fileSystemId: fileSystemId, displayName: index + 'th File System'},
93 chrome.test.callbackPass(tryNextOne)); 123 chrome.test.callbackPass(tryNextOne));
94 } else { 124 } else {
95 chrome.fileSystemProvider.mount( 125 chrome.fileSystemProvider.mount(
96 { 126 {
97 fileSystemId: 'over-the-limit-fs-id', 127 fileSystemId: 'over-the-limit-fs-id',
98 displayName: 'Over The Limit File System' 128 displayName: 'Over The Limit File System'
99 }, 129 },
100 chrome.test.callbackFail('TOO_MANY_OPENED')); 130 chrome.test.callbackFail('TOO_MANY_OPENED'));
101 } 131 }
102 }; 132 };
103 tryNextOne(); 133 tryNextOne();
104 } 134 }
105 ]); 135 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698