diff options
Diffstat (limited to 'ui/file_manager/integration_tests/test_util.js')
-rw-r--r-- | ui/file_manager/integration_tests/test_util.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ui/file_manager/integration_tests/test_util.js b/ui/file_manager/integration_tests/test_util.js index 2b586a6..2db86ff 100644 --- a/ui/file_manager/integration_tests/test_util.js +++ b/ui/file_manager/integration_tests/test_util.js @@ -27,6 +27,36 @@ function wait(time) { } /** + * Verifies if there are no Javascript errors in any of the app windows. + * @param {function()} Completion callback. + */ +function checkIfNoErrorsOccuredOnApp(app, callback) { + var countPromise = app.callRemoteTestUtil('getErrorCount', null, []); + countPromise.then(function(count) { + chrome.test.assertEq(0, count, 'The error count is not 0.'); + callback(); + }); +} + +/** + * Adds check of chrome.test to the end of the given promise. + * @param {Promise} promise Promise. + */ +function testPromiseAndApps(promise, apps) { + promise.then(function() { + return Promise.all( + apps.map(function(app) { + return new Promise(checkIfNoErrorsOccuredOnApp.bind(null, app)); + })); + }).then(chrome.test.callbackPass(function() { + // The callbacPass is necessary to avoid prematurely finishing tests. + // Don't put chrome.test.succeed() here to avoid doubled success log. + }), function(error) { + chrome.test.fail(error.stack || error); + }); +}; + +/** * Interval milliseconds between checks of repeatUntil. * @type {number} * @const |