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

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: rebase 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 apiFunctions.setHandleRequest('runWithModuleSystem', function(callback) {
30 throw new Error('Not implemented');
31 });
32
33 apiFunctions.setHandleRequest('getApiDefinitions', function() {
34 throw new Error('Not implemented');
35 });
36
37 apiFunctions.setHandleRequest('getApiFeatures', function() {
38 throw new Error('Not implemented');
39 });
40
41 apiFunctions.setHandleRequest('isProcessingUserGesture', function() {
42 throw new Error('Not implemented');
43 });
44
45 apiFunctions.setHandleRequest('runWithUserGesture', function(callback) {
46 throw new Error('Not implemented');
47 });
48
49 apiFunctions.setHandleRequest('runWithoutUserGesture', function(callback) {
50 throw new Error('Not implemented');
51 });
52
53 apiFunctions.setHandleRequest('setExceptionHandler', function(callback) {
54 chromeTest.assertEq(typeof(callback), 'function');
55 uncaughtExceptionHandler.setHandler(callback);
56 });
57 }
58
59 function testDone(runNextTest) {
60 // Use a promise here to allow previous test contexts to be eligible for
61 // garbage collection.
62 Promise.resolve().then(function() {
63 runNextTest();
64 });
65 }
66
67 function exportTests(tests, runTests, exports) {
68 $Array.forEach(tests, function(test) {
69 exports[test.name] = function() {
70 runTests([test]);
71 return true;
72 }
73 });
74 }
75
76 exports.registerHooks = registerHooks;
77 exports.testDone = testDone;
78 exports.exportTests = exportTests;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698