Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/test/data/extensions/api_test/file_system_provider/mount/test.js

Issue 194693002: [fsp] Add requestUnmount() method together with the request manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed some too strict thread checks. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Tests whether mounting succeeds, when a non-empty name is provided.
6 function goodDisplayName() { 7 function goodDisplayName() {
7 chrome.fileSystemProvider.mount( 8 chrome.fileSystemProvider.mount(
8 'test file system', 9 'test file system',
9 function(fileSystemId) { 10 function(fileSystemId) {
10 chrome.test.assertEq('number', typeof(fileSystemId)); 11 chrome.test.assertEq('number', typeof(fileSystemId));
11 chrome.test.assertTrue(fileSystemId == 1); 12 chrome.test.assertTrue(fileSystemId == 1);
12 chrome.test.succeed(); 13 chrome.test.succeed();
13 }, 14 },
14 function(error) { 15 function(error) {
15 chrome.test.fail(); 16 chrome.test.fail();
16 } 17 }
17 ); 18 );
18 }, 19 },
19 20
21 // Verifies that mounting fails, when an empty string is provided as a name.
20 function emptyDisplayName() { 22 function emptyDisplayName() {
21 chrome.fileSystemProvider.mount( 23 chrome.fileSystemProvider.mount(
22 '', 24 '',
23 function(fileSystemId) { 25 function(fileSystemId) {
24 chrome.test.fail(); 26 chrome.test.fail();
25 }, 27 },
26 function(error) { 28 function(error) {
27 chrome.test.assertEq('SecurityError', error.name); 29 chrome.test.assertEq('SecurityError', error.name);
28 chrome.test.succeed(); 30 chrome.test.succeed();
29 } 31 }
30 ); 32 );
31 }, 33 },
32 34
35 // End to end test. Mounts a volume using fileSystemProvider.mount(), then
36 // checks if the mounted volume is added to VolumeManager, by querying
37 // fileBrowserPrivate.getVolumeMetadataList().
33 function successfulMount() { 38 function successfulMount() {
34 chrome.fileSystemProvider.mount( 39 chrome.fileSystemProvider.mount(
35 'caramel-candy.zip', 40 'caramel-candy.zip',
36 function(fileSystemId) { 41 function(fileSystemId) {
37 chrome.test.assertTrue(fileSystemId > 0); 42 chrome.test.assertTrue(fileSystemId > 0);
38 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { 43 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
39 var found = volumeList.filter(function(volumeInfo) { 44 var found = volumeList.filter(function(volumeInfo) {
40 return volumeInfo.volumeId == 45 return volumeInfo.volumeId ==
41 'provided:' + chrome.runtime.id + '-' + fileSystemId + '-user'; 46 'provided:' + chrome.runtime.id + '-' + fileSystemId + '-user';
42 }); 47 });
43 chrome.test.assertEq(1, found.length); 48 chrome.test.assertEq(1, found.length);
44 chrome.test.succeed(); 49 chrome.test.succeed();
45 }); 50 });
46 }, 51 },
47 function(error) { 52 function(error) {
48 chrome.test.fail(); 53 chrome.test.fail();
49 }); 54 });
50 }, 55 },
51 56
57 // Checks is limit for mounted file systems per profile works correctly.
58 // Tries to create more than allowed number of file systems. All of the mount
59 // requests should succeed, except the last one which should fail with a
60 // security error.
52 function stressMountTest() { 61 function stressMountTest() {
53 // Try to create more than allowed number of file systems. All of the mount
54 // requests should succeed, except the last one which should fail with a
55 // security error.
56 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests. 62 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests.
57 var MAX_FILE_SYSTEMS = 16; 63 var MAX_FILE_SYSTEMS = 16;
58 var index = 0; 64 var index = 0;
59 var tryNextOne = function() { 65 var tryNextOne = function() {
60 index++; 66 index++;
61 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { 67 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) {
62 chrome.fileSystemProvider.mount( 68 chrome.fileSystemProvider.mount(
63 index + 'th file system', 69 index + 'th file system',
64 function(fileSystemId) { 70 function(fileSystemId) {
65 chrome.test.assertTrue(fileSystemId > 0); 71 chrome.test.assertTrue(fileSystemId > 0);
66 tryNextOne(); 72 tryNextOne();
67 }, 73 },
68 chrome.test.fail); 74 chrome.test.fail);
69 } else { 75 } else {
70 chrome.fileSystemProvider.mount( 76 chrome.fileSystemProvider.mount(
71 'over the limit fs', 77 'over the limit fs',
72 chrome.test.fail, 78 chrome.test.fail,
73 function(error) { 79 function(error) {
74 chrome.test.assertEq('SecurityError', error.name); 80 chrome.test.assertEq('SecurityError', error.name);
75 chrome.test.succeed(); 81 chrome.test.succeed();
76 }); 82 });
77 } 83 }
78 }; 84 };
79 tryNextOne(); 85 tryNextOne();
80 } 86 }
81 ]); 87 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698