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 var onTestSuccess = chrome.test.callbackPass();
14 chrome.fileSystemProvider.mount(
15 {fileSystemId: 'file-system-id', displayName: 'file-system-name'},
24 // Verifies that mounting fails, when an empty string is provided as a name.
25 function emptyDisplayName() {
26 var onTestSuccess = chrome.test.callbackPass();
27 chrome.fileSystemProvider.mount(
28 {fileSystemId: 'file-system-id', displayName: ''},
33 chrome.test.assertEq('SecurityError', error.name);
37 // Verifies that mounting fails, when an empty string is provided as an Id
38 function emptyFileSystemId() {
39 var onTestSuccess = chrome.test.callbackPass();
40 chrome.fileSystemProvider.mount(
41 {fileSystemId: '', displayName: 'File System Name'},
46 chrome.test.assertEq('SecurityError', error.name);
52 // End to end test. Mounts a volume using fileSystemProvider.mount(), then
53 // checks if the mounted volume is added to VolumeManager, by querying
54 // fileBrowserPrivate.getVolumeMetadataList().
55 function successfulMount() {
56 var onTestSuccess = chrome.test.callbackPass();
57 var fileSystemId = 'caramel-candy';
58 chrome.fileSystemProvider.mount(
59 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'},
61 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
63 volumeList.forEach(function(volumeInfo) {
64 if (volumeInfo.extensionId == chrome.runtime.id &&
65 volumeInfo.fileSystemId == fileSystemId) {
69 chrome.test.assertTrue(found);
78 // Checks is limit for mounted file systems per profile works correctly.
79 // Tries to create more than allowed number of file systems. All of the mount
80 // requests should succeed, except the last one which should fail with a
82 function stressMountTest() {
83 var onTestSuccess = chrome.test.callbackPass();
84 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests.
85 var MAX_FILE_SYSTEMS = 16;
87 var tryNextOne = function() {
89 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) {
90 var fileSystemId = index + '-stress-test';
91 chrome.fileSystemProvider.mount(
92 {fileSystemId: fileSystemId, displayName: index + 'th File System'},
97 chrome.test.fail(error.name);
100 chrome.fileSystemProvider.mount(
102 fileSystemId: 'over-the-limit-fs-id',
103 displayName: 'Over The Limit File System'
109 chrome.test.assertEq('SecurityError', error.name);