OLD | NEW |
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(); | 13 var onTestSuccess = chrome.test.callbackPass(); |
14 chrome.fileSystemProvider.mount( | 14 chrome.fileSystemProvider.mount( |
15 'file-system-id', | 15 {fileSystemId: 'file-system-id', displayName: 'file-system-name'}, |
16 'File System Name', | |
17 function() { | 16 function() { |
18 onTestSuccess(); | 17 onTestSuccess(); |
19 }, | 18 }, |
20 function(error) { | 19 function(error) { |
21 chrome.test.fail(); | 20 chrome.test.fail(); |
22 }); | 21 }); |
23 }, | 22 }, |
24 | 23 |
25 // Verifies that mounting fails, when an empty string is provided as a name. | 24 // Verifies that mounting fails, when an empty string is provided as a name. |
26 function emptyDisplayName() { | 25 function emptyDisplayName() { |
27 var onTestSuccess = chrome.test.callbackPass(); | 26 var onTestSuccess = chrome.test.callbackPass(); |
28 chrome.fileSystemProvider.mount( | 27 chrome.fileSystemProvider.mount( |
29 'file-system-id', | 28 {fileSystemId: 'file-system-id', displayName: ''}, |
30 '', | |
31 function() { | 29 function() { |
32 chrome.test.fail(); | 30 chrome.test.fail(); |
33 }, | 31 }, |
34 function(error) { | 32 function(error) { |
35 chrome.test.assertEq('SecurityError', error.name); | 33 chrome.test.assertEq('SecurityError', error.name); |
36 onTestSuccess(); | 34 onTestSuccess(); |
37 }); | 35 }); |
38 }, | 36 }, |
39 // Verifies that mounting fails, when an empty string is provided as an Id | 37 // Verifies that mounting fails, when an empty string is provided as an Id |
40 function emptyFileSystemId() { | 38 function emptyFileSystemId() { |
41 var onTestSuccess = chrome.test.callbackPass(); | 39 var onTestSuccess = chrome.test.callbackPass(); |
42 chrome.fileSystemProvider.mount( | 40 chrome.fileSystemProvider.mount( |
43 '', | 41 {fileSystemId: '', displayName: 'File System Name'}, |
44 'File System Name', | |
45 function() { | 42 function() { |
46 chrome.test.fail(); | 43 chrome.test.fail(); |
47 }, | 44 }, |
48 function(error) { | 45 function(error) { |
49 chrome.test.assertEq('SecurityError', error.name); | 46 chrome.test.assertEq('SecurityError', error.name); |
50 onTestSuccess(); | 47 onTestSuccess(); |
51 } | 48 } |
52 ); | 49 ); |
53 }, | 50 }, |
54 | 51 |
55 // End to end test. Mounts a volume using fileSystemProvider.mount(), then | 52 // End to end test. Mounts a volume using fileSystemProvider.mount(), then |
56 // checks if the mounted volume is added to VolumeManager, by querying | 53 // checks if the mounted volume is added to VolumeManager, by querying |
57 // fileBrowserPrivate.getVolumeMetadataList(). | 54 // fileBrowserPrivate.getVolumeMetadataList(). |
58 function successfulMount() { | 55 function successfulMount() { |
59 var onTestSuccess = chrome.test.callbackPass(); | 56 var onTestSuccess = chrome.test.callbackPass(); |
60 var fileSystemId = 'caramel-candy'; | 57 var fileSystemId = 'caramel-candy'; |
61 chrome.fileSystemProvider.mount( | 58 chrome.fileSystemProvider.mount( |
62 fileSystemId, | 59 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'}, |
63 'caramel-candy.zip', | |
64 function() { | 60 function() { |
65 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { | 61 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { |
66 var found = false; | 62 var found = false; |
67 volumeList.forEach(function(volumeInfo) { | 63 volumeList.forEach(function(volumeInfo) { |
68 if (volumeInfo.extensionId == chrome.runtime.id && | 64 if (volumeInfo.extensionId == chrome.runtime.id && |
69 volumeInfo.fileSystemId == fileSystemId) { | 65 volumeInfo.fileSystemId == fileSystemId) { |
70 found = true; | 66 found = true; |
71 } | 67 } |
72 }); | 68 }); |
73 chrome.test.assertTrue(found); | 69 chrome.test.assertTrue(found); |
(...skipping 12 matching lines...) Expand all Loading... |
86 function stressMountTest() { | 82 function stressMountTest() { |
87 var onTestSuccess = chrome.test.callbackPass(); | 83 var onTestSuccess = chrome.test.callbackPass(); |
88 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests. | 84 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests. |
89 var MAX_FILE_SYSTEMS = 16; | 85 var MAX_FILE_SYSTEMS = 16; |
90 var index = 0; | 86 var index = 0; |
91 var tryNextOne = function() { | 87 var tryNextOne = function() { |
92 index++; | 88 index++; |
93 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { | 89 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { |
94 var fileSystemId = index + '-stress-test'; | 90 var fileSystemId = index + '-stress-test'; |
95 chrome.fileSystemProvider.mount( | 91 chrome.fileSystemProvider.mount( |
96 fileSystemId, | 92 {fileSystemId: fileSystemId, displayName: index + 'th File System'}, |
97 index + 'th File System', | |
98 function() { | 93 function() { |
99 tryNextOne(); | 94 tryNextOne(); |
100 }, | 95 }, |
101 function(error) { | 96 function(error) { |
102 chrome.test.fail(error.name); | 97 chrome.test.fail(error.name); |
103 }); | 98 }); |
104 } else { | 99 } else { |
105 chrome.fileSystemProvider.mount( | 100 chrome.fileSystemProvider.mount( |
106 'over-the-limit-fs-id', | 101 { |
107 'Over The Limit File System', | 102 fileSystemId: 'over-the-limit-fs-id', |
| 103 displayName: 'Over The Limit File System' |
| 104 }, |
108 function() { | 105 function() { |
109 chrome.test.fail(); | 106 chrome.test.fail(); |
110 }, | 107 }, |
111 function(error) { | 108 function(error) { |
112 chrome.test.assertEq('SecurityError', error.name); | 109 chrome.test.assertEq('SecurityError', error.name); |
113 onTestSuccess(); | 110 onTestSuccess(); |
114 }); | 111 }); |
115 } | 112 } |
116 }; | 113 }; |
117 tryNextOne(); | 114 tryNextOne(); |
118 } | 115 } |
119 ]); | 116 ]); |
OLD | NEW |