OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Extension ID of Files.app. | 8 * Extension ID of Files.app. |
9 * @type {string} | 9 * @type {string} |
10 * @const | 10 * @const |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 return repeatUntil(function() { | 312 return repeatUntil(function() { |
313 return callRemoteTestUtil('getExecutedTasks', windowId, []). | 313 return callRemoteTestUtil('getExecutedTasks', windowId, []). |
314 then(function(executedTasks) { | 314 then(function(executedTasks) { |
315 if (executedTasks.indexOf(taskId) === -1) | 315 if (executedTasks.indexOf(taskId) === -1) |
316 return pending('Executed task is %j', executedTasks); | 316 return pending('Executed task is %j', executedTasks); |
317 }); | 317 }); |
318 }); | 318 }); |
319 } | 319 } |
320 | 320 |
321 /** | 321 /** |
| 322 * Adds check of chrome.test to the end of the given promise. |
| 323 * @param {Promise} promise Promise. |
| 324 */ |
| 325 function testPromise(promise) { |
| 326 promise.then(function() { |
| 327 return new Promise(checkIfNoErrorsOccured); |
| 328 }).then(chrome.test.callbackPass(function() { |
| 329 // The callbacPass is necessary to avoid prematurely finishing tests. |
| 330 // Don't put chrome.test.succeed() here to avoid doubled success log. |
| 331 }), function(error) { |
| 332 chrome.test.fail(error.stack || error); |
| 333 }); |
| 334 }; |
| 335 |
| 336 /** |
322 * Sends a fake key down event. | 337 * Sends a fake key down event. |
323 * @param {string} windowId Window ID. | 338 * @param {string} windowId Window ID. |
324 * @param {string} query Query for the target element. | 339 * @param {string} query Query for the target element. |
325 * @param {string} keyIdentifer Key identifier. | 340 * @param {string} keyIdentifer Key identifier. |
326 * @param {boolean} ctrlKey Control key flag. | 341 * @param {boolean} ctrlKey Control key flag. |
327 * @return {Promise} Promise to be fulfilled or rejected depending on the | 342 * @return {Promise} Promise to be fulfilled or rejected depending on the |
328 * result. | 343 * result. |
329 */ | 344 */ |
330 function fakeKeyDown(windowId, query, keyIdentifer, ctrlKey) { | 345 function fakeKeyDown(windowId, query, keyIdentifer, ctrlKey) { |
331 return new Promise(function(fulfill, reject) { | 346 return new Promise(function(fulfill, reject) { |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 chrome.test.runTests([function() { | 804 chrome.test.runTests([function() { |
790 chrome.test.fail(testCaseName + ' is not found.'); | 805 chrome.test.fail(testCaseName + ' is not found.'); |
791 }]); | 806 }]); |
792 return; | 807 return; |
793 } | 808 } |
794 chrome.test.runTests([testcase[testCaseName]]); | 809 chrome.test.runTests([testcase[testCaseName]]); |
795 } | 810 } |
796 ]; | 811 ]; |
797 steps.shift()(); | 812 steps.shift()(); |
798 }); | 813 }); |
OLD | NEW |