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 chrome.test.runTests([ | 5 chrome.test.runTests([ |
6 function goodDisplayName() { | 6 function goodDisplayName() { |
7 chrome.fileSystemProvider.mount( | 7 chrome.fileSystemProvider.mount( |
8 'test file system', | 8 'test file system', |
9 function(fileSystemId) { | 9 function(fileSystemId) { |
10 chrome.test.assertEq('string', typeof(fileSystemId)); | 10 chrome.test.assertEq('number', typeof(fileSystemId)); |
11 chrome.test.assertTrue(fileSystemId != ''); | 11 chrome.test.assertTrue(fileSystemId == 1); |
12 chrome.test.succeed(); | 12 chrome.test.succeed(); |
13 }, | 13 }, |
14 function(error) { | 14 function(error) { |
15 chrome.test.fail(); | 15 chrome.test.fail(); |
16 } | 16 } |
17 ); | 17 ); |
18 }, | 18 }, |
19 | 19 |
20 function emptyDisplayName() { | 20 function emptyDisplayName() { |
21 chrome.fileSystemProvider.mount( | 21 chrome.fileSystemProvider.mount( |
22 '', | 22 '', |
23 function(fileSystemId) { | 23 function(fileSystemId) { |
24 chrome.test.fail(); | 24 chrome.test.fail(); |
25 }, | 25 }, |
26 function(error) { | 26 function(error) { |
27 chrome.test.assertEq('SecurityError', error.name); | 27 chrome.test.assertEq('SecurityError', error.name); |
28 chrome.test.succeed(); | 28 chrome.test.succeed(); |
29 } | 29 } |
30 ); | 30 ); |
31 }, | 31 }, |
32 | 32 |
33 function successfulMount() { | 33 function successfulMount() { |
34 chrome.fileSystemProvider.mount( | 34 chrome.fileSystemProvider.mount( |
35 'caramel-candy.zip', | 35 'caramel-candy.zip', |
36 function(fileSystemId) { | 36 function(fileSystemId) { |
37 chrome.test.assertTrue(fileSystemId != ''); | 37 chrome.test.assertTrue(fileSystemId > 0); |
38 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { | 38 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { |
39 var found = volumeList.filter(function(volumeInfo) { | 39 var found = volumeList.filter(function(volumeInfo) { |
40 return volumeInfo.volumeId == 'provided:' + fileSystemId; | 40 return volumeInfo.volumeId == |
| 41 'provided:' + chrome.runtime.id + '-' + fileSystemId + '-user'; |
41 }); | 42 }); |
42 chrome.test.assertEq(1, found.length); | 43 chrome.test.assertEq(1, found.length); |
43 chrome.test.succeed(); | 44 chrome.test.succeed(); |
44 }); | 45 }); |
45 }, | 46 }, |
46 function(error) { | 47 function(error) { |
47 chrome.test.fail(); | 48 chrome.test.fail(); |
48 }); | 49 }); |
49 }, | 50 }, |
50 | 51 |
51 function stressMountTest() { | 52 function stressMountTest() { |
52 // Try to create more than allowed number of file systems. All of the mount | 53 // Try to create more than allowed number of file systems. All of the mount |
53 // requests should succeed, except the last one which should fail with a | 54 // requests should succeed, except the last one which should fail with a |
54 // security error. | 55 // security error. |
55 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests. | 56 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests. |
56 var MAX_FILE_SYSTEMS = 16; | 57 var MAX_FILE_SYSTEMS = 16; |
57 var index = 0; | 58 var index = 0; |
58 var tryNextOne = function() { | 59 var tryNextOne = function() { |
59 index++; | 60 index++; |
60 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { | 61 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { |
61 chrome.fileSystemProvider.mount( | 62 chrome.fileSystemProvider.mount( |
62 index + 'th file system', | 63 index + 'th file system', |
63 function(fileSystemId) { | 64 function(fileSystemId) { |
64 chrome.test.assertTrue(fileSystemId != ''); | 65 chrome.test.assertTrue(fileSystemId > 0); |
65 tryNextOne(); | 66 tryNextOne(); |
66 }, | 67 }, |
67 chrome.test.fail); | 68 chrome.test.fail); |
68 } else { | 69 } else { |
69 chrome.fileSystemProvider.mount( | 70 chrome.fileSystemProvider.mount( |
70 'over the limit fs', | 71 'over the limit fs', |
71 chrome.test.fail, | 72 chrome.test.fail, |
72 function(error) { | 73 function(error) { |
73 chrome.test.assertEq('SecurityError', error.name); | 74 chrome.test.assertEq('SecurityError', error.name); |
74 chrome.test.succeed(); | 75 chrome.test.succeed(); |
75 }); | 76 }); |
76 } | 77 } |
77 }; | 78 }; |
78 tryNextOne(); | 79 tryNextOne(); |
79 } | 80 } |
80 ]); | 81 ]); |
OLD | NEW |