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
3 // found in the LICENSE file.
8 * Runs all of the test cases, one by one.
10 chrome.test.runTests([
11 // Tests whether mounting succeeds, when a non-empty name is provided.
12 function goodDisplayName() {
13 chrome.fileSystemProvider.mount(
14 {fileSystemId: 'file-system-id', displayName: 'file-system-name'},
15 chrome.test.callbackPass());
18 // Verifies that mounting fails, when an empty string is provided as a name.
19 function emptyDisplayName() {
20 chrome.fileSystemProvider.mount(
21 {fileSystemId: 'file-system-id-2', displayName: ''},
22 chrome.test.callbackFail('INVALID_OPERATION'));
25 // Verifies that mounting fails, when an empty string is provided as an Id
26 function emptyFileSystemId() {
27 chrome.fileSystemProvider.mount(
28 {fileSystemId: '', displayName: 'File System Name'},
29 chrome.test.callbackFail('INVALID_OPERATION'));
32 // Verifies that mounting succeeds, when a positive limit for opened files is
34 function goodOpenedFilesLimit() {
35 chrome.fileSystemProvider.mount({
36 fileSystemId: 'file-system-id-3',
37 displayName: 'File System Name',
39 }, chrome.test.callbackPass());
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',
49 }, chrome.test.callbackPass());
52 // Verifies that mounting fails, when a negative limit for opened files is
54 function illegalOpenedFilesLimit() {
55 chrome.fileSystemProvider.mount({
56 fileSystemId: 'file-system-id-5',
57 displayName: 'File System Name',
59 }, chrome.test.callbackFail('INVALID_OPERATION'));
62 // End to end test. Mounts a volume using fileSystemProvider.mount(), then
63 // checks if the mounted volume is added to VolumeManager, by querying
64 // fileManagerPrivate.getVolumeMetadataList().
65 function successfulMount() {
66 var fileSystemId = 'caramel-candy';
67 chrome.fileSystemProvider.mount(
68 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'},
69 chrome.test.callbackPass(function() {
70 chrome.fileManagerPrivate.getVolumeMetadataList(function(volumeList) {
72 volumeList.forEach(function(inVolumeInfo) {
73 if (inVolumeInfo.extensionId == chrome.runtime.id &&
74 inVolumeInfo.fileSystemId == fileSystemId) {
75 volumeInfo = inVolumeInfo;
78 chrome.test.assertTrue(!!volumeInfo);
79 chrome.test.assertTrue(volumeInfo.isReadOnly);
84 // Checks whether mounting a file system in writable mode ends up on filling
85 // out the volume info properly.
86 function successfulWritableMount() {
87 var fileSystemId = 'caramel-fudges';
88 chrome.fileSystemProvider.mount(
90 fileSystemId: fileSystemId,
91 displayName: 'caramel-fudges.zip',
94 chrome.test.callbackPass(function() {
95 chrome.fileManagerPrivate.getVolumeMetadataList(function(volumeList) {
97 volumeList.forEach(function(inVolumeInfo) {
98 if (inVolumeInfo.extensionId == chrome.runtime.id &&
99 inVolumeInfo.fileSystemId == fileSystemId) {
100 volumeInfo = inVolumeInfo;
103 chrome.test.assertTrue(!!volumeInfo);
104 chrome.test.assertFalse(volumeInfo.isReadOnly);
109 // Checks is limit for mounted file systems per profile works correctly.
110 // Tries to create more than allowed number of file systems. All of the mount
111 // requests should succeed, except the last one which should fail with a
113 function stressMountTest() {
114 var ALREADY_MOUNTED_FILE_SYSTEMS = 5; // By previous tests.
115 var MAX_FILE_SYSTEMS = 16;
117 var tryNextOne = function() {
119 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) {
120 var fileSystemId = index + '-stress-test';
121 chrome.fileSystemProvider.mount(
122 {fileSystemId: fileSystemId, displayName: index + 'th File System'},
123 chrome.test.callbackPass(tryNextOne));
125 chrome.fileSystemProvider.mount(
127 fileSystemId: 'over-the-limit-fs-id',
128 displayName: 'Over The Limit File System'
130 chrome.test.callbackFail('TOO_MANY_OPENED'));