OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var nativesPromise = requireAsync('testNatives'); |
| 6 |
| 7 function registerHooks(api) { |
| 8 var chromeTest = api.compiledApi; |
| 9 var apiFunctions = api.apiFunctions; |
| 10 |
| 11 apiFunctions.setHandleRequest('notifyPass', function() { |
| 12 nativesPromise.then(function(natives) { |
| 13 natives.NotifyPass(); |
| 14 }); |
| 15 }); |
| 16 |
| 17 apiFunctions.setHandleRequest('notifyFail', function(message) { |
| 18 nativesPromise.then(function(natives) { |
| 19 natives.NotifyFail(message); |
| 20 }); |
| 21 }); |
| 22 |
| 23 apiFunctions.setHandleRequest('log', function() { |
| 24 nativesPromise.then(function(natives) { |
| 25 natives.Log($Array.join(arguments, ' ')); |
| 26 }); |
| 27 }); |
| 28 |
| 29 } |
| 30 |
| 31 function testDone(runNextTest) { |
| 32 // Use a promise here to allow previous test contexts to be eligible for |
| 33 // garbage collection. |
| 34 Promise.resolve().then(function() { |
| 35 runNextTest(); |
| 36 }); |
| 37 } |
| 38 |
| 39 function exportTests(tests, runTests, exports) { |
| 40 $Array.forEach(tests, function(test) { |
| 41 exports[test.name] = function() { |
| 42 runTests([test]); |
| 43 return true; |
| 44 } |
| 45 }); |
| 46 } |
| 47 |
| 48 exports.registerHooks = registerHooks; |
| 49 exports.testDone = testDone; |
| 50 exports.exportTests = exportTests; |
OLD | NEW |