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 a txt 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 txt 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. |
11 3. Listens for a message from context menu handler and makes sure its payload | 11 3. Listens for a message from context menu handler and makes sure its payload |
12 matches the random text from the test file. | 12 matches the random text from the test file. |
13 */ | 13 */ |
14 | 14 |
15 var cleanupError = 'Got unexpected error while cleaning up test directory.'; | 15 var cleanupError = 'Got unexpected error while cleaning up test directory.'; |
16 | 16 |
17 // Class specified by the client runnig the TestRunner. | 17 // Class specified by the client runnig the TestRunner. |
18 // |expectedTasks| should contain list of actions defined for txt files defined | 18 // |expectedTasks| should contain list of actions defined for abc files defined |
19 // by filesystem_handler part of the test. | 19 // by filesystem_handler part of the test. |
20 // |fileVerifierFunction| method that will verify test results received from the | 20 // |fileVerifierFunction| method that will verify test results received from the |
21 // filesystem_handler part of the test. | 21 // filesystem_handler part of the test. |
22 // The method will be passed received fileEntry object, original file | 22 // The method will be passed received fileEntry object, original file |
23 // content, file content received from filesystem_handler and callback | 23 // content, file content received from filesystem_handler and callback |
24 // function that will expect error object as its argument (or undefined on | 24 // function that will expect error object as its argument (or undefined on |
25 // success). | 25 // success). |
26 var TestExpectations = function(expectedTasks, fileVerifierFunction) { | 26 var TestExpectations = function(expectedTasks, fileVerifierFunction) { |
27 this.fileText_ = undefined; | 27 this.fileText_ = undefined; |
28 this.file_ = undefined; | 28 this.file_ = undefined; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 this.fileCreator_.init(fs, this.onFileCreatorInit_.bind(this), | 116 this.fileCreator_.init(fs, this.onFileCreatorInit_.bind(this), |
117 this.errorCallback_.bind(this)); | 117 this.errorCallback_.bind(this)); |
118 }; | 118 }; |
119 | 119 |
120 TestRunner.prototype.onFileCreatorInit_ = function() { | 120 TestRunner.prototype.onFileCreatorInit_ = function() { |
121 var self = this; | 121 var self = this; |
122 this.fileCreator_.createFile('.log', | 122 this.fileCreator_.createFile('.log', |
123 function(file, text) { | 123 function(file, text) { |
124 self.fileCreator_.createFile('.tXt', | 124 self.fileCreator_.createFile('.aBc', |
125 self.onFileCreated_.bind(self), | 125 self.onFileCreated_.bind(self), |
126 self.errorCallback_.bind(self)); | 126 self.errorCallback_.bind(self)); |
127 }, | 127 }, |
128 this.errorCallback_.bind(this)); | 128 this.errorCallback_.bind(this)); |
129 }; | 129 }; |
130 | 130 |
131 TestRunner.prototype.onFileCreated_ = function(file, text) { | 131 TestRunner.prototype.onFileCreated_ = function(file, text) { |
132 // Start | 132 // Start |
133 console.log('Get registered tasks now...'); | 133 console.log('Get registered tasks now...'); |
134 this.expectations_.setFileAndFileText(file, text); | 134 this.expectations_.setFileAndFileText(file, text); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (!error) { | 211 if (!error) { |
212 sendResponse({success: true}); | 212 sendResponse({success: true}); |
213 this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), | 213 this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), |
214 this.reportFail_.bind(this, | 214 this.reportFail_.bind(this, |
215 cleanupError)); | 215 cleanupError)); |
216 } else { | 216 } else { |
217 sendResponse({success: false}); | 217 sendResponse({success: false}); |
218 this.errorCallback_(error); | 218 this.errorCallback_(error); |
219 } | 219 } |
220 }; | 220 }; |
OLD | NEW |