Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: extensions/test/data/unit_test_environment_specific_bindings.js

Issue 399363002: Add support for writing unit tests for Mojo-backed apps/extensions APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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;
OLDNEW
« no previous file with comments | « extensions/test/data/api_test_base_unittest.js ('k') | extensions/test/extensions_unittests_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698