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

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

Issue 372163006: [fsp] Add an option for mounting in R/W mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests. Created 6 years, 5 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
« no previous file with comments | « chrome/common/extensions/api/file_system_provider.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '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([
(...skipping 16 matching lines...) Expand all
27 chrome.fileSystemProvider.mount( 27 chrome.fileSystemProvider.mount(
28 {fileSystemId: 'file-system-id', displayName: ''}, 28 {fileSystemId: 'file-system-id', displayName: ''},
29 function() { 29 function() {
30 chrome.test.fail(); 30 chrome.test.fail();
31 }, 31 },
32 function(error) { 32 function(error) {
33 chrome.test.assertEq('SecurityError', error.name); 33 chrome.test.assertEq('SecurityError', error.name);
34 onTestSuccess(); 34 onTestSuccess();
35 }); 35 });
36 }, 36 },
37
37 // Verifies that mounting fails, when an empty string is provided as an Id 38 // Verifies that mounting fails, when an empty string is provided as an Id
38 function emptyFileSystemId() { 39 function emptyFileSystemId() {
39 var onTestSuccess = chrome.test.callbackPass(); 40 var onTestSuccess = chrome.test.callbackPass();
40 chrome.fileSystemProvider.mount( 41 chrome.fileSystemProvider.mount(
41 {fileSystemId: '', displayName: 'File System Name'}, 42 {fileSystemId: '', displayName: 'File System Name'},
42 function() { 43 function() {
43 chrome.test.fail(); 44 chrome.test.fail();
44 }, 45 },
45 function(error) { 46 function(error) {
46 chrome.test.assertEq('SecurityError', error.name); 47 chrome.test.assertEq('SecurityError', error.name);
47 onTestSuccess(); 48 onTestSuccess();
48 } 49 }
49 ); 50 );
50 }, 51 },
51 52
52 // End to end test. Mounts a volume using fileSystemProvider.mount(), then 53 // End to end test. Mounts a volume using fileSystemProvider.mount(), then
53 // checks if the mounted volume is added to VolumeManager, by querying 54 // checks if the mounted volume is added to VolumeManager, by querying
54 // fileBrowserPrivate.getVolumeMetadataList(). 55 // fileBrowserPrivate.getVolumeMetadataList().
55 function successfulMount() { 56 function successfulMount() {
56 var onTestSuccess = chrome.test.callbackPass(); 57 var onTestSuccess = chrome.test.callbackPass();
57 var fileSystemId = 'caramel-candy'; 58 var fileSystemId = 'caramel-candy';
58 chrome.fileSystemProvider.mount( 59 chrome.fileSystemProvider.mount(
59 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'}, 60 {fileSystemId: fileSystemId, displayName: 'caramel-candy.zip'},
60 function() { 61 function() {
61 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) { 62 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
62 var found = false; 63 var volumeInfo;
63 volumeList.forEach(function(volumeInfo) { 64 volumeList.forEach(function(inVolumeInfo) {
64 if (volumeInfo.extensionId == chrome.runtime.id && 65 if (inVolumeInfo.extensionId == chrome.runtime.id &&
65 volumeInfo.fileSystemId == fileSystemId) { 66 inVolumeInfo.fileSystemId == fileSystemId) {
66 found = true; 67 volumeInfo = inVolumeInfo;
67 } 68 }
68 }); 69 });
69 chrome.test.assertTrue(found); 70 chrome.test.assertTrue(!!volumeInfo);
71 chrome.test.assertTrue(volumeInfo.isReadOnly);
70 onTestSuccess(); 72 onTestSuccess();
71 }); 73 });
72 }, 74 },
75 function(error) {
76 chrome.test.fail();
77 });
78 },
79
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(
86 {
87 fileSystemId: fileSystemId,
88 displayName: 'caramel-fudges.zip',
89 writable: true
90 },
91 function() {
92 chrome.fileBrowserPrivate.getVolumeMetadataList(function(volumeList) {
93 var volumeInfo;
94 volumeList.forEach(function(inVolumeInfo) {
95 if (inVolumeInfo.extensionId == chrome.runtime.id &&
96 inVolumeInfo.fileSystemId == fileSystemId) {
97 volumeInfo = inVolumeInfo;
98 }
99 });
100 chrome.test.assertTrue(!!volumeInfo);
101 chrome.test.assertFalse(volumeInfo.isReadOnly);
102 onTestSuccess();
103 });
104 },
73 function(error) { 105 function(error) {
74 chrome.test.fail(); 106 chrome.test.fail();
75 }); 107 });
76 }, 108 },
77 109
78 // Checks is limit for mounted file systems per profile works correctly. 110 // 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 111 // 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 112 // requests should succeed, except the last one which should fail with a
81 // security error. 113 // security error.
82 function stressMountTest() { 114 function stressMountTest() {
83 var onTestSuccess = chrome.test.callbackPass(); 115 var onTestSuccess = chrome.test.callbackPass();
84 var ALREADY_MOUNTED_FILE_SYSTEMS = 2; // By previous tests. 116 var ALREADY_MOUNTED_FILE_SYSTEMS = 3; // By previous tests.
85 var MAX_FILE_SYSTEMS = 16; 117 var MAX_FILE_SYSTEMS = 16;
86 var index = 0; 118 var index = 0;
87 var tryNextOne = function() { 119 var tryNextOne = function() {
88 index++; 120 index++;
89 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) { 121 if (index < MAX_FILE_SYSTEMS - ALREADY_MOUNTED_FILE_SYSTEMS + 1) {
90 var fileSystemId = index + '-stress-test'; 122 var fileSystemId = index + '-stress-test';
91 chrome.fileSystemProvider.mount( 123 chrome.fileSystemProvider.mount(
92 {fileSystemId: fileSystemId, displayName: index + 'th File System'}, 124 {fileSystemId: fileSystemId, displayName: index + 'th File System'},
93 function() { 125 function() {
94 tryNextOne(); 126 tryNextOne();
(...skipping 12 matching lines...) Expand all
107 }, 139 },
108 function(error) { 140 function(error) {
109 chrome.test.assertEq('SecurityError', error.name); 141 chrome.test.assertEq('SecurityError', error.name);
110 onTestSuccess(); 142 onTestSuccess();
111 }); 143 });
112 } 144 }
113 }; 145 };
114 tryNextOne(); 146 tryNextOne();
115 } 147 }
116 ]); 148 ]);
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/file_system_provider.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698