OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @type {string} | 8 * @type {string} |
9 * @const | 9 * @const |
10 */ | 10 */ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 function unmount() { | 51 function unmount() { |
52 var onTestSuccess = chrome.test.callbackPass(); | 52 var onTestSuccess = chrome.test.callbackPass(); |
53 | 53 |
54 var onMountCompleted = function(event) { | 54 var onMountCompleted = function(event) { |
55 chrome.test.assertEq('unmount', event.eventType); | 55 chrome.test.assertEq('unmount', event.eventType); |
56 chrome.test.assertEq('success', event.status); | 56 chrome.test.assertEq('success', event.status); |
57 chrome.test.assertEq( | 57 chrome.test.assertEq( |
58 chrome.runtime.id, event.volumeMetadata.extensionId); | 58 chrome.runtime.id, event.volumeMetadata.extensionId); |
59 chrome.test.assertEq( | 59 chrome.test.assertEq( |
60 FIRST_FILE_SYSTEM_ID, event.volumeMetadata.fileSystemId); | 60 FIRST_FILE_SYSTEM_ID, event.volumeMetadata.fileSystemId); |
61 chrome.fileBrowserPrivate.onMountCompleted.removeListener( | 61 chrome.fileManagerPrivate.onMountCompleted.removeListener( |
62 onMountCompleted); | 62 onMountCompleted); |
63 onTestSuccess(); | 63 onTestSuccess(); |
64 }; | 64 }; |
65 | 65 |
66 chrome.fileBrowserPrivate.onMountCompleted.addListener( | 66 chrome.fileManagerPrivate.onMountCompleted.addListener( |
67 onMountCompleted); | 67 onMountCompleted); |
68 chrome.fileSystemProvider.unmount( | 68 chrome.fileSystemProvider.unmount( |
69 {fileSystemId: FIRST_FILE_SYSTEM_ID}, | 69 {fileSystemId: FIRST_FILE_SYSTEM_ID}, |
70 function() { | 70 function() { |
71 // Wait for the unmount event. | 71 // Wait for the unmount event. |
72 }, | 72 }, |
73 function(error) { | 73 function(error) { |
74 chrome.test.fail(error.name); | 74 chrome.test.fail(error.name); |
75 }); | 75 }); |
76 }, | 76 }, |
77 | 77 |
78 // Tests the fileSystemProvider.unmount() with a wrong id. Verifies that | 78 // Tests the fileSystemProvider.unmount() with a wrong id. Verifies that |
79 // it fails with a correct error code. | 79 // it fails with a correct error code. |
80 function unmountWrongId() { | 80 function unmountWrongId() { |
81 var onTestSuccess = chrome.test.callbackPass(); | 81 var onTestSuccess = chrome.test.callbackPass(); |
82 chrome.fileSystemProvider.unmount( | 82 chrome.fileSystemProvider.unmount( |
83 {fileSystemId: 'wrong-fs-id'}, | 83 {fileSystemId: 'wrong-fs-id'}, |
84 function() { | 84 function() { |
85 chrome.test.fail(); | 85 chrome.test.fail(); |
86 }, | 86 }, |
87 function(error) { | 87 function(error) { |
88 chrome.test.assertEq('SecurityError', error.name); | 88 chrome.test.assertEq('SecurityError', error.name); |
89 onTestSuccess(); | 89 onTestSuccess(); |
90 }); | 90 }); |
91 }, | 91 }, |
92 | 92 |
93 // Tests if fileBrowserPrivate.removeMount() for provided file systems emits | 93 // Tests if fileManagerPrivate.removeMount() for provided file systems emits |
94 // the onMountRequested() event with correct arguments. | 94 // the onMountRequested() event with correct arguments. |
95 function requestUnmountSuccess() { | 95 function requestUnmountSuccess() { |
96 var onTestSuccess = chrome.test.callbackPass(); | 96 var onTestSuccess = chrome.test.callbackPass(); |
97 | 97 |
98 var onUnmountRequested = function(options, onSuccess, onError) { | 98 var onUnmountRequested = function(options, onSuccess, onError) { |
99 chrome.test.assertEq(SECOND_FILE_SYSTEM_ID, options.fileSystemId); | 99 chrome.test.assertEq(SECOND_FILE_SYSTEM_ID, options.fileSystemId); |
100 onSuccess(); | 100 onSuccess(); |
101 // Not calling fileSystemProvider.unmount(), so the onMountCompleted | 101 // Not calling fileSystemProvider.unmount(), so the onMountCompleted |
102 // event will not be raised. | 102 // event will not be raised. |
103 chrome.fileSystemProvider.onUnmountRequested.removeListener( | 103 chrome.fileSystemProvider.onUnmountRequested.removeListener( |
104 onUnmountRequested); | 104 onUnmountRequested); |
105 onTestSuccess(); | 105 onTestSuccess(); |
106 }; | 106 }; |
107 | 107 |
108 chrome.fileSystemProvider.onUnmountRequested.addListener( | 108 chrome.fileSystemProvider.onUnmountRequested.addListener( |
109 onUnmountRequested); | 109 onUnmountRequested); |
110 | 110 |
111 test_util.getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) { | 111 test_util.getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) { |
112 chrome.test.assertTrue(!!volumeInfo); | 112 chrome.test.assertTrue(!!volumeInfo); |
113 chrome.fileBrowserPrivate.removeMount(volumeInfo.volumeId); | 113 chrome.fileManagerPrivate.removeMount(volumeInfo.volumeId); |
114 }); | 114 }); |
115 }, | 115 }, |
116 | 116 |
117 // End to end test with a failure. Invokes fileSystemProvider.removeMount() | 117 // End to end test with a failure. Invokes fileSystemProvider.removeMount() |
118 // on a provided file system, and verifies (1) if the onMountRequested() | 118 // on a provided file system, and verifies (1) if the onMountRequested() |
119 // event is called with correct aguments, and (2) if calling onError(), | 119 // event is called with correct aguments, and (2) if calling onError(), |
120 // results in an unmount event fired from the VolumeManager instance. | 120 // results in an unmount event fired from the VolumeManager instance. |
121 function requestUnmountError() { | 121 function requestUnmountError() { |
122 var onTestSuccess = chrome.test.callbackPass(); | 122 var onTestSuccess = chrome.test.callbackPass(); |
123 var unmountRequested = false; | 123 var unmountRequested = false; |
(...skipping 10 matching lines...) Expand all Loading... |
134 var onMountCompleted = function(event) { | 134 var onMountCompleted = function(event) { |
135 chrome.test.assertEq('unmount', event.eventType); | 135 chrome.test.assertEq('unmount', event.eventType); |
136 chrome.test.assertEq('error_unknown', event.status); | 136 chrome.test.assertEq('error_unknown', event.status); |
137 chrome.test.assertEq( | 137 chrome.test.assertEq( |
138 chrome.runtime.id, event.volumeMetadata.extensionId); | 138 chrome.runtime.id, event.volumeMetadata.extensionId); |
139 chrome.test.assertEq( | 139 chrome.test.assertEq( |
140 SECOND_FILE_SYSTEM_ID, event.volumeMetadata.fileSystemId); | 140 SECOND_FILE_SYSTEM_ID, event.volumeMetadata.fileSystemId); |
141 chrome.test.assertTrue(unmountRequested); | 141 chrome.test.assertTrue(unmountRequested); |
142 | 142 |
143 // Remove the handlers and mark the test as succeeded. | 143 // Remove the handlers and mark the test as succeeded. |
144 chrome.fileBrowserPrivate.removeMount(SECOND_FILE_SYSTEM_ID); | 144 chrome.fileManagerPrivate.removeMount(SECOND_FILE_SYSTEM_ID); |
145 chrome.fileBrowserPrivate.onMountCompleted.removeListener( | 145 chrome.fileManagerPrivate.onMountCompleted.removeListener( |
146 onMountCompleted); | 146 onMountCompleted); |
147 onTestSuccess(); | 147 onTestSuccess(); |
148 }; | 148 }; |
149 | 149 |
150 chrome.fileSystemProvider.onUnmountRequested.addListener( | 150 chrome.fileSystemProvider.onUnmountRequested.addListener( |
151 onUnmountRequested); | 151 onUnmountRequested); |
152 chrome.fileBrowserPrivate.onMountCompleted.addListener(onMountCompleted); | 152 chrome.fileManagerPrivate.onMountCompleted.addListener(onMountCompleted); |
153 | 153 |
154 test_util.getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) { | 154 test_util.getVolumeInfo(SECOND_FILE_SYSTEM_ID, function(volumeInfo) { |
155 chrome.test.assertTrue(!!volumeInfo); | 155 chrome.test.assertTrue(!!volumeInfo); |
156 chrome.fileBrowserPrivate.removeMount(volumeInfo.volumeId); | 156 chrome.fileManagerPrivate.removeMount(volumeInfo.volumeId); |
157 }); | 157 }); |
158 } | 158 } |
159 ]); | 159 ]); |
160 } | 160 } |
161 | 161 |
162 // Setup and run all of the test cases. | 162 // Setup and run all of the test cases. |
163 setUp(runTests); | 163 setUp(runTests); |
OLD | NEW |