| 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, response received from filesystem_handler and callback | 23 //     content, response 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 // TODO(tbarzic): Rename this to TestParams, or something similar. | 26 // TODO(tbarzic): Rename this to TestParams, or something similar. | 
| 27 var TestExpectations = function(fileExtension, expectedTasks, | 27 var TestExpectations = function(fileExtension, expectedTasks, | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 79     var taskName = /^.*[|](\w+)$/.exec(tasks[i].taskId)[1]; | 79     var taskName = /^.*[|](\w+)$/.exec(tasks[i].taskId)[1]; | 
| 80     var patterns = tasks[i].patterns; | 80     var patterns = tasks[i].patterns; | 
| 81     var expectedPatterns = this.expectedTasks_[taskName]; | 81     var expectedPatterns = this.expectedTasks_[taskName]; | 
| 82     if (!expectedPatterns) { | 82     if (!expectedPatterns) { | 
| 83       errorCallback({message: 'Wrong task from getFileTasks(): ' + task_name}); | 83       errorCallback({message: 'Wrong task from getFileTasks(): ' + task_name}); | 
| 84       return; | 84       return; | 
| 85     } | 85     } | 
| 86     patterns = patterns.sort(); | 86     patterns = patterns.sort(); | 
| 87     expectedPatterns = expectedPatterns.sort(); | 87     expectedPatterns = expectedPatterns.sort(); | 
| 88     for (var j = 0; j < patterns.length; ++j) { | 88     for (var j = 0; j < patterns.length; ++j) { | 
| 89       if (patterns[j] != expectedPatterns[j]) { | 89       var translatedPattern = expectedPatterns[j].replace( | 
|  | 90           /^filesystem:/, "chrome-extension://*/"); | 
|  | 91       if (patterns[j] != translatedPattern) { | 
| 90         errorCallback({message: 'Wrong patterns set for task ' + | 92         errorCallback({message: 'Wrong patterns set for task ' + | 
| 91                                 taskName + '. ' + | 93                                 taskName + '. ' + | 
| 92                                 'Got: ' + patterns + | 94                                 'Got: ' + patterns + | 
| 93                                 ' expected: ' + expectedPatterns}); | 95                                 ' expected: ' + expectedPatterns}); | 
| 94         return; | 96         return; | 
| 95       } | 97       } | 
| 96     } | 98     } | 
| 97   } | 99   } | 
| 98   successCallback(tasks); | 100   successCallback(tasks); | 
| 99 }; | 101 }; | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 224   if (!error) { | 226   if (!error) { | 
| 225     sendResponse({success: true}); | 227     sendResponse({success: true}); | 
| 226     this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), | 228     this.fileCreator_.cleanupAndEndTest(this.reportSuccess_.bind(this), | 
| 227                                         this.reportFail_.bind(this, | 229                                         this.reportFail_.bind(this, | 
| 228                                                               cleanupError)); | 230                                                               cleanupError)); | 
| 229   } else { | 231   } else { | 
| 230     sendResponse({success: false}); | 232     sendResponse({success: false}); | 
| 231     this.errorCallback_(error); | 233     this.errorCallback_(error); | 
| 232   } | 234   } | 
| 233 }; | 235 }; | 
| OLD | NEW | 
|---|