| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This test file checks if we can read the expected contents | 5 // This test file checks if we can read the expected contents |
| 6 // (kExpectedContents) from the target file (kFileName). We will try to read | 6 // (kExpectedContents) from the target file (kFileName). We will try to read |
| 7 // the file directly, and using a filesystem handler | 7 // the file directly, and using a filesystem handler |
| 8 // (chorme/test/data/extensions/api_test/filesystem_handler/). What's | 8 // (chorme/test/data/extensions/api_test/filesystem_handler/). What's |
| 9 // interesting is that we'll read the file via a remote mount point. | 9 // interesting is that we'll read the file via a remote mount point. |
| 10 // See external_filesystem_apitest.cc for how this is set up. | 10 // See external_filesystem_apitest.cc for how this is set up. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }, | 109 }, |
| 110 self.errorCallback_.bind(self, 'Error opening file: ')); | 110 self.errorCallback_.bind(self, 'Error opening file: ')); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 TestRunner.prototype.runExecuteReadTask = function() { | 113 TestRunner.prototype.runExecuteReadTask = function() { |
| 114 chrome.test.assertTrue(!!this.fileEntry_); | 114 chrome.test.assertTrue(!!this.fileEntry_); |
| 115 | 115 |
| 116 // Add listener to be invoked when filesystem handler extension sends us | 116 // Add listener to be invoked when filesystem handler extension sends us |
| 117 // response. | 117 // response. |
| 118 this.listener_ = this.onHandlerRequest_.bind(this); | 118 this.listener_ = this.onHandlerRequest_.bind(this); |
| 119 chrome.extension.onMessageExternal.addListener(this.listener_); | 119 chrome.runtime.onMessageExternal.addListener(this.listener_); |
| 120 | 120 |
| 121 var self = this; | 121 var self = this; |
| 122 var fileURL = this.fileEntry_.toURL(); | 122 var fileURL = this.fileEntry_.toURL(); |
| 123 chrome.fileBrowserPrivate.getFileTasks([fileURL], [], | 123 chrome.fileBrowserPrivate.getFileTasks([fileURL], [], |
| 124 function(tasks) { | 124 function(tasks) { |
| 125 tasks = self.filterTasks_(tasks); | 125 tasks = self.filterTasks_(tasks); |
| 126 if (!tasks || !tasks.length) { | 126 if (!tasks || !tasks.length) { |
| 127 self.errorCallback_({message: 'No tasks registered'}, | 127 self.errorCallback_({message: 'No tasks registered'}, |
| 128 'Error fetching tasks: '); | 128 'Error fetching tasks: '); |
| 129 return; | 129 return; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 }, | 178 }, |
| 179 self.errorCallback_.bind(self, 'Error creating writer: ')); | 179 self.errorCallback_.bind(self, 'Error creating writer: ')); |
| 180 }, | 180 }, |
| 181 self.errorCallback_.bind(self, 'Error opening file: ')); | 181 self.errorCallback_.bind(self, 'Error opening file: ')); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 // Processes the response from file handler for which file task was executed. | 184 // Processes the response from file handler for which file task was executed. |
| 185 TestRunner.prototype.onHandlerRequest_ = | 185 TestRunner.prototype.onHandlerRequest_ = |
| 186 function(request, sender, sendResponse) { | 186 function(request, sender, sendResponse) { |
| 187 // We don't have to listen for a response anymore. | 187 // We don't have to listen for a response anymore. |
| 188 chrome.extension.onMessageExternal.removeListener(this.listener_); | 188 chrome.runtime.onMessageExternal.removeListener(this.listener_); |
| 189 | 189 |
| 190 this.verifyHandlerRequest(request, | 190 this.verifyHandlerRequest(request, |
| 191 chrome.test.succeed, | 191 chrome.test.succeed, |
| 192 this.errorCallback_.bind(this, '')); | 192 this.errorCallback_.bind(this, '')); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 TestRunner.prototype.verifyHandlerRequest = | 195 TestRunner.prototype.verifyHandlerRequest = |
| 196 function(request, successCallback, errorCallback) { | 196 function(request, successCallback, errorCallback) { |
| 197 if (!request) { | 197 if (!request) { |
| 198 errorCallback({message: 'Request from handler not defined.'}); | 198 errorCallback({message: 'Request from handler not defined.'}); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 testRunner.runCancelTest(kFileName, 'write'); | 300 testRunner.runCancelTest(kFileName, 'write'); |
| 301 }, | 301 }, |
| 302 function cancelTruncate() { | 302 function cancelTruncate() { |
| 303 testRunner.runCancelTest(kFileName, 'truncate'); | 303 testRunner.runCancelTest(kFileName, 'truncate'); |
| 304 }, | 304 }, |
| 305 function createDir() { | 305 function createDir() { |
| 306 // Creates new directory. | 306 // Creates new directory. |
| 307 testRunner.runGetDirTest(kNewDirectoryPath, true); | 307 testRunner.runGetDirTest(kNewDirectoryPath, true); |
| 308 }, | 308 }, |
| 309 ]); | 309 ]); |
| OLD | NEW |