| 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 /* | 5 /* |
| 6 This component extension test does the following: | 6 This component extension test does the following: |
| 7 | 7 |
| 8 1. Creates an abc and log file on the local file system with some random text. | 8 1. Creates an abc and log file on the local file system with some random text. |
| 9 2. Finds a registered task (file item context menu) for abc file and invokes it | 9 2. Finds a registered task (file item context menu) for abc file and invokes it |
| 10 with url of the test file. | 10 with url of the test file. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 var TestRunner = function(expectations) { | 71 var TestRunner = function(expectations) { |
| 72 this.expectations_ = expectations; | 72 this.expectations_ = expectations; |
| 73 this.fileCreator_ = new TestFileCreator("tmp", true /* shouldRandomize */); | 73 this.fileCreator_ = new TestFileCreator("tmp", true /* shouldRandomize */); |
| 74 this.listener_ = this.onHandlerRequest_.bind(this); | 74 this.listener_ = this.onHandlerRequest_.bind(this); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 // Starts the test. | 77 // Starts the test. |
| 78 TestRunner.prototype.runTest = function() { | 78 TestRunner.prototype.runTest = function() { |
| 79 // Get local FS, create dir with a file in it. | 79 // Get local FS, create dir with a file in it. |
| 80 console.log('Requesting local file system...'); | 80 console.log('Requesting local file system...'); |
| 81 chrome.extension.onMessageExternal.addListener(this.listener_); | 81 chrome.runtime.onMessageExternal.addListener(this.listener_); |
| 82 chrome.fileBrowserPrivate.requestLocalFileSystem( | 82 chrome.fileBrowserPrivate.requestLocalFileSystem( |
| 83 this.onFileSystemFetched_.bind(this)); | 83 this.onFileSystemFetched_.bind(this)); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 TestRunner.prototype.onFileSystemFetched_ = function(fs) { | 86 TestRunner.prototype.onFileSystemFetched_ = function(fs) { |
| 87 if (!fs) { | 87 if (!fs) { |
| 88 this.errorCallback_(chrome.extensions.lastError); | 88 this.errorCallback_(chrome.extensions.lastError); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 chrome.test.fail(message); | 184 chrome.test.fail(message); |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 // Listens for the request from the filesystem_handler extension. When the | 187 // Listens for the request from the filesystem_handler extension. When the |
| 188 // event is received, it verifies it and stops listening for further events. | 188 // event is received, it verifies it and stops listening for further events. |
| 189 TestRunner.prototype.onHandlerRequest_ = | 189 TestRunner.prototype.onHandlerRequest_ = |
| 190 function(request, sender, sendResponse) { | 190 function(request, sender, sendResponse) { |
| 191 this.expectations_.verifyHandlerRequest( | 191 this.expectations_.verifyHandlerRequest( |
| 192 request, | 192 request, |
| 193 this.verifyRequestCallback_.bind(this, sendResponse)); | 193 this.verifyRequestCallback_.bind(this, sendResponse)); |
| 194 chrome.extension.onMessageExternal.removeListener(this.listener_); | 194 chrome.runtime.onMessageExternal.removeListener(this.listener_); |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 TestRunner.prototype.verifyRequestCallback_ = function(sendResponse, error) { | 197 TestRunner.prototype.verifyRequestCallback_ = function(sendResponse, error) { |
| 198 if (!error) { | 198 if (!error) { |
| 199 sendResponse({success: true}); | 199 sendResponse({success: true}); |
| 200 this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), | 200 this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), |
| 201 this.reportFail_.bind(this, | 201 this.reportFail_.bind(this, |
| 202 cleanupError)); | 202 cleanupError)); |
| 203 } else { | 203 } else { |
| 204 sendResponse({success: false}); | 204 sendResponse({success: false}); |
| 205 this.errorCallback_(error); | 205 this.errorCallback_(error); |
| 206 } | 206 } |
| 207 }; | 207 }; |
| OLD | NEW |