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);
38 // Verifies that mounting fails, when an empty string is provided as an Id
39 function emptyFileSystemId() {
40 var onTestSuccess = chrome.test.callbackPass();
41 chrome.fileSystemProvider.mount(
42 {fileSystemId: '', displayName: 'File System Name'},
47 chrome.test.assertEq('SecurityError', error.name);
53 // End to end test. Mounts a volume using fileSystemProvider.mount(), then
54 // checks if the mounted volume is added to VolumeManager, by querying
55 // fileBrowserPrivate.getVolumeMetadataList().
56 function successfulMount() {
57 var onTestSuccess = chrome.test.callbackPass();
58 var fileSystemId = 'caramel-candy';
59 chrome.fileSystemProvider.mount(
60 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'},
62 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
64 volumeList.forEach(function(inVolumeInfo) {
65 if (inVolumeInfo.extensionId == chrome.runtime.id &&
66 inVolumeInfo.fileSystemId == fileSystemId) {
67 volumeInfo = inVolumeInfo;
70 chrome.test.assertTrue(!!volumeInfo);
71 chrome.test.assertTrue(volumeInfo.isReadOnly);
80 // Checks whether mounting a file system in writable mode ends up on filling
81 // out the volume info properly.
82 function successfulWritableMount() {
83 var onTestSuccess = chrome.test.callbackPass();
84 var fileSystemId = 'caramel-fudges';
85 chrome.fileSystemProvider.mount(
87 fileSystemId: fileSystemId,
88 displayName: 'caramel-fudges.zip',
92 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
94 volumeList.forEach(function(inVolumeInfo) {
95 if (inVolumeInfo.extensionId == chrome.runtime.id &&
96 inVolumeInfo.fileSystemId == fileSystemId) {
97 volumeInfo = inVolumeInfo;
100 chrome.test.assertTrue(!!volumeInfo);
101 chrome.test.assertFalse(volumeInfo.isReadOnly);
110 // Checks is limit for mounted file systems per profile works correctly.
111 // Tries to create more than allowed number of file systems. All of the mount
112 // requests should succeed, except the last one which should fail with a
114 function stressMountTest() {
115 var onTestSuccess = chrome.test.callbackPass();
116 var ALREADY_MOUNTED_FILE_SYSTEMS = 3; // By previous tests.
117 var MAX_FILE_SYSTEMS = 16;
119 var tryNextOne = function() {
121 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) {
122 var fileSystemId = index + '-stress-test';
123 chrome.fileSystemProvider.mount(
124 {fileSystemId: fileSystemId, displayName: index + 'th File System'},
129 chrome.test.fail(error.name);
132 chrome.fileSystemProvider.mount(
134 fileSystemId: 'over-the-limit-fs-id',
135 displayName: 'Over The Limit File System'
141 chrome.test.assertEq('SecurityError', error.name);