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. |
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 running the TestRunner. |
18 // |expectedTasks| should contain list of actions defined for abc 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; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 var taskName = /^.*[|](\w+)$/.exec(tasks[i].taskId)[1]; | 72 var taskName = /^.*[|](\w+)$/.exec(tasks[i].taskId)[1]; |
73 var patterns = tasks[i].patterns; | 73 var patterns = tasks[i].patterns; |
74 var expectedPatterns = this.expectedTasks_[taskName]; | 74 var expectedPatterns = this.expectedTasks_[taskName]; |
75 if (!expectedPatterns) { | 75 if (!expectedPatterns) { |
76 errorCallback({message: 'Wrong task from getFileTasks(): ' + task_name}); | 76 errorCallback({message: 'Wrong task from getFileTasks(): ' + task_name}); |
77 return; | 77 return; |
78 } | 78 } |
79 patterns = patterns.sort(); | 79 patterns = patterns.sort(); |
80 expectedPatterns = expectedPatterns.sort(); | 80 expectedPatterns = expectedPatterns.sort(); |
81 for (var j = 0; j < patterns.length; ++j) { | 81 for (var j = 0; j < patterns.length; ++j) { |
82 if (patterns[j] != expectedPatterns[j]) { | 82 var translatedPattern = expectedPatterns[j].replace( |
| 83 /^filesystem:/, "chrome-extension://*/"); |
| 84 if (patterns[j] != translatedPattern) { |
83 errorCallback({message: 'Wrong patterns set for task ' + | 85 errorCallback({message: 'Wrong patterns set for task ' + |
84 taskName + '. ' + | 86 taskName + '. ' + |
85 'Got: ' + patterns + | 87 'Got: ' + patterns + |
86 ' expected: ' + expectedPatterns}); | 88 ' expected: ' + expectedPatterns}); |
87 return; | 89 return; |
88 } | 90 } |
89 } | 91 } |
90 } | 92 } |
91 successCallback(tasks); | 93 successCallback(tasks); |
92 }; | 94 }; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (!error) { | 213 if (!error) { |
212 sendResponse({success: true}); | 214 sendResponse({success: true}); |
213 this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), | 215 this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), |
214 this.reportFail_.bind(this, | 216 this.reportFail_.bind(this, |
215 cleanupError)); | 217 cleanupError)); |
216 } else { | 218 } else { |
217 sendResponse({success: false}); | 219 sendResponse({success: false}); |
218 this.errorCallback_(error); | 220 this.errorCallback_(error); |
219 } | 221 } |
220 }; | 222 }; |
OLD | NEW |